source: golgotha/src/golg/editor/ce_event.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 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: 3.4 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#include "editor/contedit.hh"
10#include "device/event.hh"
11#include "window/win_evt.hh"
12#include "device/kernel.hh"
13#include "editor/e_state.hh"
14#include "tile.hh"
15#include "device/keys.hh"
16#include "editor/mode/e_mode.hh"
17#include "editor/editor.hh"
18
19
20void g1_controller_edit_class::receive_event(i4_event *ev)
21{
22  g1_object_controller_class::receive_event(ev);
23
24  if (!g1_map_is_loaded()) return ;
25  if (!active())
26  {
27    if (ev->type()==i4_event::WINDOW_MESSAGE)
28    {
29      CAST_PTR(wev, i4_window_message_class, ev);
30      if (wev->sub_type==i4_window_message_class::LOST_KEYBOARD_FOCUS)
31        unfocused();
32      return;
33    }             
34    else if (ev->type()==i4_event::MOUSE_BUTTON_DOWN)     
35    {
36      focused();
37      g1_current_controller=this;
38
39      request_redraw();
40      setup_context();
41      if (!mode->pass_through_focus_click())
42        return;
43    }
44    else
45    {
46      if (ev->type()==i4_event::MOUSE_MOVE)
47      {
48        CAST_PTR(mev, i4_mouse_move_event_class, ev);
49        last_mouse_x=mev->x;
50        last_mouse_y=mev->y;
51
52        if (abs((sw32)last_mouse_x-(sw32)g1_edit_state.context_help.mx)>15 ||
53            abs((sw32)last_mouse_y-(sw32)g1_edit_state.context_help.my)>15)
54          g1_edit_state.context_help.hide();
55
56      }
57
58      update_cursor();
59      return;
60    }
61  }
62
63
64  switch (ev->type())
65  {
66    case i4_event::IDLE_MESSAGE :
67    {
68      if (active())
69        mode->idle();
70    } break;
71
72
73    case i4_event::MOUSE_MOVE :
74    {
75      CAST_PTR(mev, i4_mouse_move_event_class, ev);
76      setup_context();
77      mode->mouse_move(mev->x, mev->y);
78      last_mouse_x=mev->x;
79      last_mouse_y=mev->y;
80
81      if (abs((sw32)last_mouse_x-(sw32)g1_edit_state.context_help.mx)>15 ||
82          abs((sw32)last_mouse_y-(sw32)g1_edit_state.context_help.my)>15)
83        g1_edit_state.context_help.hide();
84
85    } break;
86   
87    case i4_event::MOUSE_BUTTON_DOWN :
88    {
89      CAST_PTR(bev, i4_mouse_button_down_event_class, ev);
90      if (bev->left())
91      {
92        setup_context();
93        mode->mouse_down();
94      }
95    } break;
96
97    case i4_event::MOUSE_BUTTON_UP :
98    {
99      CAST_PTR(bev, i4_mouse_button_up_event_class, ev);
100      if (bev->left())
101      {
102        setup_context();
103        mode->mouse_up();
104      }
105    } break;
106
107    case i4_event::KEY_PRESS :
108    {
109      CAST_PTR(kev, i4_key_press_event_class, ev);
110      setup_context();
111      mode->key_press(kev);
112    } break;
113
114    case i4_event::WINDOW_MESSAGE :
115    {
116      CAST_PTR(wev, i4_window_message_class, ev);
117      switch (wev->sub_type)
118      {
119        case i4_window_message_class::LOST_KEYBOARD_FOCUS :
120          unfocused();
121          break;
122
123        case i4_window_message_class::LOST_MOUSE_FOCUS :
124          mode->hide_focus();
125          break;
126
127        case i4_window_message_class::GOT_MOUSE_FOCUS :
128          mode->show_focus();
129          break;
130
131      }
132    } break;
133
134 
135  }
136}
137
138
139
Note: See TracBrowser for help on using the repository browser.