home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / intuition / menus / menus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  7.2 KB  |  205 lines

  1. /* menus.h -- all the structures needed to make the menus. */
  2. /* Copyright (c) 1990 Commodore-Amiga, Inc.
  3.  *
  4.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  5.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  6.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  7.  * information on the correct usage of the techniques and operating system
  8.  * functions presented in this example.  The source and executable code of
  9.  * this example may only be distributed in free electronic form, via bulletin
  10.  * board or as part of a fully non-commercial and freely redistributable
  11.  * diskette.  Both the source and executable code (including comments) must
  12.  * be included, without modification, in any copy.  This example may not be
  13.  * published in printed form or distributed with any commercial product.
  14.  * However, the programming techniques and support routines set forth in
  15.  * this example may be used in the development of original executable
  16.  * software products for Commodore Amiga computers.
  17.  * All other rights reserved.
  18.  * This example is provided "as-is" and is subject to change; no warranties
  19.  * are made.  All use is at your own risk.  No liability or responsibility
  20.  * is assumed.
  21.  */
  22.  
  23.  
  24. #define   IWIDTH  96
  25. #define   IHEIGHT  8
  26.  
  27. /* Topaz 8, just in case we can't handle the default font */
  28. struct TextAttr TOPAZ80 = 
  29.     {(STRPTR)"topaz.font",TOPAZ_EIGHTY,0,0};
  30.  
  31. /* Preferences Item IntuiText */
  32. struct IntuiText PrefText[] =
  33.     {
  34.        {2,1,JAM2,CHECKWIDTH,1, NULL, " Sound...", NULL},
  35.        {2,1,JAM2,CHECKWIDTH,1, NULL, " Auto Save", NULL},
  36.        {2,1,JAM2,CHECKWIDTH,1, NULL, " Have Your Cake", NULL},
  37.        {2,1,JAM2,CHECKWIDTH,1, NULL, " Eat It Too", NULL}
  38.     };
  39.  
  40. struct MenuItem PrefItem[] =
  41.     {
  42.        /* "Sound..." */
  43.        {&PrefItem[1], 0,  0, IWIDTH, IHEIGHT, 
  44.         ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  45.         (APTR)&PrefText[0], NULL, NULL, NULL, MENUNULL
  46.        },
  47.        /* "Auto Save" (toggle-select, initially selected) */
  48.        {&PrefItem[2], 0, 10, IWIDTH, IHEIGHT, 
  49.         ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|MENUTOGGLE|CHECKED, 0,
  50.         (APTR)&PrefText[1], NULL, NULL, NULL, MENUNULL
  51.        },
  52.        /* "Have Your Cake" (initially selected, excludes "Eat It Too") */
  53.        {&PrefItem[3], 0,  0, IWIDTH, IHEIGHT, 
  54.         ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|CHECKED, 8,
  55.         (APTR)&PrefText[2], NULL, NULL, NULL, MENUNULL
  56.        },
  57.        /* "Eat It Too" (excludes "Have Your Cake") */
  58.        {NULL        , 0,  0, IWIDTH, IHEIGHT, 
  59.         ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT, 4,
  60.         (APTR)&PrefText[3], NULL, NULL, NULL, MENUNULL
  61.        }
  62.     };
  63.  
  64. /* Edit Menu Item IntuiText */
  65. struct IntuiText EditText[] =
  66.     {
  67.        {2,1,JAM2,2,1, NULL, "Undo",  NULL},
  68.        {2,1,JAM2,2,1, NULL, "Cut",   NULL},
  69.        {2,1,JAM2,2,1, NULL, "Copy",  NULL},
  70.        {2,1,JAM2,2,1, NULL, "Paste", NULL},
  71.        {2,1,JAM2,2,1, NULL, "Erase All", NULL}
  72.     };
  73.  
  74. /* Edit Menu Items */
  75. struct MenuItem EditItem[] =
  76.     {
  77.        /* "Undo" MenuItem (key-equivalent: 'Z') */
  78.        {&EditItem[1], 0,  0, IWIDTH, IHEIGHT, 
  79.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  80.         (APTR)&EditText[0], NULL,  'Z', NULL, MENUNULL
  81.        },
  82.        /* "Cut" (key-equivalent: 'X') */
  83.        {&EditItem[2], 0, 10, IWIDTH, IHEIGHT, 
  84.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  85.         (APTR)&EditText[1], NULL,  'X', NULL, MENUNULL
  86.        },
  87.        /* "Copy" (key-equivalent: 'C') */
  88.        {&EditItem[3], 0, 20, IWIDTH, IHEIGHT, 
  89.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  90.         (APTR)&EditText[2], NULL,  'C', NULL, MENUNULL
  91.        },
  92.        /* "Paste" (key-equivalent: 'V') */
  93.        {&EditItem[4], 0, 30, IWIDTH, IHEIGHT, 
  94.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  95.         (APTR)&EditText[3], NULL,  'V', NULL, MENUNULL
  96.        },
  97.        /* "Erase All" (disabled) */
  98.        {NULL,         0, 40, IWIDTH, IHEIGHT, 
  99.         ITEMTEXT|HIGHCOMP, 0,
  100.         (APTR)&EditText[4], NULL, NULL, NULL, MENUNULL
  101.        }
  102.    };
  103.  
  104. /* IntuiText for the Print Sub-Items */
  105. struct IntuiText PrtText[] =
  106.     {
  107.        {2, 1, JAM2,2,1, NULL, "NLQ",   NULL},
  108.        {2, 1, JAM2,2,1, NULL, "Draft", NULL}
  109.     };
  110.  
  111. /* Print Sub-Items */
  112. struct MenuItem PrtItem[] =
  113.     {
  114.        /* "NLQ" */
  115.        {&PrtItem[1], 61,-1, IWIDTH, IHEIGHT, ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  116.         (APTR)&PrtText[0], NULL, NULL, NULL, MENUNULL
  117.        },
  118.        /* "Draft" */
  119.        {NULL,        61, 9, IWIDTH, IHEIGHT, ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  120.         (APTR)&PrtText[1], NULL, NULL, NULL, MENUNULL
  121.        }
  122.     };
  123.  
  124. /*   Uses the >> character to indicate a sub-menu 
  125.  *   \273 Octal, 0xBB Hex or ALT-0 from the Keyboard
  126.  */
  127.  
  128. /* Project Menu Item IntuiText */
  129. struct IntuiText ProjText[] =
  130.     {
  131.        {2, 1, JAM2,2,1, NULL, "  New",         NULL},
  132.        {2, 1, JAM2,2,1, NULL, "  Open...",     NULL},
  133.        {2, 1, JAM2,2,1, NULL, "  Save",        NULL},
  134.        {2, 1, JAM2,2,1, NULL, "  Save As...",  NULL},
  135.        {2, 1, JAM2,2,1, NULL, "\273 Print",   NULL},
  136.        {2, 1, JAM2,2,1, NULL, "  About...",    NULL},
  137.        {2, 1, JAM2,2,1, NULL, "  Quit",        NULL}
  138.     };
  139.  
  140. /* Project Menu Items */
  141. struct MenuItem ProjItem[] =
  142.     {
  143.        /* "New" */
  144.        {&ProjItem[1],0, 0, IWIDTH, IHEIGHT,
  145.         ITEMTEXT|ITEMENABLED|HIGHCOMP, 0, 
  146.         (APTR)&ProjText[0], NULL, NULL, NULL, MENUNULL
  147.        },
  148.        /* "Open..." (key-equivalent: 'O') */
  149.        {&ProjItem[2],0,10, IWIDTH, IHEIGHT,
  150.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  151.         (APTR)&ProjText[1], NULL, 'O', NULL, MENUNULL
  152.        },
  153.        /* "Save" (key-equivalent: 'S') */
  154.        {&ProjItem[3],0,20, IWIDTH, IHEIGHT,
  155.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  156.         (APTR)&ProjText[2], NULL, 'S', NULL, MENUNULL
  157.        },
  158.        /* "Save As..." */
  159.        {&ProjItem[4],0,30, IWIDTH, IHEIGHT,
  160.         ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  161.         (APTR)&ProjText[3], NULL, NULL, NULL, MENUNULL
  162.        },
  163.        /* "Print" (has sub-menu) */
  164.        {&ProjItem[5],0,40, IWIDTH, IHEIGHT,
  165.         ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  166.         (APTR)&ProjText[4], NULL, NULL, &PrtItem[0], MENUNULL
  167.        },
  168.        /* "About..." */
  169.        {&ProjItem[6],0,50, IWIDTH, IHEIGHT,
  170.         ITEMTEXT|ITEMENABLED|HIGHCOMP, 0,
  171.         (APTR)&ProjText[5], NULL, NULL, NULL, MENUNULL
  172.        },
  173.        /* "Quit" (key-equivalent: 'Q' */
  174.        {NULL,        0,60, IWIDTH, IHEIGHT, 
  175.         ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0,
  176.         (APTR)&ProjText[6], NULL, 'Q', NULL, MENUNULL
  177.        }
  178.     };
  179.  
  180. /* Menu Titles */
  181. struct Menu Menus[] =
  182.     {
  183.         {&Menus[1],  0, 0, 63, 0, MENUENABLED, "Project",    &ProjItem[0]},
  184.         {&Menus[2], 70, 0, 39, 0, MENUENABLED, "Edit",       &EditItem[0]},
  185.         {NULL,     120, 0, 88, 0, MENUENABLED, "Preferences",&PrefItem[0]},
  186.     };
  187.  
  188. /* A pointer to the first menu for easy reference */
  189. struct Menu *FirstMenu = &Menus[0];
  190.  
  191. /* Window Text for Explanation of Program */
  192. struct IntuiText WinText[] =
  193.     {
  194.        {3, 0, JAM2, 54, 28, &TOPAZ80, "How to do a Menu",        NULL},
  195.        {3, 0, JAM2, 70, 38, &TOPAZ80, "(with Style)",     &WinText[0]}
  196.     };
  197.  
  198. /* NewWindow structure for our example window */
  199. struct NewWindow NewWindow =
  200.     {
  201.     202,66, 234,66, 2,1, MENUPICK|CLOSEWINDOW,
  202.     WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|ACTIVATE|NOCAREREFRESH,
  203.     NULL, NULL, "Menus", NULL, NULL, 0, 0, -1, -1, WBENCHSCREEN
  204.     };
  205.