LibreOffice Module vcl (master) 1
commandevent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_COMMANDEVENT_HXX
21#define INCLUDED_VCL_COMMANDEVENT_HXX
22
23#include <memory>
24#include <tools/gen.hxx>
25#include <tools/solar.h>
26#include <vcl/dllapi.h>
27#include <vcl/keycodes.hxx>
29#include <rtl/ustring.hxx>
33
46
47enum class CommandEventId;
48
49enum class ExtTextInputAttr {
50 NONE = 0x0000,
51 GrayWaveline = 0x0100,
52 Underline = 0x0200,
53 BoldUnderline = 0x0400,
54 DottedUnderline = 0x0800,
55 DashDotUnderline = 0x1000,
56 Highlight = 0x2000,
57 RedText = 0x4000,
58 HalfToneText = 0x8000
59};
60namespace o3tl
61{
62 template<> struct typed_flags<ExtTextInputAttr> : is_typed_flags<ExtTextInputAttr, 0xff00> {};
63}
64
65#define EXTTEXTINPUT_CURSOR_INVISIBLE (sal_uInt16(0x0001))
66#define EXTTEXTINPUT_CURSOR_OVERWRITE (sal_uInt16(0x0002))
67
68
70{
71private:
73 void* mpData;
76
77public:
79 CommandEvent( const Point& rMousePos, CommandEventId nCmd,
80 bool bMEvt = false, const void* pCmdData = nullptr );
81
83 const Point& GetMousePosPixel() const { return maPos; }
84 bool IsMouseEvent() const { return mbMouseEvent; }
85 void* GetEventData() const { return mpData; }
86
87 const CommandExtTextInputData* GetExtTextInputData() const;
88 const CommandWheelData* GetWheelData() const;
89 const CommandScrollData* GetAutoScrollData() const;
90 const CommandModKeyData* GetModKeyData() const;
91 const CommandDialogData* GetDialogData() const;
92 CommandMediaData* GetMediaData() const;
93 const CommandSelectionChangeData* GetSelectionChangeData() const;
94 const CommandGestureSwipeData* GetGestureSwipeData() const;
95 const CommandGestureLongPressData* GetLongPressData() const;
96 const CommandGesturePanData* GetGesturePanData() const;
97 const CommandGestureZoomData* GetGestureZoomData() const;
98 const CommandGestureRotateData* GetGestureRotateData() const;
99};
100
102{
103private:
104 OUString maText;
105 std::unique_ptr<ExtTextInputAttr[]> mpTextAttr;
106 sal_Int32 mnCursorPos;
107 sal_uInt16 mnCursorFlags;
109
110public:
111 CommandExtTextInputData( OUString aText,
112 const ExtTextInputAttr* pTextAttr,
113 sal_Int32 nCursorPos,
114 sal_uInt16 nCursorFlags,
115 bool bOnlyCursor );
118
119 const OUString& GetText() const { return maText; }
120 const ExtTextInputAttr* GetTextAttr() const { return mpTextAttr.get(); }
121
122 sal_Int32 GetCursorPos() const { return mnCursorPos; }
123 bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
124 bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; }
125 bool IsOnlyCursorChanged() const { return mbOnlyCursor; }
126};
127
129{
130};
131
133{
134 NONE = 0,
135 SCROLL = 1,
136 ZOOM = 2,
137 DATAZOOM = 3
138};
139
140// Magic value used in mnLines field in CommandWheelData
141#define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF))
142
144{
145private:
148 double mnLines;
150 sal_uInt16 mnCode;
151 bool mbHorz;
153
154public:
156 CommandWheelData( tools::Long nWheelDelta, tools::Long nWheelNotchDelta,
157 double nScrollLines,
158 CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
159 bool bHorz, bool bDeltaIsPixel = false );
160
161 tools::Long GetDelta() const { return mnDelta; }
162 tools::Long GetNotchDelta() const { return mnNotchDelta; }
163 double GetScrollLines() const { return mnLines; }
164 bool IsHorz() const { return mbHorz; }
165 bool IsDeltaPixel() const { return mbDeltaIsPixel; }
166
167 CommandWheelMode GetMode() const { return mnWheelMode; }
168
169 sal_uInt16 GetModifier() const
170 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
171 bool IsShift() const
172 { return ((mnCode & KEY_SHIFT) != 0); }
173 bool IsMod1() const
174 { return ((mnCode & KEY_MOD1) != 0); }
175 bool IsMod2() const
176 { return ((mnCode & KEY_MOD2) != 0); }
177};
178
180{
181private:
184
185public:
186 CommandScrollData( tools::Long nDeltaX, tools::Long nDeltaY );
187
188 tools::Long GetDeltaX() const { return mnDeltaX; }
189 tools::Long GetDeltaY() const { return mnDeltaY; }
190};
191
193{
194private:
195 bool mbDown;
197
198public:
199 CommandModKeyData( ModKeyFlags nCode, bool bDown );
200
201 bool IsDown() const { return mbDown; }
202 bool IsMod1() const { return bool(mnCode & ModKeyFlags::Mod1Msk); }
203 bool IsMod2() const { return bool(mnCode & ModKeyFlags::Mod2Msk); }
204 bool IsLeftShift() const { return bool(mnCode & ModKeyFlags::LeftShift); }
205 bool IsRightShift() const { return bool(mnCode & ModKeyFlags::RightShift); }
206};
207
208enum class ShowDialogId
209{
210 Preferences = 1,
211 About = 2,
212};
213
215{
217public:
219 : m_nDialogId( nDialogId )
220 {}
221
222 ShowDialogId GetDialogId() const { return m_nDialogId; }
223};
224
225// Media Commands
226enum class MediaCommand
227{
228 ChannelDown = 1, // Decrement the channel value, for example, for a TV or radio tuner.
229 ChannelUp = 2, // Increment the channel value, for example, for a TV or radio tuner.
230 NextTrack = 3, // Go to next media track/slide.
231 Pause = 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
232 Play = 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
233 PlayPause = 6, // Play or pause playback.
234 PreviousTrack = 7, // Go to previous media track/slide.
235 Record = 8, // Begin recording the current stream.
236 Rewind = 9,// Go backward in a stream at a higher rate of speed.
237 Stop = 10,// Stop playback.
238 MicOnOffToggle = 11,// Toggle the microphone.
239 MicrophoneVolumeDown = 12,// Increase microphone volume.
240 MicrophoneVolumeMute = 13,// Mute the microphone.
241 MicrophoneVolumeUp = 14,// Decrease microphone volume.
242 VolumeDown = 15,// Lower the volume.
243 VolumeMute = 16,// Mute the volume.
244 VolumeUp = 17,// Raise the volume.
245 Menu = 18,// Button Menu pressed.
246 PlayHold = 20,// Button Play (long) pressed.
247 NextTrackHold = 21,// Button Right holding pressed.
248};
249
251{
254public:
256 : m_nMediaId(nMediaId)
257 , m_bPassThroughToOS(true)
258 {
259 }
260 MediaCommand GetMediaId() const { return m_nMediaId; }
261 void SetPassThroughToOS(bool bPassThroughToOS) { m_bPassThroughToOS = bPassThroughToOS; }
262 bool GetPassThroughToOS() const { return m_bPassThroughToOS; }
263};
264
266{
267private:
270
271public:
273
274 sal_uLong GetStart() const { return mnStart; }
275 sal_uLong GetEnd() const { return mnEnd; }
276};
277
279{
281public:
283 : mnVelocityX(0)
284 {
285 }
286 CommandGestureSwipeData(double nVelocityX)
287 : mnVelocityX(nVelocityX)
288 {
289 }
290 double getVelocityX() const { return mnVelocityX; }
291};
292
293
295{
296 double mnX;
297 double mnY;
298public:
300 : mnX(0)
301 , mnY(0)
302 {
303 }
304 CommandGestureLongPressData(double nX, double nY)
305 : mnX(nX)
306 , mnY(nY)
307 {
308 }
309 double getX() const { return mnX; }
310 double getY() const { return mnY; }
311};
312
314{
315public:
316 double const mfX;
317 double const mfY;
318 double const mfOffset;
321
322 CommandGesturePanData(double fX, double fY, GestureEventPanType eEventType, double fOffset,
323 PanningOrientation eOrientation)
324 : mfX(fX)
325 , mfY(fY)
326 , mfOffset(fOffset)
327 , meEventType(eEventType)
328 , meOrientation(eOrientation)
329 {}
330};
331
333{
334public:
335 const double mfX = 0;
336 const double mfY = 0;
338 const double mfScaleDelta = 0;
339
340 CommandGestureZoomData(double fX, double fY, GestureEventZoomType eEventType, double fScale)
341 : mfX(fX)
342 , mfY(fY)
343 , meEventType(eEventType)
344 , mfScaleDelta(fScale)
345 {}
346};
347
349{
350public:
351 const double mfX = 0;
352 const double mfY = 0;
354 const double mfAngleDelta = 0;
355
356 CommandGestureRotateData(double fX, double fY, GestureEventRotateType eEventType,
357 double fAngleDelta)
358 : mfX(fX)
359 , mfY(fY)
360 , meEventType(eEventType)
361 , mfAngleDelta(fAngleDelta)
362 {}
363};
364
366{
367 NONE = 0,
368 ContextMenu = 1,
369 StartDrag = 2,
370 Wheel = 3,
371 StartAutoScroll = 4,
372 AutoScroll = 5,
374 ExtTextInput = 8,
375 EndExtTextInput = 9,
377 CursorPos = 11,
378 PasteSelection = 12,
379 ModKeyChange = 13,
381 ShowDialog = 16,
382 Media = 17,
383 SelectionChange = 18,
386 GestureSwipe = 21,
387 GestureLongPress = 22,
388 GesturePan = 23,
389 GestureZoom = 24,
390 GestureRotate = 25,
391};
392
393#endif // INCLUDED_VCL_COMMANDEVENT_HXX
394
395/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GestureEventPanType
PanningOrientation
GestureEventRotateType
GestureEventZoomType
Text maText
sal_Int16 mnCommand
ShowDialogId m_nDialogId
CommandDialogData(ShowDialogId nDialogId)
ShowDialogId GetDialogId() const
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
CommandEventId mnCommand
void * GetEventData() const
bool IsMouseEvent() const
sal_Int32 GetCursorPos() const
std::unique_ptr< ExtTextInputAttr[]> mpTextAttr
bool IsOnlyCursorChanged() const
const OUString & GetText() const
bool IsCursorOverwrite() const
const ExtTextInputAttr * GetTextAttr() const
bool IsCursorVisible() const
CommandGestureLongPressData(double nX, double nY)
PanningOrientation const meOrientation
CommandGesturePanData(double fX, double fY, GestureEventPanType eEventType, double fOffset, PanningOrientation eOrientation)
GestureEventPanType const meEventType
CommandGestureRotateData(double fX, double fY, GestureEventRotateType eEventType, double fAngleDelta)
double getVelocityX() const
CommandGestureSwipeData(double nVelocityX)
CommandGestureZoomData(double fX, double fY, GestureEventZoomType eEventType, double fScale)
MediaCommand GetMediaId() const
bool GetPassThroughToOS() const
MediaCommand m_nMediaId
CommandMediaData(MediaCommand nMediaId)
void SetPassThroughToOS(bool bPassThroughToOS)
bool IsRightShift() const
bool IsDown() const
bool IsMod2() const
bool IsMod1() const
ModKeyFlags mnCode
bool IsLeftShift() const
CommandModKeyData(ModKeyFlags nCode, bool bDown)
tools::Long GetDeltaX() const
CommandScrollData(tools::Long nDeltaX, tools::Long nDeltaY)
tools::Long GetDeltaY() const
tools::Long mnDeltaX
tools::Long mnDeltaY
sal_uLong GetStart() const
CommandSelectionChangeData(sal_uLong nStart, sal_uLong nEnd)
sal_uLong GetEnd() const
sal_uInt16 GetModifier() const
bool IsShift() const
tools::Long mnNotchDelta
tools::Long GetNotchDelta() const
tools::Long GetDelta() const
double GetScrollLines() const
CommandWheelMode mnWheelMode
bool IsMod2() const
bool IsDeltaPixel() const
tools::Long mnDelta
bool IsMod1() const
bool IsHorz() const
CommandWheelMode GetMode() const
Definition: menu.hxx:116
ExtTextInputAttr
#define EXTTEXTINPUT_CURSOR_OVERWRITE
MediaCommand
#define EXTTEXTINPUT_CURSOR_INVISIBLE
ShowDialogId
CommandWheelMode
CommandEventId
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
aCursorMoveIdle Stop()
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
constexpr sal_uInt16 KEY_MOD1
Definition: keycodes.hxx:31
ModKeyFlags
Definition: keycodes.hxx:165
constexpr sal_uInt16 KEY_SHIFT
Definition: keycodes.hxx:30
NONE
long Long
double mfY
double mfX
@ EndExtTextInput
@ InputContextChange
@ InputLanguageChange
@ GestureLongPress
@ QueryCharPosition
sal_uIntPtr sal_uLong