summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets/include/nxconfig.hxx
blob: 6043811a6b7efc3480e93a51da8f62399cb26c70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
/****************************************************************************
 * NxWidgets/libnxwidgets/include/nxconfig.hxx
 *
 *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
 *   Author: Gregory Nutt <gnutt@nuttx.org>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
 *    me be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

#ifndef __INCLUDE_NXCONFIG_HXX
#define __INCLUDE_NXCONFIG_HXX

/****************************************************************************
 * Included Files
 ****************************************************************************/

#include <nuttx/config.h>

#include <stdint.h>
#include <stdbool.h>

#include <nuttx/video/rgbcolors.h>
#include <nuttx/nx/nxfonts.h>

/****************************************************************************
 * Pre-Processor Definitions
 ****************************************************************************/
/* NX Configuration *********************************************************/
/**
 * Prerequisites:
 *
 * CONFIG_HAVE_CXX=y   : C++ support is required
 * CONFIG_NX=y         : NX graphics support must be enabled
 * CONFIG_NX_XYINPUT=y : Required to enable NX mouse/touchscreen support
 * CONFIG_NX_KBD=y     : Required to enabled NX keyboard support
 * CONFIG_NX_NPLANES=1 : Only a single video plane is supported
 *
 * NX Server/Device Configuration
 *
 * CONFIG_NXWIDGETS_DEVNO - LCD device number (in case there are more than
 *   one LCDs connected.  Default: 0
 * CONFIG_NXWIDGETS_VPLANE - Only a single video plane is supported. Default: 0
 * CONFIG_NXWIDGETS_SERVERPRIO - Priority of the NX server.  This applies
 *   only if NX is configured in multi-user mode (CONFIG_NX_MULTIUSER=y).
 *   Default: (SCHED_PRIORITY_DEFAULT+10).  NOTE:  Of the three priority
 *   definitions here, CONFIG_NXWIDGETS_SERVERPRIO should have the highest
 *   priority to avoid data overrun race conditions. Such errors would most
 *   likely appear as duplicated rows of data on the display.
 * CONFIG_NXWIDGETS_CLIENTPRIO - The thread that calls CNxServer::connect()
 *   will be re-prioritized to this priority.  This applies only if NX is
 *   configured in multi-user mode (CONFIG_NX_MULTIUSER=y). Default:
 *   SCHED_PRIORITY_DEFAULT
 * CONFIG_NXWIDGETS_LISTENERPRIO - Priority of the NX event listener thread.
 *   This applies only if NX is configured in multi-user mode
 *   (CONFIG_NX_MULTIUSER=y). Default: SCHED_PRIORITY_DEFAULT
 * CONFIG_NXWIDGETS_EXTERNINIT - Define to support external display
 *   initialization.
 * CONFIG_NXWIDGETS_SERVERSTACK - NX server thread stack size (in multi-user
 * mode).  Default 2048
 * CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
 * mode).  Default 2048
 * CONFIG_NXWIDGET_EVENTWAIT - Build in support for external window event, modal
 *   loop management logic.  This includes methods to wait for windows events
 *   to occur so that looping logic can sleep until something interesting
 *   happens with the window.
 *
 * NXWidget Configuration
 *
 * CONFIG_NXWIDGETS_BPP - Supported bits-per-pixel {8, 16, 24, 32}.  Default:
 *   The smallest BPP configuration supported by NX.
 * CONFIG_NXWIDGETS_SIZEOFCHAR - Size of character {1 or 2 bytes}.  Default
 *   Determined by CONFIG_NXWIDGETS_SIZEOFCHAR
 *
 * NXWidget Default Values
 *
 * CONFIG_NXWIDGETS_DEFAULT_FONTID - Default font ID.  Default: NXFONT_DEFAULT
 * CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE, CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT -
 *   Default dynamic array parameters.  Default: 16, 8
 *
 * CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR - Normal background color.  Default:
 *   MKRGB(148,189,215)
 * CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR - Default selected background
 *   color.  Default: MKRGB(206,227,241)
 * CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR - Shiny side boarder color. Default
 *   MKRGB(248,248,248)
 * CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR - Shadowed side border color.
 *   Default: MKRGB(35,58,73)
 * CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR - Highlight color.  Default:
 *   MKRGB(192,192,192)
 * CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR - Text color on a disabled widget:
 *   Default: MKRGB(192,192,192)
 * CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR - Text color on a enabled widget:
 *   Default: MKRGB(248,248,248)
 * CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR - Text color on a selected widget:
 *   Default: MKRGB(0,0,0)
 * CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR - Default font color: Default:
 *   MKRGB(255,255,255)
 * CONFIG_NXWIDGETS_TRANSPARENT_COLOR - Transparent color: Default: MKRGB(0,0,0)
 *
 * Keypad behavior
 *
 * CONFIG_NXWIDGETS_FIRST_REPEAT_TIME - Time taken before a key starts
 *   repeating (in milliseconds).  Default: 500
 * CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME - Time taken before a repeating key
 *   repeats again (in milliseconds).  Default: 200
 * CONFIG_NXWIDGETS_DOUBLECLICK_TIME - Left button release-press time for
 *   double click (in milliseconds).  Default: 350
 * CONFIG_NXWIDGETS_KBDBUFFER_SIZE - Size of incoming character buffer, i.e.,
 *   the maximum number of characters that can be entered between NX polling
 *   cycles without losing data.
 * CONFIG_NXWIDGETS_CURSORCONTROL_SIZE - Size of incoming cursor control
 *   buffer, i.e., the maximum number of cursor controls that can between
 *   entered by NX polling cycles without losing data.  Default: 4
 */

