home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iv26_w_3.zip / EXAMPLES / IDRAW / PDMENU.H < prev    next >
C/C++ Source or Header  |  1991-12-20  |  4KB  |  146 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: pdmenu.h,v 1.10 89/10/09 14:49:16 linton Exp $
  24. // declares pulldown menu classes.
  25.  
  26. #ifndef pdmenu_h
  27. #define pdmenu_h
  28.  
  29. #include "highlighter.h"
  30.  
  31. // Declare imported and used-before-defined types.
  32.  
  33. class PullDownMenuActivator;
  34. class PullDownMenuCommand;
  35.  
  36. // A PullDownMenuBar displays several activators and coordinates which
  37. // activator will open its menu.
  38.  
  39. class PullDownMenuBar : public HighlighterParent {
  40. public:
  41.  
  42.     PullDownMenuBar();
  43.     ~PullDownMenuBar();
  44.  
  45.     void Enter(PullDownMenuActivator*);
  46.     boolean Contains(Interactor*);
  47.  
  48.     boolean MenuActive();
  49.     boolean MenuShouldActivate(PullDownMenuActivator*);
  50.  
  51.     void MenuActivate(PullDownMenuActivator*);
  52.     void MenuDeactivate();
  53.  
  54. protected:
  55.  
  56.     void GrowActivators();
  57.  
  58.     PullDownMenuActivator* cur;    // stores currently active activator
  59.     int sizeactivators;        // stores current size of dynamic array
  60.     int numactivators;        // stores number of activators in array
  61.     PullDownMenuActivator**
  62.     activators;        // stores bar's interior activators
  63.  
  64. };
  65.  
  66. // A PullDownMenuActivator displays a text label and opens a menu when
  67. // you activate it.
  68.  
  69. class PullDownMenuActivator : public Highlighter {
  70. public:
  71.  
  72.     PullDownMenuActivator(PullDownMenuBar*, const char*);
  73.     ~PullDownMenuActivator();
  74.  
  75.     void SetMenu(Scene*);
  76.     void Handle(Event&);
  77.  
  78.     void Enter(PullDownMenuCommand*);
  79.     boolean Contains(Interactor*);
  80.  
  81.     void Open();
  82.     void Close();
  83.  
  84. protected:
  85.  
  86.     void Reconfig();
  87.     void Redraw(Coord, Coord, Coord, Coord);
  88.     void Resize();
  89.     void GrowCommands();
  90.  
  91.     PullDownMenuBar* bar;    // stores bar containing this activator
  92.     char* name;            // stores activator's text label
  93.     Scene* menu;        // stores menu to be opened when activated
  94.     int sizecommands;        // stores current size of dynamic array
  95.     int numcommands;        // stores number of commands in array
  96.     PullDownMenuCommand**
  97.     commands;        // stores activator's interior commands
  98.  
  99.     Coord name_x, name_y;    // stores position at which to display name
  100.  
  101. };
  102.  
  103. // A PullDownMenuCommand displays a text label and executes a command.
  104.  
  105. class PullDownMenuCommand : public Highlighter {
  106. public:
  107.  
  108.     PullDownMenuCommand(PullDownMenuActivator*, const char*, const char*);
  109.     ~PullDownMenuCommand();
  110.  
  111.     void Handle(Event&);
  112.  
  113.     virtual void Execute(Event&);
  114.  
  115. protected:
  116.  
  117.     void Reconfig();
  118.     void Redraw(Coord, Coord, Coord, Coord);
  119.     void Resize();
  120.  
  121.     PullDownMenuActivator*
  122.     activator;        // stores activator which this cmd belongs to
  123.     char* name;            // stores command's text label
  124.     char* key;            // stores label of key which selects this cmd
  125.  
  126.     Coord name_x, name_y;    // stores position at which to display name
  127.     Coord key_x, key_y;        // stores position at which to display key
  128.  
  129. };
  130.  
  131. // A PullDownMenuDivider displays a horizontal line extending the full
  132. // width of the menu, dividing it into two submenus.
  133.  
  134. class PullDownMenuDivider : public PullDownMenuCommand {
  135. public:
  136.  
  137.     PullDownMenuDivider();
  138.  
  139. protected:
  140.  
  141.     void Redraw(Coord, Coord, Coord, Coord);
  142.  
  143. };
  144.  
  145. #endif
  146.