menuitem.hh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. #ifndef __MENUITEM_HPP_
  9. #define __MENUITEM_HPP_
  10. #include "arch.hh"
  11. #include "device/event.hh"
  12. #include "device/device.hh"
  13. #include "window/window.hh"
  14. #include "device/kernel.hh"
  15. #include "string/string.hh"
  16. class i4_menu_item_parent_class;
  17. class i4_graphical_style_class;
  18. class i4_menu_item_class : public i4_parent_window_class
  19. {
  20. protected :
  21. i4_str *context_help;
  22. i4_event_handler_reference_class<i4_window_class> context_help_window;
  23. i4_bool active, // if the mouse is on us, or we have the key focus
  24. pressed, // if the mouse clicked us or ENTER was pressed while key focus
  25. disabled; // if this button is not currently enabled right now
  26. // if this is non null, the menu_parent will be notified of events sent
  27. i4_menu_item_parent_class *menu_parent;
  28. i4_graphical_style_class *hint;
  29. public :
  30. void set_menu_parent(i4_menu_item_parent_class *_menu_parent)
  31. { menu_parent=_menu_parent; }
  32. enum reaction_type { PRESSED, DEPRESSED, ACTIVATED, DEACTIVATED };
  33. struct // these event are only sent out, the are not noticed if sent in
  34. {
  35. i4_event_reaction_class *press, *depress;
  36. i4_event_reaction_class *activate, *deactivate;
  37. } send;
  38. i4_menu_item_class(const i4_const_str *idle_context_help, // can be null
  39. i4_graphical_style_class *hint, // can be null if idle_help is null
  40. w16 w, w16 h,
  41. i4_event_reaction_class *press=0,
  42. i4_event_reaction_class *depress=0,
  43. i4_event_reaction_class *activate=0,
  44. i4_event_reaction_class *deactivate=0
  45. );
  46. void set_context_help(const i4_const_str *help_string)
  47. {
  48. if (context_help)
  49. delete context_help;
  50. if (help_string)
  51. context_help = new i4_str(*help_string);
  52. else
  53. context_help = 0;
  54. }
  55. void send_event(i4_event_reaction_class *ev, reaction_type type);
  56. virtual void receive_event(i4_event *ev);
  57. virtual void do_activate();
  58. virtual void do_deactivate();
  59. virtual void do_disable();
  60. virtual void do_undisable();
  61. virtual void do_press();
  62. virtual void do_depress();
  63. virtual void do_idle();
  64. virtual i4_menu_item_class *copy() = 0;
  65. ~i4_menu_item_class();
  66. } ;
  67. // if a menu item has a pointer to it's parent, then it send it's events to the
  68. // parent instead of to who the event_reaction specifies
  69. class i4_menu_item_parent_class : public i4_parent_window_class
  70. {
  71. public:
  72. i4_menu_item_parent_class() : i4_parent_window_class(0,0) {}
  73. virtual void note_reaction_sent(i4_menu_item_class *who, // this is who sent it
  74. i4_event_reaction_class *ev, // who it was to
  75. i4_menu_item_class::reaction_type type) { ; }
  76. };
  77. #endif