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/keycod.hxx>
28 #include <vcl/font.hxx>
29 #include <o3tl/typed_flags_set.hxx>
31 class CommandExtTextInputData
;
32 class CommandWheelData
;
33 class CommandScrollData
;
34 class CommandModKeyData
;
35 class CommandDialogData
;
36 class CommandMediaData
;
37 class CommandSelectionChangeData
;
38 class CommandSwipeData
;
39 class CommandLongPressData
;
40 enum class CommandEventId
;
42 enum class ExtTextInputAttr
{
44 GrayWaveline
= 0x0100,
46 BoldUnderline
= 0x0400,
47 DottedUnderline
= 0x0800,
48 DashDotUnderline
= 0x1000,
55 template<> struct typed_flags
<ExtTextInputAttr
> : is_typed_flags
<ExtTextInputAttr
, 0xff00> {};
58 #define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001)
59 #define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002)
62 class VCL_DLLPUBLIC CommandEvent
67 CommandEventId mnCommand
;
72 CommandEvent( const Point
& rMousePos
, CommandEventId nCmd
,
73 bool bMEvt
= false, const void* pCmdData
= nullptr );
75 CommandEventId
GetCommand() const { return mnCommand
; }
76 const Point
& GetMousePosPixel() const { return maPos
; }
77 bool IsMouseEvent() const { return mbMouseEvent
; }
78 void* GetEventData() const { return mpData
; }
80 const CommandExtTextInputData
* GetExtTextInputData() const;
81 const CommandWheelData
* GetWheelData() const;
82 const CommandScrollData
* GetAutoScrollData() const;
83 const CommandModKeyData
* GetModKeyData() const;
84 const CommandDialogData
* GetDialogData() const;
85 CommandMediaData
* GetMediaData() const;
86 const CommandSelectionChangeData
* GetSelectionChangeData() const;
87 const CommandSwipeData
* GetSwipeData() const;
88 const CommandLongPressData
* GetLongPressData() const;
91 class VCL_DLLPUBLIC CommandExtTextInputData
95 std::unique_ptr
<ExtTextInputAttr
[]> mpTextAttr
;
96 sal_Int32 mnCursorPos
;
97 sal_uInt16 mnCursorFlags
;
101 CommandExtTextInputData( const OUString
& rText
,
102 const ExtTextInputAttr
* pTextAttr
,
103 sal_Int32 nCursorPos
,
104 sal_uInt16 nCursorFlags
,
106 CommandExtTextInputData( const CommandExtTextInputData
& rData
);
107 ~CommandExtTextInputData();
109 const OUString
& GetText() const { return maText
; }
110 const ExtTextInputAttr
* GetTextAttr() const { return mpTextAttr
.get(); }
112 sal_Int32
GetCursorPos() const { return mnCursorPos
; }
113 bool IsCursorVisible() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_INVISIBLE
) == 0; }
114 bool IsCursorOverwrite() const { return (mnCursorFlags
& EXTTEXTINPUT_CURSOR_OVERWRITE
) != 0; }
115 bool IsOnlyCursorChanged() const { return mbOnlyCursor
; }
118 class VCL_DLLPUBLIC CommandInputContextData
121 LanguageType meLanguage
;
124 CommandInputContextData( LanguageType eLang
);
127 enum class CommandWheelMode
135 // Magic value used in mnLines field in CommandWheelData
136 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
138 class VCL_DLLPUBLIC CommandWheelData
144 CommandWheelMode mnWheelMode
;
151 CommandWheelData( long nWheelDelta
, long nWheelNotchDelta
,
153 CommandWheelMode nWheelMode
, sal_uInt16 nKeyModifier
,
154 bool bHorz
, bool bDeltaIsPixel
= false );
156 long GetDelta() const { return mnDelta
; }
157 long GetNotchDelta() const { return mnNotchDelta
; }
158 double GetScrollLines() const { return mnLines
; }
159 bool IsHorz() const { return mbHorz
; }
160 bool IsDeltaPixel() const { return mbDeltaIsPixel
; }
162 CommandWheelMode
GetMode() const { return mnWheelMode
; }
164 sal_uInt16
GetModifier() const
165 { return (mnCode
& (KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
)); }
167 { return ((mnCode
& KEY_SHIFT
) != 0); }
169 { return ((mnCode
& KEY_MOD1
) != 0); }
171 { return ((mnCode
& KEY_MOD2
) != 0); }
174 class VCL_DLLPUBLIC CommandScrollData
181 CommandScrollData( long nDeltaX
, long nDeltaY
);
183 long GetDeltaX() const { return mnDeltaX
; }
184 long GetDeltaY() const { return mnDeltaY
; }
187 class VCL_DLLPUBLIC CommandModKeyData
194 CommandModKeyData( ModKeyFlags nCode
, bool bDown
);
196 bool IsDown() const { return mbDown
; }
197 bool IsMod1() const { return bool(mnCode
& ModKeyFlags::Mod1Msk
); }
198 bool IsMod2() const { return bool(mnCode
& ModKeyFlags::Mod2Msk
); }
199 bool IsLeftShift() const { return bool(mnCode
& ModKeyFlags::LeftShift
); }
200 bool IsRightShift() const { return bool(mnCode
& ModKeyFlags::RightShift
); }
203 enum class ShowDialogId
209 class VCL_DLLPUBLIC CommandDialogData
211 ShowDialogId m_nDialogId
;
213 CommandDialogData( ShowDialogId nDialogId
)
214 : m_nDialogId( nDialogId
)
217 ShowDialogId
GetDialogId() const { return m_nDialogId
; }
221 enum class MediaCommand
223 ChannelDown
= 1, // Decrement the channel value, for example, for a TV or radio tuner.
224 ChannelUp
= 2, // Increment the channel value, for example, for a TV or radio tuner.
225 NextTrack
= 3, // Go to next media track/slide.
226 Pause
= 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
227 Play
= 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
228 PlayPause
= 6, // Play or pause playback.
229 PreviousTrack
= 7, // Go to previous media track/slide.
230 Record
= 8, // Begin recording the current stream.
231 Rewind
= 9,// Go backward in a stream at a higher rate of speed.
232 Stop
= 10,// Stop playback.
233 MicOnOffToggle
= 11,// Toggle the microphone.
234 MicrophoneVolumeDown
= 12,// Increase microphone volume.
235 MicrophoneVolumeMute
= 13,// Mute the microphone.
236 MicrophoneVolumeUp
= 14,// Decrease microphone volume.
237 VolumeDown
= 15,// Lower the volume.
238 VolumeMute
= 16,// Mute the volume.
239 VolumeUp
= 17,// Raise the volume.
240 Menu
= 18,// Button Menu pressed.
241 PlayHold
= 20,// Button Play (long) pressed.
242 NextTrackHold
= 21,// Button Right holding pressed.
245 class VCL_DLLPUBLIC CommandMediaData
247 MediaCommand m_nMediaId
;
248 bool m_bPassThroughToOS
;
250 CommandMediaData(MediaCommand nMediaId
)
251 : m_nMediaId(nMediaId
)
252 , m_bPassThroughToOS(true)
255 MediaCommand
GetMediaId() const { return m_nMediaId
; }
256 void SetPassThroughToOS(bool bPassThroughToOS
) { m_bPassThroughToOS
= bPassThroughToOS
; }
257 bool GetPassThroughToOS() const { return m_bPassThroughToOS
; }
260 class VCL_DLLPUBLIC CommandSelectionChangeData
267 CommandSelectionChangeData( sal_uLong nStart
, sal_uLong nEnd
);
269 sal_uLong
GetStart() const { return mnStart
; }
270 sal_uLong
GetEnd() const { return mnEnd
; }
273 class VCL_DLLPUBLIC CommandSwipeData
281 CommandSwipeData(double nVelocityX
)
282 : mnVelocityX(nVelocityX
)
285 double getVelocityX() const { return mnVelocityX
; }
289 class VCL_DLLPUBLIC CommandLongPressData
294 CommandLongPressData()
299 CommandLongPressData(double nX
, double nY
)
304 double getX() const { return mnX
; }
305 double getY() const { return mnY
; }
308 enum class CommandEventId
316 StartExtTextInput
= 7,
319 InputContextChange
= 10,
323 InputLanguageChange
= 15,
326 SelectionChange
= 18,
327 PrepareReconversion
= 19,
328 QueryCharPosition
= 20,
333 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */