Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

sigc_eventsignals.h

00001 /* -*- c++ -*- */ 00002 #ifndef _sigc_eventsignals_h_ 00003 #define _sigc_eventsignals_h_ 00004 #ifdef USE_SIGCPLUSPLUS 00005 00006 #include <sigc++/signal_system.h> 00007 #include <vdk/sigc_events.h> 00008 using namespace SigC; 00009 00018 class VDKRawEventSignal : public VDKSignal1<void, const GdkEvent *>, 00019 private VDKNotCopyAble 00020 { 00021 public: 00022 VDKRawEventSignal(VDKObject*); 00023 ~VDKRawEventSignal(); 00024 Connection connect(const Slot1<void, const GdkEvent*>&); 00025 Connection connect(const Slot2<void, VDKObject*, const GdkEvent *>&); 00026 void disconnect(Connection&); 00027 00028 private: 00029 VDKObject* _obj; 00030 guint _handler_id; 00031 static gint event_handler(GtkObject* wid, GdkEvent* eve, gpointer obj); 00032 }; 00033 00034 /* here generic eventsignals begin */ 00035 00036 /* not used in user-land */ 00037 typedef enum{ 00038 BUTTON_PRESS, 00039 BUTTON_RELEASE, 00040 FOCUS_KEY_IN, 00041 FOCUS_KEY_OUT, 00042 FOCUS_POINTER_IN, 00043 FOCUS_POINTER_OUT, 00044 GEOMETRY, 00045 KEY_PRESS, 00046 KEY_RELEASE, 00047 MAPEVENT, 00048 PAINT, 00049 POINTER_MOVE, 00050 POINTER_PRESSED 00051 } W2_TraitEnum; 00052 00058 // typedef enum{ 00059 // ME_FULLY_VISIBLE, 00060 // ME_PARTIAL_VISIBLE, 00061 // ME_NOT_VISIBLE 00062 // } VDKMapEventFilter; 00063 typedef VDKMapState VDKMapEventFilter; 00064 00075 typedef enum{ 00076 BE_RELEASE, 00077 BE_PRESS, 00078 BE_CLICK2, 00079 BE_CLICK3 00080 } VDKButtonEventFilter; 00081 00082 00083 00090 typedef enum{ 00091 KE_RELEASE, 00092 KE_PRESS 00093 } VDKKeyEventFilter; 00094 00101 typedef enum{ 00102 FE_IN, 00103 FE_OUT 00104 } VDKFocusEventFilter; 00105 00111 typedef enum{ 00112 PE_ALL, 00113 PE_PRESSED 00114 } VDKPointerEventFilter; 00115 00116 00117 00118 /* ******************************************************************* 00119 * ******* Different Trait classes for template instantiation ******* 00120 * ******************************************************************/ 00121 template<W2_TraitEnum id, int scount=0> 00122 class W2_Trait 00123 { 00124 public: 00125 typedef GdkEvent ge_type; // Subclass of GdkEvent to dispatch 00126 typedef int T_vcmp; // Filter-parameter-type 00127 typedef GdkEventType T_gcmp; // Event-filter-type (must be 00128 // convertible to int!) 00129 static const char* signame; // Name to connect 00130 static T_gcmp Field(GdkEvent* eve) 00131 {return eve->type;} 00132 }; 00133 00134 template<W2_TraitEnum id> 00135 class W2_Trait<id, 1> 00136 { 00137 public: 00138 typedef GdkEvent ge_type; 00139 typedef int T_vcmp; 00140 typedef GdkEventType T_gcmp; 00141 static const int s_count; 00142 static const char* signame; 00143 static T_gcmp Field(GdkEvent* eve); 00144 static const T_vcmp EN1; 00145 static const T_gcmp GN1; 00146 }; 00147 00148 template<W2_TraitEnum id> 00149 class W2_Trait<id,2> 00150 { 00151 public: 00152 typedef GdkEvent ge_type; 00153 typedef int T_vcmp; 00154 typedef GdkEventType T_gcmp; 00155 static const int s_count; 00156 static const char* signame; 00157 static T_gcmp Field(GdkEvent* eve); 00158 static const T_vcmp EN1; 00159 static const T_gcmp GN1; 00160 static const T_vcmp EN2; 00161 static const T_gcmp GN2; 00162 }; 00163 00164 template<W2_TraitEnum id> 00165 class W2_Trait<id,3> 00166 { 00167 public: 00168 typedef GdkEvent ge_type; // Subclass of GdkEvent to dispatch 00169 typedef int T_vcmp; // Filter-parameter-type 00170 typedef GdkEventType T_gcmp; // Event-filter-type (must be 00171 // convertible to int!) 00172 static const int s_count; // Anzahl der Signal-Objekte 00173 static const char* signame; // Name to connect 00174 static T_gcmp Field(GdkEvent* eve) 00175 {return eve->type;} 00176 static const T_vcmp EN1; 00177 static const T_gcmp GN1; 00178 static const T_vcmp EN2; 00179 static const T_gcmp GN2; 00180 static const T_vcmp EN3; 00181 static const T_gcmp GN3; 00182 }; 00183 00184 #include <vdk/sigc_eventtraits.h> 00185 00186 /* ******************************************************************* 00187 * * DirectEventSignal * 00188 * *Simple Eventsignal, has one connection and no filtering parameter* 00189 * ******************************************************************/ 00190 // Second parameter to reduce number of traits 00191 template<W2_TraitEnum id, class T_vevent> 00192 class DirectEventSignal : public VDKSignal1<void, const T_vevent &> 00193 { 00194 int _handler_id; 00195 static void event_handler(GtkObject*, GdkEvent*, gpointer obj); 00196 VDKObject* _sender; 00197 typedef W2_Trait<id> T_trait; 00198 public: 00199 DirectEventSignal(VDKObject* sender) : _handler_id(0),_sender(sender) {} 00200 ~DirectEventSignal(); 00201 Connection connect(const Slot2<void,VDKObject*,const T_vevent &>&); 00202 Connection connect(const Slot1<void, const T_vevent &>&); 00203 void disconnect(Connection& con); 00204 }; 00205 00206 /* ******************************************************************* 00207 * * SignalWrapperStage2Base template * 00208 * * Provides basefunctionality for SignalWrapperStage2-class * 00209 * ******************************************************************/ 00210 template<W2_TraitEnum id, class T_vevent, int s_count, class trait> 00211 class SignalWrapperStage2Base 00212 { 00213 typedef W2_Trait<id> Trait; 00214 typedef W2_Trait<id>::T_vcmp T_vcmp; 00215 typedef W2_Trait<id>::T_gcmp T_gcmp; 00216 int _handler_id; // holds gdksigc-connection id 00217 VDKObject* _sender; 00218 VDKSignal1<void,const T_vevent& > sig_vec[s_count]; 00219 static void event_handler(GtkObject*, GdkEvent*, gpointer obj); 00220 public: 00221 SignalWrapperStage2Base(VDKObject* obj) 00222 : _handler_id(0), _sender(obj) {} 00223 ~SignalWrapperStage2Base(); 00224 // Überprüft alle internen Verbindungen und hebt ggf. die 00225 // gtksigc-Verbindung auf. 00226 void cleanup(); 00227 void disconnect(Connection&); 00228 Connection connect(const Slot2<void,VDKObject*,const T_vevent &>&, 00229 T_vcmp spec); 00230 Connection connect(const Slot1<void,const T_vevent &>&, T_vcmp spec); 00231 bool empty()const; 00232 bool responsible(T_vcmp spec) const; 00233 }; 00234 00235 template<W2_TraitEnum id, class T_vevent, int s> 00236 class SignalWrapperStage2 00237 { 00238 typedef W2_Trait<id> Trait; 00239 typedef Trait::T_vcmp T_vcmp; 00240 typedef Trait::T_gcmp T_gcmp; 00241 00242 public: 00243 SignalWrapperStage2(VDKObject* obj); 00244 }; 00245 00246 /* Acts as factroy at the same time */ 00247 template<W2_TraitEnum id, class T_vevent> 00248 class SignalWrapperStage2<id,T_vevent,1> 00249 : public SignalWrapperStage2Base<id,T_vevent,1, SignalWrapperStage2<id,T_vevent,1> > 00250 { 00251 typedef W2_Trait<id> Trait; 00252 typedef W2_Trait<id>::T_vcmp T_vcmp; 00253 typedef W2_Trait<id>::T_gcmp T_gcmp; 00254 00255 friend class SignalWrapperStage2Base<id, T_vevent,1, SignalWrapperStage2<id,T_vevent,1> >; 00256 static int vdk2vec(T_vcmp); 00257 static int eve2vec(GdkEvent* eve); 00258 public: /* ??? */ 00259 SignalWrapperStage2(VDKObject* obj) 00260 : SignalWrapperStage2Base<id, T_vevent,1, SignalWrapperStage2<id,T_vevent,1> >(obj) 00261 {} 00262 }; 00263 00264 template<W2_TraitEnum id, class T_vevent> 00265 class SignalWrapperStage2<id,T_vevent,2> 00266 : public SignalWrapperStage2Base<id,T_vevent,2, SignalWrapperStage2<id,T_vevent,2> > 00267 { 00268 typedef W2_Trait<id> myTrait; 00269 typedef myTrait::T_vcmp T_vcmp; 00270 typedef myTrait::T_gcmp T_gcmp; 00271 friend class SignalWrapperStage2Base<id,T_vevent,2,SignalWrapperStage2<id,T_vevent,2> >; 00272 static int vdk2vec(T_vcmp); 00273 static int eve2vec(GdkEvent* eve); 00274 public: /* ??? */ 00275 SignalWrapperStage2(VDKObject* obj) 00276 : SignalWrapperStage2Base<id,T_vevent,2, SignalWrapperStage2<id,T_vevent,2> >(obj) 00277 {} 00278 }; 00279 00280 template<W2_TraitEnum id, class T_vevent> 00281 class SignalWrapperStage2<id,T_vevent,3> 00282 : public SignalWrapperStage2Base<id,T_vevent,3, SignalWrapperStage2<id,T_vevent,3> > 00283 { 00284 typedef W2_Trait<id> myTrait; 00285 typedef myTrait::T_vcmp T_vcmp; 00286 typedef myTrait::T_gcmp T_gcmp; 00287 friend class SignalWrapperStage2Base<id,T_vevent, 3, SignalWrapperStage2<id,T_vevent,3> >; 00288 static int vdk2vec(T_vcmp); 00289 static int eve2vec(GdkEvent* eve); 00290 public: /* ??? */ 00291 SignalWrapperStage2(VDKObject* obj) 00292 : SignalWrapperStage2Base<id,T_vevent,3, SignalWrapperStage2<id,T_vevent,3> >(obj) 00293 {} 00294 }; 00295 00296 /* ************************************************************************** 00297 * *** SignalWrapperStage1M2 *** 00298 * *************************************************************************/ 00299 template<W2_TraitEnum id1, int s_count1, W2_TraitEnum id2, int s_count2, class T_vevent> 00300 class SignalWrapperStage1M2 00301 { 00302 private: 00303 typedef W2_Trait<id1> Trait1; 00304 typedef W2_Trait<id2> Trait2; 00305 typedef Trait1::T_vcmp T_vcmp; 00306 SignalWrapperStage2<id1, T_vevent, s_count1> swrap1; 00307 SignalWrapperStage2<id2, T_vevent, s_count2> swrap2; 00308 public: 00309 SignalWrapperStage1M2(VDKObject* obj) 00310 : swrap1(obj), swrap2(obj){} 00311 bool empty() const; 00312 Connection connect(const Slot2<void, VDKObject*, const T_vevent&>& sl, 00313 T_vcmp spec); 00314 Connection connect(const Slot1<void, const T_vevent&>& sl, T_vcmp spec); 00315 void disconnect(Connection& con); 00316 }; 00317 00318 /* ************************************************************************ 00319 * *** Definition of different signals *** 00320 * ***********************************************************************/ 00321 typedef SignalWrapperStage1M2<BUTTON_PRESS,3, BUTTON_RELEASE, 1, VDKMouseEvent> 00322 VDKButtonSignal; 00323 typedef SignalWrapperStage1M2<FOCUS_KEY_IN,1, FOCUS_KEY_OUT,1, VDKKeyFocusEvent> 00324 VDKKeyFocusSignal; 00325 typedef SignalWrapperStage1M2<FOCUS_POINTER_IN,1, FOCUS_POINTER_OUT,1, VDKMouseFocusEvent> 00326 VDKPointerFocusSignal; 00327 typedef SignalWrapperStage1M2<KEY_PRESS,1, KEY_RELEASE,1, VDKKeyEvent> 00328 VDKKeySignal; 00329 typedef SignalWrapperStage1M2<POINTER_PRESSED,1, POINTER_MOVE,1, VDKMouseEvent> 00330 VDKPointerSignal; 00331 typedef SignalWrapperStage2<MAPEVENT, VDKMapEvent, 3> 00332 VDKMapSignal; 00333 typedef DirectEventSignal<GEOMETRY,VDKGeometryEvent> 00334 VDKGeometrySignal; 00335 typedef DirectEventSignal<PAINT,VDKPaintEvent> 00336 VDKPaintSignal; 00337 00338 #endif /* USE_SIGCPLUSPLUS */ 00339 #endif /* !_sigc_eventsignals_h_ */

Generated on Wed Jul 28 17:23:53 2004 for vdk 2.0.3 by doxygen 1.3.7