1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
34 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
39 enum TextDirectionality
{
40 TextDirectionality_LeftToRight_TopToBottom
,
41 TextDirectionality_RightToLeft_TopToBottom
,
42 TextDirectionality_TopToBottom_RightToLeft
48 class VCL_DLLPUBLIC KeyEvent
53 sal_Unicode mnCharCode
;
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()
75 inline KeyEvent::KeyEvent( sal_Unicode nChar
, const KeyCode
& rKeyCode
,
76 sal_uInt16 nRepeat
) :
84 // --------------------
85 // - MouseEvent-Types -
86 // --------------------
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)
104 #define MOUSE_LEFT ((sal_uInt16)0x0001)
105 #define MOUSE_MIDDLE ((sal_uInt16)0x0002)
106 #define MOUSE_RIGHT ((sal_uInt16)0x0004)
112 class VCL_DLLPUBLIC MouseEvent
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
)); }
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()
170 inline MouseEvent::MouseEvent( const Point
& rPos
, sal_uInt16 nClicks
,
172 sal_uInt16 nButtons
, sal_uInt16 nModifier
) :
177 mnCode
= nButtons
| nModifier
;
180 class VCL_DLLPUBLIC ZoomEvent
192 ZoomEvent( const Point
& rCenter
,
199 const Point
& GetCenter() const
204 float GetScale() const
210 class VCL_DLLPUBLIC ScrollEvent
223 ScrollEvent( int xOffset
, int yOffset
) :
224 mnXOffset( xOffset
),
229 int GetXOffset() const
234 int GetYOffset() const
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
254 sal_Bool mbKeyboardActivated
;
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
) :
277 mbKeyboardActivated
= sal_False
;
280 inline HelpEvent::HelpEvent( sal_uInt16 nHelpMode
)
283 mbKeyboardActivated
= sal_True
;
290 class VCL_DLLPUBLIC UserDrawEvent
293 OutputDevice
* mpOutDev
;
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()
317 inline UserDrawEvent::UserDrawEvent( OutputDevice
* pOut
,
318 const Rectangle
& rOutRect
,
319 sal_uInt16 nId
, sal_uInt16 nStyle
) :
320 maOutRect( rOutRect
)
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)
343 class VCL_DLLPUBLIC TrackingEvent
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()
371 inline TrackingEvent::TrackingEvent( const MouseEvent
& rMEvt
,
372 sal_uInt16 nTrackFlags
) :
375 mnFlags
= nTrackFlags
;
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
406 NotifyEvent( sal_uInt16 nType
,
408 const void* pEvent
= NULL
,
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()
431 inline NotifyEvent::NotifyEvent( sal_uInt16 nType
, Window
* pWindow
,
432 const void* pEvent
, long nRet
)
435 mpData
= (void*)pEvent
;
440 inline const KeyEvent
* NotifyEvent::GetKeyEvent() const
442 if ( (mnType
== EVENT_KEYINPUT
) || (mnType
== EVENT_KEYUP
) )
443 return (const KeyEvent
*)mpData
;
448 inline const MouseEvent
* NotifyEvent::GetMouseEvent() const
450 if ( (mnType
>= EVENT_MOUSEBUTTONDOWN
) && (mnType
<= EVENT_MOUSEMOVE
) )
451 return (const MouseEvent
*)mpData
;
456 inline const CommandEvent
* NotifyEvent::GetCommandEvent() const
458 if ( mnType
== EVENT_COMMAND
)
459 return (const CommandEvent
*)mpData
;
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
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()
503 inline DataChangedEvent::DataChangedEvent( sal_uInt16 nType
,
505 sal_uLong nChangeFlags
)
507 mpData
= (void*)pData
;
508 mnFlags
= nChangeFlags
;
512 inline const AllSettings
* DataChangedEvent::GetOldSettings() const
514 if ( mnType
== DATACHANGED_SETTINGS
)
515 return (const AllSettings
*)mpData
;
520 #endif // _SV_EVENT_HXX
522 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */