home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / ev_201.zip / TMENUBAR.HPP < prev    next >
C/C++ Source or Header  |  1993-07-03  |  7KB  |  168 lines

  1. #if !defined (TMENUBAR)              // Prevents multiple declarations errors
  2. #define TMENUBAR
  3.  
  4.  
  5. /*
  6.    Module        : TMENUBAR.HPP
  7.    Version       : 2.0
  8.    Revision date : July 3rd, 1993
  9.    Author(s)     : Remy Gendron
  10.  
  11.    Description   : tmenubar declaration file.
  12. */
  13.  
  14.  
  15. // Headers ------------------------------------------------------------------
  16.  
  17. #include <conio.h>                                      // System's libraries
  18.  
  19. #include "twindow.hpp"                                       // Other modules
  20.  
  21.  
  22. // Macros -------------------------------------------------------------------
  23.  
  24. #include "stdmacro.h"                           // Standard macro definitions
  25.  
  26.  
  27. // TypeDefs -----------------------------------------------------------------
  28.  
  29. #include "stdtype.h"                             // Standard type definitions
  30.  
  31. struct tmenuitem                                             // One menu item
  32. {
  33.    char      huge *itemtext ;                                  // Item's text
  34.    int             itemkey ;             // Item's hotkey (letters or digits)
  35.    int             itemrow ;                                    // Item's row
  36.    int             itemrtnval ;                        // Item's return value
  37.    bool            itemavail ;        // TRUE: available FALSE: not available
  38.    char      huge *itemsltext ;                   // Help text for statusline
  39.    int             itemhlpctx ;            // This item's help context number
  40.    tmenuitem huge *itemnext ;                            // Next item in link
  41.    tmenuitem huge *itemprevious ;                    // Previous item in link
  42. } ;
  43.  
  44. struct tmenu                                                      // One menu
  45. {
  46.    char       huge *menuname ;                                 // Menu's name
  47.    int              menukey ;               // Menu's key (Letters or digits)
  48.    int              menucolpos ;                    // Menu's column position
  49.    char       huge *menusltext ;                  // Help text for statusline
  50.    int              menuhlpctx ;             // This menu help context number
  51.    tmenuitem  huge *itemfirst ;                         // First item in link
  52.    tmenuitem  huge *itemlast ;                           // Last item in link
  53.    int              itemcount ;               // Number of items in this menu
  54.    int              itemmaxwidth ;                     // Widest item's width
  55.    int              itemlastkey ;             // Last selected item  (hotkey)
  56.    tmenu      huge *menunext ;                           // Next menu in link
  57.    tmenu      huge *menuprevious ;                   // Previous menu in link
  58. } ;
  59.  
  60.  
  61. // --------------------------------------------------------------------------
  62.  
  63. class tmenubar
  64. {
  65.    int         menubackcolor ;                  // Menubar's background color
  66.    int         menuforecolor ;                  // Menubar's foreground color
  67.    int         menuhighcolor ;                   // Menubar's highlight color
  68.    int         menucursorcolor ;                  // Selection cursor's color
  69.    int         menucount ;                      // Number of menus on menubar
  70.    int         menubarwidth ;                   // Width of all created menus
  71.    int         menulastkey ;                   // Last menu selected (hotkey)
  72.    int         menuhlpctx ;                 // Menubar's general help context
  73.    tmenu huge *menufirst ;                              // First menu in link
  74.    tmenu huge *menulast ;                                // Last menu in link
  75.  
  76.  
  77. public:
  78.  
  79. far tmenubar () ;                                              // Constructor
  80.  
  81. far ~tmenubar () ;                                              // Destructor
  82.  
  83. void far tmenubar::setcolors                           // Sets menubar colors
  84. (
  85.    int back=LIGHTGRAY,                                    // Background color
  86.    int fore=BLACK,                                        // Foreground color
  87.    int high=RED,                                           // Highlight color
  88.    int cursor=GREEN                                           // Cursor color
  89. ) ;
  90.  
  91. void far tmenubar::sethlpctx           // Sets menubar's default help context
  92. (
  93.    int hlpctx=EV_NOHLPCTX                              // Help context number
  94. ) ;
  95.  
  96. void far tmenubar::addmenu                              // Creates a new menu
  97. (
  98.    char huge *name,                                            // Menu's name
  99.    int       hotkey,                       // Menu's hotkey (letter or digit)
  100.    char huge *sltext=NULL,                   // Statusline text for this menu
  101.    int       hlpctx=EV_NOHLPCTX                 // Menu's help context number
  102. ) ;
  103.  
  104. void far tmenubar::additem               // Adds an item to last created menu
  105. (
  106.    char huge *text=NULL,                                       // Item's text
  107.    int        hotkey=II_NUL,               // Item's hotkey (letter or digit)
  108.    int        returnval=II_NUL,                  // Return value of this item
  109.    char huge *sltext=NULL,                          // Item's statusline text
  110.    int        hlpctx=EV_NOHLPCTX                // Item's help context number
  111. ) ;
  112.  
  113. void far tmenubar::itemsetavail         // Sets item's availability ON or OFF
  114. (
  115.    int  menuhotkey,                         // Hotkey of menu in wich item is
  116.    int  itemhotkey,                             // Hotkey of menu item to set
  117.    bool state=TRUE                   // TRUE: available  FALSE: Not available
  118. ) ;
  119.  
  120. input_info far tmenubar::through                         // Activates menubar
  121. (
  122.    input_info ii                                // Pass input through menubar
  123. ) ;
  124.  
  125. void far tmenubar::refresh () ;                        // Redraws the menubar
  126.  
  127.  
  128. private :
  129.  
  130. tmenu huge* far tmenubar::menuexist    // Checks if menu exists. Returns addr
  131. (
  132.    int menuhotkey                                   // Hotkey of menu to find
  133. ) ;
  134.  
  135. tmenuitem huge* far tmenubar::itemexist              // Checks if item exists
  136. (
  137.    int menuhotkey,                                   // Menu in which to look
  138.    int itemhotkey                                         // Item to look for
  139. ) ;
  140.  
  141. void far tmenubar::menudraw                                // Displays 1 menu
  142. (
  143.    int  hotkey=II_NUL,                              // Hotkey of menu to draw
  144.    bool cursorflag=FALSE                             // TRUE: Displays cursor
  145. ) ;
  146.  
  147. void far tmenubar::itemdraw                      // Displays 1 item in a menu
  148. (
  149.    twindow   huge *winptr,                              // Ptr to menu window
  150.    tmenuitem huge *itemptr,                         // Ptr to item to display
  151.    bool            cursorflag=FALSE     // FALSE: Cursor off  TRUE: Cursor on
  152. ) ;
  153.  
  154. input_info far tmenubar::chooseitem () ;       // Opens menu and chooses item
  155.  
  156.  
  157. } ;
  158.  
  159.  
  160. // --------------------------------------------------------------------------
  161.  
  162.    extern tmenubar menubar ;            // Reference to global menubar object
  163.  
  164.  
  165. // End Header File ----------------------------------------------------------
  166.  
  167. #endif
  168.