Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_EVENT_HXX
30 : : #define _SV_EVENT_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <tools/gen.hxx>
35 : : #include <vcl/keycod.hxx>
36 : : #include <vcl/cmdevt.hxx>
37 : :
38 : : class AllSettings;
39 : : class OutputDevice;
40 : : class Window;
41 : : struct IDataObject;
42 : :
43 : : namespace com { namespace sun { namespace star { namespace awt {
44 : : struct KeyEvent;
45 : : struct MouseEvent;
46 : : } } } }
47 : :
48 : : enum TextDirectionality {
49 : : TextDirectionality_LeftToRight_TopToBottom,
50 : : TextDirectionality_RightToLeft_TopToBottom,
51 : : TextDirectionality_TopToBottom_RightToLeft
52 : : };
53 : :
54 : : // ------------
55 : : // - KeyEvent -
56 : : // ------------
57 : 2 : class VCL_DLLPUBLIC KeyEvent
58 : : {
59 : : private:
60 : : KeyCode maKeyCode;
61 : : sal_uInt16 mnRepeat;
62 : : xub_Unicode mnCharCode;
63 : :
64 : : public:
65 : : KeyEvent();
66 : : KeyEvent( xub_Unicode nChar, const KeyCode& rKeyCode,
67 : : sal_uInt16 nRepeat = 0 );
68 : :
69 : 2 : xub_Unicode GetCharCode() const { return mnCharCode; }
70 : 2 : const KeyCode& GetKeyCode() const { return maKeyCode; }
71 : 0 : sal_uInt16 GetRepeat() const { return mnRepeat; }
72 : :
73 : : KeyEvent LogicalTextDirectionality (TextDirectionality eMode) const;
74 : : KeyEvent (const KeyEvent& rKeyEvent);
75 : :
76 : : };
77 : :
78 : 2 : inline KeyEvent::KeyEvent()
79 : : {
80 : 2 : mnCharCode = 0;
81 : 2 : mnRepeat = 0;
82 : 2 : }
83 : :
84 : 2 : inline KeyEvent::KeyEvent( xub_Unicode nChar, const KeyCode& rKeyCode,
85 : : sal_uInt16 nRepeat ) :
86 : 2 : maKeyCode( rKeyCode )
87 : :
88 : : {
89 : 2 : mnCharCode = nChar;
90 : 2 : mnRepeat = nRepeat;
91 : 2 : }
92 : :
93 : : // --------------------
94 : : // - MouseEvent-Types -
95 : : // --------------------
96 : :
97 : : // Maus-Move-Modi
98 : : #define MOUSE_SIMPLEMOVE ((sal_uInt16)0x0001)
99 : : #define MOUSE_DRAGMOVE ((sal_uInt16)0x0002)
100 : : #define MOUSE_DRAGCOPY ((sal_uInt16)0x0004)
101 : : #define MOUSE_ENTERWINDOW ((sal_uInt16)0x0010)
102 : : #define MOUSE_LEAVEWINDOW ((sal_uInt16)0x0020)
103 : : #define MOUSE_SYNTHETIC ((sal_uInt16)0x0040)
104 : : #define MOUSE_MODIFIERCHANGED ((sal_uInt16)0x0080)
105 : :
106 : : // Maus-Button-Down/Up-Modi
107 : : #define MOUSE_SIMPLECLICK ((sal_uInt16)0x0001)
108 : : #define MOUSE_SELECT ((sal_uInt16)0x0002)
109 : : #define MOUSE_MULTISELECT ((sal_uInt16)0x0004)
110 : : #define MOUSE_RANGESELECT ((sal_uInt16)0x0008)
111 : :
112 : : // Maus-Buttons
113 : : #define MOUSE_LEFT ((sal_uInt16)0x0001)
114 : : #define MOUSE_MIDDLE ((sal_uInt16)0x0002)
115 : : #define MOUSE_RIGHT ((sal_uInt16)0x0004)
116 : :
117 : : // --------------
118 : : // - MouseEvent -
119 : : // --------------
120 : :
121 : : class VCL_DLLPUBLIC MouseEvent
122 : : {
123 : : private:
124 : : Point maPos;
125 : : sal_uInt16 mnMode;
126 : : sal_uInt16 mnClicks;
127 : : sal_uInt16 mnCode;
128 : :
129 : : public:
130 : : MouseEvent();
131 : : MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1,
132 : : sal_uInt16 nMode = 0, sal_uInt16 nButtons = 0,
133 : : sal_uInt16 nModifier = 0 );
134 : :
135 : 0 : const Point& GetPosPixel() const { return maPos; }
136 : 0 : sal_uInt16 GetMode() const { return mnMode; }
137 : : /** inits this vcl KeyEvent with all settings from the given awt event **/
138 : : MouseEvent( const ::com::sun::star::awt::MouseEvent& rEvent );
139 : :
140 : 0 : sal_uInt16 GetClicks() const { return mnClicks; }
141 : :
142 : 0 : sal_Bool IsEnterWindow() const
143 : 0 : { return ((mnMode & MOUSE_ENTERWINDOW) != 0); }
144 : 0 : sal_Bool IsLeaveWindow() const
145 : 0 : { return ((mnMode & MOUSE_LEAVEWINDOW) != 0); }
146 : 0 : sal_Bool IsSynthetic() const
147 : 0 : { return ((mnMode & MOUSE_SYNTHETIC) != 0); }
148 : 0 : sal_Bool IsModifierChanged() const
149 : 0 : { return ((mnMode & MOUSE_MODIFIERCHANGED) != 0); }
150 : :
151 : 0 : sal_uInt16 GetButtons() const
152 : 0 : { return (mnCode & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)); }
153 : 0 : sal_Bool IsLeft() const
154 : 0 : { return ((mnCode & MOUSE_LEFT) != 0); }
155 : 0 : sal_Bool IsMiddle() const
156 : 0 : { return ((mnCode & MOUSE_MIDDLE) != 0); }
157 : 0 : sal_Bool IsRight() const
158 : 0 : { return ((mnCode & MOUSE_RIGHT) != 0); }
159 : :
160 : 0 : sal_uInt16 GetModifier() const
161 : 0 : { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
162 : 0 : bool IsShift() const
163 : 0 : { return ((mnCode & KEY_SHIFT) != 0); }
164 : 0 : sal_Bool IsMod1() const
165 : 0 : { return ((mnCode & KEY_MOD1) != 0); }
166 : 0 : sal_Bool IsMod2() const
167 : 0 : { return ((mnCode & KEY_MOD2) != 0); }
168 : 0 : sal_Bool IsMod3() const
169 : 0 : { return ((mnCode & KEY_MOD3) != 0); }
170 : : };
171 : :
172 : 33606 : inline MouseEvent::MouseEvent()
173 : : {
174 : 33606 : mnMode = 0;
175 : 33606 : mnClicks = 0;
176 : 33606 : mnCode = 0;
177 : 33606 : }
178 : :
179 : 0 : inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks,
180 : : sal_uInt16 nMode,
181 : : sal_uInt16 nButtons, sal_uInt16 nModifier ) :
182 : 0 : maPos( rPos )
183 : : {
184 : 0 : mnClicks = nClicks;
185 : 0 : mnMode = nMode;
186 : 0 : mnCode = nButtons | nModifier;
187 : 0 : }
188 : :
189 : : // -------------
190 : : // - HelpEvent -
191 : : // -------------
192 : :
193 : : #define HELPMODE_CONTEXT ((sal_uInt16)0x0001)
194 : : #define HELPMODE_EXTENDED ((sal_uInt16)0x0002)
195 : : #define HELPMODE_BALLOON ((sal_uInt16)0x0004)
196 : : #define HELPMODE_QUICK ((sal_uInt16)0x0008)
197 : :
198 : : class VCL_DLLPUBLIC HelpEvent
199 : : {
200 : : private:
201 : : Point maPos;
202 : : sal_uInt16 mnMode;
203 : : sal_Bool mbKeyboardActivated;
204 : :
205 : : public:
206 : : HelpEvent();
207 : : HelpEvent( sal_uInt16 nHelpMode );
208 : : HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode );
209 : :
210 : : const Point& GetMousePosPixel() const;
211 : 0 : sal_uInt16 GetMode() const { return mnMode; }
212 : 0 : sal_Bool KeyboardActivated() const { return mbKeyboardActivated; }
213 : 0 : void SetKeyboardActivated( sal_Bool bKeyboard ) { mbKeyboardActivated = bKeyboard; }
214 : : };
215 : :
216 : : inline HelpEvent::HelpEvent()
217 : : {
218 : : mnMode = HELPMODE_CONTEXT;
219 : : mbKeyboardActivated = sal_True;
220 : : }
221 : :
222 : 0 : inline HelpEvent::HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode ) :
223 : 0 : maPos( rMousePos )
224 : : {
225 : 0 : mnMode = nHelpMode;
226 : 0 : mbKeyboardActivated = sal_False;
227 : 0 : }
228 : :
229 : : inline HelpEvent::HelpEvent( sal_uInt16 nHelpMode )
230 : : {
231 : : mnMode = nHelpMode;
232 : : mbKeyboardActivated = sal_True;
233 : : }
234 : :
235 : : // -----------------
236 : : // - UserDrawEvent -
237 : : // -----------------
238 : :
239 : : class VCL_DLLPUBLIC UserDrawEvent
240 : : {
241 : : private:
242 : : OutputDevice* mpOutDev;
243 : : Rectangle maOutRect;
244 : : sal_uInt16 mnItemId;
245 : : sal_uInt16 mnStyle;
246 : :
247 : : public:
248 : : UserDrawEvent();
249 : : UserDrawEvent( OutputDevice* pOut,
250 : : const Rectangle& rOutRect,
251 : : sal_uInt16 nId, sal_uInt16 nStyle = 0 );
252 : :
253 : 53158 : OutputDevice* GetDevice() const { return mpOutDev; }
254 : 81887 : const Rectangle& GetRect() const { return maOutRect; }
255 : 33340 : sal_uInt16 GetItemId() const { return mnItemId; }
256 : 16169 : sal_uInt16 GetStyle() const { return mnStyle; }
257 : : };
258 : :
259 : : inline UserDrawEvent::UserDrawEvent()
260 : : {
261 : : mpOutDev = NULL;
262 : : mnItemId = 0;
263 : : mnStyle = 0;
264 : : }
265 : :
266 : 45099 : inline UserDrawEvent::UserDrawEvent( OutputDevice* pOut,
267 : : const Rectangle& rOutRect,
268 : : sal_uInt16 nId, sal_uInt16 nStyle ) :
269 : 45099 : maOutRect( rOutRect )
270 : : {
271 : 45099 : mpOutDev = pOut;
272 : 45099 : mnItemId = nId;
273 : 45099 : mnStyle = nStyle;
274 : 45099 : }
275 : :
276 : : // ------------------
277 : : // - Tracking-Types -
278 : : // ------------------
279 : :
280 : : #define ENDTRACK_CANCEL ((sal_uInt16)0x0001)
281 : : #define ENDTRACK_KEY ((sal_uInt16)0x0002)
282 : : #define ENDTRACK_FOCUS ((sal_uInt16)0x0004)
283 : : #define ENDTRACK_END ((sal_uInt16)0x1000)
284 : : #define ENDTRACK_DONTCALLHDL ((sal_uInt16)0x8000)
285 : :
286 : : #define TRACKING_REPEAT ((sal_uInt16)0x0100)
287 : :
288 : : // -----------------
289 : : // - TrackingEvent -
290 : : // -----------------
291 : :
292 : : class VCL_DLLPUBLIC TrackingEvent
293 : : {
294 : : private:
295 : : MouseEvent maMEvt;
296 : : sal_uInt16 mnFlags;
297 : :
298 : : public:
299 : : TrackingEvent();
300 : : TrackingEvent( const MouseEvent& rMEvt,
301 : : sal_uInt16 nTrackFlags = 0 );
302 : :
303 : 0 : const MouseEvent& GetMouseEvent() const { return maMEvt; }
304 : :
305 : 0 : sal_Bool IsTrackingRepeat() const
306 : 0 : { return ((mnFlags & TRACKING_REPEAT) != 0); }
307 : :
308 : 0 : sal_Bool IsTrackingEnded() const
309 : 0 : { return ((mnFlags & ENDTRACK_END) != 0); }
310 : 0 : sal_Bool IsTrackingCanceled() const
311 : 0 : { return ((mnFlags & ENDTRACK_CANCEL) != 0); }
312 : : sal_uInt16 GetTrackingFlags() const { return mnFlags; }
313 : : };
314 : :
315 : : inline TrackingEvent::TrackingEvent()
316 : : {
317 : : mnFlags = 0;
318 : : }
319 : :
320 : 0 : inline TrackingEvent::TrackingEvent( const MouseEvent& rMEvt,
321 : : sal_uInt16 nTrackFlags ) :
322 : 0 : maMEvt( rMEvt )
323 : : {
324 : 0 : mnFlags = nTrackFlags;
325 : 0 : }
326 : :
327 : : // ---------------
328 : : // - NotifyEvent -
329 : : // ---------------
330 : :
331 : : #define EVENT_MOUSEBUTTONDOWN 1
332 : : #define EVENT_MOUSEBUTTONUP 2
333 : : #define EVENT_MOUSEMOVE 3
334 : : #define EVENT_KEYINPUT 4
335 : : #define EVENT_KEYUP 5
336 : : #define EVENT_GETFOCUS 6
337 : : #define EVENT_LOSEFOCUS 7
338 : : #define EVENT_COMMAND 8
339 : : #define EVENT_DESTROY 9
340 : : #define EVENT_INPUTENABLE 10
341 : : #define EVENT_INPUTDISABLE 11
342 : : #define EVENT_EXECUTEDIALOG 100
343 : : #define EVENT_ENDEXECUTEDIALOG 101
344 : :
345 : : class VCL_DLLPUBLIC NotifyEvent
346 : : {
347 : : private:
348 : : Window* mpWindow;
349 : : void* mpData;
350 : : sal_uInt16 mnType;
351 : : long mnRetValue;
352 : :
353 : : public:
354 : : NotifyEvent();
355 : : NotifyEvent( sal_uInt16 nType,
356 : : Window* pWindow,
357 : : const void* pEvent = NULL,
358 : : long nRet = 0 );
359 : :
360 : 745696 : sal_uInt16 GetType() const { return mnType; }
361 : 90586 : Window* GetWindow() const { return mpWindow; }
362 : 0 : void* GetData() const { return mpData; }
363 : :
364 : : void SetReturnValue( long nRet ) { mnRetValue = nRet; }
365 : : long GetReturnValue() const { return mnRetValue; }
366 : :
367 : : const KeyEvent* GetKeyEvent() const;
368 : : const MouseEvent* GetMouseEvent() const;
369 : : const CommandEvent* GetCommandEvent() const;
370 : : };
371 : :
372 : : inline NotifyEvent::NotifyEvent()
373 : : {
374 : : mpWindow = NULL;
375 : : mpData = NULL;
376 : : mnType = 0;
377 : : mnRetValue = 0;
378 : : }
379 : :
380 : 151641 : inline NotifyEvent::NotifyEvent( sal_uInt16 nType, Window* pWindow,
381 : : const void* pEvent, long nRet )
382 : : {
383 : 151641 : mpWindow = pWindow;
384 : 151641 : mpData = (void*)pEvent;
385 : 151641 : mnType = nType;
386 : 151641 : mnRetValue = nRet;
387 : 151641 : }
388 : :
389 : 0 : inline const KeyEvent* NotifyEvent::GetKeyEvent() const
390 : : {
391 [ # # ][ # # ]: 0 : if ( (mnType == EVENT_KEYINPUT) || (mnType == EVENT_KEYUP) )
392 : 0 : return (const KeyEvent*)mpData;
393 : : else
394 : 0 : return NULL;
395 : : }
396 : :
397 : 0 : inline const MouseEvent* NotifyEvent::GetMouseEvent() const
398 : : {
399 [ # # ][ # # ]: 0 : if ( (mnType >= EVENT_MOUSEBUTTONDOWN) && (mnType <= EVENT_MOUSEMOVE) )
400 : 0 : return (const MouseEvent*)mpData;
401 : : else
402 : 0 : return NULL;
403 : : }
404 : :
405 : 0 : inline const CommandEvent* NotifyEvent::GetCommandEvent() const
406 : : {
407 [ # # ]: 0 : if ( mnType == EVENT_COMMAND )
408 : 0 : return (const CommandEvent*)mpData;
409 : : else
410 : 0 : return NULL;
411 : : }
412 : :
413 : : // --------------------
414 : : // - DataChangedEvent -
415 : : // --------------------
416 : :
417 : : #define DATACHANGED_SETTINGS ((sal_uInt16)1)
418 : : #define DATACHANGED_DISPLAY ((sal_uInt16)2)
419 : : #define DATACHANGED_DATETIME ((sal_uInt16)3)
420 : : #define DATACHANGED_FONTS ((sal_uInt16)4)
421 : : #define DATACHANGED_PRINTER ((sal_uInt16)5)
422 : : #define DATACHANGED_FONTSUBSTITUTION ((sal_uInt16)6)
423 : : #define DATACHANGED_USER ((sal_uInt16)10000)
424 : :
425 : : class VCL_DLLPUBLIC DataChangedEvent
426 : : {
427 : : private:
428 : : void* mpData;
429 : : sal_uLong mnFlags;
430 : : sal_uInt16 mnType;
431 : :
432 : : public:
433 : : DataChangedEvent();
434 : : DataChangedEvent( sal_uInt16 nType,
435 : : const void* pData = NULL,
436 : : sal_uLong nFlags = 0 );
437 : :
438 : 38191 : sal_uInt16 GetType() const { return mnType; }
439 : 0 : void* GetData() const { return mpData; }
440 : 18807 : sal_uLong GetFlags() const { return mnFlags; }
441 : :
442 : : const AllSettings* GetOldSettings() const;
443 : : };
444 : :
445 : : inline DataChangedEvent::DataChangedEvent()
446 : : {
447 : : mpData = NULL;
448 : : mnFlags = 0;
449 : : mnType = 0;
450 : : }
451 : :
452 : 12809 : inline DataChangedEvent::DataChangedEvent( sal_uInt16 nType,
453 : : const void* pData,
454 : : sal_uLong nChangeFlags )
455 : : {
456 : 12809 : mpData = (void*)pData;
457 : 12809 : mnFlags = nChangeFlags;
458 : 12809 : mnType = nType;
459 : 12809 : }
460 : :
461 : 3291 : inline const AllSettings* DataChangedEvent::GetOldSettings() const
462 : : {
463 [ + - ]: 3291 : if ( mnType == DATACHANGED_SETTINGS )
464 : 3291 : return (const AllSettings*)mpData;
465 : : else
466 : 3291 : return NULL;
467 : : }
468 : :
469 : : #endif // _SV_EVENT_HXX
470 : :
471 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|