NXWidgets: cstickybuttonarray.hxx Source File

NXWidgets 1.19

cstickybuttonarray.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/cstickybuttonarray.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_CSTICKYBUTTONARRAY_HXX
37 #define __INCLUDE_CSTICKYBUTTONARRAY_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 #include "cwidgetstyle.hxx"
52
53 /****************************************************************************
54 * Pre-Processor Definitions
55 ****************************************************************************/
56
57 /****************************************************************************
58 * Implementation Classes
59 ****************************************************************************/
60
61 #if defined(__cplusplus)
62
63 namespace NXWidgets
64 {
65 /**
66 * Forward references
67 */
68
69 class CWidgetControl;
70 class CNxString;
71
72 /**
73 * Manages a two-dimensional array of buttons as one widget. A two-
74 * dimensional array of buttons might also be called a "keyboard".
75 */
76
77 class CStickyButtonArray : public CButtonArray
78 {
79 protected:
80 bool m_isStuckDown; /**< True if one key in the array stuck down */
81 bool m_stickDown; /**< True there is a change in a sticky button state */
82 uint8_t m_stickyRow; /**< The row index of the stuck button */
83 uint8_t m_stickyColumn; /**< The column index of the stuck button */
84
85 /**
86 * Draw the area of this widget that falls within the clipping region.
87 * Called by the redraw() function to draw all visible regions.
88 *
89 * @param port The CGraphicsPort to draw to.
90 * @see redraw()
91 */
92
93 virtual void drawContents(CGraphicsPort *port);
94
95 /**
96 * Copy constructor is protected to prevent usage.
97 */
98
99 inline CStickyButtonArray(const CStickyButtonArray &button) : CButtonArray(button) { }
100
101 public:
102
103 /**
104 * Constructor for an array of sticky buttons.
105 *
106 * @param pWidgetControl The widget control for the display.
107 * @param x The x coordinate of the button array, relative to its parent.
108 * @param y The y coordinate of the button array, relative to its parent.
109 * @param buttonColumns The number of buttons in one row of the button array
110 * @param buttonRows The number of buttons in one column of the button array
111 * @param buttonWidth The width of one button
112 * @param buttonHeight The height of one button
113 * @param style The style that the button should use. If this is not
114 * specified, the button will use the global default widget
115 * style.
116 */
117
118 CStickyButtonArray(CWidgetControl *pWidgetControl,
119 nxgl_coord_t x, nxgl_coord_t y,
120 uint8_t buttonColumns, uint8_t buttonRows,
121 nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
122 CWidgetStyle *style = (CWidgetStyle *)NULL);
123
124 /**
125 * CStickyButtonArray Destructor.
126 */
127
128 virtual inline ~CStickyButtonArray(void) { }
129
130 /**
131 * Return the position of the last stuck down button (0,0 will be returned
132 * the no button has every been stuck down). The button at this position
133 * is currently stuck down then, in addition, return true.
134 *
135 * @param column The location to return the column index of the button
136 * of interest
137 * @param row The location to return the row index of the button of
138 * interest
139 * @return True if a button in the array is clicked
140 */
141
142 virtual bool isAnyButtonStuckDown(int &column, int &row) const;
143
144 /**
145 * Check if this specific button in the array is stuck down
146 *
147 * @param column The column of the button to check.
148 * @param row The row of the button to check.
149 * @return True if this button is stuck down
150 */
151
152 virtual bool isThisButtonStuckDown(int column, int row) const;
153
154 /**
155 * Force the button at this position into the stuck down state
156 *
157 * @param column The column containing the button to stick down
158 * @param row The rowtcontaining the button to stick down
159 * @return False(0) is returned if the indices are out of range.
160 */
161
162 virtual bool stickDown(int column, int row);
163
164 /**
165 * Unstick all buttons
166 */
167
168 virtual void unstick(void);
169 };
170 }
171
172 #endif // __cplusplus
173
174 #endif // __INCLUDE_CSTICKYBUTTONARRAY_HXX
NXWidgets::CStickyButtonArray::~CStickyButtonArray
virtual ~CStickyButtonArray(void)
Definition: cstickybuttonarray.hxx:128
NXWidgets::CWidgetStyle
Definition: cwidgetstyle.hxx:125
NXWidgets::CWidgetControl
Definition: cwidgetcontrol.hxx:95
NXWidgets::CStickyButtonArray::unstick
virtual void unstick(void)
Definition: cstickybuttonarray.cxx:177
cwidgetstyle.hxx
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::CStickyButtonArray::CStickyButtonArray
CStickyButtonArray(const CStickyButtonArray &button)
Definition: cstickybuttonarray.hxx:99
cbuttonarray.hxx
NXWidgets::CStickyButtonArray::stickDown
virtual bool stickDown(int column, int row)
Definition: cstickybuttonarray.cxx:146
NXWidgets::CStickyButtonArray::m_isStuckDown
bool m_isStuckDown
Definition: cstickybuttonarray.hxx:80
NXWidgets::CButtonArray
Definition: cbuttonarray.hxx:77
NXWidgets::CStickyButtonArray::drawContents
virtual void drawContents(CGraphicsPort *port)
Definition: cstickybuttonarray.cxx:203
NXWidgets::CStickyButtonArray::m_stickDown
bool m_stickDown
Definition: cstickybuttonarray.hxx:81
NXWidgets::CStickyButtonArray::m_stickyRow
uint8_t m_stickyRow
Definition: cstickybuttonarray.hxx:82
NXWidgets::CStickyButtonArray
Definition: cstickybuttonarray.hxx:77
NXWidgets::CStickyButtonArray::isAnyButtonStuckDown
virtual bool isAnyButtonStuckDown(int &column, int &row) const
Definition: cstickybuttonarray.cxx:100
NXWidgets::CStickyButtonArray::isThisButtonStuckDown
virtual bool isThisButtonStuckDown(int column, int row) const
Definition: cstickybuttonarray.cxx:120
NXWidgets::CStickyButtonArray::m_stickyColumn
uint8_t m_stickyColumn
Definition: cstickybuttonarray.hxx:83
NXWidgets::CGraphicsPort
Definition: cgraphicsport.hxx:106