Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _VCL_CMDEVT_HXX
21 : #define _VCL_CMDEVT_HXX
22 :
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>
28 :
29 : // ---------------------------
30 : // - CommandExtTextInputData -
31 : // ---------------------------
32 :
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)
41 :
42 : #define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001)
43 : #define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002)
44 :
45 : class VCL_DLLPUBLIC CommandExtTextInputData
46 : {
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;
55 :
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();
66 :
67 0 : const XubString& GetText() const { return maText; }
68 0 : const sal_uInt16* GetTextAttr() const { return mpTextAttr; }
69 : sal_uInt16 GetCharTextAttr( sal_uInt16 nIndex ) const;
70 0 : xub_StrLen GetCursorPos() const { return mnCursorPos; }
71 0 : sal_Bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
72 0 : 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 0 : sal_Bool IsOnlyCursorChanged() const { return mbOnlyCursor; }
77 : };
78 :
79 : inline sal_uInt16 CommandExtTextInputData::GetCharTextAttr( sal_uInt16 nIndex ) const
80 : {
81 : if ( mpTextAttr && (nIndex < maText.Len()) )
82 : return mpTextAttr[nIndex];
83 : else
84 : return 0;
85 : }
86 :
87 : // ---------------------------
88 : // - CommandInputContextData -
89 : // ---------------------------
90 :
91 : class VCL_DLLPUBLIC CommandInputContextData
92 : {
93 : private:
94 : LanguageType meLanguage;
95 :
96 : public:
97 : CommandInputContextData();
98 : CommandInputContextData( LanguageType eLang );
99 :
100 : LanguageType GetLanguage() const { return meLanguage; }
101 : };
102 :
103 : inline CommandInputContextData::CommandInputContextData()
104 : {
105 : meLanguage = LANGUAGE_DONTKNOW;
106 : }
107 :
108 0 : inline CommandInputContextData::CommandInputContextData( LanguageType eLang )
109 : {
110 0 : meLanguage = eLang;
111 0 : }
112 :
113 : // --------------------
114 : // - CommandWheelData -
115 : // --------------------
116 :
117 : #define COMMAND_WHEEL_SCROLL ((sal_uInt16)0x0001)
118 : #define COMMAND_WHEEL_ZOOM ((sal_uInt16)0x0002)
119 : #define COMMAND_WHEEL_DATAZOOM ((sal_uInt16)0x0004)
120 :
121 : #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
122 :
123 : class VCL_DLLPUBLIC CommandWheelData
124 : {
125 : private:
126 : long mnDelta;
127 : long mnNotchDelta;
128 : sal_uLong mnLines;
129 : sal_uInt16 mnMode;
130 : sal_uInt16 mnCode;
131 : sal_Bool mbHorz;
132 : sal_Bool mbDeltaIsPixel;
133 :
134 : public:
135 : CommandWheelData();
136 : CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
137 : sal_uLong nScrollLines,
138 : sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
139 : sal_Bool bHorz = sal_False, sal_Bool bDeltaIsPixel = sal_False );
140 :
141 0 : long GetDelta() const { return mnDelta; }
142 0 : long GetNotchDelta() const { return mnNotchDelta; }
143 0 : sal_uLong GetScrollLines() const { return mnLines; }
144 0 : sal_Bool IsHorz() const { return mbHorz; }
145 0 : sal_Bool IsDeltaPixel() const { return mbDeltaIsPixel; }
146 :
147 0 : sal_uInt16 GetMode() const { return mnMode; }
148 :
149 0 : sal_uInt16 GetModifier() const
150 0 : { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
151 0 : bool IsShift() const
152 0 : { return ((mnCode & KEY_SHIFT) != 0); }
153 0 : sal_Bool IsMod1() const
154 0 : { return ((mnCode & KEY_MOD1) != 0); }
155 0 : sal_Bool IsMod2() const
156 0 : { return ((mnCode & KEY_MOD2) != 0); }
157 : sal_Bool IsMod3() const
158 : { return ((mnCode & KEY_MOD3) != 0); }
159 : };
160 :
161 : inline CommandWheelData::CommandWheelData()
162 : {
163 : mnDelta = 0;
164 : mnNotchDelta = 0;
165 : mnLines = 0;
166 : mnMode = 0;
167 : mnCode = 0;
168 : mbHorz = sal_False;
169 : mbDeltaIsPixel = sal_False;
170 : }
171 :
172 0 : inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
173 : sal_uLong nScrollLines,
174 : sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
175 : sal_Bool bHorz, sal_Bool bDeltaIsPixel )
176 : {
177 0 : mnDelta = nWheelDelta;
178 0 : mnNotchDelta = nWheelNotchDelta;
179 0 : mnLines = nScrollLines;
180 0 : mnMode = nWheelMode;
181 0 : mnCode = nKeyModifier;
182 0 : mbHorz = bHorz;
183 0 : mbDeltaIsPixel = bDeltaIsPixel;
184 0 : }
185 :
186 : // ---------------------
187 : // - CommandScrollData -
188 : // ---------------------
189 :
190 : class VCL_DLLPUBLIC CommandScrollData
191 : {
192 : private:
193 : long mnDeltaX;
194 : long mnDeltaY;
195 :
196 : public:
197 : CommandScrollData();
198 : CommandScrollData( long nDeltaX, long nDeltaY );
199 :
200 0 : long GetDeltaX() const { return mnDeltaX; }
201 0 : long GetDeltaY() const { return mnDeltaY; }
202 : };
203 :
204 0 : inline CommandScrollData::CommandScrollData()
205 : {
206 0 : mnDeltaX = 0;
207 0 : mnDeltaY = 0;
208 0 : }
209 :
210 0 : inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
211 : {
212 0 : mnDeltaX = nDeltaX;
213 0 : mnDeltaY = nDeltaY;
214 0 : }
215 :
216 : // --------------------
217 : // - CommandVoiceData -
218 : // --------------------
219 :
220 : enum DictationCommandType
221 : {
222 : VOICECOMMANDTYPE_DICTATION,
223 : VOICECOMMANDTYPE_CONTROL
224 : };
225 :
226 : class VCL_DLLPUBLIC CommandVoiceData
227 : {
228 : private:
229 : XubString maText;
230 : sal_uInt16 mnCommand;
231 : DictationCommandType meType;
232 :
233 : public:
234 : CommandVoiceData();
235 : CommandVoiceData( const XubString& rStr,
236 : DictationCommandType eType,
237 : sal_uInt16 nCommand );
238 :
239 0 : const XubString& GetText() const { return maText; }
240 0 : sal_uInt16 GetCommand() const { return mnCommand; }
241 0 : DictationCommandType GetType() const { return meType; }
242 : };
243 :
244 : inline CommandVoiceData::CommandVoiceData()
245 : {
246 : meType = VOICECOMMANDTYPE_DICTATION;
247 : mnCommand = 0;
248 : }
249 :
250 : inline CommandVoiceData::CommandVoiceData( const XubString& rStr,
251 : DictationCommandType eType,
252 : sal_uInt16 nCommand ) :
253 : maText( rStr ),
254 : mnCommand( nCommand ),
255 : meType( eType )
256 : {
257 : }
258 :
259 : // ---------------------
260 : // - CommandModKeyData -
261 : // ---------------------
262 :
263 : class VCL_DLLPUBLIC CommandModKeyData
264 : {
265 : private:
266 : sal_uInt16 mnCode;
267 :
268 : public:
269 : CommandModKeyData();
270 : CommandModKeyData( sal_uInt16 nCode );
271 :
272 : bool IsShift() const { return (mnCode & MODKEY_SHIFT) ? true : false; }
273 0 : sal_Bool IsMod1() const { return (mnCode & MODKEY_MOD1) ? sal_True : sal_False; }
274 0 : sal_Bool IsMod2() const { return (mnCode & MODKEY_MOD2) ? sal_True : sal_False; }
275 : sal_Bool IsMod3() const { return (mnCode & MODKEY_MOD3) ? sal_True : sal_False; }
276 :
277 0 : sal_Bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) ? sal_True : sal_False; }
278 : sal_Bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) ? sal_True : sal_False; }
279 : sal_Bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) ? sal_True : sal_False; }
280 : sal_Bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) ? sal_True : sal_False; }
281 :
282 0 : sal_Bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) ? sal_True : sal_False; }
283 : sal_Bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) ? sal_True : sal_False; }
284 : sal_Bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) ? sal_True : sal_False; }
285 : sal_Bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) ? sal_True : sal_False; }
286 : };
287 :
288 : inline CommandModKeyData::CommandModKeyData()
289 : {
290 : mnCode = 0L;
291 : }
292 :
293 0 : inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode )
294 : {
295 0 : mnCode = nCode;
296 0 : }
297 :
298 : // --------------------
299 : // - CommanDialogData -
300 : // --------------------
301 :
302 : #define SHOWDIALOG_ID_PREFERENCES 1
303 : #define SHOWDIALOG_ID_ABOUT 2
304 :
305 : class VCL_DLLPUBLIC CommandDialogData
306 : {
307 : int m_nDialogId;
308 : public:
309 0 : CommandDialogData( int nDialogId = SHOWDIALOG_ID_PREFERENCES )
310 0 : : m_nDialogId( nDialogId )
311 0 : {}
312 :
313 0 : int GetDialogId() const { return m_nDialogId; }
314 : };
315 :
316 : // --------------
317 : // Media Commands
318 : // --------------
319 :
320 : #define MEDIA_COMMAND_CHANNEL_DOWN ((sal_Int16)1) // Decrement the channel value, for example, for a TV or radio tuner.
321 : #define MEDIA_COMMAND_CHANNEL_UP ((sal_Int16)2) // Increment the channel value, for example, for a TV or radio tuner.
322 : #define MEDIA_COMMAND_NEXTTRACK ((sal_Int16)3) // Go to next media track/slide.
323 : #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.
324 : #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.
325 : #define MEDIA_COMMAND_PLAY_PAUSE ((sal_Int16)6) // Play or pause playback.
326 : #define MEDIA_COMMAND_PREVIOUSTRACK ((sal_Int16)7) // Go to previous media track/slide.
327 : #define MEDIA_COMMAND_RECORD ((sal_Int16)8) // Begin recording the current stream.
328 : #define MEDIA_COMMAND_REWIND ((sal_Int16)9)// Go backward in a stream at a higher rate of speed.
329 : #define MEDIA_COMMAND_STOP ((sal_Int16)10)// Stop playback.
330 : #define MEDIA_COMMAND_MIC_ON_OFF_TOGGLE ((sal_Int16)11)// Toggle the microphone.
331 : #define MEDIA_COMMAND_MICROPHONE_VOLUME_DOWN ((sal_Int16)12)// Increase microphone volume.
332 : #define MEDIA_COMMAND_MICROPHONE_VOLUME_MUTE ((sal_Int16)13)// Mute the microphone.
333 : #define MEDIA_COMMAND_MICROPHONE_VOLUME_UP ((sal_Int16)14)// Decrease microphone volume.
334 : #define MEDIA_COMMAND_VOLUME_DOWN ((sal_Int16)15)// Lower the volume.
335 : #define MEDIA_COMMAND_VOLUME_MUTE ((sal_Int16)16)// Mute the volume.
336 : #define MEDIA_COMMAND_VOLUME_UP ((sal_Int16)17)// Raise the volume.
337 : #define MEDIA_COMMAND_MENU ((sal_Int16)18)// Button Menu pressed.
338 : #define MEDIA_COMMAND_MENU_HOLD ((sal_Int16)19)// Button Menu (long) pressed.
339 : #define MEDIA_COMMAND_PLAY_HOLD ((sal_Int16)20)// Button Play (long) pressed.
340 : #define MEDIA_COMMAND_NEXTTRACK_HOLD ((sal_Int16)21)// Button Right holding pressed.
341 : #define MEDIA_COMMAND_PREVIOUSTRACK_HOLD ((sal_Int16)22)// Button Left holding pressed.
342 :
343 :
344 : // ------------------------------
345 : // - CommandSelectionChangeData -
346 : // ------------------------------
347 :
348 : class VCL_DLLPUBLIC CommandSelectionChangeData
349 : {
350 : private:
351 : sal_uLong mnStart;
352 : sal_uLong mnEnd;
353 :
354 : public:
355 : CommandSelectionChangeData();
356 : CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
357 :
358 0 : sal_uLong GetStart() const { return mnStart; }
359 0 : sal_uLong GetEnd() const { return mnEnd; }
360 : };
361 :
362 : inline CommandSelectionChangeData::CommandSelectionChangeData()
363 : {
364 : mnStart = mnEnd = 0;
365 : }
366 :
367 0 : inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart,
368 : sal_uLong nEnd )
369 : {
370 0 : mnStart = nStart;
371 0 : mnEnd = nEnd;
372 0 : }
373 :
374 : // ----------------
375 : // - CommandEvent -
376 : // ----------------
377 :
378 : #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
379 : #define COMMAND_STARTDRAG ((sal_uInt16)2)
380 : #define COMMAND_WHEEL ((sal_uInt16)3)
381 : #define COMMAND_STARTAUTOSCROLL ((sal_uInt16)4)
382 : #define COMMAND_AUTOSCROLL ((sal_uInt16)5)
383 : #define COMMAND_VOICE ((sal_uInt16)6)
384 : #define COMMAND_STARTEXTTEXTINPUT ((sal_uInt16)7)
385 : #define COMMAND_EXTTEXTINPUT ((sal_uInt16)8)
386 : #define COMMAND_ENDEXTTEXTINPUT ((sal_uInt16)9)
387 : #define COMMAND_INPUTCONTEXTCHANGE ((sal_uInt16)10)
388 : #define COMMAND_CURSORPOS ((sal_uInt16)11)
389 : #define COMMAND_PASTESELECTION ((sal_uInt16)12)
390 : #define COMMAND_MODKEYCHANGE ((sal_uInt16)13)
391 : #define COMMAND_HANGUL_HANJA_CONVERSION ((sal_uInt16)14)
392 : #define COMMAND_INPUTLANGUAGECHANGE ((sal_uInt16)15)
393 : #define COMMAND_SHOWDIALOG ((sal_uInt16)16)
394 : #define COMMAND_MEDIA ((sal_uInt16)17)
395 : #define COMMAND_SELECTIONCHANGE ((sal_uInt16)18)
396 : #define COMMAND_PREPARERECONVERSION ((sal_uInt16)19)
397 :
398 : class VCL_DLLPUBLIC CommandEvent
399 : {
400 : private:
401 : Point maPos;
402 : void* mpData;
403 : sal_uInt16 mnCommand;
404 : sal_Bool mbMouseEvent;
405 :
406 : public:
407 : CommandEvent();
408 : CommandEvent( const Point& rMousePos, sal_uInt16 nCmd,
409 : sal_Bool bMEvt = sal_False, const void* pCmdData = NULL );
410 :
411 0 : sal_uInt16 GetCommand() const { return mnCommand; }
412 0 : const Point& GetMousePosPixel() const { return maPos; }
413 0 : sal_Bool IsMouseEvent() const { return mbMouseEvent; }
414 0 : void* GetData() const { return mpData; }
415 :
416 : const CommandExtTextInputData* GetExtTextInputData() const;
417 : const CommandInputContextData* GetInputContextChangeData() const;
418 : const CommandWheelData* GetWheelData() const;
419 : const CommandScrollData* GetAutoScrollData() const;
420 : const CommandVoiceData* GetVoiceData() const;
421 : const CommandModKeyData* GetModKeyData() const;
422 : const CommandDialogData* GetDialogData() const;
423 : sal_Int16 GetMediaCommand() const;
424 : const CommandSelectionChangeData* GetSelectionChangeData() const;
425 : };
426 :
427 0 : inline CommandEvent::CommandEvent()
428 : {
429 0 : mpData = NULL;
430 0 : mnCommand = 0;
431 0 : mbMouseEvent = sal_False;
432 0 : }
433 :
434 0 : inline CommandEvent::CommandEvent( const Point& rMousePos,
435 : sal_uInt16 nCmd, sal_Bool bMEvt, const void* pCmdData ) :
436 0 : maPos( rMousePos )
437 : {
438 0 : mpData = (void*)pCmdData;
439 0 : mnCommand = nCmd;
440 0 : mbMouseEvent = bMEvt;
441 0 : }
442 :
443 0 : inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
444 : {
445 0 : if ( mnCommand == COMMAND_EXTTEXTINPUT )
446 0 : return (const CommandExtTextInputData*)mpData;
447 : else
448 0 : return NULL;
449 : }
450 :
451 : inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const
452 : {
453 : if ( mnCommand == COMMAND_INPUTCONTEXTCHANGE )
454 : return (const CommandInputContextData*)mpData;
455 : else
456 : return NULL;
457 : }
458 :
459 0 : inline const CommandWheelData* CommandEvent::GetWheelData() const
460 : {
461 0 : if ( mnCommand == COMMAND_WHEEL )
462 0 : return (const CommandWheelData*)mpData;
463 : else
464 0 : return NULL;
465 : }
466 :
467 0 : inline const CommandScrollData* CommandEvent::GetAutoScrollData() const
468 : {
469 0 : if ( mnCommand == COMMAND_AUTOSCROLL )
470 0 : return (const CommandScrollData*)mpData;
471 : else
472 0 : return NULL;
473 : }
474 :
475 0 : inline const CommandVoiceData* CommandEvent::GetVoiceData() const
476 : {
477 0 : if ( mnCommand == COMMAND_VOICE )
478 0 : return (const CommandVoiceData*)mpData;
479 : else
480 0 : return NULL;
481 : }
482 :
483 : inline const CommandModKeyData* CommandEvent::GetModKeyData() const
484 : {
485 : if( mnCommand == COMMAND_MODKEYCHANGE )
486 : return (const CommandModKeyData*)mpData;
487 : else
488 : return NULL;
489 : }
490 :
491 0 : inline const CommandDialogData* CommandEvent::GetDialogData() const
492 : {
493 0 : if( mnCommand == COMMAND_SHOWDIALOG )
494 0 : return (const CommandDialogData*)mpData;
495 : else
496 0 : return NULL;
497 : }
498 :
499 0 : inline sal_Int16 CommandEvent::GetMediaCommand() const
500 : {
501 0 : if( mnCommand == COMMAND_MEDIA )
502 0 : return *(const sal_Int16*)(mpData);
503 : else
504 0 : return 0;
505 : }
506 :
507 0 : inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
508 : {
509 0 : if( mnCommand == COMMAND_SELECTIONCHANGE )
510 0 : return (const CommandSelectionChangeData*)mpData;
511 : else
512 0 : return NULL;
513 : }
514 :
515 :
516 : #endif // _VCL_CMDEVT_HXX
517 :
518 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|