/* Prerequisites ************************************************************/
/**
 * C++ support is required
 */

#ifndef CONFIG_HAVE_CXX
#  error "C++ support is required (CONFIG_HAVE_CXX)"
#endif

/**
 * NX graphics support must be enabled
 */

#ifndef CONFIG_NX
#  error "NX graphics support is required (CONFIG_NX)"
#endif

/**
 * Required to enable NX mouse/touchscreen support
 */

#ifndef CONFIG_NX_XYINPUT
#  warning "NX mouse/touchscreen support is required (CONFIG_NX_XYINPUT)"
#endif

/**
 * Required to enabled NX keyboard support
 */

#ifndef CONFIG_NX_KBD
#  warning "NX keyboard support is required (CONFIG_NX_KBD)"
#endif

/**
 * Only a single video plane is supported
 */

#ifndef CONFIG_NX_NPLANES
#  define CONFIG_NX_NPLANES 1
#endif

#if CONFIG_NX_NPLANES != 1
#  error "Only a single color plane is supported (CONFIG_NX_NPLANES)"
#endif

/* NxTerm checks.  This just simplifies the conditional compilation by
 * reducing the AND of these three conditions to a single condition.
 */

#if !defined(CONFIG_NX_KBD) || !defined(CONFIG_NXTERM)
#  undef CONFIG_NXTERM_NXKBDIN
#endif

/* NX Server/Device Configuration *******************************************/
/**
 * LCD device number (in case there are more than one LCDs connected)
 */

#ifndef CONFIG_NXWIDGETS_DEVNO
#  define CONFIG_NXWIDGETS_DEVNO 0
#endif

/**
 * Only a single video plane is supported
 */

#ifndef CONFIG_NXWIDGETS_VPLANE
#  define CONFIG_NXWIDGETS_VPLANE 0
#endif

/**
 * Priority of the NX server (in multi-user mode)
 */

#ifndef CONFIG_NXWIDGETS_SERVERPRIO
#  define CONFIG_NXWIDGETS_SERVERPRIO (SCHED_PRIORITY_DEFAULT+10)
#endif

#ifndef CONFIG_NXWIDGETS_CLIENTPRIO
#  define CONFIG_NXWIDGETS_CLIENTPRIO SCHED_PRIORITY_DEFAULT
#endif

#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO
#  warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO"
#  warning" -- This can result in data overrun errors"
#endif

/**
 * NX server thread stack size (in multi-user mode)
 */

#ifndef CONFIG_NXWIDGETS_SERVERSTACK
#  define CONFIG_NXWIDGETS_SERVERSTACK 2048
#endif

