update credits
[LibreOffice.git] / include / vcl / cmdevt.hxx
blob75714f2f531f9fa2e22fc29b89b7f545ae73ed33
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 _VCL_CMDEVT_HXX
21 #define _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>
29 // ---------------------------
30 // - CommandExtTextInputData -
31 // ---------------------------
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 XubString maText;
49 sal_uInt16* mpTextAttr;
50 xub_StrLen mnCursorPos;
51 xub_StrLen mnDeltaStart;
52 xub_StrLen mnOldTextLen;
53 sal_uInt16 mnCursorFlags;
54 sal_Bool mbOnlyCursor;
56 public:
57 CommandExtTextInputData( const XubString& rText,
58 const sal_uInt16* pTextAttr,
59 xub_StrLen nCursorPos,
60 sal_uInt16 nCursorFlags,
61 xub_StrLen nDeltaStart,
62 xub_StrLen nOldTextLen,
63 sal_Bool bOnlyCursor );
64 CommandExtTextInputData( const CommandExtTextInputData& rData );
65 ~CommandExtTextInputData();
67 const XubString& GetText() const { return maText; }
68 const sal_uInt16* GetTextAttr() const { return mpTextAttr; }
69 sal_uInt16 GetCharTextAttr( sal_uInt16 nIndex ) const;
70 xub_StrLen GetCursorPos() const { return mnCursorPos; }
71 sal_Bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
72 sal_Bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; }
73 sal_uInt16 GetCursorFlags() const { return mnCursorFlags; }
74 xub_StrLen GetDeltaStart() const { return mnDeltaStart; }
75 xub_StrLen GetOldTextLen() const { return mnOldTextLen; }
76 sal_Bool IsOnlyCursorChanged() const { return mbOnlyCursor; }
79 inline sal_uInt16 CommandExtTextInputData::GetCharTextAttr( sal_uInt16 nIndex ) const
81 if ( mpTextAttr && (nIndex < maText.Len()) )
82 return mpTextAttr[nIndex];
83 else
84 return 0;
87 // ---------------------------
88 // - CommandInputContextData -
89 // ---------------------------
91 class VCL_DLLPUBLIC CommandInputContextData
93 private:
94 LanguageType meLanguage;
96 public:
97 CommandInputContextData();
98 CommandInputContextData( LanguageType eLang );
100 LanguageType GetLanguage() const { return meLanguage; }
103 inline CommandInputContextData::CommandInputContextData()
105 meLanguage = LANGUAGE_DONTKNOW;
108 inline CommandInputContextData::CommandInputContextData( LanguageType eLang )
110 meLanguage = eLang;
113 // --------------------
114 // - CommandWheelData -
115 // --------------------
117 #define COMMAND_WHEEL_SCROLL ((sal_uInt16)0x0001)
118 #define COMMAND_WHEEL_ZOOM ((sal_uInt16)0x0002)
119 #define COMMAND_WHEEL_ZOOM_SCALE ((sal_uInt16)0x0003)
120 #define COMMAND_WHEEL_DATAZOOM ((sal_uInt16)0x0004)
122 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
124 class VCL_DLLPUBLIC CommandWheelData
126 private:
127 long mnDelta;
128 long mnNotchDelta;
129 sal_uLong mnLines;
130 sal_uInt16 mnMode;
131 sal_uInt16 mnCode;
132 sal_Bool mbHorz;
133 sal_Bool mbDeltaIsPixel;
135 public:
136 CommandWheelData();
137 CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
138 sal_uLong nScrollLines,
139 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
140 sal_Bool bHorz = sal_False, sal_Bool bDeltaIsPixel = sal_False );
142 long GetDelta() const { return mnDelta; }
143 long GetNotchDelta() const { return mnNotchDelta; }
144 sal_uLong GetScrollLines() const { return mnLines; }
145 sal_Bool IsHorz() const { return mbHorz; }
146 sal_Bool IsDeltaPixel() const { return mbDeltaIsPixel; }
148 sal_uInt16 GetMode() const { return mnMode; }
150 sal_uInt16 GetModifier() const
151 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
152 bool IsShift() const
153 { return ((mnCode & KEY_SHIFT) != 0); }
154 sal_Bool IsMod1() const
155 { return ((mnCode & KEY_MOD1) != 0); }
156 sal_Bool IsMod2() const
157 { return ((mnCode & KEY_MOD2) != 0); }
158 sal_Bool IsMod3() const
159 { return ((mnCode & KEY_MOD3) != 0); }
162 inline CommandWheelData::CommandWheelData()
164 mnDelta = 0;
165 mnNotchDelta = 0;
166 mnLines = 0;
167 mnMode = 0;
168 mnCode = 0;
169 mbHorz = sal_False;
170 mbDeltaIsPixel = sal_False;
173 inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
174 sal_uLong nScrollLines,
175 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
176 sal_Bool bHorz, sal_Bool bDeltaIsPixel )
178 mnDelta = nWheelDelta;
179 mnNotchDelta = nWheelNotchDelta;
180 mnLines = nScrollLines;
181 mnMode = nWheelMode;
182 mnCode = nKeyModifier;
183 mbHorz = bHorz;
184 mbDeltaIsPixel = bDeltaIsPixel;
187 // ---------------------
188 // - CommandScrollData -
189 // ---------------------
191 class VCL_DLLPUBLIC CommandScrollData
193 private:
194 long mnDeltaX;
195 long mnDeltaY;
197 public:
198 CommandScrollData();
199 CommandScrollData( long nDeltaX, long nDeltaY );
201 long GetDeltaX() const { return mnDeltaX; }
202 long GetDeltaY() const { return mnDeltaY; }
205 inline CommandScrollData::CommandScrollData()
207 mnDeltaX = 0;
208 mnDeltaY = 0;
211 inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
213 mnDeltaX = nDeltaX;
214 mnDeltaY = nDeltaY;
217 // ---------------------
218 // - CommandModKeyData -
219 // ---------------------
221 class VCL_DLLPUBLIC CommandModKeyData
223 private:
224 sal_uInt16 mnCode;
226 public:
227 CommandModKeyData();
228 CommandModKeyData( sal_uInt16 nCode );
230 bool IsShift() const { return (mnCode & MODKEY_SHIFT) ? true : false; }
231 sal_Bool IsMod1() const { return (mnCode & MODKEY_MOD1) ? sal_True : sal_False; }
232 sal_Bool IsMod2() const { return (mnCode & MODKEY_MOD2) ? sal_True : sal_False; }
233 sal_Bool IsMod3() const { return (mnCode & MODKEY_MOD3) ? sal_True : sal_False; }
235 sal_Bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) ? sal_True : sal_False; }
236 sal_Bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) ? sal_True : sal_False; }
237 sal_Bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) ? sal_True : sal_False; }
238 sal_Bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) ? sal_True : sal_False; }
240 sal_Bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) ? sal_True : sal_False; }
241 sal_Bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) ? sal_True : sal_False; }
242 sal_Bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) ? sal_True : sal_False; }
243 sal_Bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) ? sal_True : sal_False; }
246 inline CommandModKeyData::CommandModKeyData()
248 mnCode = 0L;
251 inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode )
253 mnCode = nCode;
256 // --------------------
257 // - CommanDialogData -
258 // --------------------
260 #define SHOWDIALOG_ID_PREFERENCES 1
261 #define SHOWDIALOG_ID_ABOUT 2
263 class VCL_DLLPUBLIC CommandDialogData
265 int m_nDialogId;
266 public:
267 CommandDialogData( int nDialogId = SHOWDIALOG_ID_PREFERENCES )
268 : m_nDialogId( nDialogId )
271 int GetDialogId() const { return m_nDialogId; }
274 // --------------
275 // Media Commands
276 // --------------
278 #define MEDIA_COMMAND_CHANNEL_DOWN ((sal_Int16)1) // Decrement the channel value, for example, for a TV or radio tuner.
279 #define MEDIA_COMMAND_CHANNEL_UP ((sal_Int16)2) // Increment the channel value, for example, for a TV or radio tuner.
280 #define MEDIA_COMMAND_NEXTTRACK ((sal_Int16)3) // Go to next media track/slide.
281 #define MEDIA_COMMAND_PAUSE ((sal_Int16)4) // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
282 #define MEDIA_COMMAND_PLAY ((sal_Int16)5) // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
283 #define MEDIA_COMMAND_PLAY_PAUSE ((sal_Int16)6) // Play or pause playback.
284 #define MEDIA_COMMAND_PREVIOUSTRACK ((sal_Int16)7) // Go to previous media track/slide.
285 #define MEDIA_COMMAND_RECORD ((sal_Int16)8) // Begin recording the current stream.
286 #define MEDIA_COMMAND_REWIND ((sal_Int16)9)// Go backward in a stream at a higher rate of speed.
287 #define MEDIA_COMMAND_STOP ((sal_Int16)10)// Stop playback.
288 #define MEDIA_COMMAND_MIC_ON_OFF_TOGGLE ((sal_Int16)11)// Toggle the microphone.
289 #define MEDIA_COMMAND_MICROPHONE_VOLUME_DOWN ((sal_Int16)12)// Increase microphone volume.
290 #define MEDIA_COMMAND_MICROPHONE_VOLUME_MUTE ((sal_Int16)13)// Mute the microphone.
291 #define MEDIA_COMMAND_MICROPHONE_VOLUME_UP ((sal_Int16)14)// Decrease microphone volume.
292 #define MEDIA_COMMAND_VOLUME_DOWN ((sal_Int16)15)// Lower the volume.
293 #define MEDIA_COMMAND_VOLUME_MUTE ((sal_Int16)16)// Mute the volume.
294 #define MEDIA_COMMAND_VOLUME_UP ((sal_Int16)17)// Raise the volume.
295 #define MEDIA_COMMAND_MENU ((sal_Int16)18)// Button Menu pressed.
296 #define MEDIA_COMMAND_MENU_HOLD ((sal_Int16)19)// Button Menu (long) pressed.
297 #define MEDIA_COMMAND_PLAY_HOLD ((sal_Int16)20)// Button Play (long) pressed.
298 #define MEDIA_COMMAND_NEXTTRACK_HOLD ((sal_Int16)21)// Button Right holding pressed.
299 #define MEDIA_COMMAND_PREVIOUSTRACK_HOLD ((sal_Int16)22)// Button Left holding pressed.
302 // ------------------------------
303 // - CommandSelectionChangeData -
304 // ------------------------------
306 class VCL_DLLPUBLIC CommandSelectionChangeData
308 private:
309 sal_uLong mnStart;
310 sal_uLong mnEnd;
312 public:
313 CommandSelectionChangeData();
314 CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
316 sal_uLong GetStart() const { return mnStart; }
317 sal_uLong GetEnd() const { return mnEnd; }
320 inline CommandSelectionChangeData::CommandSelectionChangeData()
322 mnStart = mnEnd = 0;
325 inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart,
326 sal_uLong nEnd )
328 mnStart = nStart;
329 mnEnd = nEnd;
332 // ----------------
333 // - CommandEvent -
334 // ----------------
336 #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
337 #define COMMAND_STARTDRAG ((sal_uInt16)2)
338 #define COMMAND_WHEEL ((sal_uInt16)3)
339 #define COMMAND_STARTAUTOSCROLL ((sal_uInt16)4)
340 #define COMMAND_AUTOSCROLL ((sal_uInt16)5)
341 #define COMMAND_STARTEXTTEXTINPUT ((sal_uInt16)7)
342 #define COMMAND_EXTTEXTINPUT ((sal_uInt16)8)
343 #define COMMAND_ENDEXTTEXTINPUT ((sal_uInt16)9)
344 #define COMMAND_INPUTCONTEXTCHANGE ((sal_uInt16)10)
345 #define COMMAND_CURSORPOS ((sal_uInt16)11)
346 #define COMMAND_PASTESELECTION ((sal_uInt16)12)
347 #define COMMAND_MODKEYCHANGE ((sal_uInt16)13)
348 #define COMMAND_HANGUL_HANJA_CONVERSION ((sal_uInt16)14)
349 #define COMMAND_INPUTLANGUAGECHANGE ((sal_uInt16)15)
350 #define COMMAND_SHOWDIALOG ((sal_uInt16)16)
351 #define COMMAND_MEDIA ((sal_uInt16)17)
352 #define COMMAND_SELECTIONCHANGE ((sal_uInt16)18)
353 #define COMMAND_PREPARERECONVERSION ((sal_uInt16)19)
354 #define COMMAND_QUERYCHARPOSITION ((sal_uInt16)20)
357 class VCL_DLLPUBLIC CommandEvent
359 private:
360 Point maPos;
361 void* mpData;
362 sal_uInt16 mnCommand;
363 sal_Bool mbMouseEvent;
365 public:
366 CommandEvent();
367 CommandEvent( const Point& rMousePos, sal_uInt16 nCmd,
368 sal_Bool bMEvt = sal_False, const void* pCmdData = NULL );
370 sal_uInt16 GetCommand() const { return mnCommand; }
371 const Point& GetMousePosPixel() const { return maPos; }
372 sal_Bool IsMouseEvent() const { return mbMouseEvent; }
373 void* GetData() const { return mpData; }
375 const CommandExtTextInputData* GetExtTextInputData() const;
376 const CommandInputContextData* GetInputContextChangeData() const;
377 const CommandWheelData* GetWheelData() const;
378 const CommandScrollData* GetAutoScrollData() const;
379 const CommandModKeyData* GetModKeyData() const;
380 const CommandDialogData* GetDialogData() const;
381 sal_Int16 GetMediaCommand() const;
382 const CommandSelectionChangeData* GetSelectionChangeData() const;
385 inline CommandEvent::CommandEvent()
387 mpData = NULL;
388 mnCommand = 0;
389 mbMouseEvent = sal_False;
392 inline CommandEvent::CommandEvent( const Point& rMousePos,
393 sal_uInt16 nCmd, sal_Bool bMEvt, const void* pCmdData ) :
394 maPos( rMousePos )
396 mpData = (void*)pCmdData;
397 mnCommand = nCmd;
398 mbMouseEvent = bMEvt;
401 inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
403 if ( mnCommand == COMMAND_EXTTEXTINPUT )
404 return (const CommandExtTextInputData*)mpData;
405 else
406 return NULL;
409 inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const
411 if ( mnCommand == COMMAND_INPUTCONTEXTCHANGE )
412 return (const CommandInputContextData*)mpData;
413 else
414 return NULL;
417 inline const CommandWheelData* CommandEvent::GetWheelData() const
419 if ( mnCommand == COMMAND_WHEEL )
420 return (const CommandWheelData*)mpData;
421 else
422 return NULL;
425 inline const CommandScrollData* CommandEvent::GetAutoScrollData() const
427 if ( mnCommand == COMMAND_AUTOSCROLL )
428 return (const CommandScrollData*)mpData;
429 else
430 return NULL;
433 inline const CommandModKeyData* CommandEvent::GetModKeyData() const
435 if( mnCommand == COMMAND_MODKEYCHANGE )
436 return (const CommandModKeyData*)mpData;
437 else
438 return NULL;
441 inline const CommandDialogData* CommandEvent::GetDialogData() const
443 if( mnCommand == COMMAND_SHOWDIALOG )
444 return (const CommandDialogData*)mpData;
445 else
446 return NULL;
449 inline sal_Int16 CommandEvent::GetMediaCommand() const
451 if( mnCommand == COMMAND_MEDIA )
452 return *(const sal_Int16*)(mpData);
453 else
454 return 0;
457 inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
459 if( mnCommand == COMMAND_SELECTIONCHANGE )
460 return (const CommandSelectionChangeData*)mpData;
461 else
462 return NULL;
466 #endif // _VCL_CMDEVT_HXX
468 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */