NXWidgets: ibitmap.hxx Source File

NXWidgets 1.19

ibitmap.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/include/ibitmap.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_IBITMAP_HXX
71 #define __INCLUDE_IBITMAP_HXX
72
73 /****************************************************************************
74 * Included Files
75 ****************************************************************************/
76
77 #include <nuttx/config.h>
78
79 #include <sys/types.h>
80 #include <stdint.h>
81 #include <stdbool.h>
82
83 #include <nuttx/nx/nxglib.h>
84
85 /****************************************************************************
86 * Pre-Processor Definitions
87 ****************************************************************************/
88
89 /****************************************************************************
90 * Implementation Classes
91 ****************************************************************************/
92
93 #if defined(__cplusplus)
94
95 namespace NXWidgets
96 {
97 /**
98 * Abstract class defining the basic properties of a source bitmap. The
99 * primary intent of this class is two support a variety of sources of
100 * bitmap data with various kinds of compression.
101 */
102
103 class IBitmap
104 {
105 public:
106 /**
107 * A virtual destructor is required in order to override the IBitmap
108 * destructor. We do this because if we delete IBitmap, we want the
109 * destructor of the class that inherits from IBitmap to run, not this
110 * one.
111 */
112
113 virtual ~IBitmap(void) { }
114
115 /**
116 * Get the bitmap's color format.
117 *
118 * @return The bitmap's color format.
119 */
120
121 virtual const uint8_t getColorFormat(void) const = 0;
122
123 /**
124 * Get the bitmap's color format.
125 *
126 * @return The bitmap's color format.
127 */
128
129 virtual const uint8_t getBitsPerPixel(void) const = 0;
130
131 /**
132 * Get the bitmap's width (in pixels/columns).
133 *
134 * @return The bitmap's width (in pixels/columns).
135 */
136
137 virtual const nxgl_coord_t getWidth(void) const = 0;
138
139 /**
140 * Get the bitmap's height (in rows).
141 *
142 * @return The bitmap's height (in rows).
143 */
144
145 virtual const nxgl_coord_t getHeight(void) const = 0;
146
147 /**
148 * Get the bitmap's width (in bytes).
149 *
150 * @return The bitmap's width.
151 */
152
153 virtual const size_t getStride(void) const = 0;
154
155 /**
156 * Use the colors associated with a selected image.
157 *
158 * @param selected. true: Use colors for a selected widget,
159 * false: Use normal (default) colors.
160 */
161
162 virtual void setSelected(bool selected) = 0;
163
164 /**
165 * Get one row from the bit map image using the selected colors.
166 *
167 * @param x The offset into the row to get
168 * @param y The row number to get
169 * @param width The number of pixels to get from the row
170 * @param data The memory location provided by the caller
171 * in which to return the data. This should be at least
172 * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
173 * and properly aligned for the pixel color format.
174 * @param True if the run was returned successfully.
175 */
176
177 virtual bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
178 FAR void *data) = 0;
179 };
180 }
181
182 #endif // __cplusplus
183
184 #endif // __INCLUDE_IBITMAP_HXX
NXWidgets::IBitmap::getRun
virtual bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, FAR void *data)=0
NXWidgets::IBitmap::getHeight
virtual const nxgl_coord_t getHeight(void) const =0
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::IBitmap::getStride
virtual const size_t getStride(void) const =0
NXWidgets::IBitmap::getWidth
virtual const nxgl_coord_t getWidth(void) const =0
NXWidgets::IBitmap::setSelected
virtual void setSelected(bool selected)=0
NXWidgets::IBitmap::getBitsPerPixel
virtual const uint8_t getBitsPerPixel(void) const =0
NXWidgets::IBitmap::getColorFormat
virtual const uint8_t getColorFormat(void) const =0
NXWidgets::IBitmap
Definition: ibitmap.hxx:103
NXWidgets::IBitmap::~IBitmap
virtual ~IBitmap(void)
Definition: ibitmap.hxx:113