1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _VCL_CMDEVT_HXX
25 #define _VCL_CMDEVT_HXX
26
27 #include <tools/gen.hxx>
28 #include <vcl/sv.h>
29 #include <vcl/dllapi.h>
30 #include <vcl/keycod.hxx>
31 #include <vcl/font.hxx>
32
33 // ---------------------------
34 // - CommandExtTextInputData -
35 // ---------------------------
36
37 #define EXTTEXTINPUT_ATTR_GRAYWAVELINE ((sal_uInt16)0x0100)
38 #define EXTTEXTINPUT_ATTR_UNDERLINE ((sal_uInt16)0x0200)
39 #define EXTTEXTINPUT_ATTR_BOLDUNDERLINE ((sal_uInt16)0x0400)
40 #define EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE ((sal_uInt16)0x0800)
41 #define EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE ((sal_uInt16)0x1000)
42 #define EXTTEXTINPUT_ATTR_HIGHLIGHT ((sal_uInt16)0x2000)
43 #define EXTTEXTINPUT_ATTR_REDTEXT ((sal_uInt16)0x4000)
44 #define EXTTEXTINPUT_ATTR_HALFTONETEXT ((sal_uInt16)0x8000)
45
46 #define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001)
47 #define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002)
48
49 class VCL_DLLPUBLIC CommandExtTextInputData
50 {
51 private:
52 XubString maText;
53 sal_uInt16* mpTextAttr;
54 xub_StrLen mnCursorPos;
55 xub_StrLen mnDeltaStart;
56 xub_StrLen mnOldTextLen;
57 sal_uInt16 mnCursorFlags;
58 sal_Bool mbOnlyCursor;
59
60 public:
61 CommandExtTextInputData();
62 CommandExtTextInputData( const XubString& rText,
63 const sal_uInt16* pTextAttr,
64 xub_StrLen nCursorPos,
65 sal_uInt16 nCursorFlags,
66 xub_StrLen nDeltaStart,
67 xub_StrLen nOldTextLen,
68 sal_Bool bOnlyCursor );
69 CommandExtTextInputData( const CommandExtTextInputData& rData );
70 ~CommandExtTextInputData();
71
GetText() const72 const XubString& GetText() const { return maText; }
GetTextAttr() const73 const sal_uInt16* GetTextAttr() const { return mpTextAttr; }
74 sal_uInt16 GetCharTextAttr( sal_uInt16 nIndex ) const;
GetCursorPos() const75 xub_StrLen GetCursorPos() const { return mnCursorPos; }
IsCursorVisible() const76 sal_Bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
IsCursorOverwrite() const77 sal_Bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; }
GetCursorFlags() const78 sal_uInt16 GetCursorFlags() const { return mnCursorFlags; }
GetDeltaStart() const79 xub_StrLen GetDeltaStart() const { return mnDeltaStart; }
GetOldTextLen() const80 xub_StrLen GetOldTextLen() const { return mnOldTextLen; }
IsOnlyCursorChanged() const81 sal_Bool IsOnlyCursorChanged() const { return mbOnlyCursor; }
82 };
83
GetCharTextAttr(sal_uInt16 nIndex) const84 inline sal_uInt16 CommandExtTextInputData::GetCharTextAttr( sal_uInt16 nIndex ) const
85 {
86 if ( mpTextAttr && (nIndex < maText.Len()) )
87 return mpTextAttr[nIndex];
88 else
89 return 0;
90 }
91
92 // ---------------------------
93 // - CommandInputContextData -
94 // ---------------------------
95
96 class VCL_DLLPUBLIC CommandInputContextData
97 {
98 private:
99 LanguageType meLanguage;
100
101 public:
102 CommandInputContextData();
103 CommandInputContextData( LanguageType eLang );
104
GetLanguage() const105 LanguageType GetLanguage() const { return meLanguage; }
106 };
107
CommandInputContextData()108 inline CommandInputContextData::CommandInputContextData()
109 {
110 meLanguage = LANGUAGE_DONTKNOW;
111 }
112
CommandInputContextData(LanguageType eLang)113 inline CommandInputContextData::CommandInputContextData( LanguageType eLang )
114 {
115 meLanguage = eLang;
116 }
117
118 // --------------------
119 // - CommandWheelData -
120 // --------------------
121
122 #define COMMAND_WHEEL_SCROLL ((sal_uInt16)0x0001)
123 #define COMMAND_WHEEL_ZOOM ((sal_uInt16)0x0002)
124 #define COMMAND_WHEEL_DATAZOOM ((sal_uInt16)0x0004)
125
126 #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF)
127
128 class VCL_DLLPUBLIC CommandWheelData
129 {
130 private:
131 long mnDelta;
132 long mnNotchDelta;
133 sal_uLong mnLines;
134 sal_uInt16 mnMode;
135 sal_uInt16 mnCode;
136 sal_Bool mbHorz;
137 sal_Bool mbDeltaIsPixel;
138
139 public:
140 CommandWheelData();
141 CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
142 sal_uLong nScrollLines,
143 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
144 sal_Bool bHorz = sal_False, sal_Bool bDeltaIsPixel = sal_False );
145
GetDelta() const146 long GetDelta() const { return mnDelta; }
GetNotchDelta() const147 long GetNotchDelta() const { return mnNotchDelta; }
GetScrollLines() const148 sal_uLong GetScrollLines() const { return mnLines; }
IsHorz() const149 sal_Bool IsHorz() const { return mbHorz; }
IsDeltaPixel() const150 sal_Bool IsDeltaPixel() const { return mbDeltaIsPixel; }
151
GetMode() const152 sal_uInt16 GetMode() const { return mnMode; }
153
GetModifier() const154 sal_uInt16 GetModifier() const
155 { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
IsShift() const156 sal_Bool IsShift() const
157 { return ((mnCode & KEY_SHIFT) != 0); }
IsMod1() const158 sal_Bool IsMod1() const
159 { return ((mnCode & KEY_MOD1) != 0); }
IsMod2() const160 sal_Bool IsMod2() const
161 { return ((mnCode & KEY_MOD2) != 0); }
IsMod3() const162 sal_Bool IsMod3() const
163 { return ((mnCode & KEY_MOD3) != 0); }
164 };
165
CommandWheelData()166 inline CommandWheelData::CommandWheelData()
167 {
168 mnDelta = 0;
169 mnNotchDelta = 0;
170 mnLines = 0;
171 mnMode = 0;
172 mnCode = 0;
173 mbHorz = sal_False;
174 mbDeltaIsPixel = sal_False;
175 }
176
CommandWheelData(long nWheelDelta,long nWheelNotchDelta,sal_uLong nScrollLines,sal_uInt16 nWheelMode,sal_uInt16 nKeyModifier,sal_Bool bHorz,sal_Bool bDeltaIsPixel)177 inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
178 sal_uLong nScrollLines,
179 sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier,
180 sal_Bool bHorz, sal_Bool bDeltaIsPixel )
181 {
182 mnDelta = nWheelDelta;
183 mnNotchDelta = nWheelNotchDelta;
184 mnLines = nScrollLines;
185 mnMode = nWheelMode;
186 mnCode = nKeyModifier;
187 mbHorz = bHorz;
188 mbDeltaIsPixel = bDeltaIsPixel;
189 }
190
191 // ---------------------
192 // - CommandScrollData -
193 // ---------------------
194
195 class VCL_DLLPUBLIC CommandScrollData
196 {
197 private:
198 long mnDeltaX;
199 long mnDeltaY;
200
201 public:
202 CommandScrollData();
203 CommandScrollData( long nDeltaX, long nDeltaY );
204
GetDeltaX() const205 long GetDeltaX() const { return mnDeltaX; }
GetDeltaY() const206 long GetDeltaY() const { return mnDeltaY; }
207 };
208
CommandScrollData()209 inline CommandScrollData::CommandScrollData()
210 {
211 mnDeltaX = 0;
212 mnDeltaY = 0;
213 }
214
CommandScrollData(long nDeltaX,long nDeltaY)215 inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
216 {
217 mnDeltaX = nDeltaX;
218 mnDeltaY = nDeltaY;
219 }
220
221 // --------------------
222 // - CommandVoiceData -
223 // --------------------
224
225 enum DictationCommandType
226 {
227 VOICECOMMANDTYPE_DICTATION,
228 VOICECOMMANDTYPE_CONTROL
229 };
230
231 class VCL_DLLPUBLIC CommandVoiceData
232 {
233 private:
234 XubString maText;
235 sal_uInt16 mnCommand;
236 DictationCommandType meType;
237
238 public:
239 CommandVoiceData();
240 CommandVoiceData( const XubString& rStr,
241 DictationCommandType eType,
242 sal_uInt16 nCommand );
243
GetText() const244 const XubString& GetText() const { return maText; }
GetCommand() const245 sal_uInt16 GetCommand() const { return mnCommand; }
GetType() const246 DictationCommandType GetType() const { return meType; }
247 };
248
CommandVoiceData()249 inline CommandVoiceData::CommandVoiceData()
250 {
251 meType = VOICECOMMANDTYPE_DICTATION;
252 mnCommand = 0;
253 }
254
CommandVoiceData(const XubString & rStr,DictationCommandType eType,sal_uInt16 nCommand)255 inline CommandVoiceData::CommandVoiceData( const XubString& rStr,
256 DictationCommandType eType,
257 sal_uInt16 nCommand ) :
258 maText( rStr ),
259 mnCommand( nCommand ),
260 meType( eType )
261 {
262 }
263
264 // ---------------------
265 // - CommandModKeyData -
266 // ---------------------
267
268 class VCL_DLLPUBLIC CommandModKeyData
269 {
270 private:
271 sal_uInt16 mnCode;
272
273 public:
274 CommandModKeyData();
275 CommandModKeyData( sal_uInt16 nCode );
276
IsShift() const277 sal_Bool IsShift() const { return (mnCode & MODKEY_SHIFT) ? sal_True : sal_False; }
IsMod1() const278 sal_Bool IsMod1() const { return (mnCode & MODKEY_MOD1) ? sal_True : sal_False; }
IsMod2() const279 sal_Bool IsMod2() const { return (mnCode & MODKEY_MOD2) ? sal_True : sal_False; }
IsMod3() const280 sal_Bool IsMod3() const { return (mnCode & MODKEY_MOD3) ? sal_True : sal_False; }
281
IsLeftShift() const282 sal_Bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) ? sal_True : sal_False; }
IsLeftMod1() const283 sal_Bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) ? sal_True : sal_False; }
IsLeftMod2() const284 sal_Bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) ? sal_True : sal_False; }
IsLeftMod3() const285 sal_Bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) ? sal_True : sal_False; }
286
IsRightShift() const287 sal_Bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) ? sal_True : sal_False; }
IsRightMod1() const288 sal_Bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) ? sal_True : sal_False; }
IsRightMod2() const289 sal_Bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) ? sal_True : sal_False; }
IsRightMod3() const290 sal_Bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) ? sal_True : sal_False; }
291 };
292
CommandModKeyData()293 inline CommandModKeyData::CommandModKeyData()
294 {
295 mnCode = 0L;
296 }
297
CommandModKeyData(sal_uInt16 nCode)298 inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode )
299 {
300 mnCode = nCode;
301 }
302
303 // --------------------
304 // - CommanDialogData -
305 // --------------------
306
307 #define SHOWDIALOG_ID_PREFERENCES 1
308 #define SHOWDIALOG_ID_ABOUT 2
309
310 class VCL_DLLPUBLIC CommandDialogData
311 {
312 int m_nDialogId;
313 public:
CommandDialogData(int nDialogId=SHOWDIALOG_ID_PREFERENCES)314 CommandDialogData( int nDialogId = SHOWDIALOG_ID_PREFERENCES )
315 : m_nDialogId( nDialogId )
316 {}
317
GetDialogId() const318 int GetDialogId() const { return m_nDialogId; }
319 };
320
321 // --------------
322 // Media Commands
323 // --------------
324
325 #define MEDIA_COMMAND_CHANNEL_DOWN ((sal_Int16)1) // Decrement the channel value, for example, for a TV or radio tuner.
326 #define MEDIA_COMMAND_CHANNEL_UP ((sal_Int16)2) // Increment the channel value, for example, for a TV or radio tuner.
327 #define MEDIA_COMMAND_NEXTTRACK ((sal_Int16)3) // Go to next media track/slide.
328 #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.
329 #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.
330 #define MEDIA_COMMAND_PLAY_PAUSE ((sal_Int16)6) // Play or pause playback.
331 #define MEDIA_COMMAND_PREVIOUSTRACK ((sal_Int16)7) // Go to previous media track/slide.
332 #define MEDIA_COMMAND_RECORD ((sal_Int16)8) // Begin recording the current stream.
333 #define MEDIA_COMMAND_REWIND ((sal_Int16)9)// Go backward in a stream at a higher rate of speed.
334 #define MEDIA_COMMAND_STOP ((sal_Int16)10)// Stop playback.
335 #define MEDIA_COMMAND_MIC_ON_OFF_TOGGLE ((sal_Int16)11)// Toggle the microphone.
336 #define MEDIA_COMMAND_MICROPHONE_VOLUME_DOWN ((sal_Int16)12)// Increase microphone volume.
337 #define MEDIA_COMMAND_MICROPHONE_VOLUME_MUTE ((sal_Int16)13)// Mute the microphone.
338 #define MEDIA_COMMAND_MICROPHONE_VOLUME_UP ((sal_Int16)14)// Decrease microphone volume.
339 #define MEDIA_COMMAND_VOLUME_DOWN ((sal_Int16)15)// Lower the volume.
340 #define MEDIA_COMMAND_VOLUME_MUTE ((sal_Int16)16)// Mute the volume.
341 #define MEDIA_COMMAND_VOLUME_UP ((sal_Int16)17)// Raise the volume.
342 #define MEDIA_COMMAND_MENU ((sal_Int16)18)// Button Menu pressed.
343 #define MEDIA_COMMAND_MENU_HOLD ((sal_Int16)19)// Button Menu (long) pressed.
344 #define MEDIA_COMMAND_PLAY_HOLD ((sal_Int16)20)// Button Play (long) pressed.
345 #define MEDIA_COMMAND_NEXTTRACK_HOLD ((sal_Int16)21)// Button Right holding pressed.
346 #define MEDIA_COMMAND_PREVIOUSTRACK_HOLD ((sal_Int16)22)// Button Left holding pressed.
347
348
349 // ------------------------------
350 // - CommandSelectionChangeData -
351 // ------------------------------
352
353 class VCL_DLLPUBLIC CommandSelectionChangeData
354 {
355 private:
356 sal_uLong mnStart;
357 sal_uLong mnEnd;
358
359 public:
360 CommandSelectionChangeData();
361 CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
362
GetStart() const363 sal_uLong GetStart() const { return mnStart; }
GetEnd() const364 sal_uLong GetEnd() const { return mnEnd; }
365 };
366
CommandSelectionChangeData()367 inline CommandSelectionChangeData::CommandSelectionChangeData()
368 {
369 mnStart = mnEnd = 0;
370 }
371
CommandSelectionChangeData(sal_uLong nStart,sal_uLong nEnd)372 inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart,
373 sal_uLong nEnd )
374 {
375 mnStart = nStart;
376 mnEnd = nEnd;
377 }
378
379 // ----------------
380 // - CommandEvent -
381 // ----------------
382
383 #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
384 #define COMMAND_STARTDRAG ((sal_uInt16)2)
385 #define COMMAND_WHEEL ((sal_uInt16)3)
386 #define COMMAND_STARTAUTOSCROLL ((sal_uInt16)4)
387 #define COMMAND_AUTOSCROLL ((sal_uInt16)5)
388 #define COMMAND_VOICE ((sal_uInt16)6)
389 #define COMMAND_STARTEXTTEXTINPUT ((sal_uInt16)7)
390 #define COMMAND_EXTTEXTINPUT ((sal_uInt16)8)
391 #define COMMAND_ENDEXTTEXTINPUT ((sal_uInt16)9)
392 #define COMMAND_INPUTCONTEXTCHANGE ((sal_uInt16)10)
393 #define COMMAND_CURSORPOS ((sal_uInt16)11)
394 #define COMMAND_PASTESELECTION ((sal_uInt16)12)
395 #define COMMAND_MODKEYCHANGE ((sal_uInt16)13)
396 #define COMMAND_HANGUL_HANJA_CONVERSION ((sal_uInt16)14)
397 #define COMMAND_INPUTLANGUAGECHANGE ((sal_uInt16)15)
398 #define COMMAND_SHOWDIALOG ((sal_uInt16)16)
399 #define COMMAND_MEDIA ((sal_uInt16)17)
400 #define COMMAND_SELECTIONCHANGE ((sal_uInt16)18)
401 #define COMMAND_PREPARERECONVERSION ((sal_uInt16)19)
402 #define COMMAND_USER ((sal_uInt16)4096)
403
404 class VCL_DLLPUBLIC CommandEvent
405 {
406 private:
407 Point maPos;
408 void* mpData;
409 sal_uInt16 mnCommand;
410 sal_Bool mbMouseEvent;
411
412 public:
413 CommandEvent();
414 CommandEvent( const Point& rMousePos, sal_uInt16 nCmd,
415 sal_Bool bMEvt = sal_False, const void* pCmdData = NULL );
416
GetCommand() const417 sal_uInt16 GetCommand() const { return mnCommand; }
GetMousePosPixel() const418 const Point& GetMousePosPixel() const { return maPos; }
IsMouseEvent() const419 sal_Bool IsMouseEvent() const { return mbMouseEvent; }
GetData() const420 void* GetData() const { return mpData; }
421
422 const CommandExtTextInputData* GetExtTextInputData() const;
423 const CommandInputContextData* GetInputContextChangeData() const;
424 const CommandWheelData* GetWheelData() const;
425 const CommandScrollData* GetAutoScrollData() const;
426 const CommandVoiceData* GetVoiceData() const;
427 const CommandModKeyData* GetModKeyData() const;
428 const CommandDialogData* GetDialogData() const;
429 sal_Int16 GetMediaCommand() const;
430 const CommandSelectionChangeData* GetSelectionChangeData() const;
431 };
432
CommandEvent()433 inline CommandEvent::CommandEvent()
434 {
435 mpData = NULL;
436 mnCommand = 0;
437 mbMouseEvent = sal_False;
438 }
439
CommandEvent(const Point & rMousePos,sal_uInt16 nCmd,sal_Bool bMEvt,const void * pCmdData)440 inline CommandEvent::CommandEvent( const Point& rMousePos,
441 sal_uInt16 nCmd, sal_Bool bMEvt, const void* pCmdData ) :
442 maPos( rMousePos )
443 {
444 mpData = (void*)pCmdData;
445 mnCommand = nCmd;
446 mbMouseEvent = bMEvt;
447 }
448
GetExtTextInputData() const449 inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
450 {
451 if ( mnCommand == COMMAND_EXTTEXTINPUT )
452 return (const CommandExtTextInputData*)mpData;
453 else
454 return NULL;
455 }
456
GetInputContextChangeData() const457 inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const
458 {
459 if ( mnCommand == COMMAND_INPUTCONTEXTCHANGE )
460 return (const CommandInputContextData*)mpData;
461 else
462 return NULL;
463 }
464
GetWheelData() const465 inline const CommandWheelData* CommandEvent::GetWheelData() const
466 {
467 if ( mnCommand == COMMAND_WHEEL )
468 return (const CommandWheelData*)mpData;
469 else
470 return NULL;
471 }
472
GetAutoScrollData() const473 inline const CommandScrollData* CommandEvent::GetAutoScrollData() const
474 {
475 if ( mnCommand == COMMAND_AUTOSCROLL )
476 return (const CommandScrollData*)mpData;
477 else
478 return NULL;
479 }
480
GetVoiceData() const481 inline const CommandVoiceData* CommandEvent::GetVoiceData() const
482 {
483 if ( mnCommand == COMMAND_VOICE )
484 return (const CommandVoiceData*)mpData;
485 else
486 return NULL;
487 }
488
GetModKeyData() const489 inline const CommandModKeyData* CommandEvent::GetModKeyData() const
490 {
491 if( mnCommand == COMMAND_MODKEYCHANGE )
492 return (const CommandModKeyData*)mpData;
493 else
494 return NULL;
495 }
496
GetDialogData() const497 inline const CommandDialogData* CommandEvent::GetDialogData() const
498 {
499 if( mnCommand == COMMAND_SHOWDIALOG )
500 return (const CommandDialogData*)mpData;
501 else
502 return NULL;
503 }
504
GetMediaCommand() const505 inline sal_Int16 CommandEvent::GetMediaCommand() const
506 {
507 if( mnCommand == COMMAND_MEDIA )
508 return *(const sal_Int16*)(mpData);
509 else
510 return 0;
511 }
512
GetSelectionChangeData() const513 inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
514 {
515 if( mnCommand == COMMAND_SELECTIONCHANGE )
516 return (const CommandSelectionChangeData*)mpData;
517 else
518 return NULL;
519 }
520
521
522 #endif // _VCL_CMDEVT_HXX
523