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