ckeypad.hxx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /****************************************************************************
  2. * apps/include/graphics/nxwidgets/ckeypad.hxx
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * 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, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
  21. #define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <stdint.h>
  27. #include <stdbool.h>
  28. #include <nuttx/nx/nxglib.h>
  29. #include "graphics/nxwidgets/cbuttonarray.hxx"
  30. /****************************************************************************
  31. * Pre-Processor Definitions
  32. ****************************************************************************/
  33. /****************************************************************************
  34. * Implementation Classes
  35. ****************************************************************************/
  36. #if defined(__cplusplus)
  37. namespace NXWidgets
  38. {
  39. /**
  40. * Forward references
  41. */
  42. class CWidgetControl;
  43. class CWidgetStyle;
  44. /**
  45. * Extends the CButtonArray class to support a alphanumeric keypad.
  46. */
  47. class CKeypad : public CButtonArray
  48. {
  49. protected:
  50. NXHANDLE m_hNxServer; /**< NX server handle */
  51. bool m_numeric; /**< True: Numeric keypad, False: Alpha */
  52. /**
  53. * Configure the keypad for the currently selected display mode.
  54. */
  55. void configureKeypadMode(void);
  56. /**
  57. * Copy constructor is protected to prevent usage.
  58. */
  59. inline CKeypad(const CKeypad &keypad) : CButtonArray(keypad) { }
  60. public:
  61. /**
  62. * Constructor for buttons that display a string.
  63. *
  64. * @param pWidgetControl The widget control for the display.
  65. * @param hNxServer The NX server that will receive the keyboard input
  66. * @param x The x coordinate of the keypad, relative to its parent.
  67. * @param y The y coordinate of the keypad, relative to its parent.
  68. * @param width The width of the keypad
  69. * @param height The height of the keypad
  70. * @param style The style that the button should use. If this is not
  71. * specified, the button will use the global default widget
  72. * style.
  73. */
  74. CKeypad(CWidgetControl *pWidgetControl, NXHANDLE hNxServer,
  75. nxgl_coord_t x, nxgl_coord_t y,
  76. nxgl_coord_t width, nxgl_coord_t height,
  77. CWidgetStyle *style = (CWidgetStyle *)NULL);
  78. /**
  79. * CKeypad Destructor.
  80. */
  81. inline ~CKeypad(void) {}
  82. /**
  83. * Returns the current keypad display mode
  84. *
  85. * @return True: keypad is in numeric mode. False: alphanumeric.
  86. */
  87. inline const bool isNumericKeypad(void) const
  88. {
  89. return m_numeric;
  90. }
  91. /**
  92. * Returns the current keypad display mode
  93. *
  94. * @param mode True: put keypad in numeric mode. False: in alphanumeric.
  95. */
  96. inline void setKeypadMode(bool numeric)
  97. {
  98. m_numeric = numeric;
  99. configureKeypadMode();
  100. }
  101. /**
  102. * Catch button clicks.
  103. *
  104. * @param x The x coordinate of the click.
  105. * @param y The y coordinate of the click.
  106. */
  107. virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
  108. };
  109. }
  110. #endif // __cplusplus
  111. #endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX