menu.cc 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include "menu/menu.hh"
  9. #include "device/event.hh"
  10. #include "window/win_evt.hh"
  11. class i4_depress_menu_item : public i4_object_message_event_class
  12. {
  13. public :
  14. i4_menu_item_class *item;
  15. i4_depress_menu_item(i4_menu_class *menu,
  16. i4_menu_item_class *item)
  17. : i4_object_message_event_class(menu),item(item) {}
  18. virtual i4_event *copy()
  19. {
  20. return new i4_depress_menu_item((i4_menu_class *)object,item);
  21. }
  22. } ;
  23. void i4_menu_class::add_item(i4_menu_item_class *item)
  24. {
  25. item->set_menu_parent(this);
  26. i4_parent_window_class::add_child(0,0,item);
  27. }
  28. void i4_menu_class::note_reaction_sent(i4_menu_item_class *who, // this is who sent it
  29. i4_event_reaction_class *ev, // who it was to
  30. i4_menu_item_class::reaction_type type)
  31. {
  32. // if the item was pressed, send a delayed event to ourself to depress it
  33. if (type==i4_menu_item_class::PRESSED)
  34. {
  35. i4_depress_menu_item dn(this,who);
  36. i4_kernel.send_event(this,&dn);
  37. if (hide_on_pick)
  38. hide();
  39. }
  40. }
  41. void i4_menu_class::receive_event(i4_event *ev)
  42. {
  43. if (deleted)
  44. i4_warning("getting events after death, talk about wierd");
  45. if (ev->type()==i4_event::OBJECT_MESSAGE)
  46. {
  47. CAST_PTR(r,i4_depress_menu_item,ev);
  48. if (r->object==this)
  49. r->item->do_depress();
  50. else i4_parent_window_class::receive_event(ev);
  51. }
  52. else
  53. {
  54. if (ev->type()==i4_event::WINDOW_MESSAGE && focus_inform)
  55. {
  56. CAST_PTR(wev,i4_window_message_class,ev);
  57. if (wev->sub_type==i4_window_message_class::LOST_MOUSE_FOCUS)
  58. {
  59. CAST_PTR(lost, i4_window_lost_mouse_focus_class, ev);
  60. i4_menu_focus_event_class mlost(this,
  61. i4_menu_focus_event_class::lost_focus,
  62. lost->lost_to);
  63. i4_kernel.send_event(focus_inform, &mlost );
  64. }
  65. else if (wev->sub_type==i4_window_message_class::GOT_MOUSE_FOCUS)
  66. {
  67. i4_menu_focus_event_class got(this,
  68. i4_menu_focus_event_class::got_focus,
  69. 0);
  70. i4_kernel.send_event(focus_inform, &got );
  71. }
  72. }
  73. i4_parent_window_class::receive_event(ev);
  74. }
  75. }
  76. i4_menu_class::~i4_menu_class()
  77. {
  78. deleted=i4_T;
  79. }