home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 215 / DDJ9302.ZIP / DFPP01.ZIP / MENUSEL.H < prev    next >
C/C++ Source or Header  |  1992-12-13  |  2KB  |  80 lines

  1. // ------- menusel.h
  2.  
  3. #ifndef MENUSEL_H
  4. #define MENUSEL_H
  5.  
  6. #include <stdio.h>
  7. #include "strings.h"
  8. #include "dfwindow.h"
  9. #include "dflatdef.h"
  10.  
  11. enum MenuType {
  12.     NORMAL,
  13.     TOGGLE,
  14.     CASCADER,
  15.     SEPARATOR,
  16.     TERMINATOR
  17. };
  18.  
  19. enum Toggle { Off, On };
  20.  
  21. class DFWindow;
  22. class PopDown;
  23.  
  24. #define NULLFUNC (void (DFWindow::*)())NULL
  25.  
  26. class MenuSelection    {
  27.     String *label;                // selection label
  28.     void (DFWindow::*cmdfunction)();    // selection function
  29.     MenuType type;                // NORMAL, TOGGLE, CASCADER,
  30.                                 // SEPARATOR, TERMINATOR
  31.     Bool isenabled;                // True = enabled, False = disabled
  32.     int accelerator;            // accelerator key
  33.     PopDown *cascade;            // cascaded menu window
  34.     MenuSelection **cascaders;    // cascaded menu selection list
  35.     Toggle toggle;                // On or Off
  36.     void NullSelection();        // Build a null selection
  37.     friend PopDown;
  38.     void CommonConstructor(    char *Label,
  39.                             int Accelerator,
  40.                             void (DFWindow::*CmdFunction)(),
  41.                             Bool Active,
  42.                             MenuType Type,
  43.                             Toggle Tgl,
  44.                             MenuSelection **Cascaders = NULL);
  45. public:
  46.     MenuSelection(    char *Label, 
  47.                     void (DFWindow::*CmdFunction)() = 0,
  48.                     int Accelerator=0,
  49.                     Bool Active=True );
  50.  
  51.     MenuSelection(    char *Label,
  52.                     void (DFWindow::*CmdFunction)(),
  53.                     Toggle Tgl,
  54.                     int Accelerator=0,
  55.                     Bool Active=True );
  56.  
  57.     MenuSelection(    char *Label,
  58.                     MenuSelection **Cascaders,
  59.                     int Accelerator=0,
  60.                     Bool Active=True );
  61.  
  62.     MenuSelection(MenuType Type);
  63.  
  64.     Bool isEnabled()        { return isenabled; }
  65.     void Enable()            { isenabled = True; }
  66.     void Disable()            { isenabled = False; }
  67.     void SetToggle()        { toggle = On; }
  68.     void ClearToggle()        { toggle = Off; }
  69.     void InvertToggle()        { toggle = toggle == On ? Off : On; }
  70.     Bool isToggled()        { return (Bool) (toggle == On); };
  71.     Type()                  { return type; }
  72. };
  73.  
  74. extern MenuSelection SelectionSeparator;
  75. extern MenuSelection SelectionTerminator;
  76.  
  77. #endif
  78.  
  79.  
  80.