PCL
KeyCodes.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/KeyCodes.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_KeyCodes_h
53 #define __PCL_KeyCodes_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Flags.h>
59 
60 namespace pcl
61 {
62 
63 // ----------------------------------------------------------------------------
64 
69 // ----------------------------------------------------------------------------
70 
204 namespace KeyCode
205 {
206  enum value_type
207  {
208  Backspace = 0x00000008,
209  Tab = 0x00000009,
210  Clear = 0x0000000c,
211  Return = 0x0000000d,
212  Enter = 0x0000000d,
213  Escape = 0x0000001b,
214  Shift = 0x70000001,
215  Control = 0x70000002,
216  Alt = 0x70000003,
217  Meta = 0x70000004,
218  CapsLock = 0x70000010,
219  NumLock = 0x70000020,
220  ScrollLock = 0x70000030,
221  Pause = 0x70000100,
222  Print = 0x70000200,
223  Help = 0x70000300,
224  SysReq = 0x70000400,
225  Left = 0x10000001,
226  Up = 0x10000002,
227  Right = 0x10000003,
228  Down = 0x10000004,
229  Insert = 0x10000010,
230  Delete = 0x10000020,
231  Home = 0x10000100,
232  End = 0x10000200,
233  PageUp = 0x10000300,
234  PageDown = 0x10000400,
235  F1 = 0x08000001,
236  F2 = 0x08000002,
237  F3 = 0x08000003,
238  F4 = 0x08000004,
239  F5 = 0x08000005,
240  F6 = 0x08000006,
241  F7 = 0x08000007,
242  F8 = 0x08000008,
243  F9 = 0x08000009,
244  F10 = 0x0800000a,
245  F11 = 0x0800000b,
246  F12 = 0x0800000c,
247  F13 = 0x0800000d,
248  F14 = 0x0800000e,
249  F15 = 0x0800000f,
250  F16 = 0x08000010,
251  F17 = 0x08000020,
252  F18 = 0x08000030,
253  F19 = 0x08000040,
254  F20 = 0x08000050,
255  F21 = 0x08000060,
256  F22 = 0x08000070,
257  F23 = 0x08000080,
258  F24 = 0x08000090,
259  Space = 0x00000020,
260  Exclamation = 0x00000021,
261  DoubleQuote = 0x00000022,
262  NumberSign = 0x00000023,
263  Dollar = 0x00000024,
264  Percent = 0x00000025,
265  Ampersand = 0x00000026,
266  Apostrophe = 0x00000027,
267  LeftParenthesis = 0x00000028,
268  RightParenthesis = 0x00000029,
269  Asterisk = 0x0000002a,
270  Plus = 0x0000002b,
271  Comma = 0x0000002c,
272  Minus = 0x0000002d,
273  Period = 0x0000002e,
274  Slash = 0x0000002f,
275  Zero = 0x00000030,
276  One = 0x00000031,
277  Two = 0x00000032,
278  Three = 0x00000033,
279  Four = 0x00000034,
280  Five = 0x00000035,
281  Six = 0x00000036,
282  Seven = 0x00000037,
283  Eight = 0x00000038,
284  Nine = 0x00000039,
285  Colon = 0x0000003a,
286  Semicolon = 0x0000003b,
287  Less = 0x0000003c,
288  Equal = 0x0000003d,
289  Greater = 0x0000003e,
290  Question = 0x0000003f,
291  At = 0x00000040,
292  A = 0x00000041,
293  B = 0x00000042,
294  C = 0x00000043,
295  D = 0x00000044,
296  E = 0x00000045,
297  F = 0x00000046,
298  G = 0x00000047,
299  H = 0x00000048,
300  I = 0x00000049,
301  J = 0x0000004a,
302  K = 0x0000004b,
303  L = 0x0000004c,
304  M = 0x0000004d,
305  N = 0x0000004e,
306  O = 0x0000004f,
307  P = 0x00000050,
308  Q = 0x00000051,
309  R = 0x00000052,
310  S = 0x00000053,
311  T = 0x00000054,
312  U = 0x00000055,
313  V = 0x00000056,
314  W = 0x00000057,
315  X = 0x00000058,
316  Y = 0x00000059,
317  Z = 0x0000005a,
318  LeftBracket = 0x0000005b,
319  Backslash = 0x0000005c,
320  RightBracket = 0x0000005d,
321  Circumflex = 0x0000005e,
322  Underscore = 0x0000005f,
323  LeftQuote = 0x00000060,
324  LeftBrace = 0x0000007b,
325  Bar = 0x0000007c,
326  RightBrace = 0x0000007d,
327  Tilde = 0x0000007e,
328 
329  Unknown = 0x7fffffff
330  };
331 }
332 
333 // ----------------------------------------------------------------------------
334 
361 namespace KeyboardModifier
362 {
363  enum mask_type
364  {
365  None = 0x00000000,
366  Shift = 0x00000001,
367  Control = 0x00000002,
368  Alt = 0x00000004,
369  SpaceBar = 0x00000008,
370  Meta = 0x00000010,
371  Cmd = 0x00000020
372  };
373 }
374 
383 using KeyboardModifiers = Flags<KeyboardModifier::mask_type>;
384 
389 KeyboardModifiers CurrentKeyboardModifiers(); // implemented in pcl/Keyboard.cpp
390 
391 // ----------------------------------------------------------------------------
392 
393 #ifndef __PCL_NO_KEY_QUERY_UTILITIES
394 
399 inline bool IsSpaceBarPressed()
400 {
401  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::SpaceBar );
402 }
403 
409 inline bool IsControlPressed()
410 {
411  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::Control );
412 }
413 
418 inline bool IsShiftPressed()
419 {
420  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::Shift );
421 }
422 
428 inline bool IsAltPressed()
429 {
430  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::Alt );
431 }
432 
433 #if defined( __PCL_MACOSX )
434 
440 inline bool IsCmdPressed()
441 {
442  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::Cmd );
443 }
444 
445 #endif // __PCL_MACOSX
446 
456 inline bool IsMetaPressed()
457 {
458  return CurrentKeyboardModifiers().IsFlagSet( KeyboardModifier::Meta );
459 }
460 
469 {
470 #if defined( __PCL_MACOSX )
471  return IsCmdPressed();
472 #else
473  return IsControlPressed();
474 #endif
475 }
476 
481 {
482  return CurrentKeyboardModifiers() == KeyboardModifier::None;
483 }
484 
485 #endif // !__PCL_NO_KEY_QUERY_UTILITIES
486 
487 // ----------------------------------------------------------------------------
488 
489 } // pcl
490 
491 #endif // __PCL_KeyCodes_h
492 
493 // ----------------------------------------------------------------------------
494 // EOF pcl/KeyCodes.h - Released 2024-06-18T15:48:54Z
A type-safe collection of enumerated flags.
Definition: Flags.h:85
constexpr bool IsFlagSet(enum_type e) const
Definition: Flags.h:244
A combination of keyboard modifier codes.
KeyboardModifiers CurrentKeyboardModifiers()
bool IsSpaceBarPressed()
Definition: KeyCodes.h:399
bool IsMetaPressed()
Definition: KeyCodes.h:456
bool IsControlOrCmdPressed()
Definition: KeyCodes.h:468
bool IsControlPressed()
Definition: KeyCodes.h:409
bool IsShiftPressed()
Definition: KeyCodes.h:418
bool IsAltPressed()
Definition: KeyCodes.h:428
PCL root namespace.
Definition: AbstractImage.h:77
bool IsNoKeyboardModifierPressed()
Definition: KeyCodes.h:480