1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
49 sal_uInt16
* mpTextAttr
;
50 sal_Int32 mnCursorPos
;
51 sal_uInt16 mnCursorFlags
;
55 CommandExtTextInputData( const OUString
& rText
,
56 const sal_uInt16
* pTextAttr
,
58 sal_uInt16 nCursorFlags
,
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
68 if (mpTextAttr
&& nIndex
< maText
.getLength() && nIndex
>=0)
69 return mpTextAttr
[nIndex
];
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
88 LanguageType meLanguage
;
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
)
108 // - CommandWheelData -
111 enum class CommandWheelMode
120 // Magic value used in mnLines field in CommandWheelData
121 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
123 class VCL_DLLPUBLIC CommandWheelData
129 CommandWheelMode mnWheelMode
;
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
)); }
152 { return ((mnCode
& KEY_SHIFT
) != 0); }
154 { return ((mnCode
& KEY_MOD1
) != 0); }
156 { return ((mnCode
& KEY_MOD2
) != 0); }
158 { return ((mnCode
& KEY_MOD3
) != 0); }
161 inline CommandWheelData::CommandWheelData()
166 mnWheelMode
= CommandWheelMode::NONE
;
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
;
183 mbDeltaIsPixel
= bDeltaIsPixel
;
187 // - CommandScrollData -
190 class VCL_DLLPUBLIC CommandScrollData
198 CommandScrollData( long nDeltaX
, long nDeltaY
);
200 long GetDeltaX() const { return mnDeltaX
; }
201 long GetDeltaY() const { return mnDeltaY
; }
204 inline CommandScrollData::CommandScrollData()
210 inline CommandScrollData::CommandScrollData( long nDeltaX
, long nDeltaY
)
217 // - CommandModKeyData -
220 class VCL_DLLPUBLIC 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()
250 inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode
)
256 // - CommandDialogData -
259 enum class ShowDialogId
265 class VCL_DLLPUBLIC CommandDialogData
267 ShowDialogId m_nDialogId
;
269 CommandDialogData( ShowDialogId nDialogId
= ShowDialogId::Preferences
)
270 : m_nDialogId( nDialogId
)
273 ShowDialogId
GetDialogId() const { return m_nDialogId
; }
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
;
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
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()
338 inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart
,
345 class VCL_DLLPUBLIC CommandSwipeData
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
369 CommandLongPressData()
374 CommandLongPressData(double nX
, double nY
)
379 double getX() const { return mnX
; }
380 double getY() const { return mnY
; }
385 enum class CommandEventId
393 StartExtTextInput
= 7,
396 InputContextChange
= 10,
400 HangulHanjaConversion
= 14,
401 InputLanguageChange
= 15,
404 SelectionChange
= 18,
405 PrepareReconversion
= 19,
406 QueryCharPosition
= 20,
411 class VCL_DLLPUBLIC CommandEvent
416 CommandEventId mnCommand
;
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()
444 mnCommand
= CommandEventId::NONE
;
445 mbMouseEvent
= false;
448 inline CommandEvent::CommandEvent( const Point
& rMousePos
,
449 CommandEventId nCmd
, bool bMEvt
, const void* pCmdData
) :
452 mpData
= const_cast<void*>(pCmdData
);
454 mbMouseEvent
= bMEvt
;
457 inline const CommandExtTextInputData
* CommandEvent::GetExtTextInputData() const
459 if ( mnCommand
== CommandEventId::ExtTextInput
)
460 return static_cast<const CommandExtTextInputData
*>(mpData
);
465 inline const CommandInputContextData
* CommandEvent::GetInputContextChangeData() const
467 if ( mnCommand
== CommandEventId::InputContextChange
)
468 return static_cast<const CommandInputContextData
*>(mpData
);
473 inline const CommandWheelData
* CommandEvent::GetWheelData() const
475 if ( mnCommand
== CommandEventId::Wheel
)
476 return static_cast<const CommandWheelData
*>(mpData
);
481 inline const CommandScrollData
* CommandEvent::GetAutoScrollData() const
483 if ( mnCommand
== CommandEventId::AutoScroll
)
484 return static_cast<const CommandScrollData
*>(mpData
);
489 inline const CommandModKeyData
* CommandEvent::GetModKeyData() const
491 if( mnCommand
== CommandEventId::ModKeyChange
)
492 return static_cast<const CommandModKeyData
*>(mpData
);
497 inline const CommandDialogData
* CommandEvent::GetDialogData() const
499 if( mnCommand
== CommandEventId::ShowDialog
)
500 return static_cast<const CommandDialogData
*>(mpData
);
505 inline CommandMediaData
* CommandEvent::GetMediaData() const
507 if( mnCommand
== CommandEventId::Media
)
508 return static_cast<CommandMediaData
*>(mpData
);
513 inline const CommandSelectionChangeData
* CommandEvent::GetSelectionChangeData() const
515 if( mnCommand
== CommandEventId::SelectionChange
)
516 return static_cast<const CommandSelectionChangeData
*>(mpData
);
521 inline const CommandSwipeData
* CommandEvent::GetSwipeData() const
523 if( mnCommand
== CommandEventId::Swipe
)
524 return static_cast<const CommandSwipeData
*>(mpData
);
529 inline const CommandLongPressData
* CommandEvent::GetLongPressData() const
531 if( mnCommand
== CommandEventId::LongPress
)
532 return static_cast<const CommandLongPressData
*>(mpData
);
537 #endif // INCLUDED_VCL_CMDEVT_HXX
539 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */