menu.hh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 __MENU_HPP_
  9. #define __MENU_HPP_
  10. #include "window/window.hh"
  11. #include "error/error.hh"
  12. #include "menu/menuitem.hh"
  13. #include "string/string.hh"
  14. class i4_menu_class : public i4_menu_item_parent_class
  15. {
  16. // when a menu_item sends it's a press event should the menu hide itself?
  17. i4_bool hide_on_pick;
  18. i4_bool deleted; // debugging tool so we can see if we already got events
  19. i4_event_handler_class *focus_inform;
  20. public:
  21. virtual void notify_focus_change(i4_event_handler_class *who)
  22. { focus_inform=who; }
  23. // show should make the menu visible on the screen
  24. virtual void show(i4_parent_window_class *show_on, i4_coord x, i4_coord y) = 0;
  25. virtual void hide() = 0;
  26. // apps should call hide() before add_item()
  27. virtual void add_item(i4_menu_item_class *item);
  28. virtual void receive_event(i4_event *ev);
  29. i4_menu_class(i4_bool hide_on_pick)
  30. : hide_on_pick(hide_on_pick)
  31. {
  32. focus_inform=0;
  33. deleted=i4_F;
  34. }
  35. virtual ~i4_menu_class();
  36. virtual void add_child(i4_coord x, i4_coord y, i4_window_class *child)
  37. { i4_error("use add_item"); }
  38. virtual void note_reaction_sent(i4_menu_item_class *who, // this is who sent it
  39. i4_event_reaction_class *ev, // who it was to
  40. i4_menu_item_class::reaction_type type);
  41. } ;
  42. class i4_menu_focus_event_class : public i4_object_message_event_class
  43. {
  44. public:
  45. enum focus_state_type { got_focus, lost_focus } focus_state;
  46. i4_window_class *lost_to;
  47. i4_menu_focus_event_class(i4_menu_class *menu,
  48. focus_state_type state,
  49. i4_window_class *lost_to)
  50. : i4_object_message_event_class(menu),
  51. focus_state(state),
  52. lost_to(lost_to)
  53. {}
  54. virtual i4_event *copy()
  55. {
  56. return new i4_menu_focus_event_class((i4_menu_class *)object,
  57. focus_state,
  58. lost_to);
  59. }
  60. char *name() { return "menu lost focus"; }
  61. };
  62. #endif