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 / PANEL.H < prev    next >
C/C++ Source or Header  |  1980-01-05  |  3KB  |  89 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: panel.h,v 1.9 89/10/09 14:49:13 linton Exp $
  24. // declares classes Panel and PanelItem.
  25.  
  26. #ifndef panel_h
  27. #define panel_h
  28.  
  29. #include "highlighter.h"
  30.  
  31. // Declare imported and used-before-defined types.
  32.  
  33. class PanelItem;
  34.  
  35. // A Panel displays several items but highlights only one item.
  36.  
  37. class Panel : public HighlighterParent {
  38. public:
  39.  
  40.     Panel();
  41.  
  42.     void Enter(PanelItem*, char);
  43.     PanelItem* LookUp(char);
  44.  
  45.     void SetCur(PanelItem*);
  46.     PanelItem* GetCur();
  47.  
  48.     void PerformCurrentFunction(Event&);
  49.     void PerformTemporaryFunction(Event&, char);
  50.  
  51. protected:
  52.  
  53.     PanelItem* cur;        // stores currently selected item
  54.     PanelItem* items[128];    // stores items by their associated character
  55.  
  56. };
  57.  
  58. // A PanelItem displays two text labels and performs a function.
  59.  
  60. class PanelItem : public Highlighter {
  61. public:
  62.  
  63.     PanelItem(Panel*, const char*, const char*, char);
  64.     ~PanelItem();
  65.  
  66.     void Handle(Event&);
  67.  
  68.     virtual void Perform(Event&);
  69.  
  70. protected:
  71.  
  72.     void Reconfig();
  73.     void Redraw(Coord, Coord, Coord, Coord);
  74.     void Resize();
  75.  
  76.     Panel* panel;        // stores panel which this item belongs to
  77.     char* name;            // stores item's text label
  78.     char* key;            // stores label of key which selects this item
  79.  
  80.     Coord name_x, name_y;    // stores position at which to display name
  81.     Coord key_x, key_y;        // stores position at which to display key
  82.     Coord side;            // size of largest square fitting in canvas
  83.     Coord offx;            // horizontal offset needed to center square
  84.     Coord offy;            // vertical offset needed to center square
  85.  
  86. };
  87.  
  88. #endif
  89.