vdk 2.4.0
sigc_eventsignals.h
1/* -*- c++ -*- */
2#ifndef _sigc_eventsignals_h_
3#define _sigc_eventsignals_h_
4#ifdef USE_SIGCPLUSPLUS
5
6#include <sigc++/signal_system.h>
7#include <vdk/sigc_events.h>
8using namespace SigC;
9
18class VDKRawEventSignal : public VDKSignal1<void, const GdkEvent *>,
19 private VDKNotCopyAble
20{
21public:
22 VDKRawEventSignal(VDKObject*);
23 ~VDKRawEventSignal();
24 Connection connect(const Slot1<void, const GdkEvent*>&);
25 Connection connect(const Slot2<void, VDKObject*, const GdkEvent *>&);
26 void disconnect(Connection&);
27
28private:
29 VDKObject* _obj;
30 guint _handler_id;
31 static gint event_handler(GtkObject* wid, GdkEvent* eve, gpointer obj);
32};
33
34/* here generic eventsignals begin */
35
36/* not used in user-land */
37typedef enum{
38 BUTTON_PRESS,
39 BUTTON_RELEASE,
40 FOCUS_KEY_IN,
41 FOCUS_KEY_OUT,
42 FOCUS_POINTER_IN,
43 FOCUS_POINTER_OUT,
44 GEOMETRY,
45 KEY_PRESS,
46 KEY_RELEASE,
47 MAPEVENT,
48 PAINT,
49 POINTER_MOVE,
50 POINTER_PRESSED
51} W2_TraitEnum;
52
58// typedef enum{
59// ME_FULLY_VISIBLE,
60// ME_PARTIAL_VISIBLE,
61// ME_NOT_VISIBLE
62// } VDKMapEventFilter;
63typedef VDKMapState VDKMapEventFilter;
64
75typedef enum{
76 BE_RELEASE,
77 BE_PRESS,
78 BE_CLICK2,
79 BE_CLICK3
80} VDKButtonEventFilter;
81
82
83
90typedef enum{
91 KE_RELEASE,
92 KE_PRESS
93} VDKKeyEventFilter;
94
101typedef enum{
102 FE_IN,
103 FE_OUT
104} VDKFocusEventFilter;
105
111typedef enum{
112 PE_ALL,
113 PE_PRESSED
114} VDKPointerEventFilter;
115
116
117
118/* *******************************************************************
119 * ******* Different Trait classes for template instantiation *******
120 * ******************************************************************/
121template<W2_TraitEnum id, int scount=0>
122class W2_Trait
123{
124public:
125 typedef GdkEvent ge_type; // Subclass of GdkEvent to dispatch
126 typedef int T_vcmp; // Filter-parameter-type
127 typedef GdkEventType T_gcmp; // Event-filter-type (must be
128 // convertible to int!)
129 static const char* signame; // Name to connect
130 static T_gcmp Field(GdkEvent* eve)
131 {return eve->type;}
132};
133
134template<W2_TraitEnum id>
135class W2_Trait<id, 1>
136{
137public:
138 typedef GdkEvent ge_type;
139 typedef int T_vcmp;
140 typedef GdkEventType T_gcmp;
141 static const int s_count;
142 static const char* signame;
143 static T_gcmp Field(GdkEvent* eve);
144 static const T_vcmp EN1;
145 static const T_gcmp GN1;
146};
147
148template<W2_TraitEnum id>
149class W2_Trait<id,2>
150{
151public:
152 typedef GdkEvent ge_type;
153 typedef int T_vcmp;
154 typedef GdkEventType T_gcmp;
155 static const int s_count;
156 static const char* signame;
157 static T_gcmp Field(GdkEvent* eve);
158 static const T_vcmp EN1;
159 static const T_gcmp GN1;
160 static const T_vcmp EN2;
161 static const T_gcmp GN2;
162};
163
164template<W2_TraitEnum id>
165class W2_Trait<id,3>
166{
167public:
168 typedef GdkEvent ge_type; // Subclass of GdkEvent to dispatch
169 typedef int T_vcmp; // Filter-parameter-type
170 typedef GdkEventType T_gcmp; // Event-filter-type (must be
171 // convertible to int!)
172 static const int s_count; // Anzahl der Signal-Objekte
173 static const char* signame; // Name to connect
174 static T_gcmp Field(GdkEvent* eve)
175 {return eve->type;}
176 static const T_vcmp EN1;
177 static const T_gcmp GN1;
178 static const T_vcmp EN2;
179 static const T_gcmp GN2;
180 static const T_vcmp EN3;
181 static const T_gcmp GN3;
182};
183
184#include <vdk/sigc_eventtraits.h>
185
186/* *******************************************************************
187 * * DirectEventSignal *
188 * *Simple Eventsignal, has one connection and no filtering parameter*
189 * ******************************************************************/
190// Second parameter to reduce number of traits
191template<W2_TraitEnum id, class T_vevent>
192class DirectEventSignal : public VDKSignal1<void, const T_vevent &>
193{
194 int _handler_id;
195 static void event_handler(GtkObject*, GdkEvent*, gpointer obj);
196 VDKObject* _sender;
197 typedef W2_Trait<id> T_trait;
198public:
199 DirectEventSignal(VDKObject* sender) : _handler_id(0),_sender(sender) {}
200 ~DirectEventSignal();
201 Connection connect(const Slot2<void,VDKObject*,const T_vevent &>&);
202 Connection connect(const Slot1<void, const T_vevent &>&);
203 void disconnect(Connection& con);
204};
205
206/* *******************************************************************
207 * * SignalWrapperStage2Base template *
208 * * Provides basefunctionality for SignalWrapperStage2-class *
209 * ******************************************************************/
210template<W2_TraitEnum id, class T_vevent, int s_count, class trait>
211class SignalWrapperStage2Base
212{
213 typedef W2_Trait<id> Trait;
214 typedef W2_Trait<id>::T_vcmp T_vcmp;
215 typedef W2_Trait<id>::T_gcmp T_gcmp;
216 int _handler_id; // holds gdksigc-connection id
217 VDKObject* _sender;
218 VDKSignal1<void,const T_vevent& > sig_vec[s_count];
219 static void event_handler(GtkObject*, GdkEvent*, gpointer obj);
220public:
221 SignalWrapperStage2Base(VDKObject* obj)
222 : _handler_id(0), _sender(obj) {}
223 ~SignalWrapperStage2Base();
224 // Überprüft alle internen Verbindungen und hebt ggf. die
225 // gtksigc-Verbindung auf.
226 void cleanup();
227 void disconnect(Connection&);
228 Connection connect(const Slot2<void,VDKObject*,const T_vevent &>&,
229 T_vcmp spec);
230 Connection connect(const Slot1<void,const T_vevent &>&, T_vcmp spec);
231 bool empty()const;
232 bool responsible(T_vcmp spec) const;
233};
234
235template<W2_TraitEnum id, class T_vevent, int s>
236class SignalWrapperStage2
237{
238 typedef W2_Trait<id> Trait;
239 typedef Trait::T_vcmp T_vcmp;
240 typedef Trait::T_gcmp T_gcmp;
241
242public:
243 SignalWrapperStage2(VDKObject* obj);
244};
245
246/* Acts as factroy at the same time */
247template<W2_TraitEnum id, class T_vevent>
248class SignalWrapperStage2<id,T_vevent,1>
249 : public SignalWrapperStage2Base<id,T_vevent,1, SignalWrapperStage2<id,T_vevent,1> >
250{
251 typedef W2_Trait<id> Trait;
252 typedef W2_Trait<id>::T_vcmp T_vcmp;
253 typedef W2_Trait<id>::T_gcmp T_gcmp;
254
255 friend class SignalWrapperStage2Base<id, T_vevent,1, SignalWrapperStage2<id,T_vevent,1> >;
256 static int vdk2vec(T_vcmp);
257 static int eve2vec(GdkEvent* eve);
258public: /* ??? */
259 SignalWrapperStage2(VDKObject* obj)
260 : SignalWrapperStage2Base<id, T_vevent,1, SignalWrapperStage2<id,T_vevent,1> >(obj)
261 {}
262};
263
264template<W2_TraitEnum id, class T_vevent>
265class SignalWrapperStage2<id,T_vevent,2>
266 : public SignalWrapperStage2Base<id,T_vevent,2, SignalWrapperStage2<id,T_vevent,2> >
267{
268 typedef W2_Trait<id> myTrait;
269 typedef myTrait::T_vcmp T_vcmp;
270 typedef myTrait::T_gcmp T_gcmp;
271 friend class SignalWrapperStage2Base<id,T_vevent,2,SignalWrapperStage2<id,T_vevent,2> >;
272 static int vdk2vec(T_vcmp);
273 static int eve2vec(GdkEvent* eve);
274public: /* ??? */
275 SignalWrapperStage2(VDKObject* obj)
276 : SignalWrapperStage2Base<id,T_vevent,2, SignalWrapperStage2<id,T_vevent,2> >(obj)
277 {}
278};
279
280template<W2_TraitEnum id, class T_vevent>
281class SignalWrapperStage2<id,T_vevent,3>
282 : public SignalWrapperStage2Base<id,T_vevent,3, SignalWrapperStage2<id,T_vevent,3> >
283{
284 typedef W2_Trait<id> myTrait;
285 typedef myTrait::T_vcmp T_vcmp;
286 typedef myTrait::T_gcmp T_gcmp;
287 friend class SignalWrapperStage2Base<id,T_vevent, 3, SignalWrapperStage2<id,T_vevent,3> >;
288 static int vdk2vec(T_vcmp);
289 static int eve2vec(GdkEvent* eve);
290public: /* ??? */
291 SignalWrapperStage2(VDKObject* obj)
292 : SignalWrapperStage2Base<id,T_vevent,3, SignalWrapperStage2<id,T_vevent,3> >(obj)
293 {}
294};
295
296/* **************************************************************************
297 * *** SignalWrapperStage1M2 ***
298 * *************************************************************************/
299template<W2_TraitEnum id1, int s_count1, W2_TraitEnum id2, int s_count2, class T_vevent>
300class SignalWrapperStage1M2
301{
302private:
303 typedef W2_Trait<id1> Trait1;
304 typedef W2_Trait<id2> Trait2;
305 typedef Trait1::T_vcmp T_vcmp;
306 SignalWrapperStage2<id1, T_vevent, s_count1> swrap1;
307 SignalWrapperStage2<id2, T_vevent, s_count2> swrap2;
308public:
309 SignalWrapperStage1M2(VDKObject* obj)
310 : swrap1(obj), swrap2(obj){}
311 bool empty() const;
312 Connection connect(const Slot2<void, VDKObject*, const T_vevent&>& sl,
313 T_vcmp spec);
314 Connection connect(const Slot1<void, const T_vevent&>& sl, T_vcmp spec);
315 void disconnect(Connection& con);
316};
317
318/* ************************************************************************
319 * *** Definition of different signals ***
320 * ***********************************************************************/
321typedef SignalWrapperStage1M2<BUTTON_PRESS,3, BUTTON_RELEASE, 1, VDKMouseEvent>
322 VDKButtonSignal;
323typedef SignalWrapperStage1M2<FOCUS_KEY_IN,1, FOCUS_KEY_OUT,1, VDKKeyFocusEvent>
324 VDKKeyFocusSignal;
325typedef SignalWrapperStage1M2<FOCUS_POINTER_IN,1, FOCUS_POINTER_OUT,1, VDKMouseFocusEvent>
326 VDKPointerFocusSignal;
327typedef SignalWrapperStage1M2<KEY_PRESS,1, KEY_RELEASE,1, VDKKeyEvent>
328 VDKKeySignal;
329typedef SignalWrapperStage1M2<POINTER_PRESSED,1, POINTER_MOVE,1, VDKMouseEvent>
330 VDKPointerSignal;
331typedef SignalWrapperStage2<MAPEVENT, VDKMapEvent, 3>
332 VDKMapSignal;
333typedef DirectEventSignal<GEOMETRY,VDKGeometryEvent>
334 VDKGeometrySignal;
335typedef DirectEventSignal<PAINT,VDKPaintEvent>
336 VDKPaintSignal;
337
338#endif /* USE_SIGCPLUSPLUS */
339#endif /* !_sigc_eventsignals_h_ */
Hierarchy root class.
Definition: vdkutils.h:264
Definition: vdkobj.h:141