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 .
20 #ifndef INCLUDED_VCL_EVENT_HXX
21 #define INCLUDED_VCL_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/commandevent.hxx>
28 #include <vcl/settings.hxx>
29 #include <vcl/vclptr.hxx>
30 #include <vcl/outdev.hxx>
31 #include <vcl/window.hxx>
36 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
41 enum class TextDirectionality
{
42 LeftToRight_TopToBottom
,
43 RightToLeft_TopToBottom
,
44 TopToBottom_RightToLeft
,
45 BottomToTop_LeftToRight
48 class VCL_DLLPUBLIC KeyEvent
51 vcl::KeyCode maKeyCode
;
53 sal_Unicode mnCharCode
;
57 KeyEvent( sal_Unicode nChar
, const vcl::KeyCode
& rKeyCode
,
58 sal_uInt16 nRepeat
= 0 );
60 sal_Unicode
GetCharCode() const { return mnCharCode
; }
61 const vcl::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 vcl::KeyCode
& rKeyCode
,
76 sal_uInt16 nRepeat
) :
85 enum class MouseEventModifiers
88 // mouse move modifiers
95 MODIFIERCHANGED
= 0x0080,
96 // mouse up/down-button modifiers
104 template<> struct typed_flags
<MouseEventModifiers
> : is_typed_flags
<MouseEventModifiers
, 0xff7> {};
108 #define MOUSE_LEFT ((sal_uInt16)0x0001)
109 #define MOUSE_MIDDLE ((sal_uInt16)0x0002)
110 #define MOUSE_RIGHT ((sal_uInt16)0x0004)
113 class VCL_DLLPUBLIC MouseEvent
117 MouseEventModifiers mnMode
;
122 explicit MouseEvent();
123 explicit MouseEvent( const Point
& rPos
, sal_uInt16 nClicks
= 1,
124 MouseEventModifiers nMode
= MouseEventModifiers::NONE
, sal_uInt16 nButtons
= 0,
125 sal_uInt16 nModifier
= 0 );
127 const Point
& GetPosPixel() const { return maPos
; }
128 MouseEventModifiers
GetMode() const { return mnMode
; }
130 sal_uInt16
GetClicks() const { return mnClicks
; }
132 bool IsEnterWindow() const
133 { return bool(mnMode
& MouseEventModifiers::ENTERWINDOW
); }
134 bool IsLeaveWindow() const
135 { return bool(mnMode
& MouseEventModifiers::LEAVEWINDOW
); }
136 bool IsSynthetic() const
137 { return bool(mnMode
& MouseEventModifiers::SYNTHETIC
); }
138 bool IsModifierChanged() const
139 { return bool(mnMode
& MouseEventModifiers::MODIFIERCHANGED
); }
141 sal_uInt16
GetButtons() const
142 { return (mnCode
& (MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
)); }
144 { return ((mnCode
& MOUSE_LEFT
) != 0); }
145 bool IsMiddle() const
146 { return ((mnCode
& MOUSE_MIDDLE
) != 0); }
148 { return ((mnCode
& MOUSE_RIGHT
) != 0); }
150 sal_uInt16
GetModifier() const
151 { return (mnCode
& (KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
)); }
153 { return ((mnCode
& KEY_SHIFT
) != 0); }
155 { return ((mnCode
& KEY_MOD1
) != 0); }
157 { return ((mnCode
& KEY_MOD2
) != 0); }
159 { return ((mnCode
& KEY_MOD3
) != 0); }
162 inline MouseEvent::MouseEvent()
164 mnMode
= MouseEventModifiers::NONE
;
169 inline MouseEvent::MouseEvent( const Point
& rPos
, sal_uInt16 nClicks
,
170 MouseEventModifiers nMode
,
171 sal_uInt16 nButtons
, sal_uInt16 nModifier
) :
176 mnCode
= nButtons
| nModifier
;
179 enum class HelpEventMode
189 template<> struct typed_flags
<HelpEventMode
> : is_typed_flags
<HelpEventMode
, 0x0f> {};
192 class VCL_DLLPUBLIC HelpEvent
196 HelpEventMode mnMode
;
197 bool mbKeyboardActivated
;
200 explicit HelpEvent( const Point
& rMousePos
, HelpEventMode nHelpMode
);
202 const Point
& GetMousePosPixel() const { return maPos
; }
203 HelpEventMode
GetMode() const { return mnMode
; }
204 bool KeyboardActivated() const { return mbKeyboardActivated
; }
205 void SetKeyboardActivated( bool bKeyboard
) { mbKeyboardActivated
= bKeyboard
; }
208 inline HelpEvent::HelpEvent( const Point
& rMousePos
, HelpEventMode nHelpMode
) :
212 mbKeyboardActivated
= false;
215 /// Event to pass information for UserDraw() handling eg. in comboboxes.
216 class VCL_DLLPUBLIC UserDrawEvent
219 /// Window that owns the user draw.
220 VclPtr
<vcl::Window
> mpWindow
;
222 /// RenderContext to which we should draw - can be a VirtualDevice or anything.
223 VclPtr
<vcl::RenderContext
> mpRenderContext
;
225 tools::Rectangle maOutRect
;
230 UserDrawEvent(vcl::Window
* pWindow
, vcl::RenderContext
* pRenderContext
,
231 const tools::Rectangle
& rOutRect
, sal_uInt16 nId
, sal_uInt16 nStyle
= 0);
233 vcl::Window
* GetWindow() const { return mpWindow
; }
234 vcl::RenderContext
* GetRenderContext() const { return mpRenderContext
; }
235 const tools::Rectangle
& GetRect() const { return maOutRect
; }
236 sal_uInt16
GetItemId() const { return mnItemId
; }
237 sal_uInt16
GetStyle() const { return mnStyle
; }
240 inline UserDrawEvent::UserDrawEvent(vcl::Window
* pWindow
, vcl::RenderContext
* pRenderContext
,
241 const tools::Rectangle
& rOutRect
, sal_uInt16 nId
, sal_uInt16 nStyle
)
243 , mpRenderContext(pRenderContext
)
244 , maOutRect( rOutRect
)
251 class VCL_DLLPUBLIC TrackingEvent
255 TrackingEventFlags mnFlags
;
258 explicit TrackingEvent( const MouseEvent
&,
259 TrackingEventFlags nTrackFlags
= TrackingEventFlags::NONE
);
261 const MouseEvent
& GetMouseEvent() const { return maMEvt
; }
263 bool IsTrackingRepeat() const
264 { return bool(mnFlags
& TrackingEventFlags::Repeat
); }
265 bool IsTrackingEnded() const
266 { return bool(mnFlags
& TrackingEventFlags::End
); }
267 bool IsTrackingCanceled() const
268 { return bool(mnFlags
& TrackingEventFlags::Cancel
); }
271 inline TrackingEvent::TrackingEvent( const MouseEvent
& rMEvt
,
272 TrackingEventFlags nTrackFlags
) :
275 mnFlags
= nTrackFlags
;
279 enum class MouseNotifyEvent
294 ENDEXECUTEDIALOG
= 101
297 class VCL_DLLPUBLIC NotifyEvent
300 VclPtr
<vcl::Window
> mpWindow
;
302 MouseNotifyEvent mnEventType
;
305 NotifyEvent( MouseNotifyEvent nEventType
,
306 vcl::Window
* pWindow
,
307 const void* pEvent
= nullptr );
309 MouseNotifyEvent
GetType() const { return mnEventType
; }
310 vcl::Window
* GetWindow() const { return mpWindow
; }
311 void* GetData() const { return mpData
; }
312 const KeyEvent
* GetKeyEvent() const;
313 const MouseEvent
* GetMouseEvent() const;
314 const CommandEvent
* GetCommandEvent() const;
317 inline const KeyEvent
* NotifyEvent::GetKeyEvent() const
319 if ( (mnEventType
== MouseNotifyEvent::KEYINPUT
) || (mnEventType
== MouseNotifyEvent::KEYUP
) )
320 return static_cast<const KeyEvent
*>(mpData
);
325 inline const MouseEvent
* NotifyEvent::GetMouseEvent() const
327 if ( (mnEventType
>= MouseNotifyEvent::MOUSEBUTTONDOWN
) && (mnEventType
<= MouseNotifyEvent::MOUSEMOVE
) )
328 return static_cast<const MouseEvent
*>(mpData
);
333 inline const CommandEvent
* NotifyEvent::GetCommandEvent() const
335 if ( mnEventType
== MouseNotifyEvent::COMMAND
)
336 return static_cast<const CommandEvent
*>(mpData
);
342 enum class DataChangedEventType
{
348 FONTSUBSTITUTION
= 6,
352 class VCL_DLLPUBLIC DataChangedEvent
356 AllSettingsFlags mnFlags
;
357 DataChangedEventType mnType
;
360 explicit DataChangedEvent( DataChangedEventType nType
,
361 const void* pData
= nullptr,
362 AllSettingsFlags nFlags
= AllSettingsFlags::NONE
);
364 DataChangedEventType
GetType() const { return mnType
; }
365 AllSettingsFlags
GetFlags() const { return mnFlags
; }
367 const AllSettings
* GetOldSettings() const;
370 inline DataChangedEvent::DataChangedEvent( DataChangedEventType nType
,
372 AllSettingsFlags nChangeFlags
)
374 mpData
= const_cast<void*>(pData
);
375 mnFlags
= nChangeFlags
;
379 inline const AllSettings
* DataChangedEvent::GetOldSettings() const
381 if ( mnType
== DataChangedEventType::SETTINGS
)
382 return static_cast<const AllSettings
*>(mpData
);
387 #endif // INCLUDED_VCL_EVENT_HXX
389 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */