Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / cmdevt.hxx
blob9a7d65042f72b917674cb683f53835eb1a722da8
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_CMDEVT_HXX
21 #define INCLUDED_VCL_CMDEVT_HXX
23 #include <tools/gen.hxx>
24 #include <tools/solar.h>
25 #include <vcl/dllapi.h>
26 #include <vcl/keycod.hxx>
27 #include <vcl/font.hxx>
30 // - CommandExtTextInputData -
33 #define EXTTEXTINPUT_ATTR_GRAYWAVELINE ((sal_uInt16)0x0100)
34 #define EXTTEXTINPUT_ATTR_UNDERLINE ((sal_uInt16)0x0200)
35 #define EXTTEXTINPUT_ATTR_BOLDUNDERLINE ((sal_uInt16)0x0400)
36 #define EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE ((sal_uInt16)0x0800)
37 #define EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE ((sal_uInt16)0x1000)
38 #define EXTTEXTINPUT_ATTR_HIGHLIGHT ((sal_uInt16)0x2000)
39 #define EXTTEXTINPUT_ATTR_REDTEXT ((sal_uInt16)0x4000)
40 #define EXTTEXTINPUT_ATTR_HALFTONETEXT ((sal_uInt16)0x8000)
42 #define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001)
43 #define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002)
45 class VCL_DLLPUBLIC CommandExtTextInputData
47 private:
48 OUString maText;
49 sal_uInt16* mpTextAttr;
50 sal_Int32 mnCursorPos;
51 sal_uInt16 mnCursorFlags;
52 bool mbOnlyCursor;
54 public:
55 CommandExtTextInputData( const OUString& rText,
56 const sal_uInt16* pTextAttr,
57 sal_Int32 nCursorPos,
58 sal_uInt16 nCursorFlags,
59 bool bOnlyCursor );
60 CommandExtTextInputData( const CommandExtTextInputData& rData );
61 ~CommandExtTextInputData();
63 const OUString& GetText() const { return maText; }
64 const sal_uInt16* GetTextAttr() const { return mpTextAttr; }
65 sal_uInt16 GetCharTextAttr(sal_Int32 nIndex) const
67 assert(nIndex >= 0);
68 if (mpTextAttr && nIndex < maText.getLength() && nIndex >=0)
69 return mpTextAttr[nIndex];
70 else
71 return 0;
74 sal_Int32 GetCursorPos() const { return mnCursorPos; }
75 bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
76 bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; }
77 sal_uInt16 GetCursorFlags() const { return mnCursorFlags; }
78 bool IsOnlyCursorChanged() const { return mbOnlyCursor; }
82 // - CommandInputContextData -
85 class VCL_DLLPUBLIC CommandInputContextData
87 private:
88 LanguageType meLanguage;
90 public:
91 CommandInputContextData();
92 CommandInputContextData( LanguageType eLang );
94 LanguageType GetLanguage() const { return meLanguage; }
97 inline CommandInputContextData::CommandInputContextData()
99 meLanguage = LANGUAGE_DONTKNOW;
102 inline CommandInputContextData::CommandInputContextData( LanguageType eLang )
104 meLanguage = eLang;
108 // - CommandWheelData -
111 enum class CommandWheelMode
113 NONE = 0,
114 SCROLL = 1,
115 ZOOM = 2,
116 ZOOM_SCALE = 3,
117 DATAZOOM = 4
120 // Magic value used in mnLines field in CommandWheelData
121 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
123 class VCL_DLLPUBLIC CommandWheelData
125 private:
126 long mnDelta;
127 long mnNotchDelta;
128 sal_uLong mnLines;
129 CommandWheelMode mnWheelMode;
130 sal_uInt16 mnCode;
131 bool mbHorz;
132 bool mbDeltaIsPixel;
134 public:
135 CommandWheelData();
136 CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
137 sal_uLong nScrollLines,
138 CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
139 bool bHorz = false, bool bDeltaIsPixel = false );
141 long GetDelta() const { return mnDelta; }
142 long GetNotchDelta() const { return mnNotchDelta; }
143 sal_uLong GetScrollLines() const { return mnLines; }
144 bool IsHorz() const { return mbHorz; }
145 bool IsDeltaPixel() const { return mbDeltaIsPixel; }
147 CommandWheelMode GetMode() const { return mnWheelMode; }
149 sal_uInt16 GetModifier() const
150 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
151 bool IsShift() const
152 { return ((mnCode & KEY_SHIFT) != 0); }
153 bool IsMod1() const
154 { return ((mnCode & KEY_MOD1) != 0); }
155 bool IsMod2() const
156 { return ((mnCode & KEY_MOD2) != 0); }
157 bool IsMod3() const
158 { return ((mnCode & KEY_MOD3) != 0); }
161 inline CommandWheelData::CommandWheelData()
163 mnDelta = 0;
164 mnNotchDelta = 0;
165 mnLines = 0;
166 mnWheelMode = CommandWheelMode::NONE;
167 mnCode = 0;
168 mbHorz = false;
169 mbDeltaIsPixel = false;
172 inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
173 sal_uLong nScrollLines,
174 CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
175 bool bHorz, bool bDeltaIsPixel )
177 mnDelta = nWheelDelta;
178 mnNotchDelta = nWheelNotchDelta;
179 mnLines = nScrollLines;
180 mnWheelMode = nWheelMode;
181 mnCode = nKeyModifier;
182 mbHorz = bHorz;
183 mbDeltaIsPixel = bDeltaIsPixel;
187 // - CommandScrollData -
190 class VCL_DLLPUBLIC CommandScrollData
192 private:
193 long mnDeltaX;
194 long mnDeltaY;
196 public:
197 CommandScrollData();
198 CommandScrollData( long nDeltaX, long nDeltaY );
200 long GetDeltaX() const { return mnDeltaX; }
201 long GetDeltaY() const { return mnDeltaY; }
204 inline CommandScrollData::CommandScrollData()
206 mnDeltaX = 0;
207 mnDeltaY = 0;
210 inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
212 mnDeltaX = nDeltaX;
213 mnDeltaY = nDeltaY;
217 // - CommandModKeyData -
220 class VCL_DLLPUBLIC CommandModKeyData
222 private:
223 sal_uInt16 mnCode;
225 public:
226 CommandModKeyData();
227 CommandModKeyData( sal_uInt16 nCode );
229 bool IsShift() const { return (mnCode & MODKEY_SHIFT) != 0; }
230 bool IsMod1() const { return (mnCode & MODKEY_MOD1) != 0; }
231 bool IsMod2() const { return (mnCode & MODKEY_MOD2) != 0; }
232 bool IsMod3() const { return (mnCode & MODKEY_MOD3) != 0; }
234 bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) != 0; }
235 bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) != 0; }
236 bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) != 0; }
237 bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) != 0; }
239 bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) != 0; }
240 bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) != 0; }
241 bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) != 0; }
242 bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) != 0; }
245 inline CommandModKeyData::CommandModKeyData()
247 mnCode = 0L;
250 inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode )
252 mnCode = nCode;
256 // - CommandDialogData -
259 enum class ShowDialogId
261 Preferences = 1,
262 About = 2,
265 class VCL_DLLPUBLIC CommandDialogData
267 ShowDialogId m_nDialogId;
268 public:
269 CommandDialogData( ShowDialogId nDialogId = ShowDialogId::Preferences )
270 : m_nDialogId( nDialogId )
273 ShowDialogId GetDialogId() const { return m_nDialogId; }
276 // Media Commands
277 enum class MediaCommand
279 ChannelDown = 1, // Decrement the channel value, for example, for a TV or radio tuner.
280 ChannelUp = 2, // Increment the channel value, for example, for a TV or radio tuner.
281 NextTrack = 3, // Go to next media track/slide.
282 Pause = 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
283 Play = 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
284 PlayPause = 6, // Play or pause playback.
285 PreviousTrack = 7, // Go to previous media track/slide.
286 Record = 8, // Begin recording the current stream.
287 Rewind = 9,// Go backward in a stream at a higher rate of speed.
288 Stop = 10,// Stop playback.
289 MicOnOffToggle = 11,// Toggle the microphone.
290 MicrophoneVolumeDown = 12,// Increase microphone volume.
291 MicrophoneVolumeMute = 13,// Mute the microphone.
292 MicrophoneVolumeUp = 14,// Decrease microphone volume.
293 VolumeDown = 15,// Lower the volume.
294 VolumeMute = 16,// Mute the volume.
295 VolumeUp = 17,// Raise the volume.
296 Menu = 18,// Button Menu pressed.
297 MenuHold = 19,// Button Menu (long) pressed.
298 PlayHold = 20,// Button Play (long) pressed.
299 NextTrackHold = 21,// Button Right holding pressed.
300 PreviousTrackHold = 22,// Button Left holding pressed.
303 class VCL_DLLPUBLIC CommandMediaData
305 MediaCommand m_nMediaId;
306 bool m_bPassThroughToOS;
307 public:
308 CommandMediaData(MediaCommand nMediaId)
309 : m_nMediaId(nMediaId)
310 , m_bPassThroughToOS(true)
313 MediaCommand GetMediaId() const { return m_nMediaId; }
314 void SetPassThroughToOS(bool bPassThroughToOS) { m_bPassThroughToOS = bPassThroughToOS; }
315 bool GetPassThroughToOS() const { return m_bPassThroughToOS; }
318 // - CommandSelectionChangeData -
319 class VCL_DLLPUBLIC CommandSelectionChangeData
321 private:
322 sal_uLong mnStart;
323 sal_uLong mnEnd;
325 public:
326 CommandSelectionChangeData();
327 CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
329 sal_uLong GetStart() const { return mnStart; }
330 sal_uLong GetEnd() const { return mnEnd; }
333 inline CommandSelectionChangeData::CommandSelectionChangeData()
335 mnStart = mnEnd = 0;
338 inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart,
339 sal_uLong nEnd )
341 mnStart = nStart;
342 mnEnd = nEnd;
345 class VCL_DLLPUBLIC CommandSwipeData
347 double mnVelocityX;
348 double mnVelocityY;
349 public:
350 CommandSwipeData()
351 : mnVelocityX(0)
352 , mnVelocityY(0)
355 CommandSwipeData(double nVelocityX, double nVelocityY)
356 : mnVelocityX(nVelocityX)
357 , mnVelocityY(nVelocityY)
360 double getVelocityX() const { return mnVelocityX; }
361 double getVelocityY() const { return mnVelocityY; }
364 class VCL_DLLPUBLIC CommandLongPressData
366 double mnX;
367 double mnY;
368 public:
369 CommandLongPressData()
370 : mnX(0)
371 , mnY(0)
374 CommandLongPressData(double nX, double nY)
375 : mnX(nX)
376 , mnY(nY)
379 double getX() const { return mnX; }
380 double getY() const { return mnY; }
384 // - CommandEvent -
385 enum class CommandEventId
387 NONE = 0,
388 ContextMenu = 1,
389 StartDrag = 2,
390 Wheel = 3,
391 StartAutoScroll = 4,
392 AutoScroll = 5,
393 StartExtTextInput = 7,
394 ExtTextInput = 8,
395 EndExtTextInput = 9,
396 InputContextChange = 10,
397 CursorPos = 11,
398 PasteSelection = 12,
399 ModKeyChange = 13,
400 HangulHanjaConversion = 14,
401 InputLanguageChange = 15,
402 ShowDialog = 16,
403 Media = 17,
404 SelectionChange = 18,
405 PrepareReconversion = 19,
406 QueryCharPosition = 20,
407 Swipe = 21,
408 LongPress = 22,
411 class VCL_DLLPUBLIC CommandEvent
413 private:
414 Point maPos;
415 void* mpData;
416 CommandEventId mnCommand;
417 bool mbMouseEvent;
419 public:
420 CommandEvent();
421 CommandEvent( const Point& rMousePos, CommandEventId nCmd,
422 bool bMEvt = false, const void* pCmdData = NULL );
424 CommandEventId GetCommand() const { return mnCommand; }
425 const Point& GetMousePosPixel() const { return maPos; }
426 bool IsMouseEvent() const { return mbMouseEvent; }
427 void* GetEventData() const { return mpData; }
429 const CommandExtTextInputData* GetExtTextInputData() const;
430 const CommandInputContextData* GetInputContextChangeData() const;
431 const CommandWheelData* GetWheelData() const;
432 const CommandScrollData* GetAutoScrollData() const;
433 const CommandModKeyData* GetModKeyData() const;
434 const CommandDialogData* GetDialogData() const;
435 CommandMediaData* GetMediaData() const;
436 const CommandSelectionChangeData* GetSelectionChangeData() const;
437 const CommandSwipeData* GetSwipeData() const;
438 const CommandLongPressData* GetLongPressData() const;
441 inline CommandEvent::CommandEvent()
443 mpData = NULL;
444 mnCommand = CommandEventId::NONE;
445 mbMouseEvent = false;
448 inline CommandEvent::CommandEvent( const Point& rMousePos,
449 CommandEventId nCmd, bool bMEvt, const void* pCmdData ) :
450 maPos( rMousePos )
452 mpData = const_cast<void*>(pCmdData);
453 mnCommand = nCmd;
454 mbMouseEvent = bMEvt;
457 inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
459 if ( mnCommand == CommandEventId::ExtTextInput )
460 return static_cast<const CommandExtTextInputData*>(mpData);
461 else
462 return NULL;
465 inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const
467 if ( mnCommand == CommandEventId::InputContextChange )
468 return static_cast<const CommandInputContextData*>(mpData);
469 else
470 return NULL;
473 inline const CommandWheelData* CommandEvent::GetWheelData() const
475 if ( mnCommand == CommandEventId::Wheel )
476 return static_cast<const CommandWheelData*>(mpData);
477 else
478 return NULL;
481 inline const CommandScrollData* CommandEvent::GetAutoScrollData() const
483 if ( mnCommand == CommandEventId::AutoScroll )
484 return static_cast<const CommandScrollData*>(mpData);
485 else
486 return NULL;
489 inline const CommandModKeyData* CommandEvent::GetModKeyData() const
491 if( mnCommand == CommandEventId::ModKeyChange )
492 return static_cast<const CommandModKeyData*>(mpData);
493 else
494 return NULL;
497 inline const CommandDialogData* CommandEvent::GetDialogData() const
499 if( mnCommand == CommandEventId::ShowDialog )
500 return static_cast<const CommandDialogData*>(mpData);
501 else
502 return NULL;
505 inline CommandMediaData* CommandEvent::GetMediaData() const
507 if( mnCommand == CommandEventId::Media )
508 return static_cast<CommandMediaData*>(mpData);
509 else
510 return NULL;
513 inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
515 if( mnCommand == CommandEventId::SelectionChange )
516 return static_cast<const CommandSelectionChangeData*>(mpData);
517 else
518 return NULL;
521 inline const CommandSwipeData* CommandEvent::GetSwipeData() const
523 if( mnCommand == CommandEventId::Swipe )
524 return static_cast<const CommandSwipeData*>(mpData);
525 else
526 return NULL;
529 inline const CommandLongPressData* CommandEvent::GetLongPressData() const
531 if( mnCommand == CommandEventId::LongPress )
532 return static_cast<const CommandLongPressData*>(mpData);
533 else
534 return NULL;
537 #endif // INCLUDED_VCL_CMDEVT_HXX
539 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */