home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / visualarts-1.0.lha / VisualArts-1.0 / Demo / Source / Funny.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-09  |  8.3 KB  |  351 lines

  1. /* C code generated by:                            */
  2. /* Visual Arts Version 1.0                        */
  3. /* Copyright 1994 Danny Y. Wong  All rights reserved            */
  4. /* Calgary, Alberta (CANADA)                                    */
  5.  
  6.  
  7. struct VAobject {
  8.   struct Window *va_Window;
  9.   struct Gadget *va_Gadget;
  10.   struct IntuiMessage *va_IntuiMsg;
  11.   ULONG va_Flags;
  12.   APTR va_UserData;
  13. };
  14.  
  15. #define GetString(gad)    (((struct StringInfo *)gad->SpecialInfo)->Buffer)
  16. #define GetUndoString(gad)    (((struct StringInfo *)gad->SpecialInfo)->UndoBuffer)
  17. #define GetNumber(gad)    (((struct StringInfo *)gad->SpecialInfo)->LongInt)
  18.  
  19. extern int GetFileName(BOOL save, struct Window *window, char *title, char *path, char *dir, char *file);
  20. int  InitTempArea(void);
  21. extern void FunnyDrawCircles(struct Window *Wind);
  22. extern void FunnyDrawRects(struct Window *Wind);
  23. extern void DrawBox(struct Window *Wind, int Left, int Top, int Wid, int Hi, UBYTE APen, short Pattern );
  24. extern void DrawFBox(struct Window *Wind, int Left, int Top, int Wid, int Hi, UBYTE APen, short Pattern, UBYTE Outline, short Fill );
  25. extern void DrawLine(struct Window *Wind, int Left, int Top, int Wid, int Hi, UBYTE APen, short Pattern );
  26. extern void FunnyDrawLine(struct Window *Wind);
  27. extern void SetRPortFill(struct Window *Wind, short Type);
  28. extern void DrawNCircle(struct Window *Wind, int Left, int Top, int Right, int Bottom, UBYTE APen);
  29. extern void DrawFCircle(struct Window *Wind, int Left, int Top, int Right, int Bottom, UBYTE APen, short Pattern, UBYTE Outline, short Fill );
  30. extern void ButtonSelected(struct Window *wind, struct Gadget *gad);
  31. extern struct Window  *FunnyWnd;
  32. extern APTR   VisualInfo;
  33. extern struct Screen *Scr;
  34. extern struct Gadget *FunnyGadgets[3];
  35. extern int AddNewNode(struct List *list, char name[255]);
  36. extern int DeleteNewNode(struct List *list, char name[255]);
  37. extern struct List *GetNewList(void);
  38. extern struct NameNode *FindNodeName(struct List *list, char name[255]);
  39. extern void FreeList(struct List *list);
  40.  
  41. extern void CreateFunnyLists(void);
  42. struct NameNode
  43. {
  44.   struct Node nn_Node;
  45.   UBYTE nn_Data[255];
  46. };
  47. extern UBYTE *WantedLabels[];
  48.  
  49. ULONG LinePatterns[6] = { 0xffff, 0x0cccc, 0xaaaa, 0x8888, 0x3333, 0xffff};
  50.  
  51. struct List *FunnyLists[1];
  52.  
  53. void FunnyDrawRects(struct Window *Wind)
  54. {
  55.   UWORD offsetx = Scr->WBorLeft;
  56.   UWORD offsety = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  57.  
  58.   DrawBevelBox(Wind->RPort, 10+offsetx, 4+offsety, 141, 117, 
  59.     (GT_VisualInfo), VisualInfo, TAG_DONE);
  60.   SetDrPt(Wind->RPort, 0xFFFF);
  61.   SetOPen(Wind->RPort, 0);
  62.   SetAfPt(Wind->RPort, NULL, 0);
  63. }
  64.  
  65. void FunnyDrawCircles(struct Window *Wind)
  66. {
  67.   DrawFCircle(Wind, 50, 44, 18, 6, 1, 0, 1, 0 );
  68.   DrawFCircle(Wind, 106, 44, 18, 6, 1, 0, 1, 0 );
  69.   DrawFCircle(Wind, 100, 44, 7, 3, 2, 0, 2, 0 );
  70.   DrawFCircle(Wind, 58, 44, 7, 3, 2, 0, 2, 0 );
  71. }
  72.  
  73. void FunnyDrawLine(struct Window *Wind)
  74. {
  75.   DrawLine(Wind, 73, 50, 58, 66, 1, 0 );
  76.   DrawLine(Wind, 60, 66, 101, 66, 1, 0 );
  77.   DrawLine(Wind, 85, 50, 101, 66, 1, 0 );
  78.   DrawLine(Wind, 41, 74, 119, 74, 1, 0 );
  79.   DrawLine(Wind, 35, 27, 65, 33, 1, 0 );
  80.   DrawLine(Wind, 92, 32, 128, 27, 1, 0 );
  81.   DrawLine(Wind, 38, 12, 48, 22, 1, 0 );
  82.   DrawLine(Wind, 60, 12, 61, 21, 1, 0 );
  83.   DrawLine(Wind, 76, 22, 78, 10, 1, 0 );
  84.   DrawLine(Wind, 89, 22, 93, 11, 1, 0 );
  85.   DrawLine(Wind, 102, 22, 110, 11, 1, 0 );
  86.   DrawLine(Wind, 125, 10, 117, 22, 1, 0 );
  87.   DrawLine(Wind, 65, 83, 96, 83, 1, 0 );
  88.   DrawLine(Wind, 17, 91, 141, 91, 1, 3 );
  89. }
  90.  
  91. struct AreaInfo areaInfo={0};
  92. struct TmpRas Temprast;
  93. PLANEPTR AreaPlane=NULL;
  94. WORD areaBuffer[4000];
  95.  
  96.  
  97. UWORD AreaPattern1[] =
  98. {
  99.   0x1111, 0x2222,
  100.   0x4444, 0x8888,
  101.   0x1111, 0x2222,
  102.   0x4444, 0x8888,
  103.   0x1111, 0x2222,
  104.   0x4444, 0x8888,
  105.   0x1111, 0x2222,
  106.   0x4444, 0x8888
  107. };
  108.  
  109. UWORD AreaPattern2[] =
  110. {
  111.   0x8080, 0x8080,
  112.   0x8080, 0x8080
  113. };
  114.  
  115. UWORD AreaPattern3[] =
  116. {
  117.   0x3333, 0x3333,
  118.   0x3333, 0xffff,
  119.   0x3333, 0x3333,
  120.   0x3333, 0xffff,
  121.   0x3333, 0x3333,
  122.   0x3333, 0xffff,
  123.   0x3333, 0x3333,
  124.   0x3333, 0xffff
  125. };
  126.  
  127. UWORD AreaPattern4[] =
  128. {
  129.   0x8888, 0x8888,
  130.   0x8888, 0x8888,
  131.   0x8888, 0x8888,
  132.   0x8888, 0x8888,
  133.   0x8888, 0x8888,
  134.   0x8888, 0x8888,
  135.   0x8888, 0x8888,
  136.   0x8888, 0x8888
  137. };
  138.  
  139. UWORD AreaPattern5[] =
  140. {
  141.   0xffff, 0x0060,
  142.   0x0060, 0x0060,
  143.   0xffff, 0x6000,
  144.   0x6000, 0x6000,
  145.   0xffff, 0x0060,
  146.   0x0060, 0x0060,
  147.   0xffff, 0x6000,
  148.   0x6000, 0x6000
  149. };
  150.  
  151. UWORD AreaPattern6[] =
  152. {
  153.   0x0000, 0x0000,
  154.   0x0000, 0xffff,
  155.   0x0000, 0x0000,
  156.   0x0000, 0xffff,
  157.   0x0000, 0x0000,
  158.   0x0000, 0xffff,
  159.   0x0000, 0x0000,
  160.   0x0000, 0xffff
  161. };
  162.  
  163. UWORD AreaPattern7[] =
  164. {
  165.   0x4040, 0x0000,
  166.   0x1010, 0x0000
  167. };
  168.  
  169. UWORD AreaPattern8[] =
  170. {
  171.   0xffff, 0xffff
  172. };
  173.  
  174. UWORD AreaPattern9[] =
  175. {
  176.   0xaaaa, 0x5555
  177. };
  178.  
  179.  
  180. void SetRPortFill(struct Window *Wind, short Type)
  181. {
  182.   switch(Type)
  183.   {
  184.      case 1:
  185.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern1, 4);
  186.         break;
  187.      case 2:
  188.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern2, 2);
  189.         break;
  190.      case 3:
  191.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern3, 4);
  192.         break;
  193.      case 4:
  194.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern4, 4);
  195.         break;
  196.      case 5:
  197.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern5, 4);
  198.         break;
  199.      case 6:
  200.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern6, 4);
  201.         break;
  202.      case 7:
  203.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern7, 2);
  204.         break;
  205.      case 8:
  206.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern8, 1);
  207.         break;
  208.      case 9:
  209.         SetAfPt(Wind->RPort, (UWORD *)&AreaPattern9, 1);
  210.         break;
  211.      default:
  212.         break;
  213.   }
  214. }
  215.  
  216. int InitTempArea(void)
  217. {
  218.   register UWORD i;
  219.  
  220.   for (i=0; i<4000; i++)
  221.     areaBuffer[i]=0;
  222.   InitArea(&areaInfo, areaBuffer, 800L);
  223.   AreaPlane = AllocRaster(640, 200);
  224.   if (AreaPlane == NULL)
  225.       return(1L);
  226.   InitTmpRas(&Temprast, AreaPlane, (long)RASSIZE(640, 200));
  227.       return(0L);
  228. }
  229.  
  230.  
  231. void DrawLine(struct Window *Wind, int Left, int Top, int Wid, int Hi, UBYTE APen, short Pattern )
  232. {
  233.   UWORD offsetx = Scr->WBorLeft;
  234.   UWORD offsety = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  235.  
  236.     SetAPen(Wind->RPort, APen);
  237.     SetDrPt(Wind->RPort, LinePatterns[Pattern]);
  238.     Move(Wind->RPort, Left+offsetx, Top+offsety);
  239.     Draw(Wind->RPort, Wid+offsetx, Hi+offsety);
  240. }
  241.  
  242. void DrawFCircle(struct Window *Wind, int Left, int Top, int Right, int Bottom, UBYTE APen, short Pattern, UBYTE Outline, short Fill)
  243. {
  244.   UWORD offsetx = Scr->WBorLeft;
  245.   UWORD offsety = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  246.  
  247.   SetAPen(Wind->RPort, APen);
  248.   SetOPen(Wind->RPort, Outline);
  249.   SetDrPt(Wind->RPort, LinePatterns[Pattern]);
  250.   SetRPortFill(Wind, Fill);
  251.   AreaEllipse(Wind->RPort, Left+offsetx, Top+offsety, Right, Bottom);
  252.   AreaEnd(Wind->RPort);
  253. }
  254.  
  255. struct List *GetNewList(void)
  256. {
  257.    struct List *list;
  258.  
  259.    if (!( list = AllocMem(sizeof(struct List), MEMF_CLEAR)))
  260.        return(NULL);
  261.    NewList(list);
  262.    return(list);
  263. }
  264.  
  265. int AddNewNode(struct List *list, char name[255])
  266. {
  267.   struct NameNode *namenode;
  268.  
  269.   if (!( namenode = AllocMem(sizeof(struct NameNode), MEMF_CLEAR)))
  270.       return(1L);
  271.   strcpy(namenode->nn_Data, name);
  272.   namenode->nn_Node.ln_Name=namenode->nn_Data;
  273.   namenode->nn_Node.ln_Type=0;
  274.   namenode->nn_Node.ln_Pri=0;
  275.   AddTail((struct List *)list, (struct Node *)namenode);
  276.   return(0L);
  277. }
  278.  
  279. int DeleteNode(struct List *list, char name[255])
  280. {
  281.   struct Node *node;
  282.  
  283.   node=FindName(list, name);
  284.   if (node)
  285.   {
  286.       Remove(node);
  287.       FreeMem((struct NameNode *)node, sizeof(struct NameNode));
  288.       return(0L);
  289.   }
  290.   return(1L);
  291. }
  292.  
  293. struct NameNode *FindNodeName(struct List *list, char name[255])
  294. {
  295.   struct NameNode *worknode, *nextnode;
  296.  
  297.   worknode=(struct NameNode *)(list->lh_Head);
  298.   while (nextnode=(struct NameNode *)(worknode->nn_Node.ln_Succ))
  299.   {
  300.     if (strcmp(worknode->nn_Data, name) == 0)
  301.        return(worknode);
  302.      worknode=nextnode;
  303.   }
  304.   return(NULL);
  305. }
  306.  
  307. void FreeList(struct List *list)
  308. {
  309.   struct NameNode *worknode, *nextnode;
  310.  
  311.   worknode=(struct NameNode *)(list->lh_Head);
  312.   while (nextnode=(struct NameNode *)(worknode->nn_Node.ln_Succ))
  313.   {
  314.      FreeMem(worknode, sizeof(struct NameNode));
  315.      worknode=nextnode;
  316.   }
  317.   FreeMem(list, sizeof(struct List));
  318.   list=NULL;
  319. }
  320.  
  321. void CreateFunnyLists(void)
  322. {
  323.   short i;
  324.  
  325.   i=0;
  326.   while (WantedLabels[i])
  327.      AddNewNode(FunnyLists[0], WantedLabels[i++]);
  328.  
  329. }
  330.  
  331.              /* gadget functions */
  332.  
  333. int okObj(struct VAobject VAObject)
  334. {
  335.   return(-1L);
  336. }
  337. /*    Button  OK         */ 
  338.  
  339. int ok1Obj(struct VAobject VAObject)
  340. {
  341.   return(-1L);
  342. }
  343. /*    Button  Cancel         */ 
  344.  
  345. int wantedObj(struct VAobject VAObject)
  346. {
  347.   return(1L);
  348. }
  349. /*    ListView           */ 
  350.  
  351.