NXWidgets: cscrollbarpanel.hxx Source File

NXWidgets 1.19

cscrollbarpanel.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/cscrollbarpanel.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_CSCROLLBARPANEL_HXX
71 #define __INCLUDE_CSCROLLBARPANEL_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 "cscrollingpanel.hxx"
86 #include "cwidgetstyle.hxx"
87 #include "cscrollbarvertical.hxx"
88 #include "cscrollbarhorizontal.hxx"
89 #include "cwidgeteventhandler.hxx"
90 #include "iscrollable.hxx"
91 #include "cgraphicsport.hxx"
92
93 /****************************************************************************
94 * Pre-Processor Definitions
95 ****************************************************************************/
96
97 /****************************************************************************
98 * Implementation Classes
99 ****************************************************************************/
100
101 #if defined(__cplusplus)
102
103 namespace NXWidgets
104 {
105 /**
106 * Class containing a scrolling panel bordered by scrollbars.
107 */
108 class CScrollbarPanel : public CNxWidget, public IScrollable,
109 public CWidgetEventHandler
110 {
111 protected:
112 CWidgetControl *m_widgetControl; /**< Widget control instance */
113 CScrollingPanel *m_panel; /**< Internal panel that
114 contains children. */
115 CScrollbarHorizontal *m_scrollbarHorizontal; /**< Horizontal scrollbar. */
116 CScrollbarVertical *m_scrollbarVertical; /**< Vertical scrollbar. */
117 uint8_t m_scrollbarWidth; /**< Width of the vertical
118 scrollbar. */
119 uint8_t m_scrollbarHeight; /**< Height of the horizontal
120 scrollbar. */
121 bool m_hasVerticalScrollbar; /**< Indicates the presence of
122 a vertical scrollbar. */
123 bool m_hasHorizontalScrollbar; /**< Indicates the presence of
124 a horizontal scrollbar. */
125
126 /**
127 * Creates the child widgets.
128 */
129
130 void buildUI(void);
131
132 /**
133 * Draw the area of this widget that falls within the clipping region.
134 * Called by the redraw() function to draw all visible regions.
135 *
136 * @param port The CGraphicsPort to draw to.
137 * @see redraw()
138 */
139
140 virtual void drawContents(CGraphicsPort *port);
141
142 /**
143 * Destructor.
144 */
145
146 virtual ~CScrollbarPanel(void) { }
147
148 /**
149 * Copy constructor is protected to prevent usage.
150 */
151
152 inline CScrollbarPanel(const CScrollbarPanel &scrollbarPanel)
153 : CNxWidget(scrollbarPanel) { }
154
155 public:
156
157 /**
158 * Constructor.
159 *
160 * @param pWidgetControl The widget control for the display.
161 * @param x The x coordinate of the widget.
162 * @param y The y coordinate of the widget.
163 * @param width The width of the widget.
164 * @param height The height of the widget.
165 * @param flags The usual widget flags.
166 * @param style The style that the widget should use. If this is not
167 * specified, the widget will use the values stored in the global
168 * g_defaultWidgetStyle object. The widget will copy the properties of
169 * the style into its own internal style object.
170 */
171
172 CScrollbarPanel(CWidgetControl *pWidgetControl,
173 nxgl_coord_t x, nxgl_coord_t y,
174 nxgl_coord_t width, nxgl_coord_t height,
175 uint32_t flags,
176 CWidgetStyle *style = (CWidgetStyle *)NULL);
177
178 /**
179 * Scroll the panel by the specified amounts.
180 *
181 * @param dx The horizontal distance to scroll.
182 * @param dy The vertical distance to scroll.
183 */
184
185 virtual void scroll(int32_t dx, int32_t dy);
186
187 /**
188 * Reposition the panel's scrolling region to the specified coordinates.
189 *
190 * @param x The new x coordinate of the scrolling region.
191 * @param y The new y coordinate of the scrolling region.
192 */
193
194 virtual void jump(int32_t x, int32_t y);
195
196 /**
197 * Set whether or not horizontal scrolling is allowed.
198 *
199 * @param allow True to allow horizontal scrolling; false to deny it.
200 */
201
202 virtual void setAllowsVerticalScroll(bool allow);
203
204 /**
205 * Set whether or not horizontal scrolling is allowed.
206 *
207 * @param allow True to allow horizontal scrolling; false to deny it.
208 */
209
210 virtual void setAllowsHorizontalScroll(bool allow);
211
212 /**
213 * Sets the width of the virtual canvas.
214 *
215 * @param width The width of the virtual canvas.
216 */
217
218 virtual void setCanvasWidth(const int32_t width);
219
220 /**
221 * Sets the height of the virtual canvas.
222 *
223 * @param height The height of the virtual canvas.
224 */
225
226 virtual void setCanvasHeight(const int32_t height);
227
228 /**
229 * Returns true if vertical scrolling is allowed.
230 *
231 * @return True if vertical scrolling is allowed.
232 */
233
234 virtual bool allowsVerticalScroll(void) const;
235
236 /**
237 * Returns true if horizontal scrolling is allowed.
238 *
239 * @return True if horizontal scrolling is allowed.
240 */
241
242 virtual bool allowsHorizontalScroll(void) const;
243
244 /**
245 * Gets the x coordinate of the virtual canvas.
246 *
247 * @return The x coordinate of the virtual canvas.
248 */
249
250 virtual const int32_t getCanvasX(void) const;
251
252 /**
253 * Gets the y coordinate of the virtual canvas.
254 *
255 * @return The y coordinate of the virtual canvas.
256 */
257
258 virtual const int32_t getCanvasY(void) const;
259
260 /**
261 * Gets the width of the virtual canvas.
262 *
263 * @return The width of the virtual canvas.
264 */
265
266 virtual const int32_t getCanvasWidth(void) const;
267
268 /**
269 * Gets the height of the virtual canvas.
270 *
271 * @return The height of the virtual canvas.
272 */
273
274 virtual const int32_t getCanvasHeight(void) const;
275
276 /**
277 * Handle a widget scroll event.
278 *
279 * @param e The event data.
280 */
281
282 void handleScrollEvent(const CWidgetEventArgs &e);
283
284 /**
285 * Handle a widget value change event.
286 *
287 * @param e The event data.
288 */
289
290 void handleValueChangeEvent(const CWidgetEventArgs &e);
291
292 /**
293 * Gets a pointer to the CScrollingPanel widget contained within
294 * this widget.
295 *
296 * @return A pointer to the CScrollingPanel widget.
297 */
298
299 inline CScrollingPanel *getPanel(void)
300 {
301 return m_panel;
302 }
303 };
304 }
305
306 #endif // __cplusplus
307
308 #endif // __INCLUDE_CSCROLLBARPANEL_HXX
309
NXWidgets::CNxWidget
Definition: cnxwidget.hxx:121
cscrollbarvertical.hxx
NXWidgets::CScrollbarPanel::allowsHorizontalScroll
virtual bool allowsHorizontalScroll(void) const
Definition: cscrollbarpanel.cxx:243
NXWidgets::CScrollbarPanel::CScrollbarPanel
CScrollbarPanel(const CScrollbarPanel &scrollbarPanel)
Definition: cscrollbarpanel.hxx:152
NXWidgets::CScrollbarPanel::getCanvasHeight
virtual const int32_t getCanvasHeight(void) const
Definition: cscrollbarpanel.cxx:287
NXWidgets::CWidgetStyle
Definition: cwidgetstyle.hxx:125
NXWidgets::CWidgetEventHandler
Definition: cwidgeteventhandler.hxx:103
NXWidgets::CScrollbarPanel::setCanvasWidth
virtual void setCanvasWidth(const int32_t width)
Definition: cscrollbarpanel.cxx:208
NXWidgets::CWidgetControl
Definition: cwidgetcontrol.hxx:95
iscrollable.hxx
NXWidgets::CScrollbarPanel::setAllowsHorizontalScroll
virtual void setAllowsHorizontalScroll(bool allow)
Definition: cscrollbarpanel.cxx:185
NXWidgets::CScrollingPanel
Definition: cscrollingpanel.hxx:105
NXWidgets::CScrollbarPanel
Definition: cscrollbarpanel.hxx:108
cgraphicsport.hxx
NXWidgets::CScrollbarPanel::m_widgetControl
CWidgetControl * m_widgetControl
Definition: cscrollbarpanel.hxx:112
NXWidgets::CScrollbarPanel::m_hasHorizontalScrollbar
bool m_hasHorizontalScrollbar
Definition: cscrollbarpanel.hxx:123
NXWidgets::CScrollbarPanel::jump
virtual void jump(int32_t x, int32_t y)
Definition: cscrollbarpanel.cxx:151
cwidgetstyle.hxx
NXWidgets::IScrollable
Definition: iscrollable.hxx:102
NXWidgets::CScrollbarPanel::getPanel
CScrollingPanel * getPanel(void)
Definition: cscrollbarpanel.hxx:299
NXWidgets::CScrollbarPanel::m_hasVerticalScrollbar
bool m_hasVerticalScrollbar
Definition: cscrollbarpanel.hxx:121
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::CScrollbarPanel::~CScrollbarPanel
virtual ~CScrollbarPanel(void)
Definition: cscrollbarpanel.hxx:146
NXWidgets::CScrollbarPanel::m_scrollbarHorizontal
CScrollbarHorizontal * m_scrollbarHorizontal
Definition: cscrollbarpanel.hxx:115
NXWidgets::CScrollbarPanel::m_scrollbarWidth
uint8_t m_scrollbarWidth
Definition: cscrollbarpanel.hxx:117
NXWidgets::CScrollbarPanel::setAllowsVerticalScroll
virtual void setAllowsVerticalScroll(bool allow)
Definition: cscrollbarpanel.cxx:162
NXWidgets::CScrollbarPanel::getCanvasWidth
virtual const int32_t getCanvasWidth(void) const
Definition: cscrollbarpanel.cxx:276
NXWidgets::CScrollbarPanel::m_scrollbarVertical
CScrollbarVertical * m_scrollbarVertical
Definition: cscrollbarpanel.hxx:116
NXWidgets::CScrollbarPanel::setCanvasHeight
virtual void setCanvasHeight(const int32_t height)
Definition: cscrollbarpanel.cxx:220
NXWidgets::CScrollbarPanel::getCanvasX
virtual const int32_t getCanvasX(void) const
Definition: cscrollbarpanel.cxx:254
NXWidgets::CScrollbarPanel::handleScrollEvent
void handleScrollEvent(const CWidgetEventArgs &e)
Definition: cscrollbarpanel.cxx:298
NXWidgets::CScrollbarPanel::m_panel
CScrollingPanel * m_panel
Definition: cscrollbarpanel.hxx:113
NXWidgets::CScrollbarPanel::getCanvasY
virtual const int32_t getCanvasY(void) const
Definition: cscrollbarpanel.cxx:265
NXWidgets::CScrollbarPanel::scroll
virtual void scroll(int32_t dx, int32_t dy)
Definition: cscrollbarpanel.cxx:139
NXWidgets::CScrollbarPanel::drawContents
virtual void drawContents(CGraphicsPort *port)
Definition: cscrollbarpanel.cxx:435
NXWidgets::CWidgetEventArgs
Definition: cwidgeteventargs.hxx:127
NXWidgets::CScrollbarPanel::handleValueChangeEvent
void handleValueChangeEvent(const CWidgetEventArgs &e)
Definition: cscrollbarpanel.cxx:326
NXWidgets::CScrollbarHorizontal
Definition: cscrollbarhorizontal.hxx:114
NXWidgets::CScrollbarPanel::allowsVerticalScroll
virtual bool allowsVerticalScroll(void) const
Definition: cscrollbarpanel.cxx:232
NXWidgets::CScrollbarPanel::buildUI
void buildUI(void)
Definition: cscrollbarpanel.cxx:355
cnxwidget.hxx
cscrollingpanel.hxx
NXWidgets::CScrollbarVertical
Definition: cscrollbarvertical.hxx:113
cscrollbarhorizontal.hxx
NXWidgets::CScrollbarPanel::m_scrollbarHeight
uint8_t m_scrollbarHeight
Definition: cscrollbarpanel.hxx:119
cwidgeteventhandler.hxx
NXWidgets::CGraphicsPort
Definition: cgraphicsport.hxx:106