NXWidgets  1.19
cglyphsliderhorizontalgrip.hxx
Go to the documentation of this file.
1 /****************************************************************************
2  * NxWidgets/libnxwidgets/include/cglyphsliderhorizontalgrip.hxx
3  *
4  * Copyright (C) 2012 Ken Pettit. All rights reserved.
5  * Author: Ken Pettit <pettitkd@gmail.com>
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_CGLYPHSLIDERHORIZONTALGRIP_HXX
71 #define __INCLUDE_CGLYPHSLIDERHORIZONTALGRIP_HXX
72 
73 /****************************************************************************
74  * Included Files
75  ****************************************************************************/
76 
78 #include "cimage.hxx"
79 
80 /****************************************************************************
81  * Pre-Processor Definitions
82  ****************************************************************************/
83 
84 /****************************************************************************
85  * Implementation Classes
86  ****************************************************************************/
87 
88 #if defined(__cplusplus)
89 
90 namespace NXWidgets
91 {
92  class IBitmap;
93 
94  /**
95  * Class representing the grip, or draggable button, with a horizontal
96  * slider.
97  */
98 
100  {
101  protected:
102 
103  /**
104  * The CImage to represent the grip.
105  */
106 
107  //CImage* m_pImage;
108 
109  /**
110  * Draw the area of this widget that falls within the clipping region.
111  * Called by the redraw() function to draw all visible regions.
112  *
113  * @param port The CGraphicsPort to draw to.
114  * @see redraw()
115  */
116 
117  //virtual void drawContents(CGraphicsPort *port);
118 
119  /**
120  * Draw the area of this widget that falls within the clipping region.
121  * Called by the redraw() function to draw all visible regions.
122  *
123  * @param port The CGraphicsPort to draw to.
124  * @see redraw()
125  */
126 
127  //virtual void drawBorder(CGraphicsPort *port);
128 
129  /**
130  * Resize the slider to the new dimensions.
131  *
132  * @param width The new width.
133  * @param height The new height.
134  */
135 
136  virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
137 
138  /**
139  * Starts dragging the grip and redraws it.
140  *
141  * @param x The x coordinate of the click.
142  * @param y The y coordinate of the click.
143  */
144 
145  virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
146 
147  /**
148  * Redraws the grip.
149  *
150  * @param x The x coordinate of the mouse.
151  * @param y The y coordinate of the mouse.
152  */
153 
154  virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
155 
156  /**
157  * Redraws the grip.
158  *
159  * @param x The x coordinate of the mouse.
160  * @param y The y coordinate of the mouse.
161  */
162 
163  virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
164 
165  /**
166  * Moves the grip to follow the mouse.
167  *
168  * @param x The x coordinate of the mouse.
169  * @param y The y coordinate of the mouse.
170  * @param vX The horizontal distance of the drag.
171  * @param vY The vertical distance of the drag.
172  */
173 
174  virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
175  nxgl_coord_t vX, nxgl_coord_t vY);
176 
177  public:
178 
179  /**
180  * Constructor.
181  *
182  * @param pWidgetControl The controlling widget for the display
183  * @param x The x coordinate of the grip, relative to its parent.
184  * @param y The y coordinate of the grip, relative to its parent.
185  * @param width The width of the grip.
186  * @param height The height of the grip.
187  */
188 
190  nxgl_coord_t x, nxgl_coord_t y,
191  nxgl_coord_t width, nxgl_coord_t height,
192  IBitmap *pGripBitmap);
193 
194 
195  /**
196  * Destructor.
197  */
198 
199  virtual inline ~CGlyphSliderHorizontalGrip(void) { }
200  };
201 }
202 
203 #endif // __cplusplus
204 
205 #endif // __INCLUDE_CGLYPHSLIDERHORIZONTALGRIP_HXX
206 
virtual void onClick(nxgl_coord_t x, nxgl_coord_t y)
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height)
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y)
CGlyphSliderHorizontalGrip(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, IBitmap *pGripBitmap)
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)