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>
28 #include <o3tl/typed_flags_set.hxx>
29 #include <rtl/ustring.hxx>
30 #include <vcl/GestureEvent.hxx>
31 
33 class CommandWheelData;
34 class CommandScrollData;
35 class CommandModKeyData;
36 class CommandDialogData;
37 class CommandMediaData;
39 class CommandSwipeData;
41 class CommandGestureData;
42 
43 enum class CommandEventId;
44 
45 enum class ExtTextInputAttr {
46  NONE = 0x0000,
47  GrayWaveline = 0x0100,
48  Underline = 0x0200,
49  BoldUnderline = 0x0400,
50  DottedUnderline = 0x0800,
51  DashDotUnderline = 0x1000,
52  Highlight = 0x2000,
53  RedText = 0x4000,
54  HalfToneText = 0x8000
55 };
56 namespace o3tl
57 {
58  template<> struct typed_flags<ExtTextInputAttr> : is_typed_flags<ExtTextInputAttr, 0xff00> {};
59 }
60 
61 #define EXTTEXTINPUT_CURSOR_INVISIBLE (sal_uInt16(0x0001))
62 #define EXTTEXTINPUT_CURSOR_OVERWRITE (sal_uInt16(0x0002))
63 
64 
66 {
67 private:
69  void* mpData;
72 
73 public:
74  CommandEvent();
75  CommandEvent( const Point& rMousePos, CommandEventId nCmd,
76  bool bMEvt = false, const void* pCmdData = nullptr );
77 
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; }
82 
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;
93 };
94 
96 {
97 private:
98  OUString const maText;
99  std::unique_ptr<ExtTextInputAttr[]> mpTextAttr;
100  sal_Int32 mnCursorPos;
101  sal_uInt16 mnCursorFlags;
103 
104 public:
105  CommandExtTextInputData( const OUString& rText,
106  const ExtTextInputAttr* pTextAttr,
107  sal_Int32 nCursorPos,
108  sal_uInt16 nCursorFlags,
109  bool bOnlyCursor );
112 
113  const OUString& GetText() const { return maText; }
114  const ExtTextInputAttr* GetTextAttr() const { return mpTextAttr.get(); }
115 
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; }
120 };
121 
123 {
124 };
125 
127 {
128  NONE = 0,
129  SCROLL = 1,
130  ZOOM = 2,
131  DATAZOOM = 3
132 };
133 
134 // Magic value used in mnLines field in CommandWheelData
135 #define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF))
136 
138 {
139 private:
140  long mnDelta;
142  double mnLines;
144  sal_uInt16 mnCode;
145  bool mbHorz;
147 
148 public:
150  CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
151  double nScrollLines,
152  CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
153  bool bHorz, bool bDeltaIsPixel = false );
154 
155  long GetDelta() const { return mnDelta; }
156  long GetNotchDelta() const { return mnNotchDelta; }
157  double GetScrollLines() const { return mnLines; }
158  bool IsHorz() const { return mbHorz; }
159  bool IsDeltaPixel() const { return mbDeltaIsPixel; }
160 
161  CommandWheelMode GetMode() const { return mnWheelMode; }
162 
163  sal_uInt16 GetModifier() const
164  { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
165  bool IsShift() const
166  { return ((mnCode & KEY_SHIFT) != 0); }
167  bool IsMod1() const
168  { return ((mnCode & KEY_MOD1) != 0); }
169  bool IsMod2() const
170  { return ((mnCode & KEY_MOD2) != 0); }
171 };
172 
174 {
175 private:
176  long mnDeltaX;
177  long mnDeltaY;
178 
179 public:
180  CommandScrollData( long nDeltaX, long nDeltaY );
181 
182  long GetDeltaX() const { return mnDeltaX; }
183  long GetDeltaY() const { return mnDeltaY; }
184 };
185 
187 {
188 private:
189  bool mbDown;
191 
192 public:
193  CommandModKeyData( ModKeyFlags nCode, bool bDown );
194 
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); }
200 };
201 
202 enum class ShowDialogId
203 {
204  Preferences = 1,
205  About = 2,
206 };
207 
209 {
211 public:
213  : m_nDialogId( nDialogId )
214  {}
215 
216  ShowDialogId GetDialogId() const { return m_nDialogId; }
217 };
218 
219 // Media Commands
220 enum class MediaCommand
221 {
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.
242 };
243 
245 {
248 public:
250  : m_nMediaId(nMediaId)
251  , m_bPassThroughToOS(true)
252  {
253  }
254  MediaCommand GetMediaId() const { return m_nMediaId; }
255  void SetPassThroughToOS(bool bPassThroughToOS) { m_bPassThroughToOS = bPassThroughToOS; }
256  bool GetPassThroughToOS() const { return m_bPassThroughToOS; }
257 };
258 
260 {
261 private:
264 
265 public:
267 
268  sal_uLong GetStart() const { return mnStart; }
269  sal_uLong GetEnd() const { return mnEnd; }
270 };
271 
273 {
274  double const mnVelocityX;
275 public:
277  : mnVelocityX(0)
278  {
279  }
280  CommandSwipeData(double nVelocityX)
281  : mnVelocityX(nVelocityX)
282  {
283  }
284  double getVelocityX() const { return mnVelocityX; }
285 };
286 
287 
289 {
290  double const mnX;
291  double const mnY;
292 public:
294  : mnX(0)
295  , mnY(0)
296  {
297  }
298  CommandLongPressData(double nX, double nY)
299  : mnX(nX)
300  , mnY(nY)
301  {
302  }
303  double getX() const { return mnX; }
304  double getY() const { return mnY; }
305 };
306 
308 {
309 public:
310  double const mfX;
311  double const mfY;
313 
314  double const mfOffset;
316 
317  CommandGestureData(double fX, double fY, GestureEventType eEventType, double fOffset, PanningOrientation eOrientation)
318  : mfX(fX)
319  , mfY(fY)
320  , meEventType(eEventType)
321  , mfOffset(fOffset)
322  , meOrientation(eOrientation)
323  {}
324 };
325 
326 enum class CommandEventId
327 {
328  NONE = 0,
329  ContextMenu = 1,
330  StartDrag = 2,
331  Wheel = 3,
332  StartAutoScroll = 4,
333  AutoScroll = 5,
334  StartExtTextInput = 7,
335  ExtTextInput = 8,
336  EndExtTextInput = 9,
337  InputContextChange = 10,
338  CursorPos = 11,
339  PasteSelection = 12,
340  ModKeyChange = 13,
341  InputLanguageChange = 15,
342  ShowDialog = 16,
343  Media = 17,
344  SelectionChange = 18,
345  PrepareReconversion = 19,
346  QueryCharPosition = 20,
347  Swipe = 21,
348  LongPress = 22,
349  Gesture = 23,
350 };
351 
352 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
353 
354 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uLong GetEnd() const
bool IsMod1() const
bool IsMod2() const
CommandEventId
void SetPassThroughToOS(bool bPassThroughToOS)
bool IsMod1() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
PanningOrientation const meOrientation
#define EXTTEXTINPUT_CURSOR_INVISIBLE
sal_uIntPtr sal_uLong
#define KEY_SHIFT
Definition: keycodes.hxx:30
CommandMediaData(MediaCommand nMediaId)
ModKeyFlags mnCode
#define KEY_MOD1
Definition: keycodes.hxx:31
bool IsShift() const
ModKeyFlags
Definition: keycodes.hxx:163
long GetNotchDelta() const
bool IsDown() const
CommandSelectionChangeData(sal_uLong nStart, sal_uLong nEnd)
#define EXTTEXTINPUT_CURSOR_OVERWRITE
GestureEventType const meEventType
bool IsHorz() const
CommandEventId mnCommand
long GetDeltaY() const
bool IsOnlyCursorChanged() const
MediaCommand GetMediaId() const
#define KEY_MOD2
Definition: keycodes.hxx:32
ShowDialogId const m_nDialogId
bool IsMouseEvent() const
MediaCommand
sal_uLong GetStart() const
bool IsRightShift() const
void * GetEventData() const
bool IsCursorOverwrite() const
CommandModKeyData(ModKeyFlags nCode, bool bDown)
CommandGestureData(double fX, double fY, GestureEventType eEventType, double fOffset, PanningOrientation eOrientation)
bool IsDeltaPixel() const
CommandWheelMode
double GetScrollLines() const
const OUString & GetText() const
long GetDeltaX() const
double getX() const
std::unique_ptr< ExtTextInputAttr[]> mpTextAttr
bool IsMod2() const
CommandWheelMode GetMode() const
CommandWheelMode mnWheelMode
CommandSwipeData(double nVelocityX)
CommandEventId GetCommand() const
sal_uInt16 GetModifier() const
double const mfOffset
MediaCommand const m_nMediaId
CommandLongPressData(double nX, double nY)
GestureEventType
CommandScrollData(long nDeltaX, long nDeltaY)
const Point & GetMousePosPixel() const
ShowDialogId
Definition: menu.hxx:121
double const mnVelocityX
bool IsCursorVisible() const
long GetDelta() const
PanningOrientation
sal_Int32 GetCursorPos() const
bool GetPassThroughToOS() const
ShowDialogId GetDialogId() const
double getY() const
ExtTextInputAttr
bool IsLeftShift() const
CommandDialogData(ShowDialogId nDialogId)
double getVelocityX() const
const ExtTextInputAttr * GetTextAttr() const