Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / commandevent.hxx
blob778348b3d1a38bccb2c5b0570c7d8288be19fadd
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/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 {
43 NONE = 0x0000,
44 GrayWaveline = 0x0100,
45 Underline = 0x0200,
46 BoldUnderline = 0x0400,
47 DottedUnderline = 0x0800,
48 DashDotUnderline = 0x1000,
49 Highlight = 0x2000,
50 RedText = 0x4000,
51 HalfToneText = 0x8000
53 namespace o3tl
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
64 private:
65 Point maPos;
66 void* mpData;
67 CommandEventId mnCommand;
68 bool mbMouseEvent;
70 public:
71 CommandEvent();
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
93 private:
94 OUString maText;
95 std::unique_ptr<ExtTextInputAttr[]> mpTextAttr;
96 sal_Int32 mnCursorPos;
97 sal_uInt16 mnCursorFlags;
98 bool mbOnlyCursor;
100 public:
101 CommandExtTextInputData( const OUString& rText,
102 const ExtTextInputAttr* pTextAttr,
103 sal_Int32 nCursorPos,
104 sal_uInt16 nCursorFlags,
105 bool bOnlyCursor );
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
120 private:
121 LanguageType meLanguage;
123 public:
124 CommandInputContextData( LanguageType eLang );
127 enum class CommandWheelMode
129 NONE = 0,
130 SCROLL = 1,
131 ZOOM = 2,
132 DATAZOOM = 3
135 // Magic value used in mnLines field in CommandWheelData
136 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
138 class VCL_DLLPUBLIC CommandWheelData
140 private:
141 long mnDelta;
142 long mnNotchDelta;
143 double mnLines;
144 CommandWheelMode mnWheelMode;
145 sal_uInt16 mnCode;
146 bool mbHorz;
147 bool mbDeltaIsPixel;
149 public:
150 CommandWheelData();
151 CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
152 double nScrollLines,
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)); }
166 bool IsShift() const
167 { return ((mnCode & KEY_SHIFT) != 0); }
168 bool IsMod1() const
169 { return ((mnCode & KEY_MOD1) != 0); }
170 bool IsMod2() const
171 { return ((mnCode & KEY_MOD2) != 0); }
174 class VCL_DLLPUBLIC CommandScrollData
176 private:
177 long mnDeltaX;
178 long mnDeltaY;
180 public:
181 CommandScrollData( long nDeltaX, long nDeltaY );
183 long GetDeltaX() const { return mnDeltaX; }
184 long GetDeltaY() const { return mnDeltaY; }
187 class VCL_DLLPUBLIC CommandModKeyData
189 private:
190 bool mbDown;
191 ModKeyFlags mnCode;
193 public:
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
205 Preferences = 1,
206 About = 2,
209 class VCL_DLLPUBLIC CommandDialogData
211 ShowDialogId m_nDialogId;
212 public:
213 CommandDialogData( ShowDialogId nDialogId )
214 : m_nDialogId( nDialogId )
217 ShowDialogId GetDialogId() const { return m_nDialogId; }
220 // Media Commands
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;
249 public:
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
262 private:
263 sal_uLong mnStart;
264 sal_uLong mnEnd;
266 public:
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
275 double mnVelocityX;
276 public:
277 CommandSwipeData()
278 : mnVelocityX(0)
281 CommandSwipeData(double nVelocityX)
282 : mnVelocityX(nVelocityX)
285 double getVelocityX() const { return mnVelocityX; }
289 class VCL_DLLPUBLIC CommandLongPressData
291 double mnX;
292 double mnY;
293 public:
294 CommandLongPressData()
295 : mnX(0)
296 , mnY(0)
299 CommandLongPressData(double nX, double nY)
300 : mnX(nX)
301 , mnY(nY)
304 double getX() const { return mnX; }
305 double getY() const { return mnY; }
308 enum class CommandEventId
310 NONE = 0,
311 ContextMenu = 1,
312 StartDrag = 2,
313 Wheel = 3,
314 StartAutoScroll = 4,
315 AutoScroll = 5,
316 StartExtTextInput = 7,
317 ExtTextInput = 8,
318 EndExtTextInput = 9,
319 InputContextChange = 10,
320 CursorPos = 11,
321 PasteSelection = 12,
322 ModKeyChange = 13,
323 InputLanguageChange = 15,
324 ShowDialog = 16,
325 Media = 17,
326 SelectionChange = 18,
327 PrepareReconversion = 19,
328 QueryCharPosition = 20,
329 Swipe = 21,
330 LongPress = 22,
333 #endif // INCLUDED_VCL_COMMANDEVENT_HXX
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */