home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a066 / 1.img / MENUBAR.PRG < prev    next >
Encoding:
Text File  |  1992-03-20  |  1.2 KB  |  55 lines

  1. /*
  2.     MenuBar.prg
  3.  
  4.     Copyright (c) 1991 Chris Muller and Anton van Straaten
  5. */
  6.  
  7. #include "class(y).ch"
  8.  
  9. #define OPTION_SPACING  4
  10.  
  11.  
  12. create class MenuBar from BaseMenu
  13.  
  14.     export:
  15.         method  draw
  16.         method  addItem
  17.         method  newMenuPos
  18. endclass
  19.  
  20.  
  21. // this constructor does nothing but pass its parameter up to the superclass
  22. constructor new (aItems), (aItems)
  23. return
  24.  
  25.  
  26. method procedure addItem(cLabel, oAction, isActive)
  27.     local nCol
  28.  
  29.     // establish screen column for new option
  30.     if len(::items) == 0
  31.         nCol := OPTION_SPACING
  32.     else
  33.         // atail() is a 5.01 function; for 5.0, use  ::items[len(::items)]
  34.         nCol := atail(::items):nextCol() + OPTION_SPACING
  35.     end
  36.  
  37.     // invoke addItem in the superclass (BaseMenu)
  38.     ::super:addItem(0, nCol, cLabel, oAction, isActive)
  39. return
  40.  
  41.  
  42. method procedure draw
  43.     winCurrent(0)                           // selects main screen
  44.     @ 0, 0                                  // draw the bar
  45.     ::super:draw()                          // invoke superclass' draw method
  46. return
  47.  
  48.  
  49. method function newMenuPos
  50. // tells a child menu where to put itself
  51. return ::items[::currPos]:col
  52.  
  53.  
  54. // eof menubar.prg
  55.