source: golgotha/src/i4/menu/key_item.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: 2.5 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 I4_KEY_ITEM_HH
10#define I4_KEY_ITEM_HH
11
12
13#include "menu/menu.hh"
14#include "font/font.hh"
15#include "window/style.hh"
16#include "device/keys.hh"
17
18class i4_key_item_class : public i4_menu_item_class
19{
20  protected :
21
22  i4_color_hint_class *color;
23  i4_font_hint_class *font;
24
25  i4_str *text;
26  w16 pad_lr, pad_ud;
27  w16 use_key, key_modifiers;
28  i4_bool key_focused, valid;
29
30  public :
31  i4_bool has_keyboard_focus() { return key_focused; }
32
33  i4_key_item_class(
34               const i4_const_str &_text,
35               i4_color_hint_class *color_hint,
36               i4_font_hint_class *font_hint,
37               i4_graphical_style_class *style,
38               w16 key=I4_NO_KEY,
39               w16 key_modifiers=0,
40               w16 pad_left_right=0,
41               w16 pad_up_down=0
42               );
43
44
45  ~i4_key_item_class();
46
47  char *name() { return "key_item"; }
48
49  virtual void parent_draw(i4_draw_context_class &context);
50  virtual void receive_event(i4_event *ev);
51
52  // called when selected or key is pressed
53  virtual void action() = 0;
54
55  // if usage is disallowed then the item will be grayed out on the menu
56  void allow_use()    { valid=i4_T; }
57  void disallow_use() { valid=i4_F; }
58  virtual void do_press()
59  {
60    if (!valid) return;
61    else i4_menu_item_class::do_press();
62  }
63
64  i4_menu_item_class *copy()
65  {
66    return 0;      // don't use this key_item anymore..
67  }
68
69} ;
70
71class i4_key_accel_watcher_class : public i4_event_handler_class
72{
73  struct key_item_pointer_type
74  {   
75    i4_key_item_class *modkey[8];
76    i4_key_item_class **get_from_modifiers(w16 modifiers);
77  }
78  user[I4_NUM_KEYS];
79 
80
81  w32 total;
82  i4_bool initialized;
83public:
84  i4_key_accel_watcher_class();
85  void watch_key(i4_key_item_class *who, w16 key, w16 modifiers);
86  void unwatch_key(i4_key_item_class *who, w16 key, w16 modifiers);
87  void receive_event(i4_event *ev);
88 
89  char *name() { return "key accel watcher"; }
90};
91
92
93
94#endif
95
96
97
Note: See TracBrowser for help on using the repository browser.