NXWidgets: iscrollable.hxx Source File

NXWidgets 1.19

iscrollable.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/iscrollable.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_ISCROLLABLE_HXX
71 #define __INCLUDE_ISCROLLABLE_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 /****************************************************************************
85 * Pre-Processor Definitions
86 ****************************************************************************/
87
88 /****************************************************************************
89 * Implementation Classes
90 ****************************************************************************/
91
92 #if defined(__cplusplus)
93
94 namespace NXWidgets
95 {
96 /**
97 * Abstract class defining basic functionality of scrolling widgets.
98 * Scrolling regions are modelled as a virtual "canvas", or rectangular
99 * region, with height/width dimensions and x/y coordinates.
100 */
101
102 class IScrollable
103 {
104 public:
105 /**
106 * A virtual destructor is required in order to override the IScrollable
107 * destructor. We do this because if we delete IScrollable, we want the
108 * destructor of the class that inherits from IScrollable to run, not this
109 * one.
110 */
111
112 virtual ~IScrollable(void) { }
113
114 /**
115 * Gets the x coordinate of the virtual canvas.
116 *
117 * @return The x coordinate of the virtual canvas.
118 */
119
120 virtual const int32_t getCanvasX(void) const = 0;
121
122 /**
123 * Gets the y coordinate of the virtual canvas.
124 *
125 * @return The y coordinate of the virtual canvas.
126 */
127
128 virtual const int32_t getCanvasY(void) const = 0;
129
130 /**
131 * Gets the width of the virtual canvas.
132 *
133 * @return The width of the virtual canvas.
134 */
135
136 virtual const int32_t getCanvasWidth(void) const = 0;
137
138 /**
139 * Gets the height of the virtual canvas.
140 *
141 * @return The height of the virtual canvas.
142 */
143
144 virtual const int32_t getCanvasHeight(void) const = 0;
145
146 /**
147 * Scrolls the virtual canvas by the specified amounts.
148 *
149 * @param dx Distance to scroll horizontally.
150 * @param dy Distance to scroll vertically.
151 */
152
153 virtual void scroll(int32_t dx, int32_t dy) = 0;
154
155 /**
156 * Repositions the virtual canvas to the specified coordinates.
157 *
158 * @param x New x coordinate of the virtual canvas.
159 * @param y New y coordinate of the virtual canvas.
160 */
161
162 virtual void jump(int32_t x, int32_t y) = 0;
163
164 /**
165 * Returns true if vertical scrolling is allowed.
166 *
167 * @return True if vertical scrolling is allowed.
168 */
169
170 virtual bool allowsVerticalScroll(void) const = 0;
171
172 /**
173 * Returns true if horizontal scrolling is allowed.
174 *
175 * @return True if horizontal scrolling is allowed.
176 */
177
178 virtual bool allowsHorizontalScroll(void) const = 0;
179
180 /**
181 * Set whether or not horizontal scrolling is allowed.
182 *
183 * @param allow True to allow horizontal scrolling; false to deny it.
184 */
185
186 virtual void setAllowsVerticalScroll(bool allow) = 0;
187
188 /**
189 * Set whether or not horizontal scrolling is allowed.
190 *
191 * @param allow True to allow horizontal scrolling; false to deny it.
192 */
193
194 virtual void setAllowsHorizontalScroll(bool allow) = 0;
195
196 /**
197 * Sets the width of the virtual canvas.
198 *
199 * @param width The width of the virtual canvas.
200 */
201
202 virtual void setCanvasWidth(const int32_t width) = 0;
203
204 /**
205 * Sets the height of the virtual canvas.
206 *
207 * @param height The height of the virtual canvas.
208 */
209
210 virtual void setCanvasHeight(const int32_t height) = 0;
211 };
212 }
213
214 #endif // __cplusplus
215
216 #endif // __INCLUDE_ISCROLLABLE_HXX
217
NXWidgets::IScrollable::getCanvasX
virtual const int32_t getCanvasX(void) const =0
NXWidgets::IScrollable::jump
virtual void jump(int32_t x, int32_t y)=0
NXWidgets::IScrollable::getCanvasWidth
virtual const int32_t getCanvasWidth(void) const =0
NXWidgets::IScrollable::setCanvasWidth
virtual void setCanvasWidth(const int32_t width)=0
NXWidgets::IScrollable
Definition: iscrollable.hxx:102
NXWidgets::IScrollable::getCanvasY
virtual const int32_t getCanvasY(void) const =0
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::IScrollable::setCanvasHeight
virtual void setCanvasHeight(const int32_t height)=0
NXWidgets::IScrollable::~IScrollable
virtual ~IScrollable(void)
Definition: iscrollable.hxx:112
NXWidgets::IScrollable::allowsHorizontalScroll
virtual bool allowsHorizontalScroll(void) const =0
NXWidgets::IScrollable::allowsVerticalScroll
virtual bool allowsVerticalScroll(void) const =0
NXWidgets::IScrollable::setAllowsHorizontalScroll
virtual void setAllowsHorizontalScroll(bool allow)=0
NXWidgets::IScrollable::getCanvasHeight
virtual const int32_t getCanvasHeight(void) const =0
NXWidgets::IScrollable::setAllowsVerticalScroll
virtual void setAllowsVerticalScroll(bool allow)=0
NXWidgets::IScrollable::scroll
virtual void scroll(int32_t dx, int32_t dy)=0