Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / commandevent.hxx
blobfc6ba290793f4357f52c99a8337d64fa798b3b85
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <memory>
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 {
50 NONE = 0x0000,
51 GrayWaveline = 0x0010,
52 Underline = 0x0020,
53 BoldUnderline = 0x0040,
54 DottedUnderline = 0x0080,
55 DashDotUnderline = 0x0100,
56 DoubleUnderline = 0x0200,
57 Highlight = 0x0400,
58 RedText = 0x0800,
59 HalfToneText = 0x1000
61 namespace o3tl
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
72 private:
73 Point maPos;
74 void* mpData;
75 CommandEventId mnCommand;
76 bool mbMouseEvent;
78 public:
79 CommandEvent();
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
104 private:
105 OUString maText;
106 std::unique_ptr<ExtTextInputAttr[]> mpTextAttr;
107 sal_Int32 mnCursorPos;
108 sal_uInt16 mnCursorFlags;
109 bool mbOnlyCursor;
111 public:
112 CommandExtTextInputData( OUString aText,
113 const ExtTextInputAttr* pTextAttr,
114 sal_Int32 nCursorPos,
115 sal_uInt16 nCursorFlags,
116 bool bOnlyCursor );
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
135 NONE = 0,
136 SCROLL = 1,
137 ZOOM = 2,
138 DATAZOOM = 3
141 // Magic value used in mnLines field in CommandWheelData
142 #define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF))
144 class VCL_DLLPUBLIC CommandWheelData
146 private:
147 tools::Long mnDelta;
148 tools::Long mnNotchDelta;
149 double mnLines;
150 CommandWheelMode mnWheelMode;
151 sal_uInt16 mnCode;
152 bool mbHorz;
153 bool mbDeltaIsPixel;
155 public:
156 CommandWheelData();
157 CommandWheelData( tools::Long nWheelDelta, tools::Long nWheelNotchDelta,
158 double nScrollLines,
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)); }
172 bool IsShift() const
173 { return ((mnCode & KEY_SHIFT) != 0); }
174 bool IsMod1() const
175 { return ((mnCode & KEY_MOD1) != 0); }
176 bool IsMod2() const
177 { return ((mnCode & KEY_MOD2) != 0); }
180 class CommandScrollData
182 private:
183 tools::Long mnDeltaX;
184 tools::Long mnDeltaY;
186 public:
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
195 private:
196 bool mbDown;
197 ModKeyFlags mnCode;
199 public:
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
211 Preferences = 1,
212 About = 2,
215 class VCL_DLLPUBLIC CommandDialogData
217 ShowDialogId m_nDialogId;
218 public:
219 CommandDialogData( ShowDialogId nDialogId )
220 : m_nDialogId( nDialogId )
223 ShowDialogId GetDialogId() const { return m_nDialogId; }
226 // Media Commands
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;
255 public:
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
268 private:
269 sal_uLong mnStart;
270 sal_uLong mnEnd;
272 public:
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
281 double mnVelocityX;
282 public:
283 CommandGestureSwipeData()
284 : mnVelocityX(0)
287 CommandGestureSwipeData(double nVelocityX)
288 : mnVelocityX(nVelocityX)
291 double getVelocityX() const { return mnVelocityX; }
295 class VCL_DLLPUBLIC CommandGestureLongPressData
297 double mnX;
298 double mnY;
299 public:
300 CommandGestureLongPressData()
301 : mnX(0)
302 , mnY(0)
305 CommandGestureLongPressData(double nX, double nY)
306 : mnX(nX)
307 , mnY(nY)
310 double getX() const { return mnX; }
311 double getY() const { return mnY; }
314 class VCL_DLLPUBLIC CommandGesturePanData
316 public:
317 double const mfX;
318 double const mfY;
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)
325 : mfX(fX)
326 , mfY(fY)
327 , mfOffset(fOffset)
328 , meEventType(eEventType)
329 , meOrientation(eOrientation)
333 class VCL_DLLPUBLIC CommandGestureZoomData
335 public:
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)
342 : mfX(fX)
343 , mfY(fY)
344 , meEventType(eEventType)
345 , mfScaleDelta(fScale)
349 class VCL_DLLPUBLIC CommandGestureRotateData
351 public:
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,
358 double fAngleDelta)
359 : mfX(fX)
360 , mfY(fY)
361 , meEventType(eEventType)
362 , mfAngleDelta(fAngleDelta)
366 enum class CommandEventId
368 NONE = 0,
369 ContextMenu = 1,
370 StartDrag = 2,
371 Wheel = 3,
372 StartAutoScroll = 4,
373 AutoScroll = 5,
374 StartExtTextInput = 7,
375 ExtTextInput = 8,
376 EndExtTextInput = 9,
377 InputContextChange = 10,
378 CursorPos = 11,
379 PasteSelection = 12,
380 ModKeyChange = 13,
381 InputLanguageChange = 15,
382 ShowDialog = 16,
383 Media = 17,
384 SelectionChange = 18,
385 PrepareReconversion = 19,
386 QueryCharPosition = 20,
387 GestureSwipe = 21,
388 GestureLongPress = 22,
389 GesturePan = 23,
390 GestureZoom = 24,
391 GestureRotate = 25,
394 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */