source: golgotha/src/i4/menu/menuitem.hh

Last change on this file was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.3 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef __MENUITEM_HPP_
10#define __MENUITEM_HPP_
11
12#include "arch.hh"
13#include "device/event.hh"
14#include "device/device.hh"
15#include "window/window.hh"
16#include "device/kernel.hh"
17#include "string/string.hh"
18
19class i4_menu_item_parent_class;
20class i4_graphical_style_class;
21
22class i4_menu_item_class : public i4_parent_window_class
23{
24  protected :
25  i4_str *context_help;
26  i4_event_handler_reference_class<i4_window_class> context_help_window;
27
28  i4_bool active,    // if the mouse is on us, or we have the key focus
29          pressed,   // if the mouse clicked us or ENTER was pressed while key focus
30          disabled;  // if this button is not currently enabled right now
31
32  // if this is non null, the menu_parent will be notified of events sent
33  i4_menu_item_parent_class *menu_parent;
34  i4_graphical_style_class *hint;
35
36  public :
37
38  void set_menu_parent(i4_menu_item_parent_class *_menu_parent)
39  { menu_parent=_menu_parent; }
40
41
42  enum reaction_type { PRESSED, DEPRESSED, ACTIVATED, DEACTIVATED };
43
44  struct   // these event are only sent out, the are not noticed if sent in
45  {   
46    i4_event_reaction_class *press,    *depress;
47    i4_event_reaction_class *activate, *deactivate;
48
49  } send;
50
51 
52
53  i4_menu_item_class(const i4_const_str *idle_context_help,  // can be null
54                     i4_graphical_style_class *hint,         // can be null if idle_help is null
55                     w16 w, w16 h,
56                     i4_event_reaction_class *press=0,
57                     i4_event_reaction_class *depress=0,
58                     i4_event_reaction_class *activate=0,
59                     i4_event_reaction_class *deactivate=0
60                     );           
61
62  void set_context_help(const i4_const_str *help_string)
63  {
64    if (context_help)
65      delete context_help;
66    if (help_string)
67      context_help = new i4_str(*help_string);
68    else
69      context_help = 0;
70  }
71
72  void send_event(i4_event_reaction_class *ev, reaction_type type);
73
74  virtual void receive_event(i4_event *ev);
75
76  virtual void do_activate();
77  virtual void do_deactivate();
78  virtual void do_disable();
79  virtual void do_undisable();
80  virtual void do_press();
81  virtual void do_depress();
82  virtual void do_idle();
83
84  virtual i4_menu_item_class *copy() = 0;
85
86  ~i4_menu_item_class();
87} ;
88
89
90// if a menu item has a pointer to it's parent, then it send it's events to the
91// parent instead of to who the event_reaction specifies
92class i4_menu_item_parent_class : public i4_parent_window_class
93{
94public:
95  i4_menu_item_parent_class() : i4_parent_window_class(0,0) {}
96
97  virtual void note_reaction_sent(i4_menu_item_class *who,       // this is who sent it
98                                  i4_event_reaction_class *ev,   // who it was to
99                                  i4_menu_item_class::reaction_type type) { ; }
100};
101
102#endif
Note: See TracBrowser for help on using the repository browser.