/**
 * Priority of the NX event listener thread (in multi-user mode)
 */

#ifndef CONFIG_NXWIDGETS_LISTENERPRIO
#  define CONFIG_NXWIDGETS_LISTENERPRIO SCHED_PRIORITY_DEFAULT
#endif

#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO
#  warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO"
#  warning" -- This can result in data overrun errors"
#endif

/**
 * NX listener thread stack size (in multi-user mode)
 */

#ifndef CONFIG_NXWIDGETS_LISTENERSTACK
#  define CONFIG_NXWIDGETS_LISTENERSTACK 2048
#endif

/* NXWidget Configuration ***************************************************/
/**
 * Bits per pixel
 */

#ifndef CONFIG_NXWIDGETS_BPP
#  if !defined(CONFIG_NX_DISABLE_8BPP)
#    warning "Assuming 8-bits per pixel, RGB 3:3:2"
#    define CONFIG_NXWIDGETS_BPP 8
#  elif !defined(CONFIG_NX_DISABLE_16BPP)
#    warning "Assuming 16-bits per pixel, RGB 5:6:5"
#    define CONFIG_NXWIDGETS_BPP 16
#  elif !defined(CONFIG_NX_DISABLE_24BPP)
#    warning "Assuming 24-bits per pixel, RGB 8:8:8"
#    define CONFIG_NXWIDGETS_BPP 24
#  elif !defined(CONFIG_NX_DISABLE_32BPP)
#    warning "Assuming 32-bits per pixel, RGB 8:8:8"
#    define CONFIG_NXWIDGETS_BPP 32
#  else
#    error "No supported pixel depth is enabled"
#  endif
#endif

#if CONFIG_NXWIDGETS_BPP == 8
#  ifdef CONFIG_NX_DISABLE_8BPP
#    error "NX 8-bit support is disabled (CONFIG_NX_DISABLE_8BPP)"
#  endif
#  define CONFIG_NXWIDGETS_FMT FB_FMT_RGB8_332
#  define MKRGB                RGBTO8
#  define RGB2RED              RGB8RED
#  define RGB2GREEN            RGB8GREEN
#  define RGB2BLUE             RGB8BLUE
#  define FONT_RENDERER        nxf_convert_8bpp
#elif CONFIG_NXWIDGETS_BPP == 16
#  ifdef CONFIG_NX_DISABLE_16BPP
#    error "NX 16-bit support is disabled (CONFIG_NX_DISABLE_16BPP)"
#  endif
#  define CONFIG_NXWIDGETS_FMT FB_FMT_RGB16_565
#  define MKRGB                RGBTO16
#  define RGB2RED              RGB16RED
#  define RGB2GREEN            RGB16GREEN
#  define RGB2BLUE             RGB16BLUE
#  define FONT_RENDERER        nxf_convert_16bpp
#elif CONFIG_NXWIDGETS_BPP == 24
#  ifdef CONFIG_NX_DISABLE_24BPP
#    error "NX 24-bit support is disabled (CONFIG_NX_DISABLE_24BPP)"
#  endif
#  define CONFIG_NXWIDGETS_FMT FB_FMT_RGB24
#  define MKRGB                RGBTO24
#  define RGB2RED              RGB24RED
#  define RGB2GREEN            RGB24GREEN
#  define RGB2BLUE             RGB24BLUE
#  define FONT_RENDERER        nxf_convert_24bpp
#elif CONFIG_NXWIDGETS_BPP == 32
#  ifdef CONFIG_NX_DISABLE_32BPP
#    error "NX 32-bit support is disabled (CONFIG_NX_DISABLE_32BPP)"
#  endif
#  define CONFIG_NXWIDGETS_FMT FB_FMT_RGB32
#  define MKRGB                RGBTO24
#  define RGB2RED              RGB24RED
#  define RGB2GREEN            RGB24GREEN
#  define RGB2BLUE             RGB24BLUE
#  define FONT_RENDERER        nxf_convert_32bpp
#else
#  error "Pixel depth not supported (CONFIG_NXWIDGETS_BPP)"
#endif

/* Size of a character */

