home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 568b.lha / PowerSource_v3.0 / source.lzh / source / setmenus.c < prev    next >
C/C++ Source or Header  |  1991-09-15  |  12KB  |  283 lines

  1. /*----------------------------------------------------------------------*
  2.   setmenus.c Version 3.0 -  © Copyright 1990-91 Jaba Development
  3.  
  4.   Author : Jan van den Baard
  5.   Purpose: set the menus according to the screen depth and edit type
  6.            in the main window
  7.  *----------------------------------------------------------------------*/
  8.  
  9. static struct IntuiText fpen_text[32];
  10. static struct IntuiText bpen_text[32];
  11. static struct MenuItem  fpen_item[32];
  12. static struct MenuItem  bpen_item[32];
  13.  
  14. static struct IntuiText pen_text =
  15.  { 0,0,JAM2,20,1,NULL,(UBYTE *)"      ",NULL
  16.  };
  17. static struct MenuItem pen_item =
  18.  { NULL,4,0,68,10,HIGHBOX+CHECKIT+ITEMENABLED+ITEMTEXT,
  19.    NULL,NULL,NULL,0,NULL,NULL
  20.  };
  21.  
  22. UBYTE wbb[20];
  23.  
  24. static struct IntuiText SubText[] =
  25. { 0,1,JAM1,0,1,NULL,(UBYTE *)"C", NULL,
  26.   0,1,JAM1,0,1,NULL,(UBYTE *)"Assembler",NULL,
  27.   0,1,JAM1,0,1,NULL,(UBYTE *)"Add a text      F6",NULL,
  28.   0,1,JAM1,0,1,NULL,(UBYTE *)"Modify a text",NULL,
  29.   0,1,JAM1,0,1,NULL,(UBYTE *)"Delete a text",NULL,
  30.   0,1,JAM1,0,1,NULL,(UBYTE *)"Move a text",NULL,
  31.   0,1,JAM1,0,1,NULL,(UBYTE *)"Get Gadget Image  F7",NULL,
  32.   0,1,JAM1,0,1,NULL,(UBYTE *)"Get Select Image  F8",NULL,
  33.   0,1,JAM1,0,1,NULL,(UBYTE *)"Delete Images", NULL,
  34.   0,1,JAM1,0,1,NULL,(UBYTE *)"Image Bank       TAB",NULL
  35.  };
  36.  
  37. static struct IntuiText ItemText[] =
  38. { 0,1,JAM1,0,1,NULL,(UBYTE *)"About",NULL,
  39.   0,1,JAM1,0,1,NULL,(UBYTE *)"New", NULL,
  40.   0,1,JAM1,0,1,NULL,(UBYTE *)"Load",NULL,
  41.   0,1,JAM1,0,1,NULL,(UBYTE *)"Save",NULL,
  42.   0,1,JAM1,0,1,NULL,(UBYTE *)"Generate Source   »",NULL,
  43.   0,1,JAM1,0,1,NULL,(UBYTE *)"Preferences",NULL,
  44.   0,1,JAM1,0,1,NULL,(UBYTE *)&wbb,NULL,
  45.   0,1,JAM1,0,1,NULL,(UBYTE *)"Quit",NULL,
  46.   0,1,JAM1,0,1,NULL,(UBYTE *)"Move a gadget         F1",NULL,
  47.   0,1,JAM1,0,1,NULL,(UBYTE *)"Size a gadget         F2",NULL,
  48.   0,1,JAM1,0,1,NULL,(UBYTE *)"Copy a gadget         F3",NULL,
  49.   0,1,JAM1,0,1,NULL,(UBYTE *)"Delete a gadget       F4",NULL,
  50.   0,1,JAM1,0,1,NULL,(UBYTE *)"Edit a gadget         F5",NULL,
  51.   0,1,JAM1,0,1,NULL,(UBYTE *)"Gadget text            »",NULL,
  52.   0,1,JAM1,0,1,NULL,(UBYTE *)"IFF Image render       »",NULL,
  53.   0,1,JAM1,0,1,NULL,(UBYTE *)"Load (IFF) ColorMap   F9",NULL,
  54.   0,1,JAM1,0,1,NULL,(UBYTE *)"Edit ColorMap        F10",NULL,
  55.   0,1,JAM1,0,1,NULL,(UBYTE *)"Refresh all gadgets HELP",NULL,
  56.   0,1,JAM1,0,1,NULL,(UBYTE *)"OS-2 Border colors      ",NULL
  57.  };
  58.  
  59. static struct MenuItem SubItems[] =
  60. { &SubItems[1],150,0,108,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  61.   0,(APTR)&SubText[0],NULL,'C',NULL,NULL,
  62.   NULL,150,10,108,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  63.   0,(APTR)&SubText[1],NULL,'A',NULL,NULL,
  64.  
  65.   &SubItems[3],80,0,145,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  66.   0,(APTR)&SubText[2],NULL,NULL,NULL,NULL,
  67.   &SubItems[4],80,10,145,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  68.   0,(APTR)&SubText[3],NULL,'1',NULL,NULL,
  69.   &SubItems[5],80,20,145,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  70.   0,(APTR)&SubText[4],NULL,'2',NULL,NULL,
  71.   NULL,80,30,145,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  72.   0,(APTR)&SubText[5],NULL,'3',NULL,NULL,
  73.  
  74.   &SubItems[7],60,0,164,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  75.   0,(APTR)&SubText[6],NULL,NULL,NULL,NULL,
  76.   &SubItems[8],60,10,164,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  77.   0,(APTR)&SubText[7],NULL,NULL,NULL,NULL,
  78.   &SubItems[9],60,20,164,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  79.   0,(APTR)&SubText[8],NULL,'4',NULL,NULL,
  80.   NULL,60,30,164,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  81.   0,(APTR)&SubText[9],NULL,NULL,NULL,NULL
  82.  };
  83.  
  84. static struct MenuItem Items[] =
  85. { &Items[1],0,0,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  86.   0,(APTR)&ItemText[0],NULL,'?',NULL,NULL,
  87.   &Items[2],0,10,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  88.   0,(APTR)&ItemText[1],NULL,'N',NULL,NULL,
  89.   &Items[3],0,20,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  90.   0,(APTR)&ItemText[2],NULL,'L',NULL,NULL,
  91.   &Items[4],0,30,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  92.   0,(APTR)&ItemText[3],NULL,'S',NULL,NULL,
  93.   &Items[5],0,40,159,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  94.   0,(APTR)&ItemText[4],NULL,0,&SubItems[0],NULL,
  95.   &Items[6],0,50,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  96.   0,(APTR)&ItemText[5],NULL,'P',NULL,NULL,
  97.   &Items[7],0,60,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  98.   0,(APTR)&ItemText[6],NULL,'W',NULL,NULL,
  99.   NULL,0,70,159,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  100.   0,(APTR)&ItemText[7],NULL,'Q',NULL,NULL,
  101.  
  102.   &Items[9],0,0,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  103.   0,(APTR)&ItemText[8],NULL,NULL,NULL,NULL,
  104.   &Items[10],0,10,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  105.   0,(APTR)&ItemText[9],NULL,NULL,NULL,NULL,
  106.   &Items[11],0,20,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  107.   0,(APTR)&ItemText[10],NULL,NULL,NULL,NULL,
  108.   &Items[12],0,30,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  109.   0,(APTR)&ItemText[11],NULL,NULL,NULL,NULL,
  110.   &Items[13],0,40,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  111.   0,(APTR)&ItemText[12],NULL,NULL,NULL,NULL,
  112.   &Items[14],0,50,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  113.   0,(APTR)&ItemText[13],NULL,NULL,&SubItems[2],NULL,
  114.   &Items[15],0,60,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  115.   0,(APTR)&ItemText[14],NULL,NULL,&SubItems[6],NULL,
  116.   &Items[16],0,70,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  117.   0,(APTR)&ItemText[15],NULL,NULL,NULL,NULL,
  118.   &Items[17],0,80,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  119.   0,(APTR)&ItemText[16],NULL,NULL,NULL,NULL,
  120.   &Items[18],0,90,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  121.   0,(APTR)&ItemText[17],NULL,NULL,NULL,NULL,
  122.   NULL,0,100,196,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  123.   0,(APTR)&ItemText[18],NULL,'5',NULL,NULL,
  124.  };
  125.  
  126. struct Menu Titles[] =
  127.  { &Titles[1],0,0,70,10,MENUENABLED,(BYTE *)"Project",&Items[0],0,0,0,0,
  128.    &Titles[2],70,0,70,10,MENUENABLED,(BYTE *)"Gadgets",&Items[8],0,0,0,0,
  129.    &Titles[3],140,0,46,10,MENUENABLED,(BYTE *)"FPen",NULL,0,0,0,0,
  130.    NULL,186,0,46,10,MENUENABLED,(BYTE *)"BPen",NULL,0,0,0,0
  131.  };
  132.  
  133. static struct IntuiText TTT[] =
  134.  { 0,1,JAM1,0,1,NULL,(UBYTE *)"Add a text",NULL,
  135.    0,1,JAM1,0,1,NULL,(UBYTE *)"Modify a text",NULL,
  136.    0,1,JAM1,0,1,NULL,(UBYTE *)"Delete a text",NULL,
  137.    0,1,JAM1,0,1,NULL,(UBYTE *)"Move a text",NULL
  138.  };
  139.  
  140. static struct IntuiText WindowText[] =
  141.  { 0,1,JAM1,0,1,NULL,(UBYTE *)"Window                 »",NULL,
  142.    0,1,JAM1,0,1,NULL,(UBYTE *)"Edit Flags",NULL,
  143.    0,1,JAM1,0,1,NULL,(UBYTE *)"Edit IDCMP",NULL,
  144.    0,1,JAM1,0,1,NULL,(UBYTE *)"Set BackFill",NULL,
  145.    0,1,JAM1,0,1,NULL,(UBYTE *)"Edit Menus",NULL,
  146.    0,1,JAM1,0,1,NULL,(UBYTE *)"Set Labels",NULL
  147.  };
  148.  
  149. static struct MenuItem WindowSubs[] =
  150.  { &WindowSubs[1],90,0,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  151.    0,(APTR)&WindowText[1],NULL,'F',NULL,NULL,
  152.    &WindowSubs[2],90,10,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  153.    0,(APTR)&WindowText[2],NULL,'I',NULL,NULL,
  154.    &WindowSubs[3],90,20,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  155.    0,(APTR)&WindowText[3],NULL,'B',NULL,NULL,
  156.    &WindowSubs[4],90,30,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  157.    0,(APTR)&TTT[0],NULL,'6',NULL,NULL,
  158.    &WindowSubs[5],90,40,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  159.    0,(APTR)&TTT[1],NULL,'7',NULL,NULL,
  160.    &WindowSubs[6],90,50,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  161.    0,(APTR)&TTT[2],NULL,'8',NULL,NULL,
  162.    NULL,90,60,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  163.    0,(APTR)&TTT[3],NULL,'9',NULL,NULL
  164.  };
  165.  
  166. static struct MenuItem WindowItem[] =
  167.  { &WindowItem[1],0,110,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  168.    0,(APTR)&WindowText[0],NULL,NULL,&WindowSubs[0],NULL,
  169.    &WindowItem[2],0,120,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP+COMMSEQ,
  170.    0,(APTR)&WindowText[4],NULL,'E',NULL,NULL,
  171.    NULL,0,130,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP+COMMSEQ,
  172.    0,(APTR)&WindowText[5],NULL,'T',NULL,NULL
  173.  };
  174.  
  175. static struct IntuiText ReqText[] =
  176.  { 0,1,JAM1,0,1,NULL,(UBYTE *)"Requester              »",NULL,
  177.    0,1,JAM1,0,1,NULL,(UBYTE *)"Set BackFill",NULL
  178.  };
  179.  
  180. static struct MenuItem ReqSubs[] =
  181.  { &ReqSubs[1],90,0,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  182.    0,(APTR)&ReqText[1],NULL,'B',NULL,NULL,
  183.    &ReqSubs[2],90,10,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  184.    0,(APTR)&TTT[0],NULL,'6',NULL,NULL,
  185.    &ReqSubs[3],90,20,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  186.    0,(APTR)&TTT[1],NULL,'7',NULL,NULL,
  187.    &ReqSubs[4],90,30,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  188.    0,(APTR)&TTT[2],NULL,'8',NULL,NULL,
  189.    NULL,90,40,142,10,ITEMENABLED+ITEMTEXT+COMMSEQ+HIGHCOMP,
  190.    0,(APTR)&TTT[3],NULL,'9',NULL,NULL
  191.  };
  192.  
  193. static struct MenuItem ReqItem[] =
  194.  { &ReqItem[1],0,110,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP,
  195.    0,(APTR)&ReqText[0],NULL,NULL,&ReqSubs[0],NULL,
  196.    &ReqItem[2],0,120,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP+COMMSEQ,
  197.    0,(APTR)&WindowText[4],NULL,'E',NULL,NULL,
  198.    NULL,0,130,196,10,ITEMENABLED+ITEMTEXT+HIGHCOMP+COMMSEQ,
  199.    0,(APTR)&WindowText[5],NULL,'T',NULL,NULL
  200.  };
  201.  
  202. extern BOOL REQUESTER, WORKBENCH, WBSCREEN;
  203. extern USHORT FrontPen, BackPen;
  204.  
  205. /*
  206.  * set the extra window or requester items
  207.  */
  208. void set_extra_items( struct Window *w )
  209. {
  210.    ClearMenuStrip(w);
  211.    if(REQUESTER == TRUE) Items[18].NextItem = &ReqItem[0];
  212.    else                  Items[18].NextItem = &WindowItem[0];
  213.    SetMenuStrip(w,&Titles[0]);
  214. }
  215.  
  216. /*
  217.  * set up the menu strip for the edit window
  218.  */
  219. void SetMenu( struct Window *window )
  220. {
  221.     register USHORT i;
  222.     SHORT           am_col = (1 << window->WScreen->BitMap.Depth);
  223.     LONG            mutexf = NULL, mutexb = NULL;
  224.  
  225.     for(i = 0;i < am_col; i++) mutexf += (1 << i);
  226.  
  227.     mutexb = mutexf;
  228.  
  229.     for(i = 0; i < 16; i++) {
  230.         fpen_text[i]                 =   pen_text;
  231.         fpen_text[i+16]              =   pen_text;
  232.         fpen_text[i].BackPen         =   i;
  233.         fpen_text[i+16].BackPen      =   i+16;
  234.         bpen_text[i]                 =   fpen_text[i];
  235.         bpen_text[i+16]              =   fpen_text[i+16];
  236.  
  237.         fpen_item[i]                 =   pen_item;
  238.         fpen_item[i+16]              =   pen_item;
  239.         fpen_item[i].ItemFill        =   (APTR)&fpen_text[i];
  240.         fpen_item[i+16].ItemFill     =   (APTR)&fpen_text[i+16];
  241.         fpen_item[i].TopEdge         =   i*10;
  242.         fpen_item[i+16].TopEdge      =   i*10;
  243.         fpen_item[i].LeftEdge        =   -20;
  244.         fpen_item[i+16].LeftEdge     =   50;
  245.         fpen_item[i].MutualExclude   =   mutexf - (1 << i);
  246.         fpen_item[i+16].MutualExclude =  mutexf - (1 << (i+16));
  247.         fpen_item[i].NextItem        =   &fpen_item[i+1];
  248.         fpen_item[i+16].NextItem     =   &fpen_item[i+17];
  249.     }
  250.  
  251.     for(i = 0; i < 16; i++) {
  252.         bpen_item[i]                 =   pen_item;
  253.         bpen_item[i+16]              =   pen_item;
  254.         bpen_item[i].ItemFill        =   (APTR)&bpen_text[i];
  255.         bpen_item[i+16].ItemFill     =   (APTR)&bpen_text[i+16];
  256.         bpen_item[i].TopEdge         =   i*10;
  257.         bpen_item[i+16].TopEdge      =   i*10;
  258.         bpen_item[i].LeftEdge        =   -20;
  259.         bpen_item[i+16].LeftEdge     =   50;
  260.         bpen_item[i].MutualExclude   =   mutexb - (1 << i);
  261.         bpen_item[i+16].MutualExclude =  mutexb - (1 << (i+16));
  262.         bpen_item[i].NextItem        =   &bpen_item[i+1];
  263.         bpen_item[i+16].NextItem     =   &bpen_item[i+17];
  264.     }
  265.  
  266.     bpen_item[BackPen].Flags |= CHECKED;
  267.     fpen_item[FrontPen].Flags |= CHECKED;
  268.     bpen_item[am_col-1].NextItem = NULL;
  269.     fpen_item[am_col-1].NextItem = NULL;
  270.  
  271.     Titles[2].FirstItem = &fpen_item[0];
  272.     Titles[3].FirstItem = &bpen_item[0];
  273.  
  274.     if(WORKBENCH == TRUE) strcpy((char *)&wbb,"Open WorkBench");
  275.     else                  strcpy((char *)&wbb,"Close WorkBench");
  276.  
  277.     if(WBSCREEN)  Items[15].Flags = Items[16].Flags = ITEMTEXT+HIGHCOMP;
  278.     else          Items[15].Flags = Items[16].Flags = ITEMTEXT+HIGHCOMP+ITEMENABLED;
  279.  
  280.     SetMenuStrip(window,&Titles[0]);
  281.     set_extra_items(window);
  282. }
  283.