NXWidgets: ckeypad.hxx Source File

NXWidgets 1.19

ckeypad.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/ckeypad.hxx
3 *
4 * Copyright (C) 2012 Gregory Nutt. All rights reserved.
5 * Author: Gregory Nutt <gnutt@nuttx.org>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
18 * me be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36 #ifndef __INCLUDE_CKEYPAD_HXX
37 #define __INCLUDE_CKEYPAD_HXX
38
39 /****************************************************************************
40 * Included Files
41 ****************************************************************************/
42
43 #include <nuttx/config.h>
44
45 #include <stdint.h>
46 #include <stdbool.h>
47
48 #include <nuttx/nx/nxglib.h>
49
50 #include "cbuttonarray.hxx"
51
52 /****************************************************************************
53 * Pre-Processor Definitions
54 ****************************************************************************/
55
56 /****************************************************************************
57 * Implementation Classes
58 ****************************************************************************/
59
60 #if defined(__cplusplus)
61
62 namespace NXWidgets
63 {
64 /**
65 * Forward references
66 */
67
68 class CWidgetControl;
69 class CWidgetStyle;
70
71 /**
72 * Extends the CButtonArray class to support a alphanumeric keypad.
73 */
74
75 class CKeypad : public CButtonArray
76 {
77 protected:
78 NXHANDLE m_hNxServer; /**< NX server handle */
79 bool m_numeric; /**< True: Numeric keypad, False: Alpha */
80
81 /**
82 * Configure the keypad for the currenly selected display mode.
83 */
84
85 void configureKeypadMode(void);
86
87 /**
88 * Copy constructor is protected to prevent usage.
89 */
90
91 inline CKeypad(const CKeypad &keypad) : CButtonArray(keypad) { }
92
93 public:
94
95 /**
96 * Constructor for buttons that display a string.
97 *
98 * @param pWidgetControl The widget control for the display.
99 * @param hNxServer The NX server that will receive the keyboard input
100 * @param x The x coordinate of the keypad, relative to its parent.
101 * @param y The y coordinate of the keypad, relative to its parent.
102 * @param width The width of the keypad
103 * @param height The height of the keypad
104 * @param style The style that the button should use. If this is not
105 * specified, the button will use the global default widget
106 * style.
107 */
108
109 CKeypad(CWidgetControl *pWidgetControl, NXHANDLE hNxServer,
110 nxgl_coord_t x, nxgl_coord_t y,
111 nxgl_coord_t width, nxgl_coord_t height,
112 CWidgetStyle *style = (CWidgetStyle *)NULL);
113
114 /**
115 * CKeypad Destructor.
116 */
117
118 inline ~CKeypad(void) {}
119
120 /**
121 * Returns the current keypad display mode
122 *
123 * @return True: keypad is in numeric mode. False: alphanumeric.
124 */
125
126 inline const bool isNumericKeypad(void) const
127 {
128 return m_numeric;
129 }
130
131 /**
132 * Returns the current keypad display mode
133 *
134 * @param mode True: put keypad in numeric mode. False: in alphanumeric.
135 */
136
137 inline void setKeypadMode(bool numeric)
138 {
139 m_numeric = numeric;
140 configureKeypadMode();
141 }
142
143 /**
144 * Catch button clicks.
145 *
146 * @param x The x coordinate of the click.
147 * @param y The y coordinate of the click.
148 */
149
150 virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
151 };
152 }
153
154 #endif // __cplusplus
155
156 #endif // __INCLUDE_CKEYPAD_HXX
NXWidgets::CWidgetStyle
Definition: cwidgetstyle.hxx:125
NXWidgets::CKeypad
Definition: ckeypad.hxx:75
NXWidgets::CWidgetControl
Definition: cwidgetcontrol.hxx:95
NXWidgets::CKeypad::m_numeric
bool m_numeric
Definition: ckeypad.hxx:79
NXWidgets::CKeypad::setKeypadMode
void setKeypadMode(bool numeric)
Definition: ckeypad.hxx:137
NXWidgets::CKeypad::m_hNxServer
NXHANDLE m_hNxServer
Definition: ckeypad.hxx:78
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::CKeypad::~CKeypad
~CKeypad(void)
Definition: ckeypad.hxx:118
cbuttonarray.hxx
NXWidgets::CKeypad::isNumericKeypad
const bool isNumericKeypad(void) const
Definition: ckeypad.hxx:126
NXWidgets::CButtonArray
Definition: cbuttonarray.hxx:77
NXWidgets::CKeypad::configureKeypadMode
void configureKeypadMode(void)
Definition: ckeypad.cxx:190
NXWidgets::CKeypad::onClick
virtual void onClick(nxgl_coord_t x, nxgl_coord_t y)
Definition: ckeypad.cxx:130
NXWidgets::CKeypad::CKeypad
CKeypad(const CKeypad &keypad)
Definition: ckeypad.hxx:91