#ifndef CONFIG_NXWIDGETS_SIZEOFCHAR
# if CONFIG_NXFONTS_CHARBITS <= 8
#    define CONFIG_NXWIDGETS_SIZEOFCHAR 1
# else
#    define CONFIG_NXWIDGETS_SIZEOFCHAR 2
# endif
#endif

#if CONFIG_NXWIDGETS_SIZEOFCHAR != 1 && CONFIG_NXWIDGETS_SIZEOFCHAR != 2
#  error "Unsupported character width (CONFIG_NXWIDGETS_SIZEOFCHAR)"
#endif

/* NXWidget Default Values **************************************************/
/**
 * Default font ID
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_FONTID
#  define CONFIG_NXWIDGETS_DEFAULT_FONTID NXFONT_DEFAULT
#endif

/**
 * Default dynamic array parameters
 */

#ifndef CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE
#  define CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE 16
#endif

#ifndef CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT
#  define CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT 8
#endif

/**
 * Normal background color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR MKRGB(148,189,215)
#endif

/**
 * Default selected background color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(206,227,241)
#endif

/**
 * Shiny side border color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
#endif

/**
 * Shadowed side border color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR MKRGB(35,58,73)
#endif

/**
 * Highlight color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR MKRGB(192,192,192)
#endif

/* Text colors */

#ifndef CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR MKRGB(192,192,192)
#endif

#ifndef CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR MKRGB(248,248,248)
#endif

#ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR MKRGB(0,0,0)
#endif

/**
 * Default font color
 */

#ifndef CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
#  define CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR MKRGB(255,255,255)
#endif

/**
 * Transparent color
 */

#ifndef CONFIG_NXWIDGETS_TRANSPARENT_COLOR
#  define CONFIG_NXWIDGETS_TRANSPARENT_COLOR MKRGB(0,0,0)
#endif

/* Keypad behavior **********************************************************/
/**
 * Time taken before a key starts repeating (in milliseconds).
 */

#ifndef CONFIG_NXWIDGETS_FIRST_REPEAT_TIME
#  define CONFIG_NXWIDGETS_FIRST_REPEAT_TIME 500
#endif

/**
 * Time taken before a repeating key repeats again (in milliseconds).
 */

#ifndef CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME
#  define CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME 200
#endif

/**
 * Left button release-press time for double click (in milliseconds).
 */

#ifndef CONFIG_NXWIDGETS_DOUBLECLICK_TIME
#  define CONFIG_NXWIDGETS_DOUBLECLICK_TIME 350
#endif

/**
 * Size of incoming character buffer, i.e., the maximum number of characters
 * that can be entered between NX polling cycles without losing data.
 */

#ifndef CONFIG_NXWIDGETS_KBDBUFFER_SIZE
#  define CONFIG_NXWIDGETS_KBDBUFFER_SIZE 8
#endif

/**
 * Size of incoming cursor control buffer, i.e., the maximum number of cursor
 * controls that can between entered by NX polling cycles without losing data.
 */

#ifndef CONFIG_NXWIDGETS_CURSORCONTROL_SIZE
#  define CONFIG_NXWIDGETS_CURSORCONTROL_SIZE 4
#endif

/****************************************************************************
 * Public Types
 ****************************************************************************/

namespace NXWidgets
{
#if CONFIG_NXWIDGETS_BPP == 8
  typedef uint8_t nxwidget_pixel_t;
#elif CONFIG_NXWIDGETS_BPP == 16
  typedef uint16_t nxwidget_pixel_t;
#elif CONFIG_NXWIDGETS_BPP == 24
  typedef uint32_t nxwidget_pixel_t;
#elif CONFIG_NXWIDGETS_BPP == 32
  typedef uint32_t nxwidget_pixel_t;
#else
#  error "Pixel depth is unknown"
#endif

#if CONFIG_NXWIDGETS_SIZEOFCHAR == 2
  typedef uint16_t nxwidget_char_t;
#elif CONFIG_NXWIDGETS_SIZEOFCHAR == 1
  typedef uint8_t nxwidget_char_t;
#else
#  error "Character width is unknown"
#endif
}

/****************************************************************************
 * Implementation Classes
 ****************************************************************************/

#endif // __INCLUDE_NXCONFIG_HXX