Laxkit
0.0.7.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
lax
events.h
1
//
2
//
3
// The Laxkit, a windowing toolkit
4
// Please consult http://laxkit.sourceforge.net about where to send any
5
// correspondence about this software.
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Library General Public
9
// License as published by the Free Software Foundation; either
10
// version 2 of the License, or (at your option) any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Library General Public License for more details.
16
//
17
// You should have received a copy of the GNU Library General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
//
21
// Copyright (C) 2010-2013 by Tom Lechner
22
//
23
#ifndef _LAX_EVENTS_H
24
#define _LAX_EVENTS_H
25
26
#include <lax/configured.h>
27
28
#ifdef _LAX_PLATFORM_XLIB
29
#include <X11/Xlib.h>
30
#include <X11/Xatom.h>
31
#include <X11/Xft/Xft.h>
32
#include <X11/Xutil.h>
33
#endif //_LAX_PLATFORM_XLIB
34
35
36
#include <sys/times.h>
37
38
#include <lax/anobject.h>
39
#include <lax/laxdevices.h>
40
41
42
namespace
Laxkit {
43
44
class
anXWindow;
45
class
anXApp;
46
class
LaxDevice;
47
class
LaxMouse;
48
class
LaxKeyboard;
49
50
51
//-------------------------- Event related classes ----------------------------------
52
53
//----- EventData mask types -------
54
//These are used in EventData::type.
55
//For LAX_RandomEvent, it is assumed that EventData::send_message is defined.
56
//*** best way to do this???
57
//Used by various control windows to determine when
58
//to send a message to its owner
59
#define LAX_RandomEvent 0
60
//input and device events
61
#define LAX_onFocusOn (1<<0)
62
#define LAX_onFocusOff (1<<1)
63
#define LAX_onMouseIn (1<<2)
64
#define LAX_onMouseOut (1<<3)
65
#define LAX_onMouseMove (1<<4)
66
#define LAX_onButtonDown (1<<5)
67
#define LAX_onButtonUp (1<<6)
68
#define LAX_onKeyDown (1<<7)
69
#define LAX_onKeyUp (1<<8)
70
#define LAX_onDeviceChange (1<<9)
71
//state events
72
#define LAX_onSubmit (1<<10)
73
#define LAX_onCancel (1<<11)
74
#define LAX_onContentChange (1<<12)
75
#define LAX_onSelectionChange (1<<13)
76
#define LAX_onUpdateByEvent (1<<14)
77
#define LAX_onUngrayed (1<<15)
78
#define LAX_onGrayed (1<<16)
79
#define LAX_onMapped (1<<17)
80
#define LAX_onUnmapped (1<<18)
81
//---other events
82
//sent by window controls for various purposes.
83
//event->subtype will some value that makes sense to the control
84
#define LAX_ControlEvent (1<<19)
85
#define LAX_ButtonEvent (1<<20)
86
#define LAX_ShortcutEvent (1<<21)
87
#define LAX_ColorEvent (1<<22)
88
#define LAX_UserEvent (1<<23)
89
90
const
char
*lax_event_name(
int
e);
91
92
93
94
//-------------------------- EventData
95
class
EventData
96
{
97
friend
class
anXApp
;
98
private
:
99
int
isuserevent;
100
public
:
101
unsigned
long
type;
102
unsigned
long
subtype;
103
char
*send_message;
104
105
unsigned
long
from;
//EventReceiver object_id
106
unsigned
long
to;
107
//long info[5];
108
int
propagate;
109
110
clock_t send_time;
//as returned by times()
111
unsigned
long
xlib_time;
//as sent in xlib messages
112
113
EventData
*next;
114
115
EventData
();
116
EventData
(
const
char
*message,
unsigned
long
fromwindow=0,
unsigned
long
towindow=0);
117
EventData
(
int
message,
unsigned
long
fromwindow=0,
unsigned
long
towindow=0);
118
virtual
~
EventData
();
119
};
120
121
#ifdef _LAX_PLATFORM_XLIB
122
//-------------------------- XEventData
123
class
XEventData :
public
EventData
124
{
125
public
:
126
XEvent *xevent;
127
};
128
#endif //_LAX_PLATFORM_XLIB
129
131
class
RefCountedEventData
:
public
EventData
132
{
133
public
:
134
anObject
*object;
135
int
info1,info2,info3,info4;
136
RefCountedEventData
(
anObject
*obj=NULL);
137
virtual
~RefCountedEventData
();
138
anObject
*
TheObject
();
139
};
140
141
//-------------------------- StrEventData
142
class
StrEventData
:
public
EventData
143
{
144
public
:
145
char
*str;
146
int
info1,info2,info3,info4;
147
StrEventData
() { str=NULL; info1=info2=info3=info4=0; }
148
StrEventData
(
unsigned
long
t,
unsigned
long
f,
unsigned
long
tp,
const
char
*newmes=NULL);
149
StrEventData
(
const
char
*nstr,
int
i1,
int
i2,
int
i3,
int
i4,
150
const
char
*message=NULL,
unsigned
long
fromwindow=0,
unsigned
long
towindow=0);
151
virtual
~
StrEventData
() {
if
(str)
delete
[] str; }
152
};
153
154
typedef
StrEventData
SimpleMessage
;
155
156
//-------------------------- StrsEventData
157
class
StrsEventData
:
public
EventData
158
{
159
public
:
160
char
**strs;
161
int
n,info,info2,info3;
162
StrsEventData
();
163
StrsEventData
(
const
char
*nstr,
const
char
*message,
unsigned
long
fromwindow,
unsigned
long
towindow);
164
virtual
~
StrsEventData
();
165
};
166
167
//-------------------------- InOutData/EnterExitData/FocusChangeData
168
class
InOutData
:
public
EventData
169
{
170
public
:
171
//****
172
LaxDevice
*device;
173
anXWindow
*target;
174
int
x,y;
175
unsigned
long
child;
176
InOutData
(
int
ntype);
177
};
178
179
typedef
InOutData
FocusChangeData
;
180
typedef
InOutData
EnterExitData
;
181
182
//-------------------------- ButtonEventData
183
class
MouseEventData
:
public
EventData
184
{
185
public
:
186
int
x,y;
187
int
button, count, size;
188
double
pressure, tilt, depth;
189
unsigned
int
modifiers;
//of paired keyboard, if any
190
191
anXWindow
*target;
192
LaxMouse
*device;
193
194
MouseEventData
(
int
ntype);
195
virtual
~
MouseEventData
();
196
};
197
198
//-------------------------- KeyEventData
199
class
KeyEventData
:
public
EventData
200
{
201
public
:
202
unsigned
int
key;
203
unsigned
int
modifiers;
204
char
*buffer;
205
int
len;
206
207
LaxKeyboard
*device;
208
anXWindow
*target;
209
210
KeyEventData
(
int
ntype);
211
virtual
~
KeyEventData
();
212
};
213
214
//-------------------------- ScreenEventData
215
class
ScreenEventData
:
public
EventData
216
{
217
public
:
218
int
x,y,width,height;
//rectangle that needs refreshing
219
ScreenEventData
(
int
xx,
int
yy,
int
ww,
int
hh);
220
};
221
222
//-------------------------- DeviceEventData
223
#define LAX_DeviceStateChange 1
224
#define LAX_DeviceChanged 2
225
#define LAX_DeviceSwitched 3
226
#define LAX_DeviceHierarchyChange 4
227
228
class
DeviceEventData
:
public
EventData
229
{
230
public
:
231
int
id,subid;
//device id and subid of relevant device
232
233
int
xflags, xdev, xattachment, xenabled;
234
Time xtime;
235
DeviceEventData
(
int
i=0,
int
si=0);
236
};
237
238
239
//-------------------------- EventReceiver ----------------------------------------
240
class
EventReceiver
:
virtual
public
anObject
241
{
242
public
:
243
EventReceiver
();
244
virtual
~
EventReceiver
();
245
virtual
int
Event
(
const
EventData
*data,
const
char
*mes);
246
};
247
248
249
}
//namespace Laxkit
250
251
#endif
252
Mon Feb 17 2014 11:52:56, Laxkit