NXWidgets: cscrollbarvertical.hxx Source File

NXWidgets 1.19

cscrollbarvertical.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/cscrollbarvertical.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 * Portions of this package derive from Woopsi (http://woopsi.org/) and
37 * portions are original efforts. It is difficult to determine at this
38 * point what parts are original efforts and which parts derive from Woopsi.
39 * However, in any event, the work of Antony Dzeryn will be acknowledged
40 * in most NxWidget files. Thanks Antony!
41 *
42 * Copyright (c) 2007-2011, Antony Dzeryn
43 * All rights reserved.
44 *
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions are met:
47 *
48 * * Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * * Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * * Neither the names "Woopsi", "Simian Zombie" nor the
54 * names of its contributors may be used to endorse or promote products
55 * derived from this software without specific prior written permission.
56 *
57 * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
58 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
59 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60 * DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
61 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
64 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
66 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 *
68 ****************************************************************************/
69
70 #ifndef __INCLUDE_CSCROLLBARVERTICAL_HXX
71 #define __INCLUDE_CSCROLLBARVERTICAL_HXX
72
73 /****************************************************************************
74 * Included Files
75 ****************************************************************************/
76
77 #include <nuttx/config.h>
78
79 #include <stdint.h>
80 #include <stdbool.h>
81
82 #include <nuttx/nx/nxglib.h>
83
84 #include "cnxwidget.hxx"
85 #include "cwidgeteventhandler.hxx"
86 #include "cwidgetstyle.hxx"
87 #include "islider.hxx"
88
89 /****************************************************************************
90 * Pre-Processor Definitions
91 ****************************************************************************/
92
93 /****************************************************************************
94 * Implementation Classes
95 ****************************************************************************/
96
97 #if defined(__cplusplus)
98
99 namespace NXWidgets
100 {
101 class CSliderVertical;
102 class CGlyphButton;
103 class CNxTimer;
104
105 /**
106 * Container class that holds a slider widget and two arrow buttons.
107 * The interface is presents is virtually identical to the CSliderVertical
108 * widget, which means the two are easily interchangeable. All events
109 * raised by the internal slider widget are re-raised by this widget
110 * to this widget's event handler, meaning its events are also identical
111 * to the CSliderVertical's.
112 */
113 class CScrollbarVertical : public ISlider, public CNxWidget, public CWidgetEventHandler {
114
115 protected:
116 CSliderVertical *m_slider; /**< Pointer to the slider widget */
117 CGlyphButton *m_upButton; /**< Pointer to the up button */
118 CGlyphButton *m_downButton; /**< Pointer to the down button */
119 nxgl_coord_t m_buttonHeight; /**< Height of the buttons */
120 uint8_t m_scrollTimeout; /**< Time until a button triggers another grip
121 movement */
122 CNxTimer *m_timer; /**< Controls slider button repeats */
123
124 /**
125 * Resize the scrollbar to the new dimensions.
126 *
127 * @param width The new width.
128 * @param height The new height.
129 */
130
131 virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
132
133 /**
134 * Copy constructor is protected to prevent usage.
135 */
136
137 inline CScrollbarVertical(const CScrollbarVertical& scrollbarVertical)
138 : CNxWidget(scrollbarVertical) { }
139
140 public:
141
142 /**
143 * Constructor.
144 *
145 * @param pWidgetControl The widget control instance for the window.
146 * @param x The x coordinate of the slider, relative to its parent.
147 * @param y The y coordinate of the slider, relative to its parent.
148 * @param width The width of the slider.
149 * @param height The height of the slider.
150 * @param style The style that the widget should use. If this is not
151 * specified, the widget will use the values stored in the global
152 * g_defaultWidgetStyle object. The widget will copy the properties of
153 * the style into its own internal style object.
154 */
155
156 CScrollbarVertical(CWidgetControl *pWidgetControl,
157 nxgl_coord_t x, nxgl_coord_t y,
158 nxgl_coord_t width, nxgl_coord_t height,
159 CWidgetStyle *style = (CWidgetStyle *)NULL);
160
161 /**
162 * Destructor.
163 */
164
165 virtual inline ~CScrollbarVertical(void) { }
166
167 /**
168 * Get the smallest value that the slider can represent.
169 *
170 * @return The smallest value.
171 */
172
173 const int getMinimumValue(void) const;
174
175 /**
176 * Get the largest value that the slider can represent.
177 *
178 * @return The largest value.
179 */
180
181 const int getMaximumValue(void) const;
182
183 /**
184 * Get the current value of the slider.
185 *
186 * @return The current slider value.
187 */
188
189 const int getValue(void) const;
190
191 /**
192 * Get the value represented by the height of the grip.
193 * For sliders, this would typically be 1 (so each new
194 * grip position is worth 1). For scrollbars, this
195 * would be the height of the scrolling widget.
196 *
197 * @return The page size.
198 */
199
200 const nxgl_coord_t getPageSize(void) const;
201
202 /**
203 * Set the smallest value that the slider can represent.
204 *
205 * @param value The smallest value.
206 */
207
208 void setMinimumValue(const int value);
209
210 /**
211 * Set the largest value that the slider can represent.
212 *
213 * @param value The largest value.
214 */
215
216 void setMaximumValue(const int value);
217
218 /**
219 * Set the value that of the slider. This will reposition
220 * and redraw the grip.
221 *
222 * @param value The new value.
223 */
224
225 void setValue(const int value);
226
227 /**
228 * Set the value that of the slider. This will reposition and redraw
229 * the grip. The supplied value should be bitshifted left 16 places.
230 * This ensures greater accuracy than the standard setValue() method if
231 * the slider is being used as a scrollbar.
232 *
233 * @param value The new value.
234 */
235
236 void setValueWithBitshift(const int32_t value);
237
238 /**
239 * Set the page size represented by the grip.
240 *
241 * @param pageSize The page size.
242 * @see getPageSize().
243 */
244
245 void setPageSize(const nxgl_coord_t pageSize);
246
247 /**
248 * Process events fired by the grip.
249 *
250 * @param e The event details.
251 */
252
253 virtual void handleActionEvent(const CWidgetEventArgs &e);
254
255 /**
256 * Process events fired by the grip.
257 *
258 * @param e The event details.
259 */
260
261 virtual void handleClickEvent(const CWidgetEventArgs &e);
262
263 /**
264 * Process events fired by the grip.
265 *
266 * @param e The event details.
267 */
268
269 virtual void handleReleaseEvent(const CWidgetEventArgs &e);
270
271 /**
272 * Process events fired by the grip.
273 *
274 * @param e The event details.
275 */
276
277 virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
278
279 /**
280 * Process events fired by the grip.
281 *
282 * @param e The event details.
283 */
284
285 virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
286 };
287 }
288
289 #endif // __cplusplus
290
291 #endif // __INCLUDE_CSCROLLBARVERTICAL_HXX
NXWidgets::CGlyphButton
Definition: cglyphbutton.hxx:113
NXWidgets::CScrollbarVertical::setMinimumValue
void setMinimumValue(const int value)
Definition: cscrollbarvertical.cxx:210
NXWidgets::CNxWidget
Definition: cnxwidget.hxx:121
NXWidgets::CScrollbarVertical::setValueWithBitshift
void setValueWithBitshift(const int32_t value)
Definition: cscrollbarvertical.cxx:247
NXWidgets::CWidgetStyle
Definition: cwidgetstyle.hxx:125
NXWidgets::CScrollbarVertical::m_upButton
CGlyphButton * m_upButton
Definition: cscrollbarvertical.hxx:117
NXWidgets::CScrollbarVertical::~CScrollbarVertical
virtual ~CScrollbarVertical(void)
Definition: cscrollbarvertical.hxx:165
NXWidgets::CWidgetEventHandler
Definition: cwidgeteventhandler.hxx:103
NXWidgets::CScrollbarVertical::handleValueChangeEvent
virtual void handleValueChangeEvent(const CWidgetEventArgs &e)
Definition: cscrollbarvertical.cxx:365
NXWidgets::CWidgetControl
Definition: cwidgetcontrol.hxx:95
NXWidgets::CScrollbarVertical::onResize
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height)
Definition: cscrollbarvertical.cxx:380
NXWidgets::CScrollbarVertical::m_timer
CNxTimer * m_timer
Definition: cscrollbarvertical.hxx:122
NXWidgets::CScrollbarVertical::setValue
void setValue(const int value)
Definition: cscrollbarvertical.cxx:233
NXWidgets::CScrollbarVertical::getValue
const int getValue(void) const
Definition: cscrollbarvertical.cxx:185
NXWidgets::CScrollbarVertical::CScrollbarVertical
CScrollbarVertical(const CScrollbarVertical &scrollbarVertical)
Definition: cscrollbarvertical.hxx:137
cwidgetstyle.hxx
NXWidgets::CScrollbarVertical::getMinimumValue
const int getMinimumValue(void) const
Definition: cscrollbarvertical.cxx:163
NXWidgets::CScrollbarVertical::m_scrollTimeout
uint8_t m_scrollTimeout
Definition: cscrollbarvertical.hxx:120
islider.hxx
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::CNxTimer
Definition: cnxtimer.hxx:110
NXWidgets::ISlider
Definition: islider.hxx:99
NXWidgets::CScrollbarVertical::m_downButton
CGlyphButton * m_downButton
Definition: cscrollbarvertical.hxx:118
NXWidgets::CScrollbarVertical::m_buttonHeight
nxgl_coord_t m_buttonHeight
Definition: cscrollbarvertical.hxx:119
NXWidgets::CScrollbarVertical::handleActionEvent
virtual void handleActionEvent(const CWidgetEventArgs &e)
Definition: cscrollbarvertical.cxx:270
NXWidgets::CWidgetEventArgs
Definition: cwidgeteventargs.hxx:127
NXWidgets::CScrollbarVertical::handleClickEvent
virtual void handleClickEvent(const CWidgetEventArgs &e)
Definition: cscrollbarvertical.cxx:301
NXWidgets::CScrollbarVertical::handleReleaseOutsideEvent
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e)
Definition: cscrollbarvertical.cxx:349
NXWidgets::CScrollbarVertical::setMaximumValue
void setMaximumValue(const int value)
Definition: cscrollbarvertical.cxx:221
cnxwidget.hxx
NXWidgets::CScrollbarVertical::getMaximumValue
const int getMaximumValue(void) const
Definition: cscrollbarvertical.cxx:174
NXWidgets::CScrollbarVertical
Definition: cscrollbarvertical.hxx:113
NXWidgets::CScrollbarVertical::handleReleaseEvent
virtual void handleReleaseEvent(const CWidgetEventArgs &e)
Definition: cscrollbarvertical.cxx:333
NXWidgets::CScrollbarVertical::m_slider
CSliderVertical * m_slider
Definition: cscrollbarvertical.hxx:116
NXWidgets::CSliderVertical
Definition: cslidervertical.hxx:109
NXWidgets::CScrollbarVertical::getPageSize
const nxgl_coord_t getPageSize(void) const
Definition: cscrollbarvertical.cxx:199
NXWidgets::CScrollbarVertical::setPageSize
void setPageSize(const nxgl_coord_t pageSize)
Definition: cscrollbarvertical.cxx:259
cwidgeteventhandler.hxx