home *** CD-ROM | disk | FTP | other *** search
- /*
- * Example program for using quick menu package. Contains the necessary
- * declarations for a simple menu strip which it creates and destroys after
- * letting the user play with it.
- */
- #include <intuition/intuition.h>
- #include "qmenu.h"
-
-
- #define NILSUB {NULL,NULL}
-
- /*
- * String arrays get defined in sort-of reverse order.
- * I.e. the subitems get defined before the parent items.
- * (One rule is that menu items that cause a Requester to
- * appear are followed by "...".)
- * The string arrays themselves are terminated by a null
- * string pointer.
- */
- char *mpo_str[] = {
- "!=ORaw Text...",
- "Processed Text...",
- "Drawing...",
- "Picture...",
- "Old Settings...",
- NULL };
-
- char *mps_str[] = {
- "!=TText...",
- "!=DDrawing...",
- "Picture...",
- NULL };
-
- char *mp_str[] = {
- "!=NNew...",
- "Open",
- "!=SSave...",
- "Save as",
- "Print...",
- "Save Settings",
- "About...",
- "-",
- "!bQuit...",
- NULL };
-
- /* Array of NewMenu structs to go with the above text items.
- * Needs to be a one-to-one correspondence between text items
- * (not rules) and NewMenu structs.
- */
- struct NewMenu mp_sub[] = {
- NILSUB,
- { mpo_str, NULL },
- NILSUB,
- { mps_str, NULL },
- NILSUB,
- NILSUB,
- NILSUB,
- NILSUB
- };
-
- char *mes_str[] = {
- "!+!0111!=PPlain",
- "!c!1!=BBold",
- "!c!1!=IItalic",
- "!c!1!=UUnderline",
- NULL };
-
- char *me_str[] = {
- "!=QUndo",
- "-",
- "!=ZDelete",
- "!=XCut",
- "!=CCopy",
- "!=VPaste",
- "-",
- "Set Font...",
- "Set Style",
- NULL };
-
- struct NewMenu me_sub[] = {
- NILSUB,
- NILSUB,
- NILSUB,
- NILSUB,
- NILSUB,
- NILSUB,
- { mes_str, NULL }
- };
-
- char *mdz_str[] = {
- "!=>In",
- "!=<Out",
- "!=MManual",
- NULL };
-
- char *mdv_str[] = {
- "!+!tText",
- "!+!tLines",
- "!+!tImages",
- "!+!tBoxes",
- "!+!tLabels",
- NULL };
-
- char *mds_str[] = {
- "Interlace",
- "Non-interlace",
- "Workbench",
- NULL };
-
- char *md_str[] = {
- "Zoom",
- "!=AAuto Scale",
- "-",
- "!c!tCoordinates",
- "Visible",
- "-",
- "Screen Colors...",
- "Screen Type",
- NULL };
-
- struct NewMenu md_sub[] = {
- { mdz_str, NULL },
- NILSUB,
- NILSUB,
- { mdv_str, NULL },
- NILSUB,
- { mds_str, NULL }
- };
-
- char *mhc_str[] = {
- "Plot...",
- "Set...",
- "Lay in...",
- NULL };
-
- char *mhw_str[] = {
- "!+!0111111Full Impulse",
- "!c!1011111!=1Warp 1",
- "!c!1101111!=2Warp 2",
- "!c!1110111!=3Warp 3",
- "!c!1111011!=4Warp 4",
- "!c!1111101!=5Warp 5",
- "!c!1111110Space Normal",
- NULL };
-
- char *mhp_str[] = {
- "Stun",
- "Kill",
- "Maim",
- "Burn",
- "Overload",
- "Ineffective",
- "Burn Out",
- NULL };
-
- char *mh_str[] = {
- "New Course",
- "Speed",
- "Standard Orbit",
- "Tractor Beam...",
- "Lock Phasers",
- "-",
- "\"Make It So.\"",
- NULL };
-
- struct NewMenu mh_sub[] = {
- { mhc_str, NULL },
- { mhw_str, NULL },
- NILSUB,
- NILSUB,
- { mhp_str, NULL },
- NILSUB
- };
-
- char *mt_str[] = {
- "Hammer",
- "Screwdriver",
- "Chisel",
- "Knife",
- "Felt Pen",
- "Air Freshener",
- "-",
- "Hammer Size...",
- "Screw Type...",
- "Pine Scent...",
- NULL };
-
- char *mm_str[] = {
- "Rotate...",
- "Spin...",
- "Turn Around...",
- "Flip Out...",
- "Randomize...",
- "Energize...",
- "Simplify",
- "Complexify",
- NULL };
-
- char *main_str[] = {
- "Project",
- "Edit",
- "Display",
- "Tools",
- "Helm",
- "Modify",
- NULL };
-
- struct NewMenu main_sub[] = {
- { mp_str, mp_sub },
- { me_str, me_sub },
- { md_str, md_sub },
- { mt_str, NULL },
- { mh_str, mh_sub },
- { mm_str, NULL }
- };
-
- struct NewMenu main_menu = { main_str, main_sub };
-
- struct TextAttr ta = { (UBYTE*) "topaz.font", 8,0,0 };
-
-
- /* Basic stuff for the test program.
- */
- struct NewWindow nwin = {
- 50,20, 200,100, -1,-1, CLOSEWINDOW,
- WINDOWCLOSE|WINDOWDRAG|ACTIVATE,
- NULL,NULL, (UBYTE*) "Test the Menus", NULL,NULL,
- 0,0,0,0, WBENCHSCREEN
- };
-
- #define OLIB(var,nam) (var=OpenLibrary(nam,33L))
-
- struct IntuitionBase *IntuitionBase;
- struct Window *mywin;
-
-
- struct Window *OpenWindow();
- void *OpenLibrary();
- void *GetMsg();
-
-
- main ()
- {
- if (OLIB(IntuitionBase,"intuition.library")) {
- if (mywin = OpenWindow (&nwin)) {
- Body ();
- CloseWindow (mywin);
- }
- CloseLibrary (IntuitionBase);
- }
- }
-
-
- Body ()
- {
- struct IntuiMessage *im;
- struct Menu *m;
-
- if (!(m = GenMenu (&main_menu))) return;
-
- SetMenuStrip (mywin, m);
-
- /* Wait for the close window message.
- */
- while (!(im = (struct IntuiMessage *) GetMsg (mywin->UserPort)))
- WaitPort (mywin->UserPort);
- ReplyMsg (im);
-
- ReadMenuState (m);
- ClearMenuStrip (mywin);
- FreeMenu (m);
- }
-
-
- ReadMenuState (m)
- struct Menu *m;
- {
- struct MenuItem *mi;
-
- /* Get the text style menu array and test for checkmarks.
- */
- mi = m[1].FirstItem[8].SubItem;
- printf ("Text Style: ");
- if (mi[0].Flags & CHECKED) printf ("Plain");
- if (mi[1].Flags & CHECKED) printf ("Bold ");
- if (mi[2].Flags & CHECKED) printf ("Italic ");
- if (mi[3].Flags & CHECKED) printf ("Underline");
- printf ("\n");
- }
-