Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/sg/event

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/event (Version 11.3.0) and /externals/g4tools/include/tools/sg/event (Version 11.2.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_sg_event                              4 #ifndef tools_sg_event
  5 #define tools_sg_event                              5 #define tools_sg_event
  6                                                     6 
  7 #include "../scast"                                 7 #include "../scast"
  8 #include "../S_STRING"                              8 #include "../S_STRING"
  9 #include "../typedefs"                              9 #include "../typedefs"
 10                                                    10 
 11 #ifdef TOOLS_MEM                                   11 #ifdef TOOLS_MEM
 12 #include "../mem"                                  12 #include "../mem"
 13 #endif                                             13 #endif
 14                                                    14 
 15 #define TOOLS_SG_EVENT_ID_CAST                     15 #define TOOLS_SG_EVENT_ID_CAST
 16                                                    16 
 17 namespace tools {                                  17 namespace tools {
 18 namespace sg {                                     18 namespace sg {
 19                                                    19 
 20 class event {                                      20 class event {
 21 public:                                            21 public:
 22 #ifdef TOOLS_SG_EVENT_ID_CAST                      22 #ifdef TOOLS_SG_EVENT_ID_CAST
 23   static cid id_class() {return 0;}                23   static cid id_class() {return 0;}
 24   virtual void* cast(cid) const = 0;               24   virtual void* cast(cid) const = 0;
 25 #else                                              25 #else
 26   virtual void* cast(const std::string&) const     26   virtual void* cast(const std::string&) const = 0;
 27 #endif                                             27 #endif
 28   virtual event* copy() const = 0;                 28   virtual event* copy() const = 0;
 29 public:                                            29 public:
 30 #ifdef TOOLS_MEM                                   30 #ifdef TOOLS_MEM
 31   TOOLS_SCLASS(tools::sg::event)                   31   TOOLS_SCLASS(tools::sg::event)
 32 #endif                                             32 #endif
 33 public:                                            33 public:
 34   event(){                                         34   event(){
 35 #ifdef TOOLS_MEM                                   35 #ifdef TOOLS_MEM
 36     mem::increment(s_class().c_str());             36     mem::increment(s_class().c_str());
 37 #endif                                             37 #endif
 38   }                                                38   }
 39   virtual ~event(){                                39   virtual ~event(){
 40 #ifdef TOOLS_MEM                                   40 #ifdef TOOLS_MEM
 41     mem::decrement(s_class().c_str());             41     mem::decrement(s_class().c_str());
 42 #endif                                             42 #endif
 43   }                                                43   }
 44 public:                                            44 public:
 45   event(const event&){                             45   event(const event&){
 46 #ifdef TOOLS_MEM                                   46 #ifdef TOOLS_MEM
 47     mem::increment(s_class().c_str());             47     mem::increment(s_class().c_str());
 48 #endif                                             48 #endif
 49   }                                                49   }
 50   event& operator=(const event&){return *this;     50   event& operator=(const event&){return *this;}
 51 };                                                 51 };
 52                                                    52 
 53 class size_event : public event {                  53 class size_event : public event {
 54   typedef event parent;                            54   typedef event parent;
 55 public:                                            55 public:
 56 #ifdef TOOLS_SG_EVENT_ID_CAST                      56 #ifdef TOOLS_SG_EVENT_ID_CAST
 57   static cid id_class() {return parent::id_cla     57   static cid id_class() {return parent::id_class()+1;}
 58   virtual void* cast(cid a_class) const {          58   virtual void* cast(cid a_class) const {
 59     if(void* p = cmp_cast<size_event>(this,a_c     59     if(void* p = cmp_cast<size_event>(this,a_class)) return p;
 60     return 0;                                      60     return 0;
 61   }                                                61   }
 62 #else                                              62 #else
 63   TOOLS_SCLASS(tools::sg::size_event)              63   TOOLS_SCLASS(tools::sg::size_event)
 64   virtual void* cast(const std::string& a_clas     64   virtual void* cast(const std::string& a_class) const {
 65     if(void* p = cmp_cast<size_event>(this,a_c     65     if(void* p = cmp_cast<size_event>(this,a_class)) {return p;}
 66     return 0;                                      66     return 0;
 67   }                                                67   }
 68 #endif                                             68 #endif
 69   virtual event* copy() const {return new size     69   virtual event* copy() const {return new size_event(*this);}
 70 public:                                            70 public:
 71   size_event(unsigned int a_ow,unsigned int a_     71   size_event(unsigned int a_ow,unsigned int a_oh,
 72              unsigned int a_w,unsigned int a_h     72              unsigned int a_w,unsigned int a_h)
 73   :m_ow(a_ow)                                      73   :m_ow(a_ow)
 74   ,m_oh(a_oh)                                      74   ,m_oh(a_oh)
 75   ,m_w(a_w)                                        75   ,m_w(a_w)
 76   ,m_h(a_h)                                        76   ,m_h(a_h)
 77   {}                                               77   {}
 78   virtual ~size_event(){}                          78   virtual ~size_event(){}
 79 public:                                            79 public:
 80   size_event(const size_event& a_from)             80   size_event(const size_event& a_from)
 81   :event(a_from)                                   81   :event(a_from)
 82   ,m_ow(a_from.m_ow)                               82   ,m_ow(a_from.m_ow)
 83   ,m_oh(a_from.m_oh)                               83   ,m_oh(a_from.m_oh)
 84   ,m_w(a_from.m_w)                                 84   ,m_w(a_from.m_w)
 85   ,m_h(a_from.m_h)                                 85   ,m_h(a_from.m_h)
 86   {}                                               86   {}
 87   size_event& operator=(const size_event& a_fr     87   size_event& operator=(const size_event& a_from){
 88     event::operator=(a_from);                      88     event::operator=(a_from);
 89     m_ow = a_from.m_ow;                            89     m_ow = a_from.m_ow;
 90     m_oh = a_from.m_oh;                            90     m_oh = a_from.m_oh;
 91     m_w = a_from.m_w;                              91     m_w = a_from.m_w;
 92     m_h = a_from.m_h;                              92     m_h = a_from.m_h;
 93     return *this;                                  93     return *this;
 94   }                                                94   }
 95 public:                                            95 public:
 96   unsigned int old_width() const {return m_ow;     96   unsigned int old_width() const {return m_ow;}
 97   unsigned int old_height() const {return m_oh     97   unsigned int old_height() const {return m_oh;}
 98   unsigned int width() const {return m_w;}         98   unsigned int width() const {return m_w;}
 99   unsigned int height() const {return m_h;}        99   unsigned int height() const {return m_h;}
100 protected:                                        100 protected:
101   unsigned int m_ow;                              101   unsigned int m_ow;
102   unsigned int m_oh;                              102   unsigned int m_oh;
103   unsigned int m_w;                               103   unsigned int m_w;
104   unsigned int m_h;                               104   unsigned int m_h;
105 };                                                105 };
106                                                   106 
107 class mouse_down_event : public event {           107 class mouse_down_event : public event {
108   typedef event parent;                           108   typedef event parent;
109 public:                                           109 public:
110 #ifdef TOOLS_SG_EVENT_ID_CAST                     110 #ifdef TOOLS_SG_EVENT_ID_CAST
111   static cid id_class() {return parent::id_cla    111   static cid id_class() {return parent::id_class()+2;}
112   virtual void* cast(cid a_class) const {         112   virtual void* cast(cid a_class) const {
113     if(void* p = cmp_cast<mouse_down_event>(th    113     if(void* p = cmp_cast<mouse_down_event>(this,a_class)) return p;
114     return 0;                                     114     return 0;
115   }                                               115   }
116 #else                                             116 #else
117   TOOLS_SCLASS(tools::sg::mouse_down_event)       117   TOOLS_SCLASS(tools::sg::mouse_down_event)
118   virtual void* cast(const std::string& a_clas    118   virtual void* cast(const std::string& a_class) const {
119     if(void* p = cmp_cast<mouse_down_event>(th    119     if(void* p = cmp_cast<mouse_down_event>(this,a_class)) {return p;}
120     return 0;                                     120     return 0;
121   }                                               121   }
122 #endif                                            122 #endif
123   virtual event* copy() const {return new mous    123   virtual event* copy() const {return new mouse_down_event(*this);}
124 public:                                           124 public:
125   mouse_down_event(int a_x,int a_y) //signed b    125   mouse_down_event(int a_x,int a_y) //signed because of wall.
126   :m_x(a_x)                                       126   :m_x(a_x)
127   ,m_y(a_y)                                       127   ,m_y(a_y)
128   {}                                              128   {}
129   virtual ~mouse_down_event(){}                   129   virtual ~mouse_down_event(){}
130 public:                                           130 public:
131   mouse_down_event(const mouse_down_event& a_f    131   mouse_down_event(const mouse_down_event& a_from)
132   :event(a_from)                                  132   :event(a_from)
133   ,m_x(a_from.m_x)                                133   ,m_x(a_from.m_x)
134   ,m_y(a_from.m_y)                                134   ,m_y(a_from.m_y)
135   {}                                              135   {}
136   mouse_down_event& operator=(const mouse_down    136   mouse_down_event& operator=(const mouse_down_event& a_from){
137     event::operator=(a_from);                     137     event::operator=(a_from);
138     m_x = a_from.m_x;                             138     m_x = a_from.m_x;
139     m_y = a_from.m_y;                             139     m_y = a_from.m_y;
140     return *this;                                 140     return *this;
141   }                                               141   }
142 public:                                           142 public:
143   int x() const {return m_x;}                     143   int x() const {return m_x;}
144   int y() const {return m_y;}                     144   int y() const {return m_y;}
145 protected:                                        145 protected:
146   int m_x;                                        146   int m_x;
147   int m_y;                                        147   int m_y;
148 };                                                148 };
149                                                   149 
150 class mouse_up_event : public event {             150 class mouse_up_event : public event {
151   typedef event parent;                           151   typedef event parent;
152 public:                                           152 public:
153 #ifdef TOOLS_SG_EVENT_ID_CAST                     153 #ifdef TOOLS_SG_EVENT_ID_CAST
154   static cid id_class() {return parent::id_cla    154   static cid id_class() {return parent::id_class()+3;}
155   virtual void* cast(cid a_class) const {         155   virtual void* cast(cid a_class) const {
156     if(void* p = cmp_cast<mouse_up_event>(this    156     if(void* p = cmp_cast<mouse_up_event>(this,a_class)) return p;
157     return 0;                                     157     return 0;
158   }                                               158   }
159 #else                                             159 #else
160   TOOLS_SCLASS(tools::sg::mouse_up_event)         160   TOOLS_SCLASS(tools::sg::mouse_up_event)
161   virtual void* cast(const std::string& a_clas    161   virtual void* cast(const std::string& a_class) const {
162     if(void* p = cmp_cast<mouse_up_event>(this    162     if(void* p = cmp_cast<mouse_up_event>(this,a_class)) {return p;}
163     return 0;                                     163     return 0;
164   }                                               164   }
165 #endif                                            165 #endif
166   virtual event* copy() const {return new mous    166   virtual event* copy() const {return new mouse_up_event(*this);}
167 public:                                           167 public:
168   mouse_up_event(int a_x,int a_y) //signed bec    168   mouse_up_event(int a_x,int a_y) //signed because of wall.
169   :m_x(a_x)                                       169   :m_x(a_x)
170   ,m_y(a_y)                                       170   ,m_y(a_y)
171   {}                                              171   {}
172   virtual ~mouse_up_event(){}                     172   virtual ~mouse_up_event(){}
173 public:                                           173 public:
174   mouse_up_event(const mouse_up_event& a_from)    174   mouse_up_event(const mouse_up_event& a_from)
175   :event(a_from)                                  175   :event(a_from)
176   ,m_x(a_from.m_x)                                176   ,m_x(a_from.m_x)
177   ,m_y(a_from.m_y)                                177   ,m_y(a_from.m_y)
178   {}                                              178   {}
179   mouse_up_event& operator=(const mouse_up_eve    179   mouse_up_event& operator=(const mouse_up_event& a_from){
180     event::operator=(a_from);                     180     event::operator=(a_from);
181     m_x = a_from.m_x;                             181     m_x = a_from.m_x;
182     m_y = a_from.m_y;                             182     m_y = a_from.m_y;
183     return *this;                                 183     return *this;
184   }                                               184   }
185 public:                                           185 public:
186   int x() const {return m_x;}                     186   int x() const {return m_x;}
187   int y() const {return m_y;}                     187   int y() const {return m_y;}
188 protected:                                        188 protected:
189   int m_x;                                        189   int m_x;
190   int m_y;                                        190   int m_y;
191 };                                                191 };
192                                                   192 
193 class mouse_move_event : public event {           193 class mouse_move_event : public event {
194   typedef event parent;                           194   typedef event parent;
195 public:                                           195 public:
196 #ifdef TOOLS_SG_EVENT_ID_CAST                     196 #ifdef TOOLS_SG_EVENT_ID_CAST
197   static cid id_class() {return parent::id_cla    197   static cid id_class() {return parent::id_class()+4;}
198   virtual void* cast(cid a_class) const {         198   virtual void* cast(cid a_class) const {
199     if(void* p = cmp_cast<mouse_move_event>(th    199     if(void* p = cmp_cast<mouse_move_event>(this,a_class)) return p;
200     return 0;                                     200     return 0;
201   }                                               201   }
202 #else                                             202 #else
203   TOOLS_SCLASS(tools::sg::mouse_move_event)       203   TOOLS_SCLASS(tools::sg::mouse_move_event)
204   virtual void* cast(const std::string& a_clas    204   virtual void* cast(const std::string& a_class) const {
205     if(void* p = cmp_cast<mouse_move_event>(th    205     if(void* p = cmp_cast<mouse_move_event>(this,a_class)) {return p;}
206     return 0;                                     206     return 0;
207   }                                               207   }
208 #endif                                            208 #endif
209   virtual event* copy() const {return new mous    209   virtual event* copy() const {return new mouse_move_event(*this);}
210 public:                                           210 public:
211   mouse_move_event(int a_x,int a_y, //signed b    211   mouse_move_event(int a_x,int a_y, //signed because of wall.
212                    int a_ox,int a_oy,             212                    int a_ox,int a_oy,
213                    bool a_touch) //for sliders    213                    bool a_touch) //for sliders.
214   :m_x(a_x)                                       214   :m_x(a_x)
215   ,m_y(a_y)                                       215   ,m_y(a_y)
216   ,m_ox(a_ox)                                     216   ,m_ox(a_ox)
217   ,m_oy(a_oy)                                     217   ,m_oy(a_oy)
218   ,m_touch(a_touch)                               218   ,m_touch(a_touch)
219   {}                                              219   {}
220   virtual ~mouse_move_event(){}                   220   virtual ~mouse_move_event(){}
221 public:                                           221 public:
222   mouse_move_event(const mouse_move_event& a_f    222   mouse_move_event(const mouse_move_event& a_from)
223   :event(a_from)                                  223   :event(a_from)
224   ,m_x(a_from.m_x)                                224   ,m_x(a_from.m_x)
225   ,m_y(a_from.m_y)                                225   ,m_y(a_from.m_y)
226   ,m_ox(a_from.m_ox)                              226   ,m_ox(a_from.m_ox)
227   ,m_oy(a_from.m_oy)                              227   ,m_oy(a_from.m_oy)
228   ,m_touch(a_from.m_touch)                        228   ,m_touch(a_from.m_touch)
229   {}                                              229   {}
230   mouse_move_event& operator=(const mouse_move    230   mouse_move_event& operator=(const mouse_move_event& a_from){
231     event::operator=(a_from);                     231     event::operator=(a_from);
232     m_x = a_from.m_x;                             232     m_x = a_from.m_x;
233     m_y = a_from.m_y;                             233     m_y = a_from.m_y;
234                                                   234 
235     m_ox = a_from.m_ox;                           235     m_ox = a_from.m_ox;
236     m_oy = a_from.m_oy;                           236     m_oy = a_from.m_oy;
237                                                   237 
238     m_touch = a_from.m_touch;                     238     m_touch = a_from.m_touch;
239     return *this;                                 239     return *this;
240   }                                               240   }
241 public:                                           241 public:
242   int x() const {return m_x;}                     242   int x() const {return m_x;}
243   int y() const {return m_y;}                     243   int y() const {return m_y;}
244   int ox() const {return m_ox;}                   244   int ox() const {return m_ox;}
245   int oy() const {return m_oy;}                   245   int oy() const {return m_oy;}
246   bool is_touch() const {return m_touch;}         246   bool is_touch() const {return m_touch;}
247 protected:                                        247 protected:
248   int m_x;                                        248   int m_x;
249   int m_y;                                        249   int m_y;
250   int m_ox;                                       250   int m_ox;
251   int m_oy;  //+ = up.                            251   int m_oy;  //+ = up.
252   // etc :                                        252   // etc :
253   bool m_touch;                                   253   bool m_touch;
254 };                                                254 };
255                                                   255 
256 class anim_event : public event {                 256 class anim_event : public event {
257   typedef event parent;                           257   typedef event parent;
258 public:                                           258 public:
259 #ifdef TOOLS_SG_EVENT_ID_CAST                     259 #ifdef TOOLS_SG_EVENT_ID_CAST
260   static cid id_class() {return parent::id_cla    260   static cid id_class() {return parent::id_class()+5;}
261   virtual void* cast(cid a_class) const {         261   virtual void* cast(cid a_class) const {
262     if(void* p = cmp_cast<anim_event>(this,a_c    262     if(void* p = cmp_cast<anim_event>(this,a_class)) return p;
263     return 0;                                     263     return 0;
264   }                                               264   }
265 #else                                             265 #else
266   TOOLS_SCLASS(tools::sg::anim_event)             266   TOOLS_SCLASS(tools::sg::anim_event)
267   virtual void* cast(const std::string& a_clas    267   virtual void* cast(const std::string& a_class) const {
268     if(void* p = cmp_cast<anim_event>(this,a_c    268     if(void* p = cmp_cast<anim_event>(this,a_class)) {return p;}
269     return 0;                                     269     return 0;
270   }                                               270   }
271 #endif                                            271 #endif
272   virtual event* copy() const {return new anim    272   virtual event* copy() const {return new anim_event(*this);}
273 public:                                           273 public:
274   typedef uint64 num_t;                           274   typedef uint64 num_t;
275   anim_event(num_t a_secs,num_t a_micro_secs)     275   anim_event(num_t a_secs,num_t a_micro_secs)
276   :m_secs(a_secs),m_micro_secs(a_micro_secs)      276   :m_secs(a_secs),m_micro_secs(a_micro_secs)
277   ,m_some_found(false)                            277   ,m_some_found(false)
278   {}                                              278   {}
279   virtual ~anim_event(){}                         279   virtual ~anim_event(){}
280 public:                                           280 public:
281   anim_event(const anim_event& a_from)            281   anim_event(const anim_event& a_from)
282   :event(a_from)                                  282   :event(a_from)
283   ,m_secs(a_from.m_secs)                          283   ,m_secs(a_from.m_secs)
284   ,m_micro_secs(a_from.m_micro_secs)              284   ,m_micro_secs(a_from.m_micro_secs)
285   ,m_some_found(a_from.m_some_found)              285   ,m_some_found(a_from.m_some_found)
286   {}                                              286   {}
287   anim_event& operator=(const anim_event& a_fr    287   anim_event& operator=(const anim_event& a_from){
288     event::operator=(a_from);                     288     event::operator=(a_from);
289     m_secs = a_from.m_secs;                       289     m_secs = a_from.m_secs;
290     m_micro_secs = a_from.m_micro_secs;           290     m_micro_secs = a_from.m_micro_secs;
291     m_some_found = a_from.m_some_found;           291     m_some_found = a_from.m_some_found;
292     return *this;                                 292     return *this;
293   }                                               293   }
294 public:                                           294 public:
295 /*                                                295 /*
296   void set_time(num_t a_secs,num_t a_micro_sec    296   void set_time(num_t a_secs,num_t a_micro_secs) {
297     m_secs = a_secs;                              297     m_secs = a_secs;
298     m_micro_secs = a_micro_secs;                  298     m_micro_secs = a_micro_secs;
299   }                                               299   }
300 */                                                300 */
301   num_t seconds() const {return m_secs;}          301   num_t seconds() const {return m_secs;}
302   num_t micro_seconds() const {return m_micro_    302   num_t micro_seconds() const {return m_micro_secs;}
303                                                   303 
304   void set_some_found(bool a_v) {m_some_found     304   void set_some_found(bool a_v) {m_some_found = a_v;}
305   bool some_found() const {return m_some_found    305   bool some_found() const {return m_some_found;}
306 protected:                                        306 protected:
307   num_t m_secs;                                   307   num_t m_secs;
308   num_t m_micro_secs;                             308   num_t m_micro_secs;
309   bool m_some_found;                              309   bool m_some_found;
310 };                                                310 };
311                                                   311 
312 class key_down_event : public event {             312 class key_down_event : public event {
313   typedef event parent;                           313   typedef event parent;
314 public:                                           314 public:
315 #ifdef TOOLS_SG_EVENT_ID_CAST                     315 #ifdef TOOLS_SG_EVENT_ID_CAST
316   static cid id_class() {return parent::id_cla    316   static cid id_class() {return parent::id_class()+6;}
317   virtual void* cast(cid a_class) const {         317   virtual void* cast(cid a_class) const {
318     if(void* p = cmp_cast<key_down_event>(this    318     if(void* p = cmp_cast<key_down_event>(this,a_class)) return p;
319     return 0;                                     319     return 0;
320   }                                               320   }
321 #else                                             321 #else
322   TOOLS_SCLASS(tools::sg::key_down_event)         322   TOOLS_SCLASS(tools::sg::key_down_event)
323   virtual void* cast(const std::string& a_clas    323   virtual void* cast(const std::string& a_class) const {
324     if(void* p = cmp_cast<key_down_event>(this    324     if(void* p = cmp_cast<key_down_event>(this,a_class)) {return p;}
325     return 0;                                     325     return 0;
326   }                                               326   }
327 #endif                                            327 #endif
328   virtual event* copy() const {return new key_    328   virtual event* copy() const {return new key_down_event(*this);}
329 public:                                           329 public:
330   key_down_event(key_code a_key)                  330   key_down_event(key_code a_key)
331   :m_key(a_key)                                   331   :m_key(a_key)
332   {}                                              332   {}
333   virtual ~key_down_event(){}                     333   virtual ~key_down_event(){}
334 public:                                           334 public:
335   key_down_event(const key_down_event& a_from)    335   key_down_event(const key_down_event& a_from)
336   :event(a_from)                                  336   :event(a_from)
337   ,m_key(a_from.m_key)                            337   ,m_key(a_from.m_key)
338   {}                                              338   {}
339   key_down_event& operator=(const key_down_eve    339   key_down_event& operator=(const key_down_event& a_from){
340     event::operator=(a_from);                     340     event::operator=(a_from);
341     m_key = a_from.m_key;                         341     m_key = a_from.m_key;
342     return *this;                                 342     return *this;
343   }                                               343   }
344 public:                                           344 public:
345   key_code key() const {return m_key;}            345   key_code key() const {return m_key;}
346 protected:                                        346 protected:
347   key_code m_key;                                 347   key_code m_key;
348 };                                                348 };
349                                                   349 
350 class key_up_event : public event {               350 class key_up_event : public event {
351   typedef event parent;                           351   typedef event parent;
352 public:                                           352 public:
353 #ifdef TOOLS_SG_EVENT_ID_CAST                     353 #ifdef TOOLS_SG_EVENT_ID_CAST
354   static cid id_class() {return parent::id_cla    354   static cid id_class() {return parent::id_class()+7;}
355   virtual void* cast(cid a_class) const {         355   virtual void* cast(cid a_class) const {
356     if(void* p = cmp_cast<key_up_event>(this,a    356     if(void* p = cmp_cast<key_up_event>(this,a_class)) return p;
357     return 0;                                     357     return 0;
358   }                                               358   }
359 #else                                             359 #else
360   TOOLS_SCLASS(tools::sg::key_up_event)           360   TOOLS_SCLASS(tools::sg::key_up_event)
361   virtual void* cast(const std::string& a_clas    361   virtual void* cast(const std::string& a_class) const {
362     if(void* p = cmp_cast<key_up_event>(this,a    362     if(void* p = cmp_cast<key_up_event>(this,a_class)) {return p;}
363     return 0;                                     363     return 0;
364   }                                               364   }
365 #endif                                            365 #endif
366   virtual event* copy() const {return new key_    366   virtual event* copy() const {return new key_up_event(*this);}
367 public:                                           367 public:
368   key_up_event(key_code a_key)                    368   key_up_event(key_code a_key)
369   :m_key(a_key)                                   369   :m_key(a_key)
370   {}                                              370   {}
371   virtual ~key_up_event(){}                       371   virtual ~key_up_event(){}
372 public:                                           372 public:
373   key_up_event(const key_up_event& a_from)        373   key_up_event(const key_up_event& a_from)
374   :event(a_from)                                  374   :event(a_from)
375   ,m_key(a_from.m_key)                            375   ,m_key(a_from.m_key)
376   {}                                              376   {}
377   key_up_event& operator=(const key_up_event&     377   key_up_event& operator=(const key_up_event& a_from){
378     event::operator=(a_from);                     378     event::operator=(a_from);
379     m_key = a_from.m_key;                         379     m_key = a_from.m_key;
380     return *this;                                 380     return *this;
381   }                                               381   }
382 public:                                           382 public:
383   key_code key() const {return m_key;}            383   key_code key() const {return m_key;}
384 protected:                                        384 protected:
385   key_code m_key;                                 385   key_code m_key;
386 };                                                386 };
387                                                   387 
388 class wheel_rotate_event : public event {         388 class wheel_rotate_event : public event {
389   typedef event parent;                           389   typedef event parent;
390 public:                                           390 public:
391 #ifdef TOOLS_SG_EVENT_ID_CAST                     391 #ifdef TOOLS_SG_EVENT_ID_CAST
392   static cid id_class() {return parent::id_cla    392   static cid id_class() {return parent::id_class()+8;}
393   virtual void* cast(cid a_class) const {         393   virtual void* cast(cid a_class) const {
394     if(void* p = cmp_cast<wheel_rotate_event>(    394     if(void* p = cmp_cast<wheel_rotate_event>(this,a_class)) return p;
395     return 0;                                     395     return 0;
396   }                                               396   }
397 #else                                             397 #else
398   TOOLS_SCLASS(tools::sg::wheel_rotate_event)     398   TOOLS_SCLASS(tools::sg::wheel_rotate_event)
399   virtual void* cast(const std::string& a_clas    399   virtual void* cast(const std::string& a_class) const {
400     if(void* p = cmp_cast<wheel_rotate_event>(    400     if(void* p = cmp_cast<wheel_rotate_event>(this,a_class)) {return p;}
401     return 0;                                     401     return 0;
402   }                                               402   }
403 #endif                                            403 #endif
404   virtual event* copy() const {return new whee    404   virtual event* copy() const {return new wheel_rotate_event(*this);}
405 public:                                           405 public:
406   wheel_rotate_event(int a_angle)                 406   wheel_rotate_event(int a_angle)
407   :m_angle(a_angle)                               407   :m_angle(a_angle)
408   {}                                              408   {}
409   virtual ~wheel_rotate_event(){}                 409   virtual ~wheel_rotate_event(){}
410 public:                                           410 public:
411   wheel_rotate_event(const wheel_rotate_event&    411   wheel_rotate_event(const wheel_rotate_event& a_from)
412   :event(a_from)                                  412   :event(a_from)
413   ,m_angle(a_from.m_angle)                        413   ,m_angle(a_from.m_angle)
414   {}                                              414   {}
415   wheel_rotate_event& operator=(const wheel_ro    415   wheel_rotate_event& operator=(const wheel_rotate_event& a_from){
416     event::operator=(a_from);                     416     event::operator=(a_from);
417     m_angle = a_from.m_angle;                     417     m_angle = a_from.m_angle;
418     return *this;                                 418     return *this;
419   }                                               419   }
420 public:                                           420 public:
421   int angle() const {return m_angle;}             421   int angle() const {return m_angle;}
422 protected:                                        422 protected:
423   int m_angle;                                    423   int m_angle;
424 };                                                424 };
425                                                   425 
426 #ifdef TOOLS_SG_EVENT_ID_CAST                     426 #ifdef TOOLS_SG_EVENT_ID_CAST
427 template <class FROM,class TO> inline TO* even    427 template <class FROM,class TO> inline TO* event_cast(FROM& a_o) {return id_cast<FROM,TO>(a_o);}
428 template <class FROM,class TO> inline const TO    428 template <class FROM,class TO> inline const TO* event_cast(const FROM& a_o) {return id_cast<FROM,TO>(a_o);}
429 #else                                             429 #else
430 template <class FROM,class TO> inline TO* even    430 template <class FROM,class TO> inline TO* event_cast(FROM& a_o) {return safe_cast<FROM,TO>(a_o);}
431 template <class FROM,class TO> inline const TO    431 template <class FROM,class TO> inline const TO* event_cast(const FROM& a_o) {return safe_cast<FROM,TO>(a_o);}
432 #endif                                            432 #endif
433                                                   433 
434 inline bool get_event_xy(const sg::event& a_ev    434 inline bool get_event_xy(const sg::event& a_event,int& a_x,int& a_y) {
435   typedef sg::event evt_t;                        435   typedef sg::event evt_t;
436   typedef sg::mouse_up_event up_evt_t;            436   typedef sg::mouse_up_event up_evt_t;
437   typedef sg::mouse_down_event dn_evt_t;          437   typedef sg::mouse_down_event dn_evt_t;
438   if(const dn_evt_t* devt = event_cast<evt_t,d    438   if(const dn_evt_t* devt = event_cast<evt_t,dn_evt_t>(a_event)) {
439     a_x = devt->x();                              439     a_x = devt->x();
440     a_y = devt->y();                              440     a_y = devt->y();
441     return true;                                  441     return true;
442                                                   442 
443   } else if(const up_evt_t* uevt = event_cast<    443   } else if(const up_evt_t* uevt = event_cast<evt_t,up_evt_t>(a_event)) {
444     a_x = uevt->x();                              444     a_x = uevt->x();
445     a_y = uevt->y();                              445     a_y = uevt->y();
446     return true;                                  446     return true;
447                                                   447 
448   }                                               448   }
449   a_x = 0;                                        449   a_x = 0;
450   a_y = 0;                                        450   a_y = 0;
451   return false;                                   451   return false;
452 }                                                 452 }
453                                                   453 
454 }}                                                454 }}
455                                                   455 
456 #endif                                            456 #endif