/usr/include/vdk2/vdk/evhandle.h is in libvdk2-dev 2.4.0-5.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | /*
* ===========================
* VDK Visual Develeopment Kit
* Version 0.4
* October 1998
* ===========================
*
* Copyright (C) 1998, Mario Motta
* Developed by Mario Motta <mmotta@guest.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef EVHANDLE_H
#define EVHANDLE_H
#include <vdk/vdkobj.h>
#include <gdk/gdktypes.h>
#include <cstring>
/*
==============================================
SIGNAL DISPATCHER ROUTINES
==============================================
*/
/*
_VDKSignalTable_:
Obj/Signal/Response method Table
*/
template <class T>
class _VDKSignalTable_ {
public:
typedef bool (T::*PMF)(VDKObject* sender);
VDKObject* T::*Pm; /* <class T> member offset */
int signal; /* signal type (see enum VDKSignal in vdkobj.h) */
PMF Pmf; /* <class T> member function offset */
bool connected; /* connected flag, if false denies signal */
};
/*
Signal response function map declaration:
declare a static signal table for each form
*/
#define DECLARE_SIGNAL_MAP(_Parent_Class_) \
private:\
static _VDKSignalTable_< _Parent_Class_ > _STEntries_[];\
typedef _VDKSignalTable_< _Parent_Class_ >::PMF _Member_;\
typedef _Parent_Class_ _Parent_MyClass_;\
protected:\
virtual int VDKSignalResponseTableSize();\
public:\
virtual int VDKSignalResponse(GtkWidget* , int signal, void*, void*,bool);\
virtual int SignalDetach(VDKObject* Pm, int signal);\
virtual bool SignalAttach(int slot);
/*
define form signal response function that in turn call
object signal response function
algorithm:
1. scan table until find table end
2. if matches object and signal then slot is found
3. if slot is connected
4. bind object address with member function class offset
5. call callback
6. if callback return true consider signal "treated"
7. if signal is treated finish
otherwise recursively call himself to ancestor class
*/
#define DEFINE_SIGNAL_MAP(_Parent_Class_,base)\
\
int _Parent_Class_::VDKSignalResponse(GtkWidget* mobj, \
int signal, void* obj, void* real_sender, bool treated) \
{\
int t=0;\
/*bool treated = false;*/\
VDKObject* vdkobj = reinterpret_cast<VDKObject*>(obj);\
VDKObject* real = reinterpret_cast<VDKObject*>(real_sender);\
for(;_STEntries_[t].Pm != NULL ;t++)\
{\
VDKObject* _Parent_Class_::*memberOffset = _STEntries_[t].Pm;\
if ( ((*this).*memberOffset == vdkobj) &&\
(_STEntries_[t].signal == signal) )\
{\
if (_STEntries_[t].connected)\
{\
bool(_Parent_Class_::*response)(VDKObject* sender)= \
_STEntries_[t].Pmf;\
if(((*this).*response)(real) == true)\
treated = true;\
}\
/*break;*/\
}\
}\
if(treated) return 1;\
else return base::VDKSignalResponse(mobj,signal,obj,real_sender, treated);\
}\
\
\
int _Parent_Class_::VDKSignalResponseTableSize()\
{\
int t = 0;\
for(;_STEntries_[t].Pm != NULL;t++)\
;\
return t;\
}\
\
\
\
int _Parent_Class_::SignalDetach(VDKObject* Pm, int signal)\
{\
int t=0;\
for(;_STEntries_[t].Pm != NULL ;t++)\
{\
VDKObject* _Parent_Class_::*memberOffset = _STEntries_[t].Pm;\
if ( ((*this).*memberOffset == Pm) &&\
(_STEntries_[t].signal == signal) &&\
_STEntries_[t].connected != false)\
{\
_STEntries_[t].connected = false;\
return t;\
}\
}\
return -1;\
}\
\
\
\
bool _Parent_Class_::SignalAttach(int slot)\
{\
if( (slot >= 0) && (slot <= VDKSignalResponseTableSize()) )\
{\
_STEntries_[slot].connected = true;\
return true;\
}\
else\
return false;\
}\
\
\
_VDKSignalTable_< _Parent_Class_ > _Parent_Class_::_STEntries_[] = {
/*
fill static signal table
*/
#define ON_SIGNAL(_obj_,_SIGNAL_,_member_) \
{ reinterpret_cast<VDKObject* _Parent_MyClass_::*>(&_Parent_MyClass_::_obj_),\
_SIGNAL_,&_Parent_MyClass_::_member_,true}
/*
*/
#define END_SIGNAL_MAP ,{ NULL, 0, NULL, false} };
/*
*/
/*
==============================================
EVENT DISPATCHER ROUTINES
==============================================
*/
/*
EVENTTableEntry:
Event-ObjectCallback Table Entry
*/
template <class T>
class EVENTTableEntry {
public:
// typedef void (T::*PMF)(VDKObject* sender, GdkEvent* event);
typedef bool (T::*PMF)(VDKObject* sender, GdkEvent* event);
VDKObject* T::*Pm; /* pointer to <class T> member offset */
GdkEventType event; /* event type (see enum VDKevent in vdkobj.h) */
PMF Pmf; /* pointer to <class T> member function */
bool connected;
};
/*
Events response function map declaration:
declare a static events table for each form
*/
#define DECLARE_EVENT_MAP(_EVENTclass_) \
private:\
static EVENTTableEntry< _EVENTclass_ > __OCBEventEntries[];\
typedef EVENTTableEntry< _EVENTclass_ >::PMF _EvMember_;\
typedef _EVENTclass_ _EVENTmyclass_;\
protected:\
virtual int VDKEventResponseTableSize();\
public:\
virtual int VDKEventResponse(GtkWidget* , GdkEvent* , void*, void*,bool);\
virtual int EventDetach(VDKObject* , VDKEvent event);\
virtual bool EventAttach(int slot);
/*
define form EVENT response function that in turn call
object EVENT response function
*/
#define DEFINE_EVENT_MAP(_EVENTclass_,base) \
int _EVENTclass_::VDKEventResponse(GtkWidget* wid, GdkEvent* event, void* obj, void* real_sender, bool treated) \
\
{\
int t=0;\
/*bool treated = false;*/\
VDKObject* vdkobj = reinterpret_cast<VDKObject*>(obj);\
VDKObject* real = reinterpret_cast<VDKObject*>(real_sender);\
for(;__OCBEventEntries[t].Pm != NULL ;t++)\
{\
VDKObject* _EVENTclass_::*memberOffset = __OCBEventEntries[t].Pm;\
if( ((*this).*memberOffset == vdkobj) &&\
(__OCBEventEntries[t].event == ((GdkEventAny*)event)->type) )\
{\
if (__OCBEventEntries[t].connected)\
{\
bool (_EVENTclass_::*response)\
(VDKObject* , GdkEvent* ) = \
__OCBEventEntries[t].Pmf;\
if(((*this).*response)(real,event))\
treated = true;\
}\
/*break;*/\
}\
}\
if(treated) return 1;\
else return base::VDKEventResponse(wid,event,obj,real_sender, treated); \
}\
\
\
\
int _EVENTclass_::VDKEventResponseTableSize()\
{\
int t = 0;\
for(;__OCBEventEntries[t].Pm != NULL;t++)\
;\
return t;\
}\
\
\
\
int _EVENTclass_::EventDetach(VDKObject* Pm, VDKEvent event)\
{\
int t=0;\
for(;__OCBEventEntries[t].Pm != NULL ;t++)\
{\
VDKObject* _EVENTclass_::*memberOffset = __OCBEventEntries[t].Pm;\
if ( ((*this).*memberOffset == Pm) &&\
(__OCBEventEntries[t].event == (GdkEventType) event)&&\
__OCBEventEntries[t].connected != false)\
{\
__OCBEventEntries[t].connected = false;\
return t;\
}\
}\
return -1;\
}\
\
\
\
bool _EVENTclass_::EventAttach(int slot)\
{\
if( (slot >= 0) && (slot <= VDKEventResponseTableSize()) )\
{\
__OCBEventEntries[slot].connected = true;\
return true;\
}\
else\
return false;\
}\
\
\
EVENTTableEntry< _EVENTclass_ > _EVENTclass_::__OCBEventEntries[] = {
/*
fill static EVENT table
*/
#define ON_EVENT(_obj_,_EVENT_,_member_) \
/* {reinterpret_cast<VDKObject* _EVENTmyclass_::*>(&_EVENTmyclass_::_obj_), (GdkEventType) _EVENT_,&(_EVENTmyclass_::_member_),true} */ \
{reinterpret_cast<VDKObject* _EVENTmyclass_::*>(&_EVENTmyclass_::_obj_), (GdkEventType) _EVENT_,&_EVENTmyclass_::_member_,true}
/*
*/
#define END_EVENT_MAP ,{ NULL , (GdkEventType) 0, NULL,false} };
#endif
|