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/GestureEvent.hxx>
32 class CommandExtTextInputData
;
33 class CommandWheelData
;
34 class CommandScrollData
;
35 class CommandModKeyData
;
36 class CommandDialogData
;
37 class CommandMediaData
;
38 class CommandSelectionChangeData
;
39 class CommandSwipeData
;
40 class CommandLongPressData
;
41 class CommandGestureData
;
43 enum class CommandEventId
;
45 enum class ExtTextInputAttr
{
47 GrayWaveline
= 0x0100,
49 BoldUnderline
= 0x0400,
50 DottedUnderline
= 0x0800,
51 DashDotUnderline
= 0x1000,
58 template<> struct typed_flags
<ExtTextInputAttr
> : is_typed_flags
<ExtTextInputAttr
, 0xff00> {};
61 #define EXTTEXTINPUT_CURSOR_INVISIBLE (sal_uInt16(0x0001))
62 #define EXTTEXTINPUT_CURSOR_OVERWRITE (sal_uInt16(0x0002))
65 class VCL_DLLPUBLIC CommandEvent
70 CommandEventId mnCommand
;
75 CommandEvent( const Point
& rMousePos
, CommandEventId nCmd
,
76 bool bMEvt
= false, const void* pCmdData
= nullptr );
78 CommandEventId
GetCommand() const { return mnCommand
; }
79 const Point
& GetMousePosPixel() const { return maPos
; }
80 bool IsMouseEvent() const { return mbMouseEvent
; }
81 void* GetEventData() const { return mpData
; }
83 const CommandExtTextInputData
* GetExtTextInputData() const;
84 const CommandWheelData
* GetWheelData() const;
85 const CommandScrollData
* GetAutoScrollData() const;
86 const CommandModKeyData
* GetModKeyData() const;
87 const CommandDialogData
* GetDialogData() const;
88 CommandMediaData
* GetMediaData() const;
89 const CommandSelectionChangeData
* GetSelectionChangeData() const;
90 const CommandSwipeData
* GetSwipeData() const;
91 const CommandLongPressData
* GetLongPressData() const;
92 const CommandGestureData
* GetGestureData() const;
95 class VCL_DLLPUBLIC CommandExtTextInputData
99 std::unique_ptr
<ExtTextInputAttr
[]> mpTextAttr
;
100 sal_Int32 mnCursorPos
;
101 sal_uInt16 mnCursorFlags
;
105 CommandExtTextInputData( const OUString
& rText
,
106 const ExtTextInputAttr
* pTextAttr
,
107 sal_Int32 nCursorPos
,
108 sal_uInt16 nCursorFlags
,
110 CommandExtTextInputData( const CommandExtTextInputData
& rData
);
111 ~CommandExtTextInputData();
113 const OUString
& GetText() const { return maText
; }
114 const ExtTextInputAttr
* GetTextAttr() const { return mpTextAttr
.get(); }
116 sal_Int32
GetCursorPos() const { return mnCursorPos
; }
117 bool IsCursorVisible() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_INVISIBLE
) == 0; }
118 bool IsCursorOverwrite() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_OVERWRITE
) != 0; }
119 bool IsOnlyCursorChanged() const { return mbOnlyCursor
; }
122 class VCL_DLLPUBLIC CommandInputContextData
126 enum class CommandWheelMode
134 // Magic value used in mnLines field in CommandWheelData
135 #define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF))
137 class VCL_DLLPUBLIC CommandWheelData
141 tools::Long mnNotchDelta
;
143 CommandWheelMode mnWheelMode
;
150 CommandWheelData( tools::Long nWheelDelta
, tools::Long nWheelNotchDelta
,
152 CommandWheelMode nWheelMode
, sal_uInt16 nKeyModifier
,
153 bool bHorz
, bool bDeltaIsPixel
= false );
155 tools::Long
GetDelta() const { return mnDelta
; }
156 tools::Long
GetNotchDelta() const { return mnNotchDelta
; }
157 double GetScrollLines() const { return mnLines
; }
158 bool IsHorz() const { return mbHorz
; }
159 bool IsDeltaPixel() const { return mbDeltaIsPixel
; }
161 CommandWheelMode
GetMode() const { return mnWheelMode
; }
163 sal_uInt16
GetModifier() const
164 { return (mnCode
& (KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
)); }
166 { return ((mnCode
& KEY_SHIFT
) != 0); }
168 { return ((mnCode
& KEY_MOD1
) != 0); }
170 { return ((mnCode
& KEY_MOD2
) != 0); }
173 class CommandScrollData
176 tools::Long mnDeltaX
;
177 tools::Long mnDeltaY
;
180 CommandScrollData( tools::Long nDeltaX
, tools::Long nDeltaY
);
182 tools::Long
GetDeltaX() const { return mnDeltaX
; }
183 tools::Long
GetDeltaY() const { return mnDeltaY
; }
186 class CommandModKeyData
193 CommandModKeyData( ModKeyFlags nCode
, bool bDown
);
195 bool IsDown() const { return mbDown
; }
196 bool IsMod1() const { return bool(mnCode
& ModKeyFlags::Mod1Msk
); }
197 bool IsMod2() const { return bool(mnCode
& ModKeyFlags::Mod2Msk
); }
198 bool IsLeftShift() const { return bool(mnCode
& ModKeyFlags::LeftShift
); }
199 bool IsRightShift() const { return bool(mnCode
& ModKeyFlags::RightShift
); }
202 enum class ShowDialogId
208 class VCL_DLLPUBLIC CommandDialogData
210 ShowDialogId m_nDialogId
;
212 CommandDialogData( ShowDialogId nDialogId
)
213 : m_nDialogId( nDialogId
)
216 ShowDialogId
GetDialogId() const { return m_nDialogId
; }
220 enum class MediaCommand
222 ChannelDown
= 1, // Decrement the channel value, for example, for a TV or radio tuner.
223 ChannelUp
= 2, // Increment the channel value, for example, for a TV or radio tuner.
224 NextTrack
= 3, // Go to next media track/slide.
225 Pause
= 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
226 Play
= 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
227 PlayPause
= 6, // Play or pause playback.
228 PreviousTrack
= 7, // Go to previous media track/slide.
229 Record
= 8, // Begin recording the current stream.
230 Rewind
= 9,// Go backward in a stream at a higher rate of speed.
231 Stop
= 10,// Stop playback.
232 MicOnOffToggle
= 11,// Toggle the microphone.
233 MicrophoneVolumeDown
= 12,// Increase microphone volume.
234 MicrophoneVolumeMute
= 13,// Mute the microphone.
235 MicrophoneVolumeUp
= 14,// Decrease microphone volume.
236 VolumeDown
= 15,// Lower the volume.
237 VolumeMute
= 16,// Mute the volume.
238 VolumeUp
= 17,// Raise the volume.
239 Menu
= 18,// Button Menu pressed.
240 PlayHold
= 20,// Button Play (long) pressed.
241 NextTrackHold
= 21,// Button Right holding pressed.
244 class VCL_DLLPUBLIC CommandMediaData
246 MediaCommand m_nMediaId
;
247 bool m_bPassThroughToOS
;
249 CommandMediaData(MediaCommand nMediaId
)
250 : m_nMediaId(nMediaId
)
251 , m_bPassThroughToOS(true)
254 MediaCommand
GetMediaId() const { return m_nMediaId
; }
255 void SetPassThroughToOS(bool bPassThroughToOS
) { m_bPassThroughToOS
= bPassThroughToOS
; }
256 bool GetPassThroughToOS() const { return m_bPassThroughToOS
; }
259 class CommandSelectionChangeData
266 CommandSelectionChangeData( sal_uLong nStart
, sal_uLong nEnd
);
268 sal_uLong
GetStart() const { return mnStart
; }
269 sal_uLong
GetEnd() const { return mnEnd
; }
272 class VCL_DLLPUBLIC CommandSwipeData
280 CommandSwipeData(double nVelocityX
)
281 : mnVelocityX(nVelocityX
)
284 double getVelocityX() const { return mnVelocityX
; }
288 class VCL_DLLPUBLIC CommandLongPressData
293 CommandLongPressData()
298 CommandLongPressData(double nX
, double nY
)
303 double getX() const { return mnX
; }
304 double getY() const { return mnY
; }
307 class VCL_DLLPUBLIC CommandGestureData
312 GestureEventType
const meEventType
;
314 double const mfOffset
;
315 PanningOrientation
const meOrientation
;
317 CommandGestureData(double fX
, double fY
, GestureEventType eEventType
, double fOffset
, PanningOrientation eOrientation
)
320 , meEventType(eEventType
)
322 , meOrientation(eOrientation
)
326 enum class CommandEventId
334 StartExtTextInput
= 7,
337 InputContextChange
= 10,
341 InputLanguageChange
= 15,
344 SelectionChange
= 18,
345 PrepareReconversion
= 19,
346 QueryCharPosition
= 20,
352 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
354 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */