Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / vcl / cmdevt.hxx
blob95fbaa6db0ea09b5c3d90e9588b84264fa3698e6
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 #define COMMAND_WHEEL_SCROLL ((sal_uInt16)0x0001)
112 #define COMMAND_WHEEL_ZOOM ((sal_uInt16)0x0002)
113 #define COMMAND_WHEEL_ZOOM_SCALE ((sal_uInt16)0x0003)
114 #define COMMAND_WHEEL_DATAZOOM ((sal_uInt16)0x0004)
116 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
118 class VCL_DLLPUBLIC CommandWheelData
120 private:
121 long mnDelta;
122 long mnNotchDelta;
123 sal_uLong mnLines;
124 sal_uInt16 mnMode;
125 sal_uInt16 mnCode;
126 bool mbHorz;
127 bool mbDeltaIsPixel;
129 public:
130 CommandWheelData();
131 CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
132 sal_uLong nScrollLines,
133 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
134 bool bHorz = false, bool bDeltaIsPixel = false );
136 long GetDelta() const { return mnDelta; }
137 long GetNotchDelta() const { return mnNotchDelta; }
138 sal_uLong GetScrollLines() const { return mnLines; }
139 bool IsHorz() const { return mbHorz; }
140 bool IsDeltaPixel() const { return mbDeltaIsPixel; }
142 sal_uInt16 GetMode() const { return mnMode; }
144 sal_uInt16 GetModifier() const
145 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
146 bool IsShift() const
147 { return ((mnCode & KEY_SHIFT) != 0); }
148 bool IsMod1() const
149 { return ((mnCode & KEY_MOD1) != 0); }
150 bool IsMod2() const
151 { return ((mnCode & KEY_MOD2) != 0); }
152 bool IsMod3() const
153 { return ((mnCode & KEY_MOD3) != 0); }
156 inline CommandWheelData::CommandWheelData()
158 mnDelta = 0;
159 mnNotchDelta = 0;
160 mnLines = 0;
161 mnMode = 0;
162 mnCode = 0;
163 mbHorz = false;
164 mbDeltaIsPixel = false;
167 inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
168 sal_uLong nScrollLines,
169 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
170 bool bHorz, bool bDeltaIsPixel )
172 mnDelta = nWheelDelta;
173 mnNotchDelta = nWheelNotchDelta;
174 mnLines = nScrollLines;
175 mnMode = nWheelMode;
176 mnCode = nKeyModifier;
177 mbHorz = bHorz;
178 mbDeltaIsPixel = bDeltaIsPixel;
182 // - CommandScrollData -
185 class VCL_DLLPUBLIC CommandScrollData
187 private:
188 long mnDeltaX;
189 long mnDeltaY;
191 public:
192 CommandScrollData();
193 CommandScrollData( long nDeltaX, long nDeltaY );
195 long GetDeltaX() const { return mnDeltaX; }
196 long GetDeltaY() const { return mnDeltaY; }
199 inline CommandScrollData::CommandScrollData()
201 mnDeltaX = 0;
202 mnDeltaY = 0;
205 inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
207 mnDeltaX = nDeltaX;
208 mnDeltaY = nDeltaY;
212 // - CommandModKeyData -
215 class VCL_DLLPUBLIC CommandModKeyData
217 private:
218 sal_uInt16 mnCode;
220 public:
221 CommandModKeyData();
222 CommandModKeyData( sal_uInt16 nCode );
224 bool IsShift() const { return (mnCode & MODKEY_SHIFT) != 0; }
225 bool IsMod1() const { return (mnCode & MODKEY_MOD1) != 0; }
226 bool IsMod2() const { return (mnCode & MODKEY_MOD2) != 0; }
227 bool IsMod3() const { return (mnCode & MODKEY_MOD3) != 0; }
229 bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) != 0; }
230 bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) != 0; }
231 bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) != 0; }
232 bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) != 0; }
234 bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) != 0; }
235 bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) != 0; }
236 bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) != 0; }
237 bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) != 0; }
240 inline CommandModKeyData::CommandModKeyData()
242 mnCode = 0L;
245 inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode )
247 mnCode = nCode;
251 // - CommanDialogData -
254 #define SHOWDIALOG_ID_PREFERENCES 1
255 #define SHOWDIALOG_ID_ABOUT 2
257 class VCL_DLLPUBLIC CommandDialogData
259 int m_nDialogId;
260 public:
261 CommandDialogData( int nDialogId = SHOWDIALOG_ID_PREFERENCES )
262 : m_nDialogId( nDialogId )
265 int GetDialogId() const { return m_nDialogId; }
269 // Media Commands
272 #define MEDIA_COMMAND_CHANNEL_DOWN ((sal_Int16)1) // Decrement the channel value, for example, for a TV or radio tuner.
273 #define MEDIA_COMMAND_CHANNEL_UP ((sal_Int16)2) // Increment the channel value, for example, for a TV or radio tuner.
274 #define MEDIA_COMMAND_NEXTTRACK ((sal_Int16)3) // Go to next media track/slide.
275 #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.
276 #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.
277 #define MEDIA_COMMAND_PLAY_PAUSE ((sal_Int16)6) // Play or pause playback.
278 #define MEDIA_COMMAND_PREVIOUSTRACK ((sal_Int16)7) // Go to previous media track/slide.
279 #define MEDIA_COMMAND_RECORD ((sal_Int16)8) // Begin recording the current stream.
280 #define MEDIA_COMMAND_REWIND ((sal_Int16)9)// Go backward in a stream at a higher rate of speed.
281 #define MEDIA_COMMAND_STOP ((sal_Int16)10)// Stop playback.
282 #define MEDIA_COMMAND_MIC_ON_OFF_TOGGLE ((sal_Int16)11)// Toggle the microphone.
283 #define MEDIA_COMMAND_MICROPHONE_VOLUME_DOWN ((sal_Int16)12)// Increase microphone volume.
284 #define MEDIA_COMMAND_MICROPHONE_VOLUME_MUTE ((sal_Int16)13)// Mute the microphone.
285 #define MEDIA_COMMAND_MICROPHONE_VOLUME_UP ((sal_Int16)14)// Decrease microphone volume.
286 #define MEDIA_COMMAND_VOLUME_DOWN ((sal_Int16)15)// Lower the volume.
287 #define MEDIA_COMMAND_VOLUME_MUTE ((sal_Int16)16)// Mute the volume.
288 #define MEDIA_COMMAND_VOLUME_UP ((sal_Int16)17)// Raise the volume.
289 #define MEDIA_COMMAND_MENU ((sal_Int16)18)// Button Menu pressed.
290 #define MEDIA_COMMAND_MENU_HOLD ((sal_Int16)19)// Button Menu (long) pressed.
291 #define MEDIA_COMMAND_PLAY_HOLD ((sal_Int16)20)// Button Play (long) pressed.
292 #define MEDIA_COMMAND_NEXTTRACK_HOLD ((sal_Int16)21)// Button Right holding pressed.
293 #define MEDIA_COMMAND_PREVIOUSTRACK_HOLD ((sal_Int16)22)// Button Left holding pressed.
297 // - CommandSelectionChangeData -
300 class VCL_DLLPUBLIC CommandSelectionChangeData
302 private:
303 sal_uLong mnStart;
304 sal_uLong mnEnd;
306 public:
307 CommandSelectionChangeData();
308 CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
310 sal_uLong GetStart() const { return mnStart; }
311 sal_uLong GetEnd() const { return mnEnd; }
314 inline CommandSelectionChangeData::CommandSelectionChangeData()
316 mnStart = mnEnd = 0;
319 inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart,
320 sal_uLong nEnd )
322 mnStart = nStart;
323 mnEnd = nEnd;
327 // - CommandEvent -
330 #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
331 #define COMMAND_STARTDRAG ((sal_uInt16)2)
332 #define COMMAND_WHEEL ((sal_uInt16)3)
333 #define COMMAND_STARTAUTOSCROLL ((sal_uInt16)4)
334 #define COMMAND_AUTOSCROLL ((sal_uInt16)5)
335 #define COMMAND_STARTEXTTEXTINPUT ((sal_uInt16)7)
336 #define COMMAND_EXTTEXTINPUT ((sal_uInt16)8)
337 #define COMMAND_ENDEXTTEXTINPUT ((sal_uInt16)9)
338 #define COMMAND_INPUTCONTEXTCHANGE ((sal_uInt16)10)
339 #define COMMAND_CURSORPOS ((sal_uInt16)11)
340 #define COMMAND_PASTESELECTION ((sal_uInt16)12)
341 #define COMMAND_MODKEYCHANGE ((sal_uInt16)13)
342 #define COMMAND_HANGUL_HANJA_CONVERSION ((sal_uInt16)14)
343 #define COMMAND_INPUTLANGUAGECHANGE ((sal_uInt16)15)
344 #define COMMAND_SHOWDIALOG ((sal_uInt16)16)
345 #define COMMAND_MEDIA ((sal_uInt16)17)
346 #define COMMAND_SELECTIONCHANGE ((sal_uInt16)18)
347 #define COMMAND_PREPARERECONVERSION ((sal_uInt16)19)
348 #define COMMAND_QUERYCHARPOSITION ((sal_uInt16)20)
351 class VCL_DLLPUBLIC CommandEvent
353 private:
354 Point maPos;
355 void* mpData;
356 sal_uInt16 mnCommand;
357 bool mbMouseEvent;
359 public:
360 CommandEvent();
361 CommandEvent( const Point& rMousePos, sal_uInt16 nCmd,
362 bool bMEvt = false, const void* pCmdData = NULL );
364 sal_uInt16 GetCommand() const { return mnCommand; }
365 const Point& GetMousePosPixel() const { return maPos; }
366 bool IsMouseEvent() const { return mbMouseEvent; }
367 void* GetData() const { return mpData; }
369 const CommandExtTextInputData* GetExtTextInputData() const;
370 const CommandInputContextData* GetInputContextChangeData() const;
371 const CommandWheelData* GetWheelData() const;
372 const CommandScrollData* GetAutoScrollData() const;
373 const CommandModKeyData* GetModKeyData() const;
374 const CommandDialogData* GetDialogData() const;
375 sal_Int16 GetMediaCommand() const;
376 const CommandSelectionChangeData* GetSelectionChangeData() const;
379 inline CommandEvent::CommandEvent()
381 mpData = NULL;
382 mnCommand = 0;
383 mbMouseEvent = false;
386 inline CommandEvent::CommandEvent( const Point& rMousePos,
387 sal_uInt16 nCmd, bool bMEvt, const void* pCmdData ) :
388 maPos( rMousePos )
390 mpData = (void*)pCmdData;
391 mnCommand = nCmd;
392 mbMouseEvent = bMEvt;
395 inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
397 if ( mnCommand == COMMAND_EXTTEXTINPUT )
398 return (const CommandExtTextInputData*)mpData;
399 else
400 return NULL;
403 inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const
405 if ( mnCommand == COMMAND_INPUTCONTEXTCHANGE )
406 return (const CommandInputContextData*)mpData;
407 else
408 return NULL;
411 inline const CommandWheelData* CommandEvent::GetWheelData() const
413 if ( mnCommand == COMMAND_WHEEL )
414 return (const CommandWheelData*)mpData;
415 else
416 return NULL;
419 inline const CommandScrollData* CommandEvent::GetAutoScrollData() const
421 if ( mnCommand == COMMAND_AUTOSCROLL )
422 return (const CommandScrollData*)mpData;
423 else
424 return NULL;
427 inline const CommandModKeyData* CommandEvent::GetModKeyData() const
429 if( mnCommand == COMMAND_MODKEYCHANGE )
430 return (const CommandModKeyData*)mpData;
431 else
432 return NULL;
435 inline const CommandDialogData* CommandEvent::GetDialogData() const
437 if( mnCommand == COMMAND_SHOWDIALOG )
438 return (const CommandDialogData*)mpData;
439 else
440 return NULL;
443 inline sal_Int16 CommandEvent::GetMediaCommand() const
445 if( mnCommand == COMMAND_MEDIA )
446 return *(const sal_Int16*)(mpData);
447 else
448 return 0;
451 inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
453 if( mnCommand == COMMAND_SELECTIONCHANGE )
454 return (const CommandSelectionChangeData*)mpData;
455 else
456 return NULL;
460 #endif // INCLUDED_VCL_CMDEVT_HXX
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */