21.26 Simplemenu Interface

ORIGIN '../guienv';
LIB_DEF 'guienvutilssimplemenu' '../../lib';
BODY 'private/simplemenubody';
-- MenuBarLib: Attributes --
simplemenu: menu
(* Special menu type with interdependant check marks, some other 
 * extra features, and a few code saving patterns, that allow
 * for simple specification of a menu.
 *
 * Example:
 * 
 *  FileMenu: @simplemenu
 *    (# inew:    @item(# onSelect:: (# do NewFile    #)#);
 *       iopen:   @item(# onSelect:: (# do OpenFile   #)#);
 *       iclose:  @item(# onSelect:: (# do Iconify    #)#);
 *       isave:   @item(# onSelect:: (# do SaveFile   #)#);
 *       isaveas: @item(# onSelect:: (# do SaveFileAs #)#);
 *       iexport: @item(# onSelect:: (# do Export     #)#);
 *       iprint:  @item(# onSelect:: (# do Print      #)#);
 *       iquit:   @item(# onSelect:: (# do Quit       #)#);
 *            
 *       open:: 
 *         (# 
 *         do ('New...',    'n') -> inew.newkey;  false -> inew.enabled;
 *            ('Open...',   'o') -> iopen.newkey; false -> iopen.enabled;
 *            ('Close',     'w') -> iclose.newkey;
 *            newseparator;
 *            ('Save',      's') -> isave.newkey; false -> isave.enabled;
 *            ('Save As...')     -> isaveas.new;  false -> isaveas.enabled;
 *            newseparator;
 *            ('Print...',  'p') -> iprint.newkey; 
 *            ('Export...', 'e') -> iexport.newkey; 
 *            newseparator;
 *            ('Quit',      'q') -> iquit.newkey;
 *         #)
 *     #);
 * 
 *  ShapeMenu: @simplemenu                          
 *    (# ievenodd: @radioitem
 *         (# onSelect:: (# do EvenOddRule->SetFillRule #)#);
 *       iwinding: @radioitem
 *         (# onSelect:: (# do WindingRule->SetFillRule #)#);
 *       open:: 
 *         (# 
 *         do 'Even-Odd Fillrule'->ievenodd.new; 
 *            'Winding Fillrule'->iwinding.new;
 *         #);
 *    #);
 *)
  (#
     item: menuitem
       (#
          enabled: @boolean
          (* Set to true or false to enable or disable THIS(item) *) ;
          onSelect:< object (* Shortcut for eventhandler.onSelect *) ;
          onStatus:< booleanValue 
            (* Shortcut for eventhandler.onStatus *)
            (# do enabled->value; INNER #);
          new: (* Open and append THIS(Item) with label itemtext *)
            (# itemtext: ^text; 
            enter itemtext[]
            ...
            #);
          newkey: new
          (* Also add key quivalent *)
            (# equiv: @char
            enter equiv
            ...
            #);
          eventhandler::< (#
               onSelect::< 
                 (# 
                 ...
                 #);
               onStatus::<  (#  ... #);
               
            #);
          
       #);
     noOfRadioGroups:< integervalue
     (* The number of independant groups of radioitems.
      * Default 1.
      *) (#  ... #);
     radioitem: item
     (* Special item, that is un-checked when another radioitem
      * in the radiogroup indicated by "checkgroup" is selected. 
      *)
       (#
          checkgroup: @integer
          (* The group of items THIS(item) is dependant on. default 1. *) ;
          open::<  (#  ... #);
          onSelect::< 
            (# 
            ...
            #);
          
       #);
     toggleitem: item
     (* Special item that is checked evey second time it is selected *)
       (# onSelect::<  (#  ... #)
       #);
     newseparator:
     (* Open and append a separator to THIS(simplemenu) *)
       (#  ... #);
     new:
     (* Open THIS(simplemenu) and append it to THIS(MenuBar) 
      * with label menutext.
      *)
       (# menutext: ^text; 
       enter menutext[]
       ...
       #);
     changechecked:
     (* Explicitly change the checked item to be newitem *)
       (# newitem: ^radioitem
       enter newitem[]
       ...
       #);
     <<SLOT SimpleMenuLib:Attributes>>;
     private: @...;
     
  #)


21.26 Simplemenu Interface
© 1994-2002 Mjølner Informatics
[Modified: Friday January 21st 2000 at 8:41]