NXWidgets  1.19
nxconfig.hxx
Go to the documentation of this file.
1 /****************************************************************************
2  * NxWidgets/libnxwidgets/include/nxconfig.hxx
3  *
4  * Copyright (C) 2012-2017 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 #ifndef __INCLUDE_NXCONFIG_HXX
37 #define __INCLUDE_NXCONFIG_HXX
38 
39 /****************************************************************************
40  * Included Files
41  ****************************************************************************/
42 
43 #include <nuttx/config.h>
44 
45 #include <stdint.h>
46 #include <stdbool.h>
47 
48 #include <nuttx/video/rgbcolors.h>
49 #include <nuttx/nx/nxfonts.h>
50 
51 /****************************************************************************
52  * Pre-Processor Definitions
53  ****************************************************************************/
54 /* NX Configuration *********************************************************/
55 /**
56  * Prerequisites:
57  *
58  * CONFIG_HAVE_CXX=y : C++ support is required
59  * CONFIG_NX=y : NX graphics support must be enabled
60  * CONFIG_NX_XYINPUT=y : Required to enable NX mouse/touchscreen support
61  * CONFIG_NX_KBD=y : Required to enabled NX keyboard support
62  * CONFIG_NX_NPLANES=1 : Only a single video plane is supported
63  *
64  * NX Server/Device Configuration
65  *
66  * CONFIG_NXSTART_SERVERPRIO - Priority of the NX server.
67  * Default: (SCHED_PRIORITY_DEFAULT+10). NOTE: Of the three priority
68  * definitions here, CONFIG_NXSTART_SERVERPRIO should have the highest
69  * priority to avoid data overrun race conditions. Such errors would most
70  * likely appear as duplicated rows of data on the display.
71  * CONFIG_NXWIDGETS_CLIENTPRIO - The thread that calls CNxServer::connect()
72  * will be re-prioritized to this priority. Default:
73  * SCHED_PRIORITY_DEFAULT
74  * CONFIG_NXWIDGETS_LISTENERPRIO - Priority of the NX event listener thread.
75  * Default: SCHED_PRIORITY_DEFAULT
76  * CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
77  * mode). Default 2048
78  * CONFIG_NXWIDGET_EVENTWAIT - Build in support for external window event, modal
79  * loop management logic. This includes methods to wait for windows events
80  * to occur so that looping logic can sleep until something interesting
81  * happens with the window.
82  *
83  * NXWidget Configuration
84  *
85  * CONFIG_NXWIDGETS_BPP - Supported bits-per-pixel {8, 16, 24, 32}. Default:
86  * The smallest BPP configuration supported by NX.
87  * CONFIG_NXWIDGETS_SIZEOFCHAR - Size of character {1 or 2 bytes}. Default
88  * Determined by CONFIG_NXWIDGETS_SIZEOFCHAR
89  *
90  * NXWidget Default Values
91  *
92  * CONFIG_NXWIDGETS_DEFAULT_FONTID - Default font ID. Default: NXFONT_DEFAULT
93  * CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE, CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT -
94  * Default dynamic array parameters. Default: 16, 8
95  *
96  * CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR - Normal background color. Default:
97  * MKRGB(148,189,215)
98  * CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR - Default selected background
99  * color. Default: MKRGB(206,227,241)
100  * CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR - Shiny side boarder color. Default
101  * MKRGB(248,248,248)
102  * CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR - Shadowed side border color.
103  * Default: MKRGB(35,58,73)
104  * CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR - Highlight color. Default:
105  * MKRGB(192,192,192)
106  * CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR - Text color on a disabled widget:
107  * Default: MKRGB(192,192,192)
108  * CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR - Text color on a enabled widget:
109  * Default: MKRGB(248,248,248)
110  * CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR - Text color on a selected widget:
111  * Default: MKRGB(0,0,0)
112  * CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR - Default font color: Default:
113  * MKRGB(255,255,255)
114  * CONFIG_NXWIDGETS_TRANSPARENT_COLOR - Transparent color: Default: MKRGB(0,0,0)
115  *
116  * Keypad behavior
117  *
118  * CONFIG_NXWIDGETS_FIRST_REPEAT_TIME - Time taken before a key starts
119  * repeating (in milliseconds). Default: 500
120  * CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME - Time taken before a repeating key
121  * repeats again (in milliseconds). Default: 200
122  * CONFIG_NXWIDGETS_DOUBLECLICK_TIME - Left button release-press time for
123  * double click (in milliseconds). Default: 350
124  * CONFIG_NXWIDGETS_KBDBUFFER_SIZE - Size of incoming character buffer, i.e.,
125  * the maximum number of characters that can be entered between NX polling
126  * cycles without losing data.
127  * CONFIG_NXWIDGETS_CURSORCONTROL_SIZE - Size of incoming cursor control
128  * buffer, i.e., the maximum number of cursor controls that can between
129  * entered by NX polling cycles without losing data. Default: 4
130  */
131 
132 /* Prerequisites ************************************************************/
133 /**
134  * C++ support is required
135  */
136 
137 #ifndef CONFIG_HAVE_CXX
138 # error "C++ support is required (CONFIG_HAVE_CXX)"
139 #endif
140 
141 /**
142  * NX graphics support must be enabled
143  */
144 
145 #ifndef CONFIG_NX
146 # error "NX graphics support is required (CONFIG_NX)"
147 #endif
148 
149 /**
150  * Required to enable NX mouse/touchscreen support
151  */
152 
153 #ifndef CONFIG_NX_XYINPUT
154 # warning "NX mouse/touchscreen support is required (CONFIG_NX_XYINPUT)"
155 #endif
156 
157 /**
158  * Required to enabled NX keyboard support
159  */
160 
161 #ifndef CONFIG_NX_KBD
162 # warning "NX keyboard support is required (CONFIG_NX_KBD)"
163 #endif
164 
165 /**
166  * Only a single video plane is supported
167  */
168 
169 #ifndef CONFIG_NX_NPLANES
170 # define CONFIG_NX_NPLANES 1
171 #endif
172 
173 #if CONFIG_NX_NPLANES != 1
174 # error "Only a single color plane is supported (CONFIG_NX_NPLANES)"
175 #endif
176 
177 /* NxTerm checks. This just simplifies the conditional compilation by
178  * reducing the AND of these three conditions to a single condition.
179  */
180 
181 #if !defined(CONFIG_NX_KBD) || !defined(CONFIG_NXTERM)
182 # undef CONFIG_NXTERM_NXKBDIN
183 #endif
184 
185 /* NX Server/Device Configuration *******************************************/
186 /**
187  * Priority of the NX server (in multi-user mode)
188  */
189 
190 #ifndef CONFIG_NXWIDGETS_CLIENTPRIO
191 # define CONFIG_NXWIDGETS_CLIENTPRIO SCHED_PRIORITY_DEFAULT
192 #endif
193 
194 #if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO
195 # warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO"
196 # warning" -- This can result in data overrun errors"
197 #endif
198 
199 /**
200  * Priority of the NX event listener thread (in multi-user mode)
201  */
202 
203 #ifndef CONFIG_NXWIDGETS_LISTENERPRIO
204 # define CONFIG_NXWIDGETS_LISTENERPRIO SCHED_PRIORITY_DEFAULT
205 #endif
206 
207 #if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO
208 # warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO"
209 # warning" -- This can result in data overrun errors"
210 #endif
211 
212 /**
213  * NX listener thread stack size (in multi-user mode)
214  */
215 
216 #ifndef CONFIG_NXWIDGETS_LISTENERSTACK
217 # define CONFIG_NXWIDGETS_LISTENERSTACK 2048
218 #endif
219 
220 /* NXWidget Configuration ***************************************************/
221 /**
222  * Bits per pixel
223  */
224 
225 #ifndef CONFIG_NXWIDGETS_BPP
226 # if !defined(CONFIG_NX_DISABLE_8BPP)
227 # warning "Assuming 8-bits per pixel, RGB 3:3:2"
228 # define CONFIG_NXWIDGETS_BPP 8
229 # elif !defined(CONFIG_NX_DISABLE_16BPP)
230 # warning "Assuming 16-bits per pixel, RGB 5:6:5"
231 # define CONFIG_NXWIDGETS_BPP 16
232 # elif !defined(CONFIG_NX_DISABLE_24BPP)
233 # warning "Assuming 24-bits per pixel, RGB 8:8:8"
234 # define CONFIG_NXWIDGETS_BPP 24
235 # elif !defined(CONFIG_NX_DISABLE_32BPP)
236 # warning "Assuming 32-bits per pixel, RGB 8:8:8"
237 # define CONFIG_NXWIDGETS_BPP 32
238 # else
239 # error "No supported pixel depth is enabled"
240 # endif
241 #endif
242 
243 #if CONFIG_NXWIDGETS_BPP == 8
244 # ifdef CONFIG_NX_DISABLE_8BPP
245 # error "NX 8-bit support is disabled (CONFIG_NX_DISABLE_8BPP)"
246 # endif
247 # define CONFIG_NXWIDGETS_FMT FB_FMT_RGB8_332
248 # define MKRGB RGBTO8
249 # define RGB2RED RGB8RED
250 # define RGB2GREEN RGB8GREEN
251 # define RGB2BLUE RGB8BLUE
252 # define FONT_RENDERER nxf_convert_8bpp
253 #elif CONFIG_NXWIDGETS_BPP == 16
254 # ifdef CONFIG_NX_DISABLE_16BPP
255 # error "NX 16-bit support is disabled (CONFIG_NX_DISABLE_16BPP)"
256 # endif
257 # define CONFIG_NXWIDGETS_FMT FB_FMT_RGB16_565
258 # define MKRGB RGBTO16
259 # define RGB2RED RGB16RED
260 # define RGB2GREEN RGB16GREEN
261 # define RGB2BLUE RGB16BLUE
262 # define FONT_RENDERER nxf_convert_16bpp
263 #elif CONFIG_NXWIDGETS_BPP == 24
264 # ifdef CONFIG_NX_DISABLE_24BPP
265 # error "NX 24-bit support is disabled (CONFIG_NX_DISABLE_24BPP)"
266 # endif
267 # define CONFIG_NXWIDGETS_FMT FB_FMT_RGB24
268 # define MKRGB RGBTO24
269 # define RGB2RED RGB24RED
270 # define RGB2GREEN RGB24GREEN
271 # define RGB2BLUE RGB24BLUE
272 # define FONT_RENDERER nxf_convert_24bpp
273 #elif CONFIG_NXWIDGETS_BPP == 32
274 # ifdef CONFIG_NX_DISABLE_32BPP
275 # error "NX 32-bit support is disabled (CONFIG_NX_DISABLE_32BPP)"
276 # endif
277 # define CONFIG_NXWIDGETS_FMT FB_FMT_RGB32
278 # define MKRGB RGBTO24
279 # define RGB2RED RGB24RED
280 # define RGB2GREEN RGB24GREEN
281 # define RGB2BLUE RGB24BLUE
282 # define FONT_RENDERER nxf_convert_32bpp
283 #else
284 # error "Pixel depth not supported (CONFIG_NXWIDGETS_BPP)"
285 #endif
286 
287 /* Size of a character */
288 
289 #ifndef CONFIG_NXWIDGETS_SIZEOFCHAR
290 # if CONFIG_NXFONTS_CHARBITS <= 8
291 # define CONFIG_NXWIDGETS_SIZEOFCHAR 1
292 # else
293 # define CONFIG_NXWIDGETS_SIZEOFCHAR 2
294 # endif
295 #endif
296 
297 #if CONFIG_NXWIDGETS_SIZEOFCHAR != 1 && CONFIG_NXWIDGETS_SIZEOFCHAR != 2
298 # error "Unsupported character width (CONFIG_NXWIDGETS_SIZEOFCHAR)"
299 #endif
300 
301 /* NXWidget Default Values **************************************************/
302 /**
303  * Default font ID
304  */
305 
306 #ifndef CONFIG_NXWIDGETS_DEFAULT_FONTID
307 # define CONFIG_NXWIDGETS_DEFAULT_FONTID NXFONT_DEFAULT
308 #endif
309 
310 /**
311  * Default dynamic array parameters
312  */
313 
314 #ifndef CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE
315 # define CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE 16
316 #endif
317 
318 #ifndef CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT
319 # define CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT 8
320 #endif
321 
322 /**
323  * Normal background color
324  */
325 
326 #ifndef CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
327 # define CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR MKRGB(148,189,215)
328 #endif
329 
330 /**
331  * Default selected background color
332  */
333 
334 #ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR
335 # define CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(206,227,241)
336 #endif
337 
338 /**
339  * Shiny side border color
340  */
341 
342 #ifndef CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR
343 # define CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
344 #endif
345 
346 /**
347  * Shadowed side border color
348  */
349 
350 #ifndef CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR
351 # define CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR MKRGB(35,58,73)
352 #endif
353 
354 /**
355  * Highlight color
356  */
357 
358 #ifndef CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR
359 # define CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR MKRGB(192,192,192)
360 #endif
361 
362 /* Text colors */
363 
364 #ifndef CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR
365 # define CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR MKRGB(192,192,192)
366 #endif
367 
368 #ifndef CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR
369 # define CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR MKRGB(248,248,248)
370 #endif
371 
372 #ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR
373 # define CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR MKRGB(0,0,0)
374 #endif
375 
376 /**
377  * Default font color
378  */
379 
380 #ifndef CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
381 # define CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR MKRGB(255,255,255)
382 #endif
383 
384 /**
385  * Transparent color
386  */
387 
388 #ifndef CONFIG_NXWIDGETS_TRANSPARENT_COLOR
389 # define CONFIG_NXWIDGETS_TRANSPARENT_COLOR MKRGB(0,0,0)
390 #endif
391 
392 /* Keypad behavior **********************************************************/
393 /**
394  * Time taken before a key starts repeating (in milliseconds).
395  */
396 
397 #ifndef CONFIG_NXWIDGETS_FIRST_REPEAT_TIME
398 # define CONFIG_NXWIDGETS_FIRST_REPEAT_TIME 500
399 #endif
400 
401 /**
402  * Time taken before a repeating key repeats again (in milliseconds).
403  */
404 
405 #ifndef CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME
406 # define CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME 200
407 #endif
408 
409 /**
410  * Left button release-press time for double click (in milliseconds).
411  */
412 
413 #ifndef CONFIG_NXWIDGETS_DOUBLECLICK_TIME
414 # define CONFIG_NXWIDGETS_DOUBLECLICK_TIME 350
415 #endif
416 
417 /**
418  * Size of incoming character buffer, i.e., the maximum number of characters
419  * that can be entered between NX polling cycles without losing data.
420  */
421 
422 #ifndef CONFIG_NXWIDGETS_KBDBUFFER_SIZE
423 # define CONFIG_NXWIDGETS_KBDBUFFER_SIZE 8
424 #endif
425 
426 /**
427  * Size of incoming cursor control buffer, i.e., the maximum number of cursor
428  * controls that can between entered by NX polling cycles without losing data.
429  */
430 
431 #ifndef CONFIG_NXWIDGETS_CURSORCONTROL_SIZE
432 # define CONFIG_NXWIDGETS_CURSORCONTROL_SIZE 4
433 #endif
434 
435 /****************************************************************************
436  * Public Types
437  ****************************************************************************/
438 
439 namespace NXWidgets
440 {
441 #if CONFIG_NXWIDGETS_BPP == 8
442  typedef uint8_t nxwidget_pixel_t;
443 #elif CONFIG_NXWIDGETS_BPP == 16
444  typedef uint16_t nxwidget_pixel_t;
445 #elif CONFIG_NXWIDGETS_BPP == 24
446  typedef uint32_t nxwidget_pixel_t;
447 #elif CONFIG_NXWIDGETS_BPP == 32
448  typedef uint32_t nxwidget_pixel_t;
449 #else
450 # error "Pixel depth is unknown"
451 #endif
452 
453 #if CONFIG_NXWIDGETS_SIZEOFCHAR == 2
454  typedef uint16_t nxwidget_char_t;
455 #elif CONFIG_NXWIDGETS_SIZEOFCHAR == 1
456  typedef uint8_t nxwidget_char_t;
457 #else
458 # error "Character width is unknown"
459 #endif
460 }
461 
462 /****************************************************************************
463  * Implementation Classes
464  ****************************************************************************/
465 
466 #endif // __INCLUDE_NXCONFIG_HXX
uint8_t nxwidget_char_t
Definition: nxconfig.hxx:456
uint8_t nxwidget_pixel_t
Definition: nxconfig.hxx:442
uint16_t nxwidget_char_t
Definition: nxconfig.hxx:454
uint16_t nxwidget_pixel_t
Definition: nxconfig.hxx:444
uint32_t nxwidget_pixel_t
Definition: nxconfig.hxx:446