-
Notifications
You must be signed in to change notification settings - Fork 1
/
EVENT.H
285 lines (231 loc) · 5.9 KB
/
EVENT.H
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
/******************************************************************************
* Events
*
* A class that wishes to listen for specific events inherits from the
* listener classes it's interrested of. Note that inheritance should be
* done with virtual listeners. Any number of listeners can be attached
* to a specific window or controls.
*/
/* AEvent: Event base class */
class AEvent
{
protected:
AObject *source;
public:
AObject *getSource() { return source; }
};
/* AMouseEvent: Mouse event class */
class AMouseEvent : public AEvent
{
Point *pos;
int button, event;
public:
static int LEFT, MIDDLE, RIGHT, NONE;
static int DOWN, RELEASE, CLICK, MOVE, DOUBLECLICK, TRIPLECLICK, WHEEL;
AMouseEvent( AObject *source, Point *pos, int button, int event )
{
this->source = source;
this->pos = pos;
this->button = button;
this->event = event;
}
int getEvent() { return event; }
Point *getPos() { return pos; }
int getButton() { return button; }
};
/* Listener base class. */
class AListener
{
public:
virtual int equals( AObject *) { return FALSE; }
};
/* AMouseListener: Mouse listener template */
class AMouseListener : public AListener
{
public:
// Return TRUE if the window should get focus
virtual BOOL actionPerformed( AMouseEvent *mouseEvent ) { return TRUE; };
};
/* ASelectionEvent: A selection event */
class ASelectionEvent : public AEvent
{
int selectedItem;
public:
ASelectionEvent( AObject *source, int selectedItem )
{
this->source = source;
this->selectedItem = selectedItem;
}
/* getSelected:
returns: Returns the position in the list.*/
int getSelected() { return selectedItem; }
};
/* ASelectionListener: Listens to ListBoxes, ComboBoxes */
class ASelectionListener : public AListener
{
public:
virtual void actionPerformed( ASelectionEvent *selectionEvent ) {};
};
/* AFocusEvent: Reacts to focus changes in a control, f.e. a listbox */
class AFocusEvent : public AEvent
{
int focusItem;
public:
AFocusEvent( AObject *source, int focusItem )
{
this->source = source;
this->focusItem = focusItem;
}
/* getSelected:
returns: Returns the position in the list.*/
int getFocused() { return focusItem; }
};
/* AFocusListener: Listens to focus changes in ListBoxes, ComboBoxes */
class AFocusListener : public AListener
{
public:
virtual void actionPerformed( AFocusEvent *focusEvent ) {};
};
/* AIdEvent: An event that returns an lexId */
class AIdEvent : public AEvent
{
int id;
public:
AIdEvent( AObject *source, int id )
{
this->source = source;
this->id = id;
}
/* getSelected:
returns: Returns the ID */
int getId() { return id; }
};
/* AIdListener: Listens to controls which returns an lexId */
class AIdListener : public AListener
{
public:
void actionPerformed( AIdEvent *idEvent ) {};
};
/* AMenuEvent: A Menu event */
class AMenuEvent : public AIdEvent
{
public:
AMenuEvent( AObject *source, int id ) : AIdEvent( source, id ) {};
};
/* AMenuListener: Listens to Menues */
class AMenuListener : public AIdListener
{
public:
virtual void actionPerformed( AMenuEvent *menuEvent )
{
AIdListener::actionPerformed( (AIdEvent *)menuEvent );
}
};
/* AButtonEvent: A button event */
class AButtonEvent : public AIdEvent
{
public:
AButtonEvent( AObject *source, int id ) : AIdEvent( source, id ) {};
};
/* AButtonListener: Listens to buttons */
class AButtonListener : public AIdListener
{
public:
virtual void actionPerformed( AButtonEvent *buttonEvent ) {}
};
/* AScrollbarEvent: A scrollbar event
* Note that pos is relative the range!
*/
class AScrollbarEvent : public AIdEvent
{
int pos, action;
public:
AScrollbarEvent( AObject *source, int id, int action, int pos ) :
AIdEvent( source, id ) { this->pos = pos; this->action = action; }
int getPos() { return pos; }
int getAction() { return action; }
};
/* AButtonListener: Listens to buttons */
class AScrollbarListener : public AIdListener
{
public:
virtual void actionPerformed( AScrollbarEvent *scrollbarEvent ) {}
};
/* AToolbarEvent: A toolbar event */
class AToolbarEvent : public AEvent
{
char *command;
public:
AToolbarEvent( AObject *source, char *command )
{
this->source = source;
this->command = command;
}
char *getCommand() { return command; }
};
class Toolbutton;
/* AToolbarlistener :Listens to toolbars */
class AToolbarListener : public AListener
{
public:
virtual void actionPerformed( AToolbarEvent *toolbarEvent ) {}
};
/* AKeyEvent: A key event */
class AKeyEvent : public AEvent
{
public:
int modifiers, key;
AKeyEvent( AObject *source, int modifiers, int key )
{
this->modifiers = modifiers;
this->key = key;
};
};
/* AKeyListener: Listens to buttons */
class AKeyListener : public AIdListener
{
public:
// Return true if the key is processed
virtual BOOL actionPerformed( AKeyEvent *keyEvent ) { return FALSE; }
};
/* AWinMoveEvent: Activates when a window is moved */
class AWinMoveEvent : public AEvent
{
int oldX, oldY, newX, newY;
public:
AWinMoveEvent( AObject *source, int oldX, int oldY, int newX, int newY )
{
this->source = source;
this->oldX = oldX;
this->oldY = oldY;
this->newX = newX;
this->newY = newY;
}
int getOldX() { return oldX; }
int getOldY() { return oldY; }
int getNewX() { return newX; }
int getNewY() { return newY; }
};
/* AWinMoveListener: Listens to window moves */
class AWinMoveListener : public AListener
{
public:
virtual void actionPerformed( AWinMoveEvent *moveEvent ) {};
};
/* APositionEvent: Activates when the cursor position is changed */
class APositionEvent : public AEvent
{
long position;
public:
APositionEvent( AObject *source, long position )
{
this->position = position;
}
int getPosition() { return position; }
};
/* APositionListener: Listens to cursor moves */
class APositionListener : public AListener
{
public:
virtual void actionPerformed( APositionEvent *positionEvent ) {};
};