fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / vcl / event.hxx
blob1d3c76e0ba7b9b019f0eeba59fc6b351f351fa91
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SV_EVENT_HXX
21 #define _SV_EVENT_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <tools/gen.hxx>
26 #include <vcl/keycod.hxx>
27 #include <vcl/cmdevt.hxx>
29 class AllSettings;
30 class OutputDevice;
31 class Window;
32 struct IDataObject;
34 namespace com { namespace sun { namespace star { namespace awt {
35 struct KeyEvent;
36 struct MouseEvent;
37 } } } }
39 enum TextDirectionality {
40 TextDirectionality_LeftToRight_TopToBottom,
41 TextDirectionality_RightToLeft_TopToBottom,
42 TextDirectionality_TopToBottom_RightToLeft
45 // ------------
46 // - KeyEvent -
47 // ------------
48 class VCL_DLLPUBLIC KeyEvent
50 private:
51 KeyCode maKeyCode;
52 sal_uInt16 mnRepeat;
53 sal_Unicode mnCharCode;
55 public:
56 KeyEvent();
57 KeyEvent( sal_Unicode nChar, const KeyCode& rKeyCode,
58 sal_uInt16 nRepeat = 0 );
60 sal_Unicode GetCharCode() const { return mnCharCode; }
61 const KeyCode& GetKeyCode() const { return maKeyCode; }
62 sal_uInt16 GetRepeat() const { return mnRepeat; }
64 KeyEvent LogicalTextDirectionality (TextDirectionality eMode) const;
65 KeyEvent (const KeyEvent& rKeyEvent);
69 inline KeyEvent::KeyEvent()
71 mnCharCode = 0;
72 mnRepeat = 0;
75 inline KeyEvent::KeyEvent( sal_Unicode nChar, const KeyCode& rKeyCode,
76 sal_uInt16 nRepeat ) :
77 maKeyCode( rKeyCode )
80 mnCharCode = nChar;
81 mnRepeat = nRepeat;
84 // --------------------
85 // - MouseEvent-Types -
86 // --------------------
88 // Maus-Move-Modi
89 #define MOUSE_SIMPLEMOVE ((sal_uInt16)0x0001)
90 #define MOUSE_DRAGMOVE ((sal_uInt16)0x0002)
91 #define MOUSE_DRAGCOPY ((sal_uInt16)0x0004)
92 #define MOUSE_ENTERWINDOW ((sal_uInt16)0x0010)
93 #define MOUSE_LEAVEWINDOW ((sal_uInt16)0x0020)
94 #define MOUSE_SYNTHETIC ((sal_uInt16)0x0040)
95 #define MOUSE_MODIFIERCHANGED ((sal_uInt16)0x0080)
97 // Maus-Button-Down/Up-Modi
98 #define MOUSE_SIMPLECLICK ((sal_uInt16)0x0001)
99 #define MOUSE_SELECT ((sal_uInt16)0x0002)
100 #define MOUSE_MULTISELECT ((sal_uInt16)0x0004)
101 #define MOUSE_RANGESELECT ((sal_uInt16)0x0008)
103 // Maus-Buttons
104 #define MOUSE_LEFT ((sal_uInt16)0x0001)
105 #define MOUSE_MIDDLE ((sal_uInt16)0x0002)
106 #define MOUSE_RIGHT ((sal_uInt16)0x0004)
108 // --------------
109 // - MouseEvent -
110 // --------------
112 class VCL_DLLPUBLIC MouseEvent
114 private:
115 Point maPos;
116 sal_uInt16 mnMode;
117 sal_uInt16 mnClicks;
118 sal_uInt16 mnCode;
120 public:
121 explicit MouseEvent();
122 explicit MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1,
123 sal_uInt16 nMode = 0, sal_uInt16 nButtons = 0,
124 sal_uInt16 nModifier = 0 );
126 const Point& GetPosPixel() const { return maPos; }
127 sal_uInt16 GetMode() const { return mnMode; }
128 /** inits this vcl KeyEvent with all settings from the given awt event **/
129 MouseEvent( const ::com::sun::star::awt::MouseEvent& rEvent );
131 sal_uInt16 GetClicks() const { return mnClicks; }
133 sal_Bool IsEnterWindow() const
134 { return ((mnMode & MOUSE_ENTERWINDOW) != 0); }
135 sal_Bool IsLeaveWindow() const
136 { return ((mnMode & MOUSE_LEAVEWINDOW) != 0); }
137 sal_Bool IsSynthetic() const
138 { return ((mnMode & MOUSE_SYNTHETIC) != 0); }
139 sal_Bool IsModifierChanged() const
140 { return ((mnMode & MOUSE_MODIFIERCHANGED) != 0); }
142 sal_uInt16 GetButtons() const
143 { return (mnCode & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)); }
144 sal_Bool IsLeft() const
145 { return ((mnCode & MOUSE_LEFT) != 0); }
146 sal_Bool IsMiddle() const
147 { return ((mnCode & MOUSE_MIDDLE) != 0); }
148 sal_Bool IsRight() const
149 { return ((mnCode & MOUSE_RIGHT) != 0); }
151 sal_uInt16 GetModifier() const
152 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
153 bool IsShift() const
154 { return ((mnCode & KEY_SHIFT) != 0); }
155 sal_Bool IsMod1() const
156 { return ((mnCode & KEY_MOD1) != 0); }
157 sal_Bool IsMod2() const
158 { return ((mnCode & KEY_MOD2) != 0); }
159 sal_Bool IsMod3() const
160 { return ((mnCode & KEY_MOD3) != 0); }
163 inline MouseEvent::MouseEvent()
165 mnMode = 0;
166 mnClicks = 0;
167 mnCode = 0;
170 inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks,
171 sal_uInt16 nMode,
172 sal_uInt16 nButtons, sal_uInt16 nModifier ) :
173 maPos( rPos )
175 mnClicks = nClicks;
176 mnMode = nMode;
177 mnCode = nButtons | nModifier;
180 class VCL_DLLPUBLIC ZoomEvent
182 private:
183 Point maCenter;
184 float mfScale;
186 public:
187 ZoomEvent() :
188 mfScale( 1 )
192 ZoomEvent( const Point& rCenter,
193 float fScale ) :
194 maCenter( rCenter ),
195 mfScale( fScale )
199 const Point& GetCenter() const
201 return maCenter;
204 float GetScale() const
206 return mfScale;
210 class VCL_DLLPUBLIC ScrollEvent
212 private:
213 int mnXOffset;
214 int mnYOffset;
216 public:
217 ScrollEvent() :
218 mnXOffset( 0 ),
219 mnYOffset( 0 )
223 ScrollEvent( int xOffset, int yOffset ) :
224 mnXOffset( xOffset ),
225 mnYOffset( yOffset )
229 int GetXOffset() const
231 return mnXOffset;
234 int GetYOffset() const
236 return mnYOffset;
240 // -------------
241 // - HelpEvent -
242 // -------------
244 #define HELPMODE_CONTEXT ((sal_uInt16)0x0001)
245 #define HELPMODE_EXTENDED ((sal_uInt16)0x0002)
246 #define HELPMODE_BALLOON ((sal_uInt16)0x0004)
247 #define HELPMODE_QUICK ((sal_uInt16)0x0008)
249 class VCL_DLLPUBLIC HelpEvent
251 private:
252 Point maPos;
253 sal_uInt16 mnMode;
254 sal_Bool mbKeyboardActivated;
256 public:
257 explicit HelpEvent();
258 explicit HelpEvent( sal_uInt16 nHelpMode );
259 explicit HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode );
261 const Point& GetMousePosPixel() const;
262 sal_uInt16 GetMode() const { return mnMode; }
263 sal_Bool KeyboardActivated() const { return mbKeyboardActivated; }
264 void SetKeyboardActivated( sal_Bool bKeyboard ) { mbKeyboardActivated = bKeyboard; }
267 inline HelpEvent::HelpEvent()
269 mnMode = HELPMODE_CONTEXT;
270 mbKeyboardActivated = sal_True;
273 inline HelpEvent::HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode ) :
274 maPos( rMousePos )
276 mnMode = nHelpMode;
277 mbKeyboardActivated = sal_False;
280 inline HelpEvent::HelpEvent( sal_uInt16 nHelpMode )
282 mnMode = nHelpMode;
283 mbKeyboardActivated = sal_True;
286 // -----------------
287 // - UserDrawEvent -
288 // -----------------
290 class VCL_DLLPUBLIC UserDrawEvent
292 private:
293 OutputDevice* mpOutDev;
294 Rectangle maOutRect;
295 sal_uInt16 mnItemId;
296 sal_uInt16 mnStyle;
298 public:
299 UserDrawEvent();
300 UserDrawEvent( OutputDevice* pOut,
301 const Rectangle& rOutRect,
302 sal_uInt16 nId, sal_uInt16 nStyle = 0 );
304 OutputDevice* GetDevice() const { return mpOutDev; }
305 const Rectangle& GetRect() const { return maOutRect; }
306 sal_uInt16 GetItemId() const { return mnItemId; }
307 sal_uInt16 GetStyle() const { return mnStyle; }
310 inline UserDrawEvent::UserDrawEvent()
312 mpOutDev = NULL;
313 mnItemId = 0;
314 mnStyle = 0;
317 inline UserDrawEvent::UserDrawEvent( OutputDevice* pOut,
318 const Rectangle& rOutRect,
319 sal_uInt16 nId, sal_uInt16 nStyle ) :
320 maOutRect( rOutRect )
322 mpOutDev = pOut;
323 mnItemId = nId;
324 mnStyle = nStyle;
327 // ------------------
328 // - Tracking-Types -
329 // ------------------
331 #define ENDTRACK_CANCEL ((sal_uInt16)0x0001)
332 #define ENDTRACK_KEY ((sal_uInt16)0x0002)
333 #define ENDTRACK_FOCUS ((sal_uInt16)0x0004)
334 #define ENDTRACK_END ((sal_uInt16)0x1000)
335 #define ENDTRACK_DONTCALLHDL ((sal_uInt16)0x8000)
337 #define TRACKING_REPEAT ((sal_uInt16)0x0100)
339 // -----------------
340 // - TrackingEvent -
341 // -----------------
343 class VCL_DLLPUBLIC TrackingEvent
345 private:
346 MouseEvent maMEvt;
347 sal_uInt16 mnFlags;
349 public:
350 explicit TrackingEvent();
351 explicit TrackingEvent( const MouseEvent&,
352 sal_uInt16 nTrackFlags = 0 );
354 const MouseEvent& GetMouseEvent() const { return maMEvt; }
356 sal_Bool IsTrackingRepeat() const
357 { return ((mnFlags & TRACKING_REPEAT) != 0); }
359 sal_Bool IsTrackingEnded() const
360 { return ((mnFlags & ENDTRACK_END) != 0); }
361 sal_Bool IsTrackingCanceled() const
362 { return ((mnFlags & ENDTRACK_CANCEL) != 0); }
363 sal_uInt16 GetTrackingFlags() const { return mnFlags; }
366 inline TrackingEvent::TrackingEvent()
368 mnFlags = 0;
371 inline TrackingEvent::TrackingEvent( const MouseEvent& rMEvt,
372 sal_uInt16 nTrackFlags ) :
373 maMEvt( rMEvt )
375 mnFlags = nTrackFlags;
378 // ---------------
379 // - NotifyEvent -
380 // ---------------
382 #define EVENT_MOUSEBUTTONDOWN 1
383 #define EVENT_MOUSEBUTTONUP 2
384 #define EVENT_MOUSEMOVE 3
385 #define EVENT_KEYINPUT 4
386 #define EVENT_KEYUP 5
387 #define EVENT_GETFOCUS 6
388 #define EVENT_LOSEFOCUS 7
389 #define EVENT_COMMAND 8
390 #define EVENT_DESTROY 9
391 #define EVENT_INPUTENABLE 10
392 #define EVENT_INPUTDISABLE 11
393 #define EVENT_EXECUTEDIALOG 100
394 #define EVENT_ENDEXECUTEDIALOG 101
396 class VCL_DLLPUBLIC NotifyEvent
398 private:
399 Window* mpWindow;
400 void* mpData;
401 sal_uInt16 mnType;
402 long mnRetValue;
404 public:
405 NotifyEvent();
406 NotifyEvent( sal_uInt16 nType,
407 Window* pWindow,
408 const void* pEvent = NULL,
409 long nRet = 0 );
411 sal_uInt16 GetType() const { return mnType; }
412 Window* GetWindow() const { return mpWindow; }
413 void* GetData() const { return mpData; }
415 void SetReturnValue( long nRet ) { mnRetValue = nRet; }
416 long GetReturnValue() const { return mnRetValue; }
418 const KeyEvent* GetKeyEvent() const;
419 const MouseEvent* GetMouseEvent() const;
420 const CommandEvent* GetCommandEvent() const;
423 inline NotifyEvent::NotifyEvent()
425 mpWindow = NULL;
426 mpData = NULL;
427 mnType = 0;
428 mnRetValue = 0;
431 inline NotifyEvent::NotifyEvent( sal_uInt16 nType, Window* pWindow,
432 const void* pEvent, long nRet )
434 mpWindow = pWindow;
435 mpData = (void*)pEvent;
436 mnType = nType;
437 mnRetValue = nRet;
440 inline const KeyEvent* NotifyEvent::GetKeyEvent() const
442 if ( (mnType == EVENT_KEYINPUT) || (mnType == EVENT_KEYUP) )
443 return (const KeyEvent*)mpData;
444 else
445 return NULL;
448 inline const MouseEvent* NotifyEvent::GetMouseEvent() const
450 if ( (mnType >= EVENT_MOUSEBUTTONDOWN) && (mnType <= EVENT_MOUSEMOVE) )
451 return (const MouseEvent*)mpData;
452 else
453 return NULL;
456 inline const CommandEvent* NotifyEvent::GetCommandEvent() const
458 if ( mnType == EVENT_COMMAND )
459 return (const CommandEvent*)mpData;
460 else
461 return NULL;
464 // --------------------
465 // - DataChangedEvent -
466 // --------------------
468 #define DATACHANGED_SETTINGS ((sal_uInt16)1)
469 #define DATACHANGED_DISPLAY ((sal_uInt16)2)
470 #define DATACHANGED_DATETIME ((sal_uInt16)3)
471 #define DATACHANGED_FONTS ((sal_uInt16)4)
472 #define DATACHANGED_PRINTER ((sal_uInt16)5)
473 #define DATACHANGED_FONTSUBSTITUTION ((sal_uInt16)6)
474 #define DATACHANGED_USER ((sal_uInt16)10000)
476 class VCL_DLLPUBLIC DataChangedEvent
478 private:
479 void* mpData;
480 sal_uLong mnFlags;
481 sal_uInt16 mnType;
483 public:
484 explicit DataChangedEvent();
485 explicit DataChangedEvent( sal_uInt16 nType,
486 const void* pData = NULL,
487 sal_uLong nFlags = 0 );
489 sal_uInt16 GetType() const { return mnType; }
490 void* GetData() const { return mpData; }
491 sal_uLong GetFlags() const { return mnFlags; }
493 const AllSettings* GetOldSettings() const;
496 inline DataChangedEvent::DataChangedEvent()
498 mpData = NULL;
499 mnFlags = 0;
500 mnType = 0;
503 inline DataChangedEvent::DataChangedEvent( sal_uInt16 nType,
504 const void* pData,
505 sal_uLong nChangeFlags )
507 mpData = (void*)pData;
508 mnFlags = nChangeFlags;
509 mnType = nType;
512 inline const AllSettings* DataChangedEvent::GetOldSettings() const
514 if ( mnType == DATACHANGED_SETTINGS )
515 return (const AllSettings*)mpData;
516 else
517 return NULL;
520 #endif // _SV_EVENT_HXX
522 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */