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_COMMANDEVENT_HXX
21 #define INCLUDED_VCL_COMMANDEVENT_HXX
24 #include <tools/gen.hxx>
25 #include <tools/solar.h>
26 #include <vcl/dllapi.h>
27 #include <vcl/keycodes.hxx>
28 #include <o3tl/typed_flags_set.hxx>
29 #include <rtl/ustring.hxx>
30 #include <vcl/GestureEventPan.hxx>
31 #include <vcl/GestureEventZoom.hxx>
32 #include <vcl/GestureEventRotate.hxx>
34 class CommandExtTextInputData
;
35 class CommandWheelData
;
36 class CommandScrollData
;
37 class CommandModKeyData
;
38 class CommandDialogData
;
39 class CommandMediaData
;
40 class CommandSelectionChangeData
;
41 class CommandGestureSwipeData
;
42 class CommandGestureLongPressData
;
43 class CommandGesturePanData
;
44 class CommandGestureZoomData
;
45 class CommandGestureRotateData
;
47 enum class CommandEventId
;
49 enum class ExtTextInputAttr
{
51 GrayWaveline
= 0x0010,
53 BoldUnderline
= 0x0040,
54 DottedUnderline
= 0x0080,
55 DashDotUnderline
= 0x0100,
56 DoubleUnderline
= 0x0200,
63 template<> struct typed_flags
<ExtTextInputAttr
> : is_typed_flags
<ExtTextInputAttr
, 0x1ff0> {};
66 #define EXTTEXTINPUT_CURSOR_INVISIBLE (sal_uInt16(0x0001))
67 #define EXTTEXTINPUT_CURSOR_OVERWRITE (sal_uInt16(0x0002))
70 class VCL_DLLPUBLIC CommandEvent
75 CommandEventId mnCommand
;
80 CommandEvent( const Point
& rMousePos
, CommandEventId nCmd
,
81 bool bMEvt
= false, const void* pCmdData
= nullptr );
83 CommandEventId
GetCommand() const { return mnCommand
; }
84 const Point
& GetMousePosPixel() const { return maPos
; }
85 bool IsMouseEvent() const { return mbMouseEvent
; }
86 void* GetEventData() const { return mpData
; }
88 const CommandExtTextInputData
* GetExtTextInputData() const;
89 const CommandWheelData
* GetWheelData() const;
90 const CommandScrollData
* GetAutoScrollData() const;
91 const CommandModKeyData
* GetModKeyData() const;
92 const CommandDialogData
* GetDialogData() const;
93 CommandMediaData
* GetMediaData() const;
94 const CommandSelectionChangeData
* GetSelectionChangeData() const;
95 const CommandGestureSwipeData
* GetGestureSwipeData() const;
96 const CommandGestureLongPressData
* GetLongPressData() const;
97 const CommandGesturePanData
* GetGesturePanData() const;
98 const CommandGestureZoomData
* GetGestureZoomData() const;
99 const CommandGestureRotateData
* GetGestureRotateData() const;
102 class VCL_DLLPUBLIC CommandExtTextInputData
106 std::unique_ptr
<ExtTextInputAttr
[]> mpTextAttr
;
107 sal_Int32 mnCursorPos
;
108 sal_uInt16 mnCursorFlags
;
112 CommandExtTextInputData( OUString aText
,
113 const ExtTextInputAttr
* pTextAttr
,
114 sal_Int32 nCursorPos
,
115 sal_uInt16 nCursorFlags
,
117 CommandExtTextInputData( const CommandExtTextInputData
& rData
);
118 ~CommandExtTextInputData();
120 const OUString
& GetText() const { return maText
; }
121 const ExtTextInputAttr
* GetTextAttr() const { return mpTextAttr
.get(); }
123 sal_Int32
GetCursorPos() const { return mnCursorPos
; }
124 bool IsCursorVisible() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_INVISIBLE
) == 0; }
125 bool IsCursorOverwrite() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_OVERWRITE
) != 0; }
126 bool IsOnlyCursorChanged() const { return mbOnlyCursor
; }
129 class VCL_DLLPUBLIC CommandInputContextData
133 enum class CommandWheelMode
141 // Magic value used in mnLines field in CommandWheelData
142 #define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF))
144 class VCL_DLLPUBLIC CommandWheelData
148 tools::Long mnNotchDelta
;
150 CommandWheelMode mnWheelMode
;
157 CommandWheelData( tools::Long nWheelDelta
, tools::Long nWheelNotchDelta
,
159 CommandWheelMode nWheelMode
, sal_uInt16 nKeyModifier
,
160 bool bHorz
, bool bDeltaIsPixel
= false );
162 tools::Long
GetDelta() const { return mnDelta
; }
163 tools::Long
GetNotchDelta() const { return mnNotchDelta
; }
164 double GetScrollLines() const { return mnLines
; }
165 bool IsHorz() const { return mbHorz
; }
166 bool IsDeltaPixel() const { return mbDeltaIsPixel
; }
168 CommandWheelMode
GetMode() const { return mnWheelMode
; }
170 sal_uInt16
GetModifier() const
171 { return (mnCode
& (KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
)); }
173 { return ((mnCode
& KEY_SHIFT
) != 0); }
175 { return ((mnCode
& KEY_MOD1
) != 0); }
177 { return ((mnCode
& KEY_MOD2
) != 0); }
180 class CommandScrollData
183 tools::Long mnDeltaX
;
184 tools::Long mnDeltaY
;
187 CommandScrollData( tools::Long nDeltaX
, tools::Long nDeltaY
);
189 tools::Long
GetDeltaX() const { return mnDeltaX
; }
190 tools::Long
GetDeltaY() const { return mnDeltaY
; }
193 class CommandModKeyData
200 CommandModKeyData( ModKeyFlags nCode
, bool bDown
);
202 bool IsDown() const { return mbDown
; }
203 bool IsMod1() const { return bool(mnCode
& ModKeyFlags::Mod1Msk
); }
204 bool IsMod2() const { return bool(mnCode
& ModKeyFlags::Mod2Msk
); }
205 bool IsLeftShift() const { return bool(mnCode
& ModKeyFlags::LeftShift
); }
206 bool IsRightShift() const { return bool(mnCode
& ModKeyFlags::RightShift
); }
209 enum class ShowDialogId
215 class VCL_DLLPUBLIC CommandDialogData
217 ShowDialogId m_nDialogId
;
219 CommandDialogData( ShowDialogId nDialogId
)
220 : m_nDialogId( nDialogId
)
223 ShowDialogId
GetDialogId() const { return m_nDialogId
; }
227 enum class MediaCommand
229 ChannelDown
= 1, // Decrement the channel value, for example, for a TV or radio tuner.
230 ChannelUp
= 2, // Increment the channel value, for example, for a TV or radio tuner.
231 NextTrack
= 3, // Go to next media track/slide.
232 Pause
= 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
233 Play
= 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
234 PlayPause
= 6, // Play or pause playback.
235 PreviousTrack
= 7, // Go to previous media track/slide.
236 Record
= 8, // Begin recording the current stream.
237 Rewind
= 9,// Go backward in a stream at a higher rate of speed.
238 Stop
= 10,// Stop playback.
239 MicOnOffToggle
= 11,// Toggle the microphone.
240 MicrophoneVolumeDown
= 12,// Increase microphone volume.
241 MicrophoneVolumeMute
= 13,// Mute the microphone.
242 MicrophoneVolumeUp
= 14,// Decrease microphone volume.
243 VolumeDown
= 15,// Lower the volume.
244 VolumeMute
= 16,// Mute the volume.
245 VolumeUp
= 17,// Raise the volume.
246 Menu
= 18,// Button Menu pressed.
247 PlayHold
= 20,// Button Play (long) pressed.
248 NextTrackHold
= 21,// Button Right holding pressed.
251 class VCL_DLLPUBLIC CommandMediaData
253 MediaCommand m_nMediaId
;
254 bool m_bPassThroughToOS
;
256 CommandMediaData(MediaCommand nMediaId
)
257 : m_nMediaId(nMediaId
)
258 , m_bPassThroughToOS(true)
261 MediaCommand
GetMediaId() const { return m_nMediaId
; }
262 void SetPassThroughToOS(bool bPassThroughToOS
) { m_bPassThroughToOS
= bPassThroughToOS
; }
263 bool GetPassThroughToOS() const { return m_bPassThroughToOS
; }
266 class CommandSelectionChangeData
273 CommandSelectionChangeData( sal_uLong nStart
, sal_uLong nEnd
);
275 sal_uLong
GetStart() const { return mnStart
; }
276 sal_uLong
GetEnd() const { return mnEnd
; }
279 class VCL_DLLPUBLIC CommandGestureSwipeData
283 CommandGestureSwipeData()
287 CommandGestureSwipeData(double nVelocityX
)
288 : mnVelocityX(nVelocityX
)
291 double getVelocityX() const { return mnVelocityX
; }
295 class VCL_DLLPUBLIC CommandGestureLongPressData
300 CommandGestureLongPressData()
305 CommandGestureLongPressData(double nX
, double nY
)
310 double getX() const { return mnX
; }
311 double getY() const { return mnY
; }
314 class VCL_DLLPUBLIC CommandGesturePanData
319 double const mfOffset
;
320 GestureEventPanType
const meEventType
;
321 PanningOrientation
const meOrientation
;
323 CommandGesturePanData(double fX
, double fY
, GestureEventPanType eEventType
, double fOffset
,
324 PanningOrientation eOrientation
)
328 , meEventType(eEventType
)
329 , meOrientation(eOrientation
)
333 class VCL_DLLPUBLIC CommandGestureZoomData
336 const double mfX
= 0;
337 const double mfY
= 0;
338 const GestureEventZoomType meEventType
= GestureEventZoomType::Begin
;
339 const double mfScaleDelta
= 0;
341 CommandGestureZoomData(double fX
, double fY
, GestureEventZoomType eEventType
, double fScale
)
344 , meEventType(eEventType
)
345 , mfScaleDelta(fScale
)
349 class VCL_DLLPUBLIC CommandGestureRotateData
352 const double mfX
= 0;
353 const double mfY
= 0;
354 const GestureEventRotateType meEventType
= GestureEventRotateType::Begin
;
355 const double mfAngleDelta
= 0;
357 CommandGestureRotateData(double fX
, double fY
, GestureEventRotateType eEventType
,
361 , meEventType(eEventType
)
362 , mfAngleDelta(fAngleDelta
)
366 enum class CommandEventId
374 StartExtTextInput
= 7,
377 InputContextChange
= 10,
381 InputLanguageChange
= 15,
384 SelectionChange
= 18,
385 PrepareReconversion
= 19,
386 QueryCharPosition
= 20,
388 GestureLongPress
= 22,
394 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */