aboutsummaryrefslogtreecommitdiff
path: root/NxWidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-17 18:18:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-17 18:18:44 +0000
commit57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff (patch)
tree25d07d14e920d31c0b1947c9ca586f2a01fc32d8 /NxWidgets
downloadpx4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.tar.gz
px4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.tar.bz2
px4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.zip
Resync new repository with old repo r5166
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets')
-rw-r--r--NxWidgets/ChangeLog.txt165
-rw-r--r--NxWidgets/Doxygen/Doxyfile1551
-rw-r--r--NxWidgets/Doxygen/README.txt64
-rwxr-xr-xNxWidgets/Doxygen/gendoc.sh94
-rw-r--r--NxWidgets/README.txt91
-rw-r--r--NxWidgets/ReleaseNotes.txt99
-rw-r--r--NxWidgets/TODO.txt158
-rw-r--r--NxWidgets/UnitTests/CButton/Makefile172
-rw-r--r--NxWidgets/UnitTests/CButton/cbutton-pushed.pngbin0 -> 22223 bytes
-rw-r--r--NxWidgets/UnitTests/CButton/cbutton-released.pngbin0 -> 19844 bytes
-rw-r--r--NxWidgets/UnitTests/CButton/cbutton_main.cxx155
-rw-r--r--NxWidgets/UnitTests/CButton/cbuttontest.cxx325
-rw-r--r--NxWidgets/UnitTests/CButton/cbuttontest.hxx157
-rw-r--r--NxWidgets/UnitTests/CButtonArray/Makefile172
-rw-r--r--NxWidgets/UnitTests/CButtonArray/cbuttonarray.pngbin0 -> 35615 bytes
-rw-r--r--NxWidgets/UnitTests/CButtonArray/cbuttonarray_main.cxx327
-rw-r--r--NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.cxx301
-rw-r--r--NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.hxx172
-rw-r--r--NxWidgets/UnitTests/CCheckBox/Makefile172
-rw-r--r--NxWidgets/UnitTests/CCheckBox/ccheckbox.pngbin0 -> 20124 bytes
-rw-r--r--NxWidgets/UnitTests/CCheckBox/ccheckbox_main.cxx209
-rw-r--r--NxWidgets/UnitTests/CCheckBox/ccheckboxtest.cxx297
-rw-r--r--NxWidgets/UnitTests/CCheckBox/ccheckboxtest.hxx142
-rw-r--r--NxWidgets/UnitTests/CGlyphButton/Makefile172
-rw-r--r--NxWidgets/UnitTests/CGlyphButton/cglyphbutton_main.cxx225
-rw-r--r--NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.cxx307
-rw-r--r--NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.hxx172
-rw-r--r--NxWidgets/UnitTests/CImage/Makefile172
-rw-r--r--NxWidgets/UnitTests/CImage/cimage_main.cxx222
-rw-r--r--NxWidgets/UnitTests/CImage/cimagetest.cxx240
-rw-r--r--NxWidgets/UnitTests/CImage/cimagetest.hxx140
-rw-r--r--NxWidgets/UnitTests/CKeypad/Makefile172
-rw-r--r--NxWidgets/UnitTests/CKeypad/ckeypad_main.cxx274
-rw-r--r--NxWidgets/UnitTests/CKeypad/ckeypadtest.cxx458
-rw-r--r--NxWidgets/UnitTests/CKeypad/ckeypadtest.hxx182
-rw-r--r--NxWidgets/UnitTests/CLabel/Makefile172
-rw-r--r--NxWidgets/UnitTests/CLabel/clabel.pngbin0 -> 18204 bytes
-rw-r--r--NxWidgets/UnitTests/CLabel/clabel_main.cxx130
-rw-r--r--NxWidgets/UnitTests/CLabel/clabeltest.cxx263
-rw-r--r--NxWidgets/UnitTests/CLabel/clabeltest.hxx138
-rw-r--r--NxWidgets/UnitTests/CLatchButton/Makefile172
-rw-r--r--NxWidgets/UnitTests/CLatchButton/clatchbutton_main.cxx199
-rw-r--r--NxWidgets/UnitTests/CLatchButton/clatchbuttontest.cxx321
-rw-r--r--NxWidgets/UnitTests/CLatchButton/clatchbuttontest.hxx155
-rw-r--r--NxWidgets/UnitTests/CLatchButtonArray/Makefile172
-rw-r--r--NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarray_main.cxx301
-rw-r--r--NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.cxx301
-rw-r--r--NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.hxx172
-rw-r--r--NxWidgets/UnitTests/CListBox/Makefile172
-rw-r--r--NxWidgets/UnitTests/CListBox/clistbox_main.cxx327
-rw-r--r--NxWidgets/UnitTests/CListBox/clistboxtest.cxx224
-rw-r--r--NxWidgets/UnitTests/CListBox/clistboxtest.hxx137
-rw-r--r--NxWidgets/UnitTests/CProgressBar/Makefile172
-rw-r--r--NxWidgets/UnitTests/CProgressBar/cprogressbar.pngbin0 -> 20469 bytes
-rw-r--r--NxWidgets/UnitTests/CProgressBar/cprogressbar_main.cxx238
-rw-r--r--NxWidgets/UnitTests/CProgressBar/cprogressbartest.cxx224
-rw-r--r--NxWidgets/UnitTests/CProgressBar/cprogressbartest.hxx137
-rw-r--r--NxWidgets/UnitTests/CRadioButton/Makefile172
-rw-r--r--NxWidgets/UnitTests/CRadioButton/cradiobutton.pngbin0 -> 32930 bytes
-rw-r--r--NxWidgets/UnitTests/CRadioButton/cradiobutton_main.cxx238
-rw-r--r--NxWidgets/UnitTests/CRadioButton/cradiobuttontest.cxx305
-rw-r--r--NxWidgets/UnitTests/CRadioButton/cradiobuttontest.hxx152
-rw-r--r--NxWidgets/UnitTests/CScrollbarHorizontal/Makefile172
-rw-r--r--NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.pngbin0 -> 20426 bytes
-rw-r--r--NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal_main.cxx231
-rw-r--r--NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.cxx225
-rw-r--r--NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.hxx137
-rw-r--r--NxWidgets/UnitTests/CScrollbarVertical/Makefile172
-rw-r--r--NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.pngbin0 -> 31491 bytes
-rw-r--r--NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical_main.cxx231
-rw-r--r--NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.cxx225
-rw-r--r--NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.hxx137
-rw-r--r--NxWidgets/UnitTests/CSliderHorizonal/Makefile172
-rw-r--r--NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.pngbin0 -> 21590 bytes
-rw-r--r--NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal_main.cxx231
-rw-r--r--NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.cxx224
-rw-r--r--NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.hxx137
-rw-r--r--NxWidgets/UnitTests/CSliderVertical/Makefile172
-rw-r--r--NxWidgets/UnitTests/CSliderVertical/cslidervertical.pngbin0 -> 19625 bytes
-rw-r--r--NxWidgets/UnitTests/CSliderVertical/cslidervertical_main.cxx231
-rw-r--r--NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.cxx225
-rw-r--r--NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.hxx137
-rw-r--r--NxWidgets/UnitTests/CTextBox/Makefile172
-rw-r--r--NxWidgets/UnitTests/CTextBox/ctextbox.pngbin0 -> 45575 bytes
-rw-r--r--NxWidgets/UnitTests/CTextBox/ctextbox_main.cxx141
-rw-r--r--NxWidgets/UnitTests/CTextBox/ctextboxtest.cxx287
-rw-r--r--NxWidgets/UnitTests/CTextBox/ctextboxtest.hxx142
-rw-r--r--NxWidgets/UnitTests/README.txt418
-rw-r--r--NxWidgets/UnitTests/TestStatus.txt59
-rw-r--r--NxWidgets/UnitTests/nxwm/Makefile202
-rw-r--r--NxWidgets/UnitTests/nxwm/nxwm_main.cxx734
-rw-r--r--NxWidgets/libnxwidgets/COPYING70
-rw-r--r--NxWidgets/libnxwidgets/Makefile138
-rw-r--r--NxWidgets/libnxwidgets/doc/mainpage.h83
-rw-r--r--NxWidgets/libnxwidgets/include/cbgwindow.hxx344
-rw-r--r--NxWidgets/libnxwidgets/include/cbitmap.hxx213
-rw-r--r--NxWidgets/libnxwidgets/include/cbutton.hxx244
-rw-r--r--NxWidgets/libnxwidgets/include/cbuttonarray.hxx326
-rw-r--r--NxWidgets/libnxwidgets/include/ccallback.hxx272
-rw-r--r--NxWidgets/libnxwidgets/include/ccheckbox.hxx210
-rw-r--r--NxWidgets/libnxwidgets/include/ccyclebutton.hxx356
-rw-r--r--NxWidgets/libnxwidgets/include/cglyphbutton.hxx229
-rw-r--r--NxWidgets/libnxwidgets/include/cgraphicsport.hxx452
-rw-r--r--NxWidgets/libnxwidgets/include/cimage.hxx244
-rw-r--r--NxWidgets/libnxwidgets/include/ckeypad.hxx156
-rw-r--r--NxWidgets/libnxwidgets/include/clabel.hxx355
-rw-r--r--NxWidgets/libnxwidgets/include/clatchbutton.hxx173
-rw-r--r--NxWidgets/libnxwidgets/include/clatchbuttonarray.hxx170
-rw-r--r--NxWidgets/libnxwidgets/include/clistbox.hxx431
-rw-r--r--NxWidgets/libnxwidgets/include/clistboxdataitem.hxx180
-rw-r--r--NxWidgets/libnxwidgets/include/clistdata.hxx351
-rw-r--r--NxWidgets/libnxwidgets/include/clistdataeventargs.hxx121
-rw-r--r--NxWidgets/libnxwidgets/include/clistdataitem.hxx189
-rw-r--r--NxWidgets/libnxwidgets/include/cmultilinetextbox.hxx621
-rw-r--r--NxWidgets/libnxwidgets/include/cnxfont.hxx238
-rw-r--r--NxWidgets/libnxwidgets/include/cnxserver.hxx206
-rw-r--r--NxWidgets/libnxwidgets/include/cnxstring.hxx484
-rw-r--r--NxWidgets/libnxwidgets/include/cnxtimer.hxx220
-rw-r--r--NxWidgets/libnxwidgets/include/cnxtkwindow.hxx365
-rw-r--r--NxWidgets/libnxwidgets/include/cnxtoolbar.hxx334
-rw-r--r--NxWidgets/libnxwidgets/include/cnxwidget.hxx1336
-rw-r--r--NxWidgets/libnxwidgets/include/cnxwindow.hxx337
-rw-r--r--NxWidgets/libnxwidgets/include/cprogressbar.hxx251
-rw-r--r--NxWidgets/libnxwidgets/include/cradiobutton.hxx207
-rw-r--r--NxWidgets/libnxwidgets/include/cradiobuttongroup.hxx253
-rw-r--r--NxWidgets/libnxwidgets/include/crect.hxx436
-rw-r--r--NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx269
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx293
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx309
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx291
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollinglistbox.hxx480
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollingpanel.hxx372
-rw-r--r--NxWidgets/libnxwidgets/include/cscrollingtextbox.hxx467
-rw-r--r--NxWidgets/libnxwidgets/include/csliderhorizontal.hxx344
-rw-r--r--NxWidgets/libnxwidgets/include/csliderhorizontalgrip.hxx203
-rw-r--r--NxWidgets/libnxwidgets/include/cslidervertical.hxx344
-rw-r--r--NxWidgets/libnxwidgets/include/csliderverticalgrip.hxx202
-rw-r--r--NxWidgets/libnxwidgets/include/cstickybutton.hxx237
-rw-r--r--NxWidgets/libnxwidgets/include/cstickybuttonarray.hxx174
-rw-r--r--NxWidgets/libnxwidgets/include/cstringiterator.hxx192
-rw-r--r--NxWidgets/libnxwidgets/include/ctext.hxx386
-rw-r--r--NxWidgets/libnxwidgets/include/ctextbox.hxx375
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx769
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgeteventargs.hxx237
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx284
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx358
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgetstyle.hxx135
-rw-r--r--NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx121
-rw-r--r--NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx176
-rw-r--r--NxWidgets/libnxwidgets/include/glyphs.hxx131
-rw-r--r--NxWidgets/libnxwidgets/include/ibitmap.hxx183
-rw-r--r--NxWidgets/libnxwidgets/include/ilistbox.hxx281
-rw-r--r--NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx136
-rw-r--r--NxWidgets/libnxwidgets/include/inxwindow.hxx308
-rw-r--r--NxWidgets/libnxwidgets/include/iscrollable.hxx217
-rw-r--r--NxWidgets/libnxwidgets/include/islider.hxx196
-rw-r--r--NxWidgets/libnxwidgets/include/itextbox.hxx217
-rw-r--r--NxWidgets/libnxwidgets/include/nxconfig.hxx504
-rw-r--r--NxWidgets/libnxwidgets/include/singletons.hxx136
-rw-r--r--NxWidgets/libnxwidgets/include/teventargs.hxx136
-rw-r--r--NxWidgets/libnxwidgets/include/tnxarray.hxx437
-rw-r--r--NxWidgets/libnxwidgets/src/cbgwindow.cxx377
-rw-r--r--NxWidgets/libnxwidgets/src/cbitmap.cxx197
-rw-r--r--NxWidgets/libnxwidgets/src/cbutton.cxx311
-rw-r--r--NxWidgets/libnxwidgets/src/cbuttonarray.cxx634
-rw-r--r--NxWidgets/libnxwidgets/src/ccallback.cxx263
-rw-r--r--NxWidgets/libnxwidgets/src/ccheckbox.cxx265
-rw-r--r--NxWidgets/libnxwidgets/src/ccyclebutton.cxx482
-rw-r--r--NxWidgets/libnxwidgets/src/cglyphbutton.cxx297
-rw-r--r--NxWidgets/libnxwidgets/src/cgraphicsport.cxx994
-rw-r--r--NxWidgets/libnxwidgets/src/cimage.cxx456
-rw-r--r--NxWidgets/libnxwidgets/src/ckeypad.cxx214
-rw-r--r--NxWidgets/libnxwidgets/src/clabel.cxx426
-rw-r--r--NxWidgets/libnxwidgets/src/clatchbutton.cxx131
-rw-r--r--NxWidgets/libnxwidgets/src/clatchbuttonarray.cxx116
-rw-r--r--NxWidgets/libnxwidgets/src/clistbox.cxx661
-rw-r--r--NxWidgets/libnxwidgets/src/clistboxdataitem.cxx114
-rw-r--r--NxWidgets/libnxwidgets/src/clistdata.cxx462
-rw-r--r--NxWidgets/libnxwidgets/src/clistdataitem.cxx128
-rw-r--r--NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx1284
-rw-r--r--NxWidgets/libnxwidgets/src/cnxfont.cxx276
-rw-r--r--NxWidgets/libnxwidgets/src/cnxserver.cxx461
-rw-r--r--NxWidgets/libnxwidgets/src/cnxstring.cxx799
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtimer.cxx382
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtkwindow.cxx509
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtoolbar.cxx382
-rw-r--r--NxWidgets/libnxwidgets/src/cnxwidget.cxx1551
-rw-r--r--NxWidgets/libnxwidgets/src/cnxwindow.cxx355
-rw-r--r--NxWidgets/libnxwidgets/src/cprogressbar.cxx230
-rw-r--r--NxWidgets/libnxwidgets/src/cradiobutton.cxx225
-rw-r--r--NxWidgets/libnxwidgets/src/cradiobuttongroup.cxx344
-rw-r--r--NxWidgets/libnxwidgets/src/crect.cxx380
-rw-r--r--NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx437
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx402
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx438
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx404
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollinglistbox.cxx415
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollingpanel.cxx320
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollingtextbox.cxx577
-rw-r--r--NxWidgets/libnxwidgets/src/csliderhorizontal.cxx402
-rw-r--r--NxWidgets/libnxwidgets/src/csliderhorizontalgrip.cxx246
-rw-r--r--NxWidgets/libnxwidgets/src/cslidervertical.cxx402
-rw-r--r--NxWidgets/libnxwidgets/src/csliderverticalgrip.cxx245
-rw-r--r--NxWidgets/libnxwidgets/src/cstickybutton.cxx168
-rw-r--r--NxWidgets/libnxwidgets/src/cstickybuttonarray.cxx292
-rw-r--r--NxWidgets/libnxwidgets/src/cstringiterator.cxx198
-rw-r--r--NxWidgets/libnxwidgets/src/ctext.cxx675
-rw-r--r--NxWidgets/libnxwidgets/src/ctextbox.cxx679
-rw-r--r--NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx942
-rw-r--r--NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx538
-rw-r--r--NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx175
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_arrowdown.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_arrowleft.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_arrowright.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_arrowup.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_backspace.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_capslock.cxx155
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_checkboxmu.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_checkboxoff.cxx121
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_checkboxon.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_control.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_cycle.cxx155
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx3453
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_radiobuttonmu.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_radiobuttonoff.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_radiobuttonon.cxx156
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_return.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_screendepthdown.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_screendepthup.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_screenflipdown.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_screenflipup.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_shift.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_windowclose.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_windowdepthdown.cxx154
-rw-r--r--NxWidgets/libnxwidgets/src/glyph_windowdepthup.cxx156
-rw-r--r--NxWidgets/libnxwidgets/src/singletons.cxx202
-rw-r--r--NxWidgets/nxwm/COPYING41
-rw-r--r--NxWidgets/nxwm/Makefile143
-rw-r--r--NxWidgets/nxwm/doc/NxWM-ThreadingModel.pptbin0 -> 129024 bytes
-rw-r--r--NxWidgets/nxwm/images/calculator.pngbin0 -> 263 bytes
-rw-r--r--NxWidgets/nxwm/images/calibration.pngbin0 -> 415 bytes
-rw-r--r--NxWidgets/nxwm/images/cmd.pngbin0 -> 264 bytes
-rw-r--r--NxWidgets/nxwm/images/minimize.pngbin0 -> 284 bytes
-rw-r--r--NxWidgets/nxwm/images/nxlogo.pngbin0 -> 608 bytes
-rw-r--r--NxWidgets/nxwm/images/play.pngbin0 -> 233 bytes
-rw-r--r--NxWidgets/nxwm/images/start.pngbin0 -> 719 bytes
-rw-r--r--NxWidgets/nxwm/images/stop.pngbin0 -> 381 bytes
-rw-r--r--NxWidgets/nxwm/include/capplicationwindow.hxx233
-rw-r--r--NxWidgets/nxwm/include/ccalibration.hxx370
-rw-r--r--NxWidgets/nxwm/include/cfullscreenwindow.hxx185
-rw-r--r--NxWidgets/nxwm/include/chexcalculator.hxx330
-rw-r--r--NxWidgets/nxwm/include/ckeyboard.hxx133
-rw-r--r--NxWidgets/nxwm/include/cnxconsole.hxx245
-rw-r--r--NxWidgets/nxwm/include/cstartwindow.hxx305
-rw-r--r--NxWidgets/nxwm/include/ctaskbar.hxx428
-rw-r--r--NxWidgets/nxwm/include/ctouchscreen.hxx221
-rw-r--r--NxWidgets/nxwm/include/cwindowmessenger.hxx136
-rw-r--r--NxWidgets/nxwm/include/iapplication.hxx241
-rw-r--r--NxWidgets/nxwm/include/iapplicationwindow.hxx204
-rw-r--r--NxWidgets/nxwm/include/nxwmconfig.hxx555
-rw-r--r--NxWidgets/nxwm/include/nxwmglyphs.hxx71
-rw-r--r--NxWidgets/nxwm/src/capplicationwindow.cxx581
-rw-r--r--NxWidgets/nxwm/src/ccalibration.cxx883
-rw-r--r--NxWidgets/nxwm/src/cfullscreenwindow.cxx217
-rw-r--r--NxWidgets/nxwm/src/chexcalculator.cxx1020
-rw-r--r--NxWidgets/nxwm/src/ckeyboard.cxx240
-rw-r--r--NxWidgets/nxwm/src/cnxconsole.cxx664
-rw-r--r--NxWidgets/nxwm/src/cstartwindow.cxx696
-rw-r--r--NxWidgets/nxwm/src/ctaskbar.cxx1427
-rw-r--r--NxWidgets/nxwm/src/ctouchscreen.cxx530
-rw-r--r--NxWidgets/nxwm/src/cwindowmessenger.cxx230
-rw-r--r--NxWidgets/nxwm/src/glyph_calculator.cxx191
-rw-r--r--NxWidgets/nxwm/src/glyph_calibration.cxx198
-rw-r--r--NxWidgets/nxwm/src/glyph_cmd.cxx181
-rw-r--r--NxWidgets/nxwm/src/glyph_minimize.cxx179
-rw-r--r--NxWidgets/nxwm/src/glyph_nsh.cxx215
-rw-r--r--NxWidgets/nxwm/src/glyph_play.cxx258
-rw-r--r--NxWidgets/nxwm/src/glyph_start.cxx216
-rw-r--r--NxWidgets/nxwm/src/glyph_stop.cxx194
-rwxr-xr-xNxWidgets/tools/addobjs.sh141
-rwxr-xr-xNxWidgets/tools/indent.sh45
-rwxr-xr-xNxWidgets/tools/install.sh152
-rwxr-xr-xNxWidgets/tools/zipme.sh125
283 files changed, 79517 insertions, 0 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt
new file mode 100644
index 000000000..cdd26cb89
--- /dev/null
+++ b/NxWidgets/ChangeLog.txt
@@ -0,0 +1,165 @@
+1.0 2012-03-22 Gregory Nutt <gnutt@nuttx.org>
+
+* The initial release of the NxWidgets package
+
+1.1 2012-05-19 Gregory Nutt <gnutt@nuttx.org>
+
+* Updated and verified the NxWidgets DOxygen documentation. Contributed
+ by Jose Pablo Carballo.
+* IBitmap, CRlePalettBitmap: Extended class to support differnt LUTs
+ for selected and non-selected images.
+* CImage: If selected, uses different LUTs based, different borders.
+ CImage is now basically a button type.
+* CImage: Add logic to hightlight an CImage (using the selected LUT).
+* nxwm: The tiny NX window manager (NxWM) is being developed in this directory.
+* UnitTests/nxwm: A unit test for the NX window manager.
+* CWidgetControl: Add a semaphore to force clients to wait if the
+ size or position of the window is not yet known (multi-user mode only).
+* During integration of NxWM, corrected numerous problems with NxWidgets
+ running on toolbars and framed windows. That capability was commented
+ out in the 1.0 release but is verfied functional in 1.1.
+* CRlePalettBitmap: Fix an error in the text that determines if we
+ need to "rewind" to the beginning of the image.
+* CRlePalettBitmap: Fixe a positioning problem. It was actually losing
+ the last row of every image!
+* CNxWidget: Removed support for "shelving" widgets. I will be removing
+ some lesser used feature over time in order to reduce the NxWidgets
+ footprint.
+* CNxWidget: Removed support for reference constants and close types.
+ The goal is to ge the base widget class as small as possible.
+* CNxTkWindow: Fix uninitialized pointer value.
+* CNxToolbar: Need to "fake" the fix position callback to avoid
+ deadlock waits for the callback that won't happen.
+* CNxTkWindow: Fix toolbar background color
+* CWidgetControl: Don't declare the the geometry is good until a non-NULL
+ window size is received.
+* CGraphicsPort and CWidgetControl: If the underlying graphics device
+ is write-only, then we have to render fonts a little differently.
+* CNxWidgets, CWidgetControl, and CRectCache: Big change! Remove all support
+ for widgets in a "vertical" hierarchy. Now widgets exist in a flat,
+ two-dimensional space and should not overlap. This should greatly
+ reduce the memory requirements and, since, NuttX already supports
+ a hierarchical windowing system, does not result in loss of functionality.
+* CNxWidgets and CWidgetControl. Remove specific built-in support for
+ modal loops. There are too many different control mechanisms that might
+ be needed. Replace with hooks to control widget events from totally
+ external logic.
+* CWindowEventHandler, CWindowEventHandlerList, CWidgetControl: New
+ callback classes to receive notifications about window events.
+* NxWM::CFullScreenWindow and NxWM::CTaskbar: Add support in NxWM for full
+ screen window applications.
+* All application windows now use CWindowEventHandler and CWindowEventHandlerList
+ to get notifications about mouse and keyboard events. These class will
+ then automatically handle polling (with no need for a modal loop).
+* NxWM::CTouchscreen and NxWM::CCalibration: Add touchscreen support (still a long
+ way to go).
+* NxWM::g_playBitmp: Change the play icon again. These tiny touch icons
+ must be very simple.
+* NxWM::CCalibration: Beef up touch input handling logic. Now changes the
+ color of the touch circle to yellow when it is touched.
+* NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer.
+* NxWM::CWindowControl: Add new class to wrap CWidgetControl and provide
+ some special mouse and keyboard input event handling.
+* NxWM::CTaskbar: Correct the calculation of the physical size of the
+ display.
+* NxWM::CCalibration: run method must clear m_stop when returning, or you can
+ never restart the Calibration window.
+* NxWM::CTaskbar: On a failure to start an application, the application icon
+ CImage was being deleted twice.
+* NXWidgets::CImage: Now handles mouse click callbacks. CImage is now really
+ a button. Probably should separate basic imaging functionality as CImage
+ and create a new CImageButton.
+* NxWM::CStartWindow: Now ignores any close application button presses
+ (You can't close the start window).
+* NxWM::CCalibration: The calibration application now has its own thread.
+ This was necessary for a proper integration with the taskbar.
+* NxWM::CCalibration and NxWM:CTouchscreen: Changed the mechanism use
+ to report calbration data. It is now reported directly from CCalibration
+ to CTouchscreen. If external logic needs calibration, it can now get it
+ from CTouchscreen instead of CCalibration. This change was necessary
+ to make the termination conditions of CCalibration clean (it used to
+ have to persist until some external logic got the Calibration data).
+* IApplication, IApplicationWindow, and all classes that inherit from
+ these: Now support method to report if the application is a full-screen
+ or a normal application. This is necessary to prevent CTaskbar from
+ displaying a task bar on top of a full-screen window.
+* NxWM::CTaskbar: Ooops... minimizing the wrong application!
+* NxWM::CNxConsole: Add a on_exit() exit handler that will close the
+ NxConsole window when the NSH thread exits. A correct build now depends
+ on having CONFIG_SCHED_ONEXIT defined.
+* NXWidgets::CNxWidget: Add a new onPreRelease() method.
+* NXWidgets::CButton, CButtonArry, CImage now post action event at pre-release time.
+* NxWM: ICON touches are now drive by action events instead of click events.
+* NXWidgets::CNxTkWindow: Reported size of a framed window must exclude the
+ height of the tool bar (if present)
+* TODO.txt: Add a file to keep track of issues.
+* NxWM::CStartWindow and IApplicationFactory: This is a substantial
+ redesign. IApplication wraps an application. However, if we want to
+ be able to start multiple copies of an application, then we need to
+ be able to create multiple IApplication instances from the start window.
+ Enter IApplicationFactory. Icons in the start window now correspond
+ to application factories; icons in the task bar no correspond to
+ application instances.
+* NxWM::CStartWindow and CWindowControl: The above change necessitated
+ another architectural change: When create applications, it is sometimes
+ necessary to wait for windows events. The above change moved the
+ application creation to the window event thread, hence, causing deadlocks
+ wheneven the logic tried to wait for a window event. The solution was
+ to create a new thread, called the start window thread, that runs
+ asynchronously and can wait for windoew events.
+* doc/NxWM-ThreadingModel.ppt: Documented the now rather complex NxWM
+ threading model.
+
+1.2 2012-06-15 Gregory Nutt <gnutt@nuttx.org>
+
+* NXWidgets::CCallback: callback arguement is now type CCallback and not
+ CWidgetControl; Added a method to redirect keyboard contacts to either
+ the widgets in the window (via CWidgetControl) or to an NxConsole (via
+ nxcon_kbdin()).
+* NXWidgets::INxWindow, CBgWindow, CNxTkWindow, CNxToolbar, CNxWindow:
+ Now pass the CCallback intances as the callback argument instead of
+ the CWidgetControl instance. New method redirectNxConsole() will
+ support redirection of any window keyboard input to the NxConsole
+ (via CCallback).
+* NxWM:CNxConsole: Configures the NxConsole window to redirection keyboard
+ input to the NxConsole; redirects standard input to the NxConsole
+ device driver.
+* NxWM:CKeyboard: Add a new class that implements a keyboard listener
+ thread. This thread reads from /dev/console and injects the keyboard
+ input into NX. NX will determine which window is at the top of the
+ heirarchy and re-direct the keyboard input to only that top window.
+ This solves an important problem with, for example, running multiple
+ copies of the NxConsole: On the copy of the NxConsole at the top of
+ the heirarchy should get the keyboard input.
+* UnitTests/nxwm/main.cxx: Now starts the keyboard thread if
+ CONFIG_NXWM_KEYBOARD is defined.
+* NxWM::CTaskbar: After drawing the task bar, need to raise the
+ application window otherwise the taskbar will be on the top and
+ keyboard input will not be received by the top application.
+* NxWM::CTaskbar: Bugfix... previous window should not be minimized
+ when a new window is started. It should stay in a maximized state
+ so that it will re-appear with the window above it is closed or
+ minimized.
+* NxWM::CHexCalculator: Add a hexadecimal/decimal calculator
+ example.
+* NXWidgets::CNxTkWindow: Back out height adjustment in the getSize()
+ method. The code was correct as it was before.
+* NXWidgets::CButtonArray and NXWidgets::CGraphicsPort: There is
+ a kludge in there to handle the case where we cannot read the
+ background data because the LCD does not support read operations.
+ In that case, we just use the default background color. However,
+ that doesn't work either for the case where the background color
+ changes when the widget is selected. Then the background color
+ in the font is wrong. Fixed in CButtonArrary, but the problem
+ probably exists in other places as well.
+* NxWM: Increase default spacing of icons on the Start Window.
+* NxWM::CHexCalculator: Fix some non-standard calculator behavior
+ after = is pressed. Use upper case hex. Increase font size.
+* nxwm/Makefile: Fix error that creapt in during some other
+ recent check-ins.
+
+1.3 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
+
+* UnitTests/*/main.cxx: Change entry point name to be consistent
+ with with entry point naming conventions introduced in NuttX
+ 6.22.
diff --git a/NxWidgets/Doxygen/Doxyfile b/NxWidgets/Doxygen/Doxyfile
new file mode 100644
index 000000000..979f5720f
--- /dev/null
+++ b/NxWidgets/Doxygen/Doxyfile
@@ -0,0 +1,1551 @@
+# Doxyfile 1.6.3
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = NXWidgets
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = "1.1"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY =
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = YES
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 2
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = YES
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = NO
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = NO
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = NO
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= NO
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = "../libnxwidgets" "../nxwm"
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = NO
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = NO
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = NO
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = NO
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = NO
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = NO
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = NO
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = NO
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/NxWidgets/Doxygen/README.txt b/NxWidgets/Doxygen/README.txt
new file mode 100644
index 000000000..26d76ce4b
--- /dev/null
+++ b/NxWidgets/Doxygen/README.txt
@@ -0,0 +1,64 @@
+README
+======
+
+This directory contains the documentation automatically generated by Doxygen.
+
+Contents
+========
+
+ o Installing the necessary packages in Ubuntu
+ o Generating documentation
+ o References
+
+Installing the necessary packages in Ubuntu
+===========================================
+
+1. Install the following packages.
+
+ $ sudo aptitude install doxygen doxygen-doc doxygen-gui dot2tex graphviz
+
+2. (Optional) Install Doxygen from the latest sourcode.
+
+ The Ubuntu package is outdated. The newer the version of Doxygen, the better
+ the documentation looks.
+
+ Place yourself in some temporary folder where you can download the source,
+ and run [1]:
+
+ $ svn co https://doxygen.svn.sourceforge.net/svnroot/doxygen/trunk doxygen-svn
+ $ cd doxygen-svn
+ $ ./configure
+ $ make
+ $ make install
+
+Generating documentation
+========================
+
+Two ways described here:
+
+1. Use the provided gendoc.sh script.
+
+ trunk/NXWidgets/Doxygen/gendoc.sh
+
+ The script only needs the argument to the absolute path where to place the
+ generated documentation. I.e.:
+
+ $ cd /path/to/nuttx/trunk/NXWidgets/Doxygen/
+ $ mkdir doc
+ $ ./gendoc.sh $PWD/doc
+
+
+2. Using the Doxyfile directly:
+
+ The file "Doxyfile" contains the configuration of the Doxygen settings
+ for the run, edit only if necessary.
+
+ To generate the documentation type:
+
+ $ cd /path/to/nuttx/trunk/NXWidgets/Doxygen/
+ $ doxygen Doxyfile
+
+References
+==========
+
+[1] http://www.stack.nl/~dimitri/doxygen/download.html
diff --git a/NxWidgets/Doxygen/gendoc.sh b/NxWidgets/Doxygen/gendoc.sh
new file mode 100755
index 000000000..0132f8162
--- /dev/null
+++ b/NxWidgets/Doxygen/gendoc.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+#################################################################################
+# NxWidgets/Doxygen/gendoc.sh
+#
+# Copyright (C) 2012 Gregory Nutt. All rights reserved.
+# Author: Jose Pablo Carballo <jcarballo@nx-engineering.com>
+#
+# 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.
+#
+#################################################################################
+#
+# set -x
+# Functions
+
+function ShowUsage()
+{
+ echo ""
+ echo "USAGE: $0 <doxygen-output-directory-path>"
+ echo ""
+ echo "Where:"
+ echo " <doxygen-output-directory-path> is the full, absolut path to place the doxygen output"
+ echo ""
+}
+
+# Input parameters
+
+DOXYGENOUTPUT_DIR=$1
+if [ -z "${DOXYGENOUTPUT_DIR}" ]; then
+ echo "Missing required arguments"
+ ShowUsage
+ exit 1
+fi
+
+# Check that the directory exist
+
+if [ ! -d "${DOXYGENOUTPUT_DIR}" ]; then
+ echo "Directory ${DOXYGENOUTPUT_DIR} does not exist"
+ exit 1
+fi
+
+# Find the doxygen configuration file
+
+DOXYFILE="Doxyfile"
+if [ ! -e "${DOXYFILE}" ]; then
+ echo "This script must be executed in the documentation/ directory"
+ exit 1
+fi
+
+doxygen "${DOXYFILE}" || \
+ {
+ echo "Failed to run doxygen"; \
+ exit 1;
+
+ }
+
+cp -rf html "${DOXYGENOUTPUT_DIR}" || \
+ {
+ echo "Failed to move html output"; \
+ exit 1;
+ }
+
+rm -rf html || \
+ {
+ echo "Failed to remove the html/ directory"; \
+ exit 1;
+ }
+
+echo "open ${DOXYGENOUTPUT_DIR}/html/index.html to start browsing"
+
diff --git a/NxWidgets/README.txt b/NxWidgets/README.txt
new file mode 100644
index 000000000..7bb16820c
--- /dev/null
+++ b/NxWidgets/README.txt
@@ -0,0 +1,91 @@
+NXWidgets
+=========
+
+In order to better support NuttX based platforms, a special graphical user
+interface has been created called NXWidgets. NXWidgets is written in C++
+and integrates seamlessly with the NuttX NX graphics subsystem in order
+to provide graphic objects, or "widgets," in the NX Graphics Subsystem
+
+Some of the features of NXWidgets include:
+
+o Conservative C++
+
+ NXWidgets is written entirely in C++ but using only selected “embedded
+ friendly” C++ constructs that are fully supported under NuttX. No
+ additional C++ support libraries are required.
+
+o NX Integration
+
+ NXWidgets integrate seamlessly with the NX graphics system. Think of the
+ X server under Linux … the NX graphics system is like a tiny X server
+ that provides windowing under NuttX. By adding NXWidgets, you can support
+ graphics objects like buttons and text boxes in the NX windows and toolbars.
+
+o Small Footprint
+
+ NXWidgets is tailored for use MCUs in embedded applications. It is ideally
+ suited for mid- and upper-range of most MCU families. A complete NXWidgets
+ is possible in as little as 40Kb of FLASH and maybe 4Kb of SRAM.
+
+o Output Devices
+
+ NXWidgets will work on the high-end frame buffer devices as well as on LCDs
+ connected via serial or parallel ports to a small MCU.
+
+o Input Devices
+
+ NXWidgets will accept position and selection inputs from a mouse or a
+ touchscreen. It will also support character input from a keyboard such as a
+ USB keyboard. NXWidgets supports on very special widget called CKeypad that
+ will provide keyboard input via an on-screen keypad that can be operated
+ via mouse or touchscreen inputs.
+
+o Many Graphic Objects
+
+ Some of the graphic objects supported by NXWidgets include labels, buttons,
+ text boxes, button arrays, check boxes, cycle buttons, images, sliders,
+ scrollable list boxes, progress bars, and more.
+
+Note: Many of the fundamental classed in NxWidgets derive from the Antony
+Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
+license. See the COPYING file for details.
+
+Directory Structure
+===================
+
+libnxwidgets
+
+ The source code, header files, and build environment for NxWidgets is
+ provided in this directory.
+
+UnitTests
+
+ Provides a collection of unit-level tests for many of the individual
+ widgets provided by libnxwidgets.
+
+nxwm
+
+ This directory holds a tiny desktop for small embedded devices with a
+ touchscreen,. NxWM. NxWM is true multiple window manager but only one
+ window is displayed at a time. This simplification helps performance on
+ LCD based products (in the same way that a tiled window manager helps)
+ and also makes the best use of small displays. It is awkward from a
+ human factors point-of-view trying to manage multiple windows on a
+ small display.
+
+ The window manager consists of a task bar with icons representing the
+ running tasks. If you touch the task's icon, it comes to the top. Each
+ window has a toolbar with (1) a title, (2) a minimize button, and (3) a
+ stop application button using the standard icons for these things.
+
+ There is always a start window that is available in the task bar. When
+ you touch the start window icon, it brings up the start window containing
+ icons representing all of the available applications. If you touch an
+ icon in the start window, it will be started and added to the task bar.
+
+ There is a base class that defines an add-on application and an
+ interface that supports incorporation of new application. The only
+ application that is provided is NxConsole. This is an NSH session
+ running in a window. You should be able to select the NX icon in the start
+ menu and create as many NSH sessions in windows as you want. (keybard input
+ still comes through serial).
diff --git a/NxWidgets/ReleaseNotes.txt b/NxWidgets/ReleaseNotes.txt
new file mode 100644
index 000000000..96ce29e1a
--- /dev/null
+++ b/NxWidgets/ReleaseNotes.txt
@@ -0,0 +1,99 @@
+NxWidgets-1.0
+=============
+
+The initial version of NxWidgets was released on March 22, 2012. This
+package has been used in several projects prior to its release to open
+source and is considered stable its initial release (although not all
+features have been fully verified).
+
+NxWidgets-1.1
+=============
+
+The 2nd release of the NxWidgets package as made on May 19, 2012. The
+headline new feature in this release is:
+
+* NxWM, the tiny window manager based on NX and NxWidgets. NxWM is true
+ multiple window manager but only one window is displayed at a time.
+ This simplification helps performance on LCD based products (in the
+ same way that a tiled window manager helps) and also makes the best
+ use of small displays. It is awkward from a human factors point-of-view
+ trying to manage multiple windows on a small display.
+
+ The window manager consists of a task bar with icons representing the
+ running tasks. If you touch the task's icon, it comes to the top. Each
+ window has a toolbar with (1) a title, (2) a minimize button, and (3) a
+ stop application button using the standard icons for these things. User
+ input via a touchscreen or mouse and keyboard is supported.
+
+ There is always a start window that is available in the task bar. When
+ you touch the start window icon, it brings up the start window containing
+ icons representing all of the available applications. If you touch an
+ icon in the start window, it will be started and added to the task bar.
+
+ There is a base class that defines an add-on application and an
+ interface that supports incorporation of new application. The only
+ application that is provided is NxConsole. This is an NSH session
+ running in a window. You should be able to select the NX icon in the start
+ menu and create as many NSH sessions in windows as you want. (keybard input
+ still comes through serial).
+
+ This initial realease of NxWM should be considered an alpha release.
+ All know issues are listed in the top-level TODO list.
+
+Other important new features include:
+
+* NxWidgets::IBitmap and NxWidgets::CRlePalettBitmap: Extended to
+ support different color look-up-tables (LUTs). This allows images
+ to be highlighted when touched, for example.
+* NxWidgets::CImage: Extended to support button-like behavior. CImage
+ widgets now work well as touchable icons.
+* NxWidgets::CWidgetControl: Add a semaphore to force clients to wait if the
+ size or position of the window is not yet known (multi-user mode only).
+ Enabled and verified creation of framed windows.
+* NxWidgets::CWindowEventHandler and NxWidgets::CWindowEventHandler: Add
+ support for getting callbacks for window events.
+* DOxygen documentation support. Contributed by Jose Pablo Carballo.
+
+An effort is underway to simplify NxWidgets and reduce its memory footprint:
+
+* NxWidgets::CNxWidget: Removed support for "shelving" widgets, reference
+ constants, and close types. Remove all support for widgets in a "vertical"
+ hierarchy. Now widgets exist in a flat, two-dimensional space and should
+ not overlap. Removed built-in modal loops.
+
+Bug fixes include changes to the following (see the ChangeLog for details):
+
+* NxWidgets::CRlePalettBitmap, NxWidgets::CRlePalettBitmap,
+ NxWidgets::CGraphicsPort, NxWidgets::CWidgetControl
+
+NxWidgets-1.2
+=============
+
+The 3rd release of the NxWidgets package as made on June 15, 2012. This
+release depends on NuttX-6.19 or above and should not be used with older
+NuttX releases.
+
+New features and enhancements include:
+
+* NxWM::CNxConsole: The NxWM NxConsole windows now correctly receive keyboard
+ input. In version 1.1, NxConsoles received input from /dev/console. That,
+ of course, leads to chaos when there a multiple windows trying to get input
+ from the same device. There is now a keyboard listener task that will
+ accept input from /dev/console and inject that input into the NX keyboard
+ interface. NX will give the keyboard input only to the top window that
+ has focus, eliminating the chaos.
+
+* NxWM::CHexcalculator: The NxWM demonstration/unit test now includes a hex
+ calculator applications. This demonstrates the use of arrays of buttons
+ within a window.
+
+Bugfixes:
+
+* NxWM::CTaskbar: Was inappropriately minimizing some windows. Fixes
+ some window raising/lowering bugs.
+
+* NXWidgets::CButtonArray: Fix some coloring problems when rending button
+ text in cases where we cannot read from the display device.
+
+As well as other, less critical bugs (see the ChangeLog for details)
+
diff --git a/NxWidgets/TODO.txt b/NxWidgets/TODO.txt
new file mode 100644
index 000000000..b767f3536
--- /dev/null
+++ b/NxWidgets/TODO.txt
@@ -0,0 +1,158 @@
+NxWidgets
+---------
+
+NxWM
+----
+
+ (4) General Issues
+ (3) NxConsole Issues
+ (1) CHexCalculator Issues
+ (1) Platform specific Issues
+
+See also the NuttX TODO list graphics/ section for related issues.
+
+o General NxWM Issues
+ -------------------
+
+ Title: DISPLAY INTIALIZATION
+ Description: During the initialization of the display, the basic frame of the
+ start window is draw momentarily. The is just the empty window
+ frame. This is a consequence of how NX creates windows: The
+ are enabled all of the time so the windows are visible when they
+ are being created. The solution would be to add some disable
+ logic in NX so that that nothing gets displayed when a window
+ is created until it is fully initialized and enable.
+ Status: Open
+ Priority: Medium
+
+ Title: DRAGGING ACROSS WINDOWS
+ Description: Need some indication if the touch/mouse drags from one window to
+ another then is release. Release event is lost in this case.
+ Status: Open
+ Priority: Low. ICON just stays selected and must be touched again.
+
+ Title: AUTO-RAISE DISABLED
+ Description: Auto-raise is currently disabled in nuttx for NX multi-server
+ mode. The
+ reason is complex:
+ - Most touchscreen controls send touch data a high rates
+ - In multi-server mode, touch events get queued in a message
+ queue.
+ - The logic that receives the messages performs the auto-raise.
+ But it can do stupid things after the first auto-raise as
+ it opperates on the stale data in the message queue.
+ I am thinking that auto-raise ought to be removed from NuttX
+ and moved out into a graphics layer (like NxWM) that knows
+ more about the appropriate context to do the autoraise.
+ Status: Open
+ Priority: Medium low
+
+ Title: THREAD SAFETY
+ Description: I am not sure how thread-safe the NxWidgets are. There is
+ is very little mutli-thread in the widgets now. The "NX listener"
+ thread interacts to update mouse (and keyboard) data but all
+ of the heavy work is done on the "start window" thread. I think
+ everything is okay now, but it may be necessary in the future
+ to introduce some semaphore protection in theCWidgetControl methods
+ to make them thread safe.
+ Status: Open
+ Priority: Low
+
+ Title: COMBINE CTouchscreen AND CKeyboard THREADS
+ Description: Right now, two separate threads handle touchscreen and keyboard/
+ console input. Each just waits on read() and when toushcscreen
+ or keyboard input is received, it injects the data into NX.
+ These two threads should be combined into one thread that waits
+ on poll for read data from either device. Then when read data
+ becomes ready for either device, it could perform the read and
+ data inject from a single thread.
+ Status: Open
+ Priority: Low, this is not a product but a text example. If NxWM were
+ to be productized, this change should be done in order to reduce
+ stack memory consumption.
+
+o NxConsole Issues
+ ----------------
+
+ Title: MULTIPLE COPIES OF AN NxCONSOLE
+ Description: From the start window, you an create multiple copies of the
+ NxConsole. However, there is a problem in the current
+ implementation: Each NxConsole receives its input from the
+ serial console so, for example, it you enter text one character
+ will go to one NxConsole instance and the next character goes
+ to a different instance. That is correct behavior within the
+ current design, but not very usable. We need a mechanism to
+ assure that the top window is the one that receives all
+ eyboard input. NX already provides this capability with its
+ nx_kbdin interface(), but that is not currently used. At present,
+ NxConsoles get their input from /dev/console which is the serial
+ port. The necessary change is to create an NX input device for
+ /dev/console that will get its input from NX.
+ Status: Closed with was fixed with the check-in of 5/20/2012 (about
+ SVN version 4755). The fixed version is available in SVN but
+ won't be in a released version until NxWidgets-1.2 is released.
+ Priority: Medium high, basically prohibits the use of multiple NSH windows.
+
+ Title: CLOSING AN NxCONSOLE
+ Description: If you open multiple NxConsole applications, they all receive
+ serial input (as noted in the previous bug). However, if
+ you close one of the NxConsoles, then the others no longer
+ received input (or no long generate output -- that cannot be
+ distinguished).
+ Status: Closed with was fixed with the check-in of 5/20/2012 (about
+ SVN version 4755). The fixed version is available in SVN but
+ won't be in a released version until NxWidgets-1.2 is released.
+ Priority: Medium high, basically prohibits the use of multiple NSH windows.
+
+ Title: DOUBLE DISPLAY UPDATES
+ Description: When the NxConsole window is first opened, there are usually
+ double updates, i.e., the display forms twice.
+ Status: Open
+ Priorioty: Low, this would be necessary to fix to productize the windows.
+
+o CHexCalculator Issues
+ ---------------------
+
+ Title: NEW DATA ENTRY IS APPENDED TO PREVIOUS RESULT
+ Description: For example 1+2= and 3 is shown. But if you enter 4, then
+ 34 is shown. You have to manually clear the calculator ("C")
+ before entering the next number.
+ Status: Open
+ Priority: Low, this is only a demo. This would, of course, have to be
+ fixed if you wanted a production quality calculator (but then
+ you would probably also want to add quite a few more features
+ as well).
+
+o Platform specific Issues
+ ------------------------
+
+ Title: MISSING TOUCH RELEASE
+ Description: Using the STM3240G-EVAL board with the STMPE11 touchscreen, you
+ will find that there are occasional missing indications of when
+ you release a icon. This is believed to be a data overrun in the
+ STPMPE11 data path. The STMPE11 generates data a very high
+ rate and it is believe that it sometimes misses the interrupt
+ that indicates that the touch is released. The symptom in NxWM
+ is that you touch an icon, it is highlighted but when you release
+ the touch nothing happens. The icon stays highlighted. Touching
+ the icon again usually works around this problem.
+ Status: Closed with was fixed with the check-in of 5/21/2012 (about
+ SVN version 4758). The was change made to NuttX, not NxWidgets.
+ The fixed version is available in SVN but won't be in a released
+ version until NuttX-6.198 is released.
+ Priorioty: Low, but really annoying.
+
+ Title: BUGS WHEN CANNOT READ FROM LCD
+ Description: There is a kludge in there to handle the case where we cannot
+ read the background data because the LCD does not support read
+ operations. You cannot read from the STM3240G-EVAL LCD right
+ now (it might be possible, but I have not figured out how yet).
+
+ In that case, we just use the default background color. However,
+ that doesn't work either for the case where the background color
+ changes when the widget is selected. Then the background color
+ in the font is wrong. There is a hack in in CButtonArrary that
+ fixed this problem, but the problem certainly exists in other
+ places as well and begs for a better solution.
+ Status: Open
+ Priority: Medium-Low
diff --git a/NxWidgets/UnitTests/CButton/Makefile b/NxWidgets/UnitTests/CButton/Makefile
new file mode 100644
index 000000000..77ba7e986
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/Unitests/CButton/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cbutton_main.cxx cbuttontest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cbutton
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CButton/cbutton-pushed.png b/NxWidgets/UnitTests/CButton/cbutton-pushed.png
new file mode 100644
index 000000000..079076b86
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/cbutton-pushed.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CButton/cbutton-released.png b/NxWidgets/UnitTests/CButton/cbutton-released.png
new file mode 100644
index 000000000..0626aedb0
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/cbutton-released.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CButton/cbutton_main.cxx b/NxWidgets/UnitTests/CButton/cbutton_main.cxx
new file mode 100644
index 000000000..973a2cd8a
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/cbutton_main.cxx
@@ -0,0 +1,155 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButton/cbutton_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cbuttontest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static const char g_pushme[] = "Push Me";
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cbutton_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cbutton_main(int argc, char *argv[])
+{
+ // Create an instance of the font test
+
+ printf("cbutton_main: Create CButtonTest instance\n");
+ CButtonTest *test = new CButtonTest();
+
+ // Connect the NX server
+
+ printf("cbutton_main: Connect the CButtonTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("cbutton_main: Failed to connect the CButtonTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a window to draw into
+
+ printf("cbutton_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("cbutton_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a CButton instance
+
+ CButton *button = test->createButton(g_pushme);
+ if (!button)
+ {
+ printf("cbutton_main: Failed to create a button\n");
+ delete test;
+ return 1;
+ }
+
+ // Show the button
+
+ printf("cbutton_main: Show the button\n");
+ test->showButton(button);
+
+ // Wait two seconds, then perform a simulated mouse click on the button
+
+ sleep(2);
+ printf("cbutton_main: Click the button\n");
+ test->click();
+
+ // Poll for the mouse click event (of course this can hang if something fails)
+
+ bool clicked = test->poll(button);
+ printf("cbutton_main: Button is %s\n", clicked ? "clicked" : "released");
+
+ // Wait a second, then release the mouse buttone
+
+ sleep(1);
+ test->release();
+
+ // Poll for the mouse release event (of course this can hang if something fails)
+
+ clicked = test->poll(button);
+ printf("cbutton_main: Button is %s\n", clicked ? "clicked" : "released");
+
+ // Wait a few more seconds so that the tester can ponder the result
+
+ sleep(3);
+
+ // Clean up and exit
+
+ printf("cbutton_main: Clean-up and exit\n");
+ delete button;
+ delete test;
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CButton/cbuttontest.cxx b/NxWidgets/UnitTests/CButton/cbuttontest.cxx
new file mode 100644
index 000000000..03411fd6e
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/cbuttontest.cxx
@@ -0,0 +1,325 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButton/cbuttontest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbuttontest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CButtonTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CButtonTest Constructor
+
+CButtonTest::CButtonTest()
+{
+ m_bgWindow = (CBgWindow *)NULL;
+ m_nxFont = (CNxFont *)NULL;
+ m_text = (CNxString *)NULL;
+}
+
+// CButtonTest Descriptor
+
+CButtonTest::~CButtonTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CButtonTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Create the default font instance
+
+ m_nxFont = new CNxFont(NXFONT_DEFAULT,
+ CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ if (!m_nxFont)
+ {
+ printf("CButtonTest::connect: Failed to create the default font\n");
+ }
+
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CBUTTONTEST_BGCOLOR))
+ {
+ printf("CButtonTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CButtonTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the display string
+
+ if (m_text)
+ {
+ delete m_text;
+ m_text = (CNxString *)NULL;
+ }
+
+ // Free the default font
+
+ if (m_nxFont)
+ {
+ delete m_nxFont;
+ m_nxFont = (CNxFont *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CButtonTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ printf("CButtonTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ printf("CButtonTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CButton instance
+
+CButton *CButtonTest::createButton(FAR const char *text)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CButtonTest::createGraphics: Failed to get window size\n");
+ return (CButton *)NULL;
+ }
+
+ // Create a CNxString instance to contain the C string
+
+ m_text = new CNxString(text);
+
+ // Get the height and width of the text display area
+
+ nxgl_coord_t stringWidth = m_nxFont->getStringWidth(*m_text);
+ nxgl_coord_t stringHeight = (nxgl_coord_t)m_nxFont->getHeight();
+
+ // The default CButton has borders enabled with thickness of the border
+ // width. Add twice the thickness of the borderto the width and height. (We
+ // could let CButton do this for us by calling CButton::getPreferredDimensions())
+
+ stringWidth += 2 * 1;
+ stringHeight += 2 * 1;
+
+ // Pick an X/Y position such that the button will be centered in the display
+
+ nxgl_coord_t buttonX;
+ if (stringWidth >= windowSize.w)
+ {
+ buttonX = 0;
+ }
+ else
+ {
+ buttonX = (windowSize.w - stringWidth) >> 1;
+ }
+
+ nxgl_coord_t buttonY;
+ if (stringHeight >= windowSize.h)
+ {
+ buttonY = 0;
+ }
+ else
+ {
+ buttonY = (windowSize.h - stringHeight) >> 1;
+ }
+
+ // Save the center position of the button for use by click and release
+
+ m_center.x = buttonX + (stringWidth >> 1);
+ m_center.y = buttonY + (stringHeight >> 1);
+
+ // Now we have enough information to create the button
+
+ return new CButton(m_widgetControl, buttonX, buttonY, stringWidth, stringHeight, *m_text);
+}
+
+// Draw the button
+
+void CButtonTest::showButton(CButton *button)
+{
+ button->enable(); // Un-necessary, the widget is enabled by default
+ button->enableDrawing();
+ button->redraw();
+}
+
+// Perform a simulated mouse click on the button. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CButtonTest::click(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CButtonTest::release(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll
+// then check if the event was processed corredly.
+
+bool CButtonTest::poll(CButton *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+
+ // And return the button clicked state
+
+ return button->isClicked();
+}
+
diff --git a/NxWidgets/UnitTests/CButton/cbuttontest.hxx b/NxWidgets/UnitTests/CButton/cbuttontest.hxx
new file mode 100644
index 000000000..10465c06e
--- /dev/null
+++ b/NxWidgets/UnitTests/CButton/cbuttontest.hxx
@@ -0,0 +1,157 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButton/cbuttontest.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 __UNITTESTS_CBUTTON_CBUTTONTEST_HXX
+#define __UNITTESTS_CBUTTON_CBUTTONTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "cbutton.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CBUTTONTEST_BGCOLOR
+# define CONFIG_CBUTTONTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CBUTTONTEST_FONTCOLOR
+# define CONFIG_CBUTTONTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CButtonTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CNxFont *m_nxFont; // Default font
+ CBgWindow *m_bgWindow; // Background window instance
+ CNxString *m_text; // The button string
+ struct nxgl_point_s m_center; // X, Y position the center of the button
+
+public:
+ // Constructor/destructors
+
+ CButtonTest();
+ ~CButtonTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CButton instance. This method will show you how to create
+ // a CButton widget
+
+ CButton *createButton(FAR const char *text);
+
+ // Draw the button. This method illustrates how to draw the CButton widget.
+
+ void showButton(CButton *button);
+
+ // Perform a simulated mouse click on the button. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(void);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(void);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll
+ // then check if the event was processed corredly.
+
+ bool poll(CButton *button);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CBUTTON_CBUTTONTEST_HXX
diff --git a/NxWidgets/UnitTests/CButtonArray/Makefile b/NxWidgets/UnitTests/CButtonArray/Makefile
new file mode 100644
index 000000000..a5a33b3b0
--- /dev/null
+++ b/NxWidgets/UnitTests/CButtonArray/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CButtonArray/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cbuttonarray_main.cxx cbuttonarraytest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cbuttonarray
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CButtonArray/cbuttonarray.png b/NxWidgets/UnitTests/CButtonArray/cbuttonarray.png
new file mode 100644
index 000000000..8609d1223
--- /dev/null
+++ b/NxWidgets/UnitTests/CButtonArray/cbuttonarray.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CButtonArray/cbuttonarray_main.cxx b/NxWidgets/UnitTests/CButtonArray/cbuttonarray_main.cxx
new file mode 100644
index 000000000..c247d73e5
--- /dev/null
+++ b/NxWidgets/UnitTests/CButtonArray/cbuttonarray_main.cxx
@@ -0,0 +1,327 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButtonArray/cbuttonarray_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cnxstring.hxx"
+#include "cbuttonarraytest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmPrevious;
+static unsigned int g_mmPeak;
+
+static FAR const char *g_buttonLabels[BUTTONARRAY_NCOLUMNS*BUTTONARRAY_NROWS] = {
+ "=>", "A", "B", "<DEL",
+ "C", "D", "E", "F",
+ "G", "H", "I", "J",
+ "K", "L", "M", "N",
+ "O", "P", "Q", "R",
+ "S", "T", "U", "V",
+ "W", "X", "Y", "Z"
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cbuttonarray_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("%s: Before: %8d After: %8d Change: %8d\n",
+ msg, previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmPrevious = mmcurrent.uordblks;
+ if ((unsigned int)mmcurrent.uordblks > g_mmPeak)
+ {
+ g_mmPeak = mmcurrent.uordblks;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmPrevious = mmcurrent.uordblks;
+ g_mmPeak = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: checkHighlighting
+/////////////////////////////////////////////////////////////////////////////
+
+static void checkHighlighting(CButtonArray *buttonArray)
+{
+ // Turn highlighting on
+
+ buttonArray->setCursorPosition(0, 0);
+ buttonArray->cursor(true);
+
+ // Then test the cursor movement
+
+ for (int row = 0; row < BUTTONARRAY_NROWS; row++)
+ {
+ for (int column = 0; column < BUTTONARRAY_NCOLUMNS; column++)
+ {
+ // Set cursor position
+
+ buttonArray->setCursorPosition(column, row);
+
+ // Check cursor position
+
+ int checkColumn;
+ int checkRow;
+ if (buttonArray->isCursorPosition(checkColumn, checkRow))
+ {
+ printf("ERROR: Not button selected\n");
+ printf(" Expected (%d,%d)\n", column, row);
+ }
+ else if (checkColumn != column || checkRow != row)
+ {
+ printf("ERROR: Wrong button selected\n");
+ printf(" Expected (%d,%d)\n", column, row);
+ printf(" Selected (%d,%d)\n", checkColumn, checkRow);
+ }
+
+ // Wait a bit so that we can see the highlighting
+
+ usleep(500*1000);
+ }
+ }
+
+ // Turn highlighting off
+
+ buttonArray->cursor(false);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cbuttonarray_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the button array test
+
+ printf("cbuttonarray_main: Create CButtonArrayTest instance\n");
+ CButtonArrayTest *test = new CButtonArrayTest();
+ updateMemoryUsage(g_mmPrevious, "After creating CButtonArrayTest");
+
+ // Connect the NX server
+
+ printf("cbuttonarray_main: Connect the CButtonArrayTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("cbuttonarray_main: Failed to connect the CButtonArrayTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After connecting to the server");
+
+ // Create a window to draw into
+
+ printf("cbuttonarray_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("cbuttonarray_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating a window");
+
+ // Create a CButtonArray instance
+
+ CButtonArray *buttonArray = test->createButtonArray();
+ if (!buttonArray)
+ {
+ printf("cbuttonarray_main: Failed to create a button array\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating CButtonArray");
+
+ // Add the labels to each button
+
+ FAR const char **ptr = g_buttonLabels;
+ for (int j = 0; j < BUTTONARRAY_NROWS; j++)
+ {
+ for (int i = 0; i < BUTTONARRAY_NCOLUMNS; i++)
+ {
+ printf("cbuttonarray_main: Label (%d,%d): %s\n", i, j, *ptr);
+ CNxString string = *ptr++;
+ buttonArray->setText(i, j, string);
+ }
+ }
+ updateMemoryUsage(g_mmPrevious, "After adding labels to the buttons");
+
+ // Show the button array
+
+ printf("cbuttonarray_main: Show the button array\n");
+ test->showButton(buttonArray);
+ sleep(1);
+
+ // Verify that button highlighting works
+
+ checkHighlighting(buttonArray);
+ updateMemoryUsage(g_mmPrevious, "After highliting");
+
+ // Then perform a simulated mouse click on a button in the array
+
+ for (int j = 0; j < BUTTONARRAY_NROWS; j++)
+ {
+ for (int i = 0; i < BUTTONARRAY_NCOLUMNS; i++)
+ {
+ printf("cbuttonarray_main: Click the button (%d,%d)\n", i, j);
+ test->click(buttonArray, i, j);
+
+ // Poll for the mouse click event
+
+ test->poll(buttonArray);
+
+ // Is anything clicked?
+
+ int clickColumn;
+ int clickRow;
+ if (buttonArray->isButtonClicked(clickColumn, clickRow))
+ {
+ printf("cbuttonarray_main: %s: Button (%d, %d) is clicked\n",
+ clickColumn == i && clickRow == j ? "OK" : "ERROR",
+ clickColumn, clickRow);
+ }
+ else
+ {
+ printf("cbuttonarray_main: ERROR: No button is clicked\n");
+ }
+
+ // Wait a bit, then release the mouse button
+
+ usleep(500*1000);
+ test->release(buttonArray, i, j);
+
+ // Poll for the mouse release event (of course this can hang if something fails)
+
+ test->poll(buttonArray);
+ if (buttonArray->isButtonClicked(clickColumn, clickRow))
+ {
+ printf("cbuttonarray_main: ERROR: Button (%d, %d) is clicked\n",
+ clickColumn, clickRow);
+ }
+
+ usleep(500*1000);
+ }
+ }
+ updateMemoryUsage(g_mmPrevious, "After pushing buttons");
+
+ // Clean up and exit
+
+ printf("cbuttonarray_main: Clean-up and exit\n");
+ delete buttonArray;
+ updateMemoryUsage(g_mmPrevious, "After deleting the button array");
+ delete test;
+ updateMemoryUsage(g_mmPrevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ message("Peak memory usage: %8d\n", g_mmPeak - g_mmInitial);
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.cxx b/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.cxx
new file mode 100644
index 000000000..c1ad0e7a4
--- /dev/null
+++ b/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.cxx
@@ -0,0 +1,301 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbuttonarraytest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CButtonArrayTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CButtonArrayTest Constructor
+
+CButtonArrayTest::CButtonArrayTest()
+{
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CButtonArrayTest Descriptor
+
+CButtonArrayTest::~CButtonArrayTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CButtonArrayTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CBUTTONARRAYTEST_BGCOLOR))
+ {
+ message("CButtonArrayTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CButtonArrayTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Destroy the widget control
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CButtonArrayTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CButtonArrayTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CButtonArrayTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CButtonArray instance
+
+CButtonArray *CButtonArrayTest::createButtonArray(void)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CButtonArrayTest::createGraphics: Failed to get window size\n");
+ return (CButtonArray *)NULL;
+ }
+
+ // Pick an X/Y position such that the button array will be centered in the display
+
+ nxgl_coord_t buttonArrayX;
+ if (BUTTONARRAY_WIDTH >= windowSize.w)
+ {
+ buttonArrayX = 0;
+ }
+ else
+ {
+ buttonArrayX = (windowSize.w - BUTTONARRAY_WIDTH) >> 1;
+ }
+
+ nxgl_coord_t buttonArrayY;
+ if (BUTTONARRAY_HEIGHT >= windowSize.h)
+ {
+ buttonArrayY = 0;
+ }
+ else
+ {
+ buttonArrayY = (windowSize.h - BUTTONARRAY_HEIGHT) >> 1;
+ }
+
+ // Now we have enough information to create the button array
+
+ return new CButtonArray(m_widgetControl,
+ buttonArrayX, buttonArrayY,
+ BUTTONARRAY_NCOLUMNS, BUTTONARRAY_NROWS,
+ BUTTONARRAY_BUTTONWIDTH, BUTTONARRAY_BUTTONHEIGHT);
+}
+
+// Draw the button array
+
+void CButtonArrayTest::showButton(CButtonArray *buttonArray)
+{
+ buttonArray->enable(); // Un-necessary, the widget is enabled by default
+ buttonArray->enableDrawing();
+ buttonArray->redraw();
+}
+
+// Perform a simulated mouse click on a button in the array. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CButtonArrayTest::click(CButtonArray *buttonArray, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the selected button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = buttonArray->getX() +
+ column * BUTTONARRAY_BUTTONWIDTH +
+ BUTTONARRAY_BUTTONWIDTH/2;
+ nxgl_coord_t buttonY = buttonArray->getY() +
+ row * BUTTONARRAY_BUTTONHEIGHT +
+ BUTTONARRAY_BUTTONHEIGHT/2;
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CButtonArrayTest::release(CButtonArray *buttonArray, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = buttonArray->getX() +
+ column * BUTTONARRAY_BUTTONWIDTH +
+ BUTTONARRAY_BUTTONWIDTH/2;
+ nxgl_coord_t buttonY = buttonArray->getY() +
+ row * BUTTONARRAY_BUTTONHEIGHT +
+ BUTTONARRAY_BUTTONHEIGHT/2;
+
+ // Then inject the mouse release
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll
+// then check if the event was processed corredly.
+
+void CButtonArrayTest::poll(CButtonArray *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+}
+
diff --git a/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.hxx b/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.hxx
new file mode 100644
index 000000000..b8a9e15e5
--- /dev/null
+++ b/NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.hxx
@@ -0,0 +1,172 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CButtonArray/cbuttonarraytest.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 __UNITTESTS_CBUTTONARRAY_CBUTTONARRAYTEST_HXX
+#define __UNITTESTS_CBUTTONARRAY_CBUTTONARRAYTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "cbuttonarray.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CBUTTONARRAYTEST_BGCOLOR
+# define CONFIG_CBUTTONARRAYTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CBUTTONARRAYTEST_FONTCOLOR
+# define CONFIG_CBUTTONARRAYTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+// The geometry of the button array
+
+#define BUTTONARRAY_NCOLUMNS 4
+#define BUTTONARRAY_NROWS 7
+#define BUTTONARRAY_BUTTONWIDTH 60
+#define BUTTONARRAY_BUTTONHEIGHT 32
+#define BUTTONARRAY_WIDTH (BUTTONARRAY_BUTTONWIDTH * BUTTONARRAY_NCOLUMNS)
+#define BUTTONARRAY_HEIGHT (BUTTONARRAY_BUTTONHEIGHT * BUTTONARRAY_NROWS)
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CButtonArrayTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The widget control for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CButtonArrayTest();
+ ~CButtonArrayTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CButtonArray instance. This method will show you how to create
+ // a CButtonArray widget
+
+ CButtonArray *createButtonArray(void);
+
+ // Draw the button array. This method illustrates how to draw the CButtonArray widget.
+
+ void showButton(CButtonArray *buttonArray);
+
+ // Perform a simulated mouse click on a button in the array. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(CButtonArray *buttonArray, int column, int row);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(CButtonArray *buttonArray, int column, int row);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll
+ // then check if the event was processed corredly.
+
+ void poll(CButtonArray *buttonArray);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CBUTTONARRAY_CBUTTONARRAYTEST_HXX
diff --git a/NxWidgets/UnitTests/CCheckBox/Makefile b/NxWidgets/UnitTests/CCheckBox/Makefile
new file mode 100644
index 000000000..9b46cef8d
--- /dev/null
+++ b/NxWidgets/UnitTests/CCheckBox/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CCheckBox/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = ccheckbox_main.cxx ccheckboxtest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = ccheckbox
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CCheckBox/ccheckbox.png b/NxWidgets/UnitTests/CCheckBox/ccheckbox.png
new file mode 100644
index 000000000..9f51c82f0
--- /dev/null
+++ b/NxWidgets/UnitTests/CCheckBox/ccheckbox.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CCheckBox/ccheckbox_main.cxx b/NxWidgets/UnitTests/CCheckBox/ccheckbox_main.cxx
new file mode 100644
index 000000000..949cbc35f
--- /dev/null
+++ b/NxWidgets/UnitTests/CCheckBox/ccheckbox_main.cxx
@@ -0,0 +1,209 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CCheckBox/ccheckbox_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "crlepalettebitmap.hxx"
+#include "glyphs.hxx"
+#include "ccheckboxtest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int ccheckbox_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int ccheckbox_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("ccheckbox_main: Create CCheckBoxTest instance\n");
+ CCheckBoxTest *test = new CCheckBoxTest();
+ updateMemoryUsage(g_mmprevious, "After creating CCheckBoxTest");
+
+ // Connect the NX server
+
+ message("ccheckbox_main: Connect the CCheckBoxTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("ccheckbox_main: Failed to connect the CCheckBoxTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "ccheckbox_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("ccheckbox_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("ccheckbox_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "ccheckbox_main: After creating a window");
+
+ // Show the initial state of the checkbox
+
+ test->showCheckBox();
+ test->showCheckBoxState();
+ sleep(1);
+
+ // Now click the checkbox
+
+ message("ccheckbox_main: Click 1\n");
+ test->clickCheckBox();
+ usleep(500*1000);
+ test->showCheckBoxState();
+ updateMemoryUsage(g_mmprevious, "After click 1");
+ usleep(500*1000);
+
+ message("ccheckbox_main: Click 2\n");
+ test->clickCheckBox();
+ usleep(500*1000);
+ test->showCheckBoxState();
+ updateMemoryUsage(g_mmprevious, "After click 2");
+ usleep(500*1000);
+
+ message("ccheckbox_main: Click 3\n");
+ test->clickCheckBox();
+ usleep(500*1000);
+ test->showCheckBoxState();
+ updateMemoryUsage(g_mmprevious, "After click 3");
+ sleep(2);
+
+ // Clean up and exit
+
+ message("ccheckbox_main: Clean-up and exit\n");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.cxx b/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.cxx
new file mode 100644
index 000000000..e9ccc7628
--- /dev/null
+++ b/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.cxx
@@ -0,0 +1,297 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CCheckBox/ccheckboxtest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "ccheckboxtest.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CCheckBoxTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CCheckBoxTest Constructor
+
+CCheckBoxTest::CCheckBoxTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+ m_checkBox = (CCheckBox *)NULL;
+}
+
+// CCheckBoxTest Descriptor
+
+CCheckBoxTest::~CCheckBoxTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CCheckBoxTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CCHECKBOXTEST_BGCOLOR))
+ {
+ message("CCheckBoxTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CCheckBoxTest::disconnect(void)
+{
+ // Free the radiobutton group
+
+ if (m_checkBox)
+ {
+ delete m_checkBox;
+ m_checkBox = (CCheckBox *)NULL;
+ }
+
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CCheckBoxTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CCheckBoxTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CCheckBoxTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CCheckBoxTest::createWindow: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Use the the size of the ON checkbox glyph. (adding twice the border thickness)
+
+ nxgl_coord_t width = g_checkBoxOn.width + 2 * 1;
+ nxgl_coord_t height = g_checkBoxOn.height + 2 * 1;
+
+ nxgl_coord_t checkboxX = (windowSize.w - width) >> 1;
+ nxgl_coord_t checkboxY = (windowSize.h - height) >> 1;
+
+ // Create the checkbox
+
+ m_checkBox = new CCheckBox(m_widgetControl, checkboxX, checkboxY,
+ width, height, (CWidgetStyle *)NULL);
+ if (!m_checkBox)
+ {
+ printf("CCheckBoxTest::createWindow: Failed to create CCheckBox\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// (Re-)draw the check box.
+
+void CCheckBoxTest::showCheckBox(void)
+{
+ m_checkBox->enable(); // Un-necessary, the widget is enabled by default
+ m_checkBox->enableDrawing();
+ m_checkBox->redraw();
+}
+
+// Push the radio button
+
+void CCheckBoxTest::clickCheckBox(void)
+{
+ // Get the checkbox center coordinates
+
+ nxgl_coord_t checkboxX = m_checkBox->getX() + (m_checkBox->getWidth() >> 1);
+ nxgl_coord_t checkboxY = m_checkBox->getY() + (m_checkBox->getHeight() >> 1);
+
+ // Click the checkbox by calling nx_mousein. nx_mousein is meant to be
+ // called by mouse handling software. Here we just inject a left-button click
+ // directly in the center of the radio button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, checkboxX, checkboxY, NX_MOUSE_LEFTBUTTON);
+
+ // Poll for mouse events
+ //
+ // Widget events are normally handled in a modal loop.
+ // However, for this case we know that we just pressed the mouse button
+ // so we don't have to poll. We can just perform a one pass poll then
+ // then check if the mouse event was processed corredly.
+
+ m_widgetControl->pollEvents(m_checkBox);
+
+ // Then inject the mouse release
+
+ (void)nx_mousein(handle, checkboxX, checkboxY, 0);
+
+ // And poll for more mouse events
+
+ m_widgetControl->pollEvents(m_checkBox);
+
+ // And re-draw the buttons (the mouse click event should have automatically
+ // triggered the re-draw)
+ //
+ // showCheckBox();
+}
+
+// Show the state of the radio button group
+
+void CCheckBoxTest::showCheckBoxState(void)
+{
+ CCheckBox::CheckBoxState state = m_checkBox->getState();
+ switch (state)
+ {
+ case CCheckBox::CHECK_BOX_STATE_OFF: // Checkbox is unticked
+ message("CCheckBoxTest::showCheckBoxState Checkbox is in the unticked state\n");
+ break;
+
+ case CCheckBox::CHECK_BOX_STATE_ON: // Checkbox is ticked
+ message("CCheckBoxTest::showCheckBoxState Check is in the ticked state\n");
+ break;
+
+ default:
+ case CCheckBox::CHECK_BOX_STATE_MU: // Checkbox is in the third state
+ message("CCheckBoxTest::showCheckBoxState Checkbox is in the 3rd state\n");
+ break;
+ }
+}
diff --git a/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.hxx b/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.hxx
new file mode 100644
index 000000000..0397b37dd
--- /dev/null
+++ b/NxWidgets/UnitTests/CCheckBox/ccheckboxtest.hxx
@@ -0,0 +1,142 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CCheckBox/ccheckboxtest.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 __UNITTESTS_CCHECKBOX_CCHECKBOXTEST_HXX
+#define __UNITTESTS_CCHECKBOX_CCHECKBOXTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "ccheckbox.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CCHECKBOXTEST_BGCOLOR
+# define CONFIG_CCHECKBOXTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CCheckBoxTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+ CCheckBox *m_checkBox; // Checkgox instance under test
+
+public:
+ // Constructor/destructors
+
+ CCheckBoxTest(void);
+ ~CCheckBoxTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // (Re-)draw the checkbox.
+
+ void showCheckBox(void);
+
+ // Simulate pushing and releasing of the radio button
+
+ void clickCheckBox(void);
+
+ // Show the state of the radio button group
+
+ void showCheckBoxState(void);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CCHECKBOX_CCHECKBOXTEST_HXX
diff --git a/NxWidgets/UnitTests/CGlyphButton/Makefile b/NxWidgets/UnitTests/CGlyphButton/Makefile
new file mode 100644
index 000000000..5f2522e49
--- /dev/null
+++ b/NxWidgets/UnitTests/CGlyphButton/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CGlyphButton/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cglyphbutton_main.cxx cglyphbuttontest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cglyphbutton
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CGlyphButton/cglyphbutton_main.cxx b/NxWidgets/UnitTests/CGlyphButton/cglyphbutton_main.cxx
new file mode 100644
index 000000000..95e255dcc
--- /dev/null
+++ b/NxWidgets/UnitTests/CGlyphButton/cglyphbutton_main.cxx
@@ -0,0 +1,225 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CGlyphButton/cglyphbutton_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cglyphbuttontest.hxx"
+#include "glyphs.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cglyphbutton_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cglyphbutton_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the font test
+
+ message("cglyphbutton_main: Create CGlyphButtonTest instance\n");
+ CGlyphButtonTest *test = new CGlyphButtonTest();
+ updateMemoryUsage(g_mmprevious, "After creating CGlyphButtonTest");
+
+ // Connect the NX server
+
+ message("cglyphbutton_main: Connect the CGlyphButtonTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cglyphbutton_main: Failed to connect the CGlyphButtonTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cglyphbutton_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cglyphbutton_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "After creating a window");
+
+ // Create a CGlyphButton instance
+
+ CGlyphButton *button = test->createButton(&g_arrowDown, &g_arrowUp);
+ if (!button)
+ {
+ message("cglyphbutton_main: Failed to create a button\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "After creating the glyph button");
+
+ // Show the button
+
+ message("cglyphbutton_main: Show the button\n");
+ test->showButton(button);
+ updateMemoryUsage(g_mmprevious, "After showing the glyph button");
+
+ // Wait two seconds, then perform a simulated mouse click on the button
+
+ sleep(2);
+ message("cglyphbutton_main: Click the button\n");
+ test->click();
+ updateMemoryUsage(g_mmprevious, "After clicking glyph button");
+
+ // Poll for the mouse click event (of course this can hang if something fails)
+
+ bool clicked = test->poll(button);
+ message("cglyphbutton_main: Button is %s\n", clicked ? "clicked" : "released");
+
+ // Wait a second, then release the mouse buttone
+
+ sleep(1);
+ test->release();
+ updateMemoryUsage(g_mmprevious, "After releasing glyph button");
+
+ // Poll for the mouse release event (of course this can hang if something fails)
+
+ clicked = test->poll(button);
+ message("cglyphbutton_main: Button is %s\n", clicked ? "clicked" : "released");
+
+ // Wait a few more seconds so that the tester can ponder the result
+
+ sleep(3);
+
+ // Clean up and exit
+
+ message("cglyphbutton_main: Clean-up and exit\n");
+ delete button;
+ updateMemoryUsage(g_mmprevious, "After deleting the glyph button");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.cxx b/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.cxx
new file mode 100644
index 000000000..801da7289
--- /dev/null
+++ b/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.cxx
@@ -0,0 +1,307 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cglyphbuttontest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CGlyphButtonTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CGlyphButtonTest Constructor
+
+CGlyphButtonTest::CGlyphButtonTest()
+{
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+ m_center.x = 0;
+ m_center.y = 0;
+}
+
+// CGlyphButtonTest Descriptor
+
+CGlyphButtonTest::~CGlyphButtonTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CGlyphButtonTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CGLYPHBUTTONTEST_BGCOLOR))
+ {
+ message("CGlyphButtonTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CGlyphButtonTest::disconnect(void)
+{
+ // Delete the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CGlyphButtonTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CGlyphButtonTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CGlyphButtonTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CGlyphButton instance
+
+CGlyphButton *CGlyphButtonTest::createButton(FAR const struct SBitmap *clickGlyph,
+ FAR const struct SBitmap *unClickedGlyph)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CGlyphButtonTest::createGraphics: Failed to get window size\n");
+ return (CGlyphButton *)NULL;
+ }
+
+ // Get the height and width of the glyph display area
+
+ nxgl_coord_t glyphWidth = MAX(clickGlyph->width, unClickedGlyph->width);
+ nxgl_coord_t glyphHeight = MAX(clickGlyph->height, unClickedGlyph->height);
+
+ // The default CGlyphButton has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height. (We
+ // could let CGlyphButton do this for us by calling
+ // CGlyphButton::getPreferredDimensions())
+
+ glyphWidth += 2 * 1;
+ glyphHeight += 2 * 1;
+
+ // Pick an X/Y position such that the button will be centered in the display
+
+ nxgl_coord_t buttonX;
+ if (glyphWidth >= windowSize.w)
+ {
+ buttonX = 0;
+ }
+ else
+ {
+ buttonX = (windowSize.w - glyphWidth) >> 1;
+ }
+
+ nxgl_coord_t buttonY;
+ if (glyphHeight >= windowSize.h)
+ {
+ buttonY = 0;
+ }
+ else
+ {
+ buttonY = (windowSize.h - glyphHeight) >> 1;
+ }
+
+ // Save the center position of the button for use by click and release
+
+ m_center.x = buttonX + (glyphWidth >> 1);
+ m_center.y = buttonY + (glyphHeight >> 1);
+
+ // Now we have enough information to create the button
+
+ return new CGlyphButton(m_widgetControl, buttonX, buttonY,
+ glyphWidth, glyphHeight,
+ unClickedGlyph, clickGlyph);
+}
+
+// Draw the button
+
+void CGlyphButtonTest::showButton(CGlyphButton *button)
+{
+ button->enable(); // Un-necessary, the widget is enabled by default
+ button->enableDrawing();
+ button->redraw();
+}
+
+// Perform a simulated mouse click on the button. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CGlyphButtonTest::click(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CGlyphButtonTest::release(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll
+// then check if the event was processed corredly.
+
+bool CGlyphButtonTest::poll(CGlyphButton *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+
+ // And return the button clicked state
+
+ return button->isClicked();
+}
+
diff --git a/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.hxx b/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.hxx
new file mode 100644
index 000000000..b3e5bb656
--- /dev/null
+++ b/NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.hxx
@@ -0,0 +1,172 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CGlyphButton/cglyphbuttontest.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 __UNITTESTS_CGLYPHBUTTON_CGLYPHBUTTONTEST_HXX
+#define __UNITTESTS_CGLYPHBUTTON_CGLYPHBUTTONTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "cglyphbutton.hxx"
+#include "cbitmap.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CGLYPHBUTTONTEST_BGCOLOR
+# define CONFIG_CGLYPHBUTTONTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CGLYPHBUTTONTEST_FONTCOLOR
+# define CONFIG_CGLYPHBUTTONTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+// Helper macros
+
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CGlyphButtonTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+ struct nxgl_point_s m_center; // X, Y position the center of the button
+
+public:
+ // Constructor/destructors
+
+ CGlyphButtonTest();
+ ~CGlyphButtonTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CGlyphButton instance. This method will show you how to create
+ // a CGlyphButton widget
+
+ CGlyphButton *createButton(FAR const struct SBitmap *clickGlyph,
+ FAR const struct SBitmap *unClickedGlyph);
+
+ // Draw the button. This method illustrates how to draw the CGlyphButton widget.
+
+ void showButton(CGlyphButton *button);
+
+ // Perform a simulated mouse click on the button. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(void);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(void);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll
+ // then check if the event was processed corredly.
+
+ bool poll(CGlyphButton *button);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CGLYPHBUTTON_CGLYPHBUTTONTEST_HXX
diff --git a/NxWidgets/UnitTests/CImage/Makefile b/NxWidgets/UnitTests/CImage/Makefile
new file mode 100644
index 000000000..46e69c495
--- /dev/null
+++ b/NxWidgets/UnitTests/CImage/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CImage/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cimage_main.cxx cimagetest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cimage
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CImage/cimage_main.cxx b/NxWidgets/UnitTests/CImage/cimage_main.cxx
new file mode 100644
index 000000000..30cf49d3e
--- /dev/null
+++ b/NxWidgets/UnitTests/CImage/cimage_main.cxx
@@ -0,0 +1,222 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CImage/cimage_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "crlepalettebitmap.hxx"
+#include "glyphs.hxx"
+#include "cimagetest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static struct mallinfo g_mmInitial;
+static struct mallinfo g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cimage_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void showMemoryUsage(FAR struct mallinfo *mmbefore,
+ FAR struct mallinfo *mmafter)
+{
+ message("VARIABLE BEFORE AFTER\n");
+ message("======== ======== ========\n");
+ message("arena %8d %8d\n", mmbefore->arena, mmafter->arena);
+ message("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks);
+ message("mxordblk %8d %8d\n", mmbefore->mxordblk, mmafter->mxordblk);
+ message("uordblks %8d %8d\n", mmbefore->uordblks, mmafter->uordblks);
+ message("fordblks %8d %8d\n", mmbefore->fordblks, mmafter->fordblks);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(FAR struct mallinfo *previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ showMemoryUsage(previous, &mmcurrent);
+
+ /* Set up for the next test */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ g_mmprevious = mmcurrent;
+#else
+ memcpy(&g_mmprevious, &mmcurrent, sizeof(struct mallinfo));
+#endif
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ g_mmInitial = mallinfo();
+ g_mmprevious = g_mmInitial;
+#else
+ (void)mallinfo(&g_mmInitial);
+ memcpy(&g_mmprevious, &g_mmInitial, sizeof(struct mallinfo));
+#endif
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cimage_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the font test
+
+ message("cimage_main: Create CImageTest instance\n");
+ CImageTest *test = new CImageTest();
+ updateMemoryUsage(&g_mmprevious, "After creating CImageTest");
+
+ // Connect the NX server
+
+ message("cimage_main: Connect the CImageTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cimage_main: Failed to connect the CImageTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(&g_mmprevious, "After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cimage_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cimage_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(&g_mmprevious, "After creating a window");
+
+ // Create an instance of the NuttX logo
+
+ CRlePaletteBitmap *nuttxBitmap = new CRlePaletteBitmap(&g_nuttxBitmap);
+ updateMemoryUsage(&g_mmprevious, "After creating the bitmap");
+
+ // Create a CImage instance
+
+ CImage *image = test->createImage(static_cast<IBitmap*>(nuttxBitmap));
+ if (!image)
+ {
+ message("cimage_main: Failed to create a image\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(&g_mmprevious, "After creating CImage");
+
+ // Show the image
+
+ test->showImage(image);
+ updateMemoryUsage(&g_mmprevious, "After showing the image");
+ sleep(5);
+
+ // Clean up and exit
+
+ message("cimage_main: Clean-up and exit\n");
+ delete image;
+ updateMemoryUsage(&g_mmprevious, "After deleting CImage");
+
+ delete nuttxBitmap;
+ updateMemoryUsage(&g_mmprevious, "After deleting the bitmap");
+
+ delete test;
+ updateMemoryUsage(&g_mmprevious, "After deleting the test");
+ updateMemoryUsage(&g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CImage/cimagetest.cxx b/NxWidgets/UnitTests/CImage/cimagetest.cxx
new file mode 100644
index 000000000..48814c4ce
--- /dev/null
+++ b/NxWidgets/UnitTests/CImage/cimagetest.cxx
@@ -0,0 +1,240 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CImage/cimagetest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "ibitmap.hxx"
+#include "cbgwindow.hxx"
+#include "cimagetest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CImageTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CImageTest Constructor
+
+CImageTest::CImageTest()
+{
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CImageTest Descriptor
+
+CImageTest::~CImageTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CImageTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CIMAGETEST_BGCOLOR))
+ {
+ message("CImageTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CImageTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CImageTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CImageTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CImageTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CImage instance
+
+CImage *CImageTest::createImage(IBitmap *bitmap)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CImageTest::createGraphics: Failed to get window size\n");
+ return (CImage *)NULL;
+ }
+
+ // Get the height and width of the image
+
+ nxgl_coord_t imageWidth = bitmap->getWidth();
+ nxgl_coord_t imageHeight = (nxgl_coord_t)bitmap->getHeight();
+
+ // The default CImage has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height. (We
+ // could let CImage do this for us by calling CImage::getPreferredDimensions())
+
+ imageWidth += 2 * 1;
+ imageHeight += 2 * 1;
+
+ // Pick an X/Y position such that the image will be centered in the display
+
+ nxgl_coord_t imageX;
+ if (imageWidth >= windowSize.w)
+ {
+ imageX = 0;
+ }
+ else
+ {
+ imageX = (windowSize.w - imageWidth) >> 1;
+ }
+
+ nxgl_coord_t imageY;
+ if (imageHeight >= windowSize.h)
+ {
+ imageY = 0;
+ }
+ else
+ {
+ imageY = (windowSize.h - imageHeight) >> 1;
+ }
+
+ // Now we have enough information to create the image
+
+ return new CImage(m_widgetControl, imageX, imageY, imageWidth, imageHeight, bitmap);
+}
+
+// Draw the image
+
+void CImageTest::showImage(CImage *image)
+{
+ image->enable();
+ image->enableDrawing();
+ image->redraw();
+ image->disableDrawing();
+}
diff --git a/NxWidgets/UnitTests/CImage/cimagetest.hxx b/NxWidgets/UnitTests/CImage/cimagetest.hxx
new file mode 100644
index 000000000..9592f2936
--- /dev/null
+++ b/NxWidgets/UnitTests/CImage/cimagetest.hxx
@@ -0,0 +1,140 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CImage/cimagetest.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 __UNITTESTS_CIMAGE_CIMAGETEST_HXX
+#define __UNITTESTS_CIMAGE_CIMAGETEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "cimage.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CIMAGETEST_BGCOLOR
+# define CONFIG_CIMAGETEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CImageTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CImageTest(void);
+ ~CImageTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CImage instance. This method will show you how to create
+ // a CImage widget
+
+ CImage *createImage(IBitmap *bitmap);
+
+ // Draw the image. This method illustrates how to draw the CImage widget.
+
+ void showImage(CImage *image);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CIMAGE_CIMAGETEST_HXX
diff --git a/NxWidgets/UnitTests/CKeypad/Makefile b/NxWidgets/UnitTests/CKeypad/Makefile
new file mode 100644
index 000000000..3d37c26fe
--- /dev/null
+++ b/NxWidgets/UnitTests/CKeypad/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CKeyPad/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = ckeypad_main.cxx ckeypadtest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = ckeypad
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CKeypad/ckeypad_main.cxx b/NxWidgets/UnitTests/CKeypad/ckeypad_main.cxx
new file mode 100644
index 000000000..896ef5013
--- /dev/null
+++ b/NxWidgets/UnitTests/CKeypad/ckeypad_main.cxx
@@ -0,0 +1,274 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CKeypad/ckeypad_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cnxstring.hxx"
+#include "ckeypadtest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmPrevious;
+static unsigned int g_mmPeak;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int ckeypad_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("%s: Before: %8d After: %8d Change: %8d\n",
+ msg, previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmPrevious = mmcurrent.uordblks;
+ if ((unsigned int)mmcurrent.uordblks > g_mmPeak)
+ {
+ g_mmPeak = mmcurrent.uordblks;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmPrevious = mmcurrent.uordblks;
+ g_mmPeak = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: clickButtons
+/////////////////////////////////////////////////////////////////////////////
+
+static void clickButtons(CKeypadTest *test, CKeypad *keypad)
+{
+ // Perform a simulated mouse click on a button in the keypad
+
+ for (int j = 0; j < KEYPAD_NROWS; j++)
+ {
+ for (int i = 0; i < KEYPAD_NCOLUMNS; i++)
+ {
+ printf("clickButtons: Click the button (%d,%d)\n", i, j);
+ test->click(keypad, i, j);
+
+ // Poll for the mouse click event
+
+ test->poll(keypad);
+
+ // Is anything clicked?
+
+ int clickColumn;
+ int clickRow;
+ if (keypad->isButtonClicked(clickColumn, clickRow))
+ {
+ printf("clickButtons: %s: Button (%d, %d) is clicked\n",
+ clickColumn == i && clickRow == j ? "OK" : "ERROR",
+ clickColumn, clickRow);
+ }
+ else
+ {
+ printf("clickButtons: ERROR: No button is clicked\n");
+ }
+
+ // Wait a bit, then release the mouse button
+
+ usleep(250*1000);
+ test->release(keypad, i, j);
+
+ // Poll for the mouse release event (of course this can hang if something fails)
+
+ test->poll(keypad);
+ if (keypad->isButtonClicked(clickColumn, clickRow))
+ {
+ printf("clickButtons: ERROR: Button (%d, %d) is clicked\n",
+ clickColumn, clickRow);
+ }
+
+ usleep(500*1000);
+ }
+ }
+ updateMemoryUsage(g_mmPrevious, "After pushing buttons");
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int ckeypad_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the keypad test
+
+ printf("ckeypad_main: Create CKeypadTest instance\n");
+ CKeypadTest *test = new CKeypadTest();
+ updateMemoryUsage(g_mmPrevious, "After creating CKeypadTest");
+
+ // Connect the NX server
+
+ printf("ckeypad_main: Connect the CKeypadTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("ckeypad_main: Failed to connect the CKeypadTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After connecting to the server");
+
+ // Create a window to draw into
+
+ printf("ckeypad_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("ckeypad_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating a window");
+
+ // Create a CKeypad instance
+
+ CKeypad *keypad = test->createKeypad();
+ if (!keypad)
+ {
+ printf("ckeypad_main: Failed to create a keypad\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating CKeypad");
+
+ // Show the keypad in alphabetic mode
+
+ printf("ckeypad_main: Show the keypad in alphabetic mode\n");
+ keypad->setKeypadMode(false);
+ test->showKeypad(keypad);
+ sleep(1);
+
+ // Then click some buttons
+
+ clickButtons(test, keypad);
+ sleep(1);
+
+ // Show the keypad in numeric mode
+
+ printf("ckeypad_main: Show the keypad in numeric mode\n");
+ keypad->setKeypadMode(true);
+ sleep(1);
+
+ // Then click some buttons
+
+ clickButtons(test, keypad);
+ sleep(1);
+
+ // Clean up and exit
+
+ printf("ckeypad_main: Clean-up and exit\n");
+ delete keypad;
+ updateMemoryUsage(g_mmPrevious, "After deleting the keypad");
+ delete test;
+ updateMemoryUsage(g_mmPrevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ message("Peak memory usage: %8d\n", g_mmPeak - g_mmInitial);
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CKeypad/ckeypadtest.cxx b/NxWidgets/UnitTests/CKeypad/ckeypadtest.cxx
new file mode 100644
index 000000000..300148cc3
--- /dev/null
+++ b/NxWidgets/UnitTests/CKeypad/ckeypadtest.cxx
@@ -0,0 +1,458 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CKeypad/ckeypadtest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "ckeypadtest.hxx"
+#include "cbgwindow.hxx"
+#include "cnxstring.hxx"
+#include "cnxfont.hxx"
+#include "crect.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CKeypadTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CKeypadTest Constructor
+
+CKeypadTest::CKeypadTest()
+{
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+ m_buttonWidth = 0;
+ m_buttonHeight = 0;
+ m_displayHeight = 0;
+}
+
+// CKeypadTest Descriptor
+
+CKeypadTest::~CKeypadTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CKeypadTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CKEYPADTEST_BGCOLOR))
+ {
+ message("CKeypadTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CKeypadTest::disconnect(void)
+{
+ // Destroy the text box
+
+ if (m_textbox)
+ {
+ delete m_textbox;
+ }
+
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Destroy the widget control
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CKeypadTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CKeypadTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CKeypadTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ // Then determine the display size
+
+ setDisplaySize();
+ return true;
+}
+
+// Pick size of the display
+
+void CKeypadTest::setDisplaySize(void)
+{
+ // Get the height and width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CKeypadTest::createGraphics: Failed to get window size\n");
+ return;
+ }
+
+ // Pick a height and width of a button. Here we use inside information
+ // that the number of rows and columns in the keypad. This should not matter in
+ // a "real" application.
+
+ // Lets aim for a width of 4*60 = 240
+
+ if (windowSize.w > KEYPAD_NCOLUMNS*60)
+ {
+ m_buttonWidth = 60;
+ }
+ else
+ {
+ // Otherwise, let's use what we have
+
+ m_buttonWidth = windowSize.w >> 2;
+ }
+
+ // Lets aim for a height of 7*32 = 224. But lets bump up the number of rows
+ // to allow one for the text box.
+
+ if (windowSize.h > (KEYPAD_NROWS+1)*32)
+ {
+ m_buttonHeight = 32;
+ m_displayHeight = (KEYPAD_NROWS+1)*32;
+ }
+ else
+ {
+ // Otherwise, let's use what we have
+
+ m_buttonHeight = windowSize.h >> 3;
+ m_displayHeight = windowSize.h;
+ }
+}
+
+// Create a CKeypad instance
+
+CKeypad *CKeypadTest::createKeypad(void)
+{
+ // Get the height and width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CKeypadTest::createGraphics: Failed to get window size\n");
+ return (CKeypad *)NULL;
+ }
+
+ // Pick a height and width. Here we use inside information that the number
+ // of rows in the keypad is 7. This should not matter in a "real" application.
+
+ nxgl_coord_t keypadWidth = KEYPAD_NCOLUMNS * m_buttonWidth;
+ nxgl_coord_t keypadHeight = KEYPAD_NROWS * m_buttonHeight;
+
+ // Pick an X/Y position such that the keypad will be centered in the display
+
+ nxgl_coord_t keypadOffset = m_displayHeight - keypadHeight;
+
+ nxgl_coord_t keypadX = (windowSize.w - keypadWidth) >> 1;
+ nxgl_coord_t keypadY = keypadOffset + ((windowSize.h - m_displayHeight) >> 1);
+
+ // Now we have enough information to create the keypad
+
+ CKeypad *keypad = new CKeypad(m_widgetControl, getServer(), keypadX, keypadY,
+ keypadWidth, keypadHeight);
+ if (keypad)
+ {
+ // Create a text box to catch the keyboard inputs
+
+ m_textbox = createTextBox();
+ if (!m_textbox)
+ {
+ delete keypad;
+ keypad = (CKeypad *)NULL;
+ }
+ else
+ {
+ // Always show the cursor and wrap the cursor if it goes past the end
+
+ m_textbox->showCursor(SHOW_CURSOR_ALWAYS);
+ m_textbox->wrapCursor(true);
+
+ // Align text on the left
+
+ m_textbox->setTextAlignmentHoriz(CTextBox::TEXT_ALIGNMENT_HORIZ_LEFT);
+
+ // Configure the text box to receive the keyboard input
+
+ keypad->addWidgetEventHandler(m_textbox);
+ }
+ }
+
+ return keypad;
+}
+
+// Create a CTextBox instance so that we can see the keypad output
+
+CTextBox *CKeypadTest::createTextBox(void)
+{
+ // Get the height and width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CKeypadTest::createGraphics: Failed to get window size\n");
+ return (CTextBox *)NULL;
+ }
+
+ // Pick a height and width. Here we use inside information that the number
+ // of rows in the keypad is 7. This should not matter in a "real" application.
+
+ nxgl_coord_t textboxWidth = KEYPAD_NCOLUMNS * m_buttonWidth;
+ nxgl_coord_t textboxHeight = m_displayHeight - KEYPAD_NROWS * m_buttonHeight;
+
+ // Pick an X/Y position such that the keypad will be centered in the display
+
+ nxgl_coord_t textboxX = (windowSize.w - textboxWidth) >> 1;
+ nxgl_coord_t textboxY = (windowSize.h - m_displayHeight) >> 1;
+
+ // Now we have enough information to create the TextBox
+
+ return new CTextBox(m_widgetControl, textboxX, textboxY,
+ textboxWidth, textboxHeight, "");
+}
+
+// Draw the keypad
+
+void CKeypadTest::showKeypad(CKeypad *keypad)
+{
+ // Re-draw the keypad
+
+ keypad->enable(); // Un-necessary, the widget is enabled by default
+ keypad->enableDrawing();
+ keypad->redraw();
+
+ // Then redraw the text box
+
+ m_textbox->enable(); // Un-necessary, the widget is enabled by default
+ m_textbox->enableDrawing();
+ m_textbox->redraw();
+}
+
+// Perform a simulated mouse click on a button in the array. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CKeypadTest::click(CKeypad *keypad, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the selected button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = keypad->getX() + column * m_buttonWidth + (m_buttonWidth >> 1);
+ nxgl_coord_t buttonY = keypad->getY() + row * m_buttonHeight + (m_buttonHeight >> 1);
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CKeypadTest::release(CKeypad *keypad, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = keypad->getX() +
+ column * m_buttonWidth +
+ m_buttonWidth/2;
+ nxgl_coord_t buttonY = keypad->getY() +
+ row * m_buttonHeight +
+ m_buttonHeight/2;
+
+ // Then inject the mouse release
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll
+// then check if the event was processed corredly.
+
+void CKeypadTest::poll(CKeypad *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+
+ // Limit the amount of text in the TextBox
+
+ reverseAlignment();
+}
+
+// Start with left text alignment. When the text reaches the right sice
+// of the text box, switch to right text alignment.
+
+void CKeypadTest::reverseAlignment(void)
+{
+ // Get the current horizontal text alignment
+
+ CTextBox::TextAlignmentHoriz hAlign = m_textbox->getTextAlignmentHoriz();
+
+ // Are we still using left text alignment?
+
+ if (hAlign == CTextBox::TEXT_ALIGNMENT_HORIZ_LEFT)
+ {
+ // Yes.. Get the string in the text box
+
+ CNxString string = m_textbox->getText();
+
+ // Get the font
+
+ CNxFont *font = m_textbox->getFont();
+
+ // Get the TextBox bounding box
+
+ CRect rect;
+ m_textbox->getRect(rect);
+
+ // When the length of string approaches the width of the display
+ // region, then switch to right text alignment
+
+ int mxWidth = font->getMaxWidth();
+ if (font->getStringWidth(string) + mxWidth >= rect.getWidth())
+ {
+ // Switch to right text alignment
+
+ m_textbox->setTextAlignmentHoriz(CTextBox::TEXT_ALIGNMENT_HORIZ_RIGHT);
+ }
+ }
+}
+
diff --git a/NxWidgets/UnitTests/CKeypad/ckeypadtest.hxx b/NxWidgets/UnitTests/CKeypad/ckeypadtest.hxx
new file mode 100644
index 000000000..d11c92375
--- /dev/null
+++ b/NxWidgets/UnitTests/CKeypad/ckeypadtest.hxx
@@ -0,0 +1,182 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CKeypad/ckeypadtest.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 __UNITTESTS_CKEYPAD_CKEYPADTEST_HXX
+#define __UNITTESTS_CKEYPAD_CKEYPADTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "ctextbox.hxx"
+#include "ckeypad.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CKEYPADTEST_BGCOLOR
+# define CONFIG_CKEYPADTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+// This is the size of the keypad
+
+#define KEYPAD_NROWS 7
+#define KEYPAD_NCOLUMNS 4
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CKeypadTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The widget control for the window
+ CBgWindow *m_bgWindow; // Background window instance
+ CTextBox *m_textbox; // TextBox to show the key presses
+ nxgl_coord_t m_buttonWidth; // The width of one button
+ nxgl_coord_t m_buttonHeight; // The height of one button
+ nxgl_coord_t m_displayHeight; // The height of the display
+
+ // Pick size of the display
+
+ void setDisplaySize(void);
+
+ // Start with left text alignment. When the text reaches the right sice
+ // of the text box, switch to right text alignment.
+
+ void reverseAlignment(void);
+
+ // Create a CTextBox instance so that we can see the keypad output
+
+ CTextBox *createTextBox(void);
+
+public:
+
+ // Constructor/destructors
+
+ CKeypadTest();
+ ~CKeypadTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CKeypad instance. This method will show you how to create
+ // a CKeypad widget
+
+ CKeypad *createKeypad(void);
+
+ // Draw the keypad. This method illustrates how to draw the CKeypad widget.
+
+ void showKeypad(CKeypad *keypad);
+
+ // Perform a simulated mouse click on a button in the array. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(CKeypad *keypad, int column, int row);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(CKeypad *keypad, int column, int row);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll
+ // then check if the event was processed corredly.
+
+ void poll(CKeypad *keypad);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CKEYPAD_CKEYPADTEST_HXX
diff --git a/NxWidgets/UnitTests/CLabel/Makefile b/NxWidgets/UnitTests/CLabel/Makefile
new file mode 100644
index 000000000..e04adc7de
--- /dev/null
+++ b/NxWidgets/UnitTests/CLabel/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CLabel/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = clabel_main.cxx clabeltest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = clabel
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CLabel/clabel.png b/NxWidgets/UnitTests/CLabel/clabel.png
new file mode 100644
index 000000000..d74430ca5
--- /dev/null
+++ b/NxWidgets/UnitTests/CLabel/clabel.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CLabel/clabel_main.cxx b/NxWidgets/UnitTests/CLabel/clabel_main.cxx
new file mode 100644
index 000000000..2b800dcab
--- /dev/null
+++ b/NxWidgets/UnitTests/CLabel/clabel_main.cxx
@@ -0,0 +1,130 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLabel/clabel_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "clabeltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static const char g_hello[] = "Hello, World!";
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int clabel_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int clabel_main(int argc, char *argv[])
+{
+ // Create an instance of the font test
+
+ printf("clabel_main: Create CLabelTest instance\n");
+ CLabelTest *test = new CLabelTest();
+
+ // Connect the NX server
+
+ printf("clabel_main: Connect the CLabelTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("clabel_main: Failed to connect the CLabelTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a window to draw into
+
+ printf("clabel_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("clabel_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a CLabel instance
+
+ CLabel *label = test->createLabel(g_hello);
+ if (!label)
+ {
+ printf("clabel_main: Failed to create a label\n");
+ delete test;
+ return 1;
+ }
+
+ // Show the label
+
+ test->showLabel(label);
+ sleep(5);
+
+ // Clean up and exit
+
+ printf("clabel_main: Clean-up and exit\n");
+ delete label;
+ delete test;
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CLabel/clabeltest.cxx b/NxWidgets/UnitTests/CLabel/clabeltest.cxx
new file mode 100644
index 000000000..ef78cc3ce
--- /dev/null
+++ b/NxWidgets/UnitTests/CLabel/clabeltest.cxx
@@ -0,0 +1,263 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLabel/clabeltest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "clabeltest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CLabelTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CLabelTest Constructor
+
+CLabelTest::CLabelTest()
+{
+ m_bgWindow = (CBgWindow *)NULL;
+ m_nxFont = (CNxFont *)NULL;
+ m_text = (CNxString *)NULL;
+}
+
+// CLabelTest Descriptor
+
+CLabelTest::~CLabelTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CLabelTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Create the default font instance
+
+ m_nxFont = new CNxFont(NXFONT_DEFAULT,
+ CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ if (!m_nxFont)
+ {
+ printf("CLabelTest::connect: Failed to create the default font\n");
+ }
+
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CLABELTEST_BGCOLOR))
+ {
+ printf("CLabelTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CLabelTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the display string
+
+ if (m_text)
+ {
+ delete m_text;
+ m_text = (CNxString *)NULL;
+ }
+
+ // Free the default font
+
+ if (m_nxFont)
+ {
+ delete m_nxFont;
+ m_nxFont = (CNxFont *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CLabelTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ printf("CLabelTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ printf("CLabelTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CLabel instance
+
+CLabel *CLabelTest::createLabel(FAR const char *text)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CLabelTest::createGraphics: Failed to get window size\n");
+ return (CLabel *)NULL;
+ }
+
+ // Create a CNxString instance to contain the C string
+
+ m_text = new CNxString(text);
+
+ // Get the height and width of the text display area
+
+ nxgl_coord_t stringWidth = m_nxFont->getStringWidth(*m_text);
+ nxgl_coord_t stringHeight = (nxgl_coord_t)m_nxFont->getHeight();
+
+ // The default CLabel has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height. (We
+ // could let CLabel do this for us by calling CLabel::getPreferredDimensions())
+
+ stringWidth += 2 * 1;
+ stringHeight += 2 * 1;
+
+ // Pick an X/Y position such that the label will be centered in the display
+
+ nxgl_coord_t labelX;
+ if (stringWidth >= windowSize.w)
+ {
+ labelX = 0;
+ }
+ else
+ {
+ labelX = (windowSize.w - stringWidth) >> 1;
+ }
+
+ nxgl_coord_t labelY;
+ if (stringHeight >= windowSize.h)
+ {
+ labelY = 0;
+ }
+ else
+ {
+ labelY = (windowSize.h - stringHeight) >> 1;
+ }
+
+ // Now we have enough information to create the label
+
+ return new CLabel(m_widgetControl, labelX, labelY, stringWidth, stringHeight, *m_text);
+}
+
+// Draw the label
+
+void CLabelTest::showLabel(CLabel *label)
+{
+ label->enable();
+ label->enableDrawing();
+ label->redraw();
+ label->disableDrawing();
+}
diff --git a/NxWidgets/UnitTests/CLabel/clabeltest.hxx b/NxWidgets/UnitTests/CLabel/clabeltest.hxx
new file mode 100644
index 000000000..47bb7684b
--- /dev/null
+++ b/NxWidgets/UnitTests/CLabel/clabeltest.hxx
@@ -0,0 +1,138 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLabel/clabeltest.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 __UNITTESTS_CLABEL_CLABELTEST_HXX
+#define __UNITTESTS_CLABEL_CLABELTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "clabel.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CLABELTEST_BGCOLOR
+# define CONFIG_CLABELTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CLABELTEST_FONTCOLOR
+# define CONFIG_CLABELTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CLabelTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CNxFont *m_nxFont; // Default font
+ CBgWindow *m_bgWindow; // Background window instance
+ CNxString *m_text; // The label string
+
+public:
+ // Constructor/destructors
+
+ CLabelTest();
+ ~CLabelTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CLabel instance. This method will show you how to create
+ // a CLabel widget
+
+ CLabel *createLabel(FAR const char *text);
+
+ // Draw the label. This method illustrates how to draw the CLabel widget.
+
+ void showLabel(CLabel *label);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CLABEL_CLABELTEST_HXX
diff --git a/NxWidgets/UnitTests/CLatchButton/Makefile b/NxWidgets/UnitTests/CLatchButton/Makefile
new file mode 100644
index 000000000..7444c50be
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButton/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CLatchButton/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = clatchbutton_main.cxx clatchbuttontest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = clatchbutton
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CLatchButton/clatchbutton_main.cxx b/NxWidgets/UnitTests/CLatchButton/clatchbutton_main.cxx
new file mode 100644
index 000000000..13ed0613e
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButton/clatchbutton_main.cxx
@@ -0,0 +1,199 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButton/clatchbutton_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "clatchbuttontest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static const char g_pushme[] = "Push Me";
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int clatchbutton_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showButtonState
+/////////////////////////////////////////////////////////////////////////////
+
+static void showButtonState(CLatchButton *button, bool &clicked, bool &latched)
+{
+ bool nowClicked = button->isClicked();
+ bool nowLatched = button->isLatched();
+
+ printf("showButtonState: Button state: %s and %s\n",
+ nowClicked ? "clicked" : "released",
+ nowLatched ? "latched" : "unlatched");
+
+ if (clicked != nowClicked || latched != nowLatched)
+ {
+ printf("showButtonState: ERROR: Expected %s and %s\n",
+ clicked ? "clicked" : "released",
+ latched ? "latched" : "unlatched");
+
+ clicked = nowClicked;
+ latched = nowLatched;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int clatchbutton_main(int argc, char *argv[])
+{
+ // Create an instance of the font test
+
+ printf("clatchbutton_main: Create CLatchButtonTest instance\n");
+ CLatchButtonTest *test = new CLatchButtonTest();
+
+ // Connect the NX server
+
+ printf("clatchbutton_main: Connect the CLatchButtonTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("clatchbutton_main: Failed to connect the CLatchButtonTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a window to draw into
+
+ printf("clatchbutton_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("clatchbutton_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a CLatchButton instance
+
+ CLatchButton *button = test->createButton(g_pushme);
+ if (!button)
+ {
+ printf("clatchbutton_main: Failed to create a button\n");
+ delete test;
+ return 1;
+ }
+
+ // Show the button
+
+ printf("clatchbutton_main: Show the button\n");
+ test->showButton(button);
+
+ bool clicked = false;
+ bool latched = false;
+ showButtonState(button, clicked, latched);
+
+ // Toggle the button state a few times
+
+ for (int i = 0; i < 8; i++)
+ {
+ // Wait two seconds, then perform a simulated mouse click on the button
+
+ sleep(2);
+ printf("clatchbutton_main: Click the button\n");
+ test->click();
+ test->poll(button);
+
+ // Test the button state it should be clicked with the latch state
+ // toggled
+
+ clicked = true;
+ latched = !latched;
+ showButtonState(button, clicked, latched);
+
+ // And release the button after 0.5 seconds
+
+ usleep(500 * 1000);
+ printf("clatchbutton_main: Release the button\n");
+ test->release();
+ test->poll(button);
+
+ // Test the button state it should be unclicked with the latch state
+ // unchanged
+
+ clicked = false;
+ showButtonState(button, clicked, latched);
+ fflush(stdout);
+ }
+
+ // Wait a few more seconds so that the tester can ponder the result
+
+ sleep(3);
+
+ // Clean up and exit
+
+ printf("clatchbutton_main: Clean-up and exit\n");
+ delete button;
+ delete test;
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.cxx b/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.cxx
new file mode 100644
index 000000000..c8e02938b
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.cxx
@@ -0,0 +1,321 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButton/clatchbuttontest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "clatchbuttontest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CLatchButtonTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CLatchButtonTest Constructor
+
+CLatchButtonTest::CLatchButtonTest()
+{
+ m_bgWindow = (CBgWindow *)NULL;
+ m_nxFont = (CNxFont *)NULL;
+ m_text = (CNxString *)NULL;
+}
+
+// CLatchButtonTest Descriptor
+
+CLatchButtonTest::~CLatchButtonTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CLatchButtonTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Create the default font instance
+
+ m_nxFont = new CNxFont(NXFONT_DEFAULT,
+ CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ if (!m_nxFont)
+ {
+ printf("CLatchButtonTest::connect: Failed to create the default font\n");
+ }
+
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CLATCHBUTTONTEST_BGCOLOR))
+ {
+ printf("CLatchButtonTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CLatchButtonTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the display string
+
+ if (m_text)
+ {
+ delete m_text;
+ m_text = (CNxString *)NULL;
+ }
+
+ // Free the default font
+
+ if (m_nxFont)
+ {
+ delete m_nxFont;
+ m_nxFont = (CNxFont *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CLatchButtonTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ printf("CLatchButtonTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ printf("CLatchButtonTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CLatchButton instance
+
+CLatchButton *CLatchButtonTest::createButton(FAR const char *text)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CLatchButtonTest::createGraphics: Failed to get window size\n");
+ return (CLatchButton *)NULL;
+ }
+
+ // Create a CNxString instance to contain the C string
+
+ m_text = new CNxString(text);
+
+ // Get the height and width of the text display area
+
+ nxgl_coord_t stringWidth = m_nxFont->getStringWidth(*m_text);
+ nxgl_coord_t stringHeight = (nxgl_coord_t)m_nxFont->getHeight();
+
+ // The default CLatchButton has borders enabled with thickness of the border
+ // width. Add twice the thickness of border the to the width and height. (We
+ // could let CLatchButton do this for us by calling
+ // CLatchButton::getPreferredDimensions())
+
+ stringWidth += 2 * 1;
+ stringHeight += 2 * 1;
+
+ // Pick an X/Y position such that the button will be centered in the display
+
+ nxgl_coord_t buttonX;
+ if (stringWidth >= windowSize.w)
+ {
+ buttonX = 0;
+ }
+ else
+ {
+ buttonX = (windowSize.w - stringWidth) >> 1;
+ }
+
+ nxgl_coord_t buttonY;
+ if (stringHeight >= windowSize.h)
+ {
+ buttonY = 0;
+ }
+ else
+ {
+ buttonY = (windowSize.h - stringHeight) >> 1;
+ }
+
+ // Save the center position of the button for use by click and release
+
+ m_center.x = buttonX + (stringWidth >> 1);
+ m_center.y = buttonY + (stringHeight >> 1);
+
+ // Now we have enough information to create the button
+
+ return new CLatchButton(m_widgetControl, buttonX, buttonY, stringWidth, stringHeight, *m_text);
+}
+
+// Draw the button
+
+void CLatchButtonTest::showButton(CLatchButton *button)
+{
+ button->enable(); // Un-necessary, the widget is enabled by default
+ button->enableDrawing();
+ button->redraw();
+}
+
+// Perform a simulated mouse click on the button. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CLatchButtonTest::click(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CLatchButtonTest::release(void)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll.
+
+void CLatchButtonTest::poll(CLatchButton *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+}
+
diff --git a/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.hxx b/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.hxx
new file mode 100644
index 000000000..783b1a57c
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButton/clatchbuttontest.hxx
@@ -0,0 +1,155 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButton/clatchbuttontest.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 __UNITTESTS_CLATCHBUTTON_CLATCHBUTTONTEST_HXX
+#define __UNITTESTS_CLATCHBUTTON_CLATCHBUTTONTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "clatchbutton.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CLATCHBUTTONTEST_BGCOLOR
+# define CONFIG_CLATCHBUTTONTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CLATCHBUTTONTEST_FONTCOLOR
+# define CONFIG_CLATCHBUTTONTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CLatchButtonTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CNxFont *m_nxFont; // Default font
+ CBgWindow *m_bgWindow; // Background window instance
+ CNxString *m_text; // The button string
+ struct nxgl_point_s m_center; // X, Y position the center of the button
+
+public:
+ // Constructor/destructors
+
+ CLatchButtonTest(void);
+ ~CLatchButtonTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CLatchButton instance. This method will show you how to create
+ // a CLatchButton widget
+
+ CLatchButton *createButton(FAR const char *text);
+
+ // Draw the button. This method illustrates how to draw the CLatchButton widget.
+
+ void showButton(CLatchButton *button);
+
+ // Perform a simulated mouse click on the button. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(void);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(void);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll.
+
+ void poll(CLatchButton *button);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CLATCHBUTTON_CLATCHBUTTONTEST_HXX
diff --git a/NxWidgets/UnitTests/CLatchButtonArray/Makefile b/NxWidgets/UnitTests/CLatchButtonArray/Makefile
new file mode 100644
index 000000000..a6ac9118b
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButtonArray/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CLatchButtonArray/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = clatchbuttonarray_main.cxx clatchbuttonarraytest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = clatchbuttonarray
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarray_main.cxx b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarray_main.cxx
new file mode 100644
index 000000000..ad7646560
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarray_main.cxx
@@ -0,0 +1,301 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarry_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cnxstring.hxx"
+#include "clatchbuttonarraytest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmPrevious;
+static unsigned int g_mmPeak;
+
+static FAR const char *g_buttonLabels[BUTTONARRAY_NCOLUMNS*BUTTONARRAY_NROWS] = {
+ "=>", "A", "B", "<DEL",
+ "C", "D", "E", "F",
+ "G", "H", "I", "J",
+ "K", "L", "M", "N",
+ "O", "P", "Q", "R",
+ "S", "T", "U", "V",
+ "W", "X", "Y", "Z"
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int clatchbuttonarray_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showButtonState
+/////////////////////////////////////////////////////////////////////////////
+
+static void showButtonState(CLatchButtonArray *buttonArray, int i, int j,
+ bool &clicked, bool &latched)
+{
+ bool nowClicked = buttonArray->isThisButtonClicked(i,j);
+ bool nowLatched = buttonArray->isThisButtonLatched(i,j);
+
+ printf("showButtonState: Button(%d,%d) state: %s and %s\n",
+ i, j,
+ nowClicked ? "clicked" : "released",
+ nowLatched ? "latched" : "unlatched");
+
+ if (clicked != nowClicked || latched != nowLatched)
+ {
+ printf("showButtonState: ERROR: Expected %s and %s\n",
+ clicked ? "clicked" : "released",
+ latched ? "latched" : "unlatched");
+
+ clicked = nowClicked;
+ latched = nowLatched;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("%s: Before: %8d After: %8d Change: %8d\n",
+ msg, previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmPrevious = mmcurrent.uordblks;
+ if ((unsigned int)mmcurrent.uordblks > g_mmPeak)
+ {
+ g_mmPeak = mmcurrent.uordblks;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmPrevious = mmcurrent.uordblks;
+ g_mmPeak = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int clatchbuttonarray_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the button array test
+
+ printf("clatchbuttonarray_main: Create CLatchButtonArrayTest instance\n");
+ CLatchButtonArrayTest *test = new CLatchButtonArrayTest();
+ updateMemoryUsage(g_mmPrevious, "After creating CLatchButtonArrayTest");
+
+ // Connect the NX server
+
+ printf("clatchbuttonarray_main: Connect the CLatchButtonArrayTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("clatchbuttonarray_main: Failed to connect the CLatchButtonArrayTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After connecting to the server");
+
+ // Create a window to draw into
+
+ printf("clatchbuttonarray_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("clatchbuttonarray_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating a window");
+
+ // Create a CLatchButtonArray instance
+
+ CLatchButtonArray *buttonArray = test->createButtonArray();
+ if (!buttonArray)
+ {
+ printf("clatchbuttonarray_main: Failed to create a button array\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "After creating CLatchButtonArray");
+
+ // Add the labels to each button
+
+ FAR const char **ptr = g_buttonLabels;
+ for (int j = 0; j < BUTTONARRAY_NROWS; j++)
+ {
+ for (int i = 0; i < BUTTONARRAY_NCOLUMNS; i++)
+ {
+ printf("clatchbuttonarray_main: Label (%d,%d): %s\n", i, j, *ptr);
+ CNxString string = *ptr++;
+ buttonArray->setText(i, j, string);
+ }
+ }
+ updateMemoryUsage(g_mmPrevious, "After adding labels to the buttons");
+
+ // Show the button array
+
+ printf("clatchbuttonarray_main: Show the button array\n");
+ test->showButton(buttonArray);
+ sleep(1);
+
+ // Then perform a simulated mouse click on a button in the array
+
+ bool clicked = false;
+ bool latched = false;
+
+ for (int j = 0; j < BUTTONARRAY_NROWS; j++)
+ {
+ for (int i = 0; i < BUTTONARRAY_NCOLUMNS; i++)
+ {
+ // Initially, this button should be neither clicked nor latched
+
+ clicked = false;
+ latched = false;
+ showButtonState(buttonArray, i, j, clicked, latched);
+
+ printf("clatchbuttonarray_main: Click the button (%d,%d)\n", i, j);
+ test->click(buttonArray, i, j);
+
+ // Poll for the mouse click event
+
+ test->poll(buttonArray);
+
+ // Now it should be clicked and latched
+
+ clicked = true;
+ latched = true;
+ showButtonState(buttonArray, i, j, clicked, latched);
+
+ // Wait a bit, then release the mouse button
+
+ usleep(200*1000);
+ test->release(buttonArray, i, j);
+
+ // Poll for the mouse release event (of course this can hang if something fails)
+
+ test->poll(buttonArray);
+
+ // Now it should be un-clicked and latched
+
+ clicked = false;
+ latched = true;
+ showButtonState(buttonArray, i, j, clicked, latched);
+
+ usleep(300*1000);
+ }
+ }
+ updateMemoryUsage(g_mmPrevious, "After pushing buttons");
+
+ // Clean up and exit
+
+ printf("clatchbuttonarray_main: Clean-up and exit\n");
+ delete buttonArray;
+ updateMemoryUsage(g_mmPrevious, "After deleting the button array");
+ delete test;
+ updateMemoryUsage(g_mmPrevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ message("Peak memory usage: %8d\n", g_mmPeak - g_mmInitial);
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.cxx b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.cxx
new file mode 100644
index 000000000..cf41c1608
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.cxx
@@ -0,0 +1,301 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "clatchbuttonarraytest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CLatchButtonArrayTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CLatchButtonArrayTest Constructor
+
+CLatchButtonArrayTest::CLatchButtonArrayTest()
+{
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CLatchButtonArrayTest Descriptor
+
+CLatchButtonArrayTest::~CLatchButtonArrayTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CLatchButtonArrayTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CLATCHBUTTONARRAYTEST_BGCOLOR))
+ {
+ message("CLatchButtonArrayTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CLatchButtonArrayTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Destroy the widget control
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CLatchButtonArrayTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CLatchButtonArrayTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CLatchButtonArrayTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CLatchButtonArray instance
+
+CLatchButtonArray *CLatchButtonArrayTest::createButtonArray(void)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CLatchButtonArrayTest::createGraphics: Failed to get window size\n");
+ return (CLatchButtonArray *)NULL;
+ }
+
+ // Pick an X/Y position such that the button array will be centered in the display
+
+ nxgl_coord_t buttonArrayX;
+ if (BUTTONARRAY_WIDTH >= windowSize.w)
+ {
+ buttonArrayX = 0;
+ }
+ else
+ {
+ buttonArrayX = (windowSize.w - BUTTONARRAY_WIDTH) >> 1;
+ }
+
+ nxgl_coord_t buttonArrayY;
+ if (BUTTONARRAY_HEIGHT >= windowSize.h)
+ {
+ buttonArrayY = 0;
+ }
+ else
+ {
+ buttonArrayY = (windowSize.h - BUTTONARRAY_HEIGHT) >> 1;
+ }
+
+ // Now we have enough information to create the button array
+
+ return new CLatchButtonArray(m_widgetControl,
+ buttonArrayX, buttonArrayY,
+ BUTTONARRAY_NCOLUMNS, BUTTONARRAY_NROWS,
+ BUTTONARRAY_BUTTONWIDTH, BUTTONARRAY_BUTTONHEIGHT);
+}
+
+// Draw the button array
+
+void CLatchButtonArrayTest::showButton(CLatchButtonArray *buttonArray)
+{
+ buttonArray->enable(); // Un-necessary, the widget is enabled by default
+ buttonArray->enableDrawing();
+ buttonArray->redraw();
+}
+
+// Perform a simulated mouse click on a button in the array. This method injects
+// the mouse click through the NX heirarchy just as would real mouse
+// hardward.
+
+void CLatchButtonArrayTest::click(CLatchButtonArray *buttonArray, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the selected button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = buttonArray->getX() +
+ column * BUTTONARRAY_BUTTONWIDTH +
+ BUTTONARRAY_BUTTONWIDTH/2;
+ nxgl_coord_t buttonY = buttonArray->getY() +
+ row * BUTTONARRAY_BUTTONHEIGHT +
+ BUTTONARRAY_BUTTONHEIGHT/2;
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_LEFTBUTTON);
+}
+
+// The counterpart to click. This simulates a button release through
+// the same mechanism.
+
+void CLatchButtonArrayTest::release(CLatchButtonArray *buttonArray, int column, int row)
+{
+ // nx_mousein is meant to be called by mouse handling software.
+ // Here we just inject a left-button click directly in the center of
+ // the button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // The the coorinates of the center of the button
+
+ nxgl_coord_t buttonX = buttonArray->getX() +
+ column * BUTTONARRAY_BUTTONWIDTH +
+ BUTTONARRAY_BUTTONWIDTH/2;
+ nxgl_coord_t buttonY = buttonArray->getY() +
+ row * BUTTONARRAY_BUTTONHEIGHT +
+ BUTTONARRAY_BUTTONHEIGHT/2;
+
+ // Then inject the mouse release
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
+}
+
+// Widget events are normally handled in a modal loop.
+// However, for this case we know when there should be press and release
+// events so we don't have to poll. We can just perform a one pass poll
+// then check if the event was processed corredly.
+
+void CLatchButtonArrayTest::poll(CLatchButtonArray *button)
+{
+ // Poll for mouse events
+
+ m_widgetControl->pollEvents(button);
+}
+
diff --git a/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.hxx b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.hxx
new file mode 100644
index 000000000..98c0a3bb3
--- /dev/null
+++ b/NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.hxx
@@ -0,0 +1,172 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CLatchButtonArray/clatchbuttonarraytest.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 __UNITTESTS_CLATCHBUTTONARRAY_CLATCHBUTTONARRAYTEST_HXX
+#define __UNITTESTS_CLATCHBUTTONARRAY_CLATCHBUTTONARRAYTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "clatchbuttonarray.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CLATCHBUTTONARRAYTEST_BGCOLOR
+# define CONFIG_CLATCHBUTTONARRAYTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CLATCHBUTTONARRAYTEST_FONTCOLOR
+# define CONFIG_CLATCHBUTTONARRAYTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+// The geometry of the button array
+
+#define BUTTONARRAY_NCOLUMNS 4
+#define BUTTONARRAY_NROWS 7
+#define BUTTONARRAY_BUTTONWIDTH 60
+#define BUTTONARRAY_BUTTONHEIGHT 32
+#define BUTTONARRAY_WIDTH (BUTTONARRAY_BUTTONWIDTH * BUTTONARRAY_NCOLUMNS)
+#define BUTTONARRAY_HEIGHT (BUTTONARRAY_BUTTONHEIGHT * BUTTONARRAY_NROWS)
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CLatchButtonArrayTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The widget control for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CLatchButtonArrayTest();
+ ~CLatchButtonArrayTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CLatchButtonArray instance. This method will show you how to create
+ // a CLatchButtonArray widget
+
+ CLatchButtonArray *createButtonArray(void);
+
+ // Draw the button array. This method illustrates how to draw the CLatchButtonArray widget.
+
+ void showButton(CLatchButtonArray *buttonArray);
+
+ // Perform a simulated mouse click on a button in the array. This method injects
+ // the mouse click through the NX heirarchy just as would real mouse
+ // hardward.
+
+ void click(CLatchButtonArray *buttonArray, int column, int row);
+
+ // The counterpart to click. This simulates a button release through
+ // the same mechanism.
+
+ void release(CLatchButtonArray *buttonArray, int column, int row);
+
+ // Widget events are normally handled in a model loop (by calling goModel()).
+ // However, for this case we know when there should be press and release
+ // events so we don't have to poll. We can just perform a one pass poll
+ // then check if the event was processed corredly.
+
+ void poll(CLatchButtonArray *buttonArray);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CLATCHBUTTONARRAY_CLATCHBUTTONARRAYTEST_HXX
diff --git a/NxWidgets/UnitTests/CListBox/Makefile b/NxWidgets/UnitTests/CListBox/Makefile
new file mode 100644
index 000000000..f06873817
--- /dev/null
+++ b/NxWidgets/UnitTests/CListBox/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CListBox/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = clistbox_main.cxx clistboxtest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = clistbox
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CListBox/clistbox_main.cxx b/NxWidgets/UnitTests/CListBox/clistbox_main.cxx
new file mode 100644
index 000000000..8711f06e8
--- /dev/null
+++ b/NxWidgets/UnitTests/CListBox/clistbox_main.cxx
@@ -0,0 +1,327 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CListBox/clistbox_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "clistboxtest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmPrevious;
+static unsigned int g_mmPeak;
+
+static FAR const char *g_options[] =
+{
+ "American groundnut (Apios americana)",
+ "Azuki bean (Vigna angularis)",
+ "Black-eyed pea (Vigna unguiculata subsp. unguiculata)",
+ "Chickpea (Cicer arietinum)",
+ "Common bean (Phaseolus vulgaris)",
+ "Drumstick (Moringa oleifera)",
+ "Dolichos bean (Lablab purpureus)",
+ "Fava bean (Vicia faba)",
+ "Garbanzo (Cicer arietinum)",
+ "Green bean (Phaseolus vulgaris)",
+ "Guar (Cyamopsis tetragonoloba)",
+ "Gumbo (Abelmoschus esculentus)",
+ "Horse gram (Macrotyloma uniflorum)",
+ "Indian pea (Lathyrus sativus)",
+ "Lentil (Lens culinaris)",
+ "Lima Bean (Phaseolus lunatus)",
+ "Moth bean (Vigna acontifolia)",
+ "Mung bean (Vigna radiata)",
+ "Okra (Abelmoschus esculentus)",
+ "Pea (Pisum sativum)",
+ "Peanut (Arachis hypogaea)",
+ "Pigeon pea (Cajanus cajan)",
+ "Ricebean (Vigna umbellata)",
+ "Runner bean (Phaseolus coccineus)",
+ "Soybean (Glycine max)",
+ "Tarwi (tarhui, chocho; Lupinus mutabilis)",
+ "Tepary bean (Phaseolus acutifolius)",
+ "Urad bean (Vigna mungo)",
+ "Velvet bean (Mucuna pruriens)",
+ "Winged bean (Psophocarpus tetragonolobus)",
+ "Yardlong bean (Vigna unguiculata subsp. sesquipedalis)"
+};
+#define NOPTIONS (sizeof(g_options)/sizeof(FAR const char *))
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int clistbox_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("%s: Before: %8d After: %8d Change: %8d\n",
+ msg, previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmPrevious = mmcurrent.uordblks;
+ if ((unsigned int)mmcurrent.uordblks > g_mmPeak)
+ {
+ g_mmPeak = mmcurrent.uordblks;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmPrevious = mmcurrent.uordblks;
+ g_mmPeak = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int clistbox_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the listbox test
+
+ message("clistbox_main: Create CListBoxTest instance\n");
+ CListBoxTest *test = new CListBoxTest();
+ updateMemoryUsage(g_mmPrevious, "After creating CListBoxTest");
+
+ // Connect the NX server
+
+ message("clistbox_main: Connect the CListBoxTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("clistbox_main: Failed to connect the CListBoxTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("clistbox_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("clistbox_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After creating a window");
+
+ // Create a listbox
+
+ message("clistbox_main: Create a ListBox\n");
+ CListBox *listbox = test->createListBox();
+ if (!listbox)
+ {
+ message("clistbox_main: Failed to create a listbox\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After creating a listbox");
+
+ // Show the initial state of the listbox
+
+ listbox->setAllowMultipleSelections(true);
+ test->showListBox(listbox);
+ sleep(1);
+
+ // Now add items to the list box (in reverse alphabetical order)
+
+ message("clistbox_main: Add options to the ListBox\n");
+ for (int i = NOPTIONS - 1; i >= 0; i--)
+ {
+ listbox->addOption(g_options[i],i);
+ test->showListBox(listbox);
+ message("clistbox_main: %d. New option %s\n", i, g_options[i]);
+ usleep(500000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After adding the listbox items");
+ sleep(1);
+
+ // Sort the list box
+
+ message("clistbox_main: Sort the ListBox\n");
+ listbox->sort();
+ test->showListBox(listbox);
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After sorting the listbox");
+ sleep(1);
+
+ // Select and remove items from the listbox
+
+ srand(1978);
+ int nOptions;
+ while ((nOptions = listbox->getOptionCount()) > 0)
+ {
+ message("clistbox_main: Option count: %d\n", nOptions);
+ if (nOptions <= 5)
+ {
+ message("clistbox_main: Selecting all remaining options\n");
+ listbox->selectAllOptions();
+ test->showListBox(listbox);
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After selecting all options");
+ sleep(1);
+
+ message("clistbox_main: Removing all remaining options\n");
+ listbox->removeAllOptions();
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After removing all options");
+ test->showListBox(listbox);
+ }
+ else
+ {
+ int selected[5];
+
+ message("clistbox_main: Selecting five options\n");
+ for (int i = 0; i < 5; i++)
+ {
+ selected[i] = ((nOptions - 1) * rand()) / MAX_RAND;
+ message("clistbox_main: Selecting option %d\n", selected[i]);
+ listbox->removeOption(selected[i]);
+ test->showListBox(listbox);
+ usleep(500000);
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After selecting five options");
+
+ message("clistbox_main: De-selecting options\n");
+ int index;
+ int count = 0;
+ while ((index = listbox->getSelectedIndex()) >= 0)
+ {
+ message("clistbox_main: De-selecting option %d\n", index);
+ listbox->deselectOption(index);
+ test->showListBox(listbox);
+ count++;
+ usleep(500000);
+ }
+
+ message("clistbox_main: %s: %d options de-selected\n",
+ count == 5 ? "OK" : "ERROR", count);
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After de-selecting options");
+
+ message("clistbox_main: Removing the selected options\n");
+ for (int i = 0; i < 5; i++)
+ {
+ message("clistbox_main: Removing option %d\n", selected[i]);
+ listbox->removeOption(selected[i]);
+ test->showListBox(listbox);
+ usleep(500000);
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After removing five options");
+ }
+ sleep(1);
+ }
+ updateMemoryUsage(g_mmPrevious, "clistbox_main: After the listbox is empty again");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("clistbox_main: Clean-up and exit\n");
+ delete listbox;
+ updateMemoryUsage(g_mmPrevious, "After deleting the listbox");
+ delete test;
+ updateMemoryUsage(g_mmPrevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ message("Peak memory usage: %8d\n", g_mmPeak - g_mmInitial);
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CListBox/clistboxtest.cxx b/NxWidgets/UnitTests/CListBox/clistboxtest.cxx
new file mode 100644
index 000000000..cd41dacc7
--- /dev/null
+++ b/NxWidgets/UnitTests/CListBox/clistboxtest.cxx
@@ -0,0 +1,224 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CListBox/clistboxtest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "clistboxtest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CListBoxTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CListBoxTest Constructor
+
+CListBoxTest::CListBoxTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CListBoxTest Descriptor
+
+CListBoxTest::~CListBoxTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CListBoxTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CLISTBOXTEST_BGCOLOR))
+ {
+ message("CListBoxTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CListBoxTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CListBoxTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CListBoxTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CListBoxTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a listbox in the center of the window
+
+CListBox *CListBoxTest::createListBox(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CListBoxTest::createListBox: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the listbox in the center of the display
+
+ nxgl_coord_t listboxWidth = windowSize.w >> 1;
+ nxgl_coord_t listboxX = windowSize.w >> 2;
+
+ nxgl_coord_t listboxHeight = windowSize.h >> 1;
+ nxgl_coord_t listboxY = windowSize.h >> 2;
+
+ // Create the listbox
+
+ CListBox *listbox = new CListBox(m_widgetControl,
+ listboxX, listboxY,
+ listboxWidth, listboxHeight);
+ if (!listbox)
+ {
+ printf("CListBoxTest::createListBox: Failed to create CListBox\n");
+ disconnect();
+ }
+ return listbox;
+}
+
+// (Re-)draw the listbox.
+
+void CListBoxTest::showListBox(CListBox *listbox)
+{
+ listbox->enable(); // Un-necessary, the widget is enabled by default
+ listbox->enableDrawing();
+ listbox->redraw();
+}
diff --git a/NxWidgets/UnitTests/CListBox/clistboxtest.hxx b/NxWidgets/UnitTests/CListBox/clistboxtest.hxx
new file mode 100644
index 000000000..a19a2fabc
--- /dev/null
+++ b/NxWidgets/UnitTests/CListBox/clistboxtest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CListBox/clistboxtest.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 __UNITTESTS_CLISTBOX_CLISTBOXTEST_HXX
+#define __UNITTESTS_CLISTBOX_CLISTBOXTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "clistbox.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CLISTBOXTEST_BGCOLOR
+# define CONFIG_CLISTBOXTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CListBoxTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CListBoxTest(void);
+ ~CListBoxTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a listbox in the center of the window
+
+ CListBox *createListBox(void);
+
+ // (Re-)draw the listbox.
+
+ void showListBox(CListBox *listbox);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CLISTBOX_CLISTBOXTEST_HXX
diff --git a/NxWidgets/UnitTests/CProgressBar/Makefile b/NxWidgets/UnitTests/CProgressBar/Makefile
new file mode 100644
index 000000000..5ee346b52
--- /dev/null
+++ b/NxWidgets/UnitTests/CProgressBar/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CProgressBar/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cprogressbar_main.cxx cprogressbartest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cprogressbar
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CProgressBar/cprogressbar.png b/NxWidgets/UnitTests/CProgressBar/cprogressbar.png
new file mode 100644
index 000000000..321c4d6d9
--- /dev/null
+++ b/NxWidgets/UnitTests/CProgressBar/cprogressbar.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CProgressBar/cprogressbar_main.cxx b/NxWidgets/UnitTests/CProgressBar/cprogressbar_main.cxx
new file mode 100644
index 000000000..cb5fa130e
--- /dev/null
+++ b/NxWidgets/UnitTests/CProgressBar/cprogressbar_main.cxx
@@ -0,0 +1,238 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CProgressBar/cprogressbar_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cprogressbartest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#define MAX_PROGRESSBAR 50
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cprogressbar_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cprogressbar_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("cprogressbar_main: Create CProgressBarTest instance\n");
+ CProgressBarTest *test = new CProgressBarTest();
+ updateMemoryUsage(g_mmprevious, "After creating CProgressBarTest");
+
+ // Connect the NX server
+
+ message("cprogressbar_main: Connect the CProgressBarTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cprogressbar_main: Failed to connect the CProgressBarTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cprogressbar_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cprogressbar_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cprogressbar_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cprogressbar_main: After creating a window");
+
+ // Create a progress bar
+
+ message("cprogressbar_main: Create a ProgressBar\n");
+ CProgressBar *bar = test->createProgressBar();
+ if (!bar)
+ {
+ message("cprogressbar_main: Failed to create a progress bar\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cprogressbar_main: After creating a progress bar");
+
+ // Set the progress bar minimum and maximum values
+
+ bar->setMinimumValue(0);
+ bar->setMaximumValue(MAX_PROGRESSBAR);
+ bar->setValue(0);
+ bar->hidePercentageText();
+ message("cprogressbar_main: ProgressBar range %d->%d Initial value %d\n",
+ bar->getMinimumValue(), bar->getMaximumValue(),
+ bar->getValue());
+
+ // Show the initial state of the checkbox
+
+ test->showProgressBar(bar);
+ sleep(1);
+
+ // Now move the progress bar up from 0 to 100% (with percentages off)
+
+ for (int i = 0; i <= MAX_PROGRESSBAR; i++)
+ {
+ bar->setValue(i);
+ test->showProgressBar(bar);
+ message("cprogressbar_main: %d. New value %d\n", i, bar->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cprogressbar_main: After moving the progress bar up #1");
+ usleep(500*1000);
+
+ // Now move the progress bar up from 0 to 100% (with percentages off)
+
+ bar->showPercentageText();
+ bar->setValue(0);
+ test->showProgressBar(bar);
+ usleep(500*1000);
+
+ for (int i = 0; i <= MAX_PROGRESSBAR; i++)
+ {
+ bar->setValue(i);
+ test->showProgressBar(bar);
+ message("cprogressbar_main: %d. New value %d\n", i, bar->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cprogressbar_main: After moving the progress bar up #2");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("cprogressbar_main: Clean-up and exit\n");
+ delete bar;
+ updateMemoryUsage(g_mmprevious, "After deleting the progress bar");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CProgressBar/cprogressbartest.cxx b/NxWidgets/UnitTests/CProgressBar/cprogressbartest.cxx
new file mode 100644
index 000000000..60821d751
--- /dev/null
+++ b/NxWidgets/UnitTests/CProgressBar/cprogressbartest.cxx
@@ -0,0 +1,224 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/ProgressBar/cprogressbartest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "cprogressbartest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CProgressBarTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CProgressBarTest Constructor
+
+CProgressBarTest::CProgressBarTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CProgressBarTest Descriptor
+
+CProgressBarTest::~CProgressBarTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CProgressBarTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CPROGRESSBARTEST_BGCOLOR))
+ {
+ message("CProgressBarTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CProgressBarTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CProgressBarTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CProgressBarTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CProgressBarTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a bar in the center of the window
+
+CProgressBar *CProgressBarTest::createProgressBar(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CProgressBarTest::createProgressBar: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the bar in the center of the display
+
+ nxgl_coord_t barWidth = windowSize.w >> 1;
+ nxgl_coord_t barX = windowSize.w >> 2;
+
+ nxgl_coord_t barHeight = 16;
+ nxgl_coord_t barY = (windowSize.h - barHeight) >> 1;
+
+ // Create the bar
+
+ CProgressBar *bar = new CProgressBar(m_widgetControl,
+ barX, barY,
+ barWidth, barHeight);
+ if (!bar)
+ {
+ printf("CProgressBarTest::createProgressBar: Failed to create CProgressBar\n");
+ disconnect();
+ }
+ return bar;
+}
+
+// (Re-)draw the bar.
+
+void CProgressBarTest::showProgressBar(CProgressBar *bar)
+{
+ bar->enable(); // Un-necessary, the widget is enabled by default
+ bar->enableDrawing();
+ bar->redraw();
+}
diff --git a/NxWidgets/UnitTests/CProgressBar/cprogressbartest.hxx b/NxWidgets/UnitTests/CProgressBar/cprogressbartest.hxx
new file mode 100644
index 000000000..a7a4238e7
--- /dev/null
+++ b/NxWidgets/UnitTests/CProgressBar/cprogressbartest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CProgressBar/cprogressbartest.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 __UNITTESTS_CPROGRESSBAR_CPROGRESSBARTEST_HXX
+#define __UNITTESTS_CPROGRESSBAR_CPROGRESSBARTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cprogressbar.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CPROGRESSBARTEST_BGCOLOR
+# define CONFIG_CPROGRESSBARTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CProgressBarTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CProgressBarTest(void);
+ ~CProgressBarTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a progress bar in the center of the window
+
+ CProgressBar *createProgressBar(void);
+
+ // (Re-)draw the progress bar.
+
+ void showProgressBar(CProgressBar *bar);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CPROGRESSBAR_CPROGRESSBARTEST_HXX
diff --git a/NxWidgets/UnitTests/CRadioButton/Makefile b/NxWidgets/UnitTests/CRadioButton/Makefile
new file mode 100644
index 000000000..57190e8d3
--- /dev/null
+++ b/NxWidgets/UnitTests/CRadioButton/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CRadioButton/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cradiobutton_main.cxx cradiobuttontest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cradiobutton
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CRadioButton/cradiobutton.png b/NxWidgets/UnitTests/CRadioButton/cradiobutton.png
new file mode 100644
index 000000000..058badd5d
--- /dev/null
+++ b/NxWidgets/UnitTests/CRadioButton/cradiobutton.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CRadioButton/cradiobutton_main.cxx b/NxWidgets/UnitTests/CRadioButton/cradiobutton_main.cxx
new file mode 100644
index 000000000..0ec1ca196
--- /dev/null
+++ b/NxWidgets/UnitTests/CRadioButton/cradiobutton_main.cxx
@@ -0,0 +1,238 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CRadioButton/cradiobutton_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "crlepalettebitmap.hxx"
+#include "glyphs.hxx"
+#include "cradiobuttontest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cradiobutton_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cradiobutton_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the radio button test
+
+ message("cradiobutton_main: Create CRadioButtonTest instance\n");
+ CRadioButtonTest *test = new CRadioButtonTest();
+ updateMemoryUsage(g_mmprevious, "After creating CRadioButtonTest");
+
+ // Connect the NX server
+
+ message("cradiobutton_main: Connect the CRadioButtonTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cradiobutton_main: Failed to connect the CRadioButtonTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cradiobutton_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cradiobutton_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cradiobutton_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cradiobutton_main: After creating a window");
+
+ // Create three radio buttons
+
+ CRadioButton *button1 = test->newRadioButton();
+ if (!button1)
+ {
+ message("cradiobutton_main: Failed to create radio button 1\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cradiobutton_main: After creating radio button 1");
+
+ CRadioButton *button2 = test->newRadioButton();
+ if (!button2)
+ {
+ message("cradiobutton_main: Failed to create radio button 2\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cradiobutton_main: After creating radio button 2");
+
+ CRadioButton *button3 = test->newRadioButton();
+ if (!button3)
+ {
+ message("cradiobutton_main: Failed to create radio button 3\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cradiobutton_main: After creating radio button 3");
+
+ // Show the initial state of the buttons
+
+ test->showButtons();
+ test->showButtonState();
+ sleep(1);
+
+ // Now push some buttons
+
+ message("cradiobutton_main: Pushing button 1\n");
+ test->pushButton(button1);
+ usleep(500*1000);
+ test->showButtonState();
+ updateMemoryUsage(g_mmprevious, "After pushing button 1");
+ usleep(500*1000);
+
+ message("cradiobutton_main: Pushing button 2\n");
+ test->pushButton(button2);
+ usleep(500*1000);
+ test->showButtonState();
+ updateMemoryUsage(g_mmprevious, "After pushing button 2");
+ usleep(500*1000);
+
+ message("cradiobutton_main: Pushing button 3\n");
+ test->pushButton(button3);
+ usleep(500*1000);
+ test->showButtonState();
+ updateMemoryUsage(g_mmprevious, "After pushing button 3");
+ sleep(2);
+
+ // Clean up and exit
+
+ message("cradiobutton_main: Clean-up and exit\n");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.cxx b/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.cxx
new file mode 100644
index 000000000..09b5af8c2
--- /dev/null
+++ b/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.cxx
@@ -0,0 +1,305 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CRadioButton/cradiobuttontest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "cradiobuttontest.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CRadioButtonTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CRadioButtonTest Constructor
+
+CRadioButtonTest::CRadioButtonTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+
+ // Peek at the radio button glyph to get a good estimate of the size
+
+ m_size.w = g_radioButtonOn.width;
+ m_size.h = g_radioButtonOn.height;
+}
+
+// CRadioButtonTest Descriptor
+
+CRadioButtonTest::~CRadioButtonTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CRadioButtonTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CRADIOBUTTONTEST_BGCOLOR))
+ {
+ message("CRadioButtonTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CRadioButtonTest::disconnect(void)
+{
+ // Free the radiobutton group
+
+ if (m_radioButtonGroup)
+ {
+ delete m_radioButtonGroup;
+ m_radioButtonGroup = (CRadioButtonGroup *)NULL;
+ }
+
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CRadioButtonTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CRadioButtonTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CRadioButtonTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CRadioButton instance
+
+CRadioButton *CRadioButtonTest::newRadioButton(void)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ message("CRadioButtonTest::newRadioButton: Failed to get window size\n");
+ return (CRadioButton *)NULL;
+ }
+
+ // Create the radio button group, if we have not already done so
+
+ if (!m_radioButtonGroup)
+ {
+ // Start the radio button group in the center of the upper, left
+ // quadrant. The initial size is 0,0 and the default style is used.
+
+ nxgl_coord_t groupX = windowSize.w >> 2;
+ nxgl_coord_t groupY = windowSize.h >> 2;
+
+ m_radioButtonGroup = new CRadioButtonGroup(m_widgetControl, groupX, groupY);
+ if (!m_radioButtonGroup)
+ {
+ message("CRadioButtonTest::newRadioButton: Failed to create the radio button group\n");
+ return (CRadioButton *)NULL;
+ }
+ }
+
+ // Create the new radio button at the botton of the radio button group and
+ // with the size of the ON radio button glyph (they all need to be the same
+ // size!). Note that coordinates are relative to the parent bounding box.
+
+ nxgl_coord_t buttonX = 0;
+ nxgl_coord_t buttonY = m_radioButtonGroup->getHeight();
+
+ return m_radioButtonGroup->newRadioButton(buttonX, buttonY, m_size.w, m_size.h);
+}
+
+// (Re-)draw the buttons.
+
+void CRadioButtonTest::showButtons(void)
+{
+ m_radioButtonGroup->enable(); // Un-necessary, the widget is enabled by default
+ m_radioButtonGroup->enableDrawing();
+ m_radioButtonGroup->redraw();
+}
+
+// Push the radio button
+
+void CRadioButtonTest::pushButton(CRadioButton *button)
+{
+ // Get the button center coordinates
+
+ nxgl_coord_t buttonX = button->getX() + (button->getWidth() >> 1);
+ nxgl_coord_t buttonY = button->getY() + (button->getHeight() >> 1);
+
+ // Then push the button by calling nx_mousein. nx_mousein is meant to be
+ // called by mouse handling software. Here we just inject a left-button click
+ // directly in the center of the radio button.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level mouse interface
+
+ NXHANDLE handle = getServer();
+
+ // Then inject the mouse click
+
+ (void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_LEFTBUTTON);
+
+ // Poll for mouse events
+ //
+ // Widget events are normally handled in a modal loop.
+ // However, for this case we know that we just pressed the mouse button
+ // so we don't have to poll. We can just perform a one pass poll then
+ // then check if the mouse event was processed corredly.
+
+ m_widgetControl->pollEvents(m_radioButtonGroup);
+
+ // Then inject the mouse release
+
+ (void)nx_mousein(handle, buttonX, buttonY, 0);
+
+ // And poll for more mouse events
+
+ m_widgetControl->pollEvents(m_radioButtonGroup);
+
+ // And re-draw the buttons (the mouse click event should have automatically
+ // triggered the re-draw)
+ //
+ // showButtons();
+}
+
+// Show the state of the radio button group
+
+void CRadioButtonTest::showButtonState(void)
+{
+ int index = m_radioButtonGroup->getSelectedIndex();
+ if (index < 0)
+ {
+ message("CRadioButtonTest::showButtonState No button is pressed\n");
+ }
+ else
+ {
+ message("CRadioButtonTest::showButtonState button%d is selected\n", index+1);
+ }
+}
diff --git a/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.hxx b/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.hxx
new file mode 100644
index 000000000..540d5019b
--- /dev/null
+++ b/NxWidgets/UnitTests/CRadioButton/cradiobuttontest.hxx
@@ -0,0 +1,152 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CRadioButton/cradiobuttontest.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 __UNITTESTS_CRADIOBUTTON_CRADIOBUTTONTEST_HXX
+#define __UNITTESTS_CRADIOBUTTON_CRADIOBUTTONTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cradiobutton.hxx"
+#include "cradiobuttongroup.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CRADIOBUTTONTEST_BGCOLOR
+# define CONFIG_CRADIOBUTTONTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CRadioButtonTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+ CRadioButtonGroup *m_radioButtonGroup; // The radio button group
+
+ // These are the dimensions that we will use for creating new radio buttons
+
+ struct nxgl_size_s m_size; // The size of each radio button
+
+public:
+ // Constructor/destructors
+
+ CRadioButtonTest(void);
+ ~CRadioButtonTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // (Re-)draw the buttons.
+
+ void showButtons(void);
+
+ // Create a CRadioButton instance. This method will show you how to create
+ // a CRadioButton widget
+
+ CRadioButton *newRadioButton(void);
+
+ // Simulate pushing and releasing of the radio button
+
+ void pushButton(CRadioButton *button);
+
+ // Show the state of the radio button group
+
+ void showButtonState(void);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CRADIOBUTTON_CRADIOBUTTONTEST_HXX
diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/Makefile b/NxWidgets/UnitTests/CScrollbarHorizontal/Makefile
new file mode 100644
index 000000000..191324a96
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarHorizontal/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CScrollbarHorizontal/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cscrollbarhorizontal_main.cxx cscrollbarhorizontaltest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cscrollbarhorizontal
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png
new file mode 100644
index 000000000..8f83ded00
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal_main.cxx b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal_main.cxx
new file mode 100644
index 000000000..2b9adab11
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal_main.cxx
@@ -0,0 +1,231 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cscrollbarhorizontaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#define MAX_SCROLLBAR 50
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cscrollbarhorizontal_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cscrollbarhorizontal_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("cscrollbarhorizontal_main: Create CScrollbarHorizontalTest instance\n");
+ CScrollbarHorizontalTest *test = new CScrollbarHorizontalTest();
+ updateMemoryUsage(g_mmprevious, "After creating CScrollbarHorizontalTest");
+
+ // Connect the NX server
+
+ message("cscrollbarhorizontal_main: Connect the CScrollbarHorizontalTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cscrollbarhorizontal_main: Failed to connect the CScrollbarHorizontalTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarhorizontal_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cscrollbarhorizontal_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cscrollbarhorizontal_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarhorizontal_main: After creating a window");
+
+ // Create a scrollbar
+
+ message("cscrollbarhorizontal_main: Create a Scrollbar\n");
+ CScrollbarHorizontal *scrollbar = test->createScrollbar();
+ if (!scrollbar)
+ {
+ message("cscrollbarhorizontal_main: Failed to create a scrollbar\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarhorizontal_main: After creating a scrollbar");
+
+ // Set the scrollbar minimum and maximum values
+
+ scrollbar->setMinimumValue(0);
+ scrollbar->setMaximumValue(MAX_SCROLLBAR);
+ scrollbar->setValue(0);
+ message("cscrollbarhorizontal_main: Scrollbar range %d->%d Initial value %d\n",
+ scrollbar->getMinimumValue(), scrollbar->getMaximumValue(),
+ scrollbar->getValue());
+
+ // Show the initial state of the checkbox
+
+ test->showScrollbar(scrollbar);
+ sleep(1);
+
+ // Now move the scrollbar up
+
+ for (int i = 0; i <= MAX_SCROLLBAR; i++)
+ {
+ scrollbar->setValue(i);
+ test->showScrollbar(scrollbar);
+ message("cscrollbarhorizontal_main: %d. New value %d\n", i, scrollbar->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarhorizontal_main: After moving the scrollbar up");
+
+ // And move the scrollbar down
+
+ for (int i = MAX_SCROLLBAR; i >= 0; i--)
+ {
+ scrollbar->setValue(i);
+ test->showScrollbar(scrollbar);
+ message("cscrollbarhorizontal_main: %d. New value %d\n", i, scrollbar->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarhorizontal_main: After moving the scrollbar down");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("cscrollbarhorizontal_main: Clean-up and exit\n");
+ delete scrollbar;
+ updateMemoryUsage(g_mmprevious, "After deleting the scrollbar");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.cxx b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.cxx
new file mode 100644
index 000000000..06673f080
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.cxx
@@ -0,0 +1,225 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "cscrollbarhorizontaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CScrollbarHorizontalTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CScrollbarHorizontalTest Constructor
+
+CScrollbarHorizontalTest::CScrollbarHorizontalTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CScrollbarHorizontalTest Descriptor
+
+CScrollbarHorizontalTest::~CScrollbarHorizontalTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CScrollbarHorizontalTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CSCROLLBARHORIZONTALTEST_BGCOLOR))
+ {
+ message("CScrollbarHorizontalTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CScrollbarHorizontalTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CScrollbarHorizontalTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CScrollbarHorizontalTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CScrollbarHorizontalTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a scrollbar in the center of the window
+
+CScrollbarHorizontal *CScrollbarHorizontalTest::createScrollbar(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CScrollbarHorizontalTest::createScrollbar: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the scrollbar in the center of the display
+
+ nxgl_coord_t scrollbarWidth = windowSize.w >> 1;
+ nxgl_coord_t scrollbarX = windowSize.w >> 2;
+
+ nxgl_coord_t scrollbarHeight = 10;
+ nxgl_coord_t scrollbarY = (windowSize.h - scrollbarHeight) >> 1;
+
+ // Create the scrollbar
+
+ CScrollbarHorizontal *scrollbar =
+ new CScrollbarHorizontal(m_widgetControl,
+ scrollbarX, scrollbarY,
+ scrollbarWidth, scrollbarHeight);
+ if (!scrollbar)
+ {
+ printf("CScrollbarHorizontalTest::createScrollbar: Failed to create CScrollbarHorizontal\n");
+ disconnect();
+ }
+ return scrollbar;
+}
+
+// (Re-)draw the scrollbar.
+
+void CScrollbarHorizontalTest::showScrollbar(CScrollbarHorizontal *scrollbar)
+{
+ scrollbar->enable(); // Un-necessary, the widget is enabled by default
+ scrollbar->enableDrawing();
+ scrollbar->redraw();
+}
diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.hxx b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.hxx
new file mode 100644
index 000000000..774225091
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontaltest.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 __UNITTESTS_CSCROLLBARHORIZONTAL_CSCROLLBARHORIZONTALTEST_HXX
+#define __UNITTESTS_CSCROLLBARHORIZONTAL_CSCROLLBARHORIZONTALTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cscrollbarhorizontal.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CSCROLLBARHORIZONTALTEST_BGCOLOR
+# define CONFIG_CSCROLLBARHORIZONTALTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CScrollbarHorizontalTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CScrollbarHorizontalTest(void);
+ ~CScrollbarHorizontalTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a scrollbar in the center of the window
+
+ CScrollbarHorizontal *createScrollbar(void);
+
+ // (Re-)draw the scrollbar.
+
+ void showScrollbar(CScrollbarHorizontal *scrollbar);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CSCROLLBARHORIZONTAL_CSCROLLBARHORIZONTALTEST_HXX
diff --git a/NxWidgets/UnitTests/CScrollbarVertical/Makefile b/NxWidgets/UnitTests/CScrollbarVertical/Makefile
new file mode 100644
index 000000000..a2777e752
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarVertical/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CScrollbarVertical/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cscrollbarvertical_main.cxx cscrollbarverticaltest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cscrollbarvertical
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png
new file mode 100644
index 000000000..58067690d
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical_main.cxx b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical_main.cxx
new file mode 100644
index 000000000..26dc70dbd
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical_main.cxx
@@ -0,0 +1,231 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cscrollbarverticaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#define MAX_SCROLLBAR 20
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cscrollbarvertical_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cscrollbarvertical_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("cscrollbarvertical_main: Create CScrollbarVerticalTest instance\n");
+ CScrollbarVerticalTest *test = new CScrollbarVerticalTest();
+ updateMemoryUsage(g_mmprevious, "After creating CScrollbarVerticalTest");
+
+ // Connect the NX server
+
+ message("cscrollbarvertical_main: Connect the CScrollbarVerticalTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cscrollbarvertical_main: Failed to connect the CScrollbarVerticalTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarvertical_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cscrollbarvertical_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cscrollbarvertical_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarvertical_main: After creating a window");
+
+ // Create a scrollbar
+
+ message("cscrollbarvertical_main: Create a Scrollbar\n");
+ CScrollbarVertical *scrollbar = test->createScrollbar();
+ if (!scrollbar)
+ {
+ message("cscrollbarvertical_main: Failed to create a scrollbar\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarvertical_main: After creating a scrollbar");
+
+ // Set the scrollbar minimum and maximum values
+
+ scrollbar->setMinimumValue(0);
+ scrollbar->setMaximumValue(MAX_SCROLLBAR);
+ scrollbar->setValue(0);
+ message("cscrollbarvertical_main: Scrollbar range %d->%d Initial value %d\n",
+ scrollbar->getMinimumValue(), scrollbar->getMaximumValue(),
+ scrollbar->getValue());
+
+ // Show the initial state of the checkbox
+
+ test->showScrollbar(scrollbar);
+ sleep(1);
+
+ // Now move the scrollbar up
+
+ for (int i = 0; i <= MAX_SCROLLBAR; i++)
+ {
+ scrollbar->setValue(i);
+ test->showScrollbar(scrollbar);
+ message("cscrollbarvertical_main: %d. New value %d\n", i, scrollbar->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarvertical_main: After moving the scrollbar up");
+
+ // And move the scrollbar down
+
+ for (int i = MAX_SCROLLBAR; i >= 0; i--)
+ {
+ scrollbar->setValue(i);
+ test->showScrollbar(scrollbar);
+ message("cscrollbarvertical_main: %d. New value %d\n", i, scrollbar->getValue());
+ usleep(5000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cscrollbarvertical_main: After moving the scrollbar down");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("cscrollbarvertical_main: Clean-up and exit\n");
+ delete scrollbar;
+ updateMemoryUsage(g_mmprevious, "After deleting the scrollbar");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.cxx b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.cxx
new file mode 100644
index 000000000..df317adcd
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.cxx
@@ -0,0 +1,225 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "cscrollbarverticaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CScrollbarVerticalTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CScrollbarVerticalTest Constructor
+
+CScrollbarVerticalTest::CScrollbarVerticalTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CScrollbarVerticalTest Descriptor
+
+CScrollbarVerticalTest::~CScrollbarVerticalTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CScrollbarVerticalTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CSCROLLBARVERTICALTEST_BGCOLOR))
+ {
+ message("CScrollbarVerticalTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CScrollbarVerticalTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CScrollbarVerticalTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CScrollbarVerticalTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CScrollbarVerticalTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a scrollbar in the center of the window
+
+CScrollbarVertical *CScrollbarVerticalTest::createScrollbar(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CScrollbarVerticalTest::createScrollbar: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the scrollbar in the center of the display
+
+ nxgl_coord_t scrollbarWidth = 10;
+ nxgl_coord_t scrollbarX = (windowSize.w - scrollbarWidth) >> 1;
+
+ nxgl_coord_t scrollbarHeight = windowSize.h >> 1;
+ nxgl_coord_t scrollbarY = windowSize.h >> 2;
+
+ // Create the scrollbar
+
+ CScrollbarVertical *scrollbar =
+ new CScrollbarVertical(m_widgetControl,
+ scrollbarX, scrollbarY,
+ scrollbarWidth, scrollbarHeight);
+ if (!scrollbar)
+ {
+ printf("CScrollbarVerticalTest::createScrollbar: Failed to create CScrollbarVertical\n");
+ disconnect();
+ }
+ return scrollbar;
+}
+
+// (Re-)draw the scrollbar.
+
+void CScrollbarVerticalTest::showScrollbar(CScrollbarVertical *scrollbar)
+{
+ scrollbar->enable(); // Un-necessary, the widget is enabled by default
+ scrollbar->enableDrawing();
+ scrollbar->redraw();
+}
diff --git a/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.hxx b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.hxx
new file mode 100644
index 000000000..8b9fb1ee8
--- /dev/null
+++ b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CScrollbarVertical/cscrollbarverticaltest.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 __UNITTESTS_CSCROLLBARVERTICAL_CSCROLLBARVERTICALTEST_HXX
+#define __UNITTESTS_CSCROLLBARVERTICAL_CSCROLLBARVERTICALTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cscrollbarvertical.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CSCROLLBARVERTICALTEST_BGCOLOR
+# define CONFIG_CSCROLLBARVERTICALTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CScrollbarVerticalTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CScrollbarVerticalTest(void);
+ ~CScrollbarVerticalTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a scrollbar in the center of the window
+
+ CScrollbarVertical *createScrollbar(void);
+
+ // (Re-)draw the scrollbar.
+
+ void showScrollbar(CScrollbarVertical *scrollbar);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CSCROLLBARVERTICAL_CSCROLLBARVERTICALTEST_HXX
diff --git a/NxWidgets/UnitTests/CSliderHorizonal/Makefile b/NxWidgets/UnitTests/CSliderHorizonal/Makefile
new file mode 100644
index 000000000..0578510d3
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderHorizonal/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CSliderHorizontal/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = csliderhorizontal_main.cxx csliderhorizontaltest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = csliderhorizontal
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png
new file mode 100644
index 000000000..0b68a48c5
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal_main.cxx b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal_main.cxx
new file mode 100644
index 000000000..a336ba94a
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal_main.cxx
@@ -0,0 +1,231 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderHorizontal/csliderhorizontal_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "csliderhorizontaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#define MAX_SLIDER 50
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int csliderhorizontal_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int csliderhorizontal_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("csliderhorizontal_main: Create CSliderHorizontalTest instance\n");
+ CSliderHorizontalTest *test = new CSliderHorizontalTest();
+ updateMemoryUsage(g_mmprevious, "After creating CSliderHorizontalTest");
+
+ // Connect the NX server
+
+ message("csliderhorizontal_main: Connect the CSliderHorizontalTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("csliderhorizontal_main: Failed to connect the CSliderHorizontalTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "csliderhorizontal_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("csliderhorizontal_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("csliderhorizontal_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "csliderhorizontal_main: After creating a window");
+
+ // Create a slider
+
+ message("csliderhorizontal_main: Create a Slider\n");
+ CSliderHorizontal *slider = test->createSlider();
+ if (!slider)
+ {
+ message("csliderhorizontal_main: Failed to create a slider\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "csliderhorizontal_main: After creating a slider");
+
+ // Set the slider minimum and maximum values
+
+ slider->setMinimumValue(0);
+ slider->setMaximumValue(MAX_SLIDER);
+ slider->setValue(0);
+ message("csliderhorizontal_main: Slider range %d->%d Initial value %d\n",
+ slider->getMinimumValue(), slider->getMaximumValue(),
+ slider->getValue());
+
+ // Show the initial state of the checkbox
+
+ test->showSlider(slider);
+ sleep(1);
+
+ // Now move the slider up
+
+ for (int i = 0; i <= MAX_SLIDER; i++)
+ {
+ slider->setValue(i);
+ test->showSlider(slider);
+ message("csliderhorizontal_main: %d. New value %d\n", i, slider->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "csliderhorizontal_main: After moving the slider up");
+
+ // And move the slider down
+
+ for (int i = MAX_SLIDER; i >= 0; i--)
+ {
+ slider->setValue(i);
+ test->showSlider(slider);
+ message("csliderhorizontal_main: %d. New value %d\n", i, slider->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "csliderhorizontal_main: After moving the slider down");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("csliderhorizontal_main: Clean-up and exit\n");
+ delete slider;
+ updateMemoryUsage(g_mmprevious, "After deleting the slider");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.cxx b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.cxx
new file mode 100644
index 000000000..1687448db
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.cxx
@@ -0,0 +1,224 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderHorizontal/csliderhorizontaltest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "csliderhorizontaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CSliderHorizontalTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CSliderHorizontalTest Constructor
+
+CSliderHorizontalTest::CSliderHorizontalTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CSliderHorizontalTest Descriptor
+
+CSliderHorizontalTest::~CSliderHorizontalTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CSliderHorizontalTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CSLIDERHORIZONTALTEST_BGCOLOR))
+ {
+ message("CSliderHorizontalTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CSliderHorizontalTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CSliderHorizontalTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CSliderHorizontalTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CSliderHorizontalTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a slider in the center of the window
+
+CSliderHorizontal *CSliderHorizontalTest::createSlider(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CSliderHorizontalTest::createSlider: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the slider in the center of the display
+
+ nxgl_coord_t sliderWidth = windowSize.w >> 1;
+ nxgl_coord_t sliderX = windowSize.w >> 2;
+
+ nxgl_coord_t sliderHeight = 10;
+ nxgl_coord_t sliderY = (windowSize.h - sliderHeight) >> 1;
+
+ // Create the slider
+
+ CSliderHorizontal *slider = new CSliderHorizontal(m_widgetControl,
+ sliderX, sliderY,
+ sliderWidth, sliderHeight);
+ if (!slider)
+ {
+ printf("CSliderHorizontalTest::createSlider: Failed to create CSliderHorizontal\n");
+ disconnect();
+ }
+ return slider;
+}
+
+// (Re-)draw the slider.
+
+void CSliderHorizontalTest::showSlider(CSliderHorizontal *slider)
+{
+ slider->enable(); // Un-necessary, the widget is enabled by default
+ slider->enableDrawing();
+ slider->redraw();
+}
diff --git a/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.hxx b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.hxx
new file mode 100644
index 000000000..9709a2b7c
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontaltest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderHorizontal/csliderhorizontaltest.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 __UNITTESTS_CSLIDERHORIZONTAL_CSLIDERHORIZONTALTEST_HXX
+#define __UNITTESTS_CSLIDERHORIZONTAL_CSLIDERHORIZONTALTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "csliderhorizontal.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CSLIDERHORIZONTALTEST_BGCOLOR
+# define CONFIG_CSLIDERHORIZONTALTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CSliderHorizontalTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CSliderHorizontalTest(void);
+ ~CSliderHorizontalTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a slider in the center of the window
+
+ CSliderHorizontal *createSlider(void);
+
+ // (Re-)draw the slider.
+
+ void showSlider(CSliderHorizontal *slider);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CSLIDERHORIZONTAL_CSLIDERHORIZONTALTEST_HXX
diff --git a/NxWidgets/UnitTests/CSliderVertical/Makefile b/NxWidgets/UnitTests/CSliderVertical/Makefile
new file mode 100644
index 000000000..f37cc8619
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderVertical/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CSliderVertical/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = cslidervertical_main.cxx csliderverticaltest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = cslidervertical
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CSliderVertical/cslidervertical.png b/NxWidgets/UnitTests/CSliderVertical/cslidervertical.png
new file mode 100644
index 000000000..6572746ba
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderVertical/cslidervertical.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CSliderVertical/cslidervertical_main.cxx b/NxWidgets/UnitTests/CSliderVertical/cslidervertical_main.cxx
new file mode 100644
index 000000000..df356718b
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderVertical/cslidervertical_main.cxx
@@ -0,0 +1,231 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderVertical/cslidervertical_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "csliderverticaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#define MAX_SLIDER 50
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static unsigned int g_mmInitial;
+static unsigned int g_mmprevious;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int cslidervertical_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void updateMemoryUsage(unsigned int previous,
+ FAR const char *msg)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+ message("\n%s:\n", msg);
+ message(" Before: %8d After: %8d Change: %8d\n\n",
+ previous, mmcurrent.uordblks, mmcurrent.uordblks - previous);
+
+ /* Set up for the next test */
+
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_mmInitial = mmcurrent.uordblks;
+ g_mmprevious = mmcurrent.uordblks;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int cslidervertical_main(int argc, char *argv[])
+{
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Create an instance of the checkbox test
+
+ message("cslidervertical_main: Create CSliderVerticalTest instance\n");
+ CSliderVerticalTest *test = new CSliderVerticalTest();
+ updateMemoryUsage(g_mmprevious, "After creating CSliderVerticalTest");
+
+ // Connect the NX server
+
+ message("cslidervertical_main: Connect the CSliderVerticalTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ message("cslidervertical_main: Failed to connect the CSliderVerticalTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cslidervertical_main: After connecting to the server");
+
+ // Create a window to draw into
+
+ message("cslidervertical_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ message("cslidervertical_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cslidervertical_main: After creating a window");
+
+ // Create a slider
+
+ message("cslidervertical_main: Create a Slider\n");
+ CSliderVertical *slider = test->createSlider();
+ if (!slider)
+ {
+ message("cslidervertical_main: Failed to create a slider\n");
+ delete test;
+ return 1;
+ }
+ updateMemoryUsage(g_mmprevious, "cslidervertical_main: After creating a slider");
+
+ // Set the slider minimum and maximum values
+
+ slider->setMinimumValue(0);
+ slider->setMaximumValue(MAX_SLIDER);
+ slider->setValue(0);
+ message("cslidervertical_main: Slider range %d->%d Initial value %d\n",
+ slider->getMinimumValue(), slider->getMaximumValue(),
+ slider->getValue());
+
+ // Show the initial state of the checkbox
+
+ test->showSlider(slider);
+ sleep(1);
+
+ // Now move the slider up
+
+ for (int i = 0; i <= MAX_SLIDER; i++)
+ {
+ slider->setValue(i);
+ test->showSlider(slider);
+ message("cslidervertical_main: %d. New value %d\n", i, slider->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cslidervertical_main: After moving the slider up");
+
+ // And move the slider down
+
+ for (int i = MAX_SLIDER; i >= 0; i--)
+ {
+ slider->setValue(i);
+ test->showSlider(slider);
+ message("cslidervertical_main: %d. New value %d\n", i, slider->getValue());
+ usleep(1000); // The simulation needs this to let the X11 event loop run
+ }
+ updateMemoryUsage(g_mmprevious, "cslidervertical_main: After moving the slider down");
+ sleep(1);
+
+ // Clean up and exit
+
+ message("cslidervertical_main: Clean-up and exit\n");
+ delete slider;
+ updateMemoryUsage(g_mmprevious, "After deleting the slider");
+ delete test;
+ updateMemoryUsage(g_mmprevious, "After deleting the test");
+ updateMemoryUsage(g_mmInitial, "Final memory usage");
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.cxx b/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.cxx
new file mode 100644
index 000000000..d0691c52d
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.cxx
@@ -0,0 +1,225 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.cxx
+//
+// 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.
+// modify this software without notice.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cbgwindow.hxx"
+#include "csliderverticaltest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CSliderVerticalTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CSliderVerticalTest Constructor
+
+CSliderVerticalTest::CSliderVerticalTest()
+{
+ // Initialize state data
+
+ m_widgetControl = (CWidgetControl *)NULL;
+ m_bgWindow = (CBgWindow *)NULL;
+}
+
+// CSliderVerticalTest Descriptor
+
+CSliderVerticalTest::~CSliderVerticalTest(void)
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CSliderVerticalTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CSLIDERVERTICALTEST_BGCOLOR))
+ {
+ message("CSliderVerticalTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CSliderVerticalTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow *)NULL;
+ }
+
+ // Free the widget control instance
+
+ if (m_widgetControl)
+ {
+ delete m_widgetControl;
+ m_widgetControl = (CWidgetControl *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CSliderVerticalTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ message("CSliderVerticalTest::createWindow: Failed to create CBgWindow instance\n");
+ disconnect();
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ message("CSliderVerticalTest::createWindow: Failed to open background window\n");
+ disconnect();
+ return false;
+ }
+
+ return true;
+}
+
+// Create a slider in the center of the window
+
+CSliderVertical *CSliderVerticalTest::createSlider(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CSliderVerticalTest::createSlider: Failed to get window size\n");
+ disconnect();
+ return false;
+ }
+
+ // Put the slider in the center of the display
+
+ nxgl_coord_t sliderWidth = 10;
+ nxgl_coord_t sliderX = (windowSize.w - sliderWidth) >> 1;
+
+ nxgl_coord_t sliderHeight = windowSize.h >> 1;
+ nxgl_coord_t sliderY = windowSize.h >> 2;
+
+ // Create the slider
+
+ CSliderVertical *slider = new CSliderVertical(m_widgetControl,
+ sliderX, sliderY,
+ sliderWidth, sliderHeight);
+ if (!slider)
+ {
+ printf("CSliderVerticalTest::createSlider: Failed to create CSliderVertical\n");
+ disconnect();
+ }
+ return slider;
+}
+
+// (Re-)draw the slider.
+
+void CSliderVerticalTest::showSlider(CSliderVertical *slider)
+{
+ slider->enable(); // Un-necessary, the widget is enabled by default
+ slider->enableDrawing();
+ slider->redraw();
+}
diff --git a/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.hxx b/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.hxx
new file mode 100644
index 000000000..3bb174ba0
--- /dev/null
+++ b/NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.hxx
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CSliderVertical/csliderverticaltest.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 __UNITTESTS_CSLIDERVERTICAL_CSLIDERVERTICALTEST_HXX
+#define __UNITTESTS_CSLIDERVERTICAL_CSLIDERVERTICALTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cslidervertical.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CSLIDERVERTICALTEST_BGCOLOR
+# define CONFIG_CSLIDERVERTICALTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+// If debug is enabled, use the debug function, lib_rawprintf() instead
+// of printf() so that the output is synchronized.
+
+#ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+#else
+# define message printf
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CSliderVerticalTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CBgWindow *m_bgWindow; // Background window instance
+
+public:
+ // Constructor/destructors
+
+ CSliderVerticalTest(void);
+ ~CSliderVerticalTest(void);
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a slider in the center of the window
+
+ CSliderVertical *createSlider(void);
+
+ // (Re-)draw the slider.
+
+ void showSlider(CSliderVertical *slider);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+#endif // __UNITTESTS_CSLIDERVERTICAL_CSLIDERVERTICALTEST_HXX
diff --git a/NxWidgets/UnitTests/CTextBox/Makefile b/NxWidgets/UnitTests/CTextBox/Makefile
new file mode 100644
index 000000000..c368cc497
--- /dev/null
+++ b/NxWidgets/UnitTests/CTextBox/Makefile
@@ -0,0 +1,172 @@
+#################################################################################
+# NxWidgets/UnitTests/CTextBox/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# Hello, World! C++ Example
+
+ASRCS =
+CSRCS =
+CXXSRCS = ctextbox_main.cxx ctextboxtest.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = ctextbox
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklib
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklib:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklib does the work.
+
+.built: chkcxx chklib $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/CTextBox/ctextbox.png b/NxWidgets/UnitTests/CTextBox/ctextbox.png
new file mode 100644
index 000000000..4c9f76ae7
--- /dev/null
+++ b/NxWidgets/UnitTests/CTextBox/ctextbox.png
Binary files differ
diff --git a/NxWidgets/UnitTests/CTextBox/ctextbox_main.cxx b/NxWidgets/UnitTests/CTextBox/ctextbox_main.cxx
new file mode 100644
index 000000000..da76c88cf
--- /dev/null
+++ b/NxWidgets/UnitTests/CTextBox/ctextbox_main.cxx
@@ -0,0 +1,141 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CTextBox/ctextbox_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "ctextboxtest.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static const char string1[] = "Johhn ";
+static const char string2[] = "\b\b\bn Doe\r";
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int ctextbox_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxheaders_main
+/////////////////////////////////////////////////////////////////////////////
+
+int ctextbox_main(int argc, char *argv[])
+{
+ // Create an instance of the font test
+
+ printf("ctextbox_main: Create CTextBoxTest instance\n");
+ CTextBoxTest *test = new CTextBoxTest();
+
+ // Connect the NX server
+
+ printf("ctextbox_main: Connect the CTextBoxTest instance to the NX server\n");
+ if (!test->connect())
+ {
+ printf("ctextbox_main: Failed to connect the CTextBoxTest instance to the NX server\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a window to draw into
+
+ printf("ctextbox_main: Create a Window\n");
+ if (!test->createWindow())
+ {
+ printf("ctextbox_main: Failed to create a window\n");
+ delete test;
+ return 1;
+ }
+
+ // Create a CTextBox instance
+
+ CTextBox *textbox = test->createTextBox();
+ if (!textbox)
+ {
+ printf("ctextbox_main: Failed to create a text box\n");
+ delete test;
+ return 1;
+ }
+
+ // Show the text box
+
+ test->showTextBox(textbox);
+
+ // Wait a bit, then inject a string with a typo
+
+ sleep(1);
+ test->injectChars(textbox, sizeof(string1), (FAR const uint8_t*)string1);
+
+ // Now fix the string with backspaces and finish it correctly
+
+ usleep(500*1000);
+ test->injectChars(textbox, sizeof(string2), (FAR const uint8_t*)string2);
+
+ // Clean up and exit
+
+ sleep(2);
+ printf("ctextbox_main: Clean-up and exit\n");
+ delete textbox;
+ delete test;
+ return 0;
+}
+
diff --git a/NxWidgets/UnitTests/CTextBox/ctextboxtest.cxx b/NxWidgets/UnitTests/CTextBox/ctextboxtest.cxx
new file mode 100644
index 000000000..07a1f116d
--- /dev/null
+++ b/NxWidgets/UnitTests/CTextBox/ctextboxtest.cxx
@@ -0,0 +1,287 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CTextBox/ctextboxtest.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <cerrno>
+#include <unistd.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "ctextboxtest.hxx"
+#include "cbgwindow.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Classes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// CTextBoxTest Method Implementations
+/////////////////////////////////////////////////////////////////////////////
+
+// CTextBoxTest Constructor
+
+CTextBoxTest::CTextBoxTest()
+{
+ m_bgWindow = (CBgWindow *)NULL;
+ m_nxFont = (CNxFont *)NULL;
+ m_text = (CNxString *)NULL;
+}
+
+// CTextBoxTest Descriptor
+
+CTextBoxTest::~CTextBoxTest()
+{
+ disconnect();
+}
+
+// Connect to the NX server
+
+bool CTextBoxTest::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Create the default font instance
+
+ m_nxFont = new CNxFont(NXFONT_DEFAULT,
+ CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ if (!m_nxFont)
+ {
+ printf("CTextBoxTest::connect: Failed to create the default font\n");
+ }
+
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_CTEXTBOXTEST_BGCOLOR))
+ {
+ printf("CTextBoxTest::connect: setBackgroundColor failed\n");
+ }
+ }
+
+ return nxConnected;
+}
+
+// Disconnect from the NX server
+
+void CTextBoxTest::disconnect(void)
+{
+ // Close the window
+
+ if (m_bgWindow)
+ {
+ delete m_bgWindow;
+ }
+
+ // Free the display string
+
+ if (m_text)
+ {
+ delete m_text;
+ m_text = (CNxString *)NULL;
+ }
+
+ // Free the default font
+
+ if (m_nxFont)
+ {
+ delete m_nxFont;
+ m_nxFont = (CNxFont *)NULL;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+// Create the background window instance. This function illustrates
+// the basic steps to instantiate any window:
+//
+// 1) Create a dumb CWigetControl instance
+// 2) Pass the dumb CWidgetControl instance to the window constructor
+// that inherits from INxWindow. This will "smarten" the CWidgetControl
+// instance with some window knowlede
+// 3) Call the open() method on the window to display the window.
+// 4) After that, the fully smartened CWidgetControl instance can
+// be used to generate additional widgets by passing it to the
+// widget constructor
+
+bool CTextBoxTest::createWindow(void)
+{
+ // Initialize the widget control using the default style
+
+ m_widgetControl = new CWidgetControl((CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ m_bgWindow = getBgWindow(m_widgetControl);
+ if (!m_bgWindow)
+ {
+ printf("CTextBoxTest::createGraphics: Failed to create CBgWindow instance\n");
+ delete m_widgetControl;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = m_bgWindow->open();
+ if (!success)
+ {
+ printf("CTextBoxTest::createGraphics: Failed to open background window\n");
+ delete m_bgWindow;
+ m_bgWindow = (CBgWindow*)0;
+ return false;
+ }
+
+ return true;
+}
+
+// Create a CTextBox instance
+
+CTextBox *CTextBoxTest::createTextBox(void)
+{
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_bgWindow->getSize(&windowSize))
+ {
+ printf("CTextBoxTest::createGraphics: Failed to get window size\n");
+ return (CTextBox *)NULL;
+ }
+
+ // Create an empty CNxString instance to contain the C string
+
+ m_text = new CNxString();
+
+ // Get the height and width of the text display area. The width
+ // is half of the display width and the height is optimized for
+ // the font height
+
+ nxgl_coord_t textBoxWidth = windowSize.w >> 1;
+ nxgl_coord_t textBoxHeight = (nxgl_coord_t)m_nxFont->getHeight();
+
+ // The default CTextBox has borders enabled with thickness of one.
+ // Add twice the thickness of the border to the height.
+
+ textBoxHeight += 2 * 1;
+
+ // Pick an X/Y position such that the label will be centered in the display
+
+ nxgl_coord_t labelX = windowSize.w >> 2;
+ nxgl_coord_t labelY = (windowSize.h - textBoxHeight) >> 1;
+
+ // Now we have enough information to create the label
+
+ return new CTextBox(m_widgetControl, labelX, labelY, textBoxWidth, textBoxHeight, *m_text);
+}
+
+// Draw the label
+
+void CTextBoxTest::showTextBox(CTextBox *label)
+{
+ label->enable();
+ label->enableDrawing();
+ label->redraw();
+}
+
+// Inject simulated keyboard characters into NX.
+
+void CTextBoxTest::injectChars(CTextBox *textbox, int nCh, FAR const uint8_t *string)
+{
+ // nx_kbdin is meant to be called by keyboard handling software.
+ // Here we just inject the string under unit test control.
+
+ // First, get the server handle. Graphics software will never care
+ // about the server handle. Here we need it to get access to the
+ // low-level keyboard interface
+
+ NXHANDLE handle = getServer();
+
+ // The widget must have focus to receive keyboard input
+
+ m_widgetControl->setFocusedWidget(textbox);
+
+ // Inject the string one character at a time to get a more realistic
+ // simulation of keyboard behavior. Note the API nx_kbdin() could
+ // be used to inject the string in its entirety.
+
+ for (int i = 0; i < nCh; i++)
+ {
+ // Inject the next character
+
+ (void)nx_kbdchin(handle, string[i]);
+
+ // Widget events are normally handled in a modal loop.
+ // However, for this case we know when there should be keyboard events pending,
+ // events so we don't have to poll repeatedly. We can just perform a one pass
+ // poll
+
+ m_widgetControl->pollEvents(textbox);
+
+ // Sleep a bit, just for the effect (this also gives the X server loop a
+ // chance to run in the simulated environment.
+
+ usleep(500*1000);
+ }
+}
diff --git a/NxWidgets/UnitTests/CTextBox/ctextboxtest.hxx b/NxWidgets/UnitTests/CTextBox/ctextboxtest.hxx
new file mode 100644
index 000000000..9da8ce09f
--- /dev/null
+++ b/NxWidgets/UnitTests/CTextBox/ctextboxtest.hxx
@@ -0,0 +1,142 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/CTextBox/ctextboxtest.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 __UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
+#define __UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+
+#include <nuttx/init.h>
+#include <cstdio>
+#include <semaphore.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+#include "cbgwindow.hxx"
+#include "cnxserver.hxx"
+#include "cnxfont.hxx"
+#include "cnxstring.hxx"
+#include "ctextbox.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+// Definitions
+/////////////////////////////////////////////////////////////////////////////
+// Configuration ////////////////////////////////////////////////////////////
+
+#ifndef CONFIG_HAVE_CXX
+# error "CONFIG_HAVE_CXX must be defined"
+#endif
+
+#ifndef CONFIG_CTEXTBOXTEST_BGCOLOR
+# define CONFIG_CTEXTBOXTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_CTEXTBOXTEST_FONTCOLOR
+# define CONFIG_CTEXTBOXTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Classes
+/////////////////////////////////////////////////////////////////////////////
+
+using namespace NXWidgets;
+
+class CTextBoxTest : public CNxServer
+{
+private:
+ CWidgetControl *m_widgetControl; // The controlling widget for the window
+ CNxFont *m_nxFont; // Default font
+ CBgWindow *m_bgWindow; // Background window instance
+ CNxString *m_text; // The label string
+
+public:
+ // Constructor/destructors
+
+ CTextBoxTest();
+ ~CTextBoxTest();
+
+ // Initializer/unitializer. These methods encapsulate the basic steps for
+ // starting and stopping the NX server
+
+ bool connect(void);
+ void disconnect(void);
+
+ // Create a window. This method provides the general operations for
+ // creating a window that you can draw within.
+ //
+ // Those general operations are:
+ // 1) Create a dumb CWigetControl instance
+ // 2) Pass the dumb CWidgetControl instance to the window constructor
+ // that inherits from INxWindow. This will "smarten" the CWidgetControl
+ // instance with some window knowlede
+ // 3) Call the open() method on the window to display the window.
+ // 4) After that, the fully smartened CWidgetControl instance can
+ // be used to generate additional widgets by passing it to the
+ // widget constructor
+
+ bool createWindow(void);
+
+ // Create a CTextBox instance. This method will show you how to create
+ // a CTextBox widget
+
+ CTextBox *createTextBox(void);
+
+ // Draw the label. This method illustrates how to draw the CTextBox widget.
+
+ void showTextBox(CTextBox *label);
+
+ // Inject simulated keyboard characters into NX.
+
+ void injectChars(CTextBox *textbox, int nCh, FAR const uint8_t *string);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Data
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif // __UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
diff --git a/NxWidgets/UnitTests/README.txt b/NxWidgets/UnitTests/README.txt
new file mode 100644
index 000000000..cc01c3855
--- /dev/null
+++ b/NxWidgets/UnitTests/README.txt
@@ -0,0 +1,418 @@
+README
+======
+
+This directory contains a collection of Unit Tests that can be used to verify
+NXWidgets.:
+
+Contents
+========
+ o Installing and Building the Unit Tests
+ 1. Setup NuttX
+ a) Configure NuttX
+ b) Enable C++ Support
+ c) Enable Debug Options
+ d) Other Possible nuttx/.config changes
+ e) Other Possible apps/.config changes
+ 2. Configure in the Selected Unit Test
+ o Work-Arounds
+ 1. Build Issues
+ 2. Stack Size Issues with the X11 Simulation
+ o Theory of Operation
+ o Unit Test Directories
+ o Example
+
+Installing and Building the Unit Tests
+======================================
+
+1. Setup NuttX
+
+ a) Configure NuttX
+
+ Configure NuttX to run one of the target configurations. For example,
+ let's assume that you are using the sim/nsh2 configuration. The sim/nsh2
+ configuration was specially created for use NXWidgets on the simulation
+ platform. A similar, special configuration stm3210e-eval/nsh2 is also
+ for the STM3210E-EVAL available. However, the unit test can be run on
+ other configurations (see steps d and e below).
+
+ NOTE: There are some other special configurationsrecommended for unit-leveling
+ testing of NxWM because the configuration is more complex in that case. These
+ are:
+
+ 1) sim/nxwmm, or the simulated platform (no touchscreen), and
+ 2) stm3240g-evel, for the STM3240G-EVAL board (with the STMPE11 touchscreen)
+
+ We will assume the sim/nsh2 configuration in this discussion. The
+ sim/nsh2 configuration is installed as follows:
+
+ cd <nuttx-directory-path>
+ make distclean
+ cd tools
+ ./configure.sh sim/nsh2
+
+ Where:
+
+ <nuttx-directory-path> is the full, absolute path to the NuttX build directory
+
+ If you are using the sim/nsh2 or stm3210e-eval configurations, then skip
+ to step 2 (Hmmm.. better check 1d) too).
+
+ There may be certain requirements for the configuration that you select...
+ for example, certain widget tests may require touchscreen support or special
+ font selections. These test-specific requirements are addressed below under
+ "Unit Test Directories"
+
+ b) Enable C++ Support
+
+ If you are not using the sim/nsh2 or stm3210e-eval, you will need to add
+ the following definitions to the nuttx configuration at nuttx/.config to
+ enable C++ support:
+
+ CONFIG_HAVE_CXX=y
+
+ Check first, some configurations already have C++ support enabled (As of this
+ writing *ONLY* the sim/nsh2 and stm321-e-eval configurations have C++ support
+ pre-enabled).
+
+ c) Enable Debug Options
+
+ If you are running on a simulated target, then you might also want to
+ enable debug symbols:
+
+ CONFIG_DEBUG_SYMBOLS=y
+
+ Then you can run the simulation using GDB or DDD which is a very powerful
+ debugging environment!
+
+ d) Special configuration requirements for the nxwm unit test:
+
+ CONFIG_NXCONSOLE=y
+ CONFIG_NX_MULTIUSER=y
+
+ e) Other nuttx/.config changes -- NSH configurations only.
+
+ If the configuration that you are using supports NSH and NSH built-in tasks
+ then all is well. If it is an NSH configuration, then you will have to define
+ the following in your nuttx/.config file as well (if it is not already defined):
+
+ CONFIG_NSH_BUILTIN_APPS=y
+
+ sim/nsh2 and stm3210e-eval/nsh2 already has this setting. You do not need
+ to change anything further in the nuttx/.config file if you are using either
+ of these configurations.
+
+ f) Other apps/.config changes -- NON-NSH configurations only.
+
+ For non-NSH configurations (such as the sim/touchscreen) you will have to
+ remove the CONFIGURED_APPS seting that contains the user_start function so
+ that you use the user_start in the unit test code instead. So, for example,
+ with the sim/touchscreen configuration you need to remove the following from
+ the apps/.config file:
+
+ CONFIGURED_APPS += examples/<example> ## REMOVE
+
+ The following step will then install the new, correct directory containing
+ the user_start function for the selected unit test. If you see that NSH
+ is configured:
+
+ CONFIGURED_APPS += examples/nsh ## DO NOT REMOVE
+
+ Then DO NOT REMOVE the CONFIGURED_APPS setting. Go back and re-read c)
+ above. Do either c) or d). Don't do both!
+
+ sim/nsh2 and stm3210e-eval/nsh2 both NSH configurations. You do not need
+ to change anything further in the apps/.config file for any NSH configuration.
+
+2. Configure/Install the Selected Unit Test
+
+ Then reconfigure that to use the Unit Test of your choice:
+
+ cd <nxwidgets-directory>/tools
+ ./install.sh <apps-directory-path> <test-sub-directory>
+
+ Where:
+
+ <apps-directory-path> is the full, absolute path to the NuttX apps/ directory
+ <test-sub-directory> is the name of a sub-directory in the UnitTests directory
+
+3. Instantiate the Configuration
+
+ Before we can make the NXWidgets Library, we have to instantiate the NuttX
+ configuration with the installed unit test:
+
+ cd <nuttx-directory-path>
+ . ./setenv.sh
+ make context
+
+ This will create auto-generated files and will setup symbolic links needed
+ in order to build the NXWidgets Library.
+
+4. Adjust the Stack Size
+
+ If using an simulation configuration (like sim/nsh2) and your unit test
+ uses X11 as its display device, then you would have to increase the size
+ of unit test stack as described below under "Stack Size Issues with the
+ X11 Simulation."
+
+5. Build the NXWidgets Library
+
+ cd <nxwidgets-directory>/libnxwidgets
+ make TOPDIR=<nuttx-directory-path>
+
+6. Build the NxWM library.
+
+ The NxWM library (libnxwm.a) is required only for the NxWM unit test at
+ NxWidgets/UnitTests/nxwm. For other unit tests, skip to step 7.
+
+ cd <nxwidgets-directory>/nxwm
+ make TOPDIR=<nuttx-directory-path>
+
+7. Build NuttX including the unit test and the NXWidgets library
+
+ cd <nuttx-directory-path>
+ . ./setenv.sh
+ make
+
+Work-Arounds
+============
+
+Build Issues
+------------
+1. I have seen this error on Cygwin building C++ code:
+
+ LD: nuttx.rel
+ ld: skipping incompatible /home/patacongo/projects/nuttx/nuttx/trunk/nuttx/libxx//liblibxx.a when searching for -llibxx
+ ld: cannot find -llibxx
+
+ The problem seems to be caused because gcc build code for 32-bit mode and g++ builds code for 64-bit mode. Add the -m32 option to the g++ command line seems to fix the problem. In Make.defs:
+
+ CXXFLAGS = -m32 $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
+ $(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
+
+2. Stack Size Issues with the X11 Simulation
+
+ When you run the NuttX simulation, it uses stacks allocated by NuttX from the
+ NuttX heap. The memory management model is exactly the same in the simulation
+ as it is real, target system. This is good because this produces a higher
+ fidelity simulation.
+
+ However, when the simulation calls into Linux/Cygwin libraries, it will still
+ use these small simulation stacks. This happens, for example, when you call
+ into the system to get and put characters to the console window or when you
+ make x11 calls into the system. The programming model within those libraries
+ will assume a Linux/Cygwin environment where the stack size grows dynamically
+
+ As a consequence, those system libraries may allocate large data structures
+ on the stack and overflow the small NuttX stacks. X11, in particular,
+ requires large stacks. If you are using X11 in the simulation, make sure
+ that you set aside a "lot" of stack for the X11 system calls (maybe 8 or 16Kb).
+ The stack size for the thread that begins with user start is controlled
+ by the configuration setting CONFIG_USERMAIN_STACKSIZE; you may need to
+ increase this value to larger number to survive the X11 system calls.
+
+ If you are running X11 applications as NSH add-on programs, then the stack
+ size of the add-on program is controlled in another way. Here are the
+ steps for increasing the stack size in that case:
+
+ cd ../apps/namedapps # Go to the namedapps directory
+ vi namedapps_list.h # Edit this file and increase the stack size of the add-on
+ rm .built *.o # This will force the namedapps logic to rebuild
+
+Theory Of Operation
+===================
+
+The NuttX application Makefile at apps/Makefile has some special hooks for
+building "external" applications. In particular, it will automatically
+build in the contents any directory call "external/" that may appear in the
+apps/ directory. There is no external/ directory in the repository. Rather,
+this directory may be provided by the user (possibly as a symbolic link) to
+add libraries and applications to the standard build from the repository.
+
+The script at tools/install.sh, then, just does a lot of careful validation and
+sanity checking. Then it installs the UnitTest test sub-directory in the apps/
+directory by creating a symbolic link in the apps/ directory call "external".
+That symbolic link will refer to the selected UnitTest sub-directory.
+
+UnitTests
+=========
+
+The following provide simple unit tests for each of the NXWidgets. In
+addition, these unit tests provide examples for the use of each widget
+type.
+
+CButton
+ Exercises the CButton widget
+ Depends on CLabel
+
+CButtonArray
+ Exercises the CButtonArray widget
+
+CCheckBox
+ Exercises the CCheckBox widget
+ Depends on CLabel and CButton.
+
+CGlyphButton
+ Exercises the CGlyphButton widget.
+ Depends on CLabel and CButton.
+
+CImage
+ Exercises the CImage widget
+
+CLabel
+ Exercises the CLabel widget
+
+CProgressBar
+ Exercises the CProgressBar widget
+
+CRadioButton
+ Exercises the CRadioButton and CRadioButtonGroup widgets.
+ Depends on CLabel and CButton
+
+CScrollBarHorizontal
+ Exercises the ScrollbarHorizontal
+ Depends on CSliderHorizontal and CGlyphButton
+
+CScrollBarVertical
+ Exercises the ScrollbarHorizontal
+ Depends on CSliderVertical and CGlyphButton
+
+CSliderHorizontal
+ Exercises the CSliderHorizontal
+ Depends on CSliderHorizontalGrip
+
+CSliderVertical
+ Exercises the CSliderVertical
+ Depends on CSliderVerticalGrip
+
+CTextBox
+ Exercises the CTextBox widget
+ Depends on CLabel
+
+nxwm
+ Exercises the NxWM window manager.
+ Use the special configurations nuttx/configs/sim/nxwm or nuttx/configs/stm3240g-eval/nxwm.
+
+Example
+=======
+
+1. Configure sim/nsh2
+ Where: nuttx and nuttx/tools directory
+
+ $ cd tools/
+ $ ./configure.sh sim/nsh2
+ $ cd -
+
+2. Edit nuttx/.config to enable C++ support
+
+ Do nothing... sim/nsh2 already has C++ support enabled.
+
+3. Install the CButton C++ application (for example)
+ Where: <nxwidgets-directory>/tool
+
+ $ ./install.sh ~/projects/nuttx/nuttx/trunk/apps/ CButton
+ /home/patacongo/projects/nuttx/nuttx/trunk/apps//external already exists...
+ Removing the old symbolic link.
+ Creating symbolic link
+ - To /home/patacongo/projects/nuttx/nuttx/trunk/NxWidgets/UnitTests/CButton
+ - At /home/patacongo/projects/nuttx/nuttx/trunk/apps//external
+
+4. Instantiate the Configuration
+ Where: nuttx directory
+
+ $ cd /home/patacongo/projects/nuttx/nuttx/trunk/nuttx
+ $ . ./setenv.sh
+ $ make context
+
+ This will create auto-generated files and will setup symbolic links needed
+ in order to build the NXWidgets Library.
+
+6. Adjust the Stack Size
+
+ If using an simulation configuration (like sim/nsh2) and your unit test
+ uses X11 as its display device, then you would have to increase the size
+ of unit test stack as described above under "Stack Size Issues."
+
+7. Build the NXWdigets Library
+ Where <nxwidgets-directory>/libnxwidgets
+
+ $ cd /home/patacongo/projects/nuttx/nuttx/trunk/NxWidgets/libnxwidgets
+ $ make TOPDIR=/home/patacongo/projects/nuttx/nuttx/trunk/nuttx
+
+8. Build NuttX
+ Where: nuttx directory
+
+ $ cd /home/patacongo/projects/nuttx/nuttx/trunk/nuttx
+ $ make
+ ...
+
+8. Run the "bringup" task:
+
+ a. Start NuttX
+ Where: nuttx directory
+
+ ./nuttx
+
+ NuttShell (NSH) NuttX-6.9
+ nsh>
+
+ b. Execute NuttX
+ Where: NSH command prompt
+
+ NOTE that when you run NSH as a simulation, the commands are echoed
+ twice -- once by Linux/Cygwin and once by NuttX:
+
+ nsh> help
+ help
+ ...
+ Builtin Apps:
+ nx
+ nxhello
+ tc
+ bringup
+ nsh> bringup
+ bringup
+ bringup [2:128]
+
+ c. Then do a kludgy thing
+ Where: NSH command prompt
+
+ The I/O with the Linux/Cygwin simulation is blocking. So while NSH is
+ waiting for input nothing can run (see configs/sim/README.txt for more info).
+ One way to make NSH stop asking for input is to sleep.
+
+ nsh> sleep 10
+ sleep 10
+
+ NOTE 1: This is not a problem if CONFIG_SCHED_WAITPID is defined in the
+ configuration file. If CONFIG_SCHED_WAITPID is defined, NSH will wait
+ for the unit test to complete and it will not be necessary to sleep.
+
+ NOTE 2: CONFIG_SCHED_WAITPID is defined in the sim/nsh2 configuration
+ so you can probably ignore this kludgy thing.
+
+ d. The Unit Test runs
+
+ As soon as NSH sleeps, the unit test will run:
+
+ bringup_main: Saying hello from the dynamically constructed instance
+ CHelloWorld::HelloWorld: Hello, World!!
+ bringup_main: Saying hello from the instance constructed on the stack
+ CHelloWorld::HelloWorld: Hello, World!!
+ bringup_main: Saying hello from the statically constructed instance
+ CHelloWorld::HelloWorld: Hello, World!!
+
+8. Debugging
+ Where: nuttx directory
+
+ In the simulation (only) you can use GDB or, better, the graphic
+ front-end DDD to debug the code. Most embedded targets do not
+ have good debugging capabilities.
+
+ In order to debug, you have to have build with CONFIG_DEBUG_SYMBOLS=y.
+ This setting is preselected in the sim/nsh2 configuration so that
+ you don't have to do anything.
+
+ Then under Linux or in a Cygwin X11 window, you can start the graphic
+ debugger like:
+
+ ddd nuttx &
diff --git a/NxWidgets/UnitTests/TestStatus.txt b/NxWidgets/UnitTests/TestStatus.txt
new file mode 100644
index 000000000..965f83ef7
--- /dev/null
+++ b/NxWidgets/UnitTests/TestStatus.txt
@@ -0,0 +1,59 @@
+NxWidgets Test Status
+=====================
+
+At this point, the NXWidgets GUI toolkit code complete but still not
+completely tested. This is a list of testing issues that still need to be
+addressed.
+
+The following Widgets have been have completed unit testing. The level of
+unit testing is, however, superficial. Many features have not yet been
+tested:
+
+ - CLabel
+ - CTextBox
+ - CButton
+ - CButtonArray
+ - CKeypad
+ - CRadioButton (and CRadioButtonGoup)
+ - CGlyphButton
+ - CLatchButton (and CStickyButton)
+ - CLatchButtonArray (and CStickyButtonArray)
+ - CCheckBox
+ - CProgressBar
+ - CImage
+ - CSliderHorizontal (and CSliderHorizontalGrip)
+ - CSliderVertical (and CSliderVerticalGrip)
+ - CScrollBarHorizontal (except paging buttons)
+ - CScrollBarVertical (except paging buttons)
+
+The following components have unit test in place, but do not successfully
+pass the test:
+
+ - CListBox (and CListBoxDataItem) which also tests:
+ o CText
+ o CList and CListDataItem
+ o CScrollingPanel
+
+The following no unit tests (and, hence, are probably non-functional):
+
+ Infrastructure (won't have their own unit tests)
+ - CScrollBarPanel
+
+ Widgets that need unit tests:
+ - CCycleButton
+ - CScrollingTextBox
+ - CMultiLineTextBox
+ - CScrollingListBox
+
+There are things that require testing after all widgets complete their unit
+tests as well. As examples:
+
+ - Need to verify that a screen with many widgets works correctly. That
+ focus is correctly handled when widgets are removed. etc.
+ - Need to verify that widget with many children work correctly together.
+ - Need to verfiy that a display with many windows with multiple wigets
+ per window works okay.
+
+Most unit-level testing was performed in a simulated environment driven by
+simulated mouse and keyboard input. So many features are not tested that
+require human interaction ... such grabbing and dragging scrollbars.
diff --git a/NxWidgets/UnitTests/nxwm/Makefile b/NxWidgets/UnitTests/nxwm/Makefile
new file mode 100644
index 000000000..11c670ece
--- /dev/null
+++ b/NxWidgets/UnitTests/nxwm/Makefile
@@ -0,0 +1,202 @@
+#################################################################################
+# NxWidgets/Unitests/nxwm/Makefile
+#
+# 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.
+#
+#################################################################################
+
+TESTDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# Add the path to the NXWidget include directory to the CFLAGS
+
+NXWIDGETS_DIR="$(TESTDIR)/../../libnxwidgets"
+NXWIDGETS_INC="$(NXWIDGETS_DIR)/include"
+NXWIDGETS_LIB="$(NXWIDGETS_DIR)/libnxwidgets$(LIBEXT)"
+
+INCDIR=$(TOPDIR)/tools/incdir.sh
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWIDGETS_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWIDGETS_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWIDGETS_INC)"}
+endif
+
+# Add the path to the NxWM include directory to the CFLAGS
+
+NXWM_DIR="$(TESTDIR)/../../nxwm"
+NXWM_INC="$(NXWM_DIR)/include"
+NXWM_LIB="$(NXWM_DIR)/libnxwm$(LIBEXT)"
+
+ifeq ($(WINTOOL),y)
+ CFLAGS += ${shell $(INCDIR) -w "$(CC)" "$(NXWM_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) -w "$(CXX)" "$(NXWM_INC)"}
+else
+ CFLAGS += ${shell $(INCDIR) "$(CC)" "$(NXWM_INC)"}
+ CXXFLAGS += ${shell $(INCDIR) "$(CXX)" "$(NXWM_INC)"}
+endif
+
+# Get the path to the archiver tool
+
+TESTTOOL_DIR="$(TESTDIR)/../../tools"
+ARCHIVER=$(TESTTOOL_DIR)/addobjs.sh
+
+# NxWM unit test
+
+ASRCS =
+CSRCS =
+CXXSRCS = nxwm_main.cxx
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+POSIX_BIN = "$(APPDIR)/libapps$(LIBEXT)"
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(POSIX_BIN)}"
+else
+ BIN = $(POSIX_BIN)
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# helloxx built-in application info
+
+APPNAME = nxwm
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend context disclean chkcxx chklibnxwidgets chklibnxwm
+
+# Object file creation targets
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+# Verify that the NuttX configuration is setup to support C++
+
+chkcxx:
+ifneq ($(CONFIG_HAVE_CXX),y)
+ @echo ""
+ @echo "In order to use this example, you toolchain must support must"
+ @echo ""
+ @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
+ @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
+ @echo " of the configuration that you are using."
+ @echo ""
+ @exit 1
+endif
+
+# Verify that the NXWidget library has been built
+
+chklibnxwidgets:
+ @( \
+ if [ ! -e "$(NXWIDGETS_LIB)" ]; then \
+ echo "$(NXWIDGETS_LIB) does not exist."; \
+ echo "Please go to $(NXWIDGETS_DIR)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Verify that the NxWM library has been built
+
+chklibnxwm:
+ @( \
+ if [ ! -e "$(NXWM_LIB)" ]; then \
+ echo "$(NXWM_LIB) does not exist."; \
+ echo "Please go to $(NXWM_LIB)"; \
+ echo "and rebuild the library"; \
+ exit 1; \
+ fi; \
+ )
+
+# Library creation targets
+
+$(NXWIDGETS_LIB): # Just to keep make happy. chklibnxwidgets does the work.
+
+$(NXWM_LIB): # Just to keep make happy. chklibnxwm does the work.
+
+.built: chkcxx chklibnxwidgets chklibnxwm $(OBJS) $(NXWIDGETS_LIB)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ifeq ($(WINTOOL),y)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+ @$(ARCHIVER) -w -p "$(CROSSDEV)" $(BIN) $(NXWM_DIR)
+else
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWIDGETS_DIR)
+ @$(ARCHIVER) -p "$(CROSSDEV)" $(BIN) $(NXWM_DIR)
+endif
+ @touch .built
+
+# Standard housekeeping targets
+
+.context:
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+endif
+ @touch $@
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CXX) -- $(CXXFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/NxWidgets/UnitTests/nxwm/nxwm_main.cxx b/NxWidgets/UnitTests/nxwm/nxwm_main.cxx
new file mode 100644
index 000000000..eefc44494
--- /dev/null
+++ b/NxWidgets/UnitTests/nxwm/nxwm_main.cxx
@@ -0,0 +1,734 @@
+/////////////////////////////////////////////////////////////////////////////
+// NxWidgets/UnitTests/nxwm/nxwm_main.cxx
+//
+// 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Included Files
+/////////////////////////////////////////////////////////////////////////////
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include <cstdio>
+#include <cstdlib>
+#include <cunistd>
+
+#include "ctaskbar.hxx"
+#include "cstartwindow.hxx"
+#include "cnxconsole.hxx"
+#include "chexcalculator.hxx"
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+# include "ctouchscreen.hxx"
+# include "ccalibration.hxx"
+#endif
+
+#ifdef CONFIG_NXWM_KEYBOARD
+# include "ckeyboard.hxx"
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Pre-processor Definitions
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_HAVE_FILENAME
+# define showTestStepMemory(msg) \
+ _showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+#endif
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+# ifdef CONFIG_HAVE_FILENAME
+# define showTestCaseMemory(msg) \
+ _showTestCaseMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+# define showTestMemory(msg) \
+ _showTestMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+# endif
+#else
+# define initMemoryUsage()
+# define showTestCaseMemory(msg)
+# define showTestMemory(msg)
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Types
+/////////////////////////////////////////////////////////////////////////////
+
+struct SNxWmTest
+{
+ NxWM::CTaskbar *taskbar; // The task bar
+ NxWM::CStartWindow *startwindow; // The start window
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+ NxWM::CTouchscreen *touchscreen; // The touchscreen
+ struct NxWM::SCalibrationData calibData; // Calibration data
+#endif
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+ unsigned int mmInitial; // Initial memory usage
+ unsigned int mmStep; // Memory Usage at beginning of test step
+ unsigned int mmSubStep; // Memory Usage at beginning of test sub-step
+#endif
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Private Data
+/////////////////////////////////////////////////////////////////////////////
+
+static struct SNxWmTest g_nxwmtest;
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Function Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+// Suppress name-mangling
+
+extern "C" int nxwm_main(int argc, char *argv[]);
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: updateMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+#ifdef CONFIG_HAVE_FILENAME
+static void updateMemoryUsage(unsigned int *previous,
+ FAR const char *file, int line,
+ FAR const char *msg)
+#else
+static void updateMemoryUsage(unsigned int *previous,
+ FAR const char *msg)
+#endif
+{
+ struct mallinfo mmcurrent;
+
+ /* Get the current memory usage */
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ /* Show the change from the previous time */
+
+#ifdef CONFIG_HAVE_FILENAME
+ printf("File: %s Line: %d : %s\n", file, line, msg);
+#else
+ printf("\n%s:\n", msg);
+#endif
+ printf(" Before: %8u After: %8u Change: %8d\n",
+ *previous, mmcurrent.uordblks, (int)mmcurrent.uordblks - (int)*previous);
+
+ /* Set up for the next test */
+
+ *previous = mmcurrent.uordblks;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showTestCaseMemory
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+#ifdef CONFIG_HAVE_FILENAME
+static void _showTestCaseMemory(FAR const char *file, int line, FAR const char *msg)
+{
+ updateMemoryUsage(&g_nxwmtest.mmStep, file, line, msg);
+ g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
+}
+#else
+static void showTestCaseMemory(FAR const char *msg)
+{
+ updateMemoryUsage(&g_nxwmtest.mmStep, msg);
+ g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
+}
+#endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showTestMemory
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+#ifdef CONFIG_HAVE_FILENAME
+static void _showTestMemory(FAR const char *file, int line, FAR const char *msg)
+{
+ updateMemoryUsage(&g_nxwmtest.mmInitial, file, line, msg);
+}
+#else
+static void showTestMemory(FAR const char *msg)
+{
+ updateMemoryUsage(&g_nxwmtest.mmInitial, msg);
+}
+#endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: initMemoryUsage
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+static void initMemoryUsage(void)
+{
+ struct mallinfo mmcurrent;
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mmcurrent = mallinfo();
+#else
+ (void)mallinfo(&mmcurrent);
+#endif
+
+ g_nxwmtest.mmInitial = mmcurrent.uordblks;
+ g_nxwmtest.mmStep = mmcurrent.uordblks;
+ g_nxwmtest.mmSubStep = mmcurrent.uordblks;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: cleanup
+/////////////////////////////////////////////////////////////////////////////
+
+static void testCleanUpAndExit(int exitCode)
+{
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+ if (g_nxwmtest.touchscreen)
+ {
+ delete g_nxwmtest.touchscreen;
+ }
+#endif
+
+ // Delete the task bar then the start window. the order is important because
+ // we must bet all of the application references out of the task bar before
+ // deleting the start window. When the start window is deleted, it will
+ // also delete of of the resouces contained within the start window.
+
+ if (g_nxwmtest.taskbar)
+ {
+ delete g_nxwmtest.taskbar;
+ }
+
+ if (g_nxwmtest.startwindow)
+ {
+ delete g_nxwmtest.startwindow;
+ }
+
+ // And exit
+
+ exit(exitCode);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createTaskbar
+/////////////////////////////////////////////////////////////////////////////
+
+static bool createTaskbar(void)
+{
+ // Create an instance of the Task Bar.
+ //
+ // The general sequence for initializing the task bar is:
+ //
+ // 1. Create the CTaskbar instance,
+ // 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ // inherits the connect method from CNxServer),
+ // 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ // 3. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ // 4. Call CTaskBar::startWindowManager to start the display with applications in place
+
+ printf("createTaskbar: Create CTaskbar instance\n");
+ g_nxwmtest.taskbar = new NxWM::CTaskbar();
+ if (!g_nxwmtest.taskbar)
+ {
+ printf("createTaskbar: ERROR: Failed to instantiate CTaskbar\n");
+ return false;
+ }
+ showTestCaseMemory("createTaskbar: After create taskbar");
+
+ // Connect to the NX server
+
+ printf("createTaskbar: Connect CTaskbar instance to the NX server\n");
+ if (!g_nxwmtest.taskbar->connect())
+ {
+ printf("createTaskbar: ERROR: Failed to connect CTaskbar instance to the NX server\n");
+ return false;
+ }
+ showTestCaseMemory("createTaskbar: After connecting to the server");
+
+ // Initialize the task bar
+ //
+ // Taskbar::initWindowManager() prepares the task bar to receive applications.
+ // CTaskBar::startWindowManager() brings the window manager up with those applications
+ // in place.
+
+ printf("createTaskbar: Initialize CTaskbar instance\n");
+ if (!g_nxwmtest.taskbar->initWindowManager())
+ {
+ printf("createTaskbar: ERROR: Failed to intialize CTaskbar instance\n");
+ return false;
+ }
+
+ showTestCaseMemory("createTaskbar: After initializing window manager");
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createStartWindow
+/////////////////////////////////////////////////////////////////////////////
+
+static bool createStartWindow(void)
+{
+ // Create the start window. The start window is unique among applications
+ // because it has no factory. The general sequence for setting up the
+ // start window is:
+ //
+ // 1. Create and open a CApplicationWindow
+ // 2. Use the window to create the CStartWindow the start window application
+ // 2. Call Cstartwindow::addApplication numerous times to install applications
+ // in the start window.
+ // 3. Call CTaskBar::startApplication (initially minimized) to start the start
+ // window application.
+ //
+ // NOTE: that the start window should not have a stop button.
+
+ NxWM::CApplicationWindow *window = g_nxwmtest.taskbar->openApplicationWindow(NxWM::CApplicationWindow::WINDOW_PERSISTENT);
+ if (!window)
+ {
+ printf("createStartWindow: ERROR: Failed to create CApplicationWindow\n");
+ return false;
+ }
+ showTestCaseMemory("createStartWindow: After creating CApplicationWindow");
+
+ // Open the window (it is hot in here)
+
+ if (!window->open())
+ {
+ printf("createStartWindow: ERROR: Failed to open CApplicationWindow \n");
+ delete window;
+ return false;
+ }
+ showTestCaseMemory("createStartWindow: After opening CApplicationWindow");
+
+ // Instantiate the application, providing the window to the application's
+ // constructor
+
+ g_nxwmtest.startwindow = new NxWM::CStartWindow(g_nxwmtest.taskbar, window);
+ if (!g_nxwmtest.startwindow)
+ {
+ gdbg("ERROR: Failed to instantiate CStartWindow\n");
+ delete window;
+ return false;
+ }
+ showTestCaseMemory("createStartWindow: After creating CStartWindow");
+
+ // Add the CStartWindow application to the task bar (minimized)
+
+ printf("createStartWindow: Start the start window application\n");
+ if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.startwindow, true))
+ {
+ printf("createStartWindow: ERROR: Failed to start the start window application\n");
+ return false;
+ }
+ showTestCaseMemory("createStartWindow: After starting the start window application");
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: startWindowManager
+/////////////////////////////////////////////////////////////////////////////
+
+static bool startWindowManager(void)
+{
+ // Start the window manager
+
+ printf("startWindowManager: Start the window manager\n");
+ if (!g_nxwmtest.taskbar->startWindowManager())
+ {
+ printf("startWindowManager: ERROR: Failed to start the window manager\n");
+ return false;
+ }
+
+ showTestCaseMemory("startWindowManager: After starting the window manager");
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createTouchScreen
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+static bool createTouchScreen(void)
+{
+ // Get the physical size of the display in pixels
+
+ struct nxgl_size_s displaySize;
+ (void)g_nxwmtest.taskbar->getDisplaySize(displaySize);
+
+ // Create the touchscreen device
+
+ printf("createTouchScreen: Creating CTouchscreen\n");
+ g_nxwmtest.touchscreen = new NxWM::CTouchscreen(g_nxwmtest.taskbar, &displaySize);
+ if (!g_nxwmtest.touchscreen)
+ {
+ printf("createTouchScreen: ERROR: Failed to create CTouchscreen\n");
+ return false;
+ }
+ showTestCaseMemory("createTouchScreen: After creating CTouchscreen");
+
+ printf("createTouchScreen: Start touchscreen listener\n");
+ if (!g_nxwmtest.touchscreen->start())
+ {
+ printf("createTouchScreen: ERROR: Failed start the touchscreen listener\n");
+ delete g_nxwmtest.touchscreen;
+ return false;
+ }
+
+ showTestCaseMemory("createTouchScreen: After starting the touchscreen listener");
+ return true;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createKeyboard
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWM_KEYBOARD
+static bool createKeyboard(void)
+{
+ printf("createKeyboard: Creating CKeyboard\n");
+ NxWM::CKeyboard *keyboard = new NxWM::CKeyboard(g_nxwmtest.taskbar);
+ if (!keyboard)
+ {
+ printf("createKeyboard: ERROR: Failed to create CKeyboard\n");
+ return false;
+ }
+ showTestCaseMemory("createKeyboard After creating CKeyboard");
+
+ printf("createKeyboard: Start keyboard listener\n");
+ if (!keyboard->start())
+ {
+ printf("createKeyboard: ERROR: Failed start the keyboard listener\n");
+ delete keyboard;
+ return false;
+ }
+
+ showTestCaseMemory("createKeyboard: After starting the keyboard listener");
+ return true;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createCalibration
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+static bool createCalibration(void)
+{
+ // 1Create the CCalibrationFactory application factory
+
+ printf("createCalibration: Creating CCalibrationFactory\n");
+ NxWM::CCalibrationFactory *factory = new NxWM::CCalibrationFactory(g_nxwmtest.taskbar, g_nxwmtest.touchscreen);
+ if (!factory)
+ {
+ printf("createCalibration: ERROR: Failed to create CCalibrationFactory\n");
+ return false;
+ }
+ showTestCaseMemory("createCalibration: After creating CCalibrationFactory");
+
+ // Add the calibration application to the start window.
+
+ printf("createCalibration: Adding CCalibration to the start window\n");
+ if (!g_nxwmtest.startwindow->addApplication(factory))
+ {
+ printf("createCalibration: ERROR: Failed to add CCalibrationto the start window\n");
+ delete factory;
+ return false;
+ }
+ showTestCaseMemory("createCalibration: After adding CCalibration");
+
+ // Call StartWindowFactory::create to to create the start window application
+
+ printf("createCalibration: Creating CCalibration\n");
+ NxWM::IApplication *calibration = factory->create();
+ if (!calibration)
+ {
+ printf("createCalibration: ERROR: Failed to create CCalibration\n");
+ return false;
+ }
+ showTestCaseMemory("createCalibration: After creating CCalibration");
+
+ // Call CTaskBar::startApplication to start the Calibration application. Nothing
+ // will be displayed because the window manager has not yet been started.
+
+ printf("createCalibration: Start the calibration application\n");
+ if (!g_nxwmtest.taskbar->startApplication(calibration, false))
+ {
+ printf("createCalibration ERROR: Failed to start the calibration application\n");
+ delete calibration;
+ return false;
+ }
+ showTestCaseMemory("createCalibration: After starting the start window application");
+ return true;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createNxConsole
+/////////////////////////////////////////////////////////////////////////////
+
+static bool createNxConsole(void)
+{
+ // Add the NxConsole application to the start window
+
+ printf("createNxConsole: Creating the NxConsole application\n");
+ NxWM::CNxConsoleFactory *console = new NxWM::CNxConsoleFactory(g_nxwmtest.taskbar);
+ if (!console)
+ {
+ printf("createNxConsole: ERROR: Failed to instantiate CNxConsoleFactory\n");
+ return false;
+ }
+ showTestCaseMemory("createNxConsole: After creating the NxConsole application");
+
+ printf("createNxConsole: Adding the NxConsole application to the start window\n");
+ if (!g_nxwmtest.startwindow->addApplication(console))
+ {
+ printf("createNxConsole: ERROR: Failed to add CNxConsoleFactory to the start window\n");
+ delete console;
+ return false;
+ }
+
+ showTestCaseMemory("createNxConsole: After adding the NxConsole application");
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: createHexCalculator
+/////////////////////////////////////////////////////////////////////////////
+
+static bool createHexCalculator(void)
+{
+ // Add the hex calculator application to the start window
+
+ printf("createHexCalculator: Creating the hex calculator application\n");
+ NxWM::CHexCalculatorFactory *calculator = new NxWM::CHexCalculatorFactory(g_nxwmtest.taskbar);
+ if (!calculator)
+ {
+ printf("createHexCalculator: ERROR: Failed to instantiate CHexCalculatorFactory\n");
+ return false;
+ }
+ showTestCaseMemory("createHexCalculator: After creating the hex calculator application");
+
+ printf("createHexCalculator: Adding the hex calculator application to the start window\n");
+ if (!g_nxwmtest.startwindow->addApplication(calculator))
+ {
+ printf("createHexCalculator: ERROR: Failed to add CNxConsoleFactory to the start window\n");
+ delete calculator;
+ return false;
+ }
+
+ showTestCaseMemory("createHexCalculator: After adding the hex calculator application");
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Public Functions
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Name: showTestStepMemory
+/////////////////////////////////////////////////////////////////////////////
+// Called by ad hoc instrumentation in the NxWM/NxWidgets code
+
+#ifdef CONFIG_HAVE_FILENAME
+void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg)
+{
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+ updateMemoryUsage(&g_nxwmtest.mmSubStep, file, line, msg);
+#endif
+}
+#else
+void showTestStepMemory(FAR const char *msg)
+{
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+ updateMemoryUsage(&g_nxwmtest.mmSubStep, msg);
+#endif
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// user_start/nxwm_main
+/////////////////////////////////////////////////////////////////////////////
+
+int nxwm_main(int argc, char *argv[])
+{
+ // Call all C++ static constructors
+
+#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
+ up_cxxinitialize();
+#endif
+
+ // Initialize memory monitor logic
+
+ initMemoryUsage();
+
+ // Initialize the NSH library
+
+ printf("nxwm_main: Initialize the NSH library\n");
+ if (!NxWM::nshlibInitialize())
+ {
+ printf("nxwm_main: ERROR: Failed to initialize the NSH library\n");
+ return EXIT_FAILURE;
+ }
+ showTestCaseMemory("nxwm_main: After initializing the NSH library");
+
+ // Create the task bar.
+
+ if (!createTaskbar())
+ {
+ printf("nxwm_main: ERROR: Failed to create the task bar\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+
+ // Create the start window.
+
+ if (!createStartWindow())
+ {
+ printf("nxwm_main: ERROR: Failed to create the start window\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+
+ // Create the keyboard device
+
+#ifdef CONFIG_NXWM_KEYBOARD
+ if (!createKeyboard())
+ {
+ printf("nxwm_main: ERROR: Failed to create the keyboard\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+#endif
+
+ // Create the touchscreen device
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+ if (!createTouchScreen())
+ {
+ printf("nxwm_main ERROR: Failed to create the touchscreen\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+#endif
+
+ // Create the calibration application and add it to the start window
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+ if (!createCalibration())
+ {
+ printf("nxwm_main ERROR: Failed to create the calibration application\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+#endif
+
+ // Create the NxConsole application and add it to the start window
+
+ if (!createNxConsole())
+ {
+ printf("nxwm_main: ERROR: Failed to create the NxConsole application\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+
+ // Create the hex calculator application and add it to the start window
+
+ if (!createHexCalculator())
+ {
+ printf("nxwm_main: ERROR: Failed to create the hex calculator application\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+
+ // Call CTaskBar::startWindowManager to start the display with applications in place.
+
+ if (!startWindowManager())
+ {
+ printf("nxwm_main: ERROR: Failed to start the window manager\n");
+ testCleanUpAndExit(EXIT_FAILURE);
+ }
+
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+ // Since we started the touchscreen calibration program maximized, it will run
+ // immediately when we start the window manager. There is no positive handshake
+ // to know whenthe touchscreen has been calibrated. If we really want to know,
+ // we have to poll
+
+ printf("nxwm_main: Waiting for touchscreen calibration\n");
+ while (!g_nxwmtest.touchscreen->isCalibrated())
+ {
+ std::sleep(2);
+ }
+
+ // This is how we would then recover the calibration data. After the calibration
+ // application creates the calibration data, it hands it to the touchscreen driver
+ // After the touchscreen driver gets it, it will report isCalibrated() == true
+ // and then we can read the calibration data from the touchscreen driver.
+
+ printf("nxwm_main: Getting calibration data from the touchscreen\n");
+ if (!g_nxwmtest.touchscreen->getCalibrationData(g_nxwmtest.calibData))
+ {
+ printf("nxwm_main: ERROR: Failed to get calibration data from the touchscreen\n");
+ }
+#endif
+
+ // Wait a little bit for the display to stabilize. Then simulate pressing of
+ // the 'start window' icon in the task bar
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN
+ sleep(2);
+ g_nxwmtest.taskbar->clickIcon(0, true);
+ usleep(500*1000);
+ g_nxwmtest.taskbar->clickIcon(0, false);
+ showTestCaseMemory("nxwm_main: After clicking the start window icon");
+
+ // Wait bit to see the result of the button press. Then press the first icon
+ // in the start menu. That should be the NxConsole icon.
+
+ sleep(2);
+ g_nxwmtest.startwindow->clickIcon(0, true);
+ usleep(500*1000);
+ g_nxwmtest.startwindow->clickIcon(0, false);
+ showTestCaseMemory("nxwm_main: After clicking the NxConsole icon");
+#endif
+
+ // Wait bit to see the result of the button press.
+
+ sleep(2);
+ showTestMemory("nxwm_main: Final memory usage");
+ return EXIT_SUCCESS;
+}
+
diff --git a/NxWidgets/libnxwidgets/COPYING b/NxWidgets/libnxwidgets/COPYING
new file mode 100644
index 000000000..f12e7b82e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/COPYING
@@ -0,0 +1,70 @@
+/********************************************************************************
+ * NxWidgets
+ * Graphical Widgets for the NuttX RTOS
+ *
+ * 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 nor the names of its contributors may 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.
+ *
+ *******************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in almost all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ********************************************************************************/
+
diff --git a/NxWidgets/libnxwidgets/Makefile b/NxWidgets/libnxwidgets/Makefile
new file mode 100644
index 000000000..2520e419d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/Makefile
@@ -0,0 +1,138 @@
+#################################################################################
+# NxWidgets/libnxwidgets/Makefile
+#
+# 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.
+#
+#################################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+
+NXWIDGETDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+
+ASRCS =
+CSRCS =
+# Infrastructure
+CXXSRCS = cbitmap.cxx cbgwindow.cxx ccallback.cxx cgraphicsport.cxx
+CXXSRCS += clistdata.cxx clistdataitem.cxx cnxfont.cxx
+CXXSRCS += cnxserver.cxx cnxstring.cxx cnxtimer.cxx cnxwidget.cxx cnxwindow.cxx
+CXXSRCS += cnxtkwindow.cxx cnxtoolbar.cxx crect.cxx crlepalettebitmap.cxx
+CXXSRCS += cstringiterator.cxx ctext.cxx cwidgetcontrol.cxx cwidgeteventhandlerlist.cxx
+CXXSRCS += cwindoweventhandlerlist.cxx singletons.cxx
+# Widget APIs
+CXXSRCS += cbutton.cxx cbuttonarray.cxx ccheckbox.cxx ccyclebutton.cxx
+CXXSRCS += cglyphbutton.cxx cimage.cxx ckeypad.cxx clabel.cxx clatchbutton.cxx
+CXXSRCS += clatchbuttonarray.cxx clistbox.cxx clistboxdataitem.cxx cmultilinetextbox.cxx
+CXXSRCS += cprogressbar.cxx cradiobutton.cxx cradiobuttongroup.cxx cscrollbarhorizontal.cxx
+CXXSRCS += cscrollbarpanel.cxx cscrollbarvertical.cxx cscrollinglistbox.cxx
+CXXSRCS += cscrollingpanel.cxx cscrollingtextbox.cxx csliderhorizontal.cxx
+CXXSRCS += csliderhorizontalgrip.cxx cslidervertical.cxx csliderverticalgrip.cxx
+CXXSRCS += cstickybutton.cxx cstickybuttonarray.cxx ctextbox.cxx
+# Images
+CXXSRCS += glyph_nxlogo.cxx
+CXXSRCS += glyph_arrowdown.cxx glyph_checkboxon.cxx glyph_screendepthup.cxx
+CXXSRCS += glyph_arrowleft.cxx glyph_control.cxx glyph_screenflipdown.cxx
+CXXSRCS += glyph_arrowright.cxx glyph_cycle.cxx glyph_screenflipup.cxx
+CXXSRCS += glyph_arrowup.cxx glyph_radiobuttonoff.cxx glyph_shift.cxx
+CXXSRCS += glyph_backspace.cxx glyph_radiobuttonmu.cxx glyph_windowclose.cxx
+CXXSRCS += glyph_capslock.cxx glyph_radiobuttonon.cxx glyph_windowdepthdown.cxx
+CXXSRCS += glyph_checkboxmu.cxx glyph_return.cxx glyph_windowdepthup.cxx
+CXXSRCS += glyph_checkboxoff.cxx glyph_screendepthdown.cxx
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+BIN = libnxwidgets$(LIBEXT)
+
+ifeq ($(WINTOOL),y)
+INCDIROPT = -w
+endif
+
+CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWIDGETDIR)/include}
+CXXFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWIDGETDIR)/include}
+DEPPATH = --dep-path src
+VPATH = src
+
+all: $(BIN)
+.PHONY = check_nuttx depend clean distclean export
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+check_nuttx:
+ @( \
+ if [ -z "$(TOPDIR)" ]; then \
+ echo "The path to the nuttx directory must be provided on the command line."; \
+ echo "Usage: make -C $(NXWIDGETDIR) TOPDIR=\"<nuttx directory>\""; \
+ exit 1; \
+ fi; \
+ if [ ! -d "$(TOPDIR)" ]; then \
+ echo "The nuttx directory (TOPDIR) does not exist: $(TOPDIR)"; \
+ exit 1; \
+ fi; \
+ if [ ! -f "$(TOPDIR)/.config" ]; then \
+ echo "The nuttx directory (TOPDIR) has not been configured"; \
+ echo "Please configure NuttX and try again"; \
+ exit 1; \
+ fi; \
+ )
+
+$(BIN): check_nuttx $(OBJS)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $@, $${obj}); \
+ done ; )
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f $(BIN) *.a *.o *~ .*.sw*
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+export: $(BIN)
+ zip -r nxwidgets-export.zip include $(BIN) COPYING
+
+-include Make.dep
diff --git a/NxWidgets/libnxwidgets/doc/mainpage.h b/NxWidgets/libnxwidgets/doc/mainpage.h
new file mode 100644
index 000000000..ccd399e6a
--- /dev/null
+++ b/NxWidgets/libnxwidgets/doc/mainpage.h
@@ -0,0 +1,83 @@
+/*! \mainpage NXWidgets Documentation
+ *
+ * In order to better support NuttX based platforms, a special graphical user
+ * interface has been created called NXWidgets. NXWidgets is written in C++
+ * and integrates seamlessly with the NuttX NX graphics subystem in order to
+ * provide graphic objects, or "widgets", in the <a title="NX Graphics
+ * Subsystem" href="http://nuttx.sourceforge.net/NXGraphicsSubsystem.html">
+ * NX Graphics Subsystem</a>.
+ *
+ * \section feature Features
+ *
+ * \subsection conservative_cxx Conservative C++
+ *
+ * Written entirely in C++ but using only selected "embedded
+ * friendly" C++ constructs that are fully supported under NuttX. No
+ * additional C++ support libraries are required.
+ *
+ * \subsection nx_integration NX Integration
+ *
+ * Integrates seamlessly with the NX graphics subsytem. Think of the X
+ * server under Linux... the NX graphics subsystem is like a tiny X server
+ * that provides windowing under NuttX. By adding NXWidgets, you can
+ * support graphic objects like buttons and text boxes in the NX windows
+ * and toolbars.
+ *
+ * \subsection small_footprint Small Footprint
+ *
+ * Tailored for use MCUs in embedded applications. It is ideally suited for
+ * mid- and upper-range of most MCU families. A complete NXWidgets is
+ * possible in as little as 40Kb of FLASH and maybe 4Kb of SRAM.
+ *
+ * \subsection output_devices Output Devices
+ *
+ * NXWidgets will work on the high-end fram buffer devices as well as on
+ * LCDs connected via serial or parallel port to a small MCU.
+ *
+ * \subsection input_devices Input Devices
+ *
+ * NXWidgets will accept position and selection inputs from a mouse or a
+ * touchscreen. It will also support character input from a keyboard such
+ * as a USB keyboard. NXWidgets supports a very special widget called
+ * CKeypad that will provide keyboard input via on-screen keypad that can
+ * be operated via mouse or touchscreen inputs.
+ *
+ * \subsection many_graphic_objects Many Graphic Objects\
+ *
+ * Some of the graphic objects supported by NXWidgets include labels,
+ * buttons, text boxes, button arrays, check boxes, cycle buttons, images,
+ * sliders, scrollable list boxes, progress bars, and more.
+ *
+ * \subsection NXWM\
+ *
+ * NxWM isthe tiny window manager based on NX and NxWidgets. NxWM is a true
+ * multiple window manager but only one window is displayed at a time. This
+ * simplification helps performance on LCD based products (in the same way
+ * that a tiled window manager helps) and also makes the best use of small
+ * displays. It is awkward from a human factors point-of-view trying to
+ * manage multiple windows on a small display.
+ *
+ * The window manager consists of a task bar with icons representing the
+ * running tasks. If you touch the task's icon, it comes to the top. Each
+ * window has a toolbar with (1) a title, (2) a minimize button, and (3) a
+ * stop application button using the standard icons for these things. User
+ * input via a touchscreen or mouse and keyboard is supported.
+ *
+ * There is always a start window that is available in the task bar. When
+ * you touch the start window icon, it brings up the start window containing
+ * icons representing all of the available applications. If you touch an
+ * icon in the start window, it will be started and added to the task bar.
+ *
+ * There is a base class that defines an add-on application and an interface
+ * that supports incorporation of new applications. The only application
+ * that is provided is NxConsole. This is an NSH session running in a window.
+ * You should be able to select the NX icon in the start menu and create as
+ * many NSH sessions in windows as you want. (keybard input still comes
+ * through serial).
+ *
+ * Note 1: NwWM requires NuttX-6.18 or above.
+ *
+ * Note 2: Many of the fundamental classes in NxWidgets derive from the Antony
+ * Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
+ * license. See the COPYING file for details.
+ */
diff --git a/NxWidgets/libnxwidgets/include/cbgwindow.hxx b/NxWidgets/libnxwidgets/include/cbgwindow.hxx
new file mode 100644
index 000000000..21b75799d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cbgwindow.hxx
@@ -0,0 +1,344 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbgwindow.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_CBGWINDOW_HXX
+#define __INCLUDE_CBGWINDOW_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "ccallback.hxx"
+#include "inxwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class INxWindow;
+ struct SBitmap;
+
+ /**
+ * This class defines operations on a the NX background window.
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class CBgWindow : protected CCallback, public INxWindow
+ {
+ private:
+ NXHANDLE m_hNxServer; /**< Handle to the NX server. */
+ NXWINDOW m_hWindow; /**< Handle to the NX background window */
+ CWidgetControl *m_widgetControl; /**< The controlling widget for the window */
+
+ public:
+
+ /**
+ * Constructor. Obtains the background window from server and wraps
+ * the window as CBgWindow. Creates an uninitialized instance of the
+ * CBgWindow object. The open() method must be called to initialize
+ * the instance.
+ *
+ * The general steps to create any window include:
+ * 1) Create a dumb CWigetControl instance
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow.
+ * 3) The window constructor call CWidgetControl methods to "smarten"
+ * the CWidgetControl instance with window-specific knowledge.
+ * 4) Call the open() method on the window to display the window.
+ * 5) After that, the fully smartend CWidgetControl instance can
+ * be used to generate additional widgets.
+ * 6) After that, the fully smartened CWidgetControl instance can
+ * be used to generate additional widgets by passing it to the
+ * widget constructor
+ *
+ * @param hNxServer Handle to the NX server.
+ * @param widgetControl Controlling widget for this window.
+ */
+
+ CBgWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl);
+
+ /**
+ * Destructor. Returns the background window to the server.
+ */
+
+ virtual ~CBgWindow(void);
+
+ /**
+ * Creates a the new window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully created.
+ */
+
+ bool open(void);
+
+ /**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+ CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool requestPosition(void);
+
+ /**
+ * Get the position of the window (as reported by the NX callback). NOTE:
+ * The background window is always positioned at {0,0}
+ *
+ * @return The position.
+ */
+
+ bool getPosition(FAR struct nxgl_point_s *pPos);
+
+ /**
+ * Get the size of the window (as reported by the NX callback). NOTE:
+ * The size of the background window is always the entire display.
+ *
+ * @return The size.
+ */
+
+ bool getSize(FAR struct nxgl_size_s *pSize);
+
+ /**
+ * Set the position and size of the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setPosition(FAR const struct nxgl_point_s *pPos);
+
+ /**
+ * Set the size of the selected window. NOTE: The size of the
+ * background window is always the entire display and cannot be
+ * changed.
+ *
+ * @param pSize The new size of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setSize(FAR const struct nxgl_size_s *pSize);
+
+ /**
+ * Bring the window to the top of the display. NOTE: The background
+ * window cannot be raised.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool raise(void);
+
+ /**
+ * Lower the window to the bottom of the display. NOTE: The background
+ * window is always at the bottom of the window hierarchy.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool lower(void);
+
+ /**
+ * Each window implementation also inherits from CCallback. CCallback,
+ * by default, forwards NX keyboard input to the various widgets residing
+ * in the window. But NxConsole is a different usage model; In this case,
+ * keyboard input needs to be directed to the NxConsole character driver.
+ * This method can be used to enable (or disable) redirection of NX
+ * keyboard input from the window widgets to the NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ inline void redirectNxConsole(NXCONSOLE handle)
+ {
+ setNxConsole(handle);
+ }
+#endif
+
+ /**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+ void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
+
+ /**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset);
+
+ /**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CBGWINDOW_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cbitmap.hxx b/NxWidgets/libnxwidgets/include/cbitmap.hxx
new file mode 100644
index 000000000..4828ca9cc
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cbitmap.hxx
@@ -0,0 +1,213 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbitmap.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CBITMAP_HXX
+#define __INCLUDE_CBITMAP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "ibitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Bitmap Structure
+ */
+
+ struct SBitmap
+ {
+ uint8_t bpp; /**< Bits per pixel */
+ uint8_t fmt; /**< Color format */
+ nxgl_coord_t width; /**< Width in pixels */
+ nxgl_coord_t height; /**< Height in rows */
+ uint16_t stride; /**< Width in bytes */
+ FAR const void *data; /**< Pointer to the beginning of pixel data */
+ };
+
+ /**
+ * Class providing bitmap accessor for a bitmap represented by SBitmap.
+ */
+
+ class CBitmap : public IBitmap
+ {
+ protected:
+ const struct SBitmap *m_bitmap; /**< The bitmap that is being managed */
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CBitmap(const CBitmap &bitmap) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param bitmap The bitmap structure being wrapped.
+ */
+
+ CBitmap(const struct SBitmap *bitmap);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CBitmap(void) {}
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's width.
+ */
+
+ const uint8_t getColorFormat(void) const;
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's color format.
+ */
+
+ const uint8_t getBitsPerPixel(void) const;
+
+ /**
+ * Get the bitmap's width (in pixels/columns).
+ *
+ * @return The bitmap's pixel depth.
+ */
+
+ const nxgl_coord_t getWidth(void) const;
+
+ /**
+ * Get the bitmap's height (in rows).
+ *
+ * @return The bitmap's height.
+ */
+
+ const nxgl_coord_t getHeight(void) const;
+
+ /**
+ * Get the bitmap's width (in bytes).
+ *
+ * @return The bitmap's width.
+ */
+
+ const nxgl_coord_t getStride(void) const;
+
+ /**
+ * Use the colors associated with a selected image.
+ *
+ * @param selected. true: Use colors for a selected widget,
+ * false: Use normal (default) colors.
+ */
+
+ inline void setSelected(bool selected) {}
+
+ /**
+ * Get one row from the bit map image.
+ *
+ * @param x The offset into the row to get
+ * @param y The row number to get
+ * @param width The number of pixels to get from the row
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @param True if the run was returned successfully.
+ */
+
+ bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ FAR void *data);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CBITMAP_HXX
diff --git a/NxWidgets/libnxwidgets/include/cbutton.hxx b/NxWidgets/libnxwidgets/include/cbutton.hxx
new file mode 100644
index 000000000..45481387f
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cbutton.hxx
@@ -0,0 +1,244 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CBUTTON_HXX
+#define __INCLUDE_CBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "clabel.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+
+ /**
+ * Clickable button widget. Displays text within the button.
+ */
+
+ class CButton : public CLabel
+ {
+ protected:
+
+ /**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+ virtual void drawOutline(CGraphicsPort *port);
+
+ /**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ * @param useClicked Present outline using the 'clicked' style
+ */
+
+ void drawOutline(CGraphicsPort *port, bool useClicked);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param useClicked Present contents using the 'clicked' style
+ * @see redraw()
+ */
+
+ void drawContents(CGraphicsPort *port, bool useClicked);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param useClicked Present border using the 'clicked' style
+ * @see redraw()
+ */
+
+ void drawBorder(CGraphicsPort *port, bool useClicked);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CButton(const CButton &button) : CLabel(button) { }
+
+ public:
+
+ /**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CButton(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * CButton Destructor.
+ */
+
+ virtual inline ~CButton() { }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/cbuttonarray.hxx b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx
new file mode 100644
index 000000000..435fa1080
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx
@@ -0,0 +1,326 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbuttonarray.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_CBUTTONARRAY_HXX
+#define __INCLUDE_CBUTTONARRAY_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "clabel.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CNxString;
+
+ /**
+ * Manages a two-dimensional array of buttons as one widget. A two-
+ * dimensional array of buttons might also be called a "keyboard".
+ */
+
+ class CButtonArray : public CNxWidget
+ {
+ protected:
+ uint8_t m_buttonColumns; /**< The number of columns in one row */
+ uint8_t m_buttonRows; /**< The number buttons in one column */
+ bool m_redrawButton; /**< True: Redraw button; False: redraw all */
+ bool m_cursorOn; /**< Cursor on; highlighted button displayed */
+ bool m_cursorChange; /**< True: Redraw cursor button only */
+ nxgl_coord_t m_buttonWidth; /**< The width of one button in pixels */
+ nxgl_coord_t m_buttonHeight; /**< The height of one button in rows */
+ nxgl_coord_t m_clickX; /**< The X position of the last clicked button */
+ nxgl_coord_t m_clickY; /**< The Y position of the last clicked button */
+ uint8_t m_cursorColumn; /**< The column index of the highlighted button */
+ uint8_t m_cursorRow; /**< The row index of the highlighted button */
+ CNxString *m_buttonText; /**< Text for each button */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Redraw only one button
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param column The button column index
+ * @param row The button row index
+ * @param useClicked Draw the button using the 'clicked' button style,
+ * regardless of the actual button state.
+ * @see onClick() and onRelease()
+ */
+
+ virtual void drawButton(CGraphicsPort *port, int column, int row, bool useClicked);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Convert an X/Y position to a button column/row index
+ *
+ * @param x The x position
+ * @param y The y position
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return false is the position is invalid
+ */
+
+ virtual bool posToButton(nxgl_coord_t x, nxgl_coord_t y, int &column, int &row);
+
+ /**
+ * Updates the GUI after the text has changed.
+ */
+
+ virtual void onTextChange(void);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CButtonArray(const CButtonArray &button) : CNxWidget(button) { }
+
+ public:
+
+ /**
+ * Constructor for an array of buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * CButtonArray Destructor.
+ */
+
+ ~CButtonArray(void);
+
+ /**
+ * Returns the string shown in the label.
+ *
+ * @param column The column index of the button of interest
+ * @param row The row index of the button of interest
+ * @return The label's text.
+ */
+
+ virtual const CNxString &getText(int column, int row) const;
+
+ /**
+ * Set the text displayed in the label.
+ *
+ * @param column The column index of the button to set
+ * @param row The row index of the button to set
+ * @param text String to display.
+ */
+
+ virtual void setText(int column, int row, const CNxString &text);
+
+ /**
+ * Return the position of the last clicked button (0,0 will be returned
+ * the no button has every been clicked). The button at this position
+ * is currently clicked then, in addition, return true.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if any button in the array is clicked
+ */
+
+ virtual bool isButtonClicked(int &column, int &row) const;
+
+ /**
+ * Check if this specific button in the array is clicked
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is clicked
+ */
+
+ virtual bool isThisButtonClicked(int column, int row) const;
+
+ /**
+ * Control the cursor state.
+ *
+ * @param cursorOn True(1), the current cursor position will be highlighted
+ */
+
+ virtual void cursor(bool cursorOn);
+
+ /**
+ * Return the current cursor position (button indices) and an indication
+ * if the button at the cursor is currently hightlighted.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if the cursor is enabled and the button is highlighted
+ */
+
+ virtual bool getCursorPosition(int &column, int &row) const;
+
+ /**
+ * Set the cursor position (button indices). Note that the cursor
+ * does not have to be enabled to set the position.
+ *
+ * @param column The column index of the button of interest
+ * @param row The row index of the button of interest
+ * @return True if the cursor position is valid
+ */
+
+ virtual bool setCursorPosition(int column, int row);
+
+ /**
+ * Check if this specific button in the array is at the cursor position
+ * and highlighted.
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is at the cursor postion and highlighted.
+ */
+
+ virtual bool isCursorPosition(int column, int row) const;
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+ virtual void setFont(CNxFont *font);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CBUTTONARRAY_HXX
diff --git a/NxWidgets/libnxwidgets/include/ccallback.hxx b/NxWidgets/libnxwidgets/include/ccallback.hxx
new file mode 100644
index 000000000..714ed1a7f
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ccallback.hxx
@@ -0,0 +1,272 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ccallback.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_CCALLBACK_HXX
+#define __INCLUDE_CCALLBACK_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
+
+#include "crect.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * Callback function proxies. This class receives and dispatches callbacks
+ * from the NX server. This calls also manages a few lower-level details
+ * such as keeping track of the reported window handles and window positions
+ * and sizes.
+ *
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+
+ */
+
+ class CCallback
+ {
+ private:
+ CWidgetControl *m_widgetControl; /**< The widget control instance for this window */
+ struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ NXCONSOLE m_nxconsole; /**< The NxConsole handle for redirection of keyboard input */
+#endif
+
+ // Methods in the callback vtable
+
+ /**
+ * Re-Draw Callback. The redraw event is handled by CWidgetControl::redrawEvent.
+ *
+ * NOTE: This method runs in the context of the NX callback which may
+ * either be the context of the owning thread or, in the case of multi-
+ * user NX, the context of the NX event listener thread.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param rect The rectangle that needs to be re-drawn (in window
+ * relative coordinates).
+ * @param bMore true: More re-draw requests will follow.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+ static void redraw(NXHANDLE hwnd, FAR const struct nxgl_rect_s *rect,
+ bool bMore, FAR void *arg);
+
+ /**
+ * Position Callback. The new positional data is handled by
+ * CWidgetControl::geometryEvent.
+ *
+ * NOTE: This method runs in the context of the NX callback which may
+ * either be the context of the owning thread or, in the case of multi-
+ * user NX, the context of the NX event listener thread.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param size The size of the window.
+ * @param pos The position of the upper left hand corner of the window on
+ * the overall display.
+ * @param bounds The bounding rectangle that describes the entire display.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+ static void position(NXHANDLE hwnd, FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg);
+
+ /**
+ * New mouse data is available for the window. The new mouse
+ * data is handled by CWidgetControl::newMouseEvent.
+ *
+ * NOTE: This method runs in the context of the NX callback which may
+ * either be the context of the NX event listener thread (if multi-
+ * user NX), or possibly in the connects of device driver or even a
+ * device driver interrupt.
+ *
+ * The GUI thread is probably sleeping a semaphore, waiting to be
+ * awakened by a mouse or keyboard event.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param pos The (x,y) position of the mouse.
+ * @param buttons See NX_MOUSE_* definitions.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+#ifdef CONFIG_NX_MOUSE
+ static void newMouseEvent(NXHANDLE hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg);
+#endif /* CONFIG_NX_MOUSE */
+
+ /**
+ * New keyboard/keypad data is available for the window. The new
+ * keyboard data is handled by CWidgetControl::newKeyboardEvent.
+ *
+ * NOTE: This method runs in the context of the NX callback which may
+ * either be the context of the NX event listener thread (if multi-
+ * user NX), or possibly in the connects of device driver or even a
+ * device driver interrupt.
+ *
+ * The GUI thread is probably sleeping a semaphore, waiting to be
+ * awakened by a mouse or keyboard event.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param nCh The number of characters that are available in str[].
+ * @param str The array of characters.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+#ifdef CONFIG_NX_KBD
+ static void newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
+ FAR const uint8_t *str, FAR void *arg);
+#endif // CONFIG_NX_KBD
+
+ /**
+ * This callback is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param hwnd. Window handle of the blocked window
+ * @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ * @param arg2 - User provided argument (see nx_block or nxtk_block)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ static void windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2);
+#endif
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param widgetControl Control object associated with this window
+ */
+
+ CCallback(CWidgetControl *widgetControl);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CCallback(void) {}
+
+ /**
+ * Get the callback vtable. This is neeed only by the window
+ * instance that inherits this class. The window instance needs the
+ * C-callable vtable in order to create the NX window. Once the
+ * window is created, this class will begin to receive callbacks via
+ * the C-callable vtable methods.
+ *
+ * @return This method returns the C-callable vtable needed for
+ * NX window creation.
+ */
+
+ inline FAR struct nx_callback_s *getCallbackVTable(void)
+ {
+ return &m_callbacks;
+ }
+
+ /**
+ * By default, NX keyboard input is given to the various widgets
+ * residing in the window. But NxConsole is a different usage model;
+ * In this case, keyboard input needs to be directed to the NxConsole
+ * character driver. This method can be used to enable (or disable)
+ * redirection of NX keyboard input from the window widgets to the
+ * NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ inline void setNxConsole(NXCONSOLE handle)
+ {
+ m_nxconsole = handle;
+ }
+#endif
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CCALLBACK_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/ccheckbox.hxx b/NxWidgets/libnxwidgets/include/ccheckbox.hxx
new file mode 100644
index 000000000..109e7839e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ccheckbox.hxx
@@ -0,0 +1,210 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ccheckbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CCHECKBOX_HXX
+#define __INCLUDE_CCHECKBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbutton.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * Class representing a checkbox. Like radio buttons, checkboxes
+ * are tri-state - off, on and "mu". The mu state cannot be enabled by
+ * a user - it can only be set by the developer.
+ */
+
+ class CCheckBox : public CButton
+ {
+ public:
+
+ /**
+ * Enum listing all possible checkbox states.
+ */
+
+ enum CheckBoxState
+ {
+ CHECK_BOX_STATE_OFF = 0, /**< Checkbox is unticked */
+ CHECK_BOX_STATE_ON = 1, /**< Checkbox is ticked */
+ CHECK_BOX_STATE_MU = 2 /**< Checkbox is in the third state */
+ };
+
+ protected:
+ CheckBoxState m_state; /**< The state of the checkbox */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Toggles the state of the checkbox.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CCheckBox(const CCheckBox &checkBox) : CButton(checkBox) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the checkbox, relative to its parent.
+ * @param y The y coordinate of the checkbox, relative to its parent.
+ * @param width The width of the checkbox.
+ * @param height The height of the checkbox.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CCheckBox(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CCheckBox(void) { }
+
+ /**
+ * Get the current state of the checkbox.
+ *
+ * @return The state of the checkbox.
+ */
+
+ virtual inline const CheckBoxState getState(void) const
+ {
+ return m_state;
+ }
+
+ /**
+ * Set the state of the checkbox.
+ *
+ * @param state The new checkbox state.
+ */
+
+ virtual void setState(CheckBoxState state);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CCHECKBOX_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/ccyclebutton.hxx b/NxWidgets/libnxwidgets/include/ccyclebutton.hxx
new file mode 100644
index 000000000..5fd9405d8
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ccyclebutton.hxx
@@ -0,0 +1,356 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ccyclebutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CCYLEBUTTON_HXX
+#define __INCLUDE_CCYLEBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbutton.hxx"
+#include "ilistdataeventhandler.hxx"
+#include "clistdata.hxx"
+#include "clistdataitem.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+
+ /**
+ * Cycle button widget. Displays text within the button. Clicking it cycles
+ * through its available options.
+ */
+
+ class CCycleButton : public CButton, public IListDataEventHandler
+ {
+ protected:
+
+ CListData m_options; /**< Option storage. */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+ virtual void drawOutline(CGraphicsPort *port);
+
+ /**
+ * Selects the next option in the list and redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Prevents the CButton onResize() method from recalculating the text
+ * positions by overriding it.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual inline void onResize(nxgl_coord_t width, nxgl_coord_t height) { }
+
+ /**
+ * Override method in Label class to prevent recalculation of text positions.
+ */
+
+ virtual inline void calculateTextPosition(void) { }
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CCycleButton(void) { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CCycleButton(const CCycleButton &cycleButton) : CButton(cycleButton) { }
+
+ public:
+
+ /**
+ * Constructor for cycle buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the values stored in the global
+ * g_defaultWidgetStyle object. The button will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CCycleButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Add a new option to the widget.
+ *
+ * @param text The text of the option.
+ * @param value The value of the option.
+ */
+
+ void addOption(const CNxString &text, const uint32_t value);
+
+ /**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+ virtual void removeOption(const int index);
+
+ /**
+ * Remove all options from the widget.
+ */
+
+ virtual void removeAllOptions(void);
+
+ /**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual void selectOption(const int index);
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * option is selected, the index of the first selected option is returned.
+ *
+ * @return The selected index.
+ */
+
+ virtual const int getSelectedIndex(void) const;
+
+ /**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected options to deselected.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+ virtual void setSelectedIndex(const int index);
+
+ /**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+ virtual const CListDataItem *getSelectedOption(void) const;
+
+ /**
+ * Get the value of the current option.
+ *
+ * @return Value of the current option.
+ */
+
+ inline const uint32_t getValue(void) const
+ {
+ return getSelectedOption()->getValue();
+ }
+
+ /**
+ * Get the specified option.
+ *
+ * @return The specified option.
+ */
+
+ virtual inline const CListDataItem *getOption(const int index)
+ {
+ return m_options.getItem(index);
+ }
+
+ /**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+ virtual void sort(void);
+
+ /**
+ * Get the total number of options.
+ *
+ * @return The number of options.
+ */
+
+ virtual inline const int getOptionCount(void) const
+ {
+ return m_options.getItemCount();
+ }
+
+ /**
+ * Sets whether or not items added to the list are automatically sorted
+ * on insert or not.
+ *
+ * @param sortInsertedItems True to enable sort on insertion.
+ */
+
+ virtual inline void setSortInsertedItems(const bool sortInsertedItems)
+ {
+ m_options.setSortInsertedItems(sortInsertedItems);
+ }
+
+ /**
+ * Handles list data changed events.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleListDataChangedEvent(const CListDataEventArgs &e);
+
+ /**
+ * Handles list selection changed events.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleListDataSelectionChangedEvent(const CListDataEventArgs &e);
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CCYLEBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/cglyphbutton.hxx b/NxWidgets/libnxwidgets/include/cglyphbutton.hxx
new file mode 100644
index 000000000..aad348ca9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cglyphbutton.hxx
@@ -0,0 +1,229 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CGLYPHBUTTON_HXX
+#define __INCLUDE_CGLYPHBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ struct SBitmap;
+
+ /**
+ * Class representing a button that will display a glyph.
+ * Class representing a clickable button that contains a bitmap image
+ * instead of text. Displays two bitmaps, one when the button is clicked,
+ * and one when it isn't. The bitmaps should be the same size.
+ */
+
+ class CGlyphButton : public CNxWidget
+ {
+ protected:
+
+ FAR const struct SBitmap *m_bitmapNormal; /**< Bitmap when button is not clicked */
+ FAR const struct SBitmap *m_bitmapClicked; /**< Bitmap when button is clicked */
+ nxgl_coord_t m_bitmapX; /**< X coordinate of the bitmaps */
+ nxgl_coord_t m_bitmapY; /**< Y coordinate of the bitmaps */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ *
+ * @param port Graphics port to draw to.
+ */
+
+ virtual void drawOutline(CGraphicsPort *port);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raises an action event and redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CGlyphButton(const CGlyphButton &button) : CNxWidget(button) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button.
+ * @param y The y coordinate of the button.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param normalGlyph Glyph to display when unclicked.
+ * @param clickedGlyph Glyph to display when clicked.
+ * @param bitmapX The x coordinate at which the bitmaps will be drawn.
+ * @param bitmapY The y coordinate at which the bitmaps will be drawn.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the values stored in the global
+ * g_defaultWidgetStyle object. The button will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CGlyphButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_coord_t bitmapX, nxgl_coord_t bitmapY,
+ FAR const struct SBitmap *normalGlyph,
+ FAR const struct SBitmap *clickedGlyph,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CGlyphButton(void) { }
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent.
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CGLYPHBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/cgraphicsport.hxx b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx
new file mode 100644
index 000000000..b9fbc4d41
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx
@@ -0,0 +1,452 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cgraphicsport.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CGRAPHICSPORT_HXX
+#define __INCLUDE_CGRAPHICSPORT_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+#include "inxwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxFont;
+ class CNxString;
+ class CRect;
+ struct SBitmap;
+
+ /**
+ * CGraphicsPort is the interface between a NXwidget and NX layer.
+ */
+
+ class CGraphicsPort
+ {
+ private:
+ INxWindow *m_pNxWnd; /**< NX window interface. */
+#ifdef CONFIG_NX_WRITEONLY
+ nxgl_mxpixel_t m_backColor; /**< The background color to use */
+#endif
+
+ public:
+ /**
+ * Constructor.
+ *
+ * @param pNxWnd. An instance of the underlying window type.
+ * @param backColor. The background color is only needed if we
+ * cannot read from the graphics device.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+ CGraphicsPort(INxWindow *pNxWnd,
+ nxgl_mxpixel_t backColor = CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR);
+#else
+ CGraphicsPort(INxWindow *pNxWnd);
+#endif
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CGraphicsPort();
+
+ /**
+ * Return the absolute x coordinate of the upper left hand corner of the
+ * underlying window.
+ *
+ * @return The x coordinate of the window.
+ */
+
+ const nxgl_coord_t getX(void) const;
+
+ /**
+ * Return the absolute y coordinate of the upper left hand corner of the
+ * underlying window.
+ *
+ * @return The y coordinate of the window.
+ */
+
+ const nxgl_coord_t getY(void) const;
+
+ /**
+ * Get the background color that will be used to fill in the spaces
+ * when rendering fonts. This background color is ONLY used if the
+ * LCD device does not support reading GRAM contents.
+ *
+ * @return. The current background color being used.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+ nxgl_mxpixel_t getBackColor(void) const
+ {
+ return m_backColor;
+ }
+#endif
+
+ /**
+ * Set the background color that will be used to fill in the spaces
+ * when rendering fonts. This background color is ONLY used if the
+ * LCD device does not support reading GRAM contents.
+ *
+ * @return. The current background color being used.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+ void setBackColor(nxgl_mxpixel_t backColor)
+ {
+ m_backColor = backColor;
+ }
+#endif
+
+ /**
+ * Draw a pixel into the window.
+ *
+ * @param x The window-relative x coordinate of the pixel.
+ * @param y The window-relative y coordinate of the pixel.
+ * @param color The color of the pixel.
+ */
+
+ void drawPixel(nxgl_coord_t x, nxgl_coord_t y, nxgl_mxpixel_t color);
+
+ /**
+ * Draw a horizontal line of the specified start position, width, and
+ * color.
+ *
+ * @param x The x coordinate of the line.
+ * @param y The y coordinate of the top-most end of the line.
+ * @param width The width of the line in pixels.
+ * @param color The color of the line.
+ */
+
+ void drawHorizLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a vertical line of the specified start position, width, and
+ * color.
+ *
+ * @param x The x coordinate of the left-most end of the line.
+ * @param y The y coordinate of the line.
+ * @param height The height of the line in rows.
+ * @param color The color of the line.
+ */
+
+ void drawVertLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t height,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a line of a fixed color in the window.
+ *
+ * @param x1 The x coordinate of the start point of the line.
+ * @param y1 The y coordinate of the start point of the line.
+ * @param x2 The x coordinate of the end point of the line.
+ * @param y2 The y coordinate of the end point of the line.
+ * @param color The color of the line.
+ */
+
+ void drawLine(nxgl_coord_t x1, nxgl_coord_t y1,
+ nxgl_coord_t x2, nxgl_coord_t y2,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a filled rectangle of the specified start position, end position,
+ * width, and color.
+ *
+ * @param x The window-relative x coordinate of the rectangle.
+ * @param y The window-relative y coordinate of the rectangle.
+ * @param width The width of the rectangle in pixels.
+ * @param height The height of the rectangle in rows.
+ * @param color The color of the rectangle.
+ */
+
+ void drawFilledRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ nxgl_coord_t height, nxgl_mxpixel_t color);
+
+ /**
+ * Draw an unfilled rectangle to the window
+ *
+ * @param x The window-relative x coordinate of the rectangle.
+ * @param y The window-relative y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @param color The color of the rectangle .
+ */
+
+ void drawRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ nxgl_coord_t height, nxgl_mxpixel_t color);
+
+ /**
+ * Draw a bevelled rectangle to the window.
+ *
+ * @param x The x coordinate of the rectangle.
+ * @param y The y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @param shineColor The color of the top/left sides.
+ * @param shadowColor The color of the bottom/right sides.
+ */
+
+ void drawBevelledRect(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_mxpixel_t shineColor,
+ nxgl_mxpixel_t shadowColor);
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ inline void drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color)
+ {
+ (void)m_pNxWnd->drawFilledCircle(center, radius, color);
+ }
+
+ /**
+ * Draw a string to the window.
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ */
+
+ void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
+ const CNxString &string);
+
+ /**
+ * Draw a particular length of a string to the window in a secific color.
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ * @param startIndex The start index within the string from which
+ * drawing will commence.
+ * @param length The number of characters to draw.
+ * @param color The color of the string.
+ */
+
+ void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
+ const CNxString &string, int startIndex, int length,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a portion of a string to the window.
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ * @param startIndex The start index within the string from which
+ * drawing will commence.
+ * @param length The number of characters to draw.
+ */
+
+ void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
+ const CNxString &string, int startIndex, int length);
+
+ /**
+ * Draw an opaque bitmap to the window.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied
+ * bitmap to use as the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied
+ * bitmap to use as the origin.
+ */
+
+ void drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap, int bitmapX, int bitmapY);
+
+ /**
+ * Draw a bitmap to the window, using the supplied transparent
+ * color as an invisible color.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param transparentColor The transparent color used in the bitmap.
+ */
+
+ void drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap, int bitmapX, int bitmapY,
+ nxgl_mxpixel_t transparentColor);
+
+ /**
+ * Draw a bitmap to the port in greyscale.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
+ * the origin.
+ */
+
+ void drawBitmapGreyScale(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap, int bitmapX, int bitmapY);
+
+ /**
+ * Copy a rectangular region from the source coordinateinates to the
+ * destination coordinateinates.
+ *
+ * @param sourceX Source x coordinate.
+ * @param sourceY Source y coordinate.
+ * @param destX Destination x coordinate.
+ * @param destY Destination y coordinate.
+ * @param width Width of the rectangle to copy.
+ * @param height Height of the rectangle to copy.
+ */
+
+ void copy(nxgl_coord_t sourceX, nxgl_coord_t sourceY,
+ nxgl_coord_t destX, nxgl_coord_t destY,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Move a region by a specified distance in two dimensions.
+ *
+ * @param x X coordinate of the source area to move.
+ * @param y Y coordinate of the source area to move.
+ * @param deltaX Horizontal distance to move.
+ * @param deltaY Vertical distance to move.
+ * @param width Width of the area to move.
+ * @param height Height of the area to move.
+ */
+
+ void move(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t deltaX, nxgl_coord_t deltaY,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Convert the region to greyscale.
+ *
+ * @param x X coordinate of the region to change.
+ * @param y Y coordinate of the region to change.
+ * @param width Width of the region to change.
+ * @param height Height of the region to change.
+ */
+
+ void greyScale(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Invert colors in a region. NOTE: This allocates an in-memory
+ * buffer the size of one row in graphic memory. So it may only be
+ * useful for inverting small regions and its only current use of for
+ * the inverted cursor text.
+ *
+ * @param x X coordinate of the region to change.
+ * @param y Y coordinate of the region to change.
+ * @param width Width of the region to change.
+ * @param height Height of the region to change.
+ */
+
+ void invert(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CGRAPHICSPORT_HXX
diff --git a/NxWidgets/libnxwidgets/include/cimage.hxx b/NxWidgets/libnxwidgets/include/cimage.hxx
new file mode 100644
index 000000000..0fe275624
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cimage.hxx
@@ -0,0 +1,244 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cimage.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CIMAGE_HXX
+#define __INCLUDE_CIMAGE_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class IBitmap;
+
+ /**
+ * Simple image widget for present static images in the widget framework.
+ */
+
+ class CImage : public CNxWidget
+ {
+ protected:
+ FAR IBitmap *m_bitmap; /**< Source bitmap image */
+ struct nxgl_point_s m_origin; /**< Origin for offset image display position */
+ bool m_highlighted; /**< Image is highlighted */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the image.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the image.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CImage(const CImage &label) : CNxWidget(label) { };
+
+ public:
+
+ /**
+ * Constructor for an image.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the image box, relative to its parent.
+ * @param y The y coordinate of the image box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param bitmap The source bitmap image.
+ * @param style The style that the widget should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height, FAR IBitmap *bitmap,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CImage() { }
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Set the horizontal position of the bitmap. Zero is the left edge
+ * of the bitmap and values >0 will move the bit map to the right.
+ * This method is useful for horizontal scrolling a large bitmap
+ * within a smaller window
+ */
+
+ void setImageLeft(nxgl_coord_t column);
+
+ /**
+ * Set the vertical position of the bitmap. Zero is the top edge
+ * of the bitmap and values >0 will move the bit map down.
+ * This method is useful for vertical scrolling a large bitmap
+ * within a smaller window
+ */
+
+ void setImageTop(nxgl_coord_t row);
+
+ /**
+ * Control the highlight state.
+ *
+ * @param highlightOn True(1), the image will be highlighted
+ */
+
+ void highlight(bool highlightOn);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CIMAGE_HXX
diff --git a/NxWidgets/libnxwidgets/include/ckeypad.hxx b/NxWidgets/libnxwidgets/include/ckeypad.hxx
new file mode 100644
index 000000000..2f2a754d4
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ckeypad.hxx
@@ -0,0 +1,156 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ckeypad.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_CKEYPAD_HXX
+#define __INCLUDE_CKEYPAD_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbuttonarray.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CWidgetStyle;
+
+ /**
+ * Extends the CButtonArray class to support a alphanumeric keypad.
+ */
+
+ class CKeypad : public CButtonArray
+ {
+ protected:
+ NXHANDLE m_hNxServer; /**< NX server handle */
+ bool m_numeric; /**< True: Numeric keypad, False: Alpha */
+
+ /**
+ * Configure the keypad for the currenly selected display mode.
+ */
+
+ void configureKeypadMode(void);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CKeypad(const CKeypad &keypad) : CButtonArray(keypad) { }
+
+ public:
+
+ /**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param hNxServer The NX server that will receive the keyboard input
+ * @param x The x coordinate of the keypad, relative to its parent.
+ * @param y The y coordinate of the keypad, relative to its parent.
+ * @param width The width of the keypad
+ * @param height The height of the keypad
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CKeypad(CWidgetControl *pWidgetControl, NXHANDLE hNxServer,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * CKeypad Destructor.
+ */
+
+ inline ~CKeypad(void) {}
+
+ /**
+ * Returns the current keypad display mode
+ *
+ * @return True: keypad is in numeric mode. False: alphanumeric.
+ */
+
+ inline const bool isNumericKeypad(void) const
+ {
+ return m_numeric;
+ }
+
+ /**
+ * Returns the current keypad display mode
+ *
+ * @param mode True: put keypad in numeric mode. False: in alphanumeric.
+ */
+
+ inline void setKeypadMode(bool numeric)
+ {
+ m_numeric = numeric;
+ configureKeypadMode();
+ }
+
+ /**
+ * Catch button clicks.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CKEYPAD_HXX
diff --git a/NxWidgets/libnxwidgets/include/clabel.hxx b/NxWidgets/libnxwidgets/include/clabel.hxx
new file mode 100644
index 000000000..62ed1cda7
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clabel.hxx
@@ -0,0 +1,355 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clabel.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLABEL_HXX
+#define __INCLUDE_CLABEL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CRect;
+
+ /**
+ * Single-line label widget. Can align text both vertically and
+ * horizontally in different ways.
+ */
+
+ class CLabel : public CNxWidget
+ {
+ public:
+
+ /**
+ * Enum of horizontal alignment options.
+ */
+
+ enum TextAlignmentHoriz
+ {
+ TEXT_ALIGNMENT_HORIZ_CENTER = 0, /**< Centre the text */
+ TEXT_ALIGNMENT_HORIZ_LEFT = 1, /**< Align left */
+ TEXT_ALIGNMENT_HORIZ_RIGHT = 2 /**< Align right */
+ };
+
+ /**
+ * Enum of vertical alignment options.
+ */
+
+ enum TextAlignmentVert
+ {
+ TEXT_ALIGNMENT_VERT_CENTER = 0, /**< Align to centre of textbox */
+ TEXT_ALIGNMENT_VERT_TOP = 1, /**< Align to top of textbox */
+ TEXT_ALIGNMENT_VERT_BOTTOM = 2 /**< Align to bottom of textbox */
+ };
+
+ protected:
+ CNxString m_text; /**< Text that the textbox will display */
+ struct nxgl_point_s m_align; /**< X/Y offset for text alignment */
+ TextAlignmentHoriz m_hAlignment; /**< Horizontal alignment of the text */
+ TextAlignmentVert m_vAlignment; /**< Vertical alignment of the text */
+ bool m_textChange; /**< Redraw is due to a text change */
+ bool m_highlighted; /**< Label is highlighted */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ * @param port The CGraphicsPort to draw to.
+ *
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Resize the widget to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Calculate the vertical position of the string based on the font
+ *
+ * height and the alignment options.
+ */
+
+ virtual void calculateTextPositionVertical(void);
+
+ /**
+ * Calculate the position of the string based on its length and the
+ * alignment options.
+ */
+
+ virtual void calculateTextPositionHorizontal(void);
+
+ /**
+ * Updates the GUI after the text has changed.
+ */
+
+ virtual void onTextChange(void);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CLabel(const CLabel &label) : CNxWidget(label) { };
+
+ public:
+
+ /**
+ * Constructor for a label containing a string.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CLabel(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CLabel() { }
+
+ /**
+ * Set the horizontal alignment of text within the label.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+ virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
+
+ /**
+ * Set the vertical alignment of text within the label.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+ virtual void setTextAlignmentVert(TextAlignmentVert alignment);
+
+ /**
+ * Set the horizontal alignment of text within the label.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+ inline const TextAlignmentHoriz getTextAlignmentHoriz(void) const
+ {
+ return m_hAlignment;
+ }
+
+ /**
+ * Set the vertical alignment of text within the label.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+ inline const TextAlignmentVert getTextAlignmentVert(void) const
+ {
+ return m_vAlignment;
+ }
+
+ /**
+ * Returns the string shown in the label.
+ *
+ * @return The label's text.
+ */
+
+ virtual inline const CNxString &getText(void) const
+ {
+ return m_text;
+ }
+
+ /**
+ * Set the text displayed in the label.
+ *
+ * @param text String to display.
+ */
+
+ virtual void setText(const CNxString &text);
+
+ /**
+ * Append new text to the end of the current text displayed in the
+ * label.
+ *
+ * @param text String to append.
+ */
+
+ virtual void appendText(const CNxString &text);
+
+ /**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+ virtual void insertText(const CNxString &text, const int index);
+
+ /**
+ * Control the highlight state.
+ *
+ * @param highlightOn True(1), the label will be highlighted
+ */
+
+ virtual void highlight(bool highlightOn);
+
+ /**
+ * Return the current highlight state.
+ *
+ * @return True if the label is highlighted
+ */
+
+ virtual inline bool isHighlighted(void) const
+ {
+ return m_highlighted;
+ }
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+ virtual void setFont(CNxFont *font);
+
+ /**
+ * Is the redraw due to a text-only change?
+ *
+ * @return True if the redraw was caused by a text change
+ */
+
+ virtual inline bool isTextChange(void) const
+ {
+ return m_textChange;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLABEL_HXX
diff --git a/NxWidgets/libnxwidgets/include/clatchbutton.hxx b/NxWidgets/libnxwidgets/include/clatchbutton.hxx
new file mode 100644
index 000000000..c0b37d64b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clatchbutton.hxx
@@ -0,0 +1,173 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clatchbutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLATCHBUTTON_HXX
+#define __INCLUDE_CLATCHBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybutton.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * CButton that latches down when clicked and unlatches when clicked again.
+ */
+
+ class CLatchButton : public CStickyButton
+ {
+ protected:
+ /**
+ * Handles button click events
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CLatchButton(const CLatchButton &button) : CStickyButton(button) { }
+
+ public:
+
+ /**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CLatchButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CLatchButton(void) { }
+
+ /**
+ * Check if the button is latched
+ *
+ * @return True if the button is latched
+ */
+
+ inline const bool isLatched(void) const
+ {
+ return isStuckDown();
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLATCHBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/clatchbuttonarray.hxx b/NxWidgets/libnxwidgets/include/clatchbuttonarray.hxx
new file mode 100644
index 000000000..bffeb58a1
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clatchbuttonarray.hxx
@@ -0,0 +1,170 @@
+/****************************************************************************
+ * include/clatchbuttonarray.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_CLATCHBUTTONARRAY_HXX
+#define __INCLUDE_CLATCHBUTTONARRAY_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybuttonarray.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CNxString;
+
+ /**
+ * Manages a two-dimensional array of buttons as one widget. When a button
+ * is clicked is latches (i.e., it stays pushed after the press is released.
+ * The behavior is then like radio buttons: Pressing each each button in
+ * the array unlatches the previous button and latches the new button.
+ *
+ * Unlike CLatchButton, pressing the same button more than once has no
+ * effect.
+ */
+
+ class CLatchButtonArray : public CStickyButtonArray
+ {
+ protected:
+ /**
+ * Handles button click events
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CLatchButtonArray(const CLatchButtonArray &button) : CStickyButtonArray(button) { }
+
+ public:
+
+ /**
+ * Constructor for an array of latch buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CLatchButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * CLatchButtonArray Destructor.
+ */
+
+ virtual inline ~CLatchButtonArray(void) { }
+
+ /**
+ * Return the position of the last latched button (0,0 will be returned
+ * the no button has every been latched). The button at this position
+ * is currently latched then, in addition, return true.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if a button in the array is latched
+ */
+
+ inline const bool isAnyButtonLatched(int &column, int &row) const
+ {
+ return isAnyButtonStuckDown(column, row);
+ }
+
+ /**
+ * Check if this specific button in the array is latched
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is clicked
+ */
+
+ inline const bool isThisButtonLatched(int column, int row) const
+ {
+ return isThisButtonStuckDown(column, row);
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLATCHBUTTONARRAY_HXX
diff --git a/NxWidgets/libnxwidgets/include/clistbox.hxx b/NxWidgets/libnxwidgets/include/clistbox.hxx
new file mode 100644
index 000000000..7afa76920
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clistbox.hxx
@@ -0,0 +1,431 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clistbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in all NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLISTBOX_HXX
+#define __INCLUDE_CLISTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cscrollingpanel.hxx"
+#include "ilistdataeventhandler.hxx"
+#include "clistdata.hxx"
+#include "clistboxdataitem.hxx"
+#include "cwidgetstyle.hxx"
+#include "ilistbox.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class providing a scrollable list of options. The CListBox can be set
+ * up to only allow one selection or multiple selections. Processes
+ * double-clicks and raises double-click events, so that a double-click
+ * on an option can be made to automatically select and close a window/etc.
+ * The options themselves have user-definable text and background colors
+ * for their selected and unselected states.
+ */
+
+ class CListBox : public IListBox, public CScrollingPanel,
+ public IListDataEventHandler
+ {
+ protected:
+ CListData m_options; /**< Option storage. */
+ uint8_t m_optionPadding; /**< Padding between options. */
+ int m_lastSelectedIndex; /**< Index of the last option selected. */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Determines which item was clicked and selects or deselects it as
+ * appropriate. Also starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Selects the clicked item and deselects all others.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Select or deselect an option by its index. Does not deselect any other
+ * selected options. Set index to -1 to select nothing. Redraws the widget
+ * and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ * @param selected True to select the option, false to deselect it.
+ */
+
+ virtual void setOptionSelected(const int index, const bool selected);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CListBox(const CListBox &listBox) : CScrollingPanel(listBox) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CListBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CListBox(void);
+
+ /**
+ * Add a new option to the widget using default colors.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value);
+
+ /**
+ * Add an option to the widget.
+ *
+ * @param option The option to add.
+ */
+
+ virtual void addOption(CListBoxDataItem *option);
+
+ /**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+ virtual void removeOption(const int index);
+
+ /**
+ * Remove all options from the widget.
+ */
+
+ virtual void removeAllOptions(void);
+
+ /**
+ * Add a new option to the widget.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor);
+
+ /**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual void selectOption(const int index);
+
+ /**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual void deselectOption(const int index);
+
+ /**
+ * Select all options. Does nothing if the listbox does not allow
+ * multiple selections. Redraws the widget and raises a value changed
+ * event.
+ */
+
+ virtual void selectAllOptions(void);
+
+ /**
+ * Deselect all options.
+ * Redraws the widget and raises a value changed event.
+ */
+
+ virtual void deselectAllOptions(void);
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected. If
+ * more than one option is selected, the index of the first selected
+ * option is returned.
+ *
+ * @return The selected index.
+ */
+
+ virtual const int getSelectedIndex(void) const;
+
+ /**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected options to deselected. Redraws the widget and raises
+ * a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+ virtual void setSelectedIndex(const int index);
+
+ /**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+ virtual const CListBoxDataItem *getSelectedOption(void) const;
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @param allowMultipleSelections True to allow multiple selections.
+ */
+
+ virtual inline void
+ setAllowMultipleSelections(const bool allowMultipleSelections)
+ {
+ m_options.setAllowMultipleSelections(allowMultipleSelections);
+ }
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @return True if multiple selections are allowed.
+ */
+
+ virtual inline const bool allowsMultipleSelections(void) const
+ {
+ return m_options.allowsMultipleSelections();
+ }
+
+ /**
+ * Resize the scrolling canvas to encompass all options.
+ */
+
+ virtual void resizeCanvas(void);
+
+ /**
+ * Get the specified option.
+ *
+ * @return The specified option.
+ */
+
+ virtual inline const CListBoxDataItem *getOption(const int index)
+ {
+ return (const CListBoxDataItem *)m_options.getItem(index);
+ }
+
+ /**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+ virtual void sort(void);
+
+ /**
+ * Get the total number of options.
+ *
+ * @return The number of options.
+ */
+
+ virtual inline const int getOptionCount(void) const
+ {
+ return m_options.getItemCount();
+ }
+
+ /**
+ * Get the height of a single option.
+ *
+ * @return The height of an option.
+ */
+
+ virtual const nxgl_coord_t getOptionHeight(void) const;
+
+ /**
+ * Sets whether or not items added to the list are automatically sorted on insert or not.
+ *
+ * @param sortInsertedItems True to enable sort on insertion.
+ */
+
+ virtual inline void setSortInsertedItems(const bool sortInsertedItems)
+ {
+ m_options.setSortInsertedItems(sortInsertedItems);
+ }
+
+ /**
+ * Handles list data changed events.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleListDataChangedEvent(const CListDataEventArgs &e);
+
+ /**
+ * Handles list selection changed events.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleListDataSelectionChangedEvent(const CListDataEventArgs &e);
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Check if the click is a double-click.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click is a double-click.
+ */
+
+ virtual bool isDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLISTBOX_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/clistboxdataitem.hxx b/NxWidgets/libnxwidgets/include/clistboxdataitem.hxx
new file mode 100644
index 000000000..9a1358d39
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clistboxdataitem.hxx
@@ -0,0 +1,180 @@
+/****************************************************************************
+ * include/clistboxdataitem.hxx
+ * NxWidgets/libnxwidgets/
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLISTBOXDATAITEM_HXX
+#define __INCLUDE_CLISTBOXDATAITEM_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "clistdataitem.hxx"
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class representing a data item within a ListBox.
+ */
+
+ class CListBoxDataItem : public CListDataItem
+ {
+ private:
+ nxwidget_pixel_t m_normalTextColor; /**< Color used for text when not selected. */
+ nxwidget_pixel_t m_normalBackColor; /**< Color used for background when not selected. */
+ nxwidget_pixel_t m_selectedTextColor; /**< Color used for text when selected. */
+ nxwidget_pixel_t m_selectedBackColor; /**< Color used for background when selected. */
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param text The text to display in the item.
+ * @param value The value of the item.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+ CListBoxDataItem(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor);
+
+ /**
+ * Get the color used for text when the item is unselected.
+ *
+ * @return The text color when the item is unselected.
+ */
+
+ inline nxwidget_pixel_t getNormalTextColor(void) const
+ {
+ return m_normalTextColor;
+ }
+
+ /**
+ * Get the color used for the background when the item is unselected.
+ *
+ * @return The background color when the item is unselected.
+ */
+
+ inline nxwidget_pixel_t getNormalBackColor(void) const
+ {
+ return m_normalBackColor;
+ }
+
+ /**
+ * Get the color used for text when the item is selected.
+ *
+ * @return The text color when the item is selected.
+ */
+
+ inline nxwidget_pixel_t getSelectedTextColor(void) const
+ {
+ return m_selectedTextColor;
+ }
+
+ /**
+ * Get the color used for the background when the item is selected.
+ *
+ * @return The background color when the item is selected.
+ */
+
+ inline nxwidget_pixel_t getSelectedBackColor(void) const
+ {
+ return m_selectedBackColor;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLISTBOXDATAITEM_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/clistdata.hxx b/NxWidgets/libnxwidgets/include/clistdata.hxx
new file mode 100644
index 000000000..d88abd9fc
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clistdata.hxx
@@ -0,0 +1,351 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clistdata.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLISTDATA_HXX
+#define __INCLUDE_CLISTDATA_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "tnxarray.hxx"
+#include "ilistdataeventhandler.hxx"
+#include "clistdataitem.hxx"
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class representing a list of items. Designed to be used by the
+ * CListBox class, etc, to store its data. Fires events to notify
+ * listeners when the list changes or a new selection is made.
+ */
+
+ class CListData
+ {
+ protected:
+ TNxArray<CListDataItem*> m_items; /**< Collection of list data items. */
+ TNxArray<IListDataEventHandler*> m_listDataEventhandlers; /**< Collection of event handlers. */
+ bool m_allowMultipleSelections; /**< If true, multiple options can
+ be selected. */
+ bool m_sortInsertedItems; /**< Automatically sorts items on
+ insertion if true. */
+
+ /**
+ * Quick sort the items using their compareTo() methods.
+ *
+ * @param start The index to start sorting at.
+ * @param end The index to stop sorting at.
+ */
+
+ virtual void quickSort(const int start, const int end);
+
+ /**
+ * Swap the locations of two items in the array.
+ *
+ * @param index1 The index of the first item to swap.
+ * @param index2 The index of the second item to swap.
+ */
+
+ virtual void swapItems(const int index1, const int index2);
+
+ /**
+ * Return the index that an item should be inserted at to maintain a sorted list of data.
+ *
+ * @param item The item to insert.
+ * @return The index that the item should be imserted into at.
+ */
+
+ const int getSortedInsertionIndex(const CListDataItem *item) const;
+
+ /**
+ * Raise a data changed event.
+ */
+
+ void raiseDataChangedEvent(void);
+
+ /**
+ * Raise a selection changed event.
+ */
+
+ void raiseSelectionChangedEvent(void);
+
+ public:
+
+ /**
+ * Constructor.
+ */
+ CListData(void);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CListData(void);
+
+ /**
+ * Add a new item.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+ virtual void addItem(const CNxString &text, const uint32_t value);
+
+ /**
+ * Add an existing item. CListData becomes the owner of the option and will delete it
+ * when the list is deleted.
+ *
+ * @param item The item to add.
+ */
+
+ virtual void addItem(CListDataItem *item);
+
+ /**
+ * Remove an item by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+ virtual void removeItem(const int index);
+
+ /**
+ * Select an item by its index.
+ *
+ * @param index The index of the item to select.
+ */
+
+ virtual void selectItem(const int index);
+
+ /**
+ * Deselect an item by its index.
+ *
+ * @param index The index of the item to select.
+ */
+
+ virtual void deselectItem(const int index);
+
+ /**
+ * Remove all items.
+ */
+
+ virtual void removeAllItems(void);
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * item is selected, the index of the first selected item is returned.
+ *
+ * @return The selected index.
+ */
+
+ virtual const int getSelectedIndex(void) const;
+
+ /**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected items to deselected.
+ *
+ * @param index The selected index.
+ */
+
+ virtual void setSelectedIndex(const int index);
+
+ /**
+ * Get the selected item. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+ virtual const CListDataItem *getSelectedItem(void) const;
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @param allowMultipleSelections True to allow multiple selections.
+ */
+
+ virtual inline void
+ setAllowMultipleSelections(const bool allowMultipleSelections)
+ {
+ m_allowMultipleSelections = allowMultipleSelections;
+ }
+
+ /**
+ * Get the specified item.
+ *
+ * @return The specified item.
+ */
+
+ virtual inline const CListDataItem *getItem(const int index) const
+ {
+ return m_items[index];
+ }
+
+ /**
+ * Sort the items using their compareTo() methods.
+ */
+
+ virtual void sort(void);
+
+ /**
+ * Get the total number of items.
+ *
+ * @return The number of items.
+ */
+
+ virtual inline const int getItemCount(void) const
+ {
+ return m_items.size();
+ }
+
+ /**
+ * Select all items. Does nothing if the list does not allow
+ * multiple selections.
+ */
+
+ virtual void selectAllItems(void);
+
+ /**
+ * Deselect all items.
+ */
+
+ virtual void deselectAllItems(void);
+
+ /**
+ * Select or deselect an item by its index. Does not deselect any
+ * other selected items. Set index to -1 to select nothing.
+ *
+ * @param index The index of the item to select.
+ * @param selected True to select the item, false to deselect it.
+ */
+
+ virtual void setItemSelected(const int index, const bool selected);
+
+ /**
+ * Returns whether multiple selections are possible or not.
+ *
+ * @return True if multiple selections are allowed.
+ */
+
+ virtual inline const bool allowsMultipleSelections(void) const
+ {
+ return m_allowMultipleSelections;
+ }
+
+ /**
+ * Sets whether or not items added to the list are automatically
+ * sorted on insert or not.
+ *
+ * @param sortInsertedItems True to enable sort on insertion.
+ */
+
+ virtual inline void setSortInsertedItems(const bool sortInsertedItems)
+ {
+ m_sortInsertedItems = sortInsertedItems;
+ }
+
+ /**
+ * Add an event handler.
+ *
+ * @param eventHandler The event handler to add.
+ */
+
+ inline void addListDataEventHandler(IListDataEventHandler *eventHandler)
+ {
+ m_listDataEventhandlers.push_back(eventHandler);
+ }
+
+ /**
+ * Remove an event handler.
+ *
+ * @param eventHandler The event handler to remove.
+ */
+
+ void removeListDataEventHandler(IListDataEventHandler *eventHandler);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLISTDATA_HXX
diff --git a/NxWidgets/libnxwidgets/include/clistdataeventargs.hxx b/NxWidgets/libnxwidgets/include/clistdataeventargs.hxx
new file mode 100644
index 000000000..57118e238
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clistdataeventargs.hxx
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clistdataeventargs.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLISTDATAEVENTARGS_HXX
+#define __INCLUDE_CLISTDATAEVENTARGS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "teventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CListData;
+
+ /**
+ * Event arguments passed to listeners when a CListData object raises an
+ * event.
+ */
+
+ class CListDataEventArgs : public TEventArgs<CListData*>
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param source Pointer to the CListData object that raised the event.
+ */
+
+ inline CListDataEventArgs(CListData *source) : TEventArgs<CListData*>(source)
+ {
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLISTDATAEVENTARGS_HXX
diff --git a/NxWidgets/libnxwidgets/include/clistdataitem.hxx b/NxWidgets/libnxwidgets/include/clistdataitem.hxx
new file mode 100644
index 000000000..db3bb20a2
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/clistdataitem.hxx
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/clistdataitem.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CLISTDATAITEM_HXX
+#define __INCLUDE_CLISTDATAITEM_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class representing a data item within a list. Intended for use within
+ * the CListData class.
+ */
+
+ class CListDataItem
+ {
+ private:
+ CNxString m_text; /**< Text to display for option. */
+ uint32_t m_value; /**< Option value. */
+ bool m_isSelected; /**< True if the option is selected. */
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param text The text to display in the item.
+ * @param value The value of the item.
+ */
+
+ CListDataItem(const CNxString &text, const uint32_t value);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CListDataItem(void);
+
+ /**
+ * Get the item's text.
+ *
+ * @return The item's text.
+ */
+
+ inline const CNxString &getText(void) const
+ {
+ return m_text;
+ }
+
+ /**
+ * Get the item's value.
+ *
+ * @return The item's value.
+ */
+
+ inline const uint32_t getValue(void) const
+ {
+ return m_value;
+ }
+
+ /**
+ * Get the item's selection state.
+ *
+ * @return True if the item is selected; false if not.
+ */
+
+ inline const bool isSelected(void) const
+ {
+ return m_isSelected;
+ }
+
+ /**
+ * Set the item's selection state.
+ *
+ * @param selected True to select the item; false to deselect it.
+ */
+
+ inline void setSelected(bool selected)
+ {
+ m_isSelected = selected;
+ }
+
+ /**
+ * Compare the item with another. Comparison is based on the text of
+ * the item. Returns 0 if the text in the two items is the same,
+ * a value less than 0 if this item is less than the argument, and
+ * a value greater than 0 if this item is greater than the argument.
+ *
+ * @param item An item to compare this object with.
+ * @return 0 if the text in the two items is the same,
+ * a value less than 0 if this item is less than the argument, and
+ * a value greater than 0 if this item is greater than the argument.
+ */
+
+ virtual int compareTo(const CListDataItem *item) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CLISTDATAITEM_HXX
diff --git a/NxWidgets/libnxwidgets/include/cmultilinetextbox.hxx b/NxWidgets/libnxwidgets/include/cmultilinetextbox.hxx
new file mode 100644
index 000000000..5ed41740b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cmultilinetextbox.hxx
@@ -0,0 +1,621 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cmultilinetextbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CMULTILINETEXTBOX_HXX
+#define __INCLUDE_CMULTILINETEXTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#include "cscrollingpanel.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxstring.hxx"
+#include "ctext.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "itextbox.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxTimer;
+
+ /**
+ * Textbox that offers multiple lines of text. Has scrolling
+ * capability and can be dragged using the mouse. The text
+ * it contains can be changed or added to. It can remember more
+ * rows of text than it can display, and these additional
+ * rows can be scrolled through.
+ */
+
+ class CMultiLineTextBox : public ITextBox, public CScrollingPanel,
+ public CWidgetEventHandler
+ {
+ public:
+
+ /**
+ * Enum of horizontal alignment options.
+ */
+
+ enum TextAlignmentHoriz
+ {
+ TEXT_ALIGNMENT_HORIZ_CENTER = 0, /**< Centre the text */
+ TEXT_ALIGNMENT_HORIZ_LEFT = 1, /**< Align left */
+ TEXT_ALIGNMENT_HORIZ_RIGHT = 2 /**< Align right */
+ };
+
+ /**
+ * Enum of vertical alignment options.
+ */
+
+ enum TextAlignmentVert
+ {
+ TEXT_ALIGNMENT_VERT_CENTER = 0, /**< Align to centre of textbox */
+ TEXT_ALIGNMENT_VERT_TOP = 1, /**< Align to top of textbox */
+ TEXT_ALIGNMENT_VERT_BOTTOM = 2 /**< Align to bottom of textbox */
+ };
+
+ protected:
+ CText *m_text; /**< CText object that manipulates
+ and wraps the raw text string. */
+ uint8_t m_visibleRows; /**< Total number of rows that the
+ textbox can display at once. */
+ nxgl_coord_t m_maxRows; /**< Maximum number of rows that the
+ textbox should buffer. */
+ int32_t m_topRow; /**< Index of the top row of text
+ currently displayed. */
+ TextAlignmentHoriz m_hAlignment; /**< Horizontal alignment of the text. */
+ TextAlignmentVert m_vAlignment; /**< Vertical alignment of the text. */
+ int m_cursorPos; /**< Position of the cursor within
+ the string. */
+ uint8_t m_showCursor; /**< Cursor visibility. */
+ bool m_wrapCursor; /**< True wrap cursor at the ends of the text */
+
+ /**
+ * Get the coordinates of the cursor relative to the text.
+ *
+ * @param x Will be populated with the x coordinate of the cursor.
+ * @param y Will be populated with the y coordinate of the cursor.
+ */
+
+ virtual void getCursorCoordinates(nxgl_coord_t& x, nxgl_coord_t& y) const;
+
+ /**
+ * Gets the index of the character at the specified x coordinate in the
+ * specified row.
+ *
+ * @param x X coordinate of the character.
+ * @param rowIndex Index of the row containing the character.
+ * @return The index of the character at the specified coordinate.
+ */
+
+ virtual int getCharIndexAtCoordinate(nxgl_coord_t x, int rowIndex) const;
+
+ /**
+ * Get the index of the character at the specified coordinates.
+ *
+ * @param x X coordinate of the character.
+ * @param y Y coordinate of the character.
+ * @return The index of the character at the specified coordinates.
+ */
+
+ virtual unsigned int getCharIndexAtCoordinates(nxgl_coord_t x, nxgl_coord_t y) const;
+
+ /**
+ * Get the row containing the specified Y coordinate.
+ *
+ * @param y Y coordinate to locate.
+ * @return The index of the row containing the specified Y coordinate.
+ */
+
+ int getRowContainingCoordinate(nxgl_coord_t y) const;
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Move cursor one character to the left.
+ */
+
+ virtual void moveCursorLeft(void);
+
+ /**
+ * Move cursor one character to the right.
+ */
+
+ virtual void moveCursorRight(void);
+
+ /**
+ * Move cursor one row upwards.
+ */
+
+ virtual void moveCursorUp(void);
+
+ /**
+ * Move cursor one row downwards.
+ */
+
+ virtual void moveCursorDown(void);
+
+ /**
+ * Ensures that the textbox only contains the maximum allowed
+ * number of rows by culling any excess rows from the top of
+ * the text.
+ *
+ * @return True if lines were removed from the text; false if not.
+ */
+
+ virtual bool cullTopLines(void);
+
+ /**
+ * Ensures that the canvas height is the height of the widget,
+ * if the widget exceeds the size of the text, or the height of
+ * the text if the text exceeds the size of the widget.
+ */
+
+ virtual void limitCanvasHeight(void);
+
+ /**
+ * Ensures that the canvas cannot scroll beyond its height.
+ */
+
+ virtual void limitCanvasY(void);
+
+ /**
+ * Jumps to the cursor coordinates of the text.
+ */
+
+ void jumpToCursor(void);
+
+ /**
+ * Jumps to the bottom of the text.
+ */
+
+ void jumpToTextBottom(void);
+
+ /**
+ * Resize the textbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Opens the keyboard on the bottom display.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+ virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Handles physical button presses. Moves the cursor
+ * in the direction pressed.
+ *
+ * @param key The key that was pressed.
+ */
+
+ void processPhysicalKey(nxwidget_char_t key);
+
+ /**
+ * Handle a keyboard press event.
+ *
+ * @param e The event data.
+ */
+
+ void handleKeyPressEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a cursor control event. Replaces CWidgetEventHandler method.
+ *
+ * @param e The event data.
+ */
+
+ void handleCursorControlEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Gets the x position of a row of text based on the width of the row and the
+ * type of horizontal alignment currently set.
+ *
+ * @param row The index of the row.
+ * @return The x coordinate of the row.
+ */
+
+ nxgl_coord_t getRowX(int row) const;
+
+ /**
+ * Gets the y position of the specified row of text based on the type of
+ * vertical alignment currently set.
+ *
+ * @param row The row number to find the y coordinate of.
+ * @return The y coordinate of the specified row of text.
+ */
+
+ nxgl_coord_t getRowY(int row) const;
+
+ /**
+ * Return true if the cursor is visible
+ */
+
+ virtual bool isCursorVisible(void) const;
+
+ /**
+ * Gets the character under the cursor.
+ *
+ * @return The character under the cursor.
+ */
+
+ nxwidget_char_t getCursorChar(void) const;
+
+ /**
+ * Works out the number of visible rows within the textbox.
+ */
+
+ void calculateVisibleRows(void);
+
+ /**
+ * Draws text.
+ *
+ * @param port The CGraphicsPort to draw to.
+ */
+
+ void drawText(CGraphicsPort *port);
+
+ /**
+ * Draws the cursor.
+ *
+ * @param port The CGraphicsPort to draw to.
+ */
+
+ void drawCursor(CGraphicsPort *port);
+
+ /**
+ * Draws a single line of text.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param row The index of the row to draw.
+ */
+
+ void drawRow(CGraphicsPort *port, int row);
+
+ /**
+ * Destructor.
+ */
+
+ inline virtual ~CMultiLineTextBox(void)
+ {
+ delete m_text;
+ m_text = (CText *)NULL;
+ }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CMultiLineTextBox(const CMultiLineTextBox &multiLineTextBox)
+ : CScrollingPanel(multiLineTextBox) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param flags Standard widget flag options.
+ * @param maxRows The maximum number of rows the textbox can track. Adding
+ * text beyond this number will cause rows at the start of the text to be
+ * forgotten; text is essentially stored as a queue, and adding to the back
+ * of a full queue causes the front items to be popped off. Setting this to
+ * 0 will make the textbox track only the visible rows.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CMultiLineTextBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, uint32_t flags,
+ nxgl_coord_t maxRows = 0,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Set the horizontal alignment of text within the textbox.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+ virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
+
+ /**
+ * Set the vertical alignment of text within the textbox.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+ virtual void setTextAlignmentVert(TextAlignmentVert alignment);
+
+ /**
+ * Returns the number of "pages" that the text spans. A page
+ * is defined as the amount of text that can be displayed within
+ * the textbox at one time.
+ *
+ * @return The page count.
+ */
+
+ virtual const int getPageCount(void) const;
+
+ /**
+ * Returns the current page.
+ *
+ * @return The current page.
+ * @see getPageCount().
+ */
+
+ virtual const int getCurrentPage(void) const;
+
+ /**
+ * Returns a pointer to the CText object that contains the
+ * wrapped text used in the textbox. It is used as the
+ * pre-processed data source for the textbox, and should
+ * not be altered.
+ *
+ * @return Pointer to the CText object.
+ */
+
+ virtual inline const CText *getText(void) const
+ {
+ return m_text;
+ }
+
+ /**
+ * Set the text displayed in the textbox.
+ *
+ * @param text String to display.
+ */
+
+ virtual void setText(const CNxString &text);
+
+ /**
+ * Append new text to the end of the current text
+ * displayed in the textbox.
+ *
+ * @param text String to append.
+ */
+
+ virtual void appendText(const CNxString &text);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+ virtual void removeText(const unsigned int startIndex);
+
+ /**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+ virtual void removeText(const unsigned int startIndex, const unsigned int count);
+
+ /**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+ virtual void setFont(CNxFont *font);
+
+ /**
+ * Get the length of the text string.
+ *
+ * @return The length of the text string.
+ */
+
+ virtual const int getTextLength(void) const;
+
+ /**
+ * Sets the cursor display mode.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+ virtual void showCursor(EShowCursor cursorMode);
+
+ /**
+ * Shows the cursor in default mode (only when the TextBox has focus).
+ */
+
+ virtual inline void showCursor(void)
+ {
+ showCursor(SHOW_CURSOR_ONFOCUS);
+ }
+
+ /**
+ * Hides the cursor.
+ */
+
+ virtual inline void hideCursor(void)
+ {
+ showCursor(SHOW_CURSOR_NEVER);
+ }
+
+ /**
+ * Enables/disables cursor wrapping
+ *
+ * @param wrap True enables cursor wrapping
+ */
+
+ virtual inline void wrapCursor(bool wrap)
+ {
+ m_wrapCursor = wrap;
+ }
+
+ /**
+ * Move the cursor to the text position specified. 0 indicates the start
+ * of the string. If position is greater than the length of the string,
+ * the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+ virtual void moveCursorToPosition(const int position);
+
+ /**
+ * Get the cursor position. This is the index within the string that
+ * the cursor is currently positioned over.
+ *
+ * @return position The cursor position.
+ */
+
+ virtual inline const int getCursorPosition(void) const
+ {
+ return m_cursorPos;
+ }
+
+ /**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+ virtual void insertText(const CNxString &text,
+ const unsigned int index);
+
+ /**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+ virtual void insertTextAtCursor(const CNxString & ext);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CMULTILINETEXTBOX_HXX
diff --git a/NxWidgets/libnxwidgets/include/cnxfont.hxx b/NxWidgets/libnxwidgets/include/cnxfont.hxx
new file mode 100644
index 000000000..33e712291
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxfont.hxx
@@ -0,0 +1,238 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxfont.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_CNXFONT_HXX
+#define __INCLUDE_CNXFONT_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nxfonts.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxString;
+ struct SBitmap;
+
+ /**
+ * Class defining the properties of one font.
+ */
+
+ class CNxFont
+ {
+ private:
+ enum nx_fontid_e m_fontId; /**< The font ID. */
+ NXHANDLE m_fontHandle; /**< The font handle */
+ FAR const struct nx_font_s *m_pFontSet; /** < The font set metrics */
+ nxgl_mxpixel_t m_fontColor; /**< Color to draw the font with when rendering. */
+ nxgl_mxpixel_t m_transparentColor; /**< Background color that should not be rendered. */
+
+ public:
+
+ /**
+ * CNxFont Constructor.
+ *
+ * @param fontid The font ID to use.
+ * @param fontColor The font color to use.
+ * @param transparentColor The color in the font bitmap used as the
+ * background color.
+ */
+
+ CNxFont(enum nx_fontid_e fontid, nxgl_mxpixel_t fontColor,
+ nxgl_mxpixel_t transparentColor);
+
+ /**
+ * CNxFont Destructor.
+ */
+
+ ~CNxFont() { }
+
+ /**
+ * Checks if supplied character is blank in the current font.
+ *
+ * @param letter The character to check.
+ * @return True if the glyph contains any pixels to be drawn. False if
+ * the glyph is blank.
+ */
+
+ const bool isCharBlank(const nxwidget_char_t letter) const;
+
+ /**
+ * Gets the color currently being used as the drawing color.
+ *
+ * @return The current drawing color.
+ */
+
+ inline const nxgl_mxpixel_t getColor() const
+ {
+ return m_fontColor;
+ }
+
+ /**
+ * Sets the color to use as the drawing color. If set, this overrides
+ * the colors present in a non-monochrome font.
+ * @param color The new drawing color.
+ */
+
+ inline void setColor(const nxgl_mxpixel_t color)
+ {
+ m_fontColor = color;
+ }
+
+ /**
+ * Get the color currently being used as the transparent background
+ * color.
+ * @return The transparent background color.
+ */
+
+ inline const nxgl_mxpixel_t getTransparentColor() const
+ {
+ return m_transparentColor;
+ }
+
+ /**
+ * Sets the transparent background color to a new value.
+ * @param color The new background color.
+ */
+
+ inline void setTransparentColor(const nxgl_mxpixel_t color)
+ {
+ m_transparentColor = color;
+ }
+
+ /**
+ * Draw an individual character of the font to the specified bitmap.
+ *
+ * @param bitmap The bitmap to draw to.
+ * @param letter The character to output.
+ */
+
+ void drawChar(FAR SBitmap *bitmap, nxwidget_char_t letter);
+
+ /**
+ * Get the width of a string in pixels when drawn with this font.
+ *
+ * @param text The string to check.
+ * @return The width of the string in pixels.
+ */
+
+ nxgl_coord_t getStringWidth(const CNxString &text) const;
+
+ /**
+ * Get the width of a portion of a string in pixels when drawn with this
+ * font.
+ *
+ * @param text The string to check.
+ * @param startIndex The start point of the substring within the string.
+ * @param length The length of the substring in chars.
+ * @return The width of the substring in pixels.
+ */
+
+ nxgl_coord_t getStringWidth(const CNxString& text,
+ int startIndex, int length) const;
+
+ /**
+ * Gets font metrics for a particular character
+ *
+ *
+ * @param letter The character to get the width of.
+ * @param metrics The location to return the font metrics
+ */
+
+ void getCharMetrics(nxwidget_char_t letter,
+ FAR struct nx_fontmetric_s *metrics) const;
+
+ /**
+ * Get the width of an individual character.
+ *
+ * @param letter The character to get the width of.
+ * @return The width of the character in pixels.
+ */
+
+ nxgl_coord_t getCharWidth(nxwidget_char_t letter) const;
+
+ /**
+ * Get the height of an individual character.
+ *
+ * @param letter The letter to get the height of.
+ * @return The height of the character in pixels.
+ */
+
+ inline nxgl_coord_t getCharHeight(nxwidget_char_t letter) const;
+
+ /**
+ * Gets the maximum width of the font.
+ *
+ * @return The height of the font.
+ */
+
+ inline const uint8_t getMaxWidth(void) const
+ {
+ return m_pFontSet->mxwidth;
+ }
+
+ /**
+ * Gets the height of the font.
+ *
+ * @return The height of the font.
+ */
+
+ inline const uint8_t getHeight(void) const
+ {
+ return m_pFontSet->mxheight;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXFONT_HXX
diff --git a/NxWidgets/libnxwidgets/include/cnxserver.hxx b/NxWidgets/libnxwidgets/include/cnxserver.hxx
new file mode 100644
index 000000000..c6ca21bfc
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxserver.hxx
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxserver.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_CNXSERVER_HXX
+#define __INCLUDE_CNXSERVER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <semaphore.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "cnxwindow.hxx"
+#include "cnxtkwindow.hxx"
+#include "cbgwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CBgWindow;
+
+ /**
+ * This class represents the NX server. It includes methods to connect to
+ * and disconnect form the NX server, methods to manage the background, and
+ * "factory" methods to create window objects on the NX server. NXWidget
+ * objects them may be created on the window objects.
+ */
+
+ class CNxServer
+ {
+ private:
+ FAR NX_DRIVERTYPE *m_hDevice; /**< LCD/Framebuffer device handle */
+ NXHANDLE m_hNxServer; /**< NX server handle */
+#ifdef CONFIG_NX_MULTIUSER
+ volatile bool m_running; /**< True: The listener thread is running */
+ volatile bool m_connected; /**< True: Connected to the server */
+ volatile bool m_stop; /**< True: Waiting for the listener thread to stop */
+ sem_t m_connsem; /**< Wait for server connection */
+#endif
+ static uint8_t m_nServers; /**< The number of NX server instances */
+
+ /**
+ * NX server thread. This is the entry point into the server thread that
+ * serializes the multi-threaded accesses to the display.
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ static int server(int argc, char *argv[]);
+#endif
+
+ /**
+ * NX listener thread. This is the entry point of a thread that listeners for and
+ * dispatches events from the NX server.
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ static FAR void *listener(FAR void *arg);
+#endif
+
+ public:
+
+ /**
+ * CNXServer constructor. The CNxServer is a normally singleton. However, that
+ * not enforced: This constructor could run more than one in the situation where
+ * there are multiple physical displays. However, that configuration has never
+ * been texted.
+ */
+
+ CNxServer(void);
+
+ /**
+ * CNXServer destructor
+ */
+
+ ~CNxServer(void);
+
+ /**
+ * Connect to the NX Server
+ */
+
+ virtual bool connect(void);
+
+ /**
+ * Disconnect from the NX Server
+ */
+
+ virtual void disconnect(void);
+
+ /**
+ * Get the NX server handle
+ *
+ * @return The NX server handler (NULL is not connected)
+ */
+
+ inline NXHANDLE getServer(void)
+ {
+ return m_hNxServer;
+ }
+
+ /**
+ * Test if we are connected to the NX server.
+ *
+ * @return True is connected; false is not connected.
+ */
+
+ inline bool connected(void)
+ {
+#ifdef CONFIG_NX_MULTIUSER
+ return m_connected;
+#else
+ return true;
+#endif
+ }
+
+ /**
+ * Set the background color
+ */
+
+ inline bool setBackgroundColor(nxgl_mxpixel_t color)
+ {
+ return nx_setbgcolor(m_hNxServer, &color) == OK;
+ }
+
+ /**
+ * Get an instance of a raw NX window.
+ */
+
+ inline CNxWindow *createRawWindow(CWidgetControl *widgetControl)
+ {
+ return new CNxWindow(m_hNxServer, widgetControl);
+ }
+
+ /**
+ * Get an instance of the framed NX window.
+ */
+
+ inline CNxTkWindow *createFramedWindow(CWidgetControl *widgetControl)
+ {
+ return new CNxTkWindow(m_hNxServer, widgetControl);
+ }
+
+ /**
+ * Get an instance of the background window.
+ */
+
+ inline CBgWindow *getBgWindow(CWidgetControl *widgetControl)
+ {
+ return new CBgWindow(m_hNxServer, widgetControl);
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXSERVER_HXX
diff --git a/NxWidgets/libnxwidgets/include/cnxstring.hxx b/NxWidgets/libnxwidgets/include/cnxstring.hxx
new file mode 100644
index 000000000..91bd253c7
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxstring.hxx
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * include/cnxtring.hxx
+ * NxWidgets/libnxwidgets/
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CNXSTRING_HXX
+#define __INCLUDE_CNXSTRING_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CStringIterator;
+
+ /**
+ * Unicode string class. Uses 16-bt wide-character encoding. For optimal
+ * performance, use the CStringIterator class to iterate over a CNxString
+ * instance.
+ *
+ * Where possible, the string avoids allocating memory each time the
+ * string grows or shrinks. This means that the string may consume more
+ * memory than the number of chars would seem to dictate if the object
+ * previously contained a large string that has subsequently been truncated.
+ * It also means that increasing the length of such a string is a cheaper
+ * operation as memory does not need to allocated and copied.
+ *
+ * Additionally, the string increases its array size by m_growAmount every
+ * time it needs to allocate extra memory, potentially reducing the number
+ * of reallocs needed.
+ *
+ * The string is not null-terminated. Instead, it uses a m_stringLength
+ * member that stores the number of characters in the string. This saves a
+ * byte and makes calls to getLength() run in O(1) time instead of O(n).
+ */
+
+ class CNxString
+ {
+ private:
+ friend class CStringIterator;
+
+ int m_stringLength; /**< Number of characters in the string */
+ int m_allocatedSize; /**< Number of bytes allocated for this string */
+ int m_growAmount; /**< Number of chars that the string grows by
+ whenever it needs to get larger */
+
+
+ protected:
+ FAR nxwidget_char_t *m_text; /**< Raw char array data */
+
+ /**
+ * Allocate memory for the string.
+ *
+ * @param chars Number of chars to allocate.
+ * @param preserve If true, the data in the existing memory will be
+ * preserved if new memory must be allocated
+ */
+
+ void allocateMemory(int chars, bool preserve);
+
+ /**
+ * Check if we've got any string data stored or not.
+ *
+ * @return True if the string contains any data; false if no data has
+ * yet been supplied.
+ */
+
+ inline bool hasData(void) const
+ {
+ return m_stringLength > 0;
+ }
+
+ /**
+ * Get the amount of allocated memory.
+ *
+ * @return The number of chars allocated in RAM.
+ */
+
+ inline int getAllocatedSize(void) const
+ {
+ return m_allocatedSize;
+ }
+
+ /**
+ * Returns a pointer to the raw char array data.
+ *
+ * @return Pointer to the char array.
+ */
+
+ inline FAR const nxwidget_char_t *getCharArray(void) const
+ {
+ return m_text;
+ }
+
+ /**
+ * Return a pointer to the specified character.
+ *
+ * @param index Index of the character to retrieve.
+ */
+
+ FAR nxwidget_char_t *getCharPointer(const int index) const;
+
+ public:
+
+ /**
+ * Constructor to create an empty string object.
+ */
+
+ CNxString();
+
+ /**
+ * Constructor to create a string from a C character array.
+ *
+ * @param text Pointer to a char array to use as the basis of the
+ * string.
+ */
+
+ CNxString(FAR const char *text);
+
+ /**
+ * Constructor to create a string from a single character.
+ *
+ * @param letter Single character to use as the basis of the string.
+ */
+
+ CNxString(const nxwidget_char_t letter);
+
+ /**
+ * Copy constructor.
+ * @param string CNxString object to create a copy of.
+ */
+
+ CNxString(const CNxString &string);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CNxString()
+ {
+ delete[] m_text;
+ m_text = (FAR nxwidget_char_t *)NULL;
+ };
+
+ /**
+ * Creates and returns a new CStringIterator object that will iterate
+ * over this string. The object must be manually deleted once it is
+ * no longer needed.
+ *
+ * @return A new CStringIterator object.
+ */
+
+ CStringIterator *newStringIterator(void) const;
+
+ /**
+ * Copy the internal array to the supplied buffer. The buffer must be
+ * large enough to contain the full text in the string. The
+ * getByteCount() method can be used to obtain the length of the string.
+ * Unlike the CNxString class, the char array is null-terminated.
+ * The buffer must be (getByteCount() + 1) bytes long, in order to
+ * accommodate the terminator.
+ *
+ * @param buffer Buffer to copy the internal char array to.
+ */
+
+ void copyToCharArray(FAR nxwidget_char_t *buffer) const;
+
+ /**
+ * Set the text in the string.
+ *
+ * @param text CNxString containing the new data for this string.
+ */
+
+ void setText(const CNxString &text);
+
+ /**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+ void setText(FAR const char *text);
+
+ /**
+ * Set the nxwidget_char_t text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+ void setText(FAR const nxwidget_char_t *text, int nchars);
+
+ /**
+ * Set the 8-bit C-string text in the string.
+ *
+ * @param text Character to to use as the new data for this string.
+ */
+
+ void setText(const nxwidget_char_t text);
+
+ /**
+ * Append text to the end of the string.
+ *
+ * @param text String to append.
+ */
+
+ void append(const CNxString &text);
+
+ /**
+ * Insert text at the specified character index.
+ *
+ * @param text The text to insert.
+ * @param index The index at which to insert the text.
+ */
+
+ void insert(const CNxString &text, const int index);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+ void remove(const int startIndex);
+
+ /**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+ void remove(const int startIndex, const int count);
+
+ /**
+ * Get the of number of letters (ie. the length) of the string.
+ *
+ * @return The length of the string.
+ */
+
+ inline const int getLength(void) const
+ {
+ return m_stringLength;
+ };
+
+ /**
+ * Get the character at the specified index. This function is useful
+ * for finding the occasional character at an index, but for iterating
+ * over strings it is exceptionally slow. The newStringIterator()
+ * method should be used to retrieve an iterator object that can iterate
+ * over the string efficiently.
+ *
+ * @param index The index of the character to retrieve.
+ * @return The character at the specified index.
+ */
+
+ const nxwidget_char_t getCharAt(int index) const;
+
+ /**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found.
+ *
+ * @param letter Letter to find.
+ * @return The index of the letter.
+ */
+
+ const int indexOf(nxwidget_char_t letter) const;
+
+ /**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * from "startIndex" until it has examined all subsequent letters.
+ * @param letter Letter to find.
+ *
+ * @param startIndex The index to start searching from.
+ * @return The index of the letter.
+ */
+
+ const int indexOf(nxwidget_char_t letter, int startIndex) const;
+
+ /**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * from "startIndex" until it has examined all letters within the
+ * range "count".
+ *
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @param count The number of characters to examine.
+ * @return The index of the letter.
+ */
+
+ const int indexOf(nxwidget_char_t letter, int startIndex, int count) const;
+
+ /**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found.
+ *
+ * @param letter Letter to find.
+ * @return The index of the letter.
+ */
+
+ const int lastIndexOf(nxwidget_char_t letter) const;
+
+ /**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * backwards from "startIndex" until it has examined all preceding
+ * letters within the string.
+ *
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @return The index of the letter.
+ */
+
+ const int lastIndexOf(nxwidget_char_t letter, int startIndex) const;
+
+ /**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * backwards from "startIndex" until it has examined all letters within
+ * the range "count".
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @param count The number of characters to examine.
+ * @return The index of the letter.
+ */
+
+ const int lastIndexOf(nxwidget_char_t letter, int startIndex, int count) const;
+
+ /**
+ * Get a substring from this string. It is the responsibility of the
+ * caller to delete the substring when it is no longer required.
+ *
+ * @param startIndex The starting point of the substring.
+ * @return A pointer to a new CNxString object containing the
+ * substring.
+ */
+
+ CNxString *subString(int startIndex) const;
+
+ /**
+ * Get a substring from this string. It is the responsibility of the
+ * caller to delete the substring when it is no longer required.
+ *
+ * @param startIndex The starting point of the substring.
+ * @param length The length of the substring.
+ * @return A pointer to a new CNxString object containing the
+ * substring.
+ */
+
+ CNxString *subString(int startIndex, int length) const;
+
+ /**
+ * Overloaded assignment operator. Copies the data within the argument
+ * string to this string.
+ *
+ * @param string The string to copy.
+ * @return This string.
+ */
+
+ CNxString &operator=(const CNxString &string);
+
+ /**
+ * Overloaded assignment operator. Copies the data within the argument
+ * char array to this string.
+ *
+ * @param string The string to copy.
+ * @return This string.
+ */
+
+ CNxString &operator=(const char *string);
+
+ /**
+ * Overloaded assignment operator. Copies the data from the argument
+ * char to this string.
+ *
+ * @param letter The char to copy.
+ * @return This string.
+ */
+
+ CNxString& operator=(nxwidget_char_t letter);
+
+ /**
+ * Compares this string to the argument.
+ *
+ * @param string String to compare to.
+ * @return Zero if both strings are equal. A value greater than zero
+ * indicates that this string is greater than the argument string. A
+ * value less than zero indicates the opposite. Note that the return
+ * value indicates the *byte* that does not match, not the *character*.
+ */
+
+ int compareTo(const CNxString &string) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXSTRING_HXX
diff --git a/NxWidgets/libnxwidgets/include/cnxtimer.hxx b/NxWidgets/libnxwidgets/include/cnxtimer.hxx
new file mode 100644
index 000000000..be6038dac
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxtimer.hxx
@@ -0,0 +1,220 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxtimer.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CNXTIMER_HXX
+#define __INCLUDE_CNXTIMER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <ctime>
+
+#include "cnxwidget.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetcontrol;
+
+ /**
+ * Timer widget. It can drive time-based events, animations, etc.
+ *
+ * Using the timer is simple:
+ * - Create an instance of the CNxTimer and add it as a child to a widget.
+ * - Call the instance's "start()" method.
+ * - Catch the timer's action event and call any code that should run.
+ */
+
+ class CNxTimer : public CNxWidget
+ {
+ protected:
+ FAR timer_t m_timerid; /**< POSIX timer */
+ uint32_t m_timeout; /**< The timeout value in milliseconds */
+ bool m_isRunning; /**< Indicates whether or not the timer is running */
+ bool m_isRepeater; /**< Indicates whether or not the timer repeats */
+
+ /**
+ * The SIGALM signal handler that will be called when the timer goes off
+ *
+ * @param signo The signal number call caused the handler to run (SIGALM)
+ */
+
+ static void signalHandler(int signo);
+
+ /**
+ * Handle an expired timer
+ */
+
+ void handleTimerExpiration(void);
+
+ /**
+ * Convert a timespec to milliseconds
+ *
+ * @param tp The pointer to the timespec to convert
+ * @return The corresponding time in milliseconds
+ */
+
+ uint32_t timespecToMilliseconds(FAR const struct timespec *tp);
+
+ /**
+ * Convert milliseconds to a timespec
+ *
+ * @param milliseconds The milliseconds to be converted
+ * @param tp The pointer to the location to store the converted timespec
+ */
+
+ void millisecondsToTimespec(uint32_t milliseconds, FAR struct timespec *tp);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CNxTimer(const CNxTimer &timer) : CNxWidget(timer) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param timeout Time, in milliseconds, before the timer fires an
+ * EVENT_ACTION event.
+ * @param repeat If true, the timer will fire multiple events. If false,
+ * the timer will fire just once and stop.
+ */
+
+ CNxTimer(CWidgetControl *pWidgetControl, uint32_t timeout, bool repeat);
+
+ /**
+ * Destructor.
+ */
+
+ ~CNxTimer(void);
+
+ /**
+ * Return the time remaining on this timer.
+ *
+ * @return The number of milliseconds that this timer runs before
+ * firing an event. Zero is returned if the timer is not running.
+ */
+
+ const uint32_t getTimeout(void);
+
+ /**
+ * Resets the (running) timer to its initial timeout value. This
+ * call does nothing if the timer is not running.
+ */
+
+ void reset(void);
+
+ /**
+ * Starts the timer. This call does nothing if the timer is already
+ * running.
+ */
+
+ void start(void);
+
+ /**
+ * Stops the timer. Does nothing if the timer is not running.
+ */
+
+ void stop(void);
+
+ /**
+ * Set the timeout of this timer. This timeout value will not
+ * take effect until start() or reset() is called.
+ *
+ * @param timeout The number of milliseconds that this timer will run
+ * before firing an event.
+ */
+
+ inline void setTimeout(uint32_t timeout)
+ {
+ m_timeout = timeout;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXTIMER_HXX
diff --git a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx
new file mode 100644
index 000000000..16a0bee92
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx
@@ -0,0 +1,365 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxtkwindow.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_CNXTKWINDOW_HXX
+#define __INCLUDE_CNXTKWINDOW_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxtk.h>
+
+#include "ccallback.hxx"
+#include "inxwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxToolbar;
+ struct SBitmap;
+
+ /**
+ * This class defines operations on a framed NX window.
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class CNxTkWindow : protected CCallback, public INxWindow
+ {
+ protected:
+ NXHANDLE m_hNxServer; /**< Handle to the NX server. */
+ NXTKWINDOW m_hNxTkWindow; /**< Handle to the NX raw window */
+ CWidgetControl *m_widgetControl; /**< Controlling widget for the window */
+ CNxToolbar *m_toolbar; /**< Child toolbar */
+ nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */
+
+ public:
+
+ /**
+ * Constructor. Creates an uninitialized instance of the CNxTkWindow
+ * object. The open() method must be called to initialize the instance.
+ *
+ * The general steps to create any window include:
+ * 1) Create a dumb CWigetControl instance
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow.
+ * 3) The window constructor call CWidgetControl methods to "smarten"
+ * the CWidgetControl instance with window-specific knowledge.
+ * 4) Call the open() method on the window to display the window.
+ * 5) After that, the fully smartened CWidgetControl instance can
+ * be used to generate additional widgets.
+ * 6) After that, the fully smartened CWidgetControl instance can
+ * be used to generate additional widgets by passing it to the
+ * widget constructor
+ *
+ * @param hNxServer Handle to the NX server.
+ * @param widgetControl Controlling widget for this window.
+ */
+
+ CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl);
+
+ /**
+ * Destructor.
+ */
+
+ ~CNxTkWindow(void);
+
+ /**
+ * Creates a new window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully opened.
+ */
+
+ bool open(void);
+
+ /**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+ CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Open a toolbar on the framed window. This method both instantiates
+ * the toolbar object AND calls the INxWindow::open() method to
+ * create the toolbar. The toolbar is ready for use upon return.
+ *
+ * @param height. The height in rows of the tool bar
+ * @param widgetControl. The controlling widget for this window. If
+ * none is provided, then a new, vanilla CWidgetControl will be created
+ * for the tool bar.
+ * @return True if the toolbar was successfully created.
+ */
+
+ CNxToolbar *openToolbar(nxgl_coord_t height,
+ CWidgetControl *widgetControl = (CWidgetControl *)0);
+
+ /**
+ * Detach the toolbar. This should *ONLY* be called by the toolbar
+ * instance itself. If this is called by end-user logic, it will
+ * screw things up miserably.
+ */
+
+ inline void detachToolbar(void)
+ {
+ m_toolbar = (CNxToolbar *)NULL;
+ m_toolbarHeight = 0;
+ }
+
+ /**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool requestPosition(void);
+
+ /**
+ * Get the position of the window (as reported by the NX callback).
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool getPosition(FAR struct nxgl_point_s *pos);
+
+ /**
+ * Get the size of the window (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+ bool getSize(FAR struct nxgl_size_s *size);
+
+ /**
+ * Set the position and size of the window.
+ *
+ * @param pos The new position of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setPosition(FAR const struct nxgl_point_s *pos);
+
+ /**
+ * Set the size of the selected window.
+ *
+ * @param size The new size of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setSize(FAR const struct nxgl_size_s *size);
+
+ /**
+ * Bring the window to the top of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool raise(void);
+
+ /**
+ * Lower the window to the bottom of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool lower(void);
+
+ /**
+ * Each window implementation also inherits from CCallback. CCallback,
+ * by default, forwards NX keyboard input to the various widgets residing
+ * in the window. But NxConsole is a different usage model; In this case,
+ * keyboard input needs to be directed to the NxConsole character driver.
+ * This method can be used to enable (or disable) redirection of NX
+ * keyboard input from the window widgets to the NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ inline void redirectNxConsole(NXCONSOLE handle)
+ {
+ setNxConsole(handle);
+ }
+#endif
+
+ /**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool setPixel(FAR const struct nxgl_point_s *pos,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+ void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
+
+ /**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset);
+
+ /**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXTKWINDOW_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx
new file mode 100644
index 000000000..69a004da5
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx
@@ -0,0 +1,334 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxtoolbar.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_CNXTOOLBAR_HXX
+#define __INCLUDE_CNXTOOLBAR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxtk.h>
+
+#include "ccallback.hxx"
+#include "inxwindow.hxx"
+#include "cnxtkwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+ struct SBitmap;
+
+ /**
+ * This class defines operations on a the toolbar in a framed NX window.
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class CNxToolbar : protected CCallback, public INxWindow
+ {
+ private:
+ CNxTkWindow *m_nxTkWindow; /**< Parent framed window instance. */
+ NXTKWINDOW m_hNxTkWindow; /**< Parent framed window handle. */
+ CWidgetControl *m_widgetControl; /**< Controlling widget for the toolbar */
+ nxgl_coord_t m_height; /**< The toolbar height */
+
+ public:
+
+ /**
+ * Constructor. Creates an uninitialized instance of the CNxToolbar
+ * object. The open() method must be called to initialize the instance.
+ *
+ * @param pNxTkWindow Parent framed window instance
+ * @param hNxTkWindow Parent framed window NX handler
+ * @param widgetControl Controlling widget for this toolbar.
+ * @param height The height of the toolbar.
+ */
+
+ CNxToolbar(CNxTkWindow *pNxTkWindow, NXTKWINDOW hNxTkWindow,
+ CWidgetControl *pWidgetControl, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ ~CNxToolbar(void);
+
+ /**
+ * Creates a new toolbar. Toolbar creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the toolbar was successfully created.
+ */
+
+ bool open(void);
+
+ /**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+ CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Request the position and size information of the toolbar. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool requestPosition(void);
+
+ /**
+ * Get the position of the toolbar (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+ bool getPosition(FAR struct nxgl_point_s *pPos);
+
+ /**
+ * Get the size of the toolbar (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+ bool getSize(FAR struct nxgl_size_s *pSize);
+
+ /**
+ * Set the position and size of the toolbar. The position of
+ * the toolbar is fixed at the top of the parent framed window.
+ *
+ * @param pPos The new position of the toolbar.
+ * @return Always returns false.
+ */
+
+ bool setPosition(FAR const struct nxgl_point_s *pPos);
+
+ /**
+ * Set the position and size of the toolbar. The position of
+ * the toolbar is fixed at the top of the parent framed window.
+ *
+ * @param pPos The new position of the toolbar.
+ * @return Always returns false.
+ */
+
+ bool setSize(FAR const struct nxgl_size_s *pSize);
+
+ /**
+ * Bring the toolbar to the top of the display. The toolbar is
+ * a component of the containing, parent, framed window. It
+ * cannot be raised separately.
+ *
+ * @return Always returns false.
+ */
+
+ bool raise(void);
+
+ /**
+ * Lower the toolbar to the bottom of the display. The toolbar is
+ * a component of the containing, parent, framed window. It
+ * cannot be lowered separately.
+ *
+ * @return Always returns false.
+ */
+
+ bool lower(void);
+
+ /**
+ * Each window implementation also inherits from CCallback. CCallback,
+ * by default, forwards NX keyboard input to the various widgets residing
+ * in the window. But NxConsole is a different usage model; In this case,
+ * keyboard input needs to be directed to the NxConsole character driver.
+ * This method can be used to enable (or disable) redirection of NX
+ * keyboard input from the window widgets to the NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ inline void redirectNxConsole(NXCONSOLE handle)
+ {
+ setNxConsole(handle);
+ }
+#endif
+
+ /**
+ * Set an individual pixel in the toolbar with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified rectangle in the toolbar with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+ void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
+
+ /**
+ * Fill the specified trapezoidal region in the toolbar with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to toolbar (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified line in the toolbar with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Move a rectangular region within the toolbar.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset);
+
+ /**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified toolbar.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in toolbar coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXTOOLBAR_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx
new file mode 100644
index 000000000..2ca055c1c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx
@@ -0,0 +1,1336 @@
+/****************************************************************************
+ * include/cnxwidget.hxx
+ * NxWidgets/libnxwidgets/
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CNXWIDGET_HXX
+#define __INCLUDE_CNXWIDGET_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <ctime>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxstring.hxx"
+#include "cnxfont.hxx"
+#include "crect.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgeteventargs.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgeteventhandlerlist.hxx"
+#include "tnxarray.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CGraphicsPort;
+ class CNxFont;
+ class CWidgetEventHandlerList;
+
+ /**
+ * Class providing all the basic functionality of a NxWidget. All other
+ * widgets must must inherit from this class.
+ */
+
+ class CNxWidget
+ {
+ public:
+
+ /**
+ * Enum listing flags that can be set in the constructor's "flags" parameter.
+ */
+
+ enum WidgetFlagType
+ {
+ WIDGET_BORDERLESS = 0x0001, /**< Widget has no border */
+ WIDGET_DRAGGABLE = 0x0002, /**< Widget can be dragged by the user */
+ WIDGET_PERMEABLE = 0x0004, /**< Widget's children can exceed this widget's edges */
+ WIDGET_DOUBLE_CLICKABLE = 0x0008, /**< Widget can be double-clicked */
+ WIDGET_NO_RAISE_EVENTS = 0x0010, /**< Widget does not raise events */
+ };
+
+ /**
+ * Struct describing some basic properties of a widget.
+ */
+
+ typedef struct
+ {
+ uint8_t clicked : 1; /**< True if the widget is currently clicked. */
+ uint8_t hasFocus : 1; /**< True if the widget has focus. */
+ uint8_t dragging : 1; /**< True if the widget is being dragged. */
+ uint8_t deleted : 1; /**< True if the widget has been deleted. */
+ uint8_t borderless : 1; /**< True if the widget is borderless. */
+ uint8_t draggable : 1; /**< True if the widget can be dragged. */
+ uint8_t drawingEnabled : 1; /**< True if the widget can be drawn. */
+ uint8_t enabled : 1; /**< True if the widget is enabled. */
+ uint8_t permeable : 1; /**< True if the widget's children can exceed its dimensions. */
+ uint8_t erased : 1; /**< True if the widget is currently erased from the frame buffer. */
+ uint8_t visibleRegionCacheInvalid : 1; /**< True if the region cache is invalid. */
+ uint8_t hidden : 1; /**< True if the widget is hidden. */
+ uint8_t doubleClickable : 1; /**< True if the widget can be double-clicked. */
+ } Flags;
+
+ /**
+ * Struct describing the size of all four borders of a widget.
+ */
+
+ typedef struct
+ {
+ uint8_t top; /**< Height of the top border. */
+ uint8_t right; /**< Width of the right border. */
+ uint8_t bottom; /**< Height of the bottom border. */
+ uint8_t left; /**< Width of the left border. */
+ } WidgetBorderSize;
+
+ protected:
+ CWidgetControl *m_widgetControl; /**< The controlling widget for the display */
+ CRect m_rect; /**< Rectange bounding the widget. */
+
+ // Dragging variables
+
+ nxgl_coord_t m_grabPointX; /**< Physical space x coordinate where dragging began. */
+ nxgl_coord_t m_grabPointY; /**< Physical space y coordinate where dragging began. */
+ nxgl_coord_t m_newX; /**< Physical x coordinate where widget is being dragged to. */
+ nxgl_coord_t m_newY; /**< Physical y coordinate where widget is being dragged to. */
+
+ // Style
+
+ CWidgetStyle m_style; /**< All style information used by a widget. */
+
+ // Status
+
+ Flags m_flags; /**< Flags struct. */
+
+ // Event handling
+
+ CWidgetEventHandlerList *m_widgetEventHandlers; /**< List of event handlers. */
+
+ // Double-clicking
+
+ struct timespec m_lastClickTime; /**< System timer when last clicked. */
+ nxgl_coord_t m_lastClickX; /**< X coordinate of last click. */
+ nxgl_coord_t m_lastClickY; /**< Y coordinate of last click. */
+ int m_doubleClickBounds; /**< Area in which a click is assumed to be a double-click. */
+
+ // Hierarchy control
+
+ CNxWidget *m_parent; /**< Pointer to the widget's parent. */
+ CNxWidget *m_focusedChild; /**< Pointer to the child widget that has focus. */
+ TNxArray<CNxWidget*> m_children; /**< List of child widgets. */
+
+ // Borders
+
+ WidgetBorderSize m_borderSize; /**< Size of the widget borders. */
+
+ /**
+ * Use the provided widget style
+ */
+
+ void useWidgetStyle(const CWidgetStyle *style);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw().
+ */
+
+ virtual inline void drawContents(CGraphicsPort* port) { }
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw().
+ */
+
+ virtual void drawBorder(CGraphicsPort* port) { }
+
+ /**
+ * Draw all visible regions of this widget's children.
+ */
+
+ void drawChildren(void);
+
+ /**
+ * Erase and remove the supplied child widget from this widget and
+ * send it to the deletion queue.
+ *
+ * @param widget The widget to close.
+ * @see close().
+ */
+
+ void closeChild(CNxWidget *widget);
+
+ /**
+ * Notify this widget that it is being dragged, and set its drag point.
+ *
+ * @param x The x coordinate of the drag position relative to this widget.
+ * @param y The y coordinate of the drag position relative to this widget.
+ */
+
+ void startDragging(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Notify this widget that it is no longer being dragged.
+ */
+
+ void stopDragging(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CNxWidget(const CNxWidget &widget) { }
+
+ /**
+ * Called when the widget is clicked. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when it is
+ * clicked.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual inline void onClick(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Called when the widget is double-clicked. Override this when
+ * creating new widgets if the widget should exhibit additional
+ * behaviour when it is double-clicked. To change the conditions that
+ * apply in detecting a double-click, override the isDoubleClicked()
+ * method.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual inline void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Called just before the widget is released; the widget will be in the
+ * clicked stated. Override this when creating new widgets if the
+ * widget should exhibit additional behaviour when it is released.
+ *
+ * @param x The x coordinate of the mouse when released.
+ * @param y The y coordinate of the mouse when released.
+ */
+
+ virtual inline void onPreRelease(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Called just after the widget is released; the widget will be in the
+ * released stated. Override this when creating new widgets if the
+ * widget should exhibit additional behaviour when it is released.
+ *
+ * @param x The x coordinate of the mouse when released.
+ * @param y The y coordinate of the mouse when released.
+ */
+
+ virtual inline void onRelease(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Called when the widget is released outside of its boundaries.
+ * Override this when creating new widgets if the widget should exhibit
+ * additional behaviour when it is released outside of its boundaries.
+ *
+ * @param x The x coordinate of the mouse when released.
+ * @param y The y coordinate of the mouse when released.
+ */
+
+ virtual inline void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Called when the widget is dragged. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when it is
+ * dragged.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX X distance dragged.
+ * @param vY Y distance dragged.
+ */
+
+ virtual inline void onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY) { }
+
+ /**
+ * Called when the widget starts being dragged. Override this when
+ * creating new widgets if the widget should exhibit additional
+ * behaviour when dragging starts.
+ */
+
+ virtual inline void onDragStart(void) { }
+
+ /**
+ * Called when the widget stops being dragged. Override this when
+ * creating new widgets if the widget should exhibit additional
+ * behaviour when dragging stops.
+ */
+
+ virtual inline void onDragStop(void) { }
+
+ /**
+ * Called when the widget gains focus. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when
+ * gaining focus.
+ */
+
+ virtual inline void onFocus(void) { }
+
+ /**
+ * Called when the widget loses focus. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when
+ * losing focus.
+ */
+
+ virtual inline void onBlur(void) { }
+
+ /**
+ * Called when the widget is enabled. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when
+ * enabled.
+ */
+
+ virtual inline void onEnable(void) { }
+
+ /**
+ * Called when the widget is disabled. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when
+ * disabled.
+ */
+
+ virtual inline void onDisable(void) { }
+
+ /**
+ * Called when the widget is resized. Override this when creating new
+ * widgets if the widget should exhibit additional behaviour when
+ * resized.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual inline void onResize(nxgl_coord_t width, nxgl_coord_t height) { }
+
+ public:
+
+ /**
+ * CNxWidget constructor.
+ *
+ * @param pWidgetControl The controllwing widget for the display
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags Bitmask specifying some set-up values for the widget.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ * @see WidgetFlagType.
+ */
+
+ CNxWidget(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags,
+ FAR const CWidgetStyle *style = (FAR const CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CNxWidget(void);
+
+ /**
+ * Get the x coordinate of the widget in "Widget space".
+ *
+ * @return Widget space x coordinate.
+ */
+
+ nxgl_coord_t getX(void) const;
+
+ /**
+ * Get the y coordinate of the widget in "Widget space".
+ *
+ * @return Widget space y coordinate.
+ */
+
+ nxgl_coord_t getY(void) const;
+
+ /**
+ * Get the x coordinate of the widget relative to its parent.
+ *
+ * @return Parent-space x coordinate.
+ */
+
+ nxgl_coord_t getRelativeX(void) const;
+
+ /**
+ * Get the y coordinate of the widget relative to its parent.
+ *
+ * @return Parent-space y coordinate.
+ */
+
+ nxgl_coord_t getRelativeY(void) const;
+
+ /**
+ * Is the widget active?
+ * A value of true indicates that this widget has focus or is an ancestor
+ * of the widget with focus.
+ *
+ * @return True if active.
+ */
+
+ inline bool hasFocus(void) const
+ {
+ return m_flags.hasFocus;
+ }
+
+ /**
+ * Has the widget been marked for deletion? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are not deleted.
+ *
+ * Widgets marked for deletion are automatically deleted and should not be
+ * interacted with.
+ *
+ * @return True if marked for deletion.
+ */
+
+ bool isDeleted(void) const;
+
+ /**
+ * Is the widget allowed to draw? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are visible.
+ *
+ * @return True if drawing is enabled.
+ */
+
+ bool isDrawingEnabled(void) const;
+
+ /**
+ * Is the widget hidden? This function recurses up the widget
+ * hierarchy and returns true if any of the widgets in the ancestor
+ * chain are hidden.
+ *
+ * @return True if hidden.
+ */
+
+ bool isHidden(void) const;
+
+ /**
+ * Is the widget enabled? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are enabled.
+ *
+ * @return True if enabled.
+ */
+
+ bool isEnabled(void) const;
+
+ /**
+ * Are the widget's edges permeable or solid?
+ * Permeable widgets do not enforce their dimensions on the
+ * coordinates and dimensions of child widgets.
+ *
+ * @return True if permeable.
+ */
+
+ inline bool isPermeable(void) const
+ {
+ return m_flags.permeable;
+ }
+
+ /**
+ * IS the widget double-clickable?
+ * @return True if the widget watches for double-clicks.
+ */
+
+ inline bool isDoubleClickable(void) const
+ {
+ return m_flags.doubleClickable;
+ }
+
+ /**
+ * Does the widget have a border?
+ *
+ * @return True if the widget does not have a border.
+ */
+
+ inline bool isBorderless(void) const
+ {
+ return m_flags.borderless;
+ }
+
+ /**
+ * Is the widget clicked?
+ *
+ * @return True if the widget is currently clicked.
+ */
+
+ inline bool isClicked(void) const
+ {
+ return m_flags.clicked;
+ }
+
+ /**
+ * Is the widget being dragged?
+ *
+ * @return True if the widget is currently being dragged.
+ */
+
+ inline bool isBeingDragged(void) const
+ {
+ return m_flags.dragging;
+ }
+
+ /**
+ * Get the width of the widget.
+ *
+ * @return The widget width.
+ */
+
+ inline nxgl_coord_t getWidth(void) const
+ {
+ return m_rect.getWidth();
+ }
+
+ /**
+ * Get the height of the widget.
+ *
+ * @return The widget height.
+ */
+
+ inline nxgl_coord_t getHeight(void) const
+ {
+ return m_rect.getHeight();
+ }
+
+ /**
+ * Get the size of the widget
+ *
+ * @return The widgets's size
+ */
+
+ inline void getSize(struct nxgl_size_s &size) const
+ {
+ size.h = m_rect.getHeight();
+ size.w = m_rect.getWidth();
+ }
+
+ /**
+ * Get the position of the widget
+ *
+ * @return The widgets's position
+ */
+
+ inline void getPos(struct nxgl_point_s &pos) const
+ {
+ pos.x = m_rect.getX();
+ pos.y = m_rect.getY();
+ }
+
+ /**
+ * Get the window bounding box in physical display coordinated.
+ *
+ * @return This function returns the window handle.
+ */
+
+ inline CRect getBoundingBox(void)
+ {
+ return CRect(m_rect);
+ }
+
+ /**
+ * Get the dimensions of the border
+ *
+ */
+
+ inline void getBorderSize(WidgetBorderSize &borderSize)
+ {
+ borderSize.top = m_borderSize.top;
+ borderSize.left = m_borderSize.left;
+ borderSize.bottom = m_borderSize.bottom;
+ borderSize.right = m_borderSize.right;
+ }
+
+ /**
+ * Get a pointer to this widget's parent.
+ *
+ * @return This widget's parent.
+ */
+
+ inline CNxWidget *getParent(void) const
+ {
+ return m_parent;
+ }
+
+ /**
+ * Get a pointer to this widget's focused child.
+ *
+ * @return This widget's focused child.
+ */
+
+ inline CNxWidget *getFocusedWidget(void)
+ {
+ return m_focusedChild;
+ }
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Insert the properties of the space within this widget that is
+ * available for children into the rect passed in as a parameter.
+ * All coordinates are relative to this widget.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ void getClientRect(CRect &rect) const;
+
+ /**
+ * Insert the properties of the space within this widget that is
+ * available for children into the rect passed in as a parameter.
+ * Identical to getClientRect() except that all coordinates are
+ * absolute positions within the window.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ void getRect(CRect &rect) const;
+
+ /**
+ * Gets a pointer to the widget's font.
+ *
+ * @return A pointer to the widget's font.
+ */
+
+ inline CNxFont *getFont(void) const
+ {
+ return m_style.font;
+ }
+
+ /**
+ * Gets the color used for the normal background fill.
+ *
+ * @return Background fill color.
+ */
+
+ inline nxgl_mxpixel_t getBackgroundColor(void) const
+ {
+ return m_style.colors.background;
+ }
+
+ /**
+ * Gets the color used for the background fill when the widget is selected.
+ *
+ * @return Dark color.
+ */
+
+ inline nxgl_mxpixel_t getSelectedBackgroundColor(void) const
+ {
+ return m_style.colors.selectedBackground;
+ }
+
+ /**
+ * Gets the color used as the light edge in bevelled boxes.
+ *
+ * @return Shine color.
+ */
+
+ inline nxgl_mxpixel_t getShineEdgeColor(void) const
+ {
+ return m_style.colors.shineEdge;
+ }
+
+ /**
+ * Gets the color used as the dark edge in bevelled boxes.
+ *
+ * @return Shadow color.
+ */
+
+ inline nxgl_mxpixel_t getShadowEdgeColor(void) const
+ {
+ return m_style.colors.shadowEdge;
+ }
+
+ /**
+ * Gets the color used as the fill in focused window borders.
+ *
+ * @return Highlight color.
+ */
+
+ inline nxgl_mxpixel_t getHighlightColor(void) const
+ {
+ return m_style.colors.highlight;
+ }
+
+ /**
+ * Gets the color used for text in a disabled widget.
+ *
+ * @return Disabled text color.
+ */
+
+ inline nxgl_mxpixel_t getDisabledTextColor(void) const
+ {
+ return m_style.colors.disabledText;
+ }
+
+ /**
+ * Gets the color used for text in a enabled widget.
+ *
+ * @return Enabled text color.
+ */
+
+ inline nxgl_mxpixel_t getEnabledTextColor(void) const
+ {
+ return m_style.colors.enabledText;
+ }
+
+ /**
+ * Gets the color used for text in a clicked widget.
+ *
+ * @return Selected text color.
+ */
+
+ inline nxgl_mxpixel_t getSelectedTextColor(void) const
+ {
+ return m_style.colors.selectedText;
+ }
+
+ /**
+ * Sets this widget's border state.
+ *
+ * @param isBorderless The border state.
+ */
+
+ void setBorderless(bool isBorderless);
+
+ /**
+ * Sets whether or not this widget can be dragged.
+ *
+ * @param isDraggable The draggable state.
+ */
+
+ inline void setDraggable(bool isDraggable)
+ {
+ m_flags.draggable = isDraggable;
+ }
+
+ /**
+ * Sets whether or not child widgets can exceed this widget's dimensions.
+ *
+ * @param permeable The permeable state.
+ */
+
+ inline void setPermeable(bool permeable)
+ {
+ m_flags.permeable = permeable;
+ }
+
+ /**
+ * Sets whether or not the widgets processes double-clicks.
+ *
+ * @param doubleClickable The double-clickable state.
+ */
+
+ inline void setDoubleClickable(bool doubleClickable)
+ {
+ m_flags.doubleClickable = doubleClickable;
+ }
+
+ /**
+ * Adds a widget event handler. The event handler will receive
+ * all events raised by this widget.
+ *
+ * @param eventHandler A pointer to the event handler.
+ */
+
+ inline void addWidgetEventHandler(CWidgetEventHandler *eventHandler)
+ {
+ m_widgetEventHandlers->addWidgetEventHandler(eventHandler);
+ }
+
+ /**
+ * Remove a widget event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+ inline void removeWidgetEventHandler(CWidgetEventHandler* eventHandler)
+ {
+ m_widgetEventHandlers->removeWidgetEventHandler(eventHandler);
+ }
+
+ /**
+ * Enables or disables event firing for this widget.
+ *
+ * @param raises True to enable events, false to disable.
+ */
+
+ inline void setRaisesEvents(bool raises)
+ {
+ raises ? m_widgetEventHandlers->enable() : m_widgetEventHandlers->disable();
+ }
+
+ /**
+ * Check if event handling is enabled for this widget.
+ *
+ * @return True is event handling is enabled.
+ */
+
+ inline bool raisesEvents(void) const
+ {
+ return m_widgetEventHandlers->isEnabled();
+ }
+
+ /**
+ * Disabled drawing of this widget. Widgets hidden using this method will still
+ * be processed.
+ */
+
+ inline void disableDrawing(void)
+ {
+ m_flags.drawingEnabled = false;
+ }
+
+ /**
+ * Enables drawing of this widget.
+ */
+
+ inline void enableDrawing(void)
+ {
+ m_flags.drawingEnabled = true;
+ }
+
+ /**
+ * Sets the normal background color.
+ *
+ * @param color The new background color.
+ */
+
+ inline void setBackgroundColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.background = color;
+ }
+
+ /**
+ * Sets the background color for a selected widget.
+ *
+ * @param color The new selected background color.
+ */
+
+ inline void setSelectedBackgroundColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.selectedBackground = color;
+ }
+
+ /**
+ * Sets the shiny edge color.
+ *
+ * @param color The new shine edge color.
+ */
+
+ inline void setShineEdgeColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.shineEdge = color;
+ }
+
+ /**
+ * Sets the shadow edge color.
+ *
+ * @param color The new shadow edge color.
+ */
+
+ inline void setShadowEdgeColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.shadowEdge = color;
+ }
+
+ /**
+ * Sets the highlight color.
+ *
+ * @param color The new highlight color.
+ */
+
+ inline void setHighlightColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.highlight = color;
+ }
+
+ /**
+ * Sets the text color to use when the widget is disabled.
+ *
+ * @param color The new text color.
+ */
+
+ inline void setDisabledTextColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.disabledText = color;
+ }
+
+ /**
+ * Sets the text color to use when the widget is enabled.
+ *
+ * @param color The new text color.
+ */
+
+ inline void setEnabledTextColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.enabledText = color;
+ }
+
+ /**
+ * Sets the text color to use when the widget is highlighted or clicked.
+ *
+ * @param color The new selected text color.
+ */
+
+ inline void setSelectedTextColor(nxgl_mxpixel_t color)
+ {
+ m_style.colors.selectedText = color;
+ }
+
+ /**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+ virtual void setFont(CNxFont *font);
+
+ /**
+ * Draws the visible regions of the widget and the widget's child widgets.
+ */
+
+ void redraw(void);
+
+ /**
+ * Enables the widget.
+ *
+ * @return True if the widget was enabled.
+ */
+
+ bool enable(void);
+
+ /**
+ * Disabled the widget.
+ *
+ * @return True if the widget was disabled.
+ */
+
+ bool disable(void);
+
+ /**
+ * Erases the widget, marks it as deleted, and moves it to the CNxWidget
+ * deletion queue. Widgets are automatically deleted by the framework and
+ * should not be deleted externally.
+ */
+
+ void close(void);
+
+ /**
+ * Draws the widget and makes it visible.
+ * Does not steal focus from other widgets.
+ *
+ * @return True if the widget was shown.
+ * @see hide()
+ */
+
+ bool show(void);
+
+ /**
+ * Erases the widget and makes it invisible.
+ * Does not re-assign focus to another widget.
+ *
+ * @return True if the widget was hidden.
+ * @see show()
+ */
+
+ bool hide(void);
+
+ /**
+ * Click this widget at the supplied coordinates. This should only be
+ * overridden in subclasses if the default click behaviour needs to be changed.
+ * If the subclassed widget should just respond to a standard click,
+ * the onClick() method should be overridden instead.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click was successful.
+ */
+
+ bool click(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Check if the click is a double-click.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click is a double-click.
+ */
+
+ virtual bool isDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Double-click this widget at the supplied coordinates. This
+ * should only be overridden in subclasses if the default
+ * double-click behaviour needs to be changed. If the subclassed
+ * widget should just respond to a standard double-click, the
+ * onDoubleClick() method should be overridden instead.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click was successful.
+ */
+
+ bool doubleClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Release this widget at the supplied coordinates. This
+ * should only be overridden in subclasses if the default
+ * release behaviour needs to be changed. If the subclassed
+ * widget should just respond to a standard release, the
+ * onRelease() method should be overridden instead.
+ *
+ * @param x X coordinate of the release.
+ * @param y Y coordinate of the release.
+ * @return True if the release was successful.
+ */
+
+ bool release(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Drag the widget to the supplied coordinates.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance that the mouse was dragged.
+ * @param vY The vertical distance that the mouse was dragged.
+ * @return True if the drag was successful.
+ */
+
+ bool drag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Send a keypress to the widget.
+ *
+ * @param key The keycode to send to the widget.
+ * @return True if the keypress was processed.
+ */
+
+ bool keyPress(nxwidget_char_t key);
+
+ /**
+ * Send a cursor control event to the widget.
+ *
+ * @param control The cursor control code to send to the widget.
+ * @return True if the cursor control was processed.
+ */
+
+ bool cursorControl(ECursorControl control);
+
+ /**
+ * Give the widget focus.
+ *
+ * @return True if the widget received focus correctly.
+ */
+
+ bool focus(void);
+
+ /**
+ * Remove focus from the widget.
+ *
+ * @return True if the widget lost focus correctly.
+ */
+
+ bool blur(void);
+
+ /**
+ * Move the widget to the new coordinates.
+ * Co-ordinates are relative to the parent widget.
+ *
+ * @param x The new x coordinate.
+ * @param y The new y coordinate.
+ * @return True if the move was successful.
+ */
+
+ bool moveTo(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Resize the widget to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ * @return True if the resize was successful.
+ */
+
+ bool resize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Resize and move the widget in one operation.
+ * Only performs one redraw so it is faster than calling the
+ * two separate functions.
+ *
+ * @param x The new x coordinate.
+ * @param y The new y coordinate.
+ * @param width The new width.
+ * @param height The new height.
+ * @return True if the widget was adjusted successfully.
+ */
+
+ bool changeDimensions(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Moves the supplied child widget to the deletion queue.
+ * For framework use only.
+ *
+ * @param widget A pointer to the child widget.
+ */
+
+ void moveChildToDeleteQueue(CNxWidget *widget);
+
+ /**
+ * Sets the supplied widget as the focused child. The widget must
+ * be a child of this widget.
+ *
+ * @param widget A pointer to the child widget.
+ * @see getFocusedWidget()
+ */
+
+ void setFocusedWidget(CNxWidget *widget);
+
+ /**
+ * Checks if the supplied coordinates collide with this widget.
+ *
+ * @param x The x coordinate to check.
+ * @param y The y coordinate to check.
+ * @return True if a collision occurred.
+ */
+
+ bool checkCollision(nxgl_coord_t x, nxgl_coord_t y) const;
+
+ /**
+ * Checks if the supplied rectangle definition collides with this widget.
+ *
+ * @param x The x coordinate of the rectangle to check.
+ * @param y The y coordinate of the rectangle to check.
+ * @param width The width of the rectangle to check.
+ * @param height The height of the rectangle to check.
+ * @return True if a collision occurred.
+ */
+
+ bool checkCollision(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height) const;
+
+ /**
+ * Checks if the supplied widget collides with this widget.
+ *
+ * @param widget A pointer to another widget to check for collisions with.
+ * @return True if a collision occurred.
+ */
+
+ bool checkCollision(CNxWidget *widget) const;
+
+ /**
+ * Adds a widget to this widget's child stack. The widget is added to the
+ * top of the stack. Note that the widget can only be added if it is not
+ * already a child of another widget.
+ *
+ * @param widget A pointer to the widget to add to the child list.
+ * @see insertWidget()
+ */
+
+ void addWidget(CNxWidget *widget);
+
+ /**
+ * Inserts a widget into this widget's child stack at the bottom of the
+ * stack. Note that the widget can only be added if it is not already
+ * a child of another widget.
+ *
+ * @param widget A pointer to the widget to add to the child list.
+ * @see addWidget()
+ */
+
+ void insertWidget(CNxWidget *widget);
+
+ /**
+ * Set the widget's parent to the widget passed in as a parameter.
+ * Called automatically when a widget is added as a child.
+ *
+ * @param parent A pointer to the parent widget.
+ */
+
+ inline void setParent(CNxWidget *parent)
+ {
+ m_parent = parent;
+ }
+
+ /**
+ * Delete this widget. This should never be called in user code; widget
+ * deletion is handled internally.
+ */
+
+ inline void destroy(void)
+ {
+ delete this;
+ }
+
+ /**
+ * Remove this widget from the widget hierarchy. Returns
+ * responsibility for deleting the widget back to the developer.
+ * Does not unregister the widget from the VBL system.
+ * Does not erase the widget from the display.
+ *
+ * @return True if the widget was successfully removed.
+ */
+
+ bool remove(void);
+
+ /**
+ * Remove a child widget from the widget hierarchy. Returns
+ * responsibility for deleting the widget back to the developer.
+ * Does not unregister the widget from the VBL system.
+ * Does not erase the widget from the display.
+ *
+ * @param widget Pointer to the widget to remove from the hierarchy.
+ * @return True if the widget was succesfully removed.
+ */
+
+ bool removeChild(CNxWidget *widget);
+
+ /**
+ * Get the child widget at the specified index.
+ *
+ * @param index Index of the child to retrieve.
+ * @return Pointer to the child at the specified index.
+ */
+
+ const CNxWidget *getChild(int index) const;
+
+ /**
+ * Get the number of child widgets.
+ *
+ * @return The number of child widgets belonging to this widget.
+ */
+
+ int getChildCount(void) const
+ {
+ return m_children.size();
+ }
+
+ /**
+ * Sets the border size. The border cannot be drawn over in the
+ * drawContents() method.
+ *
+ * @param borderSize The new border size.
+ */
+
+ void setBorderSize(const WidgetBorderSize &borderSize);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXWIDGET_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cnxwindow.hxx b/NxWidgets/libnxwidgets/include/cnxwindow.hxx
new file mode 100644
index 000000000..50822cc83
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cnxwindow.hxx
@@ -0,0 +1,337 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cnxwindow.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_CNXWINDOW_HXX
+#define __INCLUDE_CNXWINDOW_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxtk.h>
+
+#include "ccallback.hxx"
+#include "inxwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ struct SBitmap;
+
+ /**
+ * This class defines operations on a basic "raw" NX window. These windows
+ * are "raw" in the since that they are simply rectangular regions with
+ * no framing or decoration of any kind
+ *
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class CNxWindow : protected CCallback, public INxWindow
+ {
+ private:
+ NXHANDLE m_hNxServer; /**< Handle to the NX server. */
+ NXWINDOW m_hNxWindow; /**< Handle to the NX raw window */
+ CWidgetControl *m_widgetControl; /**< The controlling widget for the window */
+
+ public:
+
+ /**
+ * Constructor. Creates an uninitialized instance of the CNxWindow
+ * object. The open() method must be called to initialize the instance.
+ *
+ * The general steps to create any window include:
+ * 1) Create a dumb CWigetControl instance
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow.
+ * 3) The window constructor call CWidgetControl methods to "smarten"
+ * the CWidgetControl instance with window-specific knowledge.
+ * 4) Call the open() method on the window to display the window.
+ * 5) After that, the fully smartend CWidgetControl instance can
+ * be used to generate additional widgets.
+ * 6) After that, the fully smartened CWidgetControl instance can
+ * be used to generate additional widgets by passing it to the
+ * widget constructor
+ *
+ * @param hNxServer Handle to the NX server.
+ * @param widgetControl Controlling widget for this window.
+ */
+
+ CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl);
+
+ /**
+ * Destructor.
+ */
+
+ ~CNxWindow(void);
+
+ /**
+ * Creates a new window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully opened.
+ */
+
+ bool open(void);
+
+ /**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+ CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool requestPosition(void);
+
+ /**
+ * Get the position of the window (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+ bool getPosition(FAR struct nxgl_point_s *pPos);
+
+ /**
+ * Get the size of the window (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+ bool getSize(FAR struct nxgl_size_s *pSize);
+
+ /**
+ * Set the position and size of the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setPosition(FAR const struct nxgl_point_s *pPos);
+
+ /**
+ * Set the size of the selected window.
+ *
+ * @param pSize The new size of the window.
+ * @return True on success, false on any failure.
+ */
+
+ bool setSize(FAR const struct nxgl_size_s *pSize);
+
+ /**
+ * Bring the window to the top of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool raise(void);
+
+ /**
+ * Lower the window to the bottom of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+ bool lower(void);
+
+ /**
+ * Each window implementation also inherits from CCallback. CCallback,
+ * by default, forwards NX keyboard input to the various widgets residing
+ * in the window. But NxConsole is a different usage model; In this case,
+ * keyboard input needs to be directed to the NxConsole character driver.
+ * This method can be used to enable (or disable) redirection of NX
+ * keyboard input from the window widgets to the NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ inline void redirectNxConsole(NXCONSOLE handle)
+ {
+ setNxConsole(handle);
+ }
+#endif
+
+ /**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+ void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
+
+ /**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width, nxgl_mxpixel_t color);
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color);
+
+ /**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset);
+
+ /**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+ bool bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXWINDOW_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cprogressbar.hxx b/NxWidgets/libnxwidgets/include/cprogressbar.hxx
new file mode 100644
index 000000000..c75d1eee6
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cprogressbar.hxx
@@ -0,0 +1,251 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cprogressbar.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CPROGRESSBAR_HXX
+#define __INCLUDE_CPROGRESSBAR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+
+ /**
+ * Widget providing a horizontal progress bar.
+ */
+
+ class CProgressBar : public CNxWidget
+ {
+ protected:
+ int16_t m_minimumValue; /**< Minimum value that the grip can represent. */
+ int16_t m_maximumValue; /**< Maximum value that the grip can represent. */
+ int16_t m_value; /**< Value of the progress bar. */
+ bool m_showPercentageText; /**< If true, completion percentage is drawn
+ over the bar. */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CProgressBar(const CProgressBar &progressBar) : CNxWidget(progressBar) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the progress bar, relative to its parent.
+ * @param y The y coordinate of the progress bar, relative to its parent.
+ * @param width The width of the progress bar.
+ * @param height The height of the progress bar.
+ */
+
+ CProgressBar(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CProgressBar(void) { }
+
+ /**
+ * Get the smallest value that the progress bar can represent.
+ *
+ * @return The smallest value.
+ */
+
+ inline const int16_t getMinimumValue(void) const
+ {
+ return m_minimumValue;
+ }
+
+ /**
+ * Get the largest value that the progress bar can represent.
+ *
+ * @return The largest value.
+ */
+
+ inline const int16_t getMaximumValue(void) const
+ {
+ return m_maximumValue;
+ }
+
+ /**
+ * Get the current value of the progress bar.
+ * return The current progress bar value.
+ */
+
+ inline const int16_t getValue(void) const
+ {
+ return m_value;
+ }
+
+ /**
+ * Set the smallest value that the progress bar can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ inline void setMinimumValue(const int16_t value)
+ {
+ m_minimumValue = value;
+ }
+
+ /**
+ * Set the largest value that the progress bar can represent.
+ *
+ * @param value The largest value.
+ */
+
+ inline void setMaximumValue(const int16_t value)
+ {
+ m_maximumValue = value;
+ }
+
+ /**
+ * Set the value that of the progress bar.
+ *
+ * @param value The new value.
+ */
+
+ void setValue(const int16_t value);
+
+ /**
+ * Shows the percentage text over the bar.
+ */
+
+ inline void showPercentageText(void)
+ {
+ m_showPercentageText = true;
+ redraw();
+ }
+
+ /**
+ * Hides the percentage text over the bar.
+ */
+
+ inline void hidePercentageText(void)
+ {
+ m_showPercentageText = false;
+ redraw();
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CPROGRESSBAR_HXX
diff --git a/NxWidgets/libnxwidgets/include/cradiobutton.hxx b/NxWidgets/libnxwidgets/include/cradiobutton.hxx
new file mode 100644
index 000000000..4186b8eea
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cradiobutton.hxx
@@ -0,0 +1,207 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cradiobutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CRADIOBUTTON_HXX
+#define __INCLUDE_CRADIOBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#include "cbutton.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+ class CRadioButtonGroup;
+
+ /**
+ * Represents a radio button. Radio buttons can only exist as part of a
+ * CRadioButtonGroup class, and should not be instantiated individually.
+ * Radio buttons are tri-state - off, on and "mu".
+ * The mu state cannot be enabled by a user - it can only be set by the
+ * developer.
+ */
+
+ class CRadioButton : public CButton
+ {
+ public:
+
+ /**
+ * Enum listing all possible radio button states.
+ */
+
+ enum RadioButtonState
+ {
+ RADIO_BUTTON_STATE_OFF = 0, /**< Radio button is off */
+ RADIO_BUTTON_STATE_ON = 1, /**< Radio button is on */
+ RADIO_BUTTON_STATE_MU = 2 /**< Radio button is in the third state */
+ };
+
+ protected:
+
+ RadioButtonState m_state; /**< The state of the radio button */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Sets the radiobutton's state to "on".
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CRadioButton() { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CRadioButton(const CRadioButton &radioButton) : CButton(radioButton) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the radio button, relative to its
+ * parent.
+ * @param y The y coordinate of the radio button, relative to its
+ * parent.
+ * @param width The width of the radio button.
+ * @param height The height of the radio button.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * defaultCWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CRadioButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Get the current state of the radio button.
+ *
+ * @return The state of the radio button.
+ */
+
+ virtual inline RadioButtonState getState(void)
+ {
+ return m_state;
+ }
+
+ /**
+ * Set the state of the radio button.
+ *
+ * @param state The new radio button state.
+ */
+
+ virtual void setState(RadioButtonState state);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CRADIOBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/cradiobuttongroup.hxx b/NxWidgets/libnxwidgets/include/cradiobuttongroup.hxx
new file mode 100644
index 000000000..c37630c61
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cradiobuttongroup.hxx
@@ -0,0 +1,253 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cradiobuttongroup.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CRADIOBUTTONGROUP_HXX
+#define __INCLUDE_CRADIOBUTTONGROUP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#include "cnxwidget.hxx"
+#include "cbutton.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgeteventhandler.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+ class CRadioButton;
+
+ /**
+ * Container class that holds radio button widgets and tracks their status.
+ * The group provides an easy way to determine which radio button is
+ * selected. Note that, in order to set the "mu" state for a radio button,
+ * it is necessary to set the state via the radio button, not the group.
+ */
+
+ class CRadioButtonGroup : public CNxWidget, public CWidgetEventHandler
+ {
+ protected:
+ CWidgetControl *m_pWidgetControl; /**< The controlling widget */
+ CRadioButton *m_selectedWidget; /**< Pointer to the currently selected radio button */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort* port);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CRadioButtonGroup(const CRadioButtonGroup &radioButtonGroup) : CNxWidget(radioButtonGroup) { }
+
+ public:
+
+ /**
+ * Constructor. Note that the group determines its width and height
+ * from the position and dimensions of its children.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the group.
+ * @param y The y coordinate of the group.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CRadioButtonGroup(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ ~CRadioButtonGroup(void) { }
+
+ /**
+ * Simple method for adding a new radio button to the group.
+ * This should be used in preference to the usual addWidget() method,
+ * as this method automatically resizes the group.
+ *
+ * @param x The x coordinate of the new button, relative to this
+ * widget.
+ * @param y The y coordinate of the new button, relative to this
+ * widget.
+ * @param width The width of the new button.
+ * @param height The height of the new button.
+ */
+
+ CRadioButton *newRadioButton(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Gets a pointer to the selected widget.
+ *
+ * @return Pointer to the selected widget.
+ */
+
+ virtual const CRadioButton *getSelectedWidget(void) const;
+
+ /**
+ * Gets the index of the selected widget.
+ *
+ * @return The index of the selected widget.
+ */
+
+ virtual const int getSelectedIndex(void) const;
+
+ /**
+ * Sets the selected radio button to the supplied widget.
+ *
+ * @param widget The radio button to select.
+ */
+
+ virtual void setSelectedWidget(CRadioButton *widget);
+
+ /**
+ * Selects the widget at the specified index.
+ *
+ * @param index The index of the widget to select.
+ */
+
+ virtual void setSelectedIndex(int index);
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent. Value is based on the length of the largest string
+ * in the set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+
+ /**
+ * Handle a mouse click event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse double-click event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleDoubleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse button release event that occurred within the bounds of
+ * the source widget.
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse button release event that occurred outside the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CRADIOBUTTONGROUP_HXX
diff --git a/NxWidgets/libnxwidgets/include/crect.hxx b/NxWidgets/libnxwidgets/include/crect.hxx
new file mode 100644
index 000000000..7ce233fed
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/crect.hxx
@@ -0,0 +1,436 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbgwindow.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CRECT_HXX
+#define __INCLUDE_CRECT_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class describing a rectangle.
+ */
+
+ class CRect
+ {
+ public:
+ struct nxgl_point_s m_pos; /**< The position of the rectangle in the window */
+ struct nxgl_size_s m_size; /**< The size of the rectangle */
+
+ /**
+ * Constructor.
+ */
+
+ CRect(void);
+
+ /**
+ * Constructor.
+ *
+ * @param x The x coordinate of the rect.
+ * @param y The y coordinate of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+
+ CRect(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Constructor.
+ *
+ * @param rect Pointer to an NX rectangle
+ */
+
+ CRect(FAR const nxgl_rect_s *rect);
+
+ /**
+ * Copy constructor.
+ *
+ * @param rect CRect to copy.
+ */
+
+ CRect(const CRect& rect);
+
+ /**
+ * Create a rect object from the supplied coordinates.
+ *
+ * @param x1 The x coordinate of the rect's top-left corner.
+ * @param y1 The y coordinate of the rect's top-left corner.
+ * @param x2 The x coordinate of the rect's bottom-right corner.
+ * @param y2 The y coordinate of the rect's bottom-right corner.
+ * @return A new rect.
+ */
+
+ static CRect fromCoordinates(nxgl_coord_t x1, nxgl_coord_t y1,
+ nxgl_coord_t x2, nxgl_coord_t y2);
+
+ /**
+ * Get the rectangle's left x coordinate.
+ *
+ * @return The rectangle's x coordinate.
+ */
+
+ inline nxgl_coord_t getX(void) const
+ {
+ return m_pos.x;
+ }
+
+ /**
+ * Get the rectangle's top y coordinate.
+ * @return The rectangle's y coordinate.
+ */
+
+ inline nxgl_coord_t getY(void) const
+ {
+ return m_pos.y;
+ }
+
+ /**
+ * Get the rectangle's width.
+ *
+ * @return The rectangle's width.
+ */
+
+ inline nxgl_coord_t getWidth(void) const
+ {
+ return m_size.w;
+ }
+
+ /**
+ * Get the size of the rectangle
+ *
+ * @return The rectangle's size
+ */
+
+ inline void getSize(struct nxgl_size_s &size) const
+ {
+ size.h = m_size.h;
+ size.w = m_size.w;
+ }
+
+ /**
+ * Get the rectangle's height.
+ *
+ * @return The rectangle's height.
+ */
+
+ inline nxgl_coord_t getHeight(void) const
+ {
+ return m_size.h;
+ }
+
+ /**
+ * Get the NX rectangle representation
+ *
+ * @param rect Pointer to NX rectangle
+ */
+
+ inline void getNxRect(FAR struct nxgl_rect_s *rect) const
+ {
+ rect->pt1.x = m_pos.x;
+ rect->pt1.y = m_pos.y;
+ rect->pt2.x = m_pos.x + m_size.w - 1;
+ rect->pt2.y = m_pos.y + m_size.h - 1;
+ }
+
+ /**
+ * Set the rectangle's left x coordinate.
+ *
+ * @param x The new x coordinate.
+ */
+
+ inline void setX(nxgl_coord_t x)
+ {
+ m_pos.x = x;
+ }
+
+ /**
+ * Set the rectangle's top y coordinate.
+ *
+ * @param y The new y coordinate.
+ */
+
+ inline void setY(nxgl_coord_t y)
+ {
+ m_pos.y = y;
+ }
+
+ /**
+ * Set the rect's width.
+ *
+ * @param width The new width.
+ */
+ inline void setWidth(nxgl_coord_t width)
+ {
+ m_size.w = width;
+ }
+
+ /**
+ * Set the rect's height.
+ *
+ * @param height The new height.
+ */
+
+ inline void setHeight(nxgl_coord_t height)
+ {
+ m_size.h = height;
+ }
+
+ /**
+ * Get the NX rectangle representation
+ *
+ * @param rect Pointer to NX rectangle
+ */
+
+ inline void setNxRect(FAR const struct nxgl_rect_s *rect)
+ {
+ m_pos.x = rect->pt1.x;
+ m_pos.y = rect->pt1.y;
+ m_size.w = rect->pt2.x - rect->pt1.x + 1;
+ m_size.h = rect->pt2.y - rect->pt1.y + 1;
+ }
+
+ /**
+ * Set the x coordinate of the rect's bottom-right corner. If x2 is less
+ * than the rect's current x coordinate the method automatically adjusts
+ * the coordinates so that the rect's width is never negative. Changing this
+ * property will change the width of the rect.
+ *
+ * @param x2 The x coordinate of the rect's bottom-right corner.
+ */
+
+ void setX2(nxgl_coord_t x2);
+
+ /**
+ * Set the y coordinate of the rect's bottom-right corner. If y2 is less
+ * than the rect's current y coordinate the method automatically adjusts
+ * the coordinates so that the rect's height is never negative. Changing this
+ * property will change the height of the rect.
+ *
+ * @param y2 The y coordinate of the rect's bottom-right corner.
+ */
+
+ void setY2(nxgl_coord_t y2);
+
+ /**
+ * Get the x coordinate of the rectangle's right side.
+ *
+ * @return The x coordinate of the rectangle's right side.
+ */
+
+ inline nxgl_coord_t getX2(void) const
+ {
+ return m_pos.x + m_size.w - 1;
+ }
+
+ /**
+ * Get the y coordinate of the rectangle's bottom side.
+ *
+ * @return The y coordinate of the rerectangle's bottom side.
+ */
+
+ inline nxgl_coord_t getY2(void) const
+ {
+ return m_pos.y + m_size.h - 1;
+ }
+
+ /**
+ * Offset the rectangle position by the specified dx, dy values.
+ *
+ * @param dx X offset value
+ * @param dy Y offset value
+ */
+
+ inline void offset(nxgl_coord_t dx, nxgl_coord_t dy)
+ {
+ m_pos.x += dx;
+ m_pos.y += dy;
+ }
+
+ /**
+ * Determines if the rectangle has two dimensions; in other words, does it
+ * have both height and width? Negative width or height is considered not to
+ * be valid.
+ *
+ * @return True if the rect has height and width; false if not.
+ */
+
+ inline bool hasDimensions(void) const
+ {
+ return m_size.w > 0 && m_size.h > 0;
+ }
+
+ /**
+ * Populates dest with a rectangle representating the intersection
+ * of this rectangle and rect.
+ *
+ * @param rect The rectangle to intersect with this.
+ * @param dest The destination rectangle.
+ */
+
+ void getIntersect(const CRect& rect, CRect& dest) const;
+
+ /**
+ * Populates dest with a rectangle representating the smallest
+ * rectangle that contains this rectangle and rect.
+ *
+ * @param rect The rectangle to add to this.
+ * @param dest The destination rectangle.
+ */
+
+ void getAddition(const CRect &rect, CRect &dest) const;
+
+ /**
+ * Clips this rect to the region that intersects the supplied rect.
+ *
+ * @param rect CRect to intersect.
+ */
+
+ void clipToIntersect(const CRect &rect);
+
+ /**
+ * Expands this rect so that it includes the area described by the supplied
+ * rect.
+ *
+ * @param rect CRect to include.
+ */
+
+ void expandToInclude(const CRect &rect);
+
+ /**
+ * Check if the supplied rect intersects this.
+ *
+ * @param rect CRect to check for intersection with this.
+ * @return True if the rect intersects this; false if not.
+ */
+
+ bool intersects(const CRect &rect) const;
+
+ /**
+ * Check if the rect contains the supplied point.
+ *
+ * @param x X coordinate of the point.
+ * @param y Y coordinate of the point.
+ * @return True if the rect contains the point; false if not.
+ */
+
+ bool contains(nxgl_coord_t x, nxgl_coord_t y) const;
+
+ /**
+ * Copy the properties of this rect to the destination rect.
+ *
+ * @param dest Destination rect to copy to.
+ */
+
+ void copyTo(CRect &dest) const;
+
+ /**
+ * Overloaded & operator. Returns the intersect of this rectangle and the
+ * rectangle passed as the "rect" argument".
+ *
+ * @param rect The rectangle to intersect with this.
+ */
+
+ CRect operator&(const CRect &rect);
+
+ /**
+ * Overloaded + operator. Returns the smallest rectangle that can contain
+ * this rectangle and the rectangle passed as the "rect" argument".
+ *
+ * @param rect The rectangle to add to this.
+ */
+
+ CRect operator+(const CRect &rect);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CRECT_HXX
diff --git a/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx
new file mode 100644
index 000000000..dd869c476
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx
@@ -0,0 +1,269 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/crlepalettebitmap.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_CRLEPALETTBITMAP_HXX
+#define __INCLUDE_CRLEPALETTBITMAP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "ibitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * One Run-Length Encoded (RLE) value
+ */
+
+ struct SRlePaletteBitmapEntry
+ {
+ uint8_t npixels; /**< Number of pixels */
+ uint8_t lookup; /**< Pixel RGB lookup index */
+ };
+
+ /**
+ * Run-Length Encoded (RLE), Paletted Bitmap Structure
+ */
+
+ struct SRlePaletteBitmap
+ {
+ uint8_t bpp; /**< Bits per pixel */
+ uint8_t fmt; /**< Color format */
+ uint8_t nlut; /**< Number of colors in the Look-Up Table (LUT) */
+ nxgl_coord_t width; /**< Width in pixels */
+ nxgl_coord_t height; /**< Height in rows */
+ FAR const void *lut[2]; /**< Pointers to the beginning of the Look-Up Tables (LUTs) */
+
+ /**
+ * The pointer to the beginning of the RLE data
+ */
+
+ FAR const struct SRlePaletteBitmapEntry *data;
+ };
+
+ /**
+ * Class providing bitmap accessor for a bitmap represented by SRlePaletteBitmap.
+ */
+
+ class CRlePaletteBitmap : public IBitmap
+ {
+ protected:
+ /**
+ * The bitmap that is being managed
+ */
+
+ FAR const struct SRlePaletteBitmap *m_bitmap; /**< The bitmap that is being managed */
+
+ /**
+ * Accessor state data
+ */
+
+ nxgl_coord_t m_row; /**< Logical row number */
+ nxgl_coord_t m_col; /**< Logical column number */
+ uint8_t m_remaining; /**< Number of bytes remaining in current entry */
+ FAR const void *m_lut; /**< The selected LUT */
+ FAR const struct SRlePaletteBitmapEntry *m_rle; /**< RLE entry being processed */
+
+ /**
+ * Reset to the beginning of the image
+ */
+
+ void startOfImage(void);
+
+ /**
+ * Advance position data ahead. Called after npixels have
+ * have been consume.
+ *
+ * @param npixels The number of pixels to advance
+ * @return False if this goes beyond the end of the image
+ */
+
+ bool advancePosition(nxgl_coord_t npixels);
+
+ /**
+ * Seek ahead the specific number of pixels -- discarding
+ * and advancing.
+ *
+ * @param npixels The number of pixels to skip
+ * @return False if this goes beyond the end of the image
+ */
+
+ bool skipPixels(nxgl_coord_t npixels);
+
+ /** Seek to the beginning of the next row
+ *
+ * @return False if this was the last row of the image
+ */
+
+ bool nextRow(void);
+
+ /** Seek to the beignning specific row
+ *
+ * @param row The row number to seek to
+ * @return False if this goes beyond the end of the image
+ */
+
+ bool seekRow(nxgl_coord_t row);
+
+ /** Copy the pixels from the current RLE entry the specified number of times.
+ *
+ * @param npixels The number of pixels to copy. Must be less than or equal
+ * to m_remaining.
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ */
+
+ void copyColor(nxgl_coord_t npixels, FAR void *data);
+
+ /** Copy pixels from the current position
+ *
+ * @param npixels The number of pixels to copy
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @return False if this goes beyond the end of the image
+ */
+
+ bool copyPixels(nxgl_coord_t npixels, FAR void *data);
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param bitmap The bitmap structure being wrapped.
+ */
+
+ CRlePaletteBitmap(const struct SRlePaletteBitmap *bitmap);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CRlePaletteBitmap(void) {}
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's width.
+ */
+
+ const uint8_t getColorFormat(void) const;
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's color format.
+ */
+
+ const uint8_t getBitsPerPixel(void) const;
+
+ /**
+ * Get the bitmap's width (in pixels/columns).
+ *
+ * @return The bitmap's pixel depth.
+ */
+
+ const nxgl_coord_t getWidth(void) const;
+
+ /**
+ * Get the bitmap's height (in rows).
+ *
+ * @return The bitmap's height.
+ */
+
+ const nxgl_coord_t getHeight(void) const;
+
+ /**
+ * Get the bitmap's width (in bytes).
+ *
+ * @return The bitmap's width.
+ */
+
+ const nxgl_coord_t getStride(void) const;
+
+ /**
+ * Use the colors associated with a selected image.
+ *
+ * @param selected. true: Use colors for a selected widget,
+ * false: Use normal (default) colors.
+ */
+
+ void setSelected(bool selected);
+
+ /**
+ * Get one row from the bit map image using the selected colors.
+ *
+ * @param x The offset into the row to get
+ * @param y The row number to get
+ * @param width The number of pixels to get from the row
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @param True if the run was returned successfully.
+ */
+
+ bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ FAR void *data);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CRLEPALETTBITMAP_HXX
diff --git a/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx b/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
new file mode 100644
index 000000000..20ba149fa
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollbarhorizontal.hxx
@@ -0,0 +1,293 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollbarhorizontal.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLBARHORIZONTAL_HXX
+#define __INCLUDE_CSCROLLBARHORIZONTAL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgetstyle.hxx"
+#include "islider.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CSliderHorizontal;
+ class CGlyphButton;
+ class CNxTimer;
+
+ /**
+ * Container class that holds a slider widget and two arrow buttons.
+ * The interface is presents is virtually identical to the CSliderHorizontal
+ * widget, which means the two are easily interchangeable. All events
+ * raised by the internal slider widget are re-raised by this widget
+ * to this widget's event handler, meaning its events are also identical
+ * to the CSliderHorizontal's.
+ */
+
+ class CScrollbarHorizontal : public ISlider, public CNxWidget, public CWidgetEventHandler
+ {
+ protected:
+ CSliderHorizontal *m_slider; /**< Pointer to the slider widget */
+ CGlyphButton *m_leftButton; /**< Pointer to the left button */
+ CGlyphButton *m_rightButton; /**< Pointer to the right button */
+ nxgl_coord_t m_buttonWidth; /**< Width of the buttons */
+ uint8_t m_scrollTimeout; /**< Time until a button triggers
+ another grip movement */
+ CNxTimer *m_timer; /**< Controls slider button repeats */
+
+ /**
+ * Resize the scrollbar to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScrollbarHorizontal(const CScrollbarHorizontal &scrollbarHorizontal)
+ : CNxWidget(scrollbarHorizontal) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control instance for the window.
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScrollbarHorizontal(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CScrollbarHorizontal(void) { }
+
+ /**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+ const nxgl_coord_t getMinimumValue(void) const;
+
+ /**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+ const nxgl_coord_t getMaximumValue(void) const;
+
+ /**
+ * Get the current value of the slider.
+ *
+ * @return The current slider value.
+ */
+
+ const nxgl_coord_t getValue(void) const;
+
+ /**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+ const nxgl_coord_t getPageSize(void) const;
+
+ /**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ void setMinimumValue(const nxgl_coord_t value);
+
+ /**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+ void setMaximumValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+ void setValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+ void setValueWithBitshift(const int32_t value);
+
+ /**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+ void setPageSize(const nxgl_coord_t pageSize);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleActionEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleReleaseEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLBARHORIZONTAL_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx b/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx
new file mode 100644
index 000000000..08bdb721c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx
@@ -0,0 +1,309 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollbarpanel.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLBARPANEL_HXX
+#define __INCLUDE_CSCROLLBARPANEL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cscrollingpanel.hxx"
+#include "cwidgetstyle.hxx"
+#include "cscrollbarvertical.hxx"
+#include "cscrollbarhorizontal.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "iscrollable.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class containing a scrolling panel bordered by scrollbars.
+ */
+ class CScollbarPanel : public CNxWidget, public IScrollable,
+ public CWidgetEventHandler
+ {
+ protected:
+ CWidgetControl *m_widgetControl; /**< Widget control instance */
+ CScrollingPanel *m_panel; /**< Internal panel that
+ contains children. */
+ CScrollbarHorizontal *m_scrollbarHorizontal; /**< Horizontal scrollbar. */
+ CScrollbarVertical *m_scrollbarVertical; /**< Vertical scrollbar. */
+ uint8_t m_scrollbarWidth; /**< Width of the vertical
+ scrollbar. */
+ uint8_t m_scrollbarHeight; /**< Height of the horizontal
+ scrollbar. */
+ bool m_hasVerticalScrollbar; /**< Indicates the presence of
+ a vertical scrollbar. */
+ bool m_hasHorizontalScrollbar; /**< Indicates the presence of
+ a horizontal scrollbar. */
+
+ /**
+ * Creates the child widgets.
+ */
+
+ void buildUI(void);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CScollbarPanel(void) { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScollbarPanel(const CScollbarPanel &scrollbarPanel)
+ : CNxWidget(scrollbarPanel) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags The usual widget flags.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScollbarPanel(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+ virtual void scroll(int32_t dx, int32_t dy);
+
+ /**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+ virtual void jump(int32_t x, int32_t y);
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsVerticalScroll(bool allow);
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsHorizontalScroll(bool allow);
+
+ /**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+ virtual void setCanvasWidth(const int32_t width);
+
+ /**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+ virtual void setCanvasHeight(const int32_t height);
+
+ /**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+ virtual bool allowsVerticalScroll(void) const;
+
+ /**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+ virtual bool allowsHorizontalScroll(void) const;
+
+ /**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasX(void) const;
+
+ /**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasY(void) const;
+
+ /**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasWidth(void) const;
+
+ /**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasHeight(void) const;
+
+ /**
+ * Handle a widget scroll event.
+ *
+ * @param e The event data.
+ */
+
+ void handleScrollEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a widget value change event.
+ *
+ * @param e The event data.
+ */
+
+ void handleValueChangeEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Gets a pointer to the CScrollingPanel widget contained within
+ * this widget.
+ *
+ * @return A pointer to the CScrollingPanel widget.
+ */
+
+ inline CScrollingPanel *getPanel(void)
+ {
+ return m_panel;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLBARPANEL_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx b/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx
new file mode 100644
index 000000000..974da3378
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollbarvertical.hxx
@@ -0,0 +1,291 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollbarvertical.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLBARVERTICAL_HXX
+#define __INCLUDE_CSCROLLBARVERTICAL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgetstyle.hxx"
+#include "islider.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CSliderVertical;
+ class CGlyphButton;
+ class CNxTimer;
+
+ /**
+ * Container class that holds a slider widget and two arrow buttons.
+ * The interface is presents is virtually identical to the CSliderVertical
+ * widget, which means the two are easily interchangeable. All events
+ * raised by the internal slider widget are re-raised by this widget
+ * to this widget's event handler, meaning its events are also identical
+ * to the CSliderVertical's.
+ */
+ class CScrollbarVertical : public ISlider, public CNxWidget, public CWidgetEventHandler {
+
+ protected:
+ CSliderVertical *m_slider; /**< Pointer to the slider widget */
+ CGlyphButton *m_upButton; /**< Pointer to the up button */
+ CGlyphButton *m_downButton; /**< Pointer to the down button */
+ nxgl_coord_t m_buttonHeight; /**< Height of the buttons */
+ uint8_t m_scrollTimeout; /**< Time until a button triggers another grip
+ movement */
+ CNxTimer *m_timer; /**< Controls slider button repeats */
+
+ /**
+ * Resize the scrollbar to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScrollbarVertical(const CScrollbarVertical& scrollbarVertical)
+ : CNxWidget(scrollbarVertical) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control instance for the window.
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScrollbarVertical(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CScrollbarVertical(void) { }
+
+ /**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+ const nxgl_coord_t getMinimumValue(void) const;
+
+ /**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+ const nxgl_coord_t getMaximumValue(void) const;
+
+ /**
+ * Get the current value of the slider.
+ *
+ * @return The current slider value.
+ */
+
+ const nxgl_coord_t getValue(void) const;
+
+ /**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+ const nxgl_coord_t getPageSize(void) const;
+
+ /**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ void setMinimumValue(const nxgl_coord_t value);
+
+ /**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+ void setMaximumValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+ void setValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+ void setValueWithBitshift(const int32_t value);
+
+ /**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+ void setPageSize(const nxgl_coord_t pageSize);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleActionEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleReleaseEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLBARVERTICAL_HXX
diff --git a/NxWidgets/libnxwidgets/include/cscrollinglistbox.hxx b/NxWidgets/libnxwidgets/include/cscrollinglistbox.hxx
new file mode 100644
index 000000000..ba7090b4b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollinglistbox.hxx
@@ -0,0 +1,480 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollinglistbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLINGLISTBOX_HXX
+#define __INCLUDE_CSCROLLINGLISTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "clistbox.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "clistdata.hxx"
+#include "clistboxdataitem.hxx"
+#include "cwidgetstyle.hxx"
+#include "ilistbox.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CScrollbarVertical;
+ class CWidgetControl;
+
+ /**
+ * Widget containing a CListBox and a vertical scrollbar. Exposed
+ * methods are more or less identical to the methods exposed by the CListBox
+ * to ensure that the two are interchangeable.
+ */
+
+ class CScrollingListBox : public IListBox, public CNxWidget,
+ public CWidgetEventHandler
+ {
+ protected:
+ CListBox *m_listbox; /**< Pointer to the list box. */
+ CScrollbarVertical *m_scrollbar; /**< Pointer to the scrollbar. */
+ uint8_t m_scrollbarWidth; /**< Width of the scrollbar. */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Resize the listbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CScrollingListBox(void) { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScrollingListBox(const CScrollingListBox &scrollingListBox)
+ : CNxWidget(scrollingListBox) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScrollingListBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Add a new option to the widget using default colors.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value);
+
+ /**
+ * Add an option to the widget.
+ *
+ * @param option The option to add.
+ */
+
+ virtual void addOption(CListBoxDataItem *option);
+
+ /**
+ * Add a new option to the widget.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor);
+
+ /**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+ virtual void removeOption(const int index);
+
+ /**
+ * Remove all options from the widget.
+ */
+
+ virtual void removeAllOptions(void);
+
+ /**
+ * Select an option by its index. Does not deselect any other selected options.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual inline void selectOption(const int index)
+ {
+ m_listbox->selectOption(index);
+ }
+
+ /**
+ * Select an option by its index. Does not deselect any other selected options.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual inline void deselectOption(const int index)
+ {
+ m_listbox->deselectOption(index);
+ }
+
+ /**
+ * Select all options. Does nothing if the listbox does not allow multiple selections.
+ * Redraws the widget and raises a value changed event.
+ */
+
+ virtual inline void selectAllOptions(void)
+ {
+ m_listbox->selectAllOptions();
+ }
+
+ /**
+ * Deselect all options.
+ * Redraws the widget and raises a value changed event.
+ */
+
+ virtual inline void deselectAllOptions(void)
+ {
+ m_listbox->deselectAllOptions();
+ }
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * option is selected, the index of the first selected option is returned.
+ *
+ * @return The selected index.
+ */
+
+ virtual inline const int getSelectedIndex(void) const
+ {
+ return m_listbox->getSelectedIndex();
+ }
+
+ /**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected items to deselected.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+ virtual inline void setSelectedIndex(const int index)
+ {
+ m_listbox->setSelectedIndex(index);
+ }
+
+ /**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+ virtual inline const CListBoxDataItem *getSelectedOption(void) const
+ {
+ return m_listbox->getSelectedOption();
+ }
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @param allowMultipleSelections True to allow multiple selections.
+ */
+
+ virtual inline
+ void setAllowMultipleSelections(const bool allowMultipleSelections)
+ {
+ m_listbox->setAllowMultipleSelections(allowMultipleSelections);
+ }
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @return True if multiple selections are allowed.
+ */
+
+ virtual inline const bool allowsMultipleSelections(void) const
+ {
+ return m_listbox->allowsMultipleSelections();
+ }
+
+ /**
+ * Resize the scrolling canvas to encompass all options.
+ */
+
+ virtual inline void resizeCanvas(void)
+ {
+ m_listbox->resizeCanvas();
+ }
+
+ /**
+ * Get the specified option.
+ *
+ * @return The specified option.
+ */
+
+ virtual inline const CListBoxDataItem *getOption(const int index)
+ {
+ return m_listbox->getOption(index);
+ }
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected.
+ *
+ * @return The selected index.
+ */
+
+ virtual inline const CListBoxDataItem *getOption(const int index) const
+ {
+ return m_listbox->getOption(index);
+ }
+
+ /**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+ virtual inline void sort(void)
+ {
+ m_listbox->sort();
+ }
+
+ /**
+ * Get the total number of options.
+ *
+ * @return The number of options.
+ */
+
+ virtual inline const int getOptionCount(void) const
+ {
+ return m_listbox->getOptionCount();
+ }
+
+ /**
+ * Get the height of a single option.
+ *
+ * @return The height of an option.
+ */
+
+ virtual inline const nxgl_coord_t getOptionHeight(void) const
+ {
+ return m_listbox->getOptionHeight();
+ }
+
+ /**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a widget action event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleActionEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleScrollEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse button click event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleDoubleClickEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse button release event that occurred within the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a mouse button release event that occurred outside the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+ virtual void setFont(CNxFont *font);
+
+ /**
+ * Sets whether or not items added to the list are automatically
+ * sorted on insert or not.
+ *
+ * @param sortInsertedItems True to enable sort on insertion.
+ */
+
+ virtual inline void setSortInsertedItems(const bool sortInsertedItems)
+ {
+ m_listbox->setSortInsertedItems(sortInsertedItems);
+ }
+
+ /**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+ virtual void getPreferredDimensions(CRect &rect) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLINGLISTBOX_HXX
diff --git a/NxWidgets/libnxwidgets/include/cscrollingpanel.hxx b/NxWidgets/libnxwidgets/include/cscrollingpanel.hxx
new file mode 100644
index 000000000..90dcc1ac9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollingpanel.hxx
@@ -0,0 +1,372 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollingpanel.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLINGPANEL_HXX
+#define __INCLUDE_CSCROLLINGPANEL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "iscrollable.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Class containing a scrollable region. Responds to mouse movement. Can
+ * contain sub-widgets which will also be scrolled.
+ */
+
+ class CScrollingPanel : public CNxWidget, public IScrollable
+ {
+ protected:
+ CWidgetControl *m_widgetControl; /**< Widget control instance */
+ int32_t m_canvasX; /**< X coordinate of the virtual
+ canvas. */
+ int32_t m_canvasY; /**< Y coordinate of the virtual
+ canvas. */
+ int32_t m_canvasWidth; /**< Width of the virtual canvas. */
+ int32_t m_canvasHeight; /**< Height of the virtual canvas. */
+ bool m_allowVerticalScroll; /**< True if vertical scrolling is
+ allowed. */
+ bool m_allowHorizontalScroll; /**< True if horizontal scrolling is
+ allowed. */
+ bool m_isContentScrolled; /**< True if the content drawn to the
+ panel is scrolled(ie. everything
+ drawn in the draw() method);
+ false if just child objects are scrolled. */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Scrolls the panel to match the drag.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal drag distance.
+ * @param vY The vertical drag distance.
+ */
+
+ virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Scroll all child widgets by the specified amounts. Actually uses
+ * the widget's moveTo() function to reposition them.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+ void scrollChildren(int32_t dx, int32_t dy);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CScrollingPanel(void) { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScrollingPanel(const CScrollingPanel &scrollingPanel)
+ : CNxWidget(scrollingPanel) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags The usual widget flags.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScrollingPanel(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+ virtual void scroll(int32_t dx, int32_t dy);
+
+ /**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+ virtual void jump(int32_t x, int32_t y);
+
+ /**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+ inline bool allowsVerticalScroll(void) const
+ {
+ return m_allowVerticalScroll;
+ }
+
+ /**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+ inline bool allowsHorizontalScroll(void) const
+ {
+ return m_allowHorizontalScroll;
+ }
+
+ /**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+ virtual inline const int32_t getCanvasX(void) const
+ {
+ return m_canvasX;
+ }
+
+ /**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+ virtual inline const int32_t getCanvasY(void) const
+ {
+ return m_canvasY;
+ }
+
+ /**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+ virtual inline const int32_t getCanvasWidth(void) const
+ {
+ return m_canvasWidth;
+ }
+
+ /**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+ virtual inline const int32_t getCanvasHeight(void) const
+ {
+ return m_canvasHeight;
+ }
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ inline void setAllowsVerticalScroll(bool allow)
+ {
+ m_allowVerticalScroll = allow;
+ }
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ inline void setAllowsHorizontalScroll(bool allow)
+ {
+ m_allowHorizontalScroll = allow;
+ }
+
+ /**
+ * Set whether or not the content of the panel is scrolled.
+ * Content is anything drawn to the panel in the draw() method.
+ * This property is disabled by default, which will result in
+ * faster scrolling of child objects.
+ * If the panel contains no child objects, just draw() method
+ * content, consider using a SuperBitmap class instead.
+ *
+ * @param scrolled True to enable content scrolling; false to disable it.
+ */
+
+ inline void setContentScrolled(bool scrolled)
+ {
+ m_isContentScrolled = scrolled;
+ }
+
+ /**
+ * Check if the content of the panel, drawn via the draw() method,
+ * is scrolled.
+ *
+ * @return True if the content is scrolled; false if not.
+ */
+
+ inline bool IsContentScrolled(void)
+ {
+ return m_isContentScrolled;
+ }
+
+ /**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+ virtual inline void setCanvasWidth(const int32_t width)
+ {
+ m_canvasWidth = width;
+ }
+
+ /**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+ virtual inline void setCanvasHeight(const int32_t height)
+ {
+ m_canvasHeight = height;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLINGPANEL_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cscrollingtextbox.hxx b/NxWidgets/libnxwidgets/include/cscrollingtextbox.hxx
new file mode 100644
index 000000000..0d2a1a39d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cscrollingtextbox.hxx
@@ -0,0 +1,467 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollingtextbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSCROLLINGTEXTBOX_HXX
+#define __INCLUDE_CSCROLLINGTEXTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cmultilinetextbox.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxstring.hxx"
+#include "iscrollable.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CScrollbarVertical;
+ class CNxFont;
+
+ /**
+ * Widget containing a CMultiLineTextBox and a vertical scrollbar. Exposed
+ * methods are more or less identical to the methods exposed by the
+ * CMultiLineTextBox to ensure that the two are interchangeable.
+ */
+
+ class CScrollingTextBox : public ITextBox, public CNxWidget,
+ public IScrollable, public CWidgetEventHandler
+ {
+ protected:
+ CMultiLineTextBox *m_texbox; /**< Pointer to the textbox */
+ CScrollbarVertical *m_scrollbar; /**< Pointer to the scrollbar */
+ uint8_t m_scrollbarWidth; /**< Width of the scrollbar */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Resize the textbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CScrollingTextBox(void) { }
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CScrollingTextBox(const CScrollingTextBox& scrollingTextBox)
+ : CNxWidget(scrollingTextBox) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param flags Standard widget flag options.
+ * @param maxRows The maximum number of rows the textbox can track. Adding
+ * text beyond this number will cause rows at the start of the text to be
+ * forgotten; text is essentially stored as a queue, and adding to the back
+ * of a full queue causes the front items to be popped off. Setting this to
+ * 0 will make the textbox track only the visible rows.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+ CScrollingTextBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, uint32_t flags,
+ nxgl_coord_t maxRows = 0,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Set the horizontal alignment of text within the textbox.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+ virtual void setTextAlignmentHoriz(CMultiLineTextBox::TextAlignmentHoriz alignment);
+
+ /**
+ * Set the vertical alignment of text within the textbox.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+ virtual void setTextAlignmentVert(CMultiLineTextBox::TextAlignmentVert alignment);
+
+ /**
+ * Returns the number of "pages" that the text spans. A page
+ * is defined as the amount of text that can be displayed within
+ * the textbox at one time.
+ *
+ * @return The page count.
+ */
+
+ virtual const uint16_t getPageCount(void) const;
+
+ /**
+ * Returns the current page.
+ *
+ * @return The current page.
+ * @see getPageCount().
+ */
+
+ virtual const uint16_t getCurrentPage(void) const;
+
+ /**
+ * Returns a pointer to the Text object that contains the
+ * wrapped text used in the textbox. It is used as the
+ * pre-processed data source for the textbox, and should
+ * not be altered.
+ *
+ * @return Pointer to the Text object.
+ */
+
+ virtual const CText *getText(void) const;
+
+ /**
+ * Set the text displayed in the textbox.
+ *
+ * @param text String to display.
+ */
+
+ virtual void setText(const CNxString &text);
+
+ /**
+ * Append new text to the end of the current text
+ * displayed in the textbox.
+ *
+ * @param text String to append.
+ */
+
+ virtual void appendText(const CNxString &text);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+ virtual void removeText(const unsigned int startIndex);
+
+ /**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+ virtual void removeText(const unsigned int startIndex, const unsigned int count);
+
+ /**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+ virtual void setFont(CNxFont *font);
+
+ /**
+ * Get the length of the text string.
+ *
+ * @return The length of the text string.
+ */
+
+ virtual const unsigned int getTextLength(void) const;
+
+ /**
+ * Sets the cursor display mode.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+ virtual void showCursor(EShowCursor cursorMode);
+
+ /**
+ * Shows the cursor in default mode (only when the TextBox has focus).
+ */
+
+ inline void showCursor(void)
+ {
+ showCursor(SHOW_CURSOR_ONFOCUS);
+ }
+
+ /**
+ * Hides the cursor.
+ */
+
+ inline void hideCursor(void)
+ {
+ showCursor(SHOW_CURSOR_NEVER);
+ }
+
+ /**
+ * Enables/disables cursor wrapping
+ *
+ * @param wrap True enables cursor wrapping
+ */
+
+ virtual void wrapCursor(bool wrap);
+
+ /**
+ * Move the cursor to the text position specified. 0 indicates the start
+ * of the string. If position is greater than the length of the string,
+ * the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+ virtual void moveCursorToPosition(const int32_t position);
+
+ /**
+ * Get the cursor position. This is the index within the string that
+ * the cursor is currently positioned over.
+ *
+ * @return position The cursor position.
+ */
+
+ virtual const int32_t getCursorPosition(void) const;
+
+ /**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+ virtual void insertText(const CNxString &text, const unsigned int index);
+
+ /**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+ virtual void insertTextAtCursor(const CNxString &text);
+
+ /**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleScrollEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasX(void) const;
+
+ /**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasY(void) const;
+
+ /**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasWidth(void) const;
+
+ /**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasHeight(void) const;
+
+ /**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+ virtual void scroll(int32_t dx, int32_t dy);
+
+ /**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+ virtual void jump(int32_t x, int32_t y);
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsVerticalScroll(bool allow);
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsHorizontalScroll(bool allow);
+
+ /**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+ virtual void setCanvasWidth(const int32_t width);
+
+ /**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+ virtual void setCanvasHeight(const int32_t height);
+
+ /**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+ virtual bool allowsVerticalScroll(void) const;
+
+ /**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+ virtual bool allowsHorizontalScroll(void) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSCROLLINGTEXTBOX_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx b/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
new file mode 100644
index 000000000..f732a1731
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/csliderhorizontal.hxx
@@ -0,0 +1,344 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/csliderhorizontal.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSLIDERHORIZONTAL_HXX
+#define __INCLUDE_CSLIDERHORIZONTAL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "islider.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CSliderHorizontalGrip;
+ class CWidgetControl;
+
+ /**
+ * Widget providing a sliding "grip" that can be moved left and
+ * right in the "gutter". Essentially a scrollbar, but more
+ * generic.
+ */
+
+ class CSliderHorizontal : public ISlider, public CNxWidget, public CWidgetEventHandler
+ {
+ protected:
+ CSliderHorizontalGrip *m_grip; /**< Pointer to the grip. */
+ nxgl_coord_t m_minimumValue; /**< Minimum value that the grip can represent. */
+ nxgl_coord_t m_maximumValue; /**< Maximum value that the grip can represent. */
+ int32_t m_value; /**< Current value of the slider. */
+ nxgl_coord_t m_minimumGripWidth; /**< Smallest width that the grip can become */
+ nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
+ the gutter. */
+ int32_t m_gutterWidth; /**< Width of the gutter, taking into account
+ any adjustments made to the width of the grip. */
+ uint32_t m_contentSize; /**< Number of values in the min/max range. */
+
+ /**
+ * Get the maximum possible value that the slider can represent. Useful when
+ * using the slider as a scrollbar, as the height of the grip prevents the full
+ * range of values being accessed (intentionally).
+ * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * calculations.
+ *
+ * @return The maximum possible value that the slider can represent.
+ */
+
+ int32_t getPhysicalMaximumValueWithBitshift(void) const;
+
+ /**
+ * Get the value represented by the top of the grip.
+ * return The value represented by the top of the grip.
+ */
+
+ const int32_t getGripValue(void) const;
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Resize the slider to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Moves the grip towards the mouse.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CSliderHorizontal(const CSliderHorizontal& sliderHorizontal)
+ : CNxWidget(sliderHorizontal) { }
+
+ /**
+ * Resize and redraw the grip.
+ */
+
+ void resizeGrip(void);
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control instance for the window.
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ */
+
+ CSliderHorizontal(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CSliderHorizontal(void) { }
+
+ /**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+ inline const nxgl_coord_t getMinimumValue(void) const
+ {
+ return m_minimumValue;
+ }
+
+ /**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+ inline const nxgl_coord_t getMaximumValue(void) const
+ {
+ return m_maximumValue;
+ }
+
+ /**
+ * Get the current value of the slider.
+ *
+ * return The current slider value.
+ */
+
+ inline const nxgl_coord_t getValue(void) const
+ {
+ return m_value >> 16;
+ }
+
+ /**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+ inline const nxgl_coord_t getPageSize(void) const
+ {
+ return m_pageSize;
+ }
+
+ /**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ inline void setMinimumValue(const nxgl_coord_t value)
+ {
+ m_minimumValue = value;
+ m_contentSize = m_maximumValue - m_minimumValue + 1;
+ resizeGrip();
+ };
+
+ /**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+ inline void setMaximumValue(const nxgl_coord_t value)
+ {
+ m_maximumValue = value;
+ m_contentSize = m_maximumValue - m_minimumValue + 1;
+ resizeGrip();
+ };
+
+ /**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+ void setValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+ void setValueWithBitshift(const int32_t value);
+
+ /**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+ inline void setPageSize(const nxgl_coord_t pageSize)
+ {
+ m_pageSize = pageSize;
+ resizeGrip();
+ };
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleDragEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Get the smallest value that the slider can move through when
+ * dragged.
+ *
+ * @return The smallest value that the slider can move through when
+ * dragged.
+ */
+
+ nxgl_coord_t getMinimumStep(void) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSLIDERHORIZONTAL_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/csliderhorizontalgrip.hxx b/NxWidgets/libnxwidgets/include/csliderhorizontalgrip.hxx
new file mode 100644
index 000000000..71f10f62c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/csliderhorizontalgrip.hxx
@@ -0,0 +1,203 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/csliderhorizontalgrip.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSLIDERHORIZONTALGRIP_HXX
+#define __INCLUDE_CSLIDERHORIZONTALGRIP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * Class representing the grip, or draggable button, with a horizontal
+ * slider.
+ */
+
+ class CSliderHorizontalGrip : public CNxWidget
+ {
+ protected:
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Starts dragging the grip and redraws it.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Moves the grip to follow the mouse.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance of the drag.
+ * @param vY The vertical distance of the drag.
+ */
+
+ virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CSliderHorizontalGrip(const CSliderHorizontalGrip &sliderHorizontalGrip)
+ : CNxWidget(sliderHorizontalGrip) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the grip, relative to its parent.
+ * @param y The y coordinate of the grip, relative to its parent.
+ * @param width The width of the grip.
+ * @param height The height of the grip.
+ */
+
+ CSliderHorizontalGrip(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CSliderHorizontalGrip(void) { }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSLIDERHORIZONTALGRIP_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cslidervertical.hxx b/NxWidgets/libnxwidgets/include/cslidervertical.hxx
new file mode 100644
index 000000000..a1b8651f9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cslidervertical.hxx
@@ -0,0 +1,344 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cslidervertical.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSLIDERVERTICAL_HXX
+#define __INCLUDE_CSLIDERVERTICAL_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "islider.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CSliderVerticalGrip;
+ class CWidgetControl;
+
+ /**
+ * Widget providing a sliding "grip" that can be moved up and
+ * down the "gutter". Essentially a scrollbar, but more
+ * generic.
+ */
+
+ class CSliderVertical : public ISlider, public CNxWidget, public CWidgetEventHandler
+ {
+ protected:
+ CSliderVerticalGrip* m_grip; /**< Pointer to the grip. */
+ nxgl_coord_t m_minimumValue; /**< Minimum value that the grip can represent. */
+ nxgl_coord_t m_maximumValue; /**< Maximum value that the grip can represent. */
+ int32_t m_value; /**< Current value of the slider. */
+ nxgl_coord_t m_minimumGripHeight; /**< Smallest height that the grip can become. */
+ nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
+ the gutter */
+ int32_t m_gutterHeight; /**< Height of the gutter, taking into account
+ any adjustments made to the height of the grip. */
+ uint32_t m_contentSize; /**< Number of values in the min/max range. */
+
+ /**
+ * Get the maximum possible value that the slider can represent. Useful when
+ * using the slider as a scrollbar, as the height of the grip prevents the full
+ * range of values being accessed (intentionally).
+ * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * calculations.
+ *
+ * @return The maximum possible value that the slider can represent.
+ */
+
+ int32_t getPhysicalMaximumValueWithBitshift(void) const;
+
+ /**
+ * Get the value represented by the top of the grip. The value is
+ * bitshifted left 16 places for accuracy.
+ * return The value represented by the top of the grip.
+ */
+
+ const int32_t getGripValue(void) const;
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Resize the slider to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+ virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Moves the grip towards the mouse.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CSliderVertical(const CSliderVertical &sliderVertical)
+ : CNxWidget(sliderVertical) { }
+
+ /**
+ * Resize and redraw the grip.
+ */
+
+ void resizeGrip();
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ */
+
+ CSliderVertical(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CSliderVertical(void) { }
+
+ /**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+ inline const nxgl_coord_t getMinimumValue(void) const
+ {
+ return m_minimumValue;
+ }
+
+ /**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+ inline const nxgl_coord_t getMaximumValue(void) const
+ {
+ return m_maximumValue;
+ }
+
+ /**
+ * Get the current value of the slider.
+ * return The current slider value.
+ */
+
+ inline const nxgl_coord_t getValue(void) const
+ {
+ return m_value >> 16;
+ }
+
+ /**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+ inline const nxgl_coord_t getPageSize(void) const
+ {
+ return m_pageSize;
+ }
+
+ /**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ inline void setMinimumValue(const nxgl_coord_t value)
+ {
+ m_minimumValue = value;
+ m_contentSize = m_maximumValue - m_minimumValue + 1;
+ resizeGrip();
+ }
+
+ /**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+ inline void setMaximumValue(const nxgl_coord_t value)
+ {
+ m_maximumValue = value;
+ m_contentSize = m_maximumValue - m_minimumValue + 1;
+ resizeGrip();
+ }
+
+ /**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+ void setValue(const nxgl_coord_t value);
+
+ /**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+ void setValueWithBitshift(const int32_t value);
+
+ /**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+ inline void setPageSize(const nxgl_coord_t pageSize)
+ {
+ m_pageSize = pageSize;
+ resizeGrip();
+ }
+
+ /**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+ virtual void handleDragEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Get the smallest value that the slider can move through when
+ * dragged.
+ *
+ * @return The smallest value that the slider can move through when
+ * dragged.
+ */
+
+ nxgl_coord_t getMinimumStep(void) const;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSLIDERVERTICAL_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/csliderverticalgrip.hxx b/NxWidgets/libnxwidgets/include/csliderverticalgrip.hxx
new file mode 100644
index 000000000..3ac7fb360
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/csliderverticalgrip.hxx
@@ -0,0 +1,202 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cslidervertical.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSLIDERVERTICALGRIP_HXX
+#define __INCLUDE_CSLIDERVERTICALGRIP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxwidget.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * Class representing the grip, or draggable button, with a vertical
+ * slider.
+ */
+
+ class CSliderVerticalGrip : public CNxWidget
+ {
+ protected:
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Starts dragging the grip and redraws it.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Moves the grip to follow the mouse.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance of the drag.
+ * @param vY The vertical distance of the drag.
+ */
+
+ virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CSliderVerticalGrip(const CSliderVerticalGrip &sliderVerticalGrip)
+ : CNxWidget(sliderVerticalGrip) { }
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the grip, relative to its parent.
+ * @param y The y coordinate of the grip, relative to its parent.
+ * @param width The width of the grip.
+ * @param height The height of the grip.
+ */
+
+ CSliderVerticalGrip(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CSliderVerticalGrip(void) { }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSLIDERVERTICALGRIP_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/cstickybutton.hxx b/NxWidgets/libnxwidgets/include/cstickybutton.hxx
new file mode 100644
index 000000000..c51976ec0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cstickybutton.hxx
@@ -0,0 +1,237 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cstickybutton.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSTICKYBUTTON_HXX
+#define __INCLUDE_CSTICKYBUTTON_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbutton.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CWidgetControl;
+
+ /**
+ * CButton that sticks down when clicked.
+ */
+
+ class CStickyButton : public CButton
+ {
+ protected:
+ bool m_isStuckDown; /**< True if the key is stuck down */
+
+ /**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+ virtual void drawOutline(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Don't redraw on button press events. The button display is
+ * completely controlled by the externally controlled stuck state.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y) {}
+
+ /**
+ * Don't redraw on button release events. The button display is
+ * completely controlled by the externally controlled stuck state.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Don't redraw on button release events. The button display is
+ * completely controlled by the externally controlled stuck state.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+ virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y) { }
+
+ /**
+ * Copy constructor is protected to prevent usage. The button display is
+ * completely controlled by the externally controlled stuck state.
+ */
+
+ inline CStickyButton(const CStickyButton &button) : CButton(button) { }
+
+ public:
+
+ /**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CStickyButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CStickyButton(void) { }
+
+ /**
+ * Sets the key's stuck down state. If this is true, the key has a
+ * inwards-bevelled border when drawn. If it is false, the key has
+ * an outwards-bevelled border.
+ *
+ * @param stuckDown The new stuck down state.
+ */
+
+ void setStuckDown(bool stuckDown);
+
+ /**
+ * Toggles the key's stuck down state.
+ */
+
+ inline void toggleStuckDown(void)
+ {
+ setStuckDown(!m_isStuckDown);
+ }
+
+ /**
+ * Returns the stuck down state.
+ *
+ * @return True is the button is in the stuck down state.
+ */
+
+ inline const bool isStuckDown(void) const
+ {
+ return m_isStuckDown;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSTICKYBUTTON_HXX
diff --git a/NxWidgets/libnxwidgets/include/cstickybuttonarray.hxx b/NxWidgets/libnxwidgets/include/cstickybuttonarray.hxx
new file mode 100644
index 000000000..5854c51f0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cstickybuttonarray.hxx
@@ -0,0 +1,174 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cstickybuttonarray.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_CSTICKYBUTTONARRAY_HXX
+#define __INCLUDE_CSTICKYBUTTONARRAY_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbuttonarray.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references
+ */
+
+ class CWidgetControl;
+ class CNxString;
+
+ /**
+ * Manages a two-dimensional array of buttons as one widget. A two-
+ * dimensional array of buttons might also be called a "keyboard".
+ */
+
+ class CStickyButtonArray : public CButtonArray
+ {
+ protected:
+ bool m_isStuckDown; /**< True if one key in the array stuck down */
+ bool m_stickDown; /**< True there is a change in a sticky button state */
+ uint8_t m_stickyRow; /**< The row index of the stuck button */
+ uint8_t m_stickyColumn; /**< The column index of the stuck button */
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CStickyButtonArray(const CStickyButtonArray &button) : CButtonArray(button) { }
+
+ public:
+
+ /**
+ * Constructor for an array of sticky buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CStickyButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * CStickyButtonArray Destructor.
+ */
+
+ virtual inline ~CStickyButtonArray(void) { }
+
+ /**
+ * Return the position of the last stuck down button (0,0 will be returned
+ * the no button has every been stuck down). The button at this position
+ * is currently stuck down then, in addition, return true.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if a button in the array is clicked
+ */
+
+ virtual bool isAnyButtonStuckDown(int &column, int &row) const;
+
+ /**
+ * Check if this specific button in the array is stuck down
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is stuck down
+ */
+
+ virtual bool isThisButtonStuckDown(int column, int row) const;
+
+ /**
+ * Force the button at this position into the stuck down state
+ *
+ * @param column The column containing the button to stick down
+ * @param row The rowtcontaining the button to stick down
+ * @return False(0) is returned if the indices are out of range.
+ */
+
+ virtual bool stickDown(int column, int row);
+
+ /**
+ * Unstick all buttons
+ */
+
+ virtual void unstick(void);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSTICKYBUTTONARRAY_HXX
diff --git a/NxWidgets/libnxwidgets/include/cstringiterator.hxx b/NxWidgets/libnxwidgets/include/cstringiterator.hxx
new file mode 100644
index 000000000..648d12633
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cstringiterator.hxx
@@ -0,0 +1,192 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cstringiterator.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CSTRINGITERATOR_HXX
+#define __INCLUDE_CSTRINGITERATOR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxString;
+
+ /**
+ * Class used to efficiently iterate over the characters in a CNxString
+ * object. The CNxString is a Unicode string that uses the fixed-width
+ * 16-bit encoding to represent its characters.
+ */
+
+ class CStringIterator
+ {
+ private:
+ const CNxString *m_pString; /**< String being iterated over. */
+ const nxwidget_char_t *m_pCurrentChar; /**< Pointer to the current position of the iterator. */
+ int m_currentIndex; /**< Iterator's current index within the string. */
+
+ public:
+
+ /**
+ * Constructor. Moves the iterator to the first character in the string.
+ *
+ * @param string Pointer to the string that will be iterated over.
+ */
+
+ CStringIterator(FAR const CNxString* string);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CStringIterator(void) { }
+
+ /**
+ * Moves the iterator to the first character in the string.
+ *
+ * @param Returns false if the string is empty
+ */
+
+ bool moveToFirst(void);
+
+ /**
+ * Moves the iterator to the last character in the string.
+ *
+ * @param Returns false if the string is empty
+ */
+
+ bool moveToLast(void);
+
+ /**
+ * Move the iterator to the next character in the string.
+ *
+ * @return True if the iterator moved; false if not (indicates end of string).
+ */
+
+ bool moveToNext(void);
+
+ /**
+ * Move the iterator to the previous character in the string.
+ *
+ * @return True if the iterator moved; false if not (indicates start of string).
+ */
+
+ bool moveToPrevious(void);
+
+ /**
+ * Move the iterator to the specified index.
+ *
+ * @param index The index to move to.
+ * @return True if the iterator moved; false if not (indicates end of string).
+ */
+
+ bool moveTo(int index);
+
+ /**
+ * Get the current position of the iterator within the string.
+ *
+ * @return The current character index of the iterator.
+ */
+
+ inline int getIndex(void) const
+ {
+ return m_currentIndex;
+ }
+
+ /**
+ * Get the letter in the string at the iterator's current point.
+ *
+ * @return The current character in the string.
+ */
+
+ inline nxwidget_char_t getChar(void) const
+ {
+ return *m_pCurrentChar;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSTRINGITERATOR_HXX
diff --git a/NxWidgets/libnxwidgets/include/ctext.hxx b/NxWidgets/libnxwidgets/include/ctext.hxx
new file mode 100644
index 000000000..8f8ee5783
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ctext.hxx
@@ -0,0 +1,386 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ctext.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CTEXT_HXX
+#define __INCLUDE_CTEXT_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nx.h>
+
+#include "nxconfig.hxx"
+#include "cnxfont.hxx"
+#include "tnxarray.hxx"
+#include "cnxstring.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * This class functions as a wrapper around a char array offering
+ * more advanced functionality - it can wrap text, calculate its
+ * height in pixels, calculate the width of a row, etc.
+ */
+
+ class CText : public CNxString
+ {
+ private:
+
+ /**
+ * Struct defining the position and length of a longest line within
+ * the m_linePositions array.
+ */
+
+ typedef struct
+ {
+ int index;
+ uint8_t width;
+ } LongestLine;
+
+ CNxFont *m_font; /**< Font to be used for output */
+ TNxArray<int> m_linePositions; /**< Array containing start indexes
+ of each wrapped line */
+ TNxArray<LongestLine> m_longestLines; /**< Array containing data describing
+ successively longer wrapped
+ lines */
+ uint8_t m_lineSpacing; /**< Spacing between lines of text */
+ int32_t m_textPixelHeight; /**< Total height of the wrapped
+ text in pixels */
+ uint8_t m_textPixelWidth; /**< Total width of the wrapped text
+ in pixels */
+ nxgl_coord_t m_width; /**< Width in pixels available t
+ the text */
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param font The font to use for this text object.
+ * @param text A string that this text object should wrap around.
+ * @param width The pixel width at which the text should wrap.
+ */
+
+ CText(CNxFont *font, const CNxString &text, nxgl_coord_t width);
+
+ /**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+ virtual void setText(const CNxString &text);
+
+ /**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+ virtual void setText(FAR const char *text);
+
+ /**
+ * Set the text in the string.
+ *
+ * @param text Character to to use as the new data for this string.
+ */
+
+ virtual void setText(const nxwidget_char_t text);
+
+ /**
+ * Append text to the end of the string.
+ *
+ * @param text String to append.
+ */
+
+ virtual void append(const CNxString &text);
+
+ /**
+ * Insert text at the specified character index.
+ *
+ * @param text The text to insert.
+ * @param index The char index to insert at.
+ */
+
+ virtual void insert(const CNxString &text, const int index);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex The char index to start removing from.
+ */
+
+ virtual void remove(const int startIndex);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex The char index to start removing from.
+ * @param count The number of chars to remove.
+ */
+
+ virtual void remove(const int startIndex, const int count);
+
+ /**
+ * Set the vertical spacing between rows of text.
+ *
+ * @param lineSpacing The line spacing.
+ */
+
+ void setLineSpacing(uint8_t lineSpacing);
+
+ /**
+ * Sets the pixel width of the text; text wider than
+ * this will automatically wrap.
+ *
+ * @param width Maximum pixel width of the text.
+ */
+
+ void setWidth(nxgl_coord_t width);
+
+ /**
+ * Set the font to use.
+ *
+ * @param font Pointer to the new font.
+ */
+
+ void setFont(CNxFont *font);
+
+ /**
+ * Get the number of characters in the specified line number.
+ *
+ * @param lineNumber The line number to check.
+ * @return The number of characters in the line.
+ */
+
+ const int getLineLength(const int lineNumber) const;
+
+ /**
+ * Get the number of characters in the specified line number,
+ * ignoring any trailing blank characters.
+ *
+ * @param lineNumber The line number to check.
+ * @return The number of characters in the line.
+ */
+
+ const int getLineTrimmedLength(const int lineNumber) const;
+
+ /**
+ * Get the width in pixels of the specified line number.
+ *
+ * @param lineNumber The line number to check.
+ * @return The pixel width of the line.
+ */
+
+ const nxgl_coord_t getLinePixelLength(const int lineNumber) const;
+
+ /**
+ * Get the width in pixels of the specified line number,
+ * ignoring any trailing blank characters.
+ *
+ * @param lineNumber The line number to check.
+ * @return The pixel width of the line.
+ */
+
+ const nxgl_coord_t getLineTrimmedPixelLength(const int lineNumber) const;
+
+ /**
+ * Get the total height of the text in pixels.
+ *
+ * @return The total height of the text.
+ */
+
+ inline const int32_t getPixelHeight(void) const
+ {
+ return m_textPixelHeight;
+ }
+
+ /**
+ * Get the width of the longest line in pixels.
+ *
+ * @return The width of the longest line.
+ */
+
+ inline const uint8_t getPixelWidth(void) const
+ {
+ return m_textPixelWidth;
+ }
+
+ /**
+ * Get the pixel spacing between each line of text.
+ *
+ * @return The line spacing.
+ */
+
+ inline const uint8_t getLineSpacing(void) const
+ {
+ return m_lineSpacing;
+ }
+
+ /**
+ * Get the height in pixels of a line, given as the
+ * height of the font plus the line spacing.
+ *
+ * @return The height of a line.
+ */
+
+ inline const uint8_t getLineHeight(void) const
+ {
+ return m_font->getHeight() + m_lineSpacing;
+ }
+
+ /**
+ * Get the total number of lines in the text.
+ *
+ * @return The line count.
+ */
+
+ inline const int getLineCount(void) const
+ {
+ return m_linePositions.size() - 1;
+ }
+
+ /**
+ * Get a pointer to the CText object's font.
+ *
+ * @return Pointer to the font.
+ */
+
+ CNxFont *getFont(void) const;
+
+ /**
+ * Removes lines of text from the start of the text buffer.
+ *
+ * @param lines Number of lines to remove
+ */
+
+ void stripTopLines(const int lines);
+
+ /**
+ * Wrap all of the text.
+ */
+
+ void wrap(void);
+
+ /**
+ * Wrap the text from the line containing the specified char index onwards.
+ *
+ * @param charIndex The index of the char to start wrapping from; note
+ * that the wrapping function will re-wrap that entire line of text.
+ */
+
+ void wrap(int charIndex);
+
+ /**
+ * Get the index of the line of text that contains the specified index
+ * within the raw char array.
+ *
+ * @param index The index to locate within the wrapped lines of text.
+ * @return The number of the line of wrapped text that contains the
+ * specified index.
+ */
+
+ const int getLineContainingCharIndex(const int index) const;
+
+ /**
+ * Gets the index within the char array that represents the start of the line of
+ * text indicated by the line parameter.
+ *
+ * @param line The line number to locate within the char array.
+ * @return The index within the char array of the start of the supplied line.
+ */
+
+ const int getLineStartIndex(const int line) const
+ {
+ return m_linePositions[line];
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CTEXT_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/ctextbox.hxx b/NxWidgets/libnxwidgets/include/ctextbox.hxx
new file mode 100644
index 000000000..32a0ab69f
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ctextbox.hxx
@@ -0,0 +1,375 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ctextbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CTEXTBOX_HXX
+#define __INCLUDE_CTEXTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "clabel.hxx"
+#include "cnxstring.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgeteventargs.hxx"
+#include "itextbox.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward references.
+ */
+
+ class CWidgetControl;
+ class CNxTimer;
+ class CNxString;
+
+ /**
+ * Single-line textbox widget. Can align text both vertically and
+ * horizontally in different ways. The widget gains this functionality by
+ * inheriting from the CLabel class. However, if the amount of text exceeds
+ * the dimensions of the widget, the widget will ignore its horizontal
+ * alignment settings and switch to left-aligned instead. This ensures that
+ * moving the cursor over the text will scroll through it correctly.
+ */
+
+ class CTextBox : public ITextBox, public CLabel, public CWidgetEventHandler
+ {
+ protected:
+ int m_cursorPos; /**< Position of the cursor within the string. */
+ uint8_t m_showCursor; /**< Controls cursor visibility. */
+ bool m_wrapCursor; /**< True wrap cursor at the ends of the text */
+
+ /**
+ * Redraws the widget
+ */
+
+ inline void onBlur(void);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawContents(CGraphicsPort *port);
+
+ /**
+ * Moves the cursor without redrawing.
+ *
+ * @param position New cursor position.
+ * @return True if the cursor position changed
+ */
+
+ virtual bool repositionCursor(const int position);
+
+ /**
+ * Move the cursor to the specified coordinates. The coordinates
+ * are expected to be the result of a click, and therefore in
+ * world-space rather than widget-space.
+ */
+
+ void moveCursorToClickLocation(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+ virtual void drawBorder(CGraphicsPort *port);
+
+ /**
+ * Moves the cursor to the clicked coordinates.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+ virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Does nothing.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+ virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Return true if the cursor is visible
+ */
+
+ virtual bool isCursorVisible(void) const;
+
+ /**
+ * Get the x coordinate of the cursor in pixels relative
+ * to the left-hand edge of the client rect.
+ *
+ * @return The x coordinate of the cursor in pixels.
+ */
+
+ virtual const nxgl_coord_t getCursorXPos(void) const;
+
+ /**
+ * Get the width of the cursor in pixels.
+ *
+ * @return The width of the cursor in pixels.
+ */
+
+ virtual nxgl_coord_t getCursorWidth(void) const;
+
+ /**
+ * Calculate the horizontal position of the string based on its length
+ * and the alignment options. Alignment options are overridden if the
+ * width of the string exceeds the width of the textbox.
+ */
+
+ virtual void calculateTextPositionHorizontal(void);
+
+ /**
+ * Copy constructor is protected to prevent usage.
+ */
+
+ inline CTextBox(const CTextBox& textbox) : CLabel(textbox) { };
+
+ public:
+
+ /**
+ * Constructor for a textbox containing a string.
+ *
+ * @param pWidgetControl The controlling widget for the window
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+ CTextBox(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
+ CWidgetStyle *style = (CWidgetStyle *)NULL);
+
+ /**
+ * Sets the cursor display mode.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+ virtual void showCursor(EShowCursor cursorMode);
+
+ /**
+ * Shows the cursor in default mode (only when the TextBox has focus).
+ */
+
+ virtual inline void showCursor(void)
+ {
+ showCursor(SHOW_CURSOR_ONFOCUS);
+ }
+
+ /**
+ * Hides the cursor.
+ */
+
+ virtual inline void hideCursor(void)
+ {
+ showCursor(SHOW_CURSOR_NEVER);
+ }
+
+ /**
+ * Enables/disables cursor wrapping
+ *
+ * @param wrap True enables cursor wrapping
+ */
+
+ virtual inline void wrapCursor(bool wrap)
+ {
+ m_wrapCursor = wrap;
+ }
+
+ /**
+ * Set the text displayed in the label.
+ *
+ * @param text String to display.
+ */
+
+ virtual void setText(const CNxString &text);
+
+ /**
+ * Append new text to the end of the current text displayed in the
+ * label.
+ *
+ * @param text String to append.
+ */
+
+ virtual void appendText(const CNxString &text);
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+ virtual void removeText(const unsigned int startIndex);
+
+ /**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+ virtual void removeText(const unsigned int startIndex, const unsigned int count);
+
+ /**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+ virtual void insertText(const CNxString &text, const unsigned int index);
+
+ /**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+ virtual void insertTextAtCursor(const CNxString &text);
+
+ /**
+ * Move the cursor to the text position specified. 0 indicates the
+ * start of the string. If position is greater than the length of the
+ * string, the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+ virtual void moveCursorToPosition(const int position);
+
+ /**
+ * Get the cursor position. This is the index within the string that
+ * the cursor is currently positioned over.
+ *
+ * @return position The cursor position.
+ */
+
+ virtual inline const int getCursorPosition(void) const
+ {
+ return m_cursorPos;
+ }
+
+ /**
+ * Handle a keyboard press event. Replaces CWidgetEventHandler method.
+ *
+ * @param e The event data.
+ */
+
+ void handleKeyPressEvent(const CWidgetEventArgs &e);
+
+ /**
+ * Handle a cursor control event. Replaces CWidgetEventHandler method.
+ *
+ * @param e The event data.
+ */
+
+ void handleCursorControlEvent(const CWidgetEventArgs &e);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CTEXTBOX_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
new file mode 100644
index 000000000..e709271a0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
@@ -0,0 +1,769 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwidgetcontrol.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_CWIDGETCONTROLT_HXX
+#define __INCLUDE_CWIDGETCONTROLT_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <semaphore.h>
+#include <time.h>
+
+#include "nxconfig.hxx"
+#include "cgraphicsport.hxx"
+#include "cnxwidget.hxx"
+#include "crect.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwindoweventhandler.hxx"
+#include "cwindoweventhandlerlist.hxx"
+#include "tnxarray.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class INxWindow;
+ class CNxWidget;
+
+ /**
+ * Class providing a top-level widget and an interface to the CWidgetControl
+ * widget hierarchy.
+ *
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class CWidgetControl
+ {
+ protected:
+ /**
+ * Structure holding the status of the Mouse or Touchscreen. There must
+ * be one instance of this structure per window instance. The
+ * content of this structure is update by the CGraphicsPort on each
+ * NX mouse callback
+ */
+
+ struct SMouse
+ {
+#if 0 // Center and right buttons are not used
+ uint16_t leftPressed : 1; /**< Left button pressed (or
+ touchscreen contact) */
+ uint16_t centerPressed : 1; /**< Center button pressed (not
+ used with touchscreen) */
+ uint16_t rightPressed : 1; /**< Right button pressed (not
+ used with touchscreen) */
+ uint16_t leftHeld : 1; /**< Left button held down (or
+ touchscreen contact) */
+ uint16_t centerHeld : 1; /**< Center button held down
+ (not used with touchscreen) */
+ uint16_t rightHeld : 1; /**< Right button held down
+ (not used with touchscreen) */
+ uint16_t leftDrag : 1; /**< Left button held down (or
+ touchscreen contact) */
+ uint16_t centerDrag : 1; /**< Center button held down (or
+ touchscreen contact) */
+ uint16_t rightDrag : 1; /**< Right button held down (or
+ touchscreen contact) */
+ uint16_t leftReleased : 1; /**< Left button release (or
+ loss of touchscreen contact) */
+ uint16_t centerReleased : 1; /**< Center button release (or
+ loss of touchscreen contact) */
+ uint16_t rightReleased : 1; /**< Right button release (or
+ loss of touchscreen contact) */
+ uint16_t doubleClick : 1; /**< Left button double click */
+ uint16_t unused : 3; /**< Padding bits */
+#else
+ uint8_t leftPressed : 1; /**< Left button pressed (or
+ touchscreen contact) */
+ uint8_t leftHeld : 1; /**< Left button held down (or
+ touchscreen contact) */
+ uint8_t leftDrag : 1; /**< Left button held down (or
+ touchscreen contact) */
+ uint8_t leftReleased : 1; /**< Left button release (or
+ loss of touchscreen contact) */
+ uint8_t doubleClick : 1; /**< Left button double click */
+ uint8_t unused : 3; /**< Padding bits */
+#endif
+ nxgl_coord_t x; /**< Current X coordinate of
+ the mouse/touch */
+ nxgl_coord_t y; /**< Current Y coordinate of
+ the mouse/touch */
+ nxgl_coord_t lastX; /**< X coordinate of the mouse
+ at the previous poll */
+ nxgl_coord_t lastY; /**< Y coordinate of the mouse
+ at the previous poll */
+ struct timespec leftPressTime; /**< Time the left button was
+ pressed */
+ struct timespec leftReleaseTime; /**< Time the left button was
+ released */
+ };
+
+ /**
+ * State data
+ */
+
+ CGraphicsPort *m_port; /**< The graphics port
+ that is used for
+ drawing on this window */
+ TNxArray<CNxWidget*> m_deleteQueue; /**< Array of widgets
+ awaiting deletion. */
+ TNxArray<CNxWidget*> m_widgets; /**< List of controlled
+ widgets. */
+ bool m_haveGeometry; /**< True: indicates that we
+ have valid geometry data. */
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ bool m_waiting; /**< True: Extternal logic waiting for
+ window event */
+ sem_t m_waitSem; /**< External loops waits for
+ events on this semaphore */
+#endif
+
+ /**
+ * I/O
+ */
+
+ struct SMouse m_mouse; /**< Current pointer
+ device state */
+ CNxWidget *m_clickedWidget; /**< Pointer to the widget
+ that is clicked. */
+ CNxWidget *m_focusedWidget; /**< Pointer to the widget
+ that received keyboard
+ input. */
+ uint8_t m_kbdbuf[CONFIG_NXWIDGETS_KBDBUFFER_SIZE];
+ uint8_t m_nCh; /**< Number of buffered
+ keyboard characters */
+ uint8_t m_controls[CONFIG_NXWIDGETS_CURSORCONTROL_SIZE];
+ uint8_t m_nCc; /**< Number of buffered
+ cursor controls */
+ /**
+ * The following were picked off from the position callback.
+ */
+
+ NXHANDLE m_hWindow; /**< Handle to the NX window */
+ struct nxgl_size_s m_size; /**< Size of the window */
+ struct nxgl_point_s m_pos; /**< Position in display space */
+ struct nxgl_rect_s m_bounds; /**< Size of the display */
+#ifdef CONFIG_NX_MULTIUSER
+ sem_t m_geoSem; /**< Posted when geometry is valid */
+#endif
+ CWindowEventHandlerList m_eventHandlers; /**< List of event handlers. */
+
+ /**
+ * Style
+ */
+
+ CWidgetStyle m_style; /**< Default style used by all
+ widgets in the window. */
+
+ /**
+ * Copy a widget style
+ *
+ * @param dest The destination style
+ * @param src The source to use
+ */
+
+ void copyWidgetStyle(CWidgetStyle *dest, const CWidgetStyle *src);
+
+ /**
+ * Return the elapsed time in millisconds
+ *
+ * @param startTime A time in the past from which to compute the elapsed time.
+ * @return The elapsed time since startTime
+ */
+
+ uint32_t elapsedTime(FAR const struct timespec *startTime);
+
+ /**
+ * Pass clicks to the widget hierarchy. Closes the context menu if
+ * the clicked widget is not the context menu. If a single widget
+ * is supplied, only that widget is sent the click.
+ *
+ * @param x Click xcoordinate.
+ * @param y Click ycoordinate.
+ * @param widget. Specific widget to poll. Use NULL to run the
+ * all widgets in the window.
+ */
+
+ void handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *widget);
+
+ /**
+ * Get the index of the specified controlled widget.
+ *
+ * @param widget The widget to get the index of.
+ * @return The index of the widget. -1 if the widget is not found.
+ */
+
+ const int getWidgetIndex(const CNxWidget *widget) const;
+
+ /**
+ * Delete any widgets in the deletion queue.
+ */
+
+ void processDeleteQueue(void);
+
+ /**
+ * Process mouse/touchscreen events and send throughout the hierarchy.
+ *
+ * @param widget. Specific widget to poll. Use NULL to run the
+ * all widgets in the window.
+ * @return True means a mouse event occurred
+ */
+
+ bool pollMouseEvents(CNxWidget* widget);
+
+ /**
+ * Process keypad events and send throughout the hierarchy.
+ *
+ * @return True means a keyboard event occurred
+ */
+
+ bool pollKeyboardEvents(void);
+
+ /**
+ * Process cursor control events and send throughout the hierarchy.
+ *
+ * @return True means a cursor control event was processes
+ */
+
+ bool pollCursorControlEvents(void);
+
+ /**
+ * Wake up and external logic that is waiting for a window event.
+ */
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ void postWindowEvent(void);
+#endif
+
+ /**
+ * Take the geometry semaphore (handling signal interruptions)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ void takeGeoSem(void);
+#else
+ inline void takeGeoSem(void) {}
+#endif
+
+ /**
+ * Give the geometry semaphore
+ */
+
+ inline void giveGeoSem(void)
+ {
+#ifdef CONFIG_NX_MULTIUSER
+ sem_post(&m_geoSem);
+#endif
+ }
+
+ /**
+ * Wait for geometry data
+ */
+
+ inline void waitGeoData(void)
+ {
+ takeGeoSem();
+ giveGeoSem();
+ }
+
+ /**
+ * Clear all mouse events
+ */
+
+ void clearMouseEvents(void);
+
+ public:
+
+ /**
+ * Constructor
+ *
+ * @param style The default style that all widgets on this display
+ * should use. If this is not specified, the widget will use the
+ * values stored in the defaultCWidgetStyle object.
+ */
+
+ CWidgetControl(FAR const CWidgetStyle *style = (const CWidgetStyle *)NULL);
+
+ /**
+ * Destructor.
+ */
+
+ virtual ~CWidgetControl(void);
+
+ /**
+ * Wait for an interesting window event to occur (like a mouse or keyboard event)
+ * Caller's should exercise care to assure that the test for waiting and this
+ * call are "atomic" .. perhaps by locking the scheduler like:
+ *
+ * sched_lock();
+ * <check for events>
+ * if (<no interesting events>)
+ * {
+ * window->waitForWindowEvent();
+ * }
+ * sched_unlock();
+ */
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ void waitForWindowEvent(void);
+#endif
+
+ /**
+ * Is external logic awaiting for a window event?
+ *
+ * @return True if the widget if external logic is waiting.
+ */
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ inline const bool isWaiting(void) const
+ {
+ return m_waiting;
+ }
+#endif
+
+ /**
+ * Run all code that needs to take place on a periodic basis.
+ * This method normally called externally... either periodically
+ * or when a window event is detected. If CONFIG_NXWIDGET_EVENTWAIT
+ * is defined, then external logic want call waitWindow event and
+ * when awakened, they chould call this function. As an example:
+ *
+ * for (;;)
+ * {
+ * sched_lock(); // Make the sequence atomic
+ * if (!window->pollEvents(0))
+ * {
+ * window->waitWindowEvent();
+ * }
+ * sched_unlock();
+ * }
+ *
+ * This method is just a wrapper simply calls the followi.
+ *
+ * processDeleteQueue()
+ * pollMouseEvents(widget)
+ * pollKeyboardEvents()
+ * pollCursorControlEvents()
+ *
+ * @param widget. Specific widget to poll. Use NULL to run the
+ * all widgets in the window.
+ * @return True means some interesting event occurred
+ */
+
+ bool pollEvents(CNxWidget *widget = (CNxWidget *)NULL);
+
+ /**
+ * Swaps the depth of the supplied widget.
+ * This function presumes that all child widgets are screens.
+ *
+ * @param widget The widget to be depth-swapped.
+ * @return True if the depth swap occurred.
+ */
+
+ bool swapWidgetDepth(CNxWidget *widget);
+
+ /**
+ * Add another widget to be managed by this control instance
+ *
+ * @param widget The widget to be controlled.
+ */
+
+ inline void addControlledWidget(CNxWidget* widget)
+ {
+ m_widgets.push_back(widget);
+ }
+
+ /**
+ * Remove a controlled widget
+ *
+ * @param widget The widget to be removed
+ */
+
+ void removeControlledWidget(CNxWidget* widget);
+
+ /**
+ * Get the number of controlled widgets.
+ *
+ * @return The number of child widgets belonging to this widget.
+ */
+
+ inline const int getControlledWidgetCount(void) const
+ {
+ return m_widgets.size();
+ }
+
+ /**
+ * Add a widget to the list of widgets to be deleted.
+ * Must never be called by anything other than the framework itself.
+ *
+ * @param widget The widget to add to the delete queue.
+ */
+
+ void addToDeleteQueue(CNxWidget *widget);
+
+ /**
+ * Set the clicked widget pointer. Note that this should not be
+ * called by code other than within the CWidgetControl library itself.
+ *
+ * @param widget The new clicked widget.
+ */
+
+ void setClickedWidget(CNxWidget *widget);
+
+ /**
+ * Get the clicked widget pointer.
+ *
+ * @return Pointer to the clicked widget.
+ */
+
+ inline CNxWidget *getClickedWidget(void)
+ {
+ return m_clickedWidget;
+ }
+
+ /**
+ * Set the focused widget that will receive keyboard input.
+ *
+ * @param widget The new focused widget.
+ */
+
+ void setFocusedWidget(CNxWidget *widget);
+
+ /**
+ * Reset the focused widget so that it will no longer receive keyboard input.
+ *
+ * @param widget The new focused widget.
+ */
+
+ void clearFocusedWidget(CNxWidget *widget)
+ {
+ if (widget == m_focusedWidget)
+ {
+ m_focusedWidget = (CNxWidget *)NULL;
+ }
+ }
+
+ /**
+ * Get the focused widget pointer.
+ *
+ * @return Pointer to the focused widget.
+ */
+
+ inline CNxWidget *getFocusedWidget(void)
+ {
+ return m_focusedWidget;
+ }
+
+ /**
+ * Check for the occurrence of a double click.
+ *
+ * @return Pointer to the clicked widget.
+ */
+
+ inline bool doubleClick(void)
+ {
+ return (bool)m_mouse.doubleClick;
+ }
+
+ /**
+ * Get the default widget style for this window.
+ *
+ * @param style. The location to return the widget's style
+ */
+
+ inline void getWidgetStyle(CWidgetStyle *style)
+ {
+ copyWidgetStyle(style, &m_style);
+ }
+
+ /**
+ * Set the default widget style for this window.
+ *
+ * @param style. The new widget style to copy.
+ */
+
+ inline void setWidgetStyle(const CWidgetStyle *style)
+ {
+ copyWidgetStyle(&m_style, style);
+ }
+
+ /**
+ * These remaining methods are used by the CCallback instance to
+ * provide notifications of certain events.
+ */
+
+ /**
+ * This event will occur when the position or size of the underlying
+ * window occurs.
+ *
+ * @param hWindow The window handle that should be used to communicate
+ * with the window
+ * @param pos The position of the window in the physical device space.
+ * @param size The size of the window.
+ * @param bounds The size of the underlying display (pixels x rows)
+ */
+
+ void geometryEvent(NXHANDLE hWindow,
+ const struct nxgl_size_s *size,
+ const struct nxgl_point_s *pos,
+ const struct nxgl_rect_s *bounds);
+
+ /**
+ * This event will occur when the a portion of the window that was
+ * previously obscured is now exposed.
+ *
+ * @param nxRect The region in the window that must be redrawn.
+ * @param more True means that more re-draw requests will follow
+ */
+
+ void redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more);
+
+ /**
+ * This event means that new mouse data is available for the window.
+ *
+ * @param pos The (x,y) position of the mouse.
+ * @param buttons See NX_MOUSE_* definitions.
+ */
+
+ void newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons);
+
+ /**
+ * This event means that keyboard/keypad data is available for the window.
+ *
+ * @param nCh The number of characters that are available in pStr[].
+ * @param pStr The array of characters.
+ */
+
+#ifdef CONFIG_NX_KBD
+ void newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr);
+#endif
+
+ /**
+ * This event is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending events and (2) that the
+ * window is now 'defunct' and will receive no further events.
+ *
+ * This event supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ inline void windowBlocked(FAR void *arg)
+ {
+ m_eventHandlers.raiseBlockedEvent(arg);
+ }
+#endif
+
+ /**
+ * This event means that cursor control data is available for the window.
+ *
+ * @param cursorControl The cursor control code received.
+ */
+
+ void newCursorControlEvent(ECursorControl cursorControl);
+
+ /**
+ * Get the window handle reported on the first position callback.
+ *
+ * @return This function returns the window handle.
+ */
+
+ inline NXHANDLE getWindowHandle(void)
+ {
+ return m_hWindow;
+ }
+
+ /**
+ * Get the window bounding box in physical display coordinated. This
+ * method may need to wait until geometry data is available.
+ *
+ * @return This function returns the window handle.
+ */
+
+ inline CRect getWindowBoundingBox(void)
+ {
+ waitGeoData();
+ return CRect(&m_bounds);
+ }
+
+ inline void getWindowBoundingBox(FAR struct nxgl_rect_s *bounds)
+ {
+ waitGeoData();
+ nxgl_rectcopy(bounds, &m_bounds);
+ }
+
+ /**
+ * Get the position of the window (as reported by the last NX callback). This
+ * method may need to wait until geometry data is available.
+ *
+ * @return The position.
+ */
+
+ inline bool getWindowPosition(FAR struct nxgl_point_s *pos)
+ {
+ waitGeoData();
+ pos->x = m_pos.x;
+ pos->y = m_pos.y;
+ return true;
+ }
+
+ /**
+ * Get the size of the window (as reported by the last NX callback). This
+ * method may need to wait until geometry data is available.
+ *
+ * @return The size.
+ */
+
+ inline bool getWindowSize(FAR struct nxgl_size_s *size)
+ {
+ waitGeoData();
+ size->h = m_size.h;
+ size->w = m_size.w;
+ return true;
+ }
+
+ /**
+ * Get the width of the window (as reported by the last NX callback). This
+ * method may need to wait until geometry data is available.
+ *
+ * @return The size.
+ */
+
+ inline nxgl_coord_t getWindowWidth(void)
+ {
+ waitGeoData();
+ return m_size.w;
+ }
+
+ /**
+ * Get the height of the window (as reported by the last NX callback). This
+ * method may need to wait until geometry data is available.
+ *
+ * @return The size.
+ */
+
+ inline nxgl_coord_t getWindowHeight(void)
+ {
+ waitGeoData();
+ return m_size.h;
+ }
+
+ /**
+ * The creation sequence is:
+ *
+ * 1) Create a dumb CWigetControl instance
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow.
+ * 3) The call this method with the static_cast to INxWindow to,
+ * finally, create the CGraphicsPort for this window.
+ * 4) After that, the fully smartend CWidgetControl instance can
+ * be used to generate additional widgets.
+ *
+ * @param window The instance of INxWindow needed to construct the
+ * CGraphicsPort instance
+ */
+
+ bool createGraphicsPort(INxWindow *window);
+
+ /**
+ * Get the CGraphicsPort instance for drawing on this window
+ */
+
+ inline CGraphicsPort *getGraphicsPort(void)
+ {
+ return m_port;
+ }
+
+ /**
+ * Adds a window event handler. The window handler will receive
+ * notification all NX events received by this window\.
+ *
+ * @param eventHandler A pointer to the event handler.
+ */
+
+ inline void addWindowEventHandler(CWindowEventHandler *eventHandler)
+ {
+ m_eventHandlers.addWindowEventHandler(eventHandler);
+ }
+
+ /**
+ * Remove a window event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+ inline void removeWindowEventHandler(CWindowEventHandler *eventHandler)
+ {
+ m_eventHandlers.removeWindowEventHandler(eventHandler);
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWIDGETCONTROLT_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventargs.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventargs.hxx
new file mode 100644
index 000000000..9aacafa74
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwidgeteventargs.hxx
@@ -0,0 +1,237 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwidgeteventargs.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CWIDGETEVENTARGS_HXX
+#define __INCLUDE_CWIDGETEVENTARGS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "teventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* Interesting Key events ***************************************************/
+
+#define KEY_CODE_NONE ((nxwidget_char_t)0x00) /**< No key (NUL) */
+#define KEY_CODE_BACKSPACE ((nxwidget_char_t)0x08) /**< Backspace key */
+#define KEY_CODE_DELETE ((nxwidget_char_t)0x7f) /**< Delete key */
+#define KEY_CODE_ENTER ((nxwidget_char_t)0x0d) /**< Enter key (carriage return) */
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxWidget;
+
+ /**
+ * Cursor control events
+ */
+
+ typedef enum
+ {
+ CURSOR_HOME = 1, // Set the cursor to the beginning
+ CURSOR_END, // Set the cursor to the end
+ CURSOR_UP, // Set the cursor up one row
+ CURSOR_DOWN, // Set the cursor down one row
+ CURSOR_LEFT, // Move the cursor left one column
+ CURSOR_RIGHT, // Move the cursor right one column
+ CURSOR_PAGEUP, // Move the cursor up one page
+ CURSOR_PAGEDOWN, // Move the cursor down one page
+ } ECursorControl;
+
+ /**
+ * Event arguments passed to listeners when a CNxWidget object raises an event.
+ */
+
+ class CWidgetEventArgs : public TEventArgs<CNxWidget*>
+ {
+ private:
+ nxgl_coord_t m_x; /**< X coordinateinate of the event. */
+ nxgl_coord_t m_y; /**< Y coordinateinate of the event. */
+ nxgl_coord_t m_vX; /**< X distance moved during event, for dragging. */
+ nxgl_coord_t m_vY; /**< Y distance moved during event, for dragging. */
+ nxwidget_char_t m_key; /**< The key code / cursor code that raised the event. */
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param source Pointer to the CNxWidget object that raised the event.
+ * @param x The x coordinate of the event.
+ * @param y The y coordinate of the event.
+ * @param vX The x distance of the event.
+ * @param vY The y distance of the event.
+ * @param keyCode The keycode of the event.
+ */
+
+ CWidgetEventArgs(CNxWidget *source, const nxgl_coord_t x, const nxgl_coord_t y,
+ const nxgl_coord_t vX, const nxgl_coord_t vY,
+ const nxwidget_char_t key)
+ : TEventArgs<CNxWidget*>(source)
+ {
+ m_x = x;
+ m_y = y;
+ m_vX = vX;
+ m_vY = vY;
+ m_key = key;
+ }
+
+ /**
+ * Get the x coordinate of the mouse event. Applies only to the following
+ * events: mouse click, mouse double click, mouse drag, mouse release
+ *
+ * @return The x coordinate of the event.
+ */
+
+ inline const nxgl_coord_t getX(void) const
+ {
+ return m_x;
+ }
+
+ /**
+ * Get the y coordinate of the mouse event. Applies only to the following
+ * events: mouse click, mouse double click, mouse drag, mouse release
+ *
+ * @return The y coordinate of the event.
+ */
+
+ inline const nxgl_coord_t getY(void) const
+ {
+ return m_y;
+ }
+
+ /**
+ * Get the x-axis mouse move distance of the mouse event. Applies
+ * only to the mouse drag event.
+ *
+ * @return The x-axis mouse move distance of the event.
+ */
+
+ inline const nxgl_coord_t getVX(void) const
+ {
+ return m_vX;
+ }
+
+ /**
+ * Get the y-axis mouse move distance of the event. Applies
+ * only to the mouse drag event.
+ *
+ * @return The y-axis mouse move distance of the event.
+ */
+
+ inline const nxgl_coord_t getVY(void) const
+ {
+ return m_vY;
+ }
+
+ /**
+ * Get the key press that generated the event. Applies only to
+ * the key press event.
+ *
+ * @return The key that generated the event.
+ */
+
+ inline const nxwidget_char_t getKey(void) const
+ {
+ return m_key;
+ }
+
+ /**
+ * Get the cursor control that generated the event. Applies only
+ * to the curso control event.
+ *
+ * @return The cursor control that generated the event.
+ */
+
+ inline const ECursorControl getCursorControl(void) const
+ {
+ return (ECursorControl)m_key;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWIDGETEVENTARGS_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx
new file mode 100644
index 000000000..8883fa12d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx
@@ -0,0 +1,284 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwidgeteventhandler.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CWIDGETEVENTHANDLER_HXX
+#define __INCLUDE_CWIDGETEVENTHANDLER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgeteventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxWidget;
+
+ /**
+ * Base CWidgetEventHandler class, intended to be subclassed. Any class that
+ * needs to listen for widget events should inherit from this class.
+ */
+
+ class CWidgetEventHandler
+ {
+ public:
+ /**
+ * Constructor.
+ */
+
+ inline CWidgetEventHandler() { }
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CWidgetEventHandler() { }
+
+ /**
+ * Handle a mouse button click event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleClickEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a mouse button drag event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleDragEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a drop event, triggered when the widget has been dragged-and-dropped.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleDropEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a mouse button release event that occurred within the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a mouse button release event that occurred outside the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a key press event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleKeyPressEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a cursor control event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleCursorControlEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a key repeat event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleFocusEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget blur event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleBlurEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget close event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleCloseEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget hide event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleHideEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget show event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleShowEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget enable event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleEnableEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget disable event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleDisableEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget value change event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleValueChangeEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget resize event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleResizeEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget move event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleMoveEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget scroll event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleScrollEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget double-click event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleDoubleClickEvent(const CWidgetEventArgs &e) { }
+
+ /**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+ virtual void handleActionEvent(const CWidgetEventArgs &e) { }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWIDGETEVENTHANDLER_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx
new file mode 100644
index 000000000..f0a2f1d72
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx
@@ -0,0 +1,358 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CWIDGETEVENTHANDLERLIST_HXX
+#define __INCLUDE_CWIDGETEVENTHANDLERLIST_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cwidgeteventhandler.hxx"
+#include "tnxarray.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxWidget;
+ class CListDataItem;
+
+ /**
+ * List of widget event handlers.
+ */
+ class CWidgetEventHandlerList
+ {
+ protected:
+ TNxArray<CWidgetEventHandler*> m_widgetEventHandlers; /**< List of event handlers */
+ CNxWidget *m_widget; /**< Owning widget */
+ bool m_isEnabled; /**< Indicates if events are active */
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param widget The owning widget.
+ */
+
+ CWidgetEventHandlerList(CNxWidget *widget);
+
+ /**
+ * Destructor.
+ */
+
+ ~CWidgetEventHandlerList(void) { }
+
+ /**
+ * Check if the object raises events or not.
+ *
+ * @return True if events are enabled.
+ */
+
+ bool isEnabled(void) const;
+
+ /**
+ * Get the event handler at the specified index.
+ *
+ * @param index The index of the event handler.
+ * @return The event handler at the specified index.
+ */
+
+ inline CWidgetEventHandler *at(int index) const
+ {
+ return m_widgetEventHandlers.at(index);
+ }
+
+ /**
+ * Get the size of the array.
+ *
+ * @return The size of the array.
+ */
+
+ inline nxgl_coord_t size(void) const
+ {
+ return m_widgetEventHandlers.size();
+ }
+
+ /**
+ * Adds a widget event handler. The event handler will receive
+ * all events raised by this object.
+ * @param eventHandler A pointer to the event handler.
+ */
+
+ void addWidgetEventHandler(CWidgetEventHandler *eventHandler);
+
+ /**
+ * Remove a widget event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+ void removeWidgetEventHandler(CWidgetEventHandler *eventHandler);
+
+ /**
+ * Enables event raising.
+ */
+
+ inline void enable(void)
+ {
+ m_isEnabled = true;
+ }
+
+ /**
+ * Disables event raising.
+ */
+
+ inline void disable(void)
+ {
+ m_isEnabled = false;
+ }
+
+ /**
+ * Raise a click event to the event handler.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ void raiseClickEvent(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raise a double-click event to the event handler.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+ void raiseDoubleClickEvent(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raise a mouse release event to the event handler.
+ *
+ * @param x The x coordinate of the release.
+ * @param y The y coordinate of the release.
+ */
+
+ void raiseReleaseEvent(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raise a mouse release-outside event to the event handler.
+ *
+ * @param x The x coordinate of the release.
+ * @param y The y coordinate of the release.
+ */
+
+ void raiseReleaseOutsideEvent(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raise a mouse drag event to the event handler.
+ *
+ * @param x The x coordinate of the mouse when the drag started.
+ * @param y The y coordinate of the mouse when the drag started.
+ * @param vX The horizontal distance dragged.
+ * @param vY The vertical distance dragged.
+ */
+
+ void raiseDragEvent(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Raise a widget drop event to the event handler.
+ *
+ * @param x The x coordinate of the mouse when the drop occurred.
+ * @param y The y coordinate of the mouse when the drop occurred.
+ */
+
+ void raiseDropEvent(nxgl_coord_t x, nxgl_coord_t y);
+
+ /**
+ * Raise a key press event to the event handler.
+ *
+ * @param key The character code of the key that caused the event.
+ */
+
+ void raiseKeyPressEvent(nxwidget_char_t key);
+
+ /**
+ * Raise a cursor control event to the event handler.
+ *
+ * @param cursorControl The cursor control code that caused the event.
+ */
+
+ void raiseCursorControlEvent(ECursorControl cursorControl);
+
+ /**
+ * Raise a focus event to the event handler.
+ */
+
+ void raiseFocusEvent(void);
+
+ /**
+ * Raise a blur event to the event handler.
+ */
+
+ void raiseBlurEvent(void);
+
+ /**
+ * Raise a close event to the event handler.
+ */
+
+ void raiseCloseEvent(void);
+
+ /**
+ * Raise a hide event to the event handler.
+ */
+
+ void raiseHideEvent(void);
+
+ /**
+ * Raise a show event to the event handler.
+ */
+
+ void raiseShowEvent(void);
+
+ /**
+ * Raise an enable event to the event handler.
+ */
+
+ void raiseEnableEvent(void);
+
+ /**
+ * Raise a disable event to the event handler.
+ */
+
+ void raiseDisableEvent(void);
+
+ /**
+ * Raise a value change event to the event handler.
+ */
+
+ void raiseValueChangeEvent(void);
+
+ /**
+ * Raise a resize event to the event handler.
+ *
+ * @param width The new width of the widget.
+ * @param height The new height of the widget.
+ */
+
+ void raiseResizeEvent(nxgl_coord_t width, nxgl_coord_t height);
+
+ /**
+ * Raise a move event to the event handler.
+ *
+ * @param x The new x coordinate of the widget.
+ * @param y The new y coordinate of the widget.
+ * @param vX The horizontal distance moved.
+ * @param vY The vertical distance moved.
+ */
+
+ void raiseMoveEvent(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY);
+
+ /**
+ * Raise an action event to the event handler. This should be called
+ * when a widget's purpose has been fulfilled. For example, in the case
+ * of a button, this event is raised when the button is released within
+ * its boundaries. The button has produced a valid click, and thus
+ * fulfilled its purpose, so it needs to raise an "action" event.
+ */
+
+ void raiseActionEvent(void);
+
+ /**
+ * Raises a scroll event. Fired when the panel scrolls.
+ *
+ * @param vX Horizontal distance scrolled.
+ * @param vY Vertical distance scrolled.
+ */
+
+ void raiseScrollEvent(nxgl_coord_t vX, nxgl_coord_t vY);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWIDGETEVENTHANDLERLIST_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwidgetstyle.hxx b/NxWidgets/libnxwidgets/include/cwidgetstyle.hxx
new file mode 100644
index 000000000..8fe5e2c32
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwidgetstyle.hxx
@@ -0,0 +1,135 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwidgetstyle.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_CWIDGETSTYLE_HXX
+#define __INCLUDE_CWIDGETSTYLE_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxFont;
+
+ /**
+ * Class containing all colors that a widget depends on.
+ */
+
+ class CWidgetColors
+ {
+ public:
+ nxgl_mxpixel_t background; /**< Color used for a normal background */
+ nxgl_mxpixel_t selectedBackground; /**< Color used for a selected background */
+ nxgl_mxpixel_t shineEdge; /**< Color used as light bevel edge */
+ nxgl_mxpixel_t shadowEdge; /**< Color used as dark bevel edge */
+ nxgl_mxpixel_t highlight; /**< Color used as highlighted elements */
+ nxgl_mxpixel_t disabledText; /**< Color used for text in a disabled widget */
+ nxgl_mxpixel_t enabledText; /**< Color used for text in a enabled widget */
+ nxgl_mxpixel_t selectedText; /**< Color used for text in a clicked widget */
+ };
+
+ /**
+ * Class providing the default colors and fonts for all widgets. This
+ * information is copied into the widgets when they are constructed, so you
+ * will need to change these values *before* creating any widgets if you
+ * want those widgets to use the altered colors.
+ *
+ * If the font objects are set, NXWidgets will use them in preference to the
+ * default system fonts.
+ */
+
+ class CWidgetStyle
+ {
+ public:
+ CWidgetColors colors; /**< Default widget colors */
+ CNxFont *font; /**< Default font */
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWIDGETSTYLE_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx b/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx
new file mode 100644
index 000000000..574c24b55
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwindoweventhandler.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_CWINDOWEVENTHANDLER_HXX
+#define __INCLUDE_CWINDOWEVENTHANDLER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "nxconfig.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CNxWidget;
+
+ /**
+ * Base CWindowEventHandler class, intended to be subclassed. Any class that
+ * needs to listen for window events should inherit from this class.
+ */
+
+ class CWindowEventHandler
+ {
+ public:
+ /**
+ * Constructor.
+ */
+
+ inline CWindowEventHandler() { }
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~CWindowEventHandler() { }
+
+ /**
+ * Handle a NX window redraw request event
+ */
+
+ virtual void handleRedrawEvent(void) { }
+
+ /**
+ * Handle a NX window position/size change event
+ */
+
+ virtual void handleGeometryEvent(void) { }
+
+ /**
+ * Handle an NX window mouse input event.
+ *
+ * @param e The event data.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+ virtual void handleMouseEvent(void) { }
+#endif
+
+ /**
+ * Handle a NX window keyboard input event.
+ */
+
+#ifdef CONFIG_NX_KBD
+ virtual void handleKeyboardEvent(void) { }
+#endif
+
+ /**
+ * Handle a NX window blocked event
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+ virtual void handleBlockedEvent(FAR void *arg) { }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWINDOWEVENTHANDLER_HXX
diff --git a/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx b/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
new file mode 100644
index 000000000..035e6a7b9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
@@ -0,0 +1,176 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.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_CWINDOWEVENTHANDLERLIST_HXX
+#define __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cwindoweventhandler.hxx"
+#include "tnxarray.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class CListDataItem;
+
+ /**
+ * List of window event handlers.
+ */
+ class CWindowEventHandlerList
+ {
+ protected:
+ TNxArray<CWindowEventHandler*> m_eventHandlers; /**< List of event handlers */
+
+ /**
+ * Return the index to the window event handler.
+ */
+
+ bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index);
+
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param widget The owning widget.
+ */
+
+ CWindowEventHandlerList(void) { }
+
+ /**
+ * Destructor.
+ */
+
+ inline ~CWindowEventHandlerList(void) { }
+
+ /**
+ * Get the event handler at the specified index.
+ *
+ * @param index The index of the event handler.
+ * @return The event handler at the specified index.
+ */
+
+ inline CWindowEventHandler *at(const int index) const
+ {
+ return m_eventHandlers.at(index);
+ }
+
+ /**
+ * Get the size of the array.
+ *
+ * @return The size of the array.
+ */
+
+ inline const nxgl_coord_t size(void) const
+ {
+ return m_eventHandlers.size();
+ }
+
+ /**
+ * Adds a window event handler. The event handler will receive
+ * all events raised by this object.
+ * @param eventHandler A pointer to the event handler.
+ */
+
+ void addWindowEventHandler(CWindowEventHandler *eventHandler);
+
+ /**
+ * Remove a window event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+ void removeWindowEventHandler(CWindowEventHandler *eventHandler);
+
+ /**
+ * Raise the NX window redraw event.
+ */
+
+ void raiseRedrawEvent(void);
+
+ /**
+ * Raise an NX window position/size change event.
+ */
+
+ void raiseGeometryEvent(void);
+
+ /**
+ * Raise an NX mouse window input event.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+ void raiseMouseEvent(void);
+#endif
+
+ /**
+ * Raise an NX keybord input event
+ */
+
+#ifdef CONFIG_NX_KBD
+ void raiseKeyboardEvent(void);
+#endif
+
+ /**
+ * Raise an NX window blocked event.
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+ void raiseBlockedEvent(FAR void *arg);
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
diff --git a/NxWidgets/libnxwidgets/include/glyphs.hxx b/NxWidgets/libnxwidgets/include/glyphs.hxx
new file mode 100644
index 000000000..afd6cc7a0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/glyphs.hxx
@@ -0,0 +1,131 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/glyphs.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_GLYPHS_HXX
+#define __INCLUDE_GLYPHS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Bitmap Glyph References
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ struct SBitmap;
+
+ // Global RLE Paletted Bitmaps
+
+ extern const struct SRlePaletteBitmap g_nuttxBitmap;
+
+ // Global Simple Bitmaps
+
+ extern const struct SBitmap g_screenDepthUp;
+ extern const struct SBitmap g_screenDepthDown;
+ extern const struct SBitmap g_windowClose;
+ extern const struct SBitmap g_windowDepthUp;
+ extern const struct SBitmap g_windowDepthDown;
+ extern const struct SBitmap g_radioButtonOn;
+ extern const struct SBitmap g_radioButtonOff;
+ extern const struct SBitmap g_radioButtonMu;
+ extern const struct SBitmap g_checkBoxOff;
+ extern const struct SBitmap g_checkBoxOn;
+ extern const struct SBitmap g_checkBoxMu;
+ extern const struct SBitmap g_screenFlipUp;
+ extern const struct SBitmap g_screenFlipDown;
+ extern const struct SBitmap g_arrowUp;
+ extern const struct SBitmap g_arrowDown;
+ extern const struct SBitmap g_arrowLeft;
+ extern const struct SBitmap g_arrowRight;
+ extern const struct SBitmap g_cycle;
+ extern const struct SBitmap g_backspace;
+ extern const struct SBitmap g_return;
+ extern const struct SBitmap g_shift;
+ extern const struct SBitmap g_capslock;
+ extern const struct SBitmap g_control;
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_GLYPHS_HXX
diff --git a/NxWidgets/libnxwidgets/include/ibitmap.hxx b/NxWidgets/libnxwidgets/include/ibitmap.hxx
new file mode 100644
index 000000000..923df407a
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ibitmap.hxx
@@ -0,0 +1,183 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ibitmap.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_IBITMAP_HXX
+#define __INCLUDE_IBITMAP_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Abstract class defining the basic properties of a source bitmap. The
+ * primary intent of this class is two support a variety of sources of
+ * bitmap data with various kinds of compression.
+ */
+
+ class IBitmap
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the IBitmap
+ * destructor. We do this because if we delete IBitmap, we want the
+ * destructor of the class that inherits from IBitmap to run, not this
+ * one.
+ */
+
+ virtual ~IBitmap(void) { }
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's width.
+ */
+
+ virtual const uint8_t getColorFormat(void) const = 0;
+
+ /**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's color format.
+ */
+
+ virtual const uint8_t getBitsPerPixel(void) const = 0;
+
+ /**
+ * Get the bitmap's width (in pixels/columns).
+ *
+ * @return The bitmap's pixel depth.
+ */
+
+ virtual const nxgl_coord_t getWidth(void) const = 0;
+
+ /**
+ * Get the bitmap's height (in rows).
+ *
+ * @return The bitmap's height.
+ */
+
+ virtual const nxgl_coord_t getHeight(void) const = 0;
+
+ /**
+ * Get the bitmap's width (in bytes).
+ *
+ * @return The bitmap's width.
+ */
+
+ virtual const nxgl_coord_t getStride(void) const = 0;
+
+ /**
+ * Use the colors associated with a selected image.
+ *
+ * @param selected. true: Use colors for a selected widget,
+ * false: Use normal (default) colors.
+ */
+
+ virtual void setSelected(bool selected) = 0;
+
+ /**
+ * Get one row from the bit map image using the selected colors.
+ *
+ * @param x The offset into the row to get
+ * @param y The row number to get
+ * @param width The number of pixels to get from the row
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @param True if the run was returned successfully.
+ */
+
+ virtual bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ FAR void *data) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_IBITMAP_HXX
diff --git a/NxWidgets/libnxwidgets/include/ilistbox.hxx b/NxWidgets/libnxwidgets/include/ilistbox.hxx
new file mode 100644
index 000000000..0eb33bc3b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ilistbox.hxx
@@ -0,0 +1,281 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ilistbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_ILISTBOX_HXX
+#define __INCLUDE_ILISTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "clistboxdataitem.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Defines the interface for ListBox classes.
+ */
+
+ class IListBox
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the IListBox
+ * destructor. We do this because if we delete IListBox, we want the
+ * destructor of the class that inherits from IListBox to run, not this
+ * one.
+ */
+
+ virtual ~IListBox(void) { }
+
+ /**
+ * Add a new option to the widget using default colors.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value) = 0;
+
+ /**
+ * Add an option to the widget.
+ *
+ * @param option The option to add.
+ */
+
+ virtual void addOption(CListBoxDataItem *option) = 0;
+
+ /**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+ virtual void removeOption(const int index) = 0;
+
+ /**
+ * Remove all options from the widget.
+ */
+
+ virtual void removeAllOptions(void) = 0;
+
+ /**
+ * Add a new option to the widget.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+ virtual void addOption(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor) = 0;
+
+ /**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual void selectOption(const int index) = 0;
+
+ /**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+ virtual void deselectOption(const int index) = 0;
+
+ /**
+ * Select all options. Does nothing if the listbox does not allow
+ * multiple selections. Redraws the widget and raises a value
+ * changed event.
+ */
+
+ virtual void selectAllOptions(void) = 0;
+
+ /**
+ * Deselect all options.
+ * Redraws the widget and raises a value changed event.
+ */
+
+ virtual void deselectAllOptions(void) = 0;
+
+ /**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * option is selected, the index of the first selected option is returned.
+ *
+ * @return The selected index.
+ */
+
+ virtual const int getSelectedIndex(void) const = 0;
+
+ /**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected options to deselected.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+ virtual void setSelectedIndex(const int index) = 0;
+
+ /**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+ virtual const CListBoxDataItem *getSelectedOption(void) const = 0;
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @param allowMultipleSelections True to allow multiple selections.
+ */
+
+ virtual void setAllowMultipleSelections(const bool allowMultipleSelections) = 0;
+
+ /**
+ * Sets whether multiple selections are possible or not.
+ *
+ * @return True if multiple selections are allowed.
+ */
+
+ virtual const bool allowsMultipleSelections(void) const = 0;
+
+ /**
+ * Get the specified option.
+ *
+ * @return The specified option.
+ */
+
+ virtual const CListBoxDataItem *getOption(const int index) = 0;
+
+ /**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+ virtual void sort(void) = 0;
+
+ /**
+ * Get the total number of options.
+ *
+ * @return The number of options.
+ */
+
+ virtual const int getOptionCount(void) const = 0;
+
+ /**
+ * Get the height of a single option.
+ *
+ * @return The height of an option.
+ */
+
+ virtual const nxgl_coord_t getOptionHeight(void) const = 0;
+
+ /**
+ * Sets whether or not items added to the list are automatically sorted on insert or not.
+ *
+ * @param sortInsertedItems True to enable sort on insertion.
+ */
+
+ virtual void setSortInsertedItems(const bool sortInsertedItems) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_ILISTBOX_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx b/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx
new file mode 100644
index 000000000..26bf1411b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/ilistdataeventhandler.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_ILISTDATAEVENTHANDLERR_HXX
+#define __INCLUDE_ILISTDATAEVENTHANDLERR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "clistdataeventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ class ListData;
+
+ /**
+ * Base IListDataEventHandler class, intended to be subclassed. Any class
+ * that needs to listen for CListData events should inherit from this class.
+ */
+
+ class IListDataEventHandler
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the IListDataEventHandler
+ * destructor. We do this because if we delete IListDataEventHandler, we want the
+ * destructor of the class that inherits from IListDataEventHandler to run, not this
+ * one.
+ */
+
+ virtual ~IListDataEventHandler(void) { }
+
+ /**
+ * Handle data changes.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void handleListDataChangedEvent(const CListDataEventArgs &e) = 0;
+
+ /**
+ * Handle data changes.
+ *
+ * @param e Event arguments.
+ */
+
+ virtual void
+ handleListDataSelectionChangedEvent(const CListDataEventArgs &e) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_ILISTDATAEVENTHANDLERR_HXX
diff --git a/NxWidgets/libnxwidgets/include/inxwindow.hxx b/NxWidgets/libnxwidgets/include/inxwindow.hxx
new file mode 100644
index 000000000..210a1e6ce
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/inxwindow.hxx
@@ -0,0 +1,308 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/inxwindow.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_INXWINDOW_HXX
+#define __INCLUDE_INXWINDOW_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Pure Virtual Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ struct SBitmap;
+ class CWidgetControl;
+
+ /**
+ * This class defines common operations on a any NX window.
+ * There are three instances that represent an NX window from the
+ * perspective of NXWidgets.
+ *
+ * - There is one widget control instance per NX window,
+ * - One CCallback instance per window,
+ * - One window instance.
+ *
+ * There a various kinds of of window instances, but each inherits
+ * (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
+ * that describes the common window behavior.
+ */
+
+ class INxWindow
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the INxWindow
+ * destructor. We do this because if we delete INxWindow, we want the
+ * destructor of the class that inherits from INxWindow to run, not this
+ * one.
+ */
+
+ virtual ~INxWindow(void) { }
+
+ /**
+ * Creates a new window. Window creation is separate from
+ * object instantiation so that window creation failures can
+ * be properly reported.
+ *
+ * @return True if the window was successfully created.
+ */
+
+ virtual bool open(void) = 0;
+
+ /**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+ virtual CWidgetControl *getWidgetControl(void) const = 0;
+
+ /**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return OK on success; ERROR on failure with errno set appropriately.
+ */
+
+ virtual bool requestPosition(void) = 0;
+
+ /**
+ * Get the position of the window (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+ virtual bool getPosition(FAR struct nxgl_point_s *pPos) = 0;
+
+ /**
+ * Get the size of the window (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+ virtual bool getSize(FAR struct nxgl_size_s *pSize) = 0;
+
+ /**
+ * Set the position and size of the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on failure.
+ */
+
+ virtual bool setPosition(FAR const struct nxgl_point_s *pPos) = 0;
+
+ /**
+ * Set the size of the selected window.
+ *
+ * @param pSize The new size of the window.
+ * @return OK on success; ERROR on failure with errno set appropriately.
+ */
+
+ virtual bool setSize(FAR const struct nxgl_size_s *pSize) = 0;
+
+ /**
+ * Bring the window to the top of the display.
+ *
+ * @return OK on success; ERROR on failure with errno set appropriately.
+ */
+
+ virtual bool raise(void) = 0;
+
+ /**
+ * Lower the window to the bottom of the display.
+ *
+ * @return OK on success; ERROR on failure with errno set appropriately.
+ */
+
+ virtual bool lower(void) = 0;
+
+ /**
+ * Each window implementation also inherits from CCallback. CCallback,
+ * by default, forwards NX keyboard input to the various widgets residing
+ * in the window. But NxConsole is a different usage model; In this case,
+ * keyboard input needs to be directed to the NxConsole character driver.
+ * This method can be used to enable (or disable) redirection of NX
+ * keyboard input from the window widgets to the NxConsole
+ *
+ * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard
+ * input will be directed to the NxConsole driver using this
+ * handle; If NULL (the default), NX keyboard input will be
+ * directed to the widgets within the window.
+ */
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ virtual void redirectNxConsole(NXCONSOLE handle) = 0;
+#endif
+
+ /**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color) = 0;
+
+ /**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color) = 0;
+
+ /**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+ virtual void getRectangle(FAR const struct nxgl_rect_s *rect,
+ struct SBitmap *dest) = 0;
+
+ /**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color) = 0;
+
+ /**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width,
+ nxgl_mxpixel_t color) = 0;
+
+ /**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+ virtual bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color) = 0;
+
+ /**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset) = 0;
+
+ /**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window. The source image is treated as an opaque image.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+ virtual bool bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_INXWINDOW_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/iscrollable.hxx b/NxWidgets/libnxwidgets/include/iscrollable.hxx
new file mode 100644
index 000000000..b0e65a9db
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/iscrollable.hxx
@@ -0,0 +1,217 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/iscrollable.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_ISCROLLABLE_HXX
+#define __INCLUDE_ISCROLLABLE_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Abstract class defining basic functionality of scrolling widgets.
+ * Scrolling regions are modelled as a virtual "canvas", or rectangular
+ * region, with height/width dimensions and x/y coordinates.
+ */
+
+ class IScrollable
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the IScrollable
+ * destructor. We do this because if we delete IScrollable, we want the
+ * destructor of the class that inherits from IScrollable to run, not this
+ * one.
+ */
+
+ virtual ~IScrollable(void) { }
+
+ /**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasX(void) const = 0;
+
+ /**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasY(void) const = 0;
+
+ /**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasWidth(void) const = 0;
+
+ /**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+ virtual const int32_t getCanvasHeight(void) const = 0;
+
+ /**
+ * Scrolls the virtual canvas by the specified amounts.
+ *
+ * @param dx Distance to scroll horizontally.
+ * @param dy Distance to scroll vertically.
+ */
+
+ virtual void scroll(int32_t dx, int32_t dy) = 0;
+
+ /**
+ * Repositions the virtual canvas to the specified coordinates.
+ *
+ * @param x New x coordinate of the virtual canvas.
+ * @param y New y coordinate of the virtual canvas.
+ */
+
+ virtual void jump(int32_t x, int32_t y) = 0;
+
+ /**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+ virtual bool allowsVerticalScroll(void) const = 0;
+
+ /**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+ virtual bool allowsHorizontalScroll(void) const = 0;
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsVerticalScroll(bool allow) = 0;
+
+ /**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+ virtual void setAllowsHorizontalScroll(bool allow) = 0;
+
+ /**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+ virtual void setCanvasWidth(const int32_t width) = 0;
+
+ /**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+ virtual void setCanvasHeight(const int32_t height) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_ISCROLLABLE_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/islider.hxx b/NxWidgets/libnxwidgets/include/islider.hxx
new file mode 100644
index 000000000..5a9340923
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/islider.hxx
@@ -0,0 +1,196 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/islider.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_ISLIDER_HXX
+#define __INCLUDE_ISLIDER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Defines the interface for slider widgets.
+ */
+ class ISlider
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the ISlider
+ * destructor. We do this because if we delete ISlider, we want the
+ * destructor of the class that inherits from ISlider to run, not this
+ * one.
+ */
+
+ virtual ~ISlider(void) { }
+
+ /**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+ virtual const nxgl_coord_t getMinimumValue(void) const = 0;
+
+ /**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+ virtual const nxgl_coord_t getMaximumValue(void) const = 0;
+
+ /**
+ * Get the current value of the slider.
+ *
+ * return The current slider value.
+ */
+
+ virtual const nxgl_coord_t getValue(void) const = 0;
+
+ /**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+ virtual const nxgl_coord_t getPageSize(void) const = 0;
+
+ /**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+ virtual void setMinimumValue(const nxgl_coord_t value) = 0;
+
+ /**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+ virtual void setMaximumValue(const nxgl_coord_t value) = 0;
+
+ /**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+ virtual void setValue(const nxgl_coord_t value) = 0;
+
+ /**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+ virtual void setValueWithBitshift(const int32_t value) = 0;
+
+ /**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+ virtual void setPageSize(const nxgl_coord_t pageSize) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_ISLIDER_HXX
+
diff --git a/NxWidgets/libnxwidgets/include/itextbox.hxx b/NxWidgets/libnxwidgets/include/itextbox.hxx
new file mode 100644
index 000000000..0e2e7b824
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/itextbox.hxx
@@ -0,0 +1,217 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/itextbox.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_ITEXTBOX_HXX
+#define __INCLUDE_ITEXTBOX_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cnxstring.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgeteventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Cursor display options.
+ */
+
+ typedef enum
+ {
+ SHOW_CURSOR_ONFOCUS = 0, /**< Show the cursor only if the widget has focus */
+ SHOW_CURSOR_NEVER, /**< The cursor is never displayed */
+ SHOW_CURSOR_ALWAYS /**< Always show the cursor */
+ } EShowCursor;
+
+ /**
+ * Defines the interface that textbox-like classes should implement.
+ */
+
+ class ITextBox
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the ITextBox
+ * destructor. We do this because if we delete ITextBox, we want the
+ * destructor of the class that inherits from ITextBox to run, not this
+ * one.
+ */
+
+ virtual ~ITextBox(void) { }
+
+ /**
+ * Sets the cursor display mode.
+ *
+ *@param cursorMode Determines cursor display mode
+ */
+
+ virtual void showCursor(EShowCursor cursorMode) = 0;
+
+ /**
+ * Enables/disables cursor wrapping
+ *
+ * @param wrap True enables cursor wrapping
+ */
+
+ virtual void wrapCursor(bool wrap) = 0;
+
+ /**
+ * Set the text displayed in the label.
+ *
+ * @param text String to display.
+ */
+
+ virtual void setText(const CNxString &text) = 0;
+
+ /**
+ * Append new text to the end of the current text displayed in the
+ * label.
+ *
+ * @param text String to append.
+ */
+
+ virtual void appendText(const CNxString &text) = 0;
+
+ /**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+ virtual void removeText(const unsigned int startIndex) = 0;
+
+ /**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+ virtual void removeText(const unsigned int startIndex, const unsigned int count) = 0;
+
+ /**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+ virtual void insertText(const CNxString &text, const unsigned int index) = 0;
+
+ /**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+ virtual void insertTextAtCursor(const CNxString &text) = 0;
+
+ /**
+ * Move the cursor to the text position specified. 0 indicates the
+ * start of the string. If position is greater than the length of the
+ * string, the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+ virtual void moveCursorToPosition(const int position) = 0;
+
+ /**
+ * Get the cursor position. This is the index within the string that
+ * the cursor is currently positioned over.
+ * @return position The cursor position.
+ */
+
+ virtual const int getCursorPosition(void) const = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_ITEXTBOX_HXX
diff --git a/NxWidgets/libnxwidgets/include/nxconfig.hxx b/NxWidgets/libnxwidgets/include/nxconfig.hxx
new file mode 100644
index 000000000..699686822
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/nxconfig.hxx
@@ -0,0 +1,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/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_MOUSE=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+1. 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(160,160,160)
+ * CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR - Default selected background
+ * color. Default: MKRGB(120,192,192)
+ * CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR - Shiny side boarder color. Default
+ * MKRGB(248,248,248)
+ * CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR - Shadowed side border color.
+ * Default: MKRGB(0,0,0)
+ * 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_DISABLEDTEXTCOLOR - 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_MOUSE
+# warning "NX mouse/touchscreen support is required (CONFIG_NX_MOUSE)"
+#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
+
+/* NxConsole 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_NXCONSOLE)
+# undef CONFIG_NXCONSOLE_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+1)
+#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 RBG8RED
+# define RGB2GREEN RBG8GREEN
+# define RGB2BLUE RBG8BLUE
+# 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 RBG16RED
+# define RGB2GREEN RBG16GREEN
+# define RGB2BLUE RBG16BLUE
+# 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 RBG24RED
+# define RGB2GREEN RBG24GREEN
+# define RGB2BLUE RBG24BLUE
+# 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 RBG24RED
+# define RGB2GREEN RBG24GREEN
+# define RGB2BLUE RBG24BLUE
+# 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(160,160,160)
+#endif
+
+/**
+ * Default selected background color
+ */
+
+#ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR
+# define CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(120,192,192)
+#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(0,0,0)
+#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
diff --git a/NxWidgets/libnxwidgets/include/singletons.hxx b/NxWidgets/libnxwidgets/include/singletons.hxx
new file mode 100644
index 000000000..094808939
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/singletons.hxx
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/singletons.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_SINGLETONS_HXX
+#define __INCLUDE_SINGLETONS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <cnxtimer.hxx>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Forward References
+ */
+
+ class CWidgetStyle;
+ class CNxString;
+
+ /**
+ * Global singleton instances
+ */
+
+ extern CWidgetStyle *g_defaultWidgetStyle; /**< The default widget style */
+ extern CNxString *g_nullString; /**< The reusable empty string */
+ extern TNxArray<CNxTimer*> *g_nxTimers; /**< An array of all timers */
+
+ /**
+ * Setup misc singleton instances.
+ *
+ * Q: Why is there here?
+ * A: Because it needs to be done one time before any widgets are created.
+ * Q: So why isn't it just the default style just a statically constructed class?
+ * A: Because not all platforms will support static class constructions.
+ * Q: Why isn't it part of CNxServer?
+ * A: Because the singletons may be needed before the server is started.
+ */
+
+ void instantiateSingletons(void);
+
+ /**
+ * Free the singleton instances when the last NX server is destroyed.
+ *
+ * Q: Why is there here is it is only called as part of the CNxServer destructor?
+ * A: Just for symmetry with instantiateSingletons().
+ */
+
+ void freeSingletons(void);
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_SINGLETONS_HXX
diff --git a/NxWidgets/libnxwidgets/include/teventargs.hxx b/NxWidgets/libnxwidgets/include/teventargs.hxx
new file mode 100644
index 000000000..c1371be92
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/teventargs.hxx
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/teventargs.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_TEVENTARGS_HXX
+#define __INCLUDE_TEVENTARGS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NXWidgets
+{
+ /**
+ * Base template class for all events within the NxWidgets system.
+ * All event types should inherit from this class.
+ */
+
+ template <class T>
+ class TEventArgs
+ {
+ private:
+ T m_source; /**< The object that raised the event */
+
+ public:
+
+ /**
+ * Constructor.
+ * @param source The object that raised the event.
+ */
+
+ inline TEventArgs(const T& source)
+ {
+ m_source = source;
+ }
+
+ /**
+ * Destructor.
+ */
+
+ virtual inline ~TEventArgs() { }
+
+ /**
+ * Get the source object that raised the event.
+ */
+
+ inline const T& getSource(void) const
+ {
+ return m_source;
+ }
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_TEVENTARGS_HXX
diff --git a/NxWidgets/libnxwidgets/include/tnxarray.hxx b/NxWidgets/libnxwidgets/include/tnxarray.hxx
new file mode 100644
index 000000000..44cb537ad
--- /dev/null
+++ b/NxWidgets/libnxwidgets/include/tnxarray.hxx
@@ -0,0 +1,437 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/tnxarray.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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_TNXARRAY_HXX
+#define __INCLUDE_TNXARRAY_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+/**
+ * Class providing a dynamic array; that is, an array that will automatically
+ * grow to accommodate new data. It provides a fast way to randomly access
+ * a list of data. Essentially, it provides the most important functionality
+ * of the STL vector class without any of the overhead of including an STL
+ * class.
+ *
+ * If the data to be stored will store a lot of data that will predominantly
+ * be read sequentially, consider using the LinkedList class instead. Resizing
+ * the list is an expensive operation that will occur frequently when filling
+ * the array with large amounts of data. Adding new data to the linked list is
+ * very inexpensive.
+ */
+
+template <class T>
+class TNxArray
+{
+private:
+ T *m_data; /**< Internal array of data items */
+ int m_size; /**< Number of items in the array */
+ int m_reservedSize; /**< Total size of the array including unpopulated slots */
+
+ /**
+ * Re-allocate the array to this size;
+ */
+
+ void reallocate(const int newSize);
+
+ /**
+ * Resize the array if it is full.
+ */
+
+ void resize(void);
+
+public:
+
+ /**
+ * Constructor. Creates an un-allocated array. The array will
+ * be allocated when items are added to it or when preallocate()
+ * is called.
+ */
+
+ inline TNxArray();
+
+ /**
+ * Constructor. Creates an allocated array.
+ *
+ *@param initialSize The initial size of the array.
+ */
+
+ inline TNxArray(int initialSize);
+
+ /**
+ * Destructor.
+ */
+
+ inline ~TNxArray();
+
+ /**
+ * Set the initial size of the array. Normally, the array is
+ * unallocated until the first data is pushed into the array.
+ * That works great for stacks and lists. But if you want a
+ * array of unitialized elements, then this method will
+ * preallocate the array for you.
+ *
+ * @return The size of the array.
+ */
+
+ void preallocate(void);
+
+ /**
+ * Get the size of the array.
+ *
+ * @return The size of the array.
+ */
+
+ inline const int size(void) const;
+
+ /**
+ * Add a value to the end of the array.
+ *
+ * @param value The value to add to the array.
+ */
+
+ void push_back(const T &value);
+
+ /**
+ * Insert a value into the array.
+ *
+ * @param index The index to insert into.
+ * @param value The value to insert.
+ */
+
+ void insert(const int index, const T &value);
+
+ /**
+ * Remove the last element from the array.
+ */
+
+ void pop_back(void);
+
+ /**
+ * Erase a single value at the specified index
+ */
+
+ void erase(const int index);
+
+ /**
+ * Get a value at the specified location. Does not perform bounds checking.
+ * @param index The index of the desired value.
+ * @return The value at the specified index.
+ */
+
+ inline T &at(const int index) const;
+
+ /**
+ * Check if the array has any data.
+ * @return True if the array is empty.
+ */
+
+ inline bool empty(void) const;
+
+ /**
+ * Remove all data.
+ */
+
+ void clear();
+
+ /**
+ * Overload the [] operator to allow array-style access.
+ * @param index The index to retrieve.
+ * @return The value at the specified index.
+ */
+
+ T& operator[](const int index) const;
+};
+
+template <class T>
+TNxArray<T>::TNxArray()
+{
+ // Don't allocate anything until the first data is added to
+ // the array
+
+ m_size = 0; // Number of data items in use
+ m_reservedSize = 0; // Number of data items allocated
+ m_data = (T *)0; // Allocated memory for data items
+}
+
+template <class T>
+TNxArray<T>::TNxArray(int initialSize)
+{
+ m_size = 0; // Number of data items in use
+ m_reservedSize = 0; // Number of data items allocated
+ m_data = (T *)0; // Allocated memory for data items
+ preallocate(initialSize); // Allocate the initial array
+}
+
+template <class T>
+TNxArray<T>::~TNxArray()
+{
+ if (m_data)
+ {
+ delete [] m_data;
+ }
+}
+
+template <class T>
+const int TNxArray<T>::size(void) const
+{
+ return m_size;
+}
+
+template <class T>
+void TNxArray<T>::push_back(const T &value)
+{
+ // Ensure the array is large enough to hold one more data item
+
+ resize();
+
+ // Add data to array
+
+ m_data[m_size] = value;
+
+ // Remember we've filled a slot
+
+ m_size++;
+}
+
+template <class T>
+void TNxArray<T>::pop_back(void)
+{
+ if (m_size >= 1)
+ {
+ // We can just reduce the used size of the array, as the value
+ // will get overwritten automatically
+
+ m_size--;
+ }
+}
+
+template <class T>
+void TNxArray<T>::insert(const int index, const T &value)
+{
+ // Bounds check
+
+ if ((index >= m_size) || (m_size == 0))
+ {
+ push_back(value);
+ return;
+ }
+
+ // Ensure the array is large enough to hold one more data item
+
+ resize();
+
+ // Shift all of the data back one place to make a space for the new data
+
+ for (int i = m_size; i > index; i--)
+ {
+ m_data[i] = m_data[i - 1];
+ }
+
+ // Add data to array
+
+ m_data[index] = value;
+
+ // Remember we've filled a slot
+
+ m_size++;
+}
+
+template <class T>
+void TNxArray<T>::erase(const int index)
+{
+ // Bounds check
+
+ if (index >= m_size)
+ {
+ return;
+ }
+
+ // Shift all of the data back one place and overwrite the value
+
+ for (int i = index; i < m_size - 1; i++)
+ {
+ m_data[i] = m_data[i + 1];
+ }
+
+ // Remember we've removed a slot
+
+ m_size--;
+}
+
+template <class T>
+void TNxArray<T>::reallocate(const int newSize)
+{
+ // Do we need to redim the array?
+
+ if (m_reservedSize < newSize)
+ {
+ // Create the new array
+
+ T *newData = new T[newSize];
+
+ // Copy old array contents to new the new array
+
+ for (int i = 0; i < m_reservedSize; i++)
+ {
+ newData[i] = m_data[i];
+ }
+
+ // Delete the old array (if there was one)
+
+ if (m_data)
+ {
+ delete [] m_data;
+ }
+
+ // Update values
+
+ m_data = newData;
+ m_reservedSize = newSize;
+ }
+}
+
+template <class T>
+void TNxArray<T>::resize(void)
+{
+ // Do we need to redim the array in order to add one more entry?
+
+ if (m_reservedSize == m_size)
+ {
+ // We have filled the array, so resize it
+
+ int newSize = m_reservedSize;
+#if CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE != CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT
+ newSize += m_reservedSize ?
+ CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT :
+ CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE;
+#else
+ newSize += CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT;
+#endif
+
+ // Re-allocate the array
+
+ reallocate(newSize);
+ }
+}
+
+template <class T>
+T& TNxArray<T>::at(const int index) const
+{
+ // What if this is called with index > m_reservedSize? What if
+ // this is called before m_data is allocated? Don't do that!
+
+ return m_data[index];
+}
+
+template <class T>
+bool TNxArray<T>::empty() const
+{
+ return (m_size == 0);
+}
+
+template <class T>
+T& TNxArray<T>::operator[](const int index) const
+{
+ // What if this is called with index > m_reservedSize? What if
+ // this is called before m_data is allocated? Don't do that!
+
+ return m_data[index];
+}
+
+template <class T>
+void TNxArray<T>::clear()
+{
+ // All we need to do is reset the size value
+
+ m_size = 0;
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_TNXARRAY_HXX
diff --git a/NxWidgets/libnxwidgets/src/cbgwindow.cxx b/NxWidgets/libnxwidgets/src/cbgwindow.cxx
new file mode 100644
index 000000000..268bc5d80
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cbgwindow.cxx
@@ -0,0 +1,377 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cbgwindow.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cbgwindow.hxx"
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor. Obtains the background window from server and wraps
+ * the window as CBgWindow.
+ *
+ * @param hNxServer Handle to the NX server.
+ * @param widgetControl Controlling widget for this window.
+ */
+
+CBgWindow::CBgWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl)
+ : CCallback(pWidgetControl), m_hNxServer(hNxServer), m_hWindow(0),
+ m_widgetControl(pWidgetControl)
+{
+ // Create the CGraphicsPort instance for this window
+
+ m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this));
+}
+
+/**
+ * Destructor. Returns the background window to the server.
+ */
+
+CBgWindow::~CBgWindow(void)
+{
+ // Release the background. We do not release the widget control
+ // instance. The lifetime of that instance is owned by he-who-
+ // constructed-us.
+
+ (void)nx_releasebkgd(m_hWindow);
+}
+
+/**
+ * Creates a new window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully opened.
+ */
+
+bool CBgWindow::open(void)
+{
+ // Get the C-callable callback vtable
+
+ FAR struct nx_callback_s *vtable = getCallbackVTable();
+
+ // Request the background the window
+
+ int ret = nx_requestbkgd(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
+ if (ret < 0)
+ {
+ return false;
+ }
+
+ // Window handle (picked off by the callback logic)
+
+ m_hWindow = m_widgetControl->getWindowHandle();
+ return true;
+}
+
+/**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+CWidgetControl *CBgWindow::getWidgetControl(void) const
+{
+ return m_widgetControl;
+}
+
+/**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return Always returns true.
+ */
+
+bool CBgWindow::requestPosition(void)
+{
+ // The background window is always at {0,0} and the size never changes.
+
+ return true;
+}
+
+/**
+ * Get the position of the window (as reported by the NX callback). NOTE:
+ * The background window is always positioned at {0,0}
+ *
+ * @return The position.
+ */
+
+bool CBgWindow::getPosition(FAR struct nxgl_point_s *pPos)
+{
+ // The background window is always at {0,0}
+
+ pPos->x = 0;
+ pPos->y = 0;
+ return true;
+}
+
+/**
+ * Get the size of the window (as reported by the NX callback). NOTE:
+ * The size of the background window is always the entire display.
+ *
+ * @return The size.
+ */
+
+bool CBgWindow::getSize(FAR struct nxgl_size_s *pSize)
+{
+ // The size is always the full size of the display
+
+ return m_widgetControl->getWindowSize(pSize);
+}
+
+/**
+ * Set the position and size of the window.
+ *
+ * @param pPos The new position of the window.
+ * @return Always returns false.
+ */
+
+bool CBgWindow::setPosition(FAR const struct nxgl_point_s *pPos)
+{
+ // The position of the background cannot be changed
+
+ return false;
+}
+
+/**
+ * Set the size of the selected window. NOTE: The size of the
+ * background window is always the entire display and cannot be
+ * changed.
+ *
+ * @param pSize The new size of the window.
+ * @return Always returns false.
+ */
+
+bool CBgWindow::setSize(FAR const struct nxgl_size_s *pSize)
+{
+ // The position of the background cannot be changed
+
+ return false;
+}
+
+/**
+ * Bring the window to the top of the display. NOTE: The background
+ * window cannot be raised.
+ *
+ * @return Always returns false.
+ */
+
+bool CBgWindow::raise(void)
+{
+ // The background cannot be raised
+
+ return false;
+}
+
+/**
+ * Lower the window to the bottom of the display. NOTE: The background
+ * window is always at the bottom of the window hierarchy.
+ *
+ * @return Always returns false.
+ */
+
+bool CBgWindow::lower(void)
+{
+ // The background cannot be lowered
+
+ return false;
+}
+
+/**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color)
+{
+ // Set an individual pixel to the specified color
+
+ return nx_setpixel(m_hWindow, pPos, &color) == OK;
+}
+
+/**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color)
+{
+ // Fill a rectangular region with a solid color
+
+ return nx_fill(m_hWindow, pRect, &color) == OK;
+}
+
+/**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+void CBgWindow::getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest)
+{
+ // Get a rectangule region from the window
+
+ (void)nx_getrectangle(m_hWindow, rect, 0, (FAR uint8_t*)dest->data, dest->stride);
+}
+
+/**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color)
+{
+ // Fill a trapezoidal region with a solid color
+
+ return nx_filltrapezoid(m_hWindow, pClip, pTrap, &color) == OK;
+}
+
+/**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width, nxgl_mxpixel_t color)
+{
+ // Draw a line with the specified color
+
+ return nx_drawline(m_hWindow, vector, width, &color) == OK;
+}
+
+/**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+bool CBgWindow::drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color)
+{
+ return nx_fillcircle(m_hWindow, center, radius, &color) == OK;
+}
+
+/**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset)
+{
+ // Move a rectangular region of the display
+
+ return nx_move(m_hWindow, pRect, pOffset) == OK;
+}
+
+/**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window. The source image is treated as an opaque image.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CBgWindow::bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride)
+{
+ // Copy a rectangular bitmap image in a region on the display
+
+ return nx_bitmap(m_hWindow, pDest, &pSrc, pOrigin, stride) == OK;
+}
diff --git a/NxWidgets/libnxwidgets/src/cbitmap.cxx b/NxWidgets/libnxwidgets/src/cbitmap.cxx
new file mode 100644
index 000000000..c9c974814
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cbitmap.cxx
@@ -0,0 +1,197 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cbitmap.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param bitmap The bitmap structure being wrapped.
+ */
+
+CBitmap::CBitmap(const struct SBitmap *bitmap) : m_bitmap(bitmap) {}
+
+/**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's width.
+ */
+
+const uint8_t CBitmap::getColorFormat(void) const
+{
+ return m_bitmap->fmt;
+}
+
+/**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's color format.
+ */
+
+const uint8_t CBitmap::getBitsPerPixel(void) const
+{
+ return m_bitmap->bpp;
+}
+
+/**
+ * Get the bitmap's width (in pixels/columns).
+ *
+ * @return The bitmap's pixel depth.
+ */
+
+const nxgl_coord_t CBitmap::getWidth(void) const
+{
+ return m_bitmap->width;
+}
+
+/**
+ * Get the bitmap's height (in rows).
+ *
+ * @return The bitmap's height.
+ */
+
+const nxgl_coord_t CBitmap::getHeight(void) const
+{
+ return m_bitmap->height;
+}
+
+/**
+ * Get the bitmap's width (in bytes).
+ *
+ * @return The bitmap's width.
+ */
+
+const nxgl_coord_t CBitmap::getStride(void) const
+{
+ return m_bitmap->stride;
+}
+
+/**
+ * Get one row from the bit map image.
+ *
+ * @param x The offset into the row to get
+ * @param y The row number to get
+ * @param width The number of pixels to get from the row
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @param True if the run was returned successfully.
+ */
+
+bool CBitmap::getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ FAR void *data)
+{
+ // Check ranges. Casts to unsigned int are ugly but permit one-sided comparisons
+
+ if (((unsigned int)x < (unsigned int)width) &&
+ ((unsigned int)(x + width) <= (unsigned int)m_bitmap->width) &&
+ ((unsigned int)y < (unsigned int)m_bitmap->height))
+ {
+ // Get starting position of the copy (this will only work if bpp
+ // is an even multiple of bytes).
+
+ FAR uint8_t *start = (FAR uint8_t*)m_bitmap->data +
+ y * m_bitmap->stride +
+ ((x * m_bitmap->bpp) >> 3);
+
+ // Get the number of bytes to copy.
+
+ unsigned int length = (width * m_bitmap->bpp) >> 3;
+
+ // And do the copy
+
+ memcpy(data, start, length);
+ return true;
+ }
+
+ return false;
+}
diff --git a/NxWidgets/libnxwidgets/src/cbutton.cxx b/NxWidgets/libnxwidgets/src/cbutton.cxx
new file mode 100644
index 000000000..429905759
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cbutton.cxx
@@ -0,0 +1,311 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cbutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbutton.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the values stored in the global
+ * g_defaultWidgetStyle object. The button will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CButton::CButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ nxgl_coord_t height, const CNxString &text, CWidgetStyle *style)
+: CLabel(pWidgetControl, x, y, width, height, text, style)
+{
+}
+
+/**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+void CButton::drawOutline(CGraphicsPort *port)
+{
+ drawOutline(port, isClicked());
+}
+
+/**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ * @param useClicked Present outline using the 'clicked' style
+ */
+
+void CButton::drawOutline(CGraphicsPort *port, bool useClicked)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (isBorderless())
+ {
+ return;
+ }
+
+ // Work out which colors to use
+
+ nxgl_coord_t color1;
+ nxgl_coord_t color2;
+
+ if (useClicked)
+ {
+ // Bevelled into the screen
+
+ color1 = getShadowEdgeColor();
+ color2 = getShineEdgeColor();
+ }
+ else
+ {
+ // Bevelled out of the screen
+
+ color1 = getShineEdgeColor();
+ color2 = getShadowEdgeColor();
+ }
+
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CButton::drawContents(CGraphicsPort *port)
+{
+ drawContents(port, isClicked());
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param useClicked Present contents using the 'clicked' style
+ * @see redraw()
+ */
+
+void CButton::drawContents(CGraphicsPort *port, bool useClicked)
+
+{
+ // Get the draw region (excluding any borders)
+
+ CRect rect;
+ getRect(rect);
+
+ // Get the X/Y position of the text within the button
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() + m_align.x;
+ pos.y = rect.getY() + m_align.y;
+
+ // Pick the text color
+
+ nxgl_mxpixel_t textColor;
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ }
+ else if (useClicked)
+ {
+ textColor = getSelectedTextColor();
+ }
+ else
+ {
+ textColor = getEnabledTextColor();
+ }
+
+ // And draw the button text
+
+ port->drawText(&pos, &rect, getFont(), m_text, 0, m_text.getLength(), textColor);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CButton::drawBorder(CGraphicsPort *port)
+{
+ drawBorder(port, isClicked());
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param useClicked Present border using the 'clicked' style
+ * @see redraw()
+ */
+
+void CButton::drawBorder(CGraphicsPort *port, bool useClicked)
+{
+ // Determine the background color
+
+ nxgl_mxpixel_t backColor;
+
+ if (useClicked || m_highlighted)
+ {
+ backColor = getSelectedBackgroundColor();
+ }
+ else
+ {
+ backColor = getBackgroundColor();
+ }
+
+ port->drawFilledRect(getX(), getY(), getWidth(), getHeight(), backColor);
+ drawOutline(port);
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CButton::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButton::onPreRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ m_widgetEventHandlers->raiseActionEvent();
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButton::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButton::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
diff --git a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx
new file mode 100644
index 000000000..28f14062b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx
@@ -0,0 +1,634 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cbuttonarray.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cbuttonarray.hxx"
+#include "cgraphicsport.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButtonArray Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for an array of buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CButtonArray::CButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y,
+ buttonColumns * buttonWidth + 2, buttonRows * buttonHeight + 2,
+ 0, style)
+{
+ // Save configuration
+
+ m_buttonRows = buttonRows;
+ m_buttonColumns = buttonColumns;
+ m_buttonWidth = buttonWidth;
+ m_buttonHeight = buttonHeight;
+
+ // Make sure the the positional data is valid.
+
+ m_clickX = x;
+ m_clickY = y;
+ m_cursorColumn = 0;
+ m_cursorRow = 0;
+
+ // Default behavior is to redraw the entire button array
+
+ m_redrawButton = false;
+
+ // No hightlighted buttons
+
+ m_cursorOn = false;
+ m_cursorChange = false;
+
+ // At present, There is no border on the array itself
+
+ m_flags.borderless = true;
+
+ // Make sure that the full size of the text array is allocated
+
+ m_buttonText = new CNxString[m_buttonRows * m_buttonColumns];
+}
+
+/**
+ * CButtonArray Destructor.
+ */
+
+CButtonArray::~CButtonArray(void)
+{
+ // Delete the array of CNxString instances
+
+ delete [] m_buttonText;
+}
+
+/**
+ * Returns the string shown in the label.
+ *
+ * @param column The column index of the button of interest
+* @param row The row index of the button of interest
+ * @return The label's text.
+ */
+
+const CNxString &CButtonArray::getText(int column, int row) const
+{
+ return m_buttonText[row * m_buttonColumns + column];
+}
+
+/**
+ * Set the text displayed in the label.
+ *
+ * @param column The column index of the button to set
+ * @param row The row index of the button to set
+ * @param text String to display.
+ */
+
+void CButtonArray::setText(int column, int row, const CNxString &text)
+{
+ m_buttonText[row * m_buttonColumns + column] = text;
+ onTextChange();
+}
+
+/**
+ * Return the position of the last clicked button (0,0 will be returned
+ * the no button has every been clicked). The button at this position
+ * is currently clicked then, in addition, return true.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if a button in the array is clicked
+ */
+
+bool CButtonArray::isButtonClicked(int &column, int &row) const
+{
+ // Return the last clicked position
+
+ column = (m_clickX - getX()) / m_buttonWidth;
+
+ // Calculate and return the button row index
+
+ row = (m_clickY - getY()) / m_buttonHeight;
+
+ // Return true if the button is currently clicked
+
+ return isClicked();
+}
+
+/**
+ * Check if this specific button in the array is clicked
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is clicked
+ */
+
+bool CButtonArray::isThisButtonClicked(int column, int row) const
+{
+ // The upper left X/Y position of the button at these indices
+
+ nxgl_coord_t x = getX() + column * m_buttonWidth;
+ nxgl_coord_t y = getY() + row * m_buttonHeight;
+
+ // Was the last click on this button?
+
+ if ((m_clickX >= x && m_clickX < x + m_buttonWidth) &&
+ (m_clickY >= y && m_clickY < y + m_buttonHeight))
+ {
+ // Yes.. return true if the button is clicked
+
+ return isClicked();
+ }
+ else
+ {
+ // No.. then it can't be clicked
+
+ return false;
+ }
+}
+
+/**
+ * Control the cursor state.
+ *
+ * @param cursorOn True(1), the current cursor position will be highlighted
+ */
+
+void CButtonArray::cursor(bool cursorOn)
+{
+ if (cursorOn != m_cursorOn)
+ {
+ // Set the state cursor state
+
+ m_cursorOn = cursorOn;
+
+ // Update only the effected button
+
+ m_cursorChange = true;
+ redraw();
+ m_cursorChange = false;
+ }
+}
+
+/**
+ * Return the current cursor position (button indices) and an indication
+ * if the button at the cursor is currently hightlighted.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if the cursor is enabled and the button is highlighted
+ */
+
+bool CButtonArray::getCursorPosition(int &column, int &row) const
+{
+ column = m_cursorColumn;
+ row = m_cursorRow;
+ return m_cursorOn;
+}
+
+/**
+ * Set the cursor position (button indices). Note that the cursor
+ * does not have to be enabled to set the position.
+ *
+ * @param column The column index of the button of interest
+ * @param row The row index of the button of interest
+ * @return True if the cursor position is valid
+ */
+
+bool CButtonArray::setCursorPosition(int column, int row)
+{
+ // Verify that the cursor position is within range
+
+ if ((unsigned)column < m_buttonColumns && (unsigned)row < m_buttonRows)
+ {
+ // Verify that the now position is different from the old position
+
+ if (column != m_cursorColumn || row != m_cursorRow)
+ {
+ m_cursorChange = true;
+
+ // Is the cursor on now?
+
+ bool redrawCursor = m_cursorOn;
+ if (redrawCursor)
+ {
+ // Yes.. clear the old cursor highlight
+
+ m_cursorOn = false;
+ redraw();
+ }
+
+ // Set the new cursor position
+
+ m_cursorColumn = column;
+ m_cursorRow = row;
+
+ // Do we need to turn the cursor back on?
+
+ if (redrawCursor)
+ {
+ // Yes.. Set the new cursor hightlight
+
+ m_cursorOn = true;
+ redraw();
+ }
+
+ m_cursorChange = false;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Check if this specific button in the array is at the cursor position
+ * and highlighted.
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is at the cursor postion and highlighted.
+ */
+
+bool CButtonArray::isCursorPosition(int column, int row) const
+{
+ if (column == m_cursorColumn && row == m_cursorRow)
+ {
+ return m_cursorOn;
+ }
+
+ return false;
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CButtonArray::getPreferredDimensions(CRect &rect) const
+{
+ return getRect(rect);
+}
+
+/**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+void CButtonArray::setFont(CNxFont *font)
+{
+ m_style.font = font;
+ redraw();
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CButtonArray::drawContents(CGraphicsPort *port)
+{
+ // Do we draw just the clicked/unclicked button?
+
+ if (m_redrawButton)
+ {
+ int column;
+ int row;
+
+ // Just one. Get the row/column indices from the last click
+
+ (void)posToButton(m_clickX, m_clickY, column, row);
+
+ // And draw that button
+
+ drawButton(port, column, row, isClicked());
+ }
+
+ // Do we just draw the hightlighted button?
+
+ else if (m_cursorChange)
+ {
+ // Do nothing if the highlighted button is also the clicked button
+
+ if (!isThisButtonClicked(m_cursorColumn, m_cursorRow))
+ {
+ drawButton(port, m_cursorColumn, m_cursorRow, false);
+ }
+ }
+
+ // Draw all buttons
+
+ else
+ {
+ // Visit each column
+
+ for (int column = 0; column < m_buttonColumns; column++)
+ {
+ // Visit each row
+
+ for (int row = 0; row < m_buttonRows; row++)
+ {
+ // Draw each button
+
+ drawButton(port, column, row, isThisButtonClicked(column, row));
+ }
+ }
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CButtonArray::drawBorder(CGraphicsPort *port)
+{
+ // This doesn't do anything anymore
+}
+
+/**
+ * Redraw only one button
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param column The button column index
+ * @param row The button row index
+ * @param useClicked Draw the button using the 'clicked' button style,
+ * regardless of the actual button state.
+ * @see onClick() and onRelease()
+ */
+
+void CButtonArray::drawButton(CGraphicsPort *port, int column, int row, bool useClicked)
+{
+ // The X/Y position of the button
+
+ nxgl_coord_t x = getX() + column * m_buttonWidth;
+ nxgl_coord_t y = getY() + row * m_buttonHeight;
+
+ // Determine which colors to use
+
+ nxwidget_pixel_t borderColor1;
+ nxwidget_pixel_t borderColor2;
+ nxwidget_pixel_t backColor;
+ nxwidget_pixel_t textColor;
+
+ // Pick the background and test colors. Should we use the 'clicked' backgound style?
+
+ if (useClicked || isCursorPosition(column, row))
+ {
+ // "Selected" text color on unique "Selected" background color
+
+ backColor = getSelectedBackgroundColor();
+ textColor = getSelectedTextColor();
+ }
+ else
+ {
+ // Normal background color and "Enabled" text color
+
+ backColor = getBackgroundColor();
+ textColor = getEnabledTextColor();
+ }
+
+ // Pick the border colors. Should we use the 'clicked' button style?
+
+ if (useClicked)
+ {
+ // Yes.. Bevelled into the screen
+
+ borderColor1 = getShadowEdgeColor();
+ borderColor2 = getShineEdgeColor();
+ }
+ else
+ {
+ // No.. Bevelled out of the screen
+
+ borderColor1 = getShineEdgeColor();
+ borderColor2 = getShadowEdgeColor();
+ }
+
+ // Use a special text color if the widget is not enabled
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ }
+
+ // Draw the background
+
+ port->drawFilledRect(x, y, m_buttonWidth, m_buttonHeight, backColor);
+
+ // Draw the button outline
+
+ port->drawBevelledRect(x, y, m_buttonWidth, m_buttonHeight, borderColor1, borderColor2);
+
+ // Get the text for this button
+
+ CNxString *text = &m_buttonText[row * m_buttonColumns + column];
+
+ // Get the text drawing region
+
+ CRect rect;
+ rect.setX(x + 1);
+ rect.setY(y + 1);
+ rect.setWidth(m_buttonWidth - 2);
+ rect.setHeight(m_buttonHeight - 2);
+
+ // Get the centered text alignment
+
+ nxgl_coord_t alignY = (m_buttonHeight - getFont()->getHeight() - 2) >> 1;
+ nxgl_coord_t alignX = (m_buttonWidth - getFont()->getStringWidth(*text) - 2) >> 1;
+
+ // Get the text display position
+
+ struct nxgl_point_s pos;
+ pos.x = x + alignX;
+ pos.y = y + alignY;
+
+ // Set the CGraphicsControl background to match the selected background color.
+ // This is only necessary if we cannot read from the LCD. If we cannot read
+ // from then the font background is set to this background color.
+ // REVISIT: This begs for a more generalized solution.
+
+#ifdef CONFIG_NX_WRITEONLY
+ nxgl_mxpixel_t saveColor = port->getBackColor();
+ port->setBackColor(backColor);
+#endif
+
+ // And draw the button text.
+
+ port->drawText(&pos, &rect, getFont(), *text, 0, text->getLength(), textColor);
+
+ // Restore the default background color
+
+#ifdef CONFIG_NX_WRITEONLY
+ port->setBackColor(saveColor);
+#endif
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CButtonArray::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Click X,Y is in raw window coordinates
+
+ m_clickX = x;
+ m_clickY = y;
+
+ // Redraw only the button that was clicked
+
+ m_redrawButton = true;
+ redraw();
+ m_redrawButton = false;
+}
+
+/**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButtonArray::onPreRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ m_widgetEventHandlers->raiseActionEvent();
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButtonArray::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Redraw only the button that was released
+
+ m_redrawButton = true;
+ redraw();
+ m_redrawButton = false;
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CButtonArray::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Convert an X/Y position to a button column/row index
+ *
+ * @param x The x position
+ * @param y The y position
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return false is the position is invalid
+ */
+
+bool CButtonArray::posToButton(nxgl_coord_t x, nxgl_coord_t y, int &column, int &row)
+{
+ // Get the row/column indices matching the x/y position
+
+ column = (x - getX()) / m_buttonWidth;
+ row = (y - getY()) / m_buttonHeight;
+ return ((unsigned)column < m_buttonColumns && (unsigned)row < m_buttonRows);
+}
+
+/**
+ * Updates the GUI after the text has changed.
+ */
+
+void CButtonArray::onTextChange(void)
+{
+ redraw();
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
diff --git a/NxWidgets/libnxwidgets/src/ccallback.cxx b/NxWidgets/libnxwidgets/src/ccallback.cxx
new file mode 100644
index 000000000..374502a38
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ccallback.cxx
@@ -0,0 +1,263 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ccallback.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
+
+#include "cwidgetcontrol.hxx"
+#include "ccallback.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+ /**
+ * Constructor.
+ *
+ * @param widgetControl Control object associated with this window
+ */
+
+CCallback::CCallback(CWidgetControl *widgetControl)
+{
+ // Save the widgetControl
+
+ m_widgetControl = widgetControl;
+
+ // Initialize the callback vtable
+
+ m_callbacks.redraw = redraw;
+ m_callbacks.position = position;
+#ifdef CONFIG_NX_MOUSE
+ m_callbacks.mousein = newMouseEvent;
+#endif
+#ifdef CONFIG_NX_KBD
+ m_callbacks.kbdin = newKeyboardEvent;
+#endif
+ m_callbacks.blocked = windowBlocked;
+
+ // Keyboard input is initially direct to the widgets within the window
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ m_nxconsole = (NXCONSOLE)0;
+#endif
+}
+
+ /**
+ * ReDraw Callback. The redraw action is handled by CWidgetControl:redrawEvent.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param rect The rectangle that needs to be re-drawn (in window
+ * relative coordinates).
+ * @param bMore true: More re-draw requests will follow.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+void CCallback::redraw(NXHANDLE hwnd,
+ FAR const struct nxgl_rect_s *rect,
+ bool bMore, FAR void *arg)
+{
+ gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} bMore=%s\n",
+ hwnd,
+ rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
+ bMore ? "true" : "false");
+
+ // The argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg;
+
+ // Just forward the callback to the CWidgetControl::redrawEvent method
+
+ This->m_widgetControl->redrawEvent(rect, bMore);
+}
+
+ /**
+ * Position Callback. The new positional data is handled by
+ * CWidgetControl::geometryEvent.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param size The size of the window.
+ * @param pos The position of the upper left hand corner of the window on
+ * the overall display.
+ * @param bounds The bounding rectangle that describes the entire display.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+void CCallback::position(NXHANDLE hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg)
+{
+ gvdbg("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)} arg=%p\n",
+ hwnd, size->w, size->h, pos->x, pos->y,
+ bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y,
+ arg);
+
+
+ // The argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg;
+
+ // Just forward the callback to the CWidgetControl::geometry method
+
+ This->m_widgetControl->geometryEvent(hwnd, size, pos, bounds);
+}
+
+ /**
+ * New mouse data is available for the window. The new mouse data is
+ * handled by CWidgetControl::newMouseEvent.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param pos The (x,y) position of the mouse.
+ * @param buttons See NX_MOUSE_* definitions.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+#ifdef CONFIG_NX_MOUSE
+void CCallback::newMouseEvent(NXHANDLE hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg)
+{
+ gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n",
+ hwnd, pos->x, pos->y, buttons, arg);
+
+ // The argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg;
+
+ // Just forward the callback to the CWidgetControl::newMouseEvent method
+
+ This->m_widgetControl->newMouseEvent(pos, buttons);
+}
+#endif /* CONFIG_NX_MOUSE */
+
+/**
+ * New keyboard/keypad data is available for the window. The new keyboard
+ * data is handled by CWidgetControl::newKeyboardEvent.
+ *
+ * @param hwnd Handle to a specific NX window.
+ * @param nCh The number of characters that are available in str[].
+ * @param str The array of characters.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
+ * nxtk_openwindow, or nxtk_opentoolbar).
+ */
+
+#ifdef CONFIG_NX_KBD
+void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
+ FAR const uint8_t *str,
+ FAR void *arg)
+{
+ gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg);
+
+ // The argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg;
+
+ // Is NX keyboard input being directed to the widgets within the window
+ // (default) OR is NX keyboard input being re-directed to an NxConsole
+ // driver?
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ if (This->m_nxconsole)
+ {
+ // Keyboard input is going to an NxConsole
+
+ nxcon_kbdin(This->m_nxconsole, str, nCh);
+ }
+ else
+#endif
+ {
+ // Just forward the callback to the CWidgetControl::newKeyboardEvent method
+
+ This->m_widgetControl->newKeyboardEvent(nCh, str);
+ }
+}
+
+/**
+ * This callback is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use more, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param hwnd. Window handle of the blocked window
+ * @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ * @param arg2 - User provided argument (see nx_block or nxtk_block)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2)
+{
+ gvdbg("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2);
+
+ // The first argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg1;
+
+ // Just forward the callback to the CWidgetControl::windowBlocked method
+
+ This->m_widgetControl->windowBlocked(arg2);
+}
+#endif
+
+#endif // CONFIG_NX_KBD
diff --git a/NxWidgets/libnxwidgets/src/ccheckbox.cxx b/NxWidgets/libnxwidgets/src/ccheckbox.cxx
new file mode 100644
index 000000000..a6cc9400a
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ccheckbox.cxx
@@ -0,0 +1,265 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ccheckbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "ccheckbox.hxx"
+#include "cgraphicsport.hxx"
+#include "cbitmap.hxx"
+#include "singletons.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the checkbox, relative to its parent.
+ * @param y The y coordinate of the checkbox, relative to its parent.
+ * @param width The width of the checkbox.
+ * @param height The height of the checkbox.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CCheckBox::CCheckBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CButton(pWidgetControl, x, y, width, height, *NXWidgets::g_nullString, style)
+{
+ m_state = CHECK_BOX_STATE_OFF;
+ m_flags.borderless = false;
+
+ // Border width is one line
+
+ m_borderSize.top = 1;
+ m_borderSize.right = 1;
+ m_borderSize.bottom = 1;
+ m_borderSize.left = 1;
+}
+
+/**
+ * Set the state of the checkbox.
+ *
+ * @param state The new checkbox state.
+ */
+
+void CCheckBox::setState(CCheckBox::CheckBoxState state)
+{
+ if (m_state != state)
+ {
+ m_state = state;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ redraw();
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CCheckBox::drawContents(CGraphicsPort *port)
+{
+ // Get the X/Y position of the drawable region within the CheckBox
+
+ nxgl_coord_t x = getX();
+ nxgl_coord_t y = getY();
+
+ nxgl_coord_t width = getWidth();
+ nxgl_coord_t height = getHeight();
+
+ // Include and offset for the border
+
+ if (!m_flags.borderless)
+ {
+ x += m_borderSize.left;
+ y += m_borderSize.top;
+
+ width -= (m_borderSize.left + m_borderSize.right);
+ height -= (m_borderSize.top + m_borderSize.bottom);
+ }
+
+ // Decide which glyph to draw
+
+ const struct SBitmap *glyph;
+
+ switch (m_state)
+ {
+ default:
+ case CHECK_BOX_STATE_ON:
+ glyph = &g_checkBoxOn;
+ break;
+
+ case CHECK_BOX_STATE_OFF:
+ glyph = &g_checkBoxOff;
+ break;
+
+ case CHECK_BOX_STATE_MU:
+ glyph = &g_checkBoxMu;
+ break;
+ }
+
+ // Don't exceed the size of the glyph
+
+ if (width > glyph->width)
+ {
+ width = glyph->width;
+ }
+
+ if (height > glyph->height)
+ {
+ height = glyph->height;
+ }
+
+ // Draw the checkbox
+
+ port->drawBitmap(x, y, width, height, glyph, 0, 0,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CCheckBox::drawBorder(CGraphicsPort *port)
+{
+ // Determine the background color
+
+ nxgl_mxpixel_t backColor;
+
+ if (m_highlighted)
+ {
+ backColor = getSelectedBackgroundColor();
+ }
+ else
+ {
+ backColor = getBackgroundColor();
+ }
+
+ // Draw the background (excluding the border)
+
+ port->drawFilledRect(getX(), getY(), getWidth(), getHeight(),
+ backColor);
+
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShineEdgeColor(), getShadowEdgeColor());
+ }
+}
+
+/**
+ * Toggles the state of the checkbox.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CCheckBox::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (m_state == CHECK_BOX_STATE_ON)
+ {
+ setState(CHECK_BOX_STATE_OFF);
+ }
+ else
+ {
+ setState(CHECK_BOX_STATE_ON);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/ccyclebutton.cxx b/NxWidgets/libnxwidgets/src/ccyclebutton.cxx
new file mode 100644
index 000000000..b5f96683d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ccyclebutton.cxx
@@ -0,0 +1,482 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ccyclebutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "ccyclebutton.hxx"
+#include "cgraphicsport.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for cycle buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the values stored in the global
+ * g_defaultWidgetStyle object. The button will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CCycleButton::CCycleButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CButton(pWidgetControl, x, y, width, height, "", style)
+{
+ // Force text to align left
+
+ nxgl_coord_t glyphSpace = m_borderSize.left - 1;
+
+ // Text x coordinate is width of cycle glyph plus a space plus width
+ // of the spacer line (2px) plus a space
+
+ m_align.x = g_cycle.width + 2 + (glyphSpace << 1);
+
+ m_options.addListDataEventHandler(this);
+ m_options.setAllowMultipleSelections(false);
+}
+
+/**
+ * Add a new option to the widget.
+ *
+ * @param text The text of the option.
+ * @param value The value of the option.
+ */
+
+void CCycleButton::addOption(const CNxString &text, const uint32_t value)
+{
+ m_options.addItem(new CListDataItem(text, value));
+
+ // Select the option if this is the first option added
+
+ if (m_options.getItemCount() == 1)
+ {
+ selectOption(0);
+ }
+}
+
+/**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+void CCycleButton::removeOption(const int index)
+{
+ m_options.removeItem(index);
+}
+
+/**
+ * Remove all options from the widget.
+ */
+
+void CCycleButton::removeAllOptions(void)
+{
+ m_options.removeAllItems();
+}
+
+/**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+void CCycleButton::selectOption(const int index)
+{
+ m_options.setItemSelected(index, true);
+}
+
+/**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * option is selected, the index of the first selected option is returned.
+ *
+ * @return The selected index.
+ */
+
+const int CCycleButton::getSelectedIndex(void) const
+{
+ return m_options.getSelectedIndex();
+}
+
+/**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected options to deselected.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+void CCycleButton::setSelectedIndex(const int index)
+{
+ m_options.setItemSelected(index, true);
+}
+
+/**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+const CListDataItem *CCycleButton::getSelectedOption(void) const
+{
+ return m_options.getSelectedItem();
+}
+
+/**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+void CCycleButton::sort(void)
+{
+ m_options.sort();
+}
+
+/**
+ * Handles list data changed events.
+ *
+ * @param e Event arguments.
+ */
+
+void CCycleButton::handleListDataChangedEvent(const CListDataEventArgs &e)
+{
+ redraw();
+}
+
+/**
+ * Handles list selection changed events.
+ *
+ * @param e Event arguments.
+ */
+
+void CCycleButton::handleListDataSelectionChangedEvent(const CListDataEventArgs &e)
+{
+ redraw();
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CCycleButton::getPreferredDimensions(CRect &rect) const
+{
+ nxgl_coord_t width = 0;
+ nxgl_coord_t height = getFont()->getHeight();
+
+ // Locate longest string in options
+
+ for (int i = 0; i < m_options.getItemCount(); ++i)
+ {
+ nxgl_coord_t optionWidth =
+ getFont()->getStringWidth(m_options.getItem(i)->getText());
+
+ if (optionWidth > width)
+ {
+ width = optionWidth;
+ }
+ }
+
+ // Add the border width
+
+ if (!m_flags.borderless)
+ {
+ width += (m_borderSize.left + m_borderSize.right);
+ height += (m_borderSize.top + m_borderSize.bottom);
+ }
+
+ // Add text alignment
+
+ width += m_align.x;
+ height += m_align.y;
+
+ // And returned this preferred size
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width);
+ rect.setHeight(height);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CCycleButton::drawContents(CGraphicsPort *port)
+{
+ // Get the drawing region (excluding any border)
+
+ CRect rect;
+ getRect(rect);
+
+ nxgl_coord_t glyphSpace = m_borderSize.left - 1;
+ nxgl_coord_t glyphYOffset = (rect.getHeight() - g_cycle.height) >> 1;
+
+ nxwidget_pixel_t textColor;
+ nxwidget_pixel_t separatorLeftColor;
+ nxwidget_pixel_t separatorRightColor;
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ separatorLeftColor = getShadowEdgeColor();
+ separatorRightColor = getShineEdgeColor();
+ }
+ else if (!isClicked())
+ {
+ textColor = getEnabledTextColor();
+ separatorLeftColor = getShadowEdgeColor();
+ separatorRightColor = getShineEdgeColor();
+ }
+ else
+ {
+ textColor = getSelectedTextColor();
+ separatorLeftColor = getShineEdgeColor();
+ separatorRightColor = getShadowEdgeColor();
+ }
+
+ // Draw cycle glyph
+
+ port->drawBitmap(rect.getX(), rect.getY() + glyphYOffset,
+ g_cycle.width, g_cycle.height, &g_cycle,
+ 0, 0, CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+
+ // Draw separator
+
+ nxgl_coord_t x = getX() + glyphSpace + g_cycle.width;
+ nxgl_coord_t y = getY();
+ nxgl_coord_t w = glyphSpace + g_cycle.width;
+ nxgl_coord_t h = rect.getHeight() - 1;
+
+ port->drawLine(x, y, w, h, separatorLeftColor);
+ port->drawLine(x+1, y, w+1, h, separatorRightColor);
+
+ // Only draw text if option is selected
+
+ if (m_options.getSelectedItem() != NULL)
+ {
+ struct nxgl_point_s pos;
+ pos.x = getX() + m_align.x;
+ pos.y = getY() + m_align.y;
+
+ port->drawText(&pos, &rect, getFont(),
+ m_options.getSelectedItem()->getText(), 0,
+ m_options.getSelectedItem()->getText().getLength(),
+ textColor);
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CCycleButton::drawBorder(CGraphicsPort *port)
+{
+ // Determine the background color
+
+ nxwidget_pixel_t backColor;
+
+ if (isClicked() || m_highlighted)
+ {
+ backColor = getSelectedBackgroundColor();
+ }
+ else
+ {
+ backColor = getBackgroundColor();
+ }
+
+ // Draw the background (excluding the border)
+
+ port->drawFilledRect(getX(), getY(), getWidth(), getHeight(), backColor);
+
+ // Then add the border.
+
+ drawOutline(port);
+}
+
+/**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+void CCycleButton::drawOutline(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (isBorderless())
+ {
+ return;
+ }
+
+ // Work out which colors to use
+
+ nxgl_coord_t color1;
+ nxgl_coord_t color2;
+
+ if (isClicked())
+ {
+ // Bevelled into the screen
+
+ color1 = getShadowEdgeColor();
+ color2 = getShineEdgeColor();
+ }
+ else
+ {
+ // Bevelled out of the screen
+
+ color1 = getShineEdgeColor();
+ color2 = getShadowEdgeColor();
+ }
+
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2);
+}
+
+/**
+ * Selects the next option in the list and redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CCycleButton::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Choose next option
+
+ if (m_options.getItemCount() > 1)
+ {
+ int selectedIndex = m_options.getSelectedIndex();
+
+ if (selectedIndex < m_options.getItemCount() - 1)
+ {
+ // Move to next option
+
+ selectOption(selectedIndex + 1);
+ }
+ else
+ {
+ // Wrap around as there are no more options
+
+ selectOption(0);
+ }
+ }
+
+ redraw();
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CCycleButton::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
diff --git a/NxWidgets/libnxwidgets/src/cglyphbutton.cxx b/NxWidgets/libnxwidgets/src/cglyphbutton.cxx
new file mode 100644
index 000000000..f24b5c943
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cglyphbutton.cxx
@@ -0,0 +1,297 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cglyphbutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cglyphbutton.hxx"
+#include "cgraphicsport.hxx"
+#include "cbitmap.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button.
+ * @param y The y coordinate of the button.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param normalGlyph Glyph to display when unclicked.
+ * @param clickedGlyph Glyph to display when clicked.
+ * @param bitmapX The x coordinate at which the bitmaps will be drawn.
+ * @param bitmapY The y coordinate at which the bitmaps will be drawn.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the values stored in the global
+ * g_defaultWidgetStyle object. The button will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CGlyphButton::CGlyphButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_coord_t bitmapX, nxgl_coord_t bitmapY,
+ FAR const struct SBitmap *normalGlyph,
+ FAR const struct SBitmap *clickedGlyph,
+ CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, width, height, 0, style)
+{
+ // The border should be set to the minimum so that the bitmap
+ // image can extend all the way to the border.
+
+ m_borderSize.top = 1;
+ m_borderSize.right = 1;
+ m_borderSize.bottom = 1;
+ m_borderSize.left = 1;
+
+ // Save the bitmap state data
+
+ m_bitmapX = bitmapX;
+ m_bitmapY = bitmapY;
+ m_bitmapNormal = normalGlyph;
+ m_bitmapClicked = clickedGlyph;
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent.
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CGlyphButton::getPreferredDimensions(CRect &rect) const
+{
+ nxgl_coord_t width = m_bitmapNormal->width;
+ nxgl_coord_t height = m_bitmapNormal->height;
+
+ if (!m_flags.borderless)
+ {
+ width = m_borderSize.left + m_borderSize.right;
+ height = m_borderSize.top + m_borderSize.bottom;
+ }
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width);
+ rect.setHeight(height);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CGlyphButton::drawContents(CGraphicsPort *port)
+{
+ // Get the drawable region within the Label
+
+ CRect rect;
+ getRect(rect);
+
+ // Pick the glyph to show
+
+ FAR const struct SBitmap *bitmap;
+ if (m_flags.clicked)
+ {
+ bitmap = m_bitmapClicked;
+ }
+ else
+ {
+ bitmap = m_bitmapNormal;
+ }
+
+ // Then draw it -- in greyscale if not enabled
+
+ if (isEnabled())
+ {
+ port->drawBitmap(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ bitmap, m_bitmapX, m_bitmapY,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ }
+ else
+ {
+ port->drawBitmapGreyScale(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ bitmap, m_bitmapX, m_bitmapY);
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CGlyphButton::drawBorder(CGraphicsPort *port)
+{
+ port->drawFilledRect(getX(), getY(), getWidth(),
+ getHeight(), getBackgroundColor());
+ drawOutline(port);
+}
+
+/**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+void CGlyphButton::drawOutline(CGraphicsPort *port)
+{
+ // Don't draw if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ // Determine which colors to use
+
+ nxgl_coord_t color1;
+ nxgl_coord_t color2;
+
+ if (isClicked())
+ {
+ // Bevelled into the screen
+
+ color1 = getShadowEdgeColor();
+ color2 = getShineEdgeColor();
+ }
+ else
+ {
+ // Bevelled out of the screen
+
+ color1 = getShineEdgeColor();
+ color2 = getShadowEdgeColor();
+ }
+
+ port->drawBevelledRect(getX(), getY(),
+ getWidth(), getHeight(),
+ color1, color2);
+ }
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CGlyphButton::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Raises an action event and redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CGlyphButton::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ m_widgetEventHandlers->raiseReleaseEvent(x, y);
+ redraw();
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CGlyphButton::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
diff --git a/NxWidgets/libnxwidgets/src/cgraphicsport.cxx b/NxWidgets/libnxwidgets/src/cgraphicsport.cxx
new file mode 100644
index 000000000..d43f3bdfa
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cgraphicsport.cxx
@@ -0,0 +1,994 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cgraphicsport.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <cerrno>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "inxwindow.hxx"
+#include "cnxstring.hxx"
+#include "crect.hxx"
+#include "cnxfont.hxx"
+#include "cgraphicsport.hxx"
+#include "cwidgetstyle.hxx"
+#include "cbitmap.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pNxWnd. An instance of the underlying window type.
+ * @param backColor. The background color is only needed if we
+ * cannot read from the graphics device.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+CGraphicsPort::CGraphicsPort(INxWindow *pNxWnd, nxgl_mxpixel_t backColor)
+{
+ m_pNxWnd = pNxWnd;
+ m_backColor = backColor;
+}
+#else
+CGraphicsPort::CGraphicsPort(INxWindow *pNxWnd)
+{
+ m_pNxWnd = pNxWnd;
+}
+#endif
+
+/**
+ * Destructor.
+ */
+
+CGraphicsPort::~CGraphicsPort(void)
+{
+ // m_pNxWnd is not deleted. This is an abstract base class and
+ // the caller of the CGraphicsPort instance is responsible for
+ // the window destruction.
+};
+
+/**
+ * Return the absolute x coordinate of the upper left hand corner of the
+ * underlying window.
+ *
+ * @return The x coordinate of the underlying window.
+ */
+
+const nxgl_coord_t CGraphicsPort::getX(void) const
+{
+ struct nxgl_point_s pos;
+ (void)m_pNxWnd->getPosition(&pos);
+ return pos.x;
+};
+
+/**
+ * Return the absolute y coordinate of the upper left hand corner of the
+ * underlying window.
+ *
+ * @return The y coordinate of the underlying window.
+ */
+
+const nxgl_coord_t CGraphicsPort::getY(void) const
+{
+ struct nxgl_point_s pos;
+ (void)m_pNxWnd->getPosition(&pos);
+ return pos.y;
+};
+
+/**
+ * Draw a pixel into the window.
+ *
+ * @param x The window-relative x coordinate of the pixel.
+ * @param y The window-relative y coordinate of the pixel.
+ * @param color The color of the pixel.
+ */
+
+void CGraphicsPort::drawPixel(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_mxpixel_t color)
+{
+ struct nxgl_point_s pos;
+ pos.x = x;
+ pos.y = y;
+ m_pNxWnd->setPixel(&pos, color);
+}
+
+/**
+ * Draw a horizontal line of the specified start position, width, and color.
+ *
+ * @param x The x coordinate of the line.
+ * @param y The y coordinate of the top-most end of the line.
+ * @param width The width of the line in pixels.
+ * @param color The color of the line.
+ */
+
+void CGraphicsPort::drawHorizLine(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_mxpixel_t color)
+{
+ FAR struct nxgl_rect_s dest;
+ nxgl_coord_t halfwidth;
+
+ // Express the line as a rectangle
+
+ halfwidth = width >> 1;
+
+ dest.pt1.x = x;
+ dest.pt1.y = y;
+ dest.pt2.x = x + width - 1;
+ dest.pt2.y = y;
+
+ // Draw the line
+
+ if (!m_pNxWnd->fill(&dest, color))
+ {
+ gdbg("INxWindow::fill failed\n");
+ }
+}
+
+/**
+ * Draw a vertical line of the specified start position, width, and
+ * color.
+ *
+ * @param x The x coordinate of the left-most end of the line.
+ * @param y The y coordinate of the line.
+ * @param height The height of the line in rows.
+ * @param color The color of the line.
+ */
+
+void CGraphicsPort::drawVertLine(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t height, nxgl_mxpixel_t color)
+{
+ FAR struct nxgl_rect_s dest;
+
+ // Express the line as a rectangle
+
+ dest.pt1.x = x;
+ dest.pt1.y = y;
+ dest.pt2.x = x;
+ dest.pt2.y = y + height - 1;
+
+ // Draw the line
+
+ if (!m_pNxWnd->fill(&dest, color))
+ {
+ gdbg("INxWindow::fill failed\n");
+ }
+}
+
+/**
+ * Draw a line of a fixed color in the window.
+ *
+ * @param x1 The x coordinate of the start point of the line.
+ * @param y1 The y coordinate of the start point of the line.
+ * @param x2 The x coordinate of the end point of the line.
+ * @param y2 The y coordinate of the end point of the line.
+ * @param color The color of the line.
+ */
+
+void CGraphicsPort::drawLine(nxgl_coord_t x1, nxgl_coord_t y1,
+ nxgl_coord_t x2, nxgl_coord_t y2,
+ nxgl_mxpixel_t color)
+{
+ struct nxgl_vector_s vector;
+
+ vector.pt1.x = x1;
+ vector.pt1.y = y1;
+ vector.pt2.x = x2;
+ vector.pt2.y = y2;
+
+ if (!m_pNxWnd->drawLine(&vector, 1, color))
+ {
+ gdbg("INxWindow::drawLine failed\n");
+ }
+}
+
+/**
+ * Draw a filled rectangle to the bitmap.
+ *
+ * @param x The window-relative x coordinate of the rectangle.
+ * @param y The window-relative y coordinate of the rectangle.
+ * @param width The width of the rectangle in pixels.
+ * @param height The height of the rectangle in rows.
+ * @param color The color of the rectangle.
+ */
+
+void CGraphicsPort::drawFilledRect(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_mxpixel_t color)
+{
+ struct nxgl_rect_s rect;
+ rect.pt1.x = x;
+ rect.pt1.y = y;
+ rect.pt2.x = x + width - 1;
+ rect.pt2.y = y + height - 1;
+ m_pNxWnd->fill(&rect, color);
+}
+
+/**
+ * Draw an unfilled rectangle to the window
+ *
+ * @param x The window-relative x coordinate of the rectangle.
+ * @param y The window-relative y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @param color The color of the rectangle outline.
+ */
+
+void CGraphicsPort::drawRect(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_mxpixel_t color)
+{
+ drawHorizLine(x, y, width, color);
+ drawHorizLine(x, y + height - 1, width, color);
+ drawVertLine(x, y, height, color);
+ drawVertLine(x + width -1, y, height, color);
+}
+
+/**
+ * Draw a bevelled rectangle to the window.
+ *
+ * @param x The x coordinate of the rectangle.
+ * @param y The y coordinate of the rectangle.
+ * @param width The width of the rectangle.
+ * @param height The height of the rectangle.
+ * @param shineColor The color of the top/left sides.
+ * @param shadowColor The color of the bottom/right sides.
+ */
+
+void CGraphicsPort::drawBevelledRect(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ nxgl_mxpixel_t shineColor,
+ nxgl_mxpixel_t shadowColor)
+{
+ drawHorizLine(x, y, width, shineColor); // Top
+ drawHorizLine(x, y + height - 1, width, shadowColor); // Bottom
+ drawVertLine(x, y + 1, height - 2, shineColor); // Left
+ drawVertLine(x + width - 1, y + 1, height - 2, shadowColor); // Right
+}
+
+/**
+ * Draw an opaque bitmap to the window.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied
+ * bitmap to use as the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied
+ * bitmap to use as the origin.
+ */
+
+void CGraphicsPort::drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap,
+ int bitmapX, int bitmapY)
+{
+ // origin - The origin of the upper, left-most corner of the full bitmap.
+ // Both dest and origin are in window coordinates, however, origin
+ // may lie outside of the display.
+
+ struct nxgl_point_s origin;
+ origin.x = x - bitmapX;
+ origin.y = y - bitmapY;
+
+ // dest - Describes the rectangular on the display that will receive the
+ // the bit map.
+
+ struct nxgl_rect_s dest;
+ dest.pt1.x = x;
+ dest.pt1.y = y;
+ dest.pt2.x = x + width - 1;
+ dest.pt2.y = y + height - 1;
+
+ // Blit the bitmap
+
+ (void)m_pNxWnd->bitmap(&dest, (FAR const void *)bitmap->data, &origin, bitmap->stride);
+}
+
+/**
+ * Draw a bitmap to the window, using the supplied transparent
+ * color as an invisible color.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param transparentColor The transparent color used in the bitmap.
+ */
+
+void CGraphicsPort::drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap,
+ int bitmapX, int bitmapY,
+ nxgl_mxpixel_t transparentColor)
+{
+ // Get the starting position in the image, offset by bitmapX and bitmapY into the image.
+
+ FAR uint8_t *srcLine = (uint8_t *)bitmap->data +
+ bitmapY * bitmap->stride +
+ ((bitmapX * bitmap->bpp + 7) >> 3);
+ FAR nxwidget_pixel_t *srcPtr = (nxwidget_pixel_t *)srcLine;
+
+ // Loop until all rows have been displayed
+
+ nxgl_coord_t firstX = x;
+ nxgl_coord_t lastX = x + width;
+ nxgl_coord_t lastY = y + height;
+
+ while (y < lastY)
+ {
+ // Search for the next non-transparent pixel in the source image
+
+ while (*srcPtr == transparentColor)
+ {
+ // The pixel is transparent. Move to the next column
+
+ if (++x >= lastX)
+ {
+ // We are at the end of the row. Reset to the next row
+
+ x = firstX;
+ y++;
+
+ // Was that the last row:
+
+ if (y >= lastY)
+ {
+ // Yes, then we are finished
+
+ return;
+ }
+
+ // Update the source data pointers to the beginning of the next
+ // row
+
+ srcLine += bitmap->stride;
+ srcPtr = (nxwidget_pixel_t *)srcLine;
+ }
+ else
+ {
+ // This is another transparent pixel on the same row
+
+ srcPtr++;
+ }
+ }
+
+ // srcPtr points to the next non-transparent color. Save this
+ // as the start of a run that has length of at least one
+
+ FAR nxwidget_pixel_t *runPtr = srcPtr;
+ nxgl_coord_t runX = x;
+ nxgl_coord_t runWidth = 0;
+
+ // Now search for the next transparent pixel on the same row.
+ // This will determine the length of the run
+
+ do
+ {
+ // This is another non-transparent pixel on the same row
+
+ runWidth++;
+ srcPtr++;
+
+ // Move to the next column
+
+ if (++x >= lastX)
+ {
+ // We are at the end of the row. Reset to the next row
+
+ x = firstX;
+ y++;
+
+ // Update the source data pointers to the beginning of the next
+ // row
+
+ srcLine += bitmap->stride;
+ srcPtr = (nxwidget_pixel_t *)srcLine;
+
+ // And break out of this loop
+
+ break;
+ }
+ }
+ while (*srcPtr != transparentColor);
+
+ // When we come out of the above loop, either (1) srcPtr points to the
+ // next transparent pixel on the same row, or (2) srcPtr points to the
+ // first pixel in the next row.
+
+ // origin - The origin of the upper, left-most corner of the full bitmap.
+ // Both dest and origin are in window coordinates, however, origin
+ // may lie outside of the display.
+
+ struct nxgl_point_s origin;
+ origin.x = runX;
+ origin.y = y;
+
+ // dest - Describes the rectangular on the display that will receive the
+ // the bit map.
+
+ struct nxgl_rect_s dest;
+ dest.pt1.x = runX;
+ dest.pt1.y = y;
+ dest.pt2.x = runX + runWidth - 1;
+ dest.pt2.y = y;
+
+ // Blit the bitmap
+
+ (void)m_pNxWnd->bitmap(&dest, (FAR const void *)runPtr, &origin, bitmap->stride);
+ }
+}
+
+/**
+ * Draw a bitmap to the port in greyscale.
+ *
+ * @param x The window-relative x coordinate to draw the bitmap to.
+ * @param y The window-relative y coordinate to draw the bitmap to.
+ * @param width The width of the bitmap to draw.
+ * @param height The height of the bitmap to draw.
+ * @param bitmap Pointer to the bitmap to draw.
+ * @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
+ * the origin.
+ * @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
+ * the origin.
+ */
+
+void CGraphicsPort::drawBitmapGreyScale(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const struct SBitmap *bitmap,
+ int bitmapX, int bitmapY)
+{
+ // Working buffer. Holds one converted row from the bitmap
+
+ FAR nxwidget_pixel_t *run = new nxwidget_pixel_t[width];
+
+ // Pointer to the beginning of the first source row
+
+ FAR uint8_t *src = (FAR uint8_t *)bitmap->data + bitmapY * bitmap->stride + bitmapX;
+
+ // Setup non-changing blit parameters
+
+ struct nxgl_point_s origin;
+ origin.x = 0;
+ origin.y = 0;
+
+ struct nxgl_rect_s dest;
+ dest.pt1.x = x;
+ dest.pt1.y = y;
+ dest.pt2.x = x + width - 1;
+ dest.pt2.y = y;
+
+ // Convert each row to greyscale and send it to the display
+
+ for (int row = 0; row < height; row++)
+ {
+ // Convert the next row
+
+ FAR nxwidget_pixel_t *runSrc = (FAR nxwidget_pixel_t *)src;
+ FAR nxwidget_pixel_t *runDest = run;
+
+ for (int col = 0; col < width; col++)
+ {
+ // Get the next RGB pixel and break out the individual components
+
+ nxwidget_pixel_t rgb = *runSrc++;
+ nxwidget_pixel_t r = RGB2RED(rgb);
+ nxwidget_pixel_t g = RGB2GREEN(rgb);
+ nxwidget_pixel_t b = RGB2BLUE(rgb);
+
+ // A truly accurate greyscale conversion would be complex. Let's
+ // just average.
+
+ nxwidget_pixel_t avg = (r + g + b) / 3;
+ *runDest++ = MKRGB(avg, avg, avg);
+ }
+
+ // Now blit the single row
+
+ (void)m_pNxWnd->bitmap(&dest, (FAR void *)bitmap->data, &origin, bitmap->stride);
+
+ // Setup for the next source row
+
+ y++;
+ dest.pt1.y = y;
+ dest.pt2.y = y;
+
+ src += bitmap->stride;
+ }
+
+ delete run;
+}
+
+/**
+ * Draw a string to the window.
+ *
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ */
+
+void CGraphicsPort::drawText(struct nxgl_point_s *pos, CRect *bound,
+ CNxFont *font, const CNxString &string)
+{
+ drawText(pos, bound, font, string, 0, string.getLength());
+}
+
+/**
+ * Draw a particular length of a string to the window in a secific color.
+ *
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ * @param startIndex The start index within the string from which
+ * drawing will commence.
+ * @param length The number of characters to draw.
+ * @param color The color of the string.
+ */
+
+void CGraphicsPort::drawText(struct nxgl_point_s *pos, CRect *bound,
+ CNxFont *font, const CNxString &string,
+ int startIndex, int length,
+ nxgl_mxpixel_t color)
+{
+ // Temporarily change the font color
+
+ nxgl_mxpixel_t savedColor = font->getColor();
+ font->setColor(color);
+
+ // Draw the string with this new color
+
+ drawText(pos, bound, font, string, startIndex, length);
+
+ // Restore the font color
+
+ font->setColor(savedColor);
+}
+
+/**
+ * Draw a portion of a string to the window.
+ * @param pos The window-relative x/y coordinate of the string.
+ * @param bound The window-relative bounds of the string.
+ * @param font The font to draw with.
+ * @param string The string to output.
+ * @param startIndex The start index within the string from which
+ * drawing will commence.
+ * @param length The number of characters to draw.
+ */
+
+void CGraphicsPort::drawText(struct nxgl_point_s *pos, CRect *bound,
+ CNxFont *font, const CNxString &string,
+ int startIndex, int length)
+{
+ // Verify index and length
+
+ int stringLength = string.getLength();
+ if (startIndex >= stringLength)
+ {
+ return;
+ }
+
+ int endIndex = startIndex + length;
+ if (endIndex > stringLength)
+ {
+ endIndex = stringLength;
+ }
+
+ // Allocate a bit of memory to hold the largest rendered font
+
+ unsigned int bmWidth = ((unsigned int)font->getMaxWidth() * CONFIG_NXWIDGETS_BPP + 7) >> 3;
+ unsigned int bmHeight = (unsigned int)font->getHeight();
+
+ unsigned int glyphSize = bmWidth * bmHeight;
+ FAR uint8_t *glyph = new uint8_t[glyphSize];
+
+ // Get the bounding rectangle in NX form
+
+ struct nxgl_rect_s boundingBox;
+ bound->getNxRect(&boundingBox);
+
+ // Loop setup
+
+ struct SBitmap bitmap;
+ bitmap.bpp = CONFIG_NXWIDGETS_BPP;
+ bitmap.fmt = CONFIG_NXWIDGETS_FMT;
+ bitmap.data = (FAR const nxgl_mxpixel_t*)glyph;
+
+ // Loop for each letter in the sub-string
+
+ for (int i = startIndex; i < endIndex; i++)
+ {
+ // Get the next letter in the string
+
+ const nxwidget_char_t letter = string.getCharAt(i);
+
+ // Get the font metrics for this letter
+
+ struct nx_fontmetric_s metrics;
+ font->getCharMetrics(letter, &metrics);
+
+ // Get the width of the font (in pixels)
+
+ nxgl_coord_t fontWidth = (nxgl_coord_t)(metrics.width + metrics.xoffset);
+
+ // Does the letter have height? Spaces have width, but no height
+
+ if (metrics.height > 0)
+ {
+ // Get the height of the font
+
+ nxgl_coord_t fontHeight = (nxgl_coord_t)(metrics.height + metrics.yoffset);
+
+ // Set the current, effective size of the bitmap
+
+ bitmap.width = fontWidth;
+ bitmap.height = fontHeight;
+ bitmap.stride = (fontWidth * bitmap.bpp + 7) >> 3;
+
+ // Describe the destination of the font as a bounding box
+
+ struct nxgl_rect_s dest;
+ dest.pt1.x = pos->x;
+ dest.pt1.y = pos->y;
+ dest.pt2.x = pos->x + fontWidth - 1;
+ dest.pt2.y = pos->y + fontHeight - 1;
+
+ // Get the interection of the font box and the bounding box
+
+ struct nxgl_rect_s intersection;
+ nxgl_rectintersect(&intersection, &dest, &boundingBox);
+
+ // Skip to the next character if this one is completely outside
+ // the bounding box.
+
+ if (!nxgl_nullrect(&intersection))
+ {
+ // Initialize the bitmap memory by reading from the display. The
+ // font renderer always renders the fonts on a transparent background.
+ // Sometimes a solid background works, sometimes not. But reading
+ // from graphics memory always works.
+
+#ifdef CONFIG_NX_WRITEONLY
+ // Set the glyph memory to the background color
+
+ nxwidget_pixel_t *bmPtr = (nxwidget_pixel_t *)bitmap.data;
+ unsigned int npixels = fontWidth * fontHeight;
+ for (unsigned int j = 0; j < npixels; j++)
+ {
+ *bmPtr++ = m_backColor;
+ }
+#else
+ // Read the current contents of the destination into the glyph memory
+
+ m_pNxWnd->getRectangle(&dest, &bitmap);
+#endif
+ // Render the font into the initialized bitmap
+
+ font->drawChar(&bitmap, letter);
+
+ // Then put the font on the display
+
+ if (!m_pNxWnd->bitmap(&intersection, (FAR const void *)bitmap.data,
+ pos, bitmap.stride))
+ {
+ gvdbg("nx_bitmapwindow failed: %d\n", errno);
+ }
+ }
+ }
+
+ // Adjust the X position for the next character in the string
+
+ pos->x += fontWidth;
+ }
+
+ delete glyph;
+}
+
+/**
+ * Copy a rectangular region from the source coordinates to the
+ * destination coordinates.
+ *
+ * @param sourceX Source x coordinate.
+ * @param sourceY Source y coordinate.
+ * @param destX Destination x coordinate.
+ * @param destY Destination y coordinate.
+ * @param width Width of the rectangle to copy.
+ * @param height Height of the rectangle to copy.
+ */
+
+void CGraphicsPort::copy(nxgl_coord_t sourceX, nxgl_coord_t sourceY,
+ nxgl_coord_t destX, nxgl_coord_t destY,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ struct nxgl_rect_s rect;
+ struct nxgl_point_s offset;
+
+ rect.pt1.x = sourceX;
+ rect.pt1.y = sourceY;
+ rect.pt1.x = sourceX + width - 1;
+ rect.pt1.y = sourceY + height - 1;
+
+ offset.x = destX - sourceX;
+ offset.y = destY - sourceY;
+
+ (void)m_pNxWnd->move(&rect, &offset);
+}
+
+/**
+ * Move a region by a specified distance in two dimensions.
+ *
+ * @param x X coordinate of the source area to move.
+ * @param y Y coordinate of the source area to move.
+ * @param deltaX Horizontal distance to move.
+ * @param deltaY Vertical distance to move.
+ * @param width Width of the area to move.
+ * @param height Height of the area to move.
+ */
+
+void CGraphicsPort::move(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t deltaX, nxgl_coord_t deltaY,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ struct nxgl_rect_s rect;
+ rect.pt1.x = x;
+ rect.pt1.y = y;
+ rect.pt2.x = x + width - 1;
+ rect.pt2.y = y = height -1;
+
+ struct nxgl_point_s offset;
+ offset.x = deltaX;
+ offset.y = deltaY;
+
+ (void)m_pNxWnd->move(&rect, &offset);
+}
+
+/**
+ * Convert the region to greyscale.
+ *
+ * @param x X coordinate of the region to change.
+ * @param y Y coordinate of the region to change.
+ * @param width Width of the region to change.
+ * @param height Height of the region to change.
+ */
+
+void CGraphicsPort::greyScale(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Allocate memory to hold one row of graphics data
+
+ unsigned int stride = ((unsigned int)width * CONFIG_NXWIDGETS_BPP + 7) >> 3;
+ FAR uint8_t *rowBuffer = new uint8_t[height * stride];
+ if (!rowBuffer)
+ {
+ return;
+ }
+
+ // Describe the receiving bitmap memory
+
+ SBitmap rowBitmap;
+ rowBitmap.bpp = CONFIG_NXWIDGETS_BPP;
+ rowBitmap.fmt = CONFIG_NXWIDGETS_FMT;
+ rowBitmap.width = width;
+ rowBitmap.height = 1;
+ rowBitmap.stride = stride;
+ rowBitmap.data = (FAR const nxgl_mxpixel_t *)rowBuffer;
+
+ // Partially describe the source rectangle
+
+ struct nxgl_rect_s rect;
+ rect.pt1.x = x;
+ rect.pt2.x = x + width - 1;
+
+ // Partially setup the graphics origin
+
+ struct nxgl_point_s origin;
+ origin.x = x;
+
+ // Loop for each row in the region to be inverted
+
+ for (int row = 0; row < height; row++)
+ {
+ // Read the graphic memory corresponding to the row
+
+ rect.pt1.y = rect.pt2.y = y + row;
+ m_pNxWnd->getRectangle(&rect, &rowBitmap);
+
+ // Convert each bit to each bit
+
+ nxwidget_pixel_t *ptr = (nxwidget_pixel_t *)rowBuffer;
+ for (int col = 0; col < width; col++)
+ {
+ // Get the next RGB pixel and break out the individual components
+
+ nxwidget_pixel_t color = *ptr;
+ uint8_t red = RGB2RED(color);
+ uint8_t green = RGB2GREEN(color);
+ uint8_t blue = RGB2BLUE(color);
+
+ // A truly accurate greyscale conversion would be complex. Let's
+ // just average.
+
+ nxwidget_pixel_t avg = (red + green + blue) / 3;
+ *ptr++ = MKRGB(avg, avg, avg);
+ }
+
+ // Then write the row back to graphics memory
+
+ origin.y = rect.pt1.y;
+ m_pNxWnd->bitmap(&rect, (FAR const void *)rowBitmap.data,
+ &origin, rowBitmap.stride) ;
+ }
+
+ delete rowBuffer;
+}
+
+/**
+ * Invert colors in a region. NOTE: This allocates an in-memory
+ * buffer the size of one row in graphic memory. So it may only be
+ * useful for inverting small regions and its only current use of for
+ * the inverted cursor text.
+ *
+ * @param x X coordinate of the region to change.
+ * @param y Y coordinate of the region to change.
+ * @param width Width of the region to change.
+ * @param height Height of the region to change.
+ */
+
+void CGraphicsPort::invert(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Allocate memory to hold one row of graphics data
+
+ unsigned int stride = ((unsigned int)width * CONFIG_NXWIDGETS_BPP + 7) >> 3;
+ FAR uint8_t *rowBuffer = new uint8_t[height * stride];
+ if (!rowBuffer)
+ {
+ return;
+ }
+
+ // Describe the receiving bitmap memory
+
+ SBitmap rowBitmap;
+ rowBitmap.bpp = CONFIG_NXWIDGETS_BPP;
+ rowBitmap.fmt = CONFIG_NXWIDGETS_FMT;
+ rowBitmap.width = width;
+ rowBitmap.height = 1;
+ rowBitmap.stride = stride;
+ rowBitmap.data = (FAR const nxgl_mxpixel_t *)rowBuffer;
+
+ // Partially describe the source rectangle
+
+ struct nxgl_rect_s rect;
+ rect.pt1.x = x;
+ rect.pt2.x = x + width - 1;
+
+ // Partially setup the graphics origin
+
+ struct nxgl_point_s origin;
+ origin.x = x;
+
+ // Loop for each row in the region to be inverted
+
+ for (int row = 0; row < height; row++)
+ {
+ // Read the graphic memory corresponding to the row
+
+ rect.pt1.y = rect.pt2.y = y + row;
+ m_pNxWnd->getRectangle(&rect, &rowBitmap);
+
+ // Invert each bit
+
+ nxwidget_pixel_t *ptr = (nxwidget_pixel_t *)rowBuffer;
+ for (int col = 0; col < width; col++)
+ {
+ nxwidget_pixel_t color = *ptr;
+ uint8_t red = RGB2RED(color);
+ uint8_t green = RGB2GREEN(color);
+ uint8_t blue = RGB2BLUE(color);
+ *ptr++ = MKRGB(~red, ~green, ~blue);
+ }
+
+ // Then write the row back to graphics memory
+
+ origin.y = rect.pt1.y;
+ m_pNxWnd->bitmap(&rect, (FAR const void *)rowBitmap.data,
+ &origin, rowBitmap.stride) ;
+ }
+
+ delete rowBuffer;
+};
+
diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx
new file mode 100644
index 000000000..30bf7e78b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cimage.cxx
@@ -0,0 +1,456 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cimage.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cgraphicsport.hxx"
+#include "ibitmap.hxx"
+#include "cbitmap.hxx"
+#include "cimage.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for a label containing a string.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the image box, relative to its parent.
+ * @param y The y coordinate of the image box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param bitmap The source bitmap image.
+ * @param style The style that the widget should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CImage::CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height, FAR IBitmap *bitmap,
+ CWidgetStyle *style)
+ : CNxWidget(pWidgetControl, x, y, width, height, 0, style)
+{
+ // Save the IBitmap instance
+
+ m_bitmap = bitmap;
+
+ // Not highlighted
+
+ m_highlighted = false;
+
+ // Position the top/lef corner of the bitmap in the top/left corner of the display
+
+ m_origin.x = 0;
+ m_origin.y = 0;
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CImage::getPreferredDimensions(CRect &rect) const
+{
+ nxgl_coord_t width = m_bitmap->getWidth();
+ nxgl_coord_t height = m_bitmap->getHeight();
+
+ if (!m_flags.borderless)
+ {
+ width += (m_borderSize.left + m_borderSize.right);
+ height += (m_borderSize.top + m_borderSize.bottom);
+ }
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width);
+ rect.setHeight(height);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CImage::drawContents(CGraphicsPort *port)
+{
+ // Get the the drawable region
+
+ CRect rect;
+ getRect(rect);
+
+ // Allocate a working buffer that will hold one row of the bitmap
+
+ FAR nxwidget_pixel_t *buffer = new nxwidget_pixel_t[rect.getWidth()];
+
+ // Set up a simple bitmap structure to describe one row
+
+ struct SBitmap bitmap;
+ bitmap.bpp = m_bitmap->getBitsPerPixel();
+ bitmap.fmt = m_bitmap->getColorFormat();
+ bitmap.width = rect.getWidth();
+ bitmap.height = 1;
+ bitmap.stride = (rect.getWidth() * m_bitmap->getBitsPerPixel()) >> 3;
+ bitmap.data = buffer;
+
+ // Select the correct colorization
+
+ m_bitmap->setSelected(isClicked() || m_highlighted);
+
+ // This is the number of rows that we can draw at the top of the display
+
+ nxgl_coord_t nTopRows = m_bitmap->getHeight() - m_origin.y;
+ if (nTopRows > rect.getHeight())
+ {
+ nTopRows = rect.getHeight();
+ }
+ else if (nTopRows < 0)
+ {
+ nTopRows = 0;
+ }
+
+ // This the starting row in the bitmap image where we will begin drawing.
+
+ nxgl_coord_t imageRow = m_origin.y;
+
+ // This the starting row in the display image where we will begin drawing.
+
+ nxgl_coord_t displayRow = rect.getY();
+
+ // Are we going to draw any rows at the top of the display?
+
+ if (nTopRows > 0)
+ {
+ // This is the number of columns that we can draw on the left side of
+ // the display
+
+ nxgl_coord_t nLeftPixels = m_bitmap->getWidth() - m_origin.x;
+
+ // This is the number of rows that we have to pad on the right if the display
+ // width is wider than the image width
+
+ nxgl_coord_t nRightPad;
+ if (nLeftPixels >= rect.getWidth())
+ {
+ nRightPad = 0;
+ }
+ else
+ {
+ nRightPad = rect.getWidth() - nLeftPixels;
+ }
+
+ // Apply the padding to the right hand side
+
+ FAR nxwidget_pixel_t *ptr = &buffer[nLeftPixels];
+ nxwidget_pixel_t backColor = getBackgroundColor();
+
+ for (int column = nLeftPixels; column < rect.getWidth(); column++)
+ {
+ *ptr++ = backColor;
+ }
+
+ // The is the row number of the first row that we cannot draw into
+
+ nxgl_coord_t lastTopRow = nTopRows + m_origin.y;
+
+ // Now draw the rows from the offset position
+
+ for (; imageRow < lastTopRow; imageRow++, displayRow++)
+ {
+ // Get the graphics data for the right hand side of this row
+
+ if (!m_bitmap->getRun(m_origin.x, imageRow, nLeftPixels, buffer))
+ {
+ gvdbg("IBitmap::getRun failed at image row\n", imageRow);
+ delete buffer;
+ return;
+ }
+
+ // Replace any transparent pixels with the background color.
+ // Then we can use the faster opaque drawBitmap() function.
+
+ ptr = buffer;
+ for (int i = 0; i < nLeftPixels; i++, ptr++)
+ {
+ if (*ptr == CONFIG_NXWIDGETS_TRANSPARENT_COLOR)
+ {
+ *ptr = backColor;
+ }
+ }
+
+ // And put these on the display
+
+ if (isEnabled())
+ {
+ port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1,
+ &bitmap, 0, 0);
+ }
+ else
+ {
+ port->drawBitmapGreyScale(rect.getX(), displayRow,
+ rect.getWidth(), 1,
+ &bitmap, 0, 0);
+ }
+ }
+ }
+
+ // Are we going to draw any rows at the bottom of the display?
+
+ if (nTopRows < rect.getHeight())
+ {
+ // Pad the entire row
+
+ FAR nxwidget_pixel_t *ptr = buffer;
+ nxwidget_pixel_t backColor = getBackgroundColor();
+
+ for (int column = 0; column < rect.getWidth(); column++)
+ {
+ *ptr++ = backColor;
+ }
+
+ // Now draw the rows from the offset position
+
+ for (; displayRow < rect.getHeight(); displayRow++)
+ {
+ // Put the padded row on the display
+
+ if (isEnabled())
+ {
+ port->drawBitmap(rect.getX(), displayRow,
+ rect.getWidth(), 1,
+ &bitmap, 0, 0);
+ }
+ else
+ {
+ port->drawBitmapGreyScale(rect.getX(),displayRow,
+ rect.getWidth(), 1,
+ &bitmap, 0, 0);
+ }
+ }
+ }
+
+ delete buffer;
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CImage::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (isBorderless())
+ {
+ return;
+ }
+
+ // Work out which colors to use
+
+ nxgl_coord_t color1;
+ nxgl_coord_t color2;
+
+ if (isClicked())
+ {
+ // Bevelled into the screen
+
+ color1 = getShadowEdgeColor();
+ color2 = getShineEdgeColor();
+ }
+ else
+ {
+ // Bevelled out of the screen
+
+ color1 = getShineEdgeColor();
+ color2 = getShadowEdgeColor();
+ }
+
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2);
+}
+
+/**
+ * Control the highlight state.
+ *
+ * @param highlightOn True(1), the image will be highlighted
+ */
+
+void CImage::highlight(bool highlightOn)
+{
+ if (m_highlighted != highlightOn)
+ {
+ m_highlighted = highlightOn;
+ redraw();
+ }
+}
+
+/**
+ * Redraws the button.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CImage::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Raises an action.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CImage::onPreRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ m_widgetEventHandlers->raiseActionEvent();
+}
+
+/**
+ * Redraws the image.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CImage::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Redraws the image.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CImage::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Set the horizontal position of the bitmap. Zero is the left edge
+ * of the bitmap and values >0 will move the bit map to the right.
+ * This method is useful for horizontal scrolling a large bitmap
+ * within a smaller window
+ */
+
+void CImage::setImageLeft(nxgl_coord_t column)
+{
+ if (column > 0 && column <= m_bitmap->getWidth())
+ {
+ m_origin.x = column;
+ }
+}
+
+/**
+ * Set the vertical position of the bitmap. Zero is the top edge
+ * of the bitmap and values >0 will move the bit map down.
+ * This method is useful for vertical scrolling a large bitmap
+ * within a smaller window
+ */
+
+void CImage::setImageTop(nxgl_coord_t row)
+{
+ if (row > 0 && row <= m_bitmap->getHeight())
+ {
+ m_origin.x = row;
+ }
+}
+
diff --git a/NxWidgets/libnxwidgets/src/ckeypad.cxx b/NxWidgets/libnxwidgets/src/ckeypad.cxx
new file mode 100644
index 000000000..898885c62
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ckeypad.cxx
@@ -0,0 +1,214 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ckeypad.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxglib.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cwidgetstyle.hxx"
+#include "ckeypad.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+// The geometry of the button array
+
+#define BUTTONARRAY_NCOLUMNS 4
+#define BUTTONARRAY_NROWS 7
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+static FAR const char *g_alphaLabels[BUTTONARRAY_NCOLUMNS*BUTTONARRAY_NROWS] = {
+ "=>", "A", "B", "<DEL",
+ "C", "D", "E", "F",
+ "G", "H", "I", "J",
+ "K", "L", "M", "N",
+ "O", "P", "Q", "R",
+ "S", "T", "U", "V",
+ "W", "X", "Y", "Z"
+};
+
+static FAR const char *g_numLabels[BUTTONARRAY_NCOLUMNS*BUTTONARRAY_NROWS] = {
+ "=>", "0", "1", "<DEL",
+ "2", "3", "4", "5",
+ "6", "7", "8", "9",
+ "-", "#", "*", "&",
+ "?", "!", "@", "%",
+ ":", ",", ".", "/",
+ "\"", "'", "(", ")"
+};
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+/**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param hNxServer The NX server that will receive the keyboard input
+ * @param x The x coordinate of the keypad, relative to its parent.
+ * @param y The y coordinate of the keypad, relative to its parent.
+ * @param width The width of the keypad
+ * @param height The height of the keypad
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CKeypad::CKeypad(CWidgetControl *pWidgetControl, NXHANDLE hNxServer,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CButtonArray(pWidgetControl, x, y, 4, 7, width / BUTTONARRAY_NCOLUMNS,
+ height / BUTTONARRAY_NROWS, style)
+{
+ m_hNxServer = hNxServer;
+
+ // Force the height and width to be an exact multiple of the button height and width
+
+ resize(m_buttonWidth * m_buttonColumns, m_buttonHeight * m_buttonRows);
+
+ // Start in alphabetic mode
+
+ setKeypadMode(false);
+}
+
+/**
+ * Catch button clicks.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CKeypad::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Perform the redraw
+
+ CButtonArray::onClick(x, y);
+
+ // The button should now be clicked
+
+ int column;
+ int row;
+
+ if (isButtonClicked(column, row))
+ {
+ // The left arrow at (0,0) is a special case
+
+ char ch;
+ if (column == 0 && row == 0)
+ {
+ m_widgetControl->newCursorControlEvent(CURSOR_RIGHT);
+ return;
+ }
+
+ // The backspace at (3,0) is a special case
+
+ else if (column == 3 && row == 0)
+ {
+ ch = KEY_CODE_BACKSPACE;
+ }
+
+ // Otherwise, just grab the character for the arrays
+
+ else
+ {
+ int index = row * BUTTONARRAY_NCOLUMNS + column;
+ FAR const char *ptr;
+ if (m_numeric)
+ {
+ ptr = g_numLabels[index];
+ }
+ else
+ {
+ ptr = g_alphaLabels[index];
+ }
+
+ ch = ptr[0];
+ }
+
+ // Then inject the keyboard input into the NX server. The NX
+ // server will determine which window receives the input.
+ // The ultimate recipient will be the widget in the top window
+ // that has focus.
+
+ (void)nx_kbdchin(m_hNxServer, (uint8_t)ch);
+ }
+}
+
+/**
+ * Configure the keypad for the currenly selected display mode.
+ */
+
+void CKeypad::configureKeypadMode(void)
+{
+ // Add the labels to each button. Each call to setText would
+ // cause a text change event and, hence, redrawing of the
+
+ FAR const char **ptr = m_numeric ? g_numLabels : g_alphaLabels;
+ for (int j = 0; j < BUTTONARRAY_NROWS; j++)
+ {
+ for (int i = 0; i < BUTTONARRAY_NCOLUMNS; i++)
+ {
+ // setText does this. But each call to setText would
+ // cause a text change even and, hence, redrawing of
+ // the whole keypad. So we access the protected data
+ // directly and redraw only once.
+
+ CNxString string = *ptr++;
+ m_buttonText[j * m_buttonColumns + i] = string;
+ }
+ }
+
+ // Then redraw the display
+
+ onTextChange();
+}
+
diff --git a/NxWidgets/libnxwidgets/src/clabel.cxx b/NxWidgets/libnxwidgets/src/clabel.cxx
new file mode 100644
index 000000000..4c7ea3554
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clabel.cxx
@@ -0,0 +1,426 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clabel.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "clabel.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CLabel Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for a label containing a string.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CLabel::CLabel(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, CWidgetStyle *style)
+ : CNxWidget(pWidgetControl, x, y, width, height, 0, style)
+{
+ // Default is centered text
+
+ m_hAlignment = TEXT_ALIGNMENT_HORIZ_CENTER;
+ m_vAlignment = TEXT_ALIGNMENT_VERT_CENTER;
+
+ // The border thickness is 1 pixel
+
+ m_borderSize.top = 1;
+ m_borderSize.right = 1;
+ m_borderSize.bottom = 1;
+ m_borderSize.left = 1;
+
+ m_align.x = 0;
+ m_align.y = 0;
+
+ m_textChange = false;
+ m_highlighted = false;
+ setText(text);
+
+ calculateTextPositionHorizontal();
+ calculateTextPositionVertical();
+}
+
+/**
+ * Set the horizontal alignment of text within the label.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+void CLabel::setTextAlignmentHoriz(TextAlignmentHoriz alignment)
+{
+ m_hAlignment = alignment;
+ calculateTextPositionHorizontal();
+ redraw();
+}
+
+/**
+ * Set the vertical alignment of text within the label.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+void CLabel::setTextAlignmentVert(TextAlignmentVert alignment)
+{
+ m_vAlignment = alignment;
+ calculateTextPositionVertical();
+ redraw();
+}
+
+/**
+ * Set the text displayed in the label.
+ *
+ * @param text String to display.
+ */
+
+void CLabel::setText(const CNxString &text)
+{
+ m_text = text;
+ onTextChange();
+}
+
+/**
+ * Append new text to the end of the current text displayed in the
+ * label.
+ *
+ * @param text String to append.
+ */
+
+void CLabel::appendText(const CNxString &text)
+{
+ m_text.append(text);
+ onTextChange();
+}
+
+/**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+void CLabel::insertText(const CNxString &text, const int index)
+{
+ m_text.insert(text, index);
+ onTextChange();
+}
+
+/**
+ * Control the highlight state.
+ *
+ * @param highlightOn True(1), the label will be highlighted
+ */
+
+void CLabel::highlight(bool highlightOn)
+{
+ if (highlightOn != m_highlighted)
+ {
+ m_highlighted = highlightOn;
+ redraw();
+ }
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CLabel::getPreferredDimensions(CRect &rect) const
+{
+ nxgl_coord_t width;
+ nxgl_coord_t height;
+
+ if (!m_flags.borderless)
+ {
+ width = m_borderSize.left + m_borderSize.right;
+ height = m_borderSize.top + m_borderSize.bottom;
+ }
+ else
+ {
+ width = 0;
+ height = 0;
+ }
+
+ width += getFont()->getStringWidth(m_text);
+ height += getFont()->getHeight();
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width);
+ rect.setHeight(height);
+}
+
+/**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+void CLabel::setFont(CNxFont *font)
+{
+ m_style.font = font;
+
+ // Need to recalculate the text position as the font may have changed size
+
+ calculateTextPositionHorizontal();
+ calculateTextPositionVertical();
+ redraw();
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ * @param port The CGraphicsPort to draw to.
+ *
+ * @see redraw()
+ */
+
+void CLabel::drawContents(CGraphicsPort *port)
+{
+ // Get the drawing area (excluding the border)
+
+ CRect rect;
+ getRect(rect);
+
+ // Pick the text and background colors
+
+ nxgl_mxpixel_t textColor;
+ nxgl_mxpixel_t backColor;
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ backColor = getBackgroundColor();
+ }
+ else if (m_highlighted)
+ {
+ textColor = getSelectedTextColor();
+ backColor = getSelectedBackgroundColor();
+ }
+ else
+ {
+ textColor = getEnabledTextColor();
+ backColor = getBackgroundColor();
+ }
+
+ // Draw the background (excluding the border)
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(), backColor);
+
+ // Get the X/Y position of the text within the Label
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() + m_align.x;
+ pos.y = rect.getY() + m_align.y;
+
+ // Add the text using the selected color
+
+ port->drawText(&pos, &rect, getFont(), m_text, 0, m_text.getLength(),
+ textColor);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CLabel::drawBorder(CGraphicsPort *port)
+{
+ // Check if the widget indicates it should have an outline: That
+ // the outline is enabled and the this is not just a text-only
+ // redraw
+
+ if (!isBorderless() && !isTextChange())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Resize the widget to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CLabel::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ calculateTextPositionHorizontal();
+ calculateTextPositionVertical();
+}
+
+/**
+ * Calculate the vertical position of the string based on the font
+ *
+ * height and the alignment options.
+ */
+
+void CLabel::calculateTextPositionVertical(void)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ nxgl_coord_t height = rect.getHeight();
+
+ switch (m_vAlignment)
+ {
+ case TEXT_ALIGNMENT_VERT_CENTER:
+ m_align.y = (height - getFont()->getHeight()) >> 1;
+ break;
+
+ case TEXT_ALIGNMENT_VERT_TOP:
+ m_align.y = 0;
+ break;
+
+ case TEXT_ALIGNMENT_VERT_BOTTOM:
+ m_align.y = height - getFont()->getHeight();
+ break;
+ }
+}
+
+/**
+ * Calculate the position of the string based on its length and the
+ * alignment options.
+ */
+
+void CLabel::calculateTextPositionHorizontal(void)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ nxgl_coord_t width = rect.getWidth();
+
+ switch (m_hAlignment)
+ {
+ case TEXT_ALIGNMENT_HORIZ_CENTER:
+ m_align.x = (width - getFont()->getStringWidth(m_text)) >> 1;
+ break;
+
+ case TEXT_ALIGNMENT_HORIZ_LEFT:
+ m_align.x = 0;
+ break;
+
+ case TEXT_ALIGNMENT_HORIZ_RIGHT:
+ m_align.x = width - getFont()->getStringWidth(m_text);
+ break;
+ }
+}
+
+/**
+ * Updates the GUI after the text has changed.
+ */
+
+void CLabel::onTextChange(void)
+{
+ calculateTextPositionHorizontal();
+ calculateTextPositionVertical();
+ m_textChange = true;
+ redraw();
+ m_textChange = false;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+
diff --git a/NxWidgets/libnxwidgets/src/clatchbutton.cxx b/NxWidgets/libnxwidgets/src/clatchbutton.cxx
new file mode 100644
index 000000000..673d50319
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clatchbutton.cxx
@@ -0,0 +1,131 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clatchbutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybutton.hxx"
+#include "clatchbutton.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CLatchButton::CLatchButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text,
+ CWidgetStyle *style)
+: CStickyButton(pWidgetControl, x, y, width, height, text, style)
+{
+}
+
+/**
+ * Handles button click events
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CLatchButton::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ /* On each press event, toggle the button stuck down state */
+
+ toggleStuckDown();
+}
diff --git a/NxWidgets/libnxwidgets/src/clatchbuttonarray.cxx b/NxWidgets/libnxwidgets/src/clatchbuttonarray.cxx
new file mode 100644
index 000000000..d8292941b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clatchbuttonarray.cxx
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clatchbuttonarray.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybuttonarray.hxx"
+#include "clatchbuttonarray.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for an array of latch buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CLatchButtonArray::CLatchButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style)
+: CStickyButtonArray(pWidgetControl, x, y, buttonColumns, buttonRows, buttonWidth, buttonHeight, style)
+{
+}
+
+/**
+ * Handles button click events
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CLatchButtonArray::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // We need to save the button position so that when CButtonArray
+ // gets the release, it will have the correct position. This would
+ // look nicer if we just called CButtonArray::onClock() but that
+ // would cause duplicate redraw()
+
+ m_clickX = x;
+ m_clickY = y;
+
+ // Convert the new key press to row/columin indices
+
+ int column;
+ int row;
+
+ if (posToButton(x, y, column, row))
+ {
+ // Change the stuck down button on each in-range button press
+ // NOTE that normally button click events are not processed (but
+ // button release events will be processed).
+
+ stickDown(column, row);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/clistbox.cxx b/NxWidgets/libnxwidgets/src/clistbox.cxx
new file mode 100644
index 000000000..a8d3db0a6
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clistbox.cxx
@@ -0,0 +1,661 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clistbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "clistbox.hxx"
+#include "cgraphicsport.hxx"
+#include "cnxfont.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CListBox::CListBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CScrollingPanel(pWidgetControl, x, y, width, height, 0, style)
+{
+ m_flags.draggable = true;
+ m_flags.doubleClickable = true;
+ m_optionPadding = 2;
+ m_options.addListDataEventHandler(this);
+ m_lastSelectedIndex = -1;
+
+ // Disallow horizontal scrolling
+
+ setAllowsHorizontalScroll(false);
+}
+
+/**
+ * Destructor.
+ */
+
+CListBox::~CListBox(void)
+{
+ m_options.removeListDataEventHandler(this);
+}
+
+
+/**
+ * Add a new option to the widget using default colors.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+void CListBox::addOption(const CNxString &text, const uint32_t value)
+{
+ addOption(text, value,
+ getShadowEdgeColor(), getBackgroundColor(),
+ getShadowEdgeColor(), getHighlightColor());
+}
+
+/**
+ * Add an option to the widget.
+ *
+ * @param option The option to add.
+ */
+
+void CListBox::addOption(CListBoxDataItem *option)
+{
+ m_options.addItem(option);
+}
+
+/**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+void CListBox::removeOption(const int index)
+{
+ m_options.removeItem(index);
+}
+
+/**
+ * Remove all options from the widget.
+ */
+
+void CListBox::removeAllOptions(void)
+{
+ m_options.removeAllItems();
+}
+
+/**
+ * Add a new option to the widget.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+void CListBox::addOption(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor)
+{
+ addOption(new CListBoxDataItem(text, value,
+ normalTextColor, normalBackColor,
+ selectedTextColor, selectedBackColor));
+}
+
+/**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+void CListBox::selectOption(const int index)
+{
+ setOptionSelected(index, true);
+}
+
+/**
+ * Select an option by its index.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ */
+
+void CListBox::deselectOption(const int index)
+{
+ setOptionSelected(index, false);
+}
+
+/**
+ * Select all options. Does nothing if the listbox does not allow
+ * multiple selections. Redraws the widget and raises a value changed
+ * event.
+ */
+
+void CListBox::selectAllOptions(void)
+{
+ m_options.selectAllItems();
+}
+
+/**
+ * Deselect all options.
+ * Redraws the widget and raises a value changed event.
+ */
+
+void CListBox::deselectAllOptions(void)
+{
+ m_options.deselectAllItems();
+}
+
+/**
+ * Get the selected index. Returns -1 if nothing is selected. If
+ * more than one option is selected, the index of the first selected
+ * option is returned.
+ *
+ * @return The selected index.
+ */
+
+const int CListBox::getSelectedIndex(void) const
+{
+ return m_options.getSelectedIndex();
+}
+
+/**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected options to deselected. Redraws the widget and raises
+ * a value changed event.
+ *
+ * @param index The selected index.
+ */
+
+void CListBox::setSelectedIndex(const int index)
+{
+ setOptionSelected(index, true);
+}
+
+/**
+ * Get the selected option. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+const CListBoxDataItem *CListBox::getSelectedOption(void) const
+{
+ return (const CListBoxDataItem*)m_options.getSelectedItem();
+}
+
+/**
+ * Resize the scrolling canvas to encompass all options.
+ */
+
+void CListBox::resizeCanvas(void)
+{
+ // Get client area
+
+ CRect rect;
+ getClientRect(rect);
+
+ int oldCanvasHeight = m_canvasHeight;
+
+ // Resize the canvas
+
+ m_canvasHeight = (m_options.getItemCount() * getOptionHeight());
+
+ // Ensure canvas is at least as tall as the widget
+
+ m_canvasHeight = m_canvasHeight < rect.getHeight() ? rect.getHeight() : m_canvasHeight;
+
+ // If resize has left scroll position beyond end of canvas, adjust
+ // to compensate
+
+ if (m_canvasY + (m_canvasHeight - getHeight()) < 0)
+ {
+ scroll(0, -(oldCanvasHeight - (m_canvasHeight - getHeight())));
+ }
+}
+
+/**
+ * Sort the options alphabetically by the text of the options.
+ */
+
+void CListBox::sort(void)
+{
+ m_options.sort();
+}
+
+/**
+ * Get the height of a single option.
+ *
+ * @return The height of an option.
+ */
+
+const nxgl_coord_t CListBox::getOptionHeight(void) const
+{
+ return getFont()->getHeight() + (m_optionPadding << 1);
+}
+
+/**
+ * Handles list data changed events.
+ *
+ * @param e Event arguments.
+ */
+
+void CListBox::handleListDataChangedEvent(const CListDataEventArgs &e)
+{
+ // Forget the last selected item as it may have changed
+
+ m_lastSelectedIndex = -1;
+ resizeCanvas();
+ redraw();
+}
+
+/**
+ * Handles list selection changed events.
+ *
+ * @param e Event arguments.
+ */
+
+void CListBox::handleListDataSelectionChangedEvent(const CListDataEventArgs &e)
+{
+ redraw();
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CListBox::getPreferredDimensions(CRect &rect) const
+{
+ nxgl_coord_t width;
+ nxgl_coord_t height;
+
+ if (!m_flags.borderless)
+ {
+ width = m_borderSize.left + m_borderSize.right;
+ height = m_borderSize.top + m_borderSize.bottom;
+ }
+ else
+ {
+ width = 0;
+ height = 0;
+ }
+
+ nxgl_coord_t maxWidth = 0;
+ nxgl_coord_t optionWidth = 0;
+
+ // Locate longest string in options
+
+ for (int i = 0; i < m_options.getItemCount(); ++i)
+ {
+ optionWidth = getFont()->getStringWidth(m_options.getItem(i)->getText());
+
+ if (optionWidth > maxWidth)
+ {
+ maxWidth = optionWidth;
+ }
+ }
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width + (m_optionPadding << 1) + maxWidth);
+ rect.setHeight(height + getOptionHeight() * 3);
+}
+
+/**
+ * Check if the click is a double-click.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click is a double-click.
+ */
+
+bool CListBox::isDoubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (CNxWidget::isDoubleClick(x, y))
+ {
+ // Calculate which option was clicked
+
+ int selectedIndex = (-m_canvasY + (y - getY())) / getOptionHeight();
+
+ // Has the same option been clicked twice? Ignore double-clicks that
+ // occur on different items
+
+ if (selectedIndex == m_lastSelectedIndex)
+ {
+ // Process click as a double-click
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CListBox::drawContents(CGraphicsPort *port)
+{
+ // Get the drawing region (excluding the borders)
+
+ CRect rect;
+ getRect(rect);
+
+ // Draw background
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ getBackgroundColor());
+
+ // Calculate clipping values
+
+ nxgl_coord_t clipX = rect.getX();
+ nxgl_coord_t clipY = rect.getY();
+ nxgl_coord_t clipHeight = rect.getHeight();
+
+ // Precalc values for option draw loop
+
+ nxgl_coord_t optionHeight = getOptionHeight();
+
+ // Ensure that we subtract 1 from topOption to ensure that the option
+ // above is drawn if it is partially visible
+
+ int topOption = ((clipY - m_canvasY) / optionHeight) - 1;
+
+ // Ensure that we add 2 to the bottom option to ensure that the option
+ // below is draw if it is partially visible - subbing 1 from topOption
+ // means we need to add an additional 1 to compensate
+
+ int bottomOption = topOption + (clipHeight / optionHeight) + 2;
+
+ // Ensure top options is not negative
+
+ if (topOption < 0)
+ {
+ topOption = 0;
+ }
+
+ // Ensure bottom option does not exceed number of options
+
+ if (bottomOption >= m_options.getItemCount())
+ {
+ bottomOption = m_options.getItemCount() - 1;
+ }
+
+ // Calculate values for loop
+
+ int y = m_canvasY + (topOption * optionHeight);
+ int i = topOption;
+
+ const CListBoxDataItem *item = (CListBoxDataItem *)NULL;
+
+ // Loop through all options drawing each ones
+
+ while (i <= bottomOption)
+ {
+ item = (const CListBoxDataItem*)m_options.getItem(i);
+
+ // Is the option selected?
+
+ if (item->isSelected())
+ {
+ // Draw background
+
+ if (item->getSelectedBackColor() != getBackgroundColor())
+ {
+ port->drawFilledRect(rect.getX(), rect.getY() + y,
+ rect.getWidth(), optionHeight,
+ item->getSelectedBackColor());
+ }
+
+ // Draw text
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() + m_optionPadding;
+ pos.y = rect.getY() + y + m_optionPadding;
+
+ if (isEnabled())
+ {
+ port->drawText(&pos, &rect, getFont(), item->getText(), 0,
+ item->getText().getLength(),
+ item->getSelectedTextColor());
+ }
+ else
+ {
+ port->drawText(&pos, &rect, getFont(), item->getText(), 0,
+ item->getText().getLength(),
+ getDisabledTextColor());
+ }
+ }
+ else
+ {
+ // Draw background
+
+ if (item->getNormalBackColor() != getBackgroundColor())
+ {
+ port->drawFilledRect(clipX, y, getWidth(), optionHeight,
+ item->getNormalBackColor());
+ }
+
+ // Draw text
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() + m_optionPadding;
+ pos.y = rect.getY() + y + m_optionPadding;
+
+ if (isEnabled())
+ {
+ port->drawText(&pos, &rect, getFont(), item->getText(), 0,
+ item->getText().getLength(),
+ item->getNormalTextColor());
+ }
+ else
+ {
+ port->drawText(&pos, &rect, getFont(), item->getText(), 0,
+ item->getText().getLength(),
+ getDisabledTextColor());
+ }
+ }
+
+ i++;
+ y += optionHeight;
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CListBox::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(0, 0, getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Determines which item was clicked and selects or deselects it as
+ * appropriate. Also starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CListBox::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Calculate which option was clicked
+
+ m_lastSelectedIndex = (-m_canvasY + (y - getY())) / getOptionHeight();
+
+ const CListBoxDataItem *item =
+ (const CListBoxDataItem*)m_options.getItem(m_lastSelectedIndex);
+
+ // Are we setting or unsetting?
+
+ if (item->isSelected())
+ {
+ // Deselecting
+
+ m_options.deselectItem(m_lastSelectedIndex);
+ }
+ else
+ {
+ // Selecting
+
+ m_options.selectItem(m_lastSelectedIndex);
+ }
+
+ startDragging(x, y);
+ redraw();
+}
+
+/**
+ * Selects the clicked item and deselects all others.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CListBox::onDoubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Calculate which option was clicked
+
+ int newSelectedIndex = (-m_canvasY + (y - getY())) / getOptionHeight();
+
+ // Double-click - select the item exclusively
+
+ deselectAllOptions();
+ setSelectedIndex(newSelectedIndex);
+ m_widgetEventHandlers->raiseActionEvent();
+}
+
+/**
+ * Select or deselect an option by its index. Does not deselect any other selected options.
+ * Set index to -1 to select nothing.
+ * Redraws the widget and raises a value changed event.
+ *
+ * @param index The index of the option to select.
+ * @param selected True to select the option, false to deselect it.
+ */
+
+void CListBox::setOptionSelected(const int index, bool selected)
+{
+ m_options.setItemSelected(index, selected);
+}
diff --git a/NxWidgets/libnxwidgets/src/clistboxdataitem.cxx b/NxWidgets/libnxwidgets/src/clistboxdataitem.cxx
new file mode 100644
index 000000000..0ef1b2d25
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clistboxdataitem.cxx
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clistboxdataitem.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "clistboxdataitem.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param text The text to display in the item.
+ * @param value The value of the item.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+CListBoxDataItem::CListBoxDataItem(const CNxString& text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor)
+: CListDataItem(text, value)
+{
+ m_normalTextColor = normalTextColor;
+ m_normalBackColor = normalBackColor;
+ m_selectedTextColor = selectedTextColor;
+ m_selectedBackColor = selectedBackColor;
+}
diff --git a/NxWidgets/libnxwidgets/src/clistdata.cxx b/NxWidgets/libnxwidgets/src/clistdata.cxx
new file mode 100644
index 000000000..3b9601fc0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clistdata.cxx
@@ -0,0 +1,462 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clistdata.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+
+#include "clistdata.hxx"
+#include "ilistdataeventhandler.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ */
+
+CListData::CListData(void)
+{
+ m_allowMultipleSelections = true;
+ m_sortInsertedItems = false;
+}
+
+/**
+ * Destructor.
+ */
+
+CListData::~CListData(void)
+{
+ removeAllItems();
+}
+
+/**
+ * Add a new item.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+void CListData::addItem(const CNxString &text, const uint32_t value)
+{
+ // Create new option
+
+ addItem(new CListDataItem(text, value));
+}
+
+/**
+ * Add an existing item. CListData becomes the owner of the option and will delete it
+ * when the list is deleted.
+ *
+ * @param item The item to add.
+ */
+
+void CListData::addItem(CListDataItem *item)
+{
+ // Determine insert type
+
+ if (m_sortInsertedItems)
+ {
+ // Sorted insert
+
+ m_items.insert(getSortedInsertionIndex(item), item);
+ }
+ else
+ {
+ // Append
+
+ m_items.push_back(item);
+ }
+
+ raiseDataChangedEvent();
+}
+
+/**
+ * Remove an item by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+void CListData::removeItem(const int index)
+{
+ // Bounds check
+
+ if (index < m_items.size())
+ {
+ // Delete the option
+
+ delete m_items[index];
+
+ // Erase the option from the list
+
+ m_items.erase(index);
+ raiseDataChangedEvent();
+ }
+}
+
+/**
+ * Select an item by its index.
+ *
+ * @param index The index of the item to select.
+ */
+
+void CListData::selectItem(const int index)
+{
+ setItemSelected(index, true);
+}
+
+/**
+ * Deselect an item by its index.
+ *
+ * @param index The index of the item to select.
+ */
+
+void CListData::deselectItem(const int index)
+{
+ setItemSelected(index, false);
+}
+
+/**
+ * Remove all items.
+ */
+
+void CListData::removeAllItems(void)
+{
+ // Delete all option data
+
+ for (int i = 0; i < m_items.size(); i++)
+ {
+ delete m_items[i];
+ }
+
+ m_items.clear();
+ raiseDataChangedEvent();
+}
+
+/**
+ * Get the selected index. Returns -1 if nothing is selected. If more than one
+ * item is selected, the index of the first selected item is returned.
+ *
+ * @return The selected index.
+ */
+
+const int CListData::getSelectedIndex(void) const
+{
+ // Get the first selected index
+
+ for (int i = 0; i < m_items.size(); i++)
+ {
+ if (m_items[i]->isSelected())
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/**
+ * Sets the selected index. Specify -1 to select nothing. Resets any
+ * other selected items to deselected.
+ *
+ * @param index The selected index.
+ */
+
+void CListData::setSelectedIndex(const int index)
+{
+ setItemSelected(index, true);
+}
+
+/**
+ * Get the selected item. Returns NULL if nothing is selected.
+ *
+ * @return The selected option.
+ */
+
+const CListDataItem *CListData::getSelectedItem(void) const
+{
+ // Get the first selected option
+
+ int index = getSelectedIndex();
+ if (index > -1)
+ {
+ return m_items[index];
+ }
+ return (CListDataItem *)NULL;
+}
+
+/**
+ * Sort the items using their compareTo() methods.
+ */
+
+void CListData::sort(void)
+{
+ quickSort(0, m_items.size() - 1);
+ raiseDataChangedEvent();
+}
+
+/**
+ * Select all items. Does nothing if the list does not allow
+ * multiple selections.
+ */
+
+void CListData::selectAllItems(void)
+{
+ if (m_allowMultipleSelections)
+ {
+ for (int i = 0; i < m_items.size(); i++)
+ {
+ m_items[i]->setSelected(true);
+ }
+
+ raiseSelectionChangedEvent();
+ }
+}
+
+/**
+ * Deselect all items.
+ */
+
+void CListData::deselectAllItems(void)
+{
+ for (int i = 0; i < m_items.size(); i++)
+ {
+ m_items[i]->setSelected(false);
+ }
+
+ raiseSelectionChangedEvent();
+}
+
+/**
+ * Select or deselect an item by its index. Does not deselect any
+ * other selected items. Set index to -1 to select nothing.
+ *
+ * @param index The index of the item to select.
+ * @param selected True to select the item, false to deselect it.
+ */
+
+void CListData::setItemSelected(const int index, bool selected)
+{
+ // Deselect old options if we're making an option selected and
+ // we're not a multiple list
+
+ if (((!m_allowMultipleSelections) || (index == -1)) && (selected))
+ {
+ for (int i = 0; i < m_items.size(); i++)
+ {
+ m_items[i]->setSelected(false);
+ }
+ }
+
+ // Select or deselect the new option
+
+ if ((index > -1) && (index < m_items.size()))
+ {
+ m_items[index]->setSelected(selected);
+ }
+
+ raiseSelectionChangedEvent();
+}
+
+/**
+ * Remove an event handler.
+ *
+ * @param eventHandler The event handler to remove.
+ */
+
+void CListData::removeListDataEventHandler(IListDataEventHandler *eventHandler)
+{
+ for (int i = 0; i < m_listDataEventhandlers.size(); ++i)
+ {
+ if (m_listDataEventhandlers.at(i) == eventHandler)
+ {
+ m_listDataEventhandlers.erase(i);
+ return;
+ }
+ }
+}
+
+/**
+ * Quick sort the items using their compareTo() methods.
+ *
+ * @param start The index to start sorting at.
+ * @param end The index to stop sorting at.
+ */
+
+void CListData::quickSort(const int start, const int end)
+{
+ if (end > start)
+ {
+ int left = start;
+ int right = end;
+
+ CListDataItem *pivot = m_items[(start + end) >> 1];
+
+ do
+ {
+ while ((pivot->compareTo(m_items[left]) > 0) && (left < end))
+ {
+ left++;
+ }
+
+ while ((pivot->compareTo(m_items[right]) < 0) && (right > start))
+ {
+ right--;
+ }
+
+ if (left > right)
+ {
+ break;
+ }
+
+ swapItems(left, right);
+ left++;
+ right--;
+ }
+ while (left <= right);
+
+ quickSort(start, right);
+ quickSort(left, end);
+ }
+}
+
+/**
+ * Swap the locations of two items in the array.
+ *
+ * @param index1 The index of the first item to swap.
+ * @param index2 The index of the second item to swap.
+ */
+
+void CListData::swapItems(const int index1, const int index2)
+{
+ CListDataItem *tmp = m_items[index1];
+ m_items[index1] = m_items[index2];
+ m_items[index2] = tmp;
+}
+
+/**
+ * Return the index that an item should be inserted at to maintain a sorted list of data.
+ *
+ * @param item The item to insert.
+ * @return The index that the item should be imserted into at.
+ */
+
+const int CListData::getSortedInsertionIndex(const CListDataItem *item) const
+{
+ int i = 0;
+
+ // Locate slot where new option should go
+
+ while ((i < m_items.size()) && (item->compareTo(m_items[i]) > 0))
+ {
+ i++;
+ }
+ return i;
+}
+
+/**
+ * Raise a data changed event.
+ */
+
+void CListData::raiseDataChangedEvent(void)
+{
+ CListDataEventArgs eventArgs(this);
+
+ for (int i = 0; i < m_listDataEventhandlers.size(); ++i)
+ {
+ m_listDataEventhandlers.at(i)->handleListDataChangedEvent(eventArgs);
+ }
+}
+
+/**
+ * Raise a selection changed event.
+ */
+
+void CListData::raiseSelectionChangedEvent(void)
+{
+ CListDataEventArgs eventArgs(this);
+
+ for (int i = 0; i < m_listDataEventhandlers.size(); ++i)
+ {
+ m_listDataEventhandlers.at(i)->handleListDataSelectionChangedEvent(eventArgs);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/clistdataitem.cxx b/NxWidgets/libnxwidgets/src/clistdataitem.cxx
new file mode 100644
index 000000000..036cea61e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/clistdataitem.cxx
@@ -0,0 +1,128 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/clistdataitem.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "clistdataitem.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+/**
+ * Constructor.
+ *
+ * @param text The text to display in the item.
+ * @param value The value of the item.
+ */
+
+CListDataItem::CListDataItem(const CNxString &text, const uint32_t value)
+{
+ m_text = text;
+ m_value = value;
+ m_isSelected = false;
+}
+
+/**
+ * Destructor.
+ */
+
+CListDataItem::~CListDataItem(void)
+{
+}
+
+/**
+ * Compare the item with another. Comparison is based on the text of
+ * the item. Returns 0 if the text in the two items is the same,
+ * a value less than 0 if this item is less than the argument, and
+ * a value greater than 0 if this item is greater than the argument.
+ *
+ * @param item An item to compare this object with.
+ * @return 0 if the text in the two items is the same,
+ * a value less than 0 if this item is less than the argument, and
+ * a value greater than 0 if this item is greater than the argument.
+ */
+
+int CListDataItem::compareTo(const CListDataItem *item) const
+{
+ return m_text.compareTo(item->getText());
+}
diff --git a/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx b/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
new file mode 100644
index 000000000..94caac5fd
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
@@ -0,0 +1,1284 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cnxfont.hxx"
+#include "ctext.hxx"
+#include "cgraphicsport.hxx"
+#include "singletons.hxx"
+#include "cstringiterator.hxx"
+#include "cnxtimer.hxx"
+#include "cmultilinetextbox.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param flags Standard widget flag options.
+ * @param maxRows The maximum number of rows the textbox can track. Adding
+ * text beyond this number will cause rows at the start of the text to be
+ * forgotten; text is essentially stored as a queue, and adding to the back
+ * of a full queue causes the front items to be popped off. Setting this to
+ * 0 will make the textbox track only the visible rows.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CMultiLineTextBox::CMultiLineTextBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, uint32_t flags,
+ nxgl_coord_t maxRows, CWidgetStyle *style)
+: CScrollingPanel(pWidgetControl, x, y, width, height, flags, style)
+{
+ m_hAlignment = TEXT_ALIGNMENT_HORIZ_CENTER;
+ m_vAlignment = TEXT_ALIGNMENT_VERT_CENTER;
+ m_topRow = 0;
+
+ // The border is one line thick
+
+ m_borderSize.top = 1;
+ m_borderSize.right = 1;
+ m_borderSize.bottom = 1;
+ m_borderSize.left = 1;
+
+ CRect rect;
+ getClientRect(rect);
+ m_text = new CText(getFont(), "", rect.getWidth());
+ m_canvasWidth = rect.getWidth();
+
+ m_flags.draggable = true;
+ m_flags.doubleClickable = true;
+ m_maxRows = maxRows;
+
+ calculateVisibleRows();
+
+ // Set maximum rows if value not set
+
+ if (m_maxRows == 0)
+ {
+ m_maxRows = m_visibleRows + 1;
+ }
+
+ m_cursorPos = 0;
+ m_showCursor = SHOW_CURSOR_NEVER;
+ m_wrapCursor = false;
+
+ setText(text);
+}
+
+/**
+ * Set the horizontal alignment of text within the textbox.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+void CMultiLineTextBox::setTextAlignmentHoriz(TextAlignmentHoriz alignment)
+{
+ m_hAlignment = alignment;
+ redraw();
+}
+
+/**
+ * Set the vertical alignment of text within the textbox.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+void CMultiLineTextBox::setTextAlignmentVert(TextAlignmentVert alignment)
+{
+ m_vAlignment = alignment;
+ redraw();
+}
+
+/**
+ * Returns the number of "pages" that the text spans. A page
+ * is defined as the amount of text that can be displayed within
+ * the textbox at one time.
+ *
+ * @return The page count.
+ */
+
+const int CMultiLineTextBox::getPageCount(void) const
+{
+ if (m_visibleRows > 0)
+ {
+ return (m_text->getLineCount() / m_visibleRows) + 1;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/**
+ * Returns the current page.
+ *
+ * @return The current page.
+ * @see getPageCount().
+ */
+
+const int CMultiLineTextBox::getCurrentPage(void) const
+{
+ // Calculate the top line of text
+
+ int topRow = -m_canvasY / m_text->getLineHeight();
+
+ // Return the page on which the top row falls
+
+ if (m_visibleRows > 0)
+ {
+ return topRow / m_visibleRows;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/**
+ * Set the text displayed in the textbox.
+ *
+ * @param text String to display.
+ */
+
+void CMultiLineTextBox::setText(const CNxString &text)
+{
+ bool drawingEnabled = m_flags.drawingEnabled;
+ disableDrawing();
+
+ m_text->setText(text);
+
+ cullTopLines();
+ limitCanvasHeight();
+ jumpToTextBottom();
+
+ if (drawingEnabled)
+ {
+ enableDrawing();
+ }
+ redraw();
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Append new text to the end of the current text
+ * displayed in the textbox.
+ *
+ * @param text String to append.
+ */
+
+void CMultiLineTextBox::appendText(const CNxString &text)
+{
+ bool drawingEnabled = m_flags.drawingEnabled;
+ disableDrawing();
+
+ m_text->append(text);
+
+ cullTopLines();
+ limitCanvasHeight();
+ jumpToTextBottom();
+
+ if (drawingEnabled)
+ {
+ enableDrawing();
+ }
+ redraw();
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+void CMultiLineTextBox::removeText(const unsigned int startIndex)
+{
+ removeText(startIndex, m_text->getLength() - startIndex);
+}
+
+/**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+void CMultiLineTextBox::removeText(const unsigned int startIndex,
+ const unsigned int count)
+{
+ bool drawingEnabled = m_flags.drawingEnabled;
+ disableDrawing();
+
+ m_text->remove(startIndex, count);
+
+ limitCanvasHeight();
+ limitCanvasY();
+
+ moveCursorToPosition(startIndex);
+
+ if (drawingEnabled)
+ {
+ enableDrawing();
+ }
+ redraw();
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+void CMultiLineTextBox::setFont(CNxFont *font)
+{
+ bool drawingEnabled = m_flags.drawingEnabled;
+ disableDrawing();
+
+ m_style.font = font;
+ m_text->setFont(font);
+
+ cullTopLines();
+ limitCanvasHeight();
+ limitCanvasY();
+
+ if (drawingEnabled)
+ {
+ enableDrawing();
+ }
+ redraw();
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Get the length of the text string.
+ *
+ * @return The length of the text string.
+ */
+
+const int CMultiLineTextBox::getTextLength(void) const
+{
+ return m_text->getLength();
+}
+
+/**
+ * Sets the cursor display mode.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+void CMultiLineTextBox::showCursor(EShowCursor cursorMode)
+{
+ if (m_showCursor != cursorMode)
+ {
+ m_showCursor = (uint8_t)cursorMode;
+ redraw();
+ }
+}
+
+/**
+ * Move the cursor to the text position specified. 0 indicates the start
+ * of the string. If position is greater than the length of the string,
+ * the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+void CMultiLineTextBox::moveCursorToPosition(const int position)
+{
+ CGraphicsPort *port = m_widgetControl->getGraphicsPort();
+
+ // Erase existing cursor
+
+ drawCursor(port);
+
+ // Force position to within confines of string
+
+ if (position < 0)
+ {
+ m_cursorPos = 0;
+ }
+ else
+ {
+ int len = (int)m_text->getLength();
+ m_cursorPos = len > position ? position : len;
+ }
+
+ // Draw cursor in new position
+
+ drawCursor(port);
+}
+
+/**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+void CMultiLineTextBox::insertText(const CNxString &text,
+ const unsigned int index)
+{
+ bool drawingEnabled = m_flags.drawingEnabled;
+ disableDrawing();
+
+ m_text->insert(text, index);
+
+ cullTopLines();
+ limitCanvasHeight();
+
+ moveCursorToPosition(index + text.getLength());
+
+ if (drawingEnabled)
+ {
+ enableDrawing();
+ }
+ redraw();
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+}
+
+/**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+void CMultiLineTextBox::insertTextAtCursor(const CNxString &text)
+{
+ insertText(text, getCursorPosition());
+}
+
+/**
+ * Handle a keyboard press event.
+ *
+ * @param e The event data.
+ */
+
+void CMultiLineTextBox::handleKeyPressEvent(const CWidgetEventArgs &e)
+{
+ nxwidget_char_t key = e.getKey();
+
+ if (key == KEY_CODE_BACKSPACE)
+ {
+ // Delete character in front of cursor
+
+ if (m_cursorPos > 0)
+ {
+ removeText(m_cursorPos - 1, 1);
+ }
+ }
+ else if (key != KEY_CODE_NONE)
+ {
+ // Not modifier; append value
+
+ insertTextAtCursor(key);
+ }
+}
+
+/**
+ * Get the coordinates of the cursor relative to the text.
+ *
+ * @param x Will be populated with the x coordinate of the cursor.
+ * @param y Will be populated with the y coordinate of the cursor.
+ */
+
+void CMultiLineTextBox::getCursorCoordinates(nxgl_coord_t &x, nxgl_coord_t &y) const
+{
+ unsigned int cursorRow = 0;
+
+ x = 0;
+ y = 0;
+
+ // Only calculate the cursor position if the cursor isn't at the start
+ // of the text
+
+ if (m_cursorPos > 0)
+ {
+ // Calculate the row in which the cursor appears
+
+ cursorRow = m_text->getLineContainingCharIndex(m_cursorPos);
+
+ // Cursor line offset gives us the distance of the cursor from the
+ // start of the line
+
+ uint8_t cursorLineOffset = m_cursorPos - m_text->getLineStartIndex(cursorRow);
+
+ CStringIterator *iterator = m_text->newStringIterator();
+ iterator->moveTo(m_text->getLineStartIndex(cursorRow));
+
+ // Sum the width of each char in the row to find the x coordinate
+
+ for (int i = 0; i < cursorLineOffset; ++i)
+ {
+ x += getFont()->getCharWidth(iterator->getChar());
+ iterator->moveToNext();
+ }
+
+ delete iterator;
+ }
+
+ // Add offset of row to calculated value
+
+ x += getRowX(cursorRow);
+
+ // Calculate y coordinate of the cursor
+
+ y = getRowY(cursorRow);
+}
+
+/**
+ * Gets the index of the character at the specified x coordinate in the
+ * specified row.
+ *
+ * @param x X coordinate of the character.
+ * @param rowIndex Index of the row containing the character.
+ * @return The index of the character at the specified coordinate.
+ */
+
+int CMultiLineTextBox::getCharIndexAtCoordinate(nxgl_coord_t x, int rowIndex) const
+{
+ // Locate the character within the row
+
+ int startIndex = m_text->getLineStartIndex(rowIndex);
+ int stopIndex = m_text->getLineLength(rowIndex);
+ int width = getRowX(rowIndex);
+ int index = -1;
+
+ CStringIterator *iterator = m_text->newStringIterator();
+ iterator->moveTo(startIndex);
+
+ width += m_text->getFont()->getCharWidth(iterator->getChar());
+
+ for (int i = 0; i < stopIndex; ++i)
+ {
+ if (width > x)
+ {
+ if (i == 0)
+ {
+ // If the coordinate is on the left of the text, we add nothing
+ // to the index
+
+ index = startIndex;
+ }
+ else
+ {
+ // Character within the row.
+ // This is the character that contains the coordinate.
+
+ index = startIndex + i;
+ }
+ break;
+ }
+
+ iterator->moveToNext();
+ width += m_text->getFont()->getCharWidth(iterator->getChar());
+ }
+
+ delete iterator;
+
+ // If the coordinate is past the last character, index will still be -1.
+ // We need to set it to the last character
+
+ if (index == -1)
+ {
+ if (rowIndex == m_text->getLineCount() - 1)
+ {
+ // Index past the end point of the text, so return an index
+ // just past the text
+
+ index = startIndex + stopIndex;
+ }
+ else
+ {
+ // Index at the end of a row, so return the last index of the
+ // row
+
+ index = startIndex + stopIndex - 1;
+ }
+ }
+
+ return index;
+}
+
+/**
+ * Get the index of the character at the specified coordinates.
+ *
+ * @param x X coordinate of the character.
+ * @param y Y coordinate of the character.
+ * @return The index of the character at the specified coordinates.
+ */
+
+unsigned int
+CMultiLineTextBox::getCharIndexAtCoordinates(nxgl_coord_t x, nxgl_coord_t y) const
+{
+ int rowIndex = getRowContainingCoordinate(y);
+ return getCharIndexAtCoordinate(x, rowIndex);
+}
+
+/**
+ * Get the row containing the specified Y coordinate.
+ *
+ * @param y Y coordinate to locate.
+ * @return The index of the row containing the specified Y coordinate.
+ */
+
+int CMultiLineTextBox::getRowContainingCoordinate(nxgl_coord_t y) const
+{
+ int row = -1;
+
+ // Locate the row containing the character
+
+ for (int i = 0; i < m_text->getLineCount(); ++i)
+ {
+ // Abort search if we've found the row below the y coordinate
+
+ if (getRowY(i) > y)
+ {
+ if (i == 0)
+ {
+ // If the coordinate is above the text, we return the top
+ // row
+
+ row = 0;
+ }
+ else
+ {
+ // Row within the text, so return the previous row - this is
+ // the row that contains the coordinate.
+
+ row = i - 1;
+ }
+
+ break;
+ }
+ }
+
+ // If the coordinate is below the text, row will still be -1.
+ // We need to set it to the last row
+
+ if (row == -1)
+ {
+ row = m_text->getLineCount() - 1;
+ }
+
+ return row;
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CMultiLineTextBox::drawContents(CGraphicsPort *port)
+{
+ drawText(port);
+
+ // Draw the cursor
+
+ drawCursor(port);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CMultiLineTextBox::drawBorder(CGraphicsPort *port)
+{
+ port->drawFilledRect(0, 0, getWidth(), getHeight(), getBackgroundColor());
+
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(0, 0, getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Move cursor one character to the left.
+ */
+
+void CMultiLineTextBox::moveCursorLeft(void)
+{
+ if (m_cursorPos > 0)
+ {
+ moveCursorToPosition(m_cursorPos - 1);
+ }
+
+ jumpToCursor();
+}
+
+/**
+ * Move cursor one character to the right.
+ */
+
+void CMultiLineTextBox::moveCursorRight(void)
+{
+ if (m_cursorPos < (int)m_text->getLength())
+ {
+ moveCursorToPosition(m_cursorPos + 1);
+ }
+
+ jumpToCursor();
+}
+
+/**
+ * Move cursor one row upwards.
+ */
+
+void CMultiLineTextBox::moveCursorUp(void)
+{
+ nxgl_coord_t cursorX = 0;
+ nxgl_coord_t cursorY = 0;
+
+ getCursorCoordinates(cursorX, cursorY);
+
+ // Get the midpoint of the cursor. We use the midpoint to ensure that
+ // the cursor does not drift off to the left as it moves up the text, which
+ // is a problem when we use the left edge as the reference point when the
+ // font is proportional
+
+ cursorX += m_text->getFont()->getCharWidth(m_text->getCharAt(m_cursorPos)) >> 1;
+
+ // Locate the character above the midpoint
+
+ int index = getCharIndexAtCoordinates(cursorX, cursorY + m_text->getLineHeight());
+ moveCursorToPosition(index);
+ jumpToCursor();
+}
+
+/**
+ * Move cursor one row downwards.
+ */
+
+void CMultiLineTextBox::moveCursorDown(void)
+{
+ nxgl_coord_t cursorX = 0;
+ nxgl_coord_t cursorY = 0;
+
+ getCursorCoordinates(cursorX, cursorY);
+
+ // Get the midpoint of the cursor. We use the midpoint to ensure that
+ // the cursor does not drift off to the left as it moves up the text, which
+ // is a problem when we use the left edge as the reference point when the
+ // font is proportional
+
+ cursorX += m_text->getFont()->getCharWidth(m_text->getCharAt(m_cursorPos)) >> 1;
+
+ // Locate the character above the midpoint
+
+ int index = getCharIndexAtCoordinates(cursorX, cursorY - m_text->getLineHeight());
+ moveCursorToPosition(index);
+ jumpToCursor();
+}
+
+/**
+ * Ensures that the textbox only contains the maximum allowed
+ * number of rows by culling any excess rows from the top of
+ * the text.
+ *
+ * @return True if lines were removed from the text; false if not.
+ */
+
+bool CMultiLineTextBox::cullTopLines(void)
+{
+ // Ensure that we have the correct number of rows
+
+ if (m_text->getLineCount() > m_maxRows)
+ {
+ m_text->stripTopLines(m_text->getLineCount() - m_maxRows);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Ensures that the canvas height is the height of the widget,
+ * if the widget exceeds the size of the text, or the height of
+ * the text if the text exceeds the size of the widget.
+ */
+
+void CMultiLineTextBox::limitCanvasHeight(void)
+{
+ m_canvasHeight = m_text->getPixelHeight();
+
+ CRect rect;
+ getClientRect(rect);
+ if (m_canvasHeight < rect.getHeight())
+ {
+ m_canvasHeight = rect.getHeight();
+ }
+}
+
+/**
+ * Ensures that the canvas cannot scroll beyond its height.
+ */
+
+void CMultiLineTextBox::limitCanvasY(void)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ // Ensure that the visible portion of the canvas is not less than the
+ // height of the viewer window
+
+ if (m_canvasY + m_canvasHeight < rect.getHeight())
+ {
+ jumpToTextBottom();
+ }
+}
+
+/**
+ * Jumps to the cursor coordinates of the text.
+ */
+
+void CMultiLineTextBox::jumpToCursor(void)
+{
+ // Get the co-odinates of the cursor
+
+ nxgl_coord_t cursorX;
+ nxgl_coord_t cursorY;
+
+ getCursorCoordinates(cursorX, cursorY);
+
+ // Work out which row the cursor falls within
+
+ int cursorRow = m_text->getLineContainingCharIndex(m_cursorPos);
+ nxgl_coord_t rowY = getRowY(cursorRow);
+
+ // If the cursor is outside the visible portion of the canvas, jump to it
+
+ CRect rect;
+ getClientRect(rect);
+
+ if (rowY + m_text->getLineHeight() + m_canvasY > rect.getHeight())
+ {
+ // Cursor is below the visible portion of the canvas, so
+ // jump down so that the cursor's row is the bottom row of
+ // text
+
+ jump(0, -(rowY + m_text->getLineHeight() - rect.getHeight()));
+ }
+ else if (rowY + m_canvasY < 0)
+ {
+ // Cursor is above the visible portion of the canvas, so
+ // jump up so that the cursor's row is the top row of text
+
+ jump(0, -cursorY);
+ }
+}
+
+/**
+ * Jumps to the bottom of the text.
+ */
+
+void CMultiLineTextBox::jumpToTextBottom(void)
+{
+ CRect rect;
+ getClientRect(rect);
+ jump(0, -(m_canvasHeight - rect.getHeight()));
+}
+
+/**
+ * Resize the textbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CMultiLineTextBox::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Ensure the base class resize method is called
+
+ CScrollingPanel::onResize(width, height);
+
+ // Resize the canvas' width
+
+ CRect rect;
+ getClientRect(rect);
+
+ m_canvasWidth = rect.getWidth();
+ m_canvasHeight = rect.getHeight();
+ m_canvasX = 0;
+ m_canvasY = 0;
+
+ calculateVisibleRows();
+
+ // Re-wrap the text
+
+ m_text->setWidth(getWidth());
+ m_text->wrap();
+
+ bool raiseEvent = cullTopLines();
+ limitCanvasHeight();
+ limitCanvasY();
+
+ if (raiseEvent)
+ {
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CMultiLineTextBox::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ startDragging(x, y);
+
+ // Move cursor to clicked coordinates
+
+ CRect rect;
+ getClientRect(rect);
+
+ // Adjust x and y from screen coordinates to canvas coordinates
+
+ nxgl_coord_t canvasRelativeX = x - getX() - rect.getX() - m_canvasX;
+ nxgl_coord_t canvasRelativeY = y - getY() - rect.getY() - m_canvasY;
+
+ moveCursorToPosition(getCharIndexAtCoordinates(canvasRelativeX, canvasRelativeY));
+}
+
+/**
+ * Opens the keyboard on the bottom display.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+void CMultiLineTextBox::onDoubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+}
+
+/**
+ * Handles cursor control events. Moves the cursor
+ * in the direction selected.
+ *
+ * @param key The key that was pressed.
+ */
+
+void CMultiLineTextBox::handleCursorControlEvent(const CWidgetEventArgs &e)
+{
+ ECursorControl control = e.getCursorControl();
+
+ switch (control)
+ {
+ case CURSOR_LEFT:
+ moveCursorLeft();
+ break;
+
+ case CURSOR_RIGHT:
+ moveCursorRight();
+ break;
+
+ case CURSOR_UP:
+ moveCursorDown();
+ break;
+
+ case CURSOR_DOWN:
+ moveCursorUp();
+ break;
+
+ default:
+ // Not interested in other controls
+
+ break;
+ }
+}
+
+/**
+ * Handle a keyboard press event.
+ *
+ * @param e The event data.
+ */
+
+ void handleKeyPressEvent(const CWidgetEventArgs &e);
+
+/**
+ * Gets the x position of a row of text based on the width of the row and the
+ * type of horizontal alignment currently set.
+ *
+ * @param row The index of the row.
+ * @return The x coordinate of the row.
+ */
+
+nxgl_coord_t CMultiLineTextBox::getRowX(int row) const
+{
+ CRect rect;
+ getClientRect(rect);
+
+ uint8_t rowLength = m_text->getLineTrimmedLength(row);
+ uint8_t rowPixelWidth = m_text->getFont()->getStringWidth(*m_text, m_text->getLineStartIndex(row), rowLength);
+
+ // Calculate horizontal position
+
+ switch (m_hAlignment)
+ {
+ case TEXT_ALIGNMENT_HORIZ_CENTER:
+ return (rect.getWidth() - rowPixelWidth) >> 1;
+
+ case TEXT_ALIGNMENT_HORIZ_LEFT:
+ return 0;
+
+ case TEXT_ALIGNMENT_HORIZ_RIGHT:
+ return rect.getWidth() - rowPixelWidth;
+ }
+
+ // Will never be reached
+
+ return 0;
+}
+
+/**
+ * Gets the y position of the specified row of text based on the type of
+ * vertical alignment currently set.
+ *
+ * @param row The row number to find the y coordinate of.
+ * @return The y coordinate of the specified row of text.
+ */
+
+nxgl_coord_t CMultiLineTextBox::getRowY(int row) const
+{
+ // If the amount of text exceeds the size of the widget, force
+ // the text to be top-aligned
+
+ if (m_visibleRows <= m_text->getLineCount())
+ {
+ return row * m_text->getLineHeight();
+ }
+
+ // All text falls within the textbox, so obey the alignment
+ // options
+
+ nxgl_coord_t textY = 0;
+ nxgl_coord_t startPos = 0;
+
+ int canvasRows = 0;
+ int textRows = 0;
+
+ CRect rect;
+ getClientRect(rect);
+
+ // Calculate vertical position
+
+ switch (m_vAlignment)
+ {
+ case TEXT_ALIGNMENT_VERT_CENTER:
+
+ // Calculate the maximum number of rows
+
+ canvasRows = m_canvasHeight / m_text->getLineHeight();
+ textY = row * m_text->getLineHeight();
+
+ // Get the number of rows of text
+
+ textRows = m_text->getLineCount();
+
+ // Ensure there's always one row
+
+ if (textRows == 0)
+ {
+ textRows = 1;
+ }
+
+ // Calculate the start position of the block of text
+
+ startPos = ((canvasRows - textRows) * m_text->getLineHeight()) >> 1;
+
+ // Calculate the row Y coordinate
+
+ textY = startPos + textY;
+ break;
+
+ case TEXT_ALIGNMENT_VERT_TOP:
+ textY = row * m_text->getLineHeight();
+ break;
+
+ case TEXT_ALIGNMENT_VERT_BOTTOM:
+ textY = rect.getHeight() - (((m_text->getLineCount() - row) * m_text->getLineHeight()));
+ break;
+ }
+
+ return textY;
+}
+
+/**
+ * Return true if the cursor is visible
+ */
+
+bool CMultiLineTextBox::isCursorVisible(void) const
+{
+ return (m_showCursor == SHOW_CURSOR_ALWAYS ||
+ (m_showCursor == SHOW_CURSOR_ONFOCUS && hasFocus()));
+}
+
+/**
+ * Gets the character under the cursor.
+ *
+ * @return The character under the cursor.
+ */
+
+nxwidget_char_t CMultiLineTextBox::getCursorChar(void) const
+{
+ if (m_cursorPos < m_text->getLength())
+ {
+ return m_text->getCharAt(m_cursorPos);
+ }
+ else
+ {
+ return ' ';
+ }
+}
+
+/**
+ * Works out the number of visible rows within the textbox.
+ */
+
+void CMultiLineTextBox::calculateVisibleRows(void)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ m_visibleRows = rect.getHeight() / m_text->getLineHeight();
+}
+
+/**
+ * Draws text.
+ *
+ * @param port The CGraphicsPort to draw to.
+ */
+
+void CMultiLineTextBox::drawText(CGraphicsPort *port)
+{
+ // Early exit if there is no text to display
+
+ if (m_text->getLineCount() == 0)
+ {
+ return;
+ }
+
+ // Determine the top and bottom rows within the graphicsport's clip rect.
+ // We only draw these rows in order to increase the speed of the routine.
+
+ int regionY = -m_canvasY + m_rect.getY(); // Y coord of canvas visible region
+ int topRow = getRowContainingCoordinate(regionY);
+ int bottomRow = getRowContainingCoordinate(regionY + m_rect.getHeight());
+
+ // Early exit checks
+
+ if ((topRow < 0) && (bottomRow < 0))
+ {
+ return;
+ }
+
+ if ((bottomRow >= m_text->getLineCount()) && (topRow >= m_text->getLineCount()))
+ {
+ return;
+ }
+
+ // Prevent overflows
+
+ if (topRow < 0)
+ {
+ topRow = 0;
+ }
+
+ if (bottomRow >= m_text->getLineCount())
+ {
+ bottomRow = m_text->getLineCount() - 1;
+ }
+
+ // Draw lines of text
+
+ int currentRow = topRow;
+
+ // Draw all rows in this region
+
+ while (currentRow <= bottomRow)
+ {
+ drawRow(port, currentRow);
+ currentRow++;
+ }
+}
+
+/**
+ * Draws the cursor.
+ *
+ * @param port The CGraphicsPort to draw to.
+ */
+
+void CMultiLineTextBox::drawCursor(CGraphicsPort *port)
+{
+ // Get the cursor coordinates
+
+ if (isCursorVisible())
+ {
+ nxgl_coord_t cursorX = 0;
+ nxgl_coord_t cursorY = 0;
+
+ getCursorCoordinates(cursorX, cursorY);
+
+ // Adjust for canvas offsets
+
+ cursorX += m_canvasX;
+ cursorY += m_canvasY;
+
+ // Draw cursor
+
+ port->invert(cursorX, cursorY,
+ m_text->getFont()->getCharWidth( getCursorChar()),
+ m_text->getFont()->getHeight());
+ }
+}
+
+/**
+ * Draws a single line of text.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @param row The index of the row to draw.
+ */
+
+void CMultiLineTextBox::drawRow(CGraphicsPort *port, int row)
+{
+ // Get the drawing region
+
+ CRect rect;
+ getRect(rect);
+
+ uint8_t rowLength = m_text->getLineTrimmedLength(row);
+
+ struct nxgl_point_s pos;
+ pos.x = getRowX(row) + m_canvasX;
+ pos.y = getRowY(row) + m_canvasY;
+
+ // Determine the background and text color
+
+ nxgl_mxpixel_t textColor;
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ }
+ else
+ {
+ textColor = getEnabledTextColor();
+ }
+
+ // And draw the text using the selected color
+
+ port->drawText(&pos, &rect, m_text->getFont(), *m_text,
+ m_text->getLineStartIndex(row), rowLength, textColor);
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxfont.cxx b/NxWidgets/libnxwidgets/src/cnxfont.cxx
new file mode 100644
index 000000000..189cfb9e0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxfont.cxx
@@ -0,0 +1,276 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxfont.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/nx/nxfonts.h>
+
+#include "nxconfig.hxx"
+#include "cnxstring.hxx"
+#include "cstringiterator.hxx"
+#include "cnxfont.hxx"
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CNxFont Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * CNxFont Constructor.
+ *
+ * @param fontid The font ID to use.
+ * @param fontColor The font color to use.
+ * @param transparentColor The color in the font bitmap used as the
+ * background color.
+ */
+
+CNxFont::CNxFont(enum nx_fontid_e fontid, nxgl_mxpixel_t fontColor,
+ nxgl_mxpixel_t transparentColor)
+{
+ m_fontId = fontid;
+ m_fontHandle = nxf_getfonthandle(fontid);
+ m_pFontSet = nxf_getfontset(m_fontHandle);
+ m_fontColor = fontColor;
+ m_transparentColor = transparentColor;
+}
+
+/**
+ * Checks if supplied character is blank in the current font.
+ *
+ * @param letter The character to check.
+ * @return True if the glyph contains any pixels to be drawn. False if
+ * the glyph is blank.
+ */
+
+const bool CNxFont::isCharBlank(const nxwidget_char_t letter) const
+{
+ FAR const struct nx_fontbitmap_s *fbm;
+
+ /* Get the bitmap associated with the character */
+
+ fbm = nxf_getbitmap(m_fontHandle, (uint16_t)letter);
+ return (fbm == NULL);
+}
+
+/**
+ * Draw an individual character of the font to the specified bitmap.
+ *
+ * @param bitmap The bitmap to draw use. The caller should use
+ * the getFontMetrics method to assure that the buffer will hold
+ * the font.
+ * @param letter The character to output.
+ *
+ * @return The width of the string in pixels.
+ */
+
+void CNxFont::drawChar(FAR SBitmap *bitmap, nxwidget_char_t letter)
+{
+ // Get the NX bitmap associated with the font
+
+ FAR const struct nx_fontbitmap_s *fbm;
+ fbm = nxf_getbitmap(m_fontHandle, letter);
+ if (fbm)
+ {
+ // Get information about the font bitmap
+
+ uint8_t fwidth = fbm->metric.width + fbm->metric.xoffset;
+ uint8_t fheight = fbm->metric.height + fbm->metric.yoffset;
+ uint8_t fstride = (fwidth * bitmap->bpp + 7) >> 3;
+
+ // Then render the glyph into the bitmap memory
+
+ (void)FONT_RENDERER((FAR nxgl_mxpixel_t*)bitmap->data, fheight,
+ fwidth, fstride, fbm, m_fontColor);
+ }
+}
+
+/**
+ * Get the width of a string in pixels when drawn with this font.
+ *
+ * @param text The string to check.
+ * @return The width of the string in pixels.
+ */
+
+nxgl_coord_t CNxFont::getStringWidth(const CNxString &text) const
+{
+ CStringIterator *iter = text.newStringIterator();
+
+ // Get the width of the string of characters
+ // Move to the first character
+
+ unsigned int width = 0;
+ if (iter->moveToFirst())
+ {
+ // moveToFirst returns true if there is at least one character
+
+ do
+ {
+ // Add the width of the font bitmap for this character and
+ // move the the next character
+
+ nxwidget_char_t ch = iter->getChar();
+
+ width += getCharWidth(ch);
+ }
+ while (iter->moveToNext());
+ }
+
+ // Return the total width
+
+ delete iter;
+ return width;
+}
+
+/**
+ * Get the width of a portion of a string in pixels when drawn with this
+ * font.
+ *
+ * @param text The string to check.
+ * @param startIndex The start point of the substring within the string.
+ * @param length The length of the substring in chars.
+ * @return The width of the substring in pixels.
+ */
+
+nxgl_coord_t CNxFont::getStringWidth(const CNxString &text,
+ int startIndex, int length) const
+{
+ CStringIterator *iter = text.newStringIterator();
+
+ // Get the width of the string of characters
+
+ iter->moveTo(startIndex);
+ unsigned int width = 0;
+
+ while (length-- > 0)
+ {
+ // Add the width of the font bitmap for this character
+
+ nxwidget_char_t ch = iter->getChar();
+ width += getCharWidth(ch);
+
+ // Position to the next character in the string
+
+ if (!iter->moveToNext())
+ {
+ break;
+ }
+ }
+
+ // Return the total width
+
+ delete iter;
+ return width;
+}
+
+/**
+ * Gets font metrics for a particular character
+ *
+ * @param letter The character to get the width of.
+ * @param metrics The location to return the font metrics
+ */
+
+void CNxFont::getCharMetrics(nxwidget_char_t letter,
+ FAR struct nx_fontmetric_s *metrics) const
+{
+ FAR const struct nx_fontbitmap_s *fbm;
+
+ // Get the font bitmap for this character
+
+ fbm = nxf_getbitmap(m_fontHandle, letter);
+ if (fbm)
+ {
+ // Return the metrics of the font
+
+ memcpy(metrics, &fbm->metric, sizeof(struct nx_fontmetric_s));
+ }
+ else
+ {
+ // Use the metrics of a space which has no width and no height
+ // but an xoffset equal to the standard width of a space.
+
+ metrics->stride = (m_pFontSet->spwidth * CONFIG_NXWIDGETS_BPP + 7) >> 3;
+ metrics->width = 0;
+ metrics->height = 0;
+ metrics->xoffset = m_pFontSet->spwidth;
+ metrics->yoffset = 0;
+ }
+}
+
+/**
+ * Get the width of an individual character.
+ *
+ * @param letter The character to get the width of.
+ * @return The width of the character in pixels.
+ */
+
+nxgl_coord_t CNxFont::getCharWidth(nxwidget_char_t letter) const
+{
+ FAR const struct nx_fontbitmap_s *fbm;
+ nxgl_coord_t width;
+
+ /* Get the font bitmap for this character */
+
+ fbm = nxf_getbitmap(m_fontHandle, letter);
+ if (fbm)
+ {
+ /* Return the width of the font -- including the X offset */
+
+ width = fbm->metric.width + fbm->metric.xoffset;
+ }
+ else
+ {
+ /* Use the width of a space */
+
+ width = m_pFontSet->spwidth;
+ }
+
+ return width;
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxserver.cxx b/NxWidgets/libnxwidgets/src/cnxserver.cxx
new file mode 100644
index 000000000..be67e5641
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxserver.cxx
@@ -0,0 +1,461 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxserver.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <cstdlib>
+#include <cerrno>
+#include <debug.h>
+
+#ifdef CONFIG_NX_MULTIUSER
+# include <sched.h>
+# include <pthread.h>
+#endif
+
+#include "nxconfig.hxx"
+#include "singletons.hxx"
+#include "cnxserver.hxx"
+
+/****************************************************************************
+ * Static Data Members
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+uint8_t CNxServer::m_nServers; /**< The number of NX server instances */
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+/**
+ * CNXServer constructor
+ */
+
+CNxServer::CNxServer(void)
+{
+ // Initialize server instance state data
+
+ m_hDevice = (FAR NX_DRIVERTYPE *)NULL; // LCD/Framebuffer device handle
+ m_hNxServer = (NXHANDLE)NULL; // NX server handle
+#ifdef CONFIG_NX_MULTIUSER
+ m_connected = false; // True: Connected to the server
+ sem_init(&m_connsem, 0, 0); // Wait for server connection
+#endif
+
+ // Increment the global count of NX servers. Normally there is only one
+ // but we don't want to preclude the case where there might be multiple
+ // displays, each with its own NX server instance
+
+ m_nServers++;
+
+ // Create miscellaneous singleton instances. Why is this done here?
+ // Because this needs to be done once before any widgets are created and we
+ // don't want to rely on static constructors.
+
+ instantiateSingletons();
+}
+
+/**
+ * CNXServer destructor
+ */
+
+CNxServer::~CNxServer(void)
+{
+ // Disconnect from the server
+
+ disconnect();
+
+ // Decrement the count of NX servers. When that count goes to zero,
+ // delete all of the fake static instances
+
+ if (--m_nServers == 0)
+ {
+ freeSingletons();
+ }
+}
+
+/**
+ * Connect to the NX Server -- Single user version
+ */
+
+#ifndef CONFIG_NX_MULTIUSER
+bool CNxServer::connect(void)
+{
+#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
+ // Use external graphics driver initialization
+
+ m_hDevice = up_nxdrvinit(CONFIG_NXWIDGETS_DEVNO);
+ if (!m_hDevice)
+ {
+ gdbg("up_nxdrvinit failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
+ return false;
+ }
+
+#elif defined(CONFIG_NX_LCDDRIVER)
+ int ret;
+
+ // Initialize the LCD device
+
+ ret = up_lcdinitialize();
+ if (ret < 0)
+ {
+ gdbg("up_lcdinitialize failed: %d\n", -ret);
+ return false;
+ }
+
+ // Get the device instance
+
+ m_hDevice = up_lcdgetdev(CONFIG_NXWIDGETS_DEVNO);
+ if (!m_hDevice)
+ {
+ gdbg("up_lcdgetdev failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
+ return false;
+ }
+
+ // Turn the LCD on at 75% power
+
+ (void)m_hDevice->setpower(m_hDevice, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
+#else
+ int ret;
+
+ // Initialize the frame buffer device
+
+ ret = up_fbinitialize();
+ if (ret < 0)
+ {
+ gdbg("up_fbinitialize failed: %d\n", -ret);
+ return false;
+ }
+
+ m_hDevice = up_fbgetvplane(CONFIG_NXWIDGETS_VPLANE);
+ if (!m_hDevice)
+ {
+ gdbg("CNxServer::connect: up_fbgetvplane failed, vplane=%d\n",
+ CONFIG_NXWIDGETS_VPLANE);
+ return false;
+ }
+#endif
+
+ // Then open NX
+
+ m_hNxServer = nx_open(m_hDevice);
+ if (!m_hNxServer)
+ {
+ gdbg("CNxServer::connect: nx_open failed: %d\n", errno);
+ return false;
+ }
+
+ return true;
+}
+#endif
+
+/**
+ * Connect to the NX Server -- Multi user version
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+bool CNxServer::connect(void)
+{
+ struct sched_param param;
+ pthread_t thread;
+ pid_t serverId;
+ int ret;
+
+ // Set the client task priority
+
+ param.sched_priority = CONFIG_NXWIDGETS_CLIENTPRIO;
+ ret = sched_setparam(0, &param);
+ if (ret < 0)
+ {
+ gdbg("CNxServer::connect: sched_setparam failed: %d\n" , ret);
+ return false;
+ }
+
+ // Start the server task
+
+ gvdbg("NxServer::connect: Starting server task\n");
+ serverId = TASK_CREATE("NX Server", CONFIG_NXWIDGETS_SERVERPRIO,
+ CONFIG_NXWIDGETS_SERVERSTACK, server, (FAR const char **)0);
+ if (serverId < 0)
+ {
+ gdbg("NxServer::connect: Failed to create nx_servertask task: %d\n", errno);
+ return false;
+ }
+
+ // Wait a bit to let the server get started
+
+ sleep(1);
+
+ // Connect to the server
+
+ m_hNxServer = nx_connect();
+ if (m_hNxServer)
+ {
+ pthread_attr_t attr;
+
+ // Start a separate thread to listen for server events. This is probably
+ // the least efficient way to do this, but it makes this logic flow more
+ // smoothly.
+
+ (void)pthread_attr_init(&attr);
+ param.sched_priority = CONFIG_NXWIDGETS_LISTENERPRIO;
+ (void)pthread_attr_setschedparam(&attr, &param);
+ (void)pthread_attr_setstacksize(&attr, CONFIG_NXWIDGETS_LISTENERSTACK);
+
+ m_stop = false;
+ m_running = true;
+
+ ret = pthread_create(&thread, &attr, listener, (FAR void *)this);
+ if (ret != 0)
+ {
+ gdbg("NxServer::connect: pthread_create failed: %d\n", ret);
+ m_running = false;
+ disconnect();
+ return false;
+ }
+
+ // Detach from the thread
+
+ (void)pthread_detach(thread);
+
+ // Don't return until we are connected to the server
+
+ while (!m_connected && m_running)
+ {
+ // Wait for the listener thread to wake us up when we really
+ // are connected.
+
+ (void)sem_wait(&m_connsem);
+ }
+
+ // In the successful case, the listener is still running (m_running)
+ // and the server is connected (m_connected). Anything else is a failure.
+
+ if (!m_connected || !m_running)
+ {
+ disconnect();
+ return false;
+ }
+ }
+ else
+ {
+ gdbg("NxServer::connect: nx_connect failed: %d\n", errno);
+ return false;
+ }
+
+ return true;
+}
+#endif
+
+/**
+ * Disconnect to the NX Server -- Single user version
+ */
+
+#ifndef CONFIG_NX_MULTIUSER
+void CNxServer::disconnect(void)
+{
+ // Close the server
+
+ if (m_hNxServer)
+ {
+ nx_close(m_hNxServer);
+ m_hNxServer = NULL;
+ }
+}
+#endif
+
+/**
+ * Disconnect to the NX Server -- Single user version
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CNxServer::disconnect(void)
+{
+ // Is the listener running?
+ // Hmm.. won't this hang is the listener is in a blocking call?
+
+ while (m_running)
+ {
+ // Yes.. stop the listener thread
+
+ m_stop = true;
+ while (m_running)
+ {
+ // Wait for the listener thread to stop
+
+ (void)sem_wait(&m_connsem);
+ }
+ }
+
+ // Disconnect from the server
+
+ if (m_hNxServer)
+ {
+ nx_disconnect(m_hNxServer);
+ m_hNxServer = NULL;
+ }
+}
+#endif
+
+/**
+ * NX server thread. This is the entry point into the server thread that
+ * serializes the multi-threaded accesses to the display.
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+int CNxServer::server(int argc, char *argv[])
+{
+ FAR NX_DRIVERTYPE *dev;
+ int ret;
+
+#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
+ // Use external graphics driver initialization
+
+ dev = up_nxdrvinit(CONFIG_NXWIDGETS_DEVNO);
+ if (!dev)
+ {
+ gdbg("up_nxdrvinit failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
+ return EXIT_FAILURE;
+ }
+
+#elif defined(CONFIG_NX_LCDDRIVER)
+ // Initialize the LCD device
+
+ ret = up_lcdinitialize();
+ if (ret < 0)
+ {
+ gdbg("up_lcdinitialize failed: %d\n", -ret);
+ return EXIT_FAILURE;
+ }
+
+ // Get the device instance
+
+ dev = up_lcdgetdev(CONFIG_NXWIDGETS_DEVNO);
+ if (!dev)
+ {
+ gdbg("up_lcdgetdev failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
+ return EXIT_FAILURE;
+ }
+
+ // Turn the LCD on at 75% power
+
+ (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
+#else
+ // Initialize the frame buffer device
+
+ ret = up_fbinitialize();
+ if (ret < 0)
+ {
+ gdbg("nxcon_server: up_fbinitialize failed: %d\n", -ret);
+ return EXIT_FAILURE;
+ }
+
+ dev = up_fbgetvplane(CONFIG_NXWIDGETS_VPLANE);
+ if (!dev)
+ {
+ gdbg("up_fbgetvplane failed, vplane=%d\n", CONFIG_NXWIDGETS_VPLANE);
+ return 2;
+ }
+#endif
+
+ // Then start the server
+
+ ret = nx_run(dev);
+ gvdbg("nx_run returned: %d\n", errno);
+ return EXIT_FAILURE;
+}
+#endif
+
+/**
+ * This is the entry point of a thread that listeners for and dispatches
+ * events from the NX server.
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+FAR void *CNxServer::listener(FAR void *arg)
+{
+ // The argument must be the CNxServer instance
+
+ CNxServer *This = (CNxServer*)arg;
+
+ // Process events forever
+
+ while (!This->m_stop)
+ {
+ // Handle the next event. If we were configured blocking, then
+ // we will stay right here until the next event is received. Since
+ // we have dedicated a while thread to servicing events, it would
+ // be most natural to also select CONFIG_NX_BLOCKING -- if not, the
+ // following would be a tight infinite loop (unless we added addition
+ // logic with nx_eventnotify and sigwait to pace it).
+
+ int ret = nx_eventhandler(This->m_hNxServer);
+ if (ret < 0)
+ {
+ // An error occurred... assume that we have lost connection with
+ // the server.
+
+ gdbg("Lost server connection: %d\n", errno);
+ break;
+ }
+
+ // If we received a message, we must be connected
+
+ if (!This->m_connected)
+ {
+ This->m_connected = true;
+ sem_post(&This->m_connsem);
+ gvdbg("Connected\n");
+ }
+ }
+
+ // We fall out of the loop when either (1) the server has died or
+ // we have been requested to stop
+
+ This->m_running = false;
+ This->m_connected = false;
+ sem_post(&This->m_connsem);
+ return NULL;
+}
+#endif
diff --git a/NxWidgets/libnxwidgets/src/cnxstring.cxx b/NxWidgets/libnxwidgets/src/cnxstring.cxx
new file mode 100644
index 000000000..3ad3855b9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxstring.cxx
@@ -0,0 +1,799 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxstring.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include "cnxstring.hxx"
+#include "cstringiterator.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CNxString Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor to create an empty string object.
+ */
+
+CNxString::CNxString()
+{
+ m_text = (FAR nxwidget_char_t *)NULL;
+ m_stringLength = 0;
+ m_allocatedSize = 0;
+ m_growAmount = 16;
+}
+
+/**
+ * Constructor to create a string from a C character array.
+ *
+ * @param text Pointer to a char array to use as the basis of the
+ * string.
+ */
+
+CNxString::CNxString(FAR const char *text)
+{
+ m_text = (FAR nxwidget_char_t *)NULL;
+ m_stringLength = 0;
+ m_allocatedSize = 0;
+ m_growAmount = 16;
+
+ setText(text);
+}
+
+/**
+ * Constructor to create a string from a single character.
+ * @param letter Single character to use as the basis of the string.
+ */
+
+CNxString::CNxString(const nxwidget_char_t text)
+{
+ m_text = (FAR nxwidget_char_t *)NULL;
+ m_stringLength = 0;
+ m_allocatedSize = 0;
+ m_growAmount = 16;
+
+ setText(text);
+}
+
+CNxString::CNxString(const CNxString &string)
+{
+ m_text = (FAR nxwidget_char_t *)NULL;
+ m_stringLength = 0;
+ m_allocatedSize = 0;
+ m_growAmount = 16;
+
+ setText(string);
+}
+
+/**
+ * Creates and returns a new CCStringIterator object that will iterate
+ * over this string. The object must be manually deleted once it is
+ * no longer needed.
+ *
+ * @return A new CCStringIterator object.
+ */
+
+CStringIterator *CNxString::newStringIterator() const
+{
+ return new CStringIterator(this);
+}
+
+/**
+ * Copy the internal array to the supplied buffer. The buffer must be
+ * large enough to contain the full text in the string. The
+ * getByteCount() method can be used to obtain the length of the string.
+ * Unlike the CNxString class, the char array is null-terminated.
+ * The buffer must be (getByteCount() + 2) bytes long, in order to
+ * accommodate the terminator.
+ *
+ * @param buffer Buffer to copy the internal char array to.
+ */
+
+void CNxString::copyToCharArray(FAR nxwidget_char_t *buffer) const
+{
+ unsigned int dataLength = sizeof(nxwidget_char_t) * m_stringLength;
+ memcpy(buffer, m_text, dataLength);
+ buffer[dataLength] = '\0';
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text CNxString containing the new data for this string.
+ */
+
+void CNxString::setText(const CNxString &text)
+{
+ // Ensure we've got enough memory available
+
+ allocateMemory(text.getLength(), false);
+
+ // Copy the text into the internal array
+
+ memcpy(m_text, text.getCharArray(), sizeof(nxwidget_char_t) * text.getLength());
+
+ // Save size (in characters) of the string
+
+ m_stringLength = text.getLength();
+}
+
+/**
+ * Set the 8-bit C-string text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+void CNxString::setText(FAR const char *text)
+{
+ int length = strlen(text);
+
+ // Ensure we've got enough memory available
+
+ allocateMemory(length, false);
+
+ // Copy characters into m_text, converting from 8- to 16-bit characters
+ // (if necessary) and cache the length
+
+ for (int i = 0; i < length; i++)
+ {
+ m_text[i] = (nxwidget_char_t)text[i];
+ }
+
+ m_stringLength = length;
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+void CNxString::setText(FAR const nxwidget_char_t *text, int nchars)
+{
+ // Ensure we've got enough memory available
+
+ allocateMemory(nchars, false);
+
+ // Copy characters into m_text and cache the length
+
+ m_stringLength = nchars;
+ memcpy(m_text, text, sizeof(nxwidget_char_t) * nchars);
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text Character to to use as the new data for this string.
+ */
+
+void CNxString::setText(const nxwidget_char_t letter)
+{
+ // Ensure we've got enough memory available
+
+ allocateMemory(1, false);
+
+ // Copy the valid character into m_text and cache the length
+
+ *m_text = letter;
+ m_stringLength = 1;
+}
+
+/**
+ * Append text to the end of the string.
+ *
+ * @param text String to append.
+ */
+
+void CNxString::append(const CNxString &text)
+{
+ // Ensure we've got enough memory available
+
+ allocateMemory(m_stringLength + text.getLength(), true);
+
+ // Append the new string to the end of the array
+
+ FAR nxwidget_char_t *dest = &m_text[m_stringLength];
+ FAR const nxwidget_char_t *src = text.getCharArray();
+ for (int i = 0; i < text.getLength(); i++)
+ {
+ *dest++ = *src++;
+ }
+
+ // Update the size in characters and the size in bytes
+
+ m_stringLength += text.getLength();
+}
+
+/**
+ * Insert text at the specified character index.
+ *
+ * @param text The text to insert.
+ * @param index The index at which to insert the text.
+ */
+
+void CNxString::insert(const CNxString &text, int index)
+{
+ // Early exit if the string is empty
+
+ if (!hasData())
+ {
+ CNxString::setText(text);
+ return;
+ }
+
+ // Early exit if we're just appending
+
+ if (index >= m_stringLength)
+ {
+ CNxString::append(text);
+ return;
+ }
+
+ // Get the total size of the string that we need
+
+ int newLength = m_stringLength + text.getLength();
+ int newSize = newLength * sizeof(nxwidget_char_t);
+
+ // Reallocate memory if the existing memory isn't large enough
+
+ if (m_allocatedSize < newSize)
+ {
+ int allocLength = newLength + m_growAmount;
+
+ // Allocate new string large enough to contain additional data
+
+ FAR nxwidget_char_t *newText = new nxwidget_char_t[allocLength];
+
+ // Copy the start of the existing text to the newly allocated string
+
+ FAR nxwidget_char_t *dest = newText;
+ FAR const nxwidget_char_t *src = m_text;
+ for (int i = 0; i < index; i++)
+ {
+ *dest++ = *src++;
+ }
+
+ // Insert the additional text into the new string
+
+ src = text.getCharArray();
+ for (int i = 0; i < text.getLength(); i++)
+ {
+ *dest++ = *src++;
+ }
+
+ // Copy the end of the existing text the the newly allocated string
+
+ src = &m_text[index];
+ for (int i = index; i < m_stringLength; i++)
+ {
+ *dest++ = *src++;
+ }
+
+ m_allocatedSize = allocLength * sizeof(nxwidget_char_t);
+
+ // Delete existing string
+
+ delete[] m_text;
+
+ // Swap pointers
+
+ m_stringLength = newLength;
+ m_text = newText;
+ }
+ else
+ {
+ // Existing size is large enough, so make space in string for insert
+
+ FAR nxwidget_char_t *dest = &m_text[newLength - 1];
+ FAR const nxwidget_char_t *src = &m_text[m_stringLength - 1];
+ for (int i = 0; i < m_stringLength - index; i++)
+ {
+ *dest-- = *src--;
+ }
+
+ // Insert the additional text into the new string
+
+ dest = &m_text[index];
+ src = text.getCharArray();
+ for (int i = 0; i < text.getLength(); i++)
+ {
+ *dest++ = *src++;
+ }
+
+ m_stringLength = newLength;
+ }
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+void CNxString::remove(const int startIndex)
+{
+ // Reject if requested operation makes no sense
+
+ if (!hasData() || startIndex >= m_stringLength)
+ {
+ return;
+ }
+
+ // Removing characters from the end of the string is trivial - simply
+ // decrease the length
+
+ m_stringLength = startIndex;
+}
+
+/**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+void CNxString::remove(const int startIndex, const int count)
+{
+ // Reject if requested operation makes no sense
+
+ if (!hasData() || startIndex >= m_stringLength)
+ {
+ return;
+ }
+
+ // Don't remove in this way if the count includes the end of the string
+
+ int endIndex = startIndex + count;
+ if (endIndex > m_stringLength)
+ {
+ remove(startIndex);
+ return;
+ }
+
+ // Copy characters from a point after the area to be deleted into the space created
+ // by the deletion
+
+ FAR nxwidget_char_t *dest = &m_text[startIndex];
+ FAR const nxwidget_char_t *src = &m_text[endIndex];
+ for (int i = m_stringLength - endIndex; i > 0; i--)
+ {
+ *dest++ = *src++;
+ }
+
+ // Decrease length
+
+ m_stringLength -= count;
+
+}
+
+/**
+ * Get the character at the specified index. This function is useful
+ * for finding the occasional character at an index, but for iterating
+ * over strings it is exceptionally slow. The newStringIterator()
+ * method should be used to retrieve an iterator object that can iterate
+ * over the string efficiently.
+ *
+ * @param index The index of the character to retrieve.
+ * @return The character at the specified index.
+ */
+
+const nxwidget_char_t CNxString::getCharAt(int index) const
+{
+ return *getCharPointer(index);
+}
+
+/**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found.
+ *
+ * @param letter Letter to find.
+ * @return The index of the letter.
+ */
+
+const int CNxString::indexOf(nxwidget_char_t letter) const
+{
+ return indexOf(letter, 0, getLength());
+}
+
+/**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * from "startIndex" until it has examined all subsequent letters.
+ *
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @return The index of the letter.
+ */
+
+const int CNxString::indexOf(nxwidget_char_t letter, int startIndex) const
+{
+ return indexOf(letter, startIndex, getLength() - startIndex);
+}
+
+/**
+ * Returns the first index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * from "startIndex" until it has examined all letters within the
+ * range "count".
+ *
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @param count The number of characters to examine.
+ * @return The index of the letter.
+ */
+
+const int CNxString::indexOf(nxwidget_char_t letter, int startIndex, int count) const
+{
+ // Exit if no data available
+
+ if (!hasData())
+ {
+ return -1;
+ }
+
+ int index = -1;
+ int charsExamined = 0;
+
+ CStringIterator *iterator = new CStringIterator(this);
+ if (!iterator->moveTo(startIndex))
+ {
+ delete iterator;
+ return -1;
+ }
+
+ do
+ {
+ if (iterator->getChar() == letter)
+ {
+ index = iterator->getIndex();
+ break;
+ }
+
+ charsExamined++;
+ }
+ while (iterator->moveToNext() && (charsExamined < count));
+
+ delete iterator;
+ return index;
+}
+
+/**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found.
+ *
+ * @param letter Letter to find.
+ * @return The index of the letter.
+ */
+
+const int CNxString::lastIndexOf(nxwidget_char_t letter) const
+{
+ return lastIndexOf(letter, getLength() - 1, getLength());
+}
+
+/**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * backwards from "startIndex" until it has examined all preceding
+ * letters within the string.
+ *
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @return The index of the letter.
+ */
+
+const int CNxString::lastIndexOf(nxwidget_char_t letter, int startIndex) const
+{
+ return lastIndexOf(letter, startIndex, getLength() - (getLength() - startIndex));
+}
+
+/**
+ * Returns the last index of the specified letter within the string.
+ * Will return -1 if the letter is not found. Scans through the string
+ * backwards from "startIndex" until it has examined all letters within
+ * the range "count".
+ * @param letter Letter to find.
+ * @param startIndex The index to start searching from.
+ * @param count The number of characters to examine.
+ * @return The index of the letter.
+ */
+
+const int CNxString::lastIndexOf(nxwidget_char_t letter, int startIndex, int count) const
+{
+ // Exit if no data available
+
+ if (!hasData())
+ {
+ return -1;
+ }
+
+ int index = -1;
+ int charsExamined = 0;
+
+ CStringIterator *iterator = new CStringIterator(this);
+ if (!iterator->moveTo(startIndex))
+ {
+ delete iterator;
+ return -1;
+ }
+
+ do
+ {
+ if (iterator->getChar() == letter)
+ {
+ index = iterator->getIndex();
+ break;
+ }
+
+ charsExamined++;
+ }
+ while (iterator->moveToPrevious() && (charsExamined <= count));
+
+ delete iterator;
+ return index;
+}
+
+/**
+ * Get a substring from this string. It is the responsibility of the
+ * caller to delete the substring when it is no longer required.
+ *
+ * @param startIndex The starting point of the substring.
+ * @return A pointer to a new CNxString object containing the
+ * substring.
+ */
+
+CNxString* CNxString::subString(int startIndex) const
+{
+ return subString(startIndex, getLength() - startIndex);
+}
+
+/**
+ * Get a substring from this string. It is the responsibility of the
+ * caller to delete the substring when it is no longer required.
+ *
+ * @param startIndex The starting point of the substring.
+ * @param length The length of the substring.
+ * @return A pointer to a new CNxString object containing the
+ * substring.
+*/
+
+CNxString *CNxString::subString(int startIndex, int length) const
+{
+ CNxString *newString = new CNxString();
+ CStringIterator *iterator = new CStringIterator(this);
+
+ if (!iterator->moveTo(startIndex))
+ {
+ delete iterator;
+ return (CNxString *)0;
+ }
+
+ // Build up the string character by character. We could do a memcpy
+ // here and improve performance.
+
+ int count = 0;
+ while (count < length)
+ {
+ newString->append(iterator->getChar());
+ iterator->moveToNext();
+ count++;
+ }
+
+ delete iterator;
+ return newString;
+}
+
+/**
+ * Overloaded assignment operator. Copies the data within the argument
+ * string to this string.
+ *
+ * @param string The string to copy.
+ * @return This string.
+ */
+
+CNxString& CNxString::operator=(const CNxString &string)
+{
+ if (&string != this)
+ {
+ setText(string);
+ }
+ return *this;
+}
+
+/**
+ * Overloaded assignment operator. Copies the data within the argument
+ * char array to this string.
+ *
+ * @param string The string to copy.
+ * @return This string.
+ */
+
+CNxString& CNxString::operator=(const char *string)
+{
+ setText(string);
+ return *this;
+}
+
+/**
+ * Overloaded assignment operator. Copies the data from the argument
+ * char to this string.
+ *
+ * @param letter The char to copy.
+ * @return This string.
+ */
+
+CNxString& CNxString::operator=(const nxwidget_char_t letter)
+{
+ setText(letter);
+ return *this;
+}
+
+/**
+ * Compares this string to the argument.
+ *
+ * @param string String to compare to.
+ * @return Zero if both strings are equal. A value greater than zero
+ * indicates that this string is greater than the argument string. A
+ * value less than zero indicates the opposite. Note that the return
+ * value indicates the *byte* that does not match, not the *character*.
+ */
+
+int CNxString::compareTo(const CNxString &string) const
+{
+ return memcmp((FAR const char*)m_text,
+ (FAR const char*)string.getCharArray(),
+ getLength());
+}
+
+/**
+ * Allocate memory for the string.
+ *
+ * @param chars Number nxwidget_char_t size characters to allocate.
+ * @param preserve If true, the data in the existing memory will be
+ * preserved if new memory must be allocated
+ */
+
+void CNxString::allocateMemory(int nChars, bool preserve)
+{
+ // This is the size of the allocation that we need
+
+ int nBytesNeeded = nChars * sizeof(nxwidget_char_t);
+
+ // Do we already have enough memory allocated to contain this new size?
+ // If so, we can avoid deallocating and allocating new memory by re-using the old
+
+ if (nBytesNeeded > m_allocatedSize)
+ {
+ // Not enough space in existing memory; allocate new memory
+
+ int allocChars = nChars + m_growAmount;
+ nxwidget_char_t *newText = new nxwidget_char_t[allocChars];
+
+ // Free old memory if necessary
+
+ if (m_text != NULL)
+ {
+ // Preserve existing data if required
+
+ if (preserve)
+ {
+ memcpy(newText, m_text, sizeof(nxwidget_char_t) * m_stringLength);
+ }
+
+ delete[] m_text;
+ }
+
+ // Set pointer to new memory
+
+ m_text = newText;
+
+ // Remember how much memory we've allocated.
+
+ m_allocatedSize = allocChars * sizeof(nxwidget_char_t);
+ }
+}
+
+/**
+ * Return a pointer to the specified characters.
+ *
+ * @param index Index of the character to retrieve.
+ */
+
+FAR nxwidget_char_t *CNxString::getCharPointer(const int index) const
+{
+ // Early exit if the string is empty
+
+ if (!hasData())
+ {
+ return (FAR nxwidget_char_t*)NULL;
+ }
+
+ // Early exit if the index is greater than the length of the string
+
+ if (index >= m_stringLength)
+ {
+ return (FAR nxwidget_char_t*)NULL;
+ }
+
+ return &m_text[index];
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxtimer.cxx b/NxWidgets/libnxwidgets/src/cnxtimer.cxx
new file mode 100644
index 000000000..e351d2357
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxtimer.cxx
@@ -0,0 +1,382 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxtimer.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+#include <ctime>
+#include <csignal>
+#include <debug.h>
+
+#include "cnxtimer.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Static Data Members
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param timeout Time, in milliseconds, before the timer fires an
+ * EVENT_ACTION event.
+ * @param repeat If true, the timer will fire multiple events. If false,
+ * the timer will fire just once and stop.
+ */
+
+CNxTimer::CNxTimer(CWidgetControl *pWidgetControl, uint32_t timeout, bool repeat)
+: CNxWidget(pWidgetControl, 0, 0, 0, 0, 0, 0)
+{
+ // Remember the timer configuration
+
+ m_timeout = timeout;
+ m_isRepeater = repeat;
+ m_isRunning = false;
+
+ // Create a POSIX timer (We can't do anything about failures here)
+
+ int ret = timer_create(CLOCK_REALTIME, (FAR struct sigevent *)NULL, &m_timerid);
+ if (ret < 0)
+ {
+ gdbg("timer_create() failed\n");
+ return;
+ }
+
+ // If we are the first timer created in the whole system, then create
+ // the timer list and attach the SIGALRM timer handler.
+
+ if (!g_nxTimers)
+ {
+ if (!g_nxTimers)
+ {
+ gdbg("Failed to create the timer list\n");
+ return;
+ }
+
+ // Attach the SIGALM signal handler (no harm if this is done multiple times)
+
+ struct sigaction sigact;
+ sigact.sa_handler = signalHandler;
+ sigact.sa_flags = 0;
+ sigemptyset(&sigact.sa_mask);
+
+ ret = sigaction(SIGALRM, &sigact, (FAR struct sigaction *)NULL);
+ if (ret < 0)
+ {
+ gdbg("sigaction() failed\n");
+ return;
+ }
+ }
+
+ // Add ourself onto the array of timers
+#warning "Need to disable SIGALRM here"
+ g_nxTimers->push_back(this);
+}
+
+/**
+ * Destructor.
+ */
+
+CNxTimer::~CNxTimer(void)
+{
+ // Locate ourself in the list of timers and remove ourselves
+
+#warning "Need to disable SIGALRM here"
+ for (int i = 0; i < g_nxTimers->size(); i++)
+ {
+ CNxTimer *timer = g_nxTimers->at(i);
+ if (timer == this)
+ {
+ g_nxTimers->erase(i);
+ break;
+ }
+ }
+
+ // Destroy the timer
+
+ (void)timer_delete(m_timerid);
+}
+
+/**
+ * Return the timeout of this timer.
+ *
+ * @return The number of milliseconds that this timer will run before firing
+ * an event.
+ */
+
+const uint32_t CNxTimer::getTimeout(void)
+{
+ // If the timer is not running, then just return the timeout value
+
+ if (!m_isRunning)
+ {
+ return m_timeout;
+ }
+ else
+ {
+ // Get the time remaining on the POSIX timer. Of course, there
+ // are race conditions here.. the timer could expire at anytime
+
+ struct itimerspec remaining;
+ int ret = timer_gettime(m_timerid, &remaining);
+ if (ret < 0)
+ {
+ gdbg("timer_gettime() failed\n");
+ return 0;
+ }
+
+ return timespecToMilliseconds(&remaining.it_value);
+ }
+}
+
+/**
+ * Resets the millisecond timer.
+ */
+
+void CNxTimer::reset(void)
+{
+ // It does not make sense to reset the timer if the timer is not running
+
+ if (m_isRunning)
+ {
+ // If the specified timer was already armed when timer_settime() is
+ // called, this call will reset the time until next expiration to the
+ // value specified.
+
+ m_isRunning = false;
+ start();
+ }
+}
+
+/**
+ * Starts the timer.
+ */
+
+void CNxTimer::start(void)
+{
+ // If the timer is running, reset should be used to restart it
+
+ if (!m_isRunning)
+ {
+ // If the specified timer was already armed when timer_settime() is
+ // called, this call will reset the time until next expiration to the
+ // value specified.
+
+ struct itimerspec timerspec;
+ millisecondsToTimespec(m_timeout, &timerspec.it_value);
+ timerspec.it_interval.tv_sec = 0;
+ timerspec.it_interval.tv_nsec = 0;
+
+ int ret = timer_settime(m_timerid, 0, &timerspec,
+ (FAR struct itimerspec *)NULL);
+ if (ret < 0)
+ {
+ gdbg("timer_settime() failed\n");
+ }
+
+ // The timer is now running
+
+ m_isRunning = true;
+ }
+}
+
+/**
+ * Stops the timer
+ */
+
+void CNxTimer::stop(void)
+{
+ if (m_isRunning)
+ {
+ // If the it_value member of value is zero, the timer will be disarmed.
+ // The effect of disarming or resetting a timer with pending expiration
+ // notifications is unspecified.
+
+ struct itimerspec nullTime;
+ memset(&nullTime, 0, sizeof(struct itimerspec));
+
+ int ret = timer_settime(m_timerid, 0, &nullTime,
+ (FAR struct itimerspec *)NULL);
+ if (ret < 0)
+ {
+ gdbg("timer_settime failed\n");
+ }
+
+ // The time is no longer running
+
+ m_isRunning = false;
+ }
+}
+
+/**
+ * The SIGALM signal handler that will be called when the timer goes off
+ *
+ * @param signo The signal number call caused the handler to run (SIGALM)
+ */
+
+void CNxTimer::signalHandler(int signo)
+{
+ // Call handlerTimerExpiration on every timer instance
+
+ for (int i = 0; i < g_nxTimers->size(); i++)
+ {
+ CNxTimer *timer = g_nxTimers->at(i);
+ timer->handleTimerExpiration();
+ }
+}
+
+/**
+ * Handle an expired timer
+ */
+
+void CNxTimer::handleTimerExpiration(void)
+{
+ // Do we think our timer is running?
+
+ if (m_isRunning)
+ {
+ // Is it running? It the timer is not running, it will return an
+ // it_value of zero.
+
+ struct itimerspec status;
+ int ret = timer_gettime(m_timerid, &status);
+ if (ret < 0)
+ {
+ gdbg("timer_gettime() failed\n");
+ return;
+ }
+
+ // it_value == 0 means that timer is not running
+
+ if (status.it_value.tv_sec == 0 && status.it_value.tv_nsec == 0)
+ {
+ // It has expired
+
+ m_isRunning = false;
+
+ // Raise the action event. Hmmm.. are there any issues with
+ // doing this from a signal handler? We'll find out
+
+ m_widgetEventHandlers->raiseActionEvent();
+
+ // Restart the timer if this is a repeating timer
+
+ if (m_isRepeater)
+ {
+ start();
+ }
+ }
+ }
+}
+
+/**
+ * Convert a timespec to milliseconds
+ *
+ * @param tp The pointer to the timespec to convert
+ * @return The corresponding time in milliseconds
+ */
+
+uint32_t CNxTimer::timespecToMilliseconds(FAR const struct timespec *tp)
+{
+ return (uint32_t)tp->tv_sec * 1000 + (uint32_t)tp->tv_nsec / 10000000;
+}
+
+/**
+ * Convert milliseconds to a timespec
+ *
+ * @param milliseconds The milliseconds to be converted
+ * @param tp The pointer to the location to store the converted timespec
+ */
+
+ void CNxTimer::millisecondsToTimespec(uint32_t milliseconds,
+ FAR struct timespec *tp)
+ {
+ tp->tv_sec = milliseconds / 1000;
+ uint32_t remainder = milliseconds - (uint32_t)tp->tv_sec * 1000;
+ tp->tv_nsec = remainder * 1000000;
+ }
+
+
diff --git a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
new file mode 100644
index 000000000..05241817c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
@@ -0,0 +1,509 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sched.h>
+#include <cassert>
+
+#include "cwidgetcontrol.hxx"
+#include "cnxtkwindow.hxx"
+#include "cnxtoolbar.hxx"
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param hNxServer Handle to the NX server.
+ * @param widgetControl Controlling widget for this window.
+ */
+
+CNxTkWindow::CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl)
+ : CCallback(widgetControl)
+{
+ // Save construction values
+
+ m_hNxServer = hNxServer;
+ m_widgetControl = widgetControl;
+
+ // Nullify uninitilized pointers and values
+
+ m_hNxTkWindow = (NXTKWINDOW )0;
+ m_toolbar = (CNxToolbar *)0;
+ m_toolbarHeight = 0;
+
+ // Create the CGraphicsPort instance for this window
+
+ m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this));
+}
+
+/**
+ * Destructor.
+ */
+
+CNxTkWindow::~CNxTkWindow(void)
+{
+ // It would be a disaster if toolbar instance persists beyond
+ // the window!
+
+ DEBUGASSERT(!m_toolbar);
+
+ // Release the window. We do not release the widget control
+ // instance. The lifetime of that instance is owned by he-who-
+ // constructed-us.
+
+ (void)nxtk_closewindow(m_hNxTkWindow);
+}
+
+/**
+ * Creates a new framed window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the framed window was successfully created.
+ */
+
+bool CNxTkWindow::open(void)
+{
+ // Get the C-callable callback vtable
+
+ FAR struct nx_callback_s *vtable = getCallbackVTable();
+
+ // Create the window
+
+ m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
+ return m_hNxTkWindow != NULL;
+}
+
+/**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+CWidgetControl *CNxTkWindow::getWidgetControl(void) const
+{
+ return m_widgetControl;
+}
+
+/**
+ * Open a toolbar on the framed window. This method both instantiates
+ * the toolbar object AND calls the INxWindow::open() method to
+ * create the toolbar. The toolbar is ready for use upon return.
+ *
+ * @param height. The height in rows of the tool bar
+ * @param widgetControl. The controlling widget for this window. If
+ * none is provided, then a new, vanilla CWidgetControl will be created
+ * for the tool bar.
+ * @param height Height of the toolbar
+ */
+
+CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height, CWidgetControl *widgetControl)
+{
+ if (m_hNxTkWindow && !m_toolbar)
+ {
+ // Create a new widget control if none was provided
+
+ CWidgetControl *allocControl = (CWidgetControl *)0;
+ if (!widgetControl)
+ {
+ // NOTE: This constructor would accept the toolbar "style" as a argument.
+ // However, we will explicitly set the style below to handle the case
+ // where the user has provided a custom widget control
+
+ allocControl = new CWidgetControl();
+ if (!allocControl)
+ {
+ return (CNxToolbar *)0;
+ }
+
+ // Use the allocated widget control
+
+ widgetControl = allocControl;
+ }
+
+ // Get current window style from the NXTK window's widget control
+
+ CWidgetStyle style;
+ m_widgetControl->getWidgetStyle(&style);
+
+ // Set the background color(s) to the color of the toolbar
+
+ style.colors.background = CONFIG_NXTK_BORDERCOLOR1;
+ style.colors.selectedBackground = CONFIG_NXTK_BORDERCOLOR1;
+
+ widgetControl->setWidgetStyle(&style);
+
+ // And create the toolbar
+
+ m_toolbar = new CNxToolbar(this, m_hNxTkWindow,
+ widgetControl, height);
+ if (!m_toolbar)
+ {
+ if (allocControl)
+ {
+ delete allocControl;
+ }
+ return (CNxToolbar *)0;
+ }
+
+ // Create the new toolbar. Toolbar creation is separate from
+ // object instantiation so that failures can be reported.
+
+ if (!m_toolbar->open())
+ {
+ // Failed to create the toolbar. Clean-up and return NULL
+
+ delete m_toolbar;
+ if (allocControl)
+ {
+ delete allocControl;
+ }
+ return (CNxToolbar *)0;
+ }
+
+ // Save the height of the toolbar. We will need this because it will change
+ // how we report the size of drawable part of the window.
+
+ m_toolbarHeight = height;
+
+ // Provide parent widget control information to new widget control instance.
+ // This information is reported by an NX callback for "normal" windows. But
+ // the toolbar widget control does not get NX callbacks and has to get the
+ // window size through the setWindowBounds method.
+
+ // Disable preemption so that we can be assured that all of the following
+ // values are synchronized.
+
+ sched_lock();
+
+ // Get the physical bounding box of the window in display coordinates
+
+ struct nxgl_rect_s windowBounds;
+ m_widgetControl->getWindowBoundingBox(&windowBounds);
+
+ // Get the position of the parent window in display coordinates
+
+ struct nxgl_point_s windowPos;
+ m_widgetControl->getWindowPosition(&windowPos);
+
+ // Get the bounding box of the toolbar in parent window coordinates
+
+ struct nxgl_rect_s toolbarBounds;
+ nxtk_toolbarbounds(m_hNxTkWindow, &toolbarBounds);
+
+ // Get the toolbar size
+
+ struct nxgl_size_s toolbarSize;
+ nxgl_rectsize(&toolbarSize, &toolbarBounds);
+
+ // Get the toolbar position in display coordinates by adding the window position
+
+ struct nxgl_point_s toolbarPos;
+ nxgl_vectoradd(&toolbarPos, &toolbarBounds.pt1, &windowPos);
+
+ // Perform the fake NX callback
+
+ widgetControl->geometryEvent(m_hNxTkWindow, &toolbarSize,
+ &toolbarPos, &windowBounds);
+ sched_unlock();
+ }
+
+ return m_toolbar;
+}
+
+/**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxTkWindow::requestPosition(void)
+{
+ // Request the window position
+
+ return nxtk_getposition(m_hNxTkWindow) == OK;
+}
+
+/**
+ * Get the position of the window in the physical display coordinates
+ * (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+bool CNxTkWindow::getPosition(FAR struct nxgl_point_s *pos)
+{
+ return m_widgetControl->getWindowPosition(pos);
+}
+
+/**
+ * Get the size of the window drawable region.
+ *
+ * @return The size.
+ */
+
+bool CNxTkWindow::getSize(FAR struct nxgl_size_s *size)
+{
+ // Get the size of the NXTK window (this will exclude the thickness of
+ // the frame and the height of the toolbar, if any).
+
+ return m_widgetControl->getWindowSize(size);
+}
+
+/**
+ * Set the position and size of the window.
+ *
+ * @param pos The new position of the window.
+ * @return True on success, false on any failure.
+ */
+
+bool CNxTkWindow::setPosition(FAR const struct nxgl_point_s *pos)
+{
+ // Set the window size and position
+
+ return nxtk_setposition(m_hNxTkWindow, pos) == OK;
+}
+
+/**
+ * Set the size of the selected window.
+ *
+ * @param size The new size of the window.
+ * @return True on success, false on any failure.
+ */
+
+bool CNxTkWindow::setSize(FAR const struct nxgl_size_s *size)
+{
+ // Set the window size
+
+ return nxtk_setsize(m_hNxTkWindow, size) == OK;
+}
+
+/**
+ * Bring the window to the top of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxTkWindow::raise(void)
+{
+ // Raise the window to the top of the display
+
+ return nxtk_raise(m_hNxTkWindow) == OK;
+}
+
+/**
+ * Lower the window to the bottom of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxTkWindow::lower(void)
+{
+ // Lower the window to the bottom of the display
+
+ return nxtk_lower(m_hNxTkWindow) == OK;
+}
+
+/**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::setPixel(FAR const struct nxgl_point_s *pos,
+ nxgl_mxpixel_t color)
+{
+#if 0
+ // Set an individual pixel to the specified color
+
+ return nxtk_setpixel(m_hNxTkWindow, pos, &color) == OK;
+#else
+ // REVISIT
+ return false;
+#endif
+}
+
+/**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color)
+{
+ // Fill a rectangular region with a solid color
+
+ return nxtk_fillwindow(m_hNxTkWindow, pRect, &color) == OK;
+}
+
+/**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+void CNxTkWindow::getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest)
+{
+ // Get a rectangule region from the window
+
+ (void)nxtk_getwindow(m_hNxTkWindow, rect, 0, (FAR uint8_t*)dest->data, dest->stride);
+}
+
+/**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color)
+{
+ // Fill a trapezoidal region with a solid color
+
+ return nxtk_filltrapwindow(m_hNxTkWindow, pTrap, &color) == OK;
+}
+
+/**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width, nxgl_mxpixel_t color)
+{
+ // Draw a line with the specified color
+
+ return nxtk_drawlinewindow(m_hNxTkWindow, vector, width, &color) == OK;
+}
+
+/**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+bool CNxTkWindow::drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color)
+{
+ return nxtk_fillcirclewindow(m_hNxTkWindow, center, radius, &color) == OK;
+}
+
+/**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset)
+{
+ // Move a rectangular region of the display
+
+ return nxtk_movewindow(m_hNxTkWindow, pRect, pOffset) == OK;
+}
+
+/**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window. The source image is treated as an opaque image.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxTkWindow::bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride)
+{
+ // Copy a rectangular bitmap image in a region on the display
+
+ return nxtk_bitmapwindow(m_hNxTkWindow, pDest, &pSrc, pOrigin, stride) == OK;
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
new file mode 100644
index 000000000..725a368fa
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
@@ -0,0 +1,382 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cnxtoolbar.hxx"
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pNxTkWindow Parent framed window instance
+ * @param hNxTkWindow Parent framed window NX handler
+ * @param widgetControl Controlling widget for this toolbar.
+ * @param height The height of the toolbar.
+ */
+
+CNxToolbar::CNxToolbar(CNxTkWindow *pNxTkWindow, NXTKWINDOW hNxTkWindow,
+ CWidgetControl *pWidgetControl, nxgl_coord_t height)
+ : CCallback(pWidgetControl)
+{
+ // Initialize toolbar state data
+
+ m_nxTkWindow = pNxTkWindow;
+ m_hNxTkWindow = hNxTkWindow;
+ m_widgetControl = pWidgetControl;
+ m_height = height;
+
+ // Create the CGraphicsPort instance for this window
+
+ m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this));
+}
+
+/**
+ * Destructor.
+ */
+
+CNxToolbar::~CNxToolbar(void)
+{
+ // Inform the parent window instance that the toolbar is gone
+
+ m_nxTkWindow->detachToolbar();
+
+ // Release the widget control instance. Normally the lifetime
+ // of the widget control instance is managed by logic outside
+ // of the window instance. But here, as in the real world,
+ // our parent expects us to clean up after ourselves.
+
+ delete m_widgetControl;
+
+ // Release the toolbar.
+
+ (void)nxtk_closetoolbar(m_hNxTkWindow);
+}
+
+/**
+ * Creates a new toolbar. Toolbar creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the toolbar was successfully created.
+ */
+
+bool CNxToolbar::open(void)
+{
+ // Get the C-callable callback vtable
+
+ FAR struct nx_callback_s *vtable = getCallbackVTable();
+
+ // Create the toolbar
+
+ int ret = nxtk_opentoolbar(m_hNxTkWindow, m_height, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
+ return ret == OK;
+}
+
+/**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+CWidgetControl *CNxToolbar::getWidgetControl(void) const
+{
+ return m_widgetControl;
+}
+
+/**
+ * Request the position and size information of the toolbar. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxToolbar::requestPosition(void)
+{
+ // Request the position of the entire framed window containing the
+ // toolbar. The NXTK callback will route toolbar specific
+ // information back to us.
+
+ nxtk_getposition(m_hNxTkWindow);
+ return false;
+}
+
+/**
+ * Get the position of the toolbar in the physical display coordinates
+ * (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+bool CNxToolbar::getPosition(FAR struct nxgl_point_s *pPos)
+{
+ return m_widgetControl->getWindowPosition(pPos);
+}
+
+/**
+ * Get the size of the toolbar (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+bool CNxToolbar::getSize(FAR struct nxgl_size_s *pSize)
+{
+ return m_widgetControl->getWindowSize(pSize);
+}
+
+/**
+ * Set the position and size of the toolbar. The position of
+ * the toolbar is fixed at the top of the parent framed window.
+ *
+ * @param pPos The new position of the toolbar.
+ * @return Always returns false.
+ */
+
+bool CNxToolbar::setPosition(FAR const struct nxgl_point_s *pPos)
+{
+ return false;
+}
+
+/**
+ * Set the size of the selected toolbar. The only variable dimension
+ * is the height of the toolbar, but that cannot be changed once
+ * it is created.
+ *
+ * @param pSize The new size of the toolbar.
+ * @return Always returns false.
+ */
+
+bool CNxToolbar::setSize(FAR const struct nxgl_size_s *pSize)
+{
+ return false;
+}
+
+/**
+ * Bring the toolbar to the top of the display. The toolbar is
+ * a component of the containing, parent, framed window. It
+ * cannot be raised separately.
+ *
+ * @return Always returns false.
+ */
+
+bool CNxToolbar::raise(void)
+{
+ return false;
+}
+
+/**
+ * Lower the toolbar to the bottom of the display. The toolbar is
+ * a component of the containing, parent, framed window. It
+ * cannot be raised separately.
+ *
+ * @return Always returns false.
+ */
+
+bool CNxToolbar::lower(void)
+{
+ return false;
+}
+
+/**
+ * Set an individual pixel in the toolbar with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color)
+{
+#if 0
+ // Set an individual pixel to the specified color
+
+ return nxtk_setpixel(m_hNxTkWindow, pPos, &color) == OK;
+#else
+# warning "Revisit"
+ return false;
+#endif
+}
+
+/**
+ * Fill the specified rectangle in the toolbar with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color)
+{
+ // Fill a rectangular region with a solid color
+
+ return nxtk_filltoolbar(m_hNxTkWindow, pRect, &color) == OK;
+}
+
+/**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+void CNxToolbar::getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest)
+{
+ // Get a rectangule region from the toolbar
+
+ (void)nxtk_gettoolbar(m_hNxTkWindow, rect, 0, (FAR uint8_t*)dest->data, dest->stride);
+}
+
+/**
+ * Fill the specified trapezoidal region in the toolbar with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to toolbar (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color)
+{
+ // Fill a trapezoidal region with a solid color
+
+ return nxtk_filltraptoolbar(m_hNxTkWindow, pTrap, &color) == OK;
+}
+
+/**
+ * Fill the specified line in the toolbar with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width, nxgl_mxpixel_t color)
+{
+ // Draw a line with the specified color
+
+ return nxtk_drawlinetoolbar(m_hNxTkWindow, vector, width, &color) == OK;
+}
+
+/**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+bool CNxToolbar::drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color)
+{
+ return nxtk_fillcircletoolbar(m_hNxTkWindow, center, radius, &color) == OK;
+}
+
+/**
+ * Move a rectangular region within the toolbar.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset)
+{
+ // Move a rectangular region of the display
+
+ return nxtk_movetoolbar(m_hNxTkWindow, pRect, pOffset) == OK;
+}
+
+/**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified toolbar. The source image is treated as an opaque image.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in toolbar coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxToolbar::bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride)
+{
+ // Copy a rectangular bitmap image in a region on the display
+
+ return nxtk_bitmaptoolbar(m_hNxTkWindow, pDest, &pSrc, pOrigin, stride) == OK;
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxwidget.cxx b/NxWidgets/libnxwidgets/src/cnxwidget.cxx
new file mode 100644
index 000000000..ab4a09b4e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxwidget.cxx
@@ -0,0 +1,1551 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxwidget.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cnxwidget.hxx"
+#include "cgraphicsport.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cnxfont.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgeteventargs.hxx"
+#include "cwidgetcontrol.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+#define DOUBLE_CLICK_BOUNDS 10
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controllwing widget for the display
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags Bitmask specifying some set-up values for the widget.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ * @see WidgetFlagType.
+ */
+
+CNxWidget::CNxWidget(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags, const CWidgetStyle *style)
+{
+ // Save the controlling widget
+
+ m_widgetControl = pWidgetControl;
+
+ // Set properties from parameters. If this is a child widget, then
+ // this coordinates are relative to the parent widget.
+
+ m_rect.setX(x);
+ m_rect.setY(y);
+ m_rect.setWidth(width);
+ m_rect.setHeight(height);
+
+ // Do we need to fetch the default style?
+
+ if (style == (CWidgetStyle *)NULL)
+ {
+ // Get the style from the controlling widget. This allows different
+ // widgets within a window to have the same style, unique to the window.
+
+ pWidgetControl->getWidgetStyle(&m_style);
+ }
+ else
+ {
+ // Use specified style
+
+ useWidgetStyle(style);
+ }
+
+ // Add ourself to the list of controlled widgets
+
+ pWidgetControl->addControlledWidget(this);
+
+ // Mask flags against bitmasks and logical NOT twice to obtain boolean values
+
+ m_flags.borderless = (!(!(flags & WIDGET_BORDERLESS)));
+ m_flags.draggable = (!(!(flags & WIDGET_DRAGGABLE)));
+ m_flags.permeable = (!(!(flags & WIDGET_PERMEABLE)));
+ m_flags.doubleClickable = (!(!(flags & WIDGET_DOUBLE_CLICKABLE)));
+
+ // Dragging values
+
+ m_grabPointX = 0;
+ m_grabPointY = 0;
+ m_newX = 0;
+ m_newY = 0;
+
+ // Set initial flag values
+
+ m_flags.clicked = false;
+ m_flags.dragging = false;
+ m_flags.hasFocus = false;
+ m_flags.deleted = false;
+ m_flags.drawingEnabled = false;
+ m_flags.enabled = true;
+ m_flags.erased = true;
+ m_flags.visibleRegionCacheInvalid = true;
+ m_flags.hidden = false;
+
+ // Set hierarchy pointers
+
+ m_parent = (CNxWidget *)NULL;
+ m_focusedChild = (CNxWidget *)NULL;
+
+ // Double-click
+
+ clock_gettime(CLOCK_REALTIME, &m_lastClickTime);
+ m_lastClickX = 0;
+ m_lastClickY = 0;
+ m_doubleClickBounds = DOUBLE_CLICK_BOUNDS;
+
+ // Set border size to 1 line
+
+ m_borderSize.top = 1;
+ m_borderSize.right = 1;
+ m_borderSize.bottom = 1;
+ m_borderSize.left = 1;
+
+ m_widgetEventHandlers = new CWidgetEventHandlerList(this);
+}
+
+/**
+ * Destructor.
+ */
+
+CNxWidget::~CNxWidget(void)
+{
+ if (!m_flags.deleted)
+ {
+ m_flags.deleted = true;
+
+ // Unset the clicked pointer if necessary
+
+ if (m_widgetControl->getClickedWidget() == this)
+ {
+ m_widgetControl->setClickedWidget((CNxWidget *)NULL);
+ }
+ }
+
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ m_parent->removeChild(this);
+ }
+
+ // Delete children
+
+ while (m_children.size() > 0)
+ {
+ m_children[0]->destroy();
+ }
+
+ // Remove ourselve from the controlled widget list
+
+ m_widgetControl->removeControlledWidget(this);
+
+ // Delete instances. NOTE that we do not delete the controlling
+ // widget. It persists until the window is closed.
+
+ delete m_widgetEventHandlers;
+}
+
+/**
+ * Get the x coordinate of the widget in "Widget space".
+ *
+ * @return Widget space x coordinate.
+ */
+
+nxgl_coord_t CNxWidget::getX(void) const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ return m_parent->getX() + m_rect.getX();
+ }
+
+ return m_rect.getX();
+}
+
+/**
+ * Get the y coordinate of the widget in "Widget space".
+ *
+ * @return Widget space y coordinate.
+ */
+
+nxgl_coord_t CNxWidget::getY(void) const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ return m_parent->getY() + m_rect.getY();
+ }
+
+ return m_rect.getY();
+}
+
+/**
+ * Get the x coordinate of the widget relative to its parent.
+ *
+ * @return Parent-space x coordinate.
+ */
+
+nxgl_coord_t CNxWidget::getRelativeX(void) const
+{
+ return m_rect.getX();
+}
+
+/**
+ * Get the y coordinate of the widget relative to its parent.
+ *
+ * @return Parent-space y coordinate.
+ */
+
+nxgl_coord_t CNxWidget::getRelativeY(void) const
+{
+ return m_rect.getY();
+}
+
+/**
+ * Has the widget been marked for deletion? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are not deleted.
+ *
+ * Widgets marked for deletion are automatically deleted and should not be
+ * interacted with.
+ *
+ * @return True if marked for deletion.
+ */
+
+bool CNxWidget::isDeleted(void) const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (m_parent->isDeleted())
+ {
+ return true;
+ }
+ }
+
+ return m_flags.deleted;
+}
+
+/**
+ * Is the widget allowed to draw? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are visible.
+ *
+ * @return True if drawing is enabled.
+ */
+
+bool CNxWidget::isDrawingEnabled(void) const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (m_parent->isDrawingEnabled())
+ {
+ // Drawing is enabled if the widget is drawable and not deleted
+
+ return (m_flags.drawingEnabled && (!m_flags.deleted) && (!m_flags.hidden));
+ }
+ }
+ else
+ {
+ return (m_flags.drawingEnabled && (!m_flags.deleted) && (!m_flags.hidden));
+ }
+
+ return false;
+}
+
+/**
+ * Is the widget hidden? This function recurses up the widget
+ * hierarchy and returns true if any of the widgets in the ancestor
+ * chain are hidden.
+ *
+ * @return True if hidden.
+ */
+
+bool CNxWidget::isHidden(void) const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (!m_parent->isHidden())
+ {
+ // Hidden if the widget is deleted or hidden
+
+ return (m_flags.deleted || m_flags.hidden);
+ }
+ }
+ else
+ {
+ return (m_flags.deleted || m_flags.hidden);
+ }
+
+ return true;
+}
+
+/**
+ * Is the widget enabled? This function recurses up the widget
+ * hierarchy and only returns true if all of the widgets in the ancestor
+ * chain are enabled.
+ *
+ * @return True if enabled.
+ */
+
+bool CNxWidget::isEnabled() const
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (m_parent->isEnabled())
+ {
+ // Enabled if the widget is enabled, not deleted and not hidden
+
+ return (m_flags.enabled && (!m_flags.deleted) && (!m_flags.hidden));
+ }
+ }
+ else
+ {
+ return (m_flags.enabled && (!m_flags.deleted) && (!m_flags.hidden));
+ }
+
+ return false;
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CNxWidget::getPreferredDimensions(CRect &rect) const
+{
+ rect = m_rect;
+}
+
+/**
+ * Insert the properties of the space within this widget that is available
+ * for children into the rect passed in as a parameter.
+ * All coordinates are relative to this widget.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CNxWidget::getClientRect(CRect &rect) const
+{
+ if (m_flags.borderless)
+ {
+ rect.setX(0);
+ rect.setY(0);
+ rect.setWidth(getWidth());
+ rect.setHeight(getHeight());
+ }
+ else
+ {
+ rect.setX(m_borderSize.left);
+ rect.setY(m_borderSize.top);
+ rect.setWidth(getWidth() - (m_borderSize.left + m_borderSize.right));
+ rect.setHeight(getHeight() - (m_borderSize.top + m_borderSize.bottom));
+ }
+}
+
+/**
+ * Insert the properties of the space within this widget that is
+ * available for children into the rect passed in as a parameter.
+ * Identical to getClientRect() except that all coordinates are
+ * absolute positions within the window.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CNxWidget::getRect(CRect &rect) const
+{
+ getClientRect(rect);
+ rect.setX(rect.getX() + getX());
+ rect.setY(rect.getY() + getY());
+}
+
+/**
+ * Sets this widget's border state.
+ *
+ * @param isBorderless The border state.
+ */
+
+void CNxWidget::setBorderless(bool borderless)
+{
+ m_flags.borderless = borderless;
+}
+
+/**
+ * Sets the font.
+ *
+ * @param font A pointer to the font to use.
+ */
+
+void CNxWidget::setFont(CNxFont *font)
+{
+ m_style.font = font;
+}
+
+/**
+ * Draws the visible regions of the widget and the widget's child widgets.
+ */
+
+void CNxWidget::redraw(void)
+{
+ if (isDrawingEnabled())
+ {
+ // Get the graphics port needed to draw on this window
+
+ CGraphicsPort *port = m_widgetControl->getGraphicsPort();
+
+ // Draw the Widget
+
+ drawBorder(port);
+ drawContents(port);
+
+ // Remember that the widget is no longer erased
+
+ m_flags.erased = false;
+
+ // Draw the children of the widget
+
+ drawChildren();
+ }
+}
+
+/**
+ * Enables the widget.
+ *
+ * @return True if the widget was enabled.
+ */
+
+bool CNxWidget::enable(void)
+{
+ if (!m_flags.enabled)
+ {
+ m_flags.enabled = true;
+ onEnable();
+ redraw();
+ m_widgetEventHandlers->raiseEnableEvent();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Disabled the widget.
+ *
+ * @return True if the widget was disabled.
+ */
+
+bool CNxWidget::disable(void)
+{
+ if (m_flags.enabled)
+ {
+ m_flags.enabled = false;
+ onDisable();
+ redraw();
+ m_widgetEventHandlers->raiseDisableEvent();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Erases the widget, marks it as deleted, and moves it to the CNxWidget
+ * deletion queue. Widgets are automatically deleted by the framework and
+ * should not be deleted externally.
+ */
+
+void CNxWidget::close(void)
+{
+ if (!m_flags.deleted)
+ {
+ m_widgetEventHandlers->raiseCloseEvent();
+ m_widgetEventHandlers->disable();
+
+ m_flags.deleted = true;
+ m_flags.drawingEnabled = false;
+
+ // Unset clicked widget if necessary
+
+ CNxWidget *clickedWidget = m_widgetControl->getClickedWidget();
+ if (clickedWidget == this)
+ {
+ release(clickedWidget->getX(), clickedWidget->getY());
+ }
+
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ m_parent->closeChild(this);
+ }
+ }
+}
+
+/**
+ * Draws the widget and makes it visible.
+ * Does not steal focus from other widgets.
+ *
+ * @return True if the widget was shown.
+ * @see hide()
+ */
+
+bool CNxWidget::show(void)
+{
+ if (m_flags.hidden)
+ {
+ m_flags.hidden = false;
+
+ m_widgetEventHandlers->raiseShowEvent();
+ redraw();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Erases the widget and makes it invisible.
+ * Does not re-assign focus to another widget.
+ *
+ * @return True if the widget was hidden.
+ * @see show()
+ */
+
+bool CNxWidget::hide(void)
+{
+ if (!m_flags.hidden)
+ {
+ m_flags.hidden = true;
+ m_widgetEventHandlers->raiseHideEvent();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Click this widget at the supplied coordinates. This should only be
+ * overridden in subclasses if the default click behaviour needs to be changed.
+ * If the subclassed widget should just respond to a standard click,
+ * the onClick() method should be overridden instead.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click was successful.
+ */
+
+bool CNxWidget::click(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (!isEnabled() || !checkCollision(x, y))
+ {
+ return false;
+ }
+
+ // Check for a double-click
+
+ if (isDoubleClick(x, y))
+ {
+ return doubleClick(x, y);
+ }
+
+ // Work out which child was clicked
+
+ for (int i = m_children.size() - 1; i > -1; i--)
+ {
+ if (m_children[i]->click(x, y))
+ {
+ return true;
+ }
+ }
+
+ // Handle clicks on this
+
+ m_flags.clicked = true;
+
+ // Record data for double-click
+
+ clock_gettime(CLOCK_REALTIME, &m_lastClickTime);
+ m_lastClickX = x;
+ m_lastClickY = y;
+
+ // Take focus away from child widgets
+
+ setFocusedWidget((CNxWidget *)NULL);
+
+ // Tell controlling widget that the clicked widget has changed
+
+ m_widgetControl->setClickedWidget(this);
+
+ // Run any code in the inherited class
+
+ onClick(x, y);
+ m_widgetEventHandlers->raiseClickEvent(x, y);
+ return true;
+}
+
+/**
+ * Check if the click is a double-click.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click is a double-click.
+ */
+
+bool CNxWidget::isDoubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Check for a double-click
+
+ if (m_flags.doubleClickable && hasFocus() && m_widgetControl->doubleClick())
+ {
+ // Within the allowed region?
+
+ if ((m_lastClickX > x - m_doubleClickBounds) && (m_lastClickX < x + m_doubleClickBounds))
+ {
+ if ((m_lastClickY > y - m_doubleClickBounds) && (m_lastClickY < y + m_doubleClickBounds))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Double-click this widget at the supplied coordinates. This
+ * should only be overridden in subclasses if the default
+ * double-click behaviour needs to be changed. If the subclassed
+ * widget should just respond to a standard double-click, the
+ * onDoubleClick() method should be overridden instead.
+ *
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ * @return True if the click was successful.
+ */
+
+bool CNxWidget::doubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (!isEnabled() || !checkCollision(x, y))
+ {
+ return false;
+ }
+
+ // Work out which child was clicked. Allow the
+ // child to determine if it has been double-clicked or not
+ // in case the second click has fallen on a different
+ // child to the first.
+
+ for (int i = m_children.size() - 1; i > -1; i--)
+ {
+ if (m_children[i]->click(x, y))
+ {
+ return true;
+ }
+ }
+
+ m_flags.clicked = true;
+
+ // Record data for double-click
+
+ clock_gettime(CLOCK_REALTIME, &m_lastClickTime);
+ m_lastClickX = x;
+ m_lastClickY = y;
+
+ // Take focus away from child widgets
+
+ setFocusedWidget((CNxWidget *)NULL);
+
+ // Tell controlling widget that the clicked widget has changed
+
+ m_widgetControl->setClickedWidget(this);
+
+ onDoubleClick(x, y);
+ m_widgetEventHandlers->raiseDoubleClickEvent(x, y);
+ return true;
+}
+
+/**
+ * Release this widget at the supplied coordinates. This should only be
+ * overridden in subclasses if the default release behaviour needs to be
+ * changed. If the subclassed widget should just respond to a standard
+ * release, the onRelease() method should be overridden instead.
+ *
+ * @param x X coordinate of the release.
+ * @param y Y coordinate of the release.
+ * @return True if the release was successful.
+ */
+
+bool CNxWidget::release(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (!m_flags.clicked)
+ {
+ return false;
+ }
+
+ // Notify of the pre-release event. In this event, the widget is still in the
+ // clicked state. This event is used, for example, by button handlers so
+ // that the click event is really processed when the button is released
+ // instead of pressed. The former behavior is needed because the result
+ // of processing the press may obscure the button and make it impossible
+ // to receive the release event.
+
+ onPreRelease(x, y);
+
+ // Now mark the widget as NOT clicked and stop draggin actions.
+
+ m_flags.clicked = false;
+ stopDragging(x, y);
+
+ if (m_widgetControl->getClickedWidget() == this)
+ {
+ m_widgetControl->setClickedWidget((CNxWidget *)NULL);
+ }
+
+ // Determine which release event to fire
+
+ if (checkCollision(x, y))
+ {
+ // Notify of the release event... the widget was NOT dragged outside of
+ // its original bounding box
+
+ onRelease(x, y);
+
+ // Release occurred within widget; raise release
+
+ m_widgetEventHandlers->raiseReleaseEvent(x, y);
+ }
+ else
+ {
+ // Notify of the release event... the widget WAS dragged outside of
+ // its original bounding box
+
+ onReleaseOutside(x, y);
+
+ // Release occurred outside widget; raise release outside event
+
+ m_widgetEventHandlers->raiseReleaseOutsideEvent(x, y);
+ }
+
+ return true;
+}
+
+/**
+ * Drag the widget to the supplied coordinates.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance that the mouse was dragged.
+ * @param vY The vertical distance that the mouse was dragged.
+ * @return True if the drag was successful.
+ */
+
+bool CNxWidget::drag(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ if ((isEnabled()) && (m_flags.dragging))
+ {
+ if ((vX != 0) || (vY != 0))
+ {
+ onDrag(x, y, vX, vY);
+ m_widgetEventHandlers->raiseDragEvent(x, y, vX, vY);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Send a keypress to the widget.
+ *
+ * @param key The keycode to send to the widget.
+ * @return True if the keypress was processed.
+ */
+
+bool CNxWidget::keyPress(nxwidget_char_t key)
+{
+ if (!isEnabled())
+ {
+ return false;
+ }
+
+ // Raise keypress for this widget
+
+ m_widgetEventHandlers->raiseKeyPressEvent(key);
+
+ // Handle active child
+
+ if (m_focusedChild != NULL)
+ {
+ m_focusedChild->keyPress(key);
+ }
+
+ return true;
+}
+
+/**
+ * Send a cursor control event to the widget.
+ *
+ * @param cursorControl The cursor control code o send to the widget.
+ * @return True if the cursor control was processed.
+ */
+
+bool CNxWidget::cursorControl(ECursorControl control)
+{
+ if (!isEnabled())
+ {
+ return false;
+ }
+
+ // Raise cursor control for this widget
+
+ m_widgetEventHandlers->raiseCursorControlEvent(control);
+
+ // Handle active child
+
+ if (m_focusedChild != NULL)
+ {
+ m_focusedChild->cursorControl(control);
+ }
+
+ return true;
+}
+
+/**
+ * Give the widget focus.
+ *
+ * @return True if the widget received focus correctly.
+ */
+
+bool CNxWidget::focus(void)
+{
+ if (!isEnabled())
+ {
+ return false;
+ }
+
+ // Remember if the widget has focus
+
+ bool hadFocus = m_flags.hasFocus;
+ m_flags.hasFocus = true;
+
+ // Notify parent that this widget has focus
+
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ m_parent->setFocusedWidget(this);
+ }
+
+ // Raise an event only if the widget did not have focus
+
+ if (!hadFocus)
+ {
+ onFocus();
+
+ m_widgetEventHandlers->raiseFocusEvent();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Remove focus from the widget.
+ *
+ * @return True if the widget lost focus correctly.
+ */
+
+bool CNxWidget::blur(void)
+{
+ // Remember if the widget had focus
+
+ bool hadFocus = m_flags.hasFocus;
+
+ m_flags.hasFocus = false;
+
+ // Take focus away from child widgets
+
+ if (m_focusedChild != (CNxWidget *)NULL)
+ {
+ m_focusedChild->blur();
+ m_focusedChild = (CNxWidget *)NULL;
+ m_widgetControl->clearFocusedWidget(this);
+ }
+
+ // Raise an event only if the widget had focus
+
+ if (hadFocus)
+ {
+ onBlur();
+
+ m_widgetEventHandlers->raiseBlurEvent();
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Move the widget to the new coordinates.
+ * Co-ordinates are relative to the parent widget.
+ *
+ * @param x The new x coordinate.
+ * @param y The new y coordinate.
+ * @return True if the move was successful.
+ */
+
+bool CNxWidget::moveTo(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Enforce widget to stay within parent confines if necessary
+
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (!m_parent->isPermeable())
+ {
+ CRect parentRect;
+ m_parent->getClientRect(parentRect);
+
+ // Check x coordinate
+
+ if (x < parentRect.getX())
+ {
+ x = parentRect.getX();
+
+ // Check width against new value
+
+ if (x + getWidth() > parentRect.getX2() + 1)
+ {
+ return false;
+ }
+ }
+ else if (x + getWidth() > parentRect.getX2() + 1)
+ {
+ x = (parentRect.getX() + parentRect.getX()) - getWidth();
+
+ // Check new x value
+
+ if (x < parentRect.getX())
+ {
+ return false;
+ }
+ }
+
+ // Check y coordinate
+
+ if (y < parentRect.getY())
+ {
+ y = parentRect.getY();
+
+ // Check height against new value
+
+ if (y + getHeight() > parentRect.getY2() + 1)
+ {
+ return false;
+ }
+ }
+ else if (y + getHeight() > parentRect.getY2() + 1)
+ {
+ y = (parentRect.getY() + parentRect.getY()) - getHeight();
+
+ // Check new y value
+
+ if (y < parentRect.getY())
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ // Perform move if necessary
+
+ if ((m_rect.getX() != x) || (m_rect.getY() != y))
+ {
+ nxgl_coord_t oldX = m_rect.getX();
+ nxgl_coord_t oldY = m_rect.getY();
+
+ m_rect.setX(x);
+ m_rect.setY(y);
+
+ redraw();
+ m_widgetEventHandlers->raiseMoveEvent(x, y, x - oldX, y - oldY);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Resize the widget to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ * @return True if the resize was successful.
+ */
+
+bool CNxWidget::resize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Enforce widget to stay within parent confines if necessary
+
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ if (!m_parent->isPermeable())
+ {
+ CRect parentRect;
+ m_parent->getClientRect(parentRect);
+
+ // Check width
+
+ if (m_rect.getX() + width > parentRect.getX2() + 1)
+ {
+ width = parentRect.getX2() + 1 - m_rect.getX();
+ }
+
+ // Check height
+
+ if (m_rect.getY() + height > parentRect.getY2() + 1)
+ {
+ height = parentRect.getY2() + 1 - m_rect.getY();
+ }
+ }
+ }
+
+ if (getWidth() != width || getHeight() != height)
+ {
+ // Remember if the widget is permeable
+
+ bool wasPermeable = m_flags.permeable;
+
+ // Remember if widget was drawing
+
+ bool wasDrawEnabled = m_flags.drawingEnabled;
+
+ m_flags.permeable = true;
+ disableDrawing();
+
+ m_rect.setWidth(width);
+ m_rect.setHeight(height);
+
+ onResize(width, height);
+
+ // Reset the permeable value
+
+ m_flags.permeable = wasPermeable;
+
+ // Reset drawing value
+
+ m_flags.drawingEnabled = wasDrawEnabled;
+ redraw();
+ m_widgetEventHandlers->raiseResizeEvent(width, height);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Resize and move the widget in one operation.
+ * Only performs one redraw so it is faster than calling the
+ * two separate functions.
+ *
+ * @param x The new x coordinate.
+ * @param y The new y coordinate.
+ * @param width The new width.
+ * @param height The new height.
+ * @return True if the widget was adjusted successfully.
+ */
+
+bool CNxWidget::changeDimensions(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ bool wasDrawing = m_flags.drawingEnabled;
+ m_flags.drawingEnabled = false;
+ bool moved = moveTo(x, y);
+ m_flags.drawingEnabled = wasDrawing;
+ return (resize(width, height) | moved);
+}
+
+/**
+ * Moves the supplied child widget to the deletion queue.
+ * For framework use only.
+ *
+ * @param widget A pointer to the child widget.
+ */
+
+void CNxWidget::moveChildToDeleteQueue(CNxWidget *widget)
+{
+ // Locate widget in main vector
+
+ for (int i = 0; i < m_children.size(); i++)
+ {
+ if (m_children[i] == widget)
+ {
+ // Add widget to controlling widget's delete vector
+
+ m_widgetControl->addToDeleteQueue(widget);
+
+ // Remove widget from main vector
+
+ m_children.erase(i);
+ break;
+ }
+ }
+}
+
+/**
+ * Sets the supplied widget as the focused child. The widget must
+ * be a child of this widget.
+ *
+ * @param widget A pointer to the child widget.
+ * @see getFocusedWidget()
+ */
+
+void CNxWidget::setFocusedWidget(CNxWidget *widget)
+{
+ if (m_focusedChild != widget)
+ {
+ if (m_focusedChild != NULL)
+ {
+ // Blur the current active widget
+
+ m_focusedChild->blur();
+ }
+ }
+
+ // Remember the new active widget
+
+ m_focusedChild = widget;
+
+ // Make this widget active too
+
+ focus();
+
+ // Route keyboard input to the focused widget
+
+ m_widgetControl->setFocusedWidget(this);
+}
+
+/**
+ * Checks if the supplied coordinates collide with this widget.
+ *
+ * @param x The x coordinate to check.
+ * @param y The y coordinate to check.
+ * @return True if a collision occurred.
+ */
+
+bool CNxWidget::checkCollision(nxgl_coord_t x, nxgl_coord_t y) const
+{
+ if (isHidden())
+ {
+ return false;
+ }
+
+ // Get the clipped rect
+
+ CRect rect;
+ getRect(rect);
+ return rect.contains(x, y);
+}
+
+/**
+ * Checks if the supplied rectangle definition collides with this widget.
+ *
+ * @param x The x coordinate of the rectangle to check.
+ * @param y The y coordinate of the rectangle to check.
+ * @param width The width of the rectangle to check.
+ * @param height The height of the rectangle to check.
+ * @return True if a collision occurred.
+ */
+
+bool CNxWidget::checkCollision(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height) const
+{
+ if (isHidden())
+ {
+ return false;
+ }
+
+ // Get the clipped rect
+
+ CRect rect;
+ getRect(rect);
+ return rect.intersects(CRect(x, y, width, height));
+}
+
+/**
+ * Checks if the supplied widget collides with this widget.
+ *
+ * @param widget A pointer to another widget to check for collisions with.
+ * @return True if a collision occurred.
+ */
+
+bool CNxWidget::checkCollision(CNxWidget *widget) const
+{
+ // Get the clipped rect
+
+ CRect rect;
+ widget->getRect(rect);
+ return rect.intersects(m_rect);
+}
+
+/**
+ * Adds a widget to this widget's child stack. The widget is added to the
+ * top of the stack. Note that the widget can only be added if it is not
+ * already a child of another widget.
+ *
+ * @param widget A pointer to the widget to add to the child list.
+ * @see insertWidget()
+ */
+
+void CNxWidget::addWidget(CNxWidget *widget)
+{
+ if (widget->getParent() == NULL)
+ {
+ widget->setParent(this);
+ m_children.push_back(widget);
+
+ // Should the widget steal the focus?
+
+ if (widget->hasFocus())
+ {
+ setFocusedWidget(widget);
+ }
+
+ widget->enableDrawing();
+ widget->redraw();
+ }
+}
+
+/**
+ * Inserts a widget into this widget's child stack at the bottom of the
+ * stack. Note that the widget can only be added if it is not already
+ * a child of another widget.
+ *
+ * @param widget A pointer to the widget to add to the child list.
+ * @see addWidget()
+ */
+
+void CNxWidget::insertWidget(CNxWidget *widget)
+{
+ if (widget->getParent() == NULL)
+ {
+ widget->setParent(this);
+ m_children.insert(0, widget);
+
+ widget->enableDrawing();
+ widget->redraw();
+ }
+}
+
+/**
+ * Remove this widget from the widget hierarchy. Returns
+ * responsibility for deleting the widget back to the developer.
+ * Does not unregister the widget from the VBL system.
+ * Does not erase the widget from the display.
+ *
+ * @return True if the widget was successfully removed.
+ */
+
+bool CNxWidget::remove(void)
+{
+ if (m_parent != (CNxWidget *)NULL)
+ {
+ return m_parent->removeChild(this);
+ }
+
+ return false;
+}
+
+/**
+ * Remove a child widget from the widget hierarchy. Returns
+ * responsibility for deleting the widget back to the developer.
+ * Does not unregister the widget from the VBL system.
+ * Does not erase the widget from the display.
+ *
+ * @param widget Pointer to the widget to remove from the hierarchy.
+ * @return True if the widget was succesfully removed.
+ */
+
+bool CNxWidget::removeChild(CNxWidget *widget)
+{
+ // Do we need to make another widget active?
+
+ if (m_focusedChild == widget)
+ {
+ m_focusedChild = (CNxWidget *)NULL;
+ m_widgetControl->clearFocusedWidget(this);
+ }
+
+ // Unset clicked widget if necessary
+
+ CNxWidget *clickedWidget = m_widgetControl->getClickedWidget();
+ if (clickedWidget == widget)
+ {
+ clickedWidget->release(clickedWidget->getX(), clickedWidget->getY());
+ }
+
+ // Divorce child from parent
+
+ widget->setParent((CNxWidget *)NULL);
+ widget->disableDrawing();
+
+ // Locate widget in main vector
+
+ for (int i = 0; i < m_children.size(); i++)
+ {
+ if (m_children[i] == widget)
+ {
+ // Remove widget from main vector
+
+ m_children.erase(i);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Get the child widget at the specified index.
+ *
+ * @param index Index of the child to retrieve.
+ * @return Pointer to the child at the specified index.
+ */
+
+const CNxWidget *CNxWidget::getChild(int index) const
+{
+ if (index < (int)m_children.size())
+ {
+ return m_children[index];
+ }
+ return (CNxWidget *)NULL;
+}
+
+/**
+ * Sets the border size. The border cannot be drawn over in the
+ * drawContents() method.
+ *
+ * @param borderSize The new border size.
+ */
+
+void CNxWidget::setBorderSize(const WidgetBorderSize &borderSize)
+{
+ m_borderSize.top = borderSize.top;
+ m_borderSize.right = borderSize.right;
+ m_borderSize.bottom = borderSize.bottom;
+ m_borderSize.left = borderSize.left;
+}
+
+/**
+ * Use the provided widget style
+ */
+
+void CNxWidget::useWidgetStyle(const CWidgetStyle *style)
+{
+ m_style.colors.background = style->colors.background;
+ m_style.colors.selectedBackground = style->colors.selectedBackground;
+ m_style.colors.shineEdge = style->colors.shineEdge;
+ m_style.colors.shadowEdge = style->colors.shadowEdge;
+ m_style.colors.highlight = style->colors.highlight;
+ m_style.colors.disabledText = style->colors.disabledText;
+ m_style.colors.enabledText = style->colors.enabledText;
+ m_style.colors.selectedText = style->colors.selectedText;
+ m_style.font = style->font;
+}
+
+/**
+ * Draw all visible regions of this widget's children.
+ */
+
+void CNxWidget::drawChildren(void)
+{
+ for (int i = 0; i < m_children.size(); i++)
+ {
+ m_children[i]->redraw();
+ }
+}
+
+/**
+ * Remove the supplied child widget from this widget and send it to
+ * the deletion queue.
+ *
+ * @param widget The widget to close.
+ * @see close().
+ */
+
+void CNxWidget::closeChild(CNxWidget *widget)
+{
+ if (widget == NULL)
+ {
+ return;
+ }
+
+ // Ensure widget knows it is being closed
+
+ widget->close();
+
+ // Do we need to make another widget active?
+
+ if (m_focusedChild == widget)
+ {
+ m_focusedChild = (CNxWidget *)NULL;
+ m_widgetControl->clearFocusedWidget(this);
+
+ // Try to choose highest widget
+
+ for (int i = m_children.size() - 1; i > -1; i--)
+ {
+ if ((m_children[i] != widget) && (!m_children[i]->isHidden()))
+ {
+ m_focusedChild = m_children[i];
+ }
+ }
+
+ // Where should the focus go?
+
+ if (m_focusedChild != NULL)
+ {
+ // Send focus to the new active widget
+
+ m_focusedChild->focus();
+
+ // Route keyboard input to the focused widget
+
+ m_widgetControl->setFocusedWidget(this);
+ }
+ else
+ {
+ // Give focus to this
+
+ setFocusedWidget((CNxWidget *)NULL);
+ }
+ }
+
+ moveChildToDeleteQueue(widget);
+}
+
+/**
+ * Notify this widget that it is being dragged, and set its drag point.
+ *
+ * @param x The x coordinate of the drag position relative to this widget.
+ * @param y The y coordinate of the drag position relative to this widget.
+ */
+
+void CNxWidget::startDragging(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (m_flags.draggable)
+ {
+ m_flags.dragging = true;
+ m_flags.clicked = true;
+ m_grabPointX = x - getX();
+ m_grabPointY = y - getY();
+ m_newX = m_rect.getX();
+ m_newY = m_rect.getY();
+
+ onDragStart();
+ }
+}
+
+/**
+ * Notify this widget that it is no longer being dragged.
+ */
+
+void CNxWidget::stopDragging(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (m_flags.dragging)
+ {
+ onDragStop();
+ m_flags.dragging = false;
+ m_widgetEventHandlers->raiseDropEvent(x, y);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cnxwindow.cxx b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
new file mode 100644
index 000000000..b38667d8d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
@@ -0,0 +1,355 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cnxwindow.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cnxwindow.hxx"
+#include "cbitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param hNxServer Handle to the NX server.
+ */
+
+CNxWindow::CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl)
+ : CCallback(pWidgetControl), m_hNxServer(hNxServer), m_hNxWindow(0),
+ m_widgetControl(pWidgetControl)
+{
+ // Create the CGraphicsPort instance for this window
+
+ m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this));
+}
+
+/**
+ * Destructor.
+ */
+
+CNxWindow::~CNxWindow(void)
+{
+ // Release the window. We do not release the widget control
+ // instance. The lifetime of that instance is owned by he-who-
+ // constructed-us.
+
+ (void)nx_closewindow(m_hNxWindow);
+}
+
+/**
+ * Creates a new window. Window creation is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully opened.
+ */
+
+bool CNxWindow::open(void)
+{
+ // Get the C-callable callback vtable
+
+ FAR struct nx_callback_s *vtable = getCallbackVTable();
+
+ // Create the window
+
+ m_hNxWindow = nx_openwindow(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
+ return m_hNxWindow != NULL;
+}
+
+/**
+ * Each implementation of INxWindow must provide a method to recover
+ * the contained CWidgetControl instance.
+ *
+ * @return The contained CWidgetControl instance
+ */
+
+CWidgetControl *CNxWindow::getWidgetControl(void) const
+{
+ return m_widgetControl;
+}
+
+/**
+ * Request the position and size information of the window. The values
+ * will be returned asynchronously through the client callback method.
+ * The GetPosition() method may than be called to obtain the positional
+ * data as provided by the callback.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxWindow::requestPosition(void)
+{
+ // Request the window position
+
+ return nx_getposition(m_hNxWindow) == OK;
+}
+
+/**
+ * Get the position of the window in the physical display coordinates
+ * (as reported by the NX callback).
+ *
+ * @return The position.
+ */
+
+bool CNxWindow::getPosition(FAR struct nxgl_point_s *pPos)
+{
+ return m_widgetControl->getWindowPosition(pPos);
+}
+
+/**
+ * Get the size of the window (as reported by the NX callback).
+ *
+ * @return The size.
+ */
+
+bool CNxWindow::getSize(FAR struct nxgl_size_s *pSize)
+{
+ return m_widgetControl->getWindowSize(pSize);
+}
+
+/**
+ * Set the position and size of the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on any failure.
+ */
+
+bool CNxWindow::setPosition(FAR const struct nxgl_point_s *pPos)
+{
+ // Set the window size and position
+
+ return nx_setposition(m_hNxWindow, pPos) == OK;
+}
+
+/**
+ * Set the size of the selected window.
+ *
+ * @param pSize The new size of the window.
+ * @return True on success, false on any failure.
+ */
+
+bool CNxWindow::setSize(FAR const struct nxgl_size_s *pSize)
+{
+ // Set the window size
+
+ return nx_setsize(m_hNxWindow, pSize) == OK;
+}
+
+/**
+ * Bring the window to the top of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxWindow::raise(void)
+{
+ // Raise the window to the top of the display
+
+ return nx_raise(m_hNxWindow) == OK;
+}
+
+/**
+ * Lower the window to the bottom of the display.
+ *
+ * @return True on success, false on any failure.
+ */
+
+bool CNxWindow::lower(void)
+{
+ // Lower the window to the bottom of the display
+
+ return nx_lower(m_hNxWindow) == OK;
+}
+
+/**
+ * Set an individual pixel in the window with the specified color.
+ *
+ * @param pPos The location of the pixel to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::setPixel(FAR const struct nxgl_point_s *pPos,
+ nxgl_mxpixel_t color)
+{
+ // Set an individual pixel to the specified color
+
+ return nx_setpixel(m_hNxWindow, pPos, &color) == OK;
+}
+
+/**
+ * Fill the specified rectangle in the window with the specified color.
+ *
+ * @param pRect The location to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::fill(FAR const struct nxgl_rect_s *pRect,
+ nxgl_mxpixel_t color)
+{
+ // Fill a rectangular region with a solid color
+
+ return nx_fill(m_hNxWindow, pRect, &color) == OK;
+}
+
+/**
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * @param rect The location to be copied
+ * @param dest - The describes the destination bitmap to receive the
+ * graphics data.
+ */
+
+void CNxWindow::getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest)
+{
+ // Get a rectangule region from the window
+
+ (void)nx_getrectangle(m_hNxWindow, rect, 0, (FAR uint8_t*)dest->data, dest->stride);
+}
+/**
+ * Fill the specified trapezoidal region in the window with the specified
+ * color.
+ *
+ * @param pClip Clipping rectangle relative to window (may be null).
+ * @param pTrap The trapezoidal region to be filled.
+ * @param color The color to use in the fill.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
+ FAR const struct nxgl_trapezoid_s *pTrap,
+ nxgl_mxpixel_t color)
+{
+ // Fill a trapezoidal region with a solid color
+
+ return nx_filltrapezoid(m_hNxWindow, pClip, pTrap, &color) == OK;
+}
+
+/**
+ * Fill the specified line in the window with the specified color.
+ *
+ * @param vector - Describes the line to be drawn
+ * @param width - The width of the line
+ * @param color - The color to use to fill the line
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::drawLine(FAR struct nxgl_vector_s *vector,
+ nxgl_coord_t width, nxgl_mxpixel_t color)
+{
+ // Draw a line with the specified color
+
+ return nx_drawline(m_hNxWindow, vector, width, &color) == OK;
+}
+
+/**
+ * Draw a filled circle at the specified position, size, and color.
+ *
+ * @param center The window-relative coordinates of the circle center.
+ * @param radius The radius of the rectangle in pixels.
+ * @param color The color of the rectangle.
+ */
+
+bool CNxWindow::drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
+ nxgl_mxpixel_t color)
+{
+ return nx_fillcircle(m_hNxWindow, center, radius, &color) == OK;
+}
+
+/**
+ * Move a rectangular region within the window.
+ *
+ * @param pRect Describes the rectangular region to move.
+ * @param pOffset The offset to move the region.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::move(FAR const struct nxgl_rect_s *pRect,
+ FAR const struct nxgl_point_s *pOffset)
+{
+ // Move a rectangular region of the display
+
+ return nx_move(m_hNxWindow, pRect, pOffset) == OK;
+}
+
+/**
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window. The source image is treated as an opaque image.
+ *
+ * @param pDest Describes the rectangular on the display that will receive
+ * the bitmap.
+ * @param pSrc The start of the source image.
+ * @param pOrigin the pOrigin of the upper, left-most corner of the full
+ * bitmap. Both pDest and pOrigin are in window coordinates, however,
+ * pOrigin may lie outside of the display.
+ * @param stride The width of the full source image in bytes.
+ *
+ * @return True on success; false on failure.
+ */
+
+bool CNxWindow::bitmap(FAR const struct nxgl_rect_s *pDest,
+ FAR const void *pSrc,
+ FAR const struct nxgl_point_s *pOrigin,
+ unsigned int stride)
+{
+ // Copy a rectangular bitmap image in a region on the display
+
+ return nx_bitmap(m_hNxWindow, pDest, &pSrc, pOrigin, stride) == OK;
+}
diff --git a/NxWidgets/libnxwidgets/src/cprogressbar.cxx b/NxWidgets/libnxwidgets/src/cprogressbar.cxx
new file mode 100644
index 000000000..5f29a3f7e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cprogressbar.cxx
@@ -0,0 +1,230 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cprogressbar.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstdio>
+#include <cstring>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cprogressbar.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the progress bar, relative to its parent.
+ * @param y The y coordinate of the progress bar, relative to its parent.
+ * @param width The width of the progress bar.
+ * @param height The height of the progress bar.
+ */
+
+CProgressBar::CProgressBar(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+: CNxWidget(pWidgetControl, x, y, width, height, 0)
+{
+ m_minimumValue = 0;
+ m_maximumValue = 0;
+ m_value = 0;
+ m_showPercentageText = true;
+ m_flags.borderless = false;
+}
+
+/**
+ * Set the value that of the progress bar.
+ *
+ * @param value The new value.
+ */
+
+void CProgressBar::setValue(const int16_t value)
+{
+ m_value = value;
+
+ // Limit to max/min values
+
+ if (m_value > m_maximumValue)
+ {
+ m_value = m_maximumValue;
+ }
+
+ if (m_value < m_minimumValue)
+ {
+ m_value = m_minimumValue;
+ }
+
+ redraw();
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CProgressBar::drawContents(CGraphicsPort *port)
+{
+ // Get the drawing window, accounting for the presence of any border
+
+ CRect rect;
+ getRect(rect);
+
+ // Calculate ratio of pixels to value range (max fractional value of 255)
+
+ uint32_t ratio = ((uint32_t)rect.getWidth() << 8) / (uint32_t)(m_maximumValue - m_minimumValue);
+
+ // Convert value using ratio, rounding up and shifting down
+
+ int16_t barWidth = ((m_value * ratio) + 128) >> 8;
+
+ // Draw filled region
+
+ port->drawFilledRect(rect.getX(), rect.getY(), barWidth, rect.getHeight(), getHighlightColor());
+
+ // Draw unfilled background
+
+ if (barWidth < rect.getWidth())
+ {
+ port->drawFilledRect(rect.getX() + barWidth, rect.getY(),
+ rect.getWidth() - barWidth, rect.getHeight(),
+ getBackgroundColor());
+ }
+
+ // Draw completion percentage text
+
+ if (m_showPercentageText)
+ {
+ char text[6];
+ sprintf(text, "%d%%", (100 * m_value) / (m_maximumValue - m_minimumValue));
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() +
+ ((rect.getWidth() - getFont()->getStringWidth(text)) >> 1);
+ pos.y = rect.getY() +
+ ((rect.getHeight() - getFont()->getHeight()) >> 1);
+
+ // Determine the background and text color
+
+ nxgl_mxpixel_t textColor;
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ }
+ else
+ {
+ textColor = getEnabledTextColor();
+ }
+
+ // And draw the text using the selected color
+
+ port->drawText(&pos, &rect, getFont(), text, 0, strlen(text),
+ textColor);
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CProgressBar::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cradiobutton.cxx b/NxWidgets/libnxwidgets/src/cradiobutton.cxx
new file mode 100644
index 000000000..86ad4118f
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cradiobutton.cxx
@@ -0,0 +1,225 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cradiobutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cradiobutton.hxx"
+#include "cradiobuttongroup.hxx"
+#include "cgraphicsport.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CLabel Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the radio button, relative to its
+ * parent.
+ * @param y The y coordinate of the radio button, relative to its
+ * parent.
+ * @param width The width of the radio button.
+ * @param height The height of the radio button.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * defaultCWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CRadioButton::CRadioButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CButton(pWidgetControl, x, y, width, height, *NXWidgets::g_nullString, style)
+{
+ m_state = RADIO_BUTTON_STATE_OFF;
+ m_flags.borderless = true;
+}
+
+/**
+ * Set the state of the radio button.
+ *
+ * @param state The new radio button state.
+ */
+
+void CRadioButton::setState(CRadioButton::RadioButtonState state)
+{
+ if (m_state != state)
+ {
+ m_state = state;
+
+ if (m_state != RADIO_BUTTON_STATE_OFF)
+ {
+ ((CRadioButtonGroup*)m_parent)->setSelectedWidget(this);
+ }
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ redraw();
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CRadioButton::drawContents(CGraphicsPort *port)
+{
+ // Get the X/Y position of the drawable region within the Label
+
+ nxgl_coord_t x = getX();
+ nxgl_coord_t y = getY();
+
+ nxgl_coord_t width = getWidth();
+ nxgl_coord_t height = getHeight();
+
+ // Include and offset for the border
+
+ if (!m_flags.borderless)
+ {
+ x += m_borderSize.left;
+ y += m_borderSize.top;
+
+ width -= (m_borderSize.left + m_borderSize.right);
+ height -= (m_borderSize.top + m_borderSize.bottom);
+ }
+
+ // Decide which glyph to draw
+
+ const struct SBitmap *glyph;
+
+ switch (m_state)
+ {
+ default:
+ case RADIO_BUTTON_STATE_ON:
+ glyph = &g_radioButtonOn;
+ break;
+
+ case RADIO_BUTTON_STATE_OFF:
+ glyph = &g_radioButtonOff;
+ break;
+
+ case RADIO_BUTTON_STATE_MU:
+ glyph = &g_radioButtonMu;
+ break;
+ }
+
+ // Don't exceed the size of the glyph
+
+ if (width > glyph->width)
+ {
+ width = glyph->width;
+ }
+
+ if (height > glyph->height)
+ {
+ height = glyph->height;
+ }
+
+ // Draw button
+
+ port->drawBitmap(x, y, width, height, glyph, 0, 0,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+}
+
+/**
+ * Sets the radiobutton's state to "on".
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CRadioButton::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ setState(RADIO_BUTTON_STATE_ON);
+}
diff --git a/NxWidgets/libnxwidgets/src/cradiobuttongroup.cxx b/NxWidgets/libnxwidgets/src/cradiobuttongroup.cxx
new file mode 100644
index 000000000..b1d75f625
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cradiobuttongroup.cxx
@@ -0,0 +1,344 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cradiobutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cradiobuttongroup.hxx"
+#include "cradiobutton.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CLabel Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor. Note that the group determines its width and height
+ * from the position and dimensions of its children.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the group.
+ * @param y The y coordinate of the group.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CRadioButtonGroup::CRadioButtonGroup(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, 0, 0, WIDGET_BORDERLESS, style)
+{
+ m_widgetControl = pWidgetControl;
+ m_selectedWidget = (CRadioButton *)NULL;
+}
+
+/**
+ * Simple method for adding a new radio button to the group.
+ * This should be used in preference to the usual addWidget() method,
+ * as this method automatically resizes the group.
+ *
+ * @param x The x coordinate of the new button, relative to this
+ * widget.
+ * @param y The y coordinate of the new button, relative to this
+ * widget.
+ * @param width The width of the new button.
+ * @param height The height of the new button.
+ */
+
+CRadioButton *CRadioButtonGroup::newRadioButton(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+{
+ CRadioButton *newButton = new CRadioButton(m_widgetControl, x, y, width, height, &m_style);
+ newButton->addWidgetEventHandler(this);
+ addWidget(newButton);
+
+ // Do we need to resize?
+
+ nxgl_coord_t newWidth = getWidth();
+ nxgl_coord_t newHeight = getHeight();
+
+ if (newWidth < x + width)
+ {
+ newWidth = x + width;
+ }
+
+ if (newHeight < y + height)
+ {
+ newHeight = y + height;
+ }
+
+ resize(newWidth, newHeight);
+ return newButton;
+}
+
+/**
+ * Gets a pointer to the selected widget.
+ *
+ * @return Pointer to the selected widget.
+ */
+
+const CRadioButton *CRadioButtonGroup::getSelectedWidget(void) const
+{
+ return (CRadioButton *)m_selectedWidget;
+}
+
+/**
+ * Gets the index of the selected widget.
+ *
+ * @return The index of the selected widget.
+ */
+
+const int CRadioButtonGroup::getSelectedIndex(void) const
+{
+ for (int i = 0; i < m_children.size(); i++)
+ {
+ if (((CRadioButton*)m_children[i]) == m_selectedWidget)
+ {
+ return i;
+ }
+ }
+
+ // Nothing selected
+
+ return -1;
+}
+
+/**
+ * Sets the selected radio button to the supplied widget.
+ *
+ * @param widget The radio button to select.
+ */
+
+void CRadioButtonGroup::setSelectedWidget(CRadioButton* widget)
+{
+ if (m_selectedWidget != widget)
+ {
+ if (m_selectedWidget != NULL)
+ {
+ m_selectedWidget->setState(CRadioButton::RADIO_BUTTON_STATE_OFF);
+ }
+
+ m_selectedWidget = widget;
+
+ if (m_selectedWidget != NULL)
+ {
+ m_selectedWidget->setState(CRadioButton::RADIO_BUTTON_STATE_ON);
+ }
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Selects the widget at the specified index.
+ *
+ * @param index The index of the widget to select.
+ */
+
+void CRadioButtonGroup::setSelectedIndex(int index)
+{
+ if (index < m_children.size())
+ {
+ setSelectedWidget((CRadioButton*)m_children[index]);
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the
+ * widget's parent. Value is based on the length of the largest string
+ * in the set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CRadioButtonGroup::getPreferredDimensions(CRect& rect) const
+{
+ nxgl_coord_t width = 0;
+ nxgl_coord_t height = 0;
+
+ if (!m_flags.borderless)
+ {
+ width = m_borderSize.left + m_borderSize.right;
+ height = m_borderSize.top + m_borderSize.bottom;
+ }
+
+ nxgl_coord_t widgetX = 0;
+ nxgl_coord_t widgetY = 0;
+
+ nxgl_coord_t maxX = 0;
+ nxgl_coord_t maxY = 0;
+
+ // Locate largest x and y coords within children
+
+ for (int i = 0; i < m_children.size(); ++i)
+ {
+ widgetX = m_children[i]->getX() + m_children[i]->getWidth();
+ widgetY = m_children[i]->getY() + m_children[i]->getHeight();
+
+ if (widgetX > maxX)
+ {
+ maxX = widgetX;
+ }
+
+ if (widgetY > maxY)
+ {
+ maxY = widgetY;
+ }
+ }
+
+ rect.setX(m_rect.getX());
+ rect.setY(m_rect.getY());
+ rect.setWidth(width + maxX - getX());
+ rect.setHeight(height + maxY - getY());
+}
+
+/**
+ * Handle a mouse click event.
+ *
+ * @param e The event data.
+ */
+
+void CRadioButtonGroup::handleClickEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseClickEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handle a mouse double-click event.
+ *
+ * @param e The event data.
+ */
+
+void CRadioButtonGroup::handleDoubleClickEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseDoubleClickEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handle a mouse button release event that occurred within the bounds of
+ * the source widget.
+ * @param e The event data.
+ */
+
+void CRadioButtonGroup::handleReleaseEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseReleaseEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handle a mouse button release event that occurred outside the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+void CRadioButtonGroup::handleReleaseOutsideEvent(const CWidgetEventArgs &e)
+{
+ // Child raised a release outside event, but we need to raise a different
+ // event if the release occurred within the bounds of this parent widget
+
+ if (checkCollision(e.getX(), e.getY()))
+ {
+ m_widgetEventHandlers->raiseReleaseEvent(e.getX(), e.getY());
+ }
+ else
+ {
+ m_widgetEventHandlers->raiseReleaseOutsideEvent(e.getX(), e.getY());
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CRadioButtonGroup::drawContents(CGraphicsPort *port)
+{
+ port->drawFilledRect(getX(), getY(), getWidth(), getHeight(), getBackgroundColor());
+}
diff --git a/NxWidgets/libnxwidgets/src/crect.cxx b/NxWidgets/libnxwidgets/src/crect.cxx
new file mode 100644
index 000000000..8e0ed2cd4
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/crect.cxx
@@ -0,0 +1,380 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cbgwindow.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "crect.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ */
+
+CRect::CRect(void)
+{
+ m_pos.x = 0;
+ m_pos.y = 0;
+ m_size.w = 0;
+ m_size.h = 0;
+}
+
+/**
+ * Constructor.
+ *
+ * @param x The x coordinate of the rect.
+ * @param y The y coordinate of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+
+CRect::CRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
+{
+ m_pos.x = x;
+ m_pos.y = y;
+ m_size.w = width;
+ m_size.h = height;
+}
+
+/**
+ * Constructor.
+ *
+ * @param rect Pointer to an NX rectangle
+ */
+
+CRect::CRect(FAR const nxgl_rect_s *rect)
+{
+ setNxRect(rect);
+}
+
+/**
+ * Copy constructor.
+ *
+ * @param rect CRect to copy.
+ */
+
+CRect::CRect(const CRect &rect)
+{
+ m_pos.x = rect.getX();
+ m_pos.y = rect.getY();
+ m_size.w = rect.getWidth();
+ m_size.h = rect.getHeight();
+}
+
+/**
+ * Create a rect object from the supplied coordinates.
+ *
+ * @param x1 The x coordinate of the rect's top-left corner.
+ * @param y1 The y coordinate of the rect's top-left corner.
+ * @param x2 The x coordinate of the rect's bottom-right corner.
+ * @param y2 The y coordinate of the rect's bottom-right corner.
+ * @return A new rect.
+ */
+
+CRect fromCoordinates(nxgl_coord_t x1, nxgl_coord_t y1,
+ nxgl_coord_t x2, nxgl_coord_t y2)
+{
+ // Ensure x2 is the larger value
+
+ if (x2 < x1)
+ {
+ nxgl_coord_t swap = x1;
+ x1 = x2;
+ x2 = swap;
+ }
+ nxgl_coord_t width = x2 - x1 + 1;
+
+ // Ensure y2 is the larger value
+
+ if (y2 < y1)
+ {
+ nxgl_coord_t swap = y1;
+ y1 = y2;
+ y2 = swap;
+ }
+ nxgl_coord_t height = y2 - y1 + 1;
+
+ // Create the CRect instance
+
+ return CRect(x1, y1, width, height);
+}
+
+/**
+ * Set the x coordinate of the rect's bottom-right corner. If x2 is less
+ * than the rect's current x coordinate the method automatically adjusts
+ * the coordinates so that the rect's width is never negative. Changing this
+ * property will change the width of the rect.
+ *
+ * @param x2 The x coordinate of the rect's bottom-right corner.
+ */
+
+void CRect::setX2(nxgl_coord_t x2)
+{
+ // Ensure that x contains the smaller value
+
+ if (x2 < m_pos.x)
+ {
+ nxgl_coord_t swap = m_pos.x;
+ m_pos.x = x2;
+ x2 = swap;
+ }
+
+ // Then set the width
+
+ m_size.w = x2 - m_pos.x + 1;
+}
+
+/**
+ * Set the y coordinate of the rect's bottom-right corner. If y2 is less
+ * than the rect's current y coordinate the method automatically adjusts
+ * the coordinates so that the rect's height is never negative. Changing this
+ * property will change the height of the rect.
+ *
+ * @param y2 The y coordinate of the rect's bottom-right corner.
+ */
+
+void CRect::setY2(nxgl_coord_t y2)
+{
+ // Ensure that y contains the smaller value
+
+ if (y2 < m_pos.y)
+ {
+ nxgl_coord_t swap = m_pos.y;
+ m_pos.y = y2;
+ y2 = swap;
+ }
+
+ // Then set the height
+
+ m_size.h = y2 - m_pos.y + 1;
+}
+
+/**
+ * Populates dest with a rectangle representating the intersection
+ * of this rectangle and rect.
+ *
+ * @param rect The rectangle to intersect with this.
+ * @param dest The destination rectangle.
+ */
+
+void CRect::getIntersect(const CRect &rect, CRect &dest) const
+{
+ nxgl_coord_t x1 = ngl_max(m_pos.x, rect.getX());
+ nxgl_coord_t y1 = ngl_max(m_pos.y, rect.getY());
+ nxgl_coord_t x2 = ngl_min(getX2(), rect.getX2());
+ nxgl_coord_t y2 = ngl_min(getY2(), rect.getY2());
+
+ dest.setX(x1);
+ dest.setY(y1);
+ dest.setWidth(x2 - x1 + 1);
+ dest.setHeight(y2 - y1 + 1);
+}
+
+/**
+ * Populates dest with a rectangle representating the smallest
+ * rectangle that contains this rectangle and rect.
+ *
+ * @param rect The rectangle to add to this.
+ * @param dest The destination rectangle.
+ */
+
+void CRect::getAddition(const CRect &rect, CRect &dest) const
+{
+
+ nxgl_coord_t x1 = ngl_min(m_pos.x, rect.getX());
+ nxgl_coord_t y1 = ngl_min(m_pos.y, rect.getY());
+ nxgl_coord_t x2 = ngl_max(getX2(), rect.getX2());
+ nxgl_coord_t y2 = ngl_max(getY2(), rect.getY2());
+
+ dest.setX(x1);
+ dest.setY(y1);
+ dest.setWidth(x2 - x1 + 1);
+ dest.setHeight(y2 - y1 + 1);
+}
+
+/**
+ * Clips this rect to the region that intersects the supplied rect.
+ *
+ * @param rect CRect to intersect.
+ */
+
+void CRect::clipToIntersect(const CRect &rect)
+{
+ CRect clipped;
+ getIntersect(rect, clipped);
+
+ setX(clipped.getX());
+ setY(clipped.getY());
+ setWidth(clipped.getWidth());
+ setHeight(clipped.getHeight());
+}
+
+/**
+ * Expands this rect so that it includes the area described by the supplied
+ * rect.
+ *
+ * @param rect CRect to include.
+ */
+
+void CRect::expandToInclude(const CRect& rect)
+{
+ CRect addition;
+ getAddition(rect, addition);
+
+ setX(addition.getX());
+ setY(addition.getY());
+ setWidth(addition.getWidth());
+ setHeight(addition.getHeight());
+}
+
+/**
+ * Check if the supplied rect intersects this.
+ *
+ * @param rect CRect to check for intersection with this.
+ * @return True if the rect intersects this; false if not.
+ */
+
+bool CRect::intersects(const CRect &rect) const
+{
+ return ((m_pos.x + m_size.w > rect.getX()) &&
+ (m_pos.y + m_size.h > rect.getY()) &&
+ (m_pos.x < rect.getX() + rect.getWidth()) &&
+ (m_pos.y < rect.getY() + rect.getHeight()));
+}
+
+/**
+ * Check if the rect contains the supplied point.
+ *
+ * @param x X coordinate of the point.
+ * @param y Y coordinate of the point.
+ * @return True if the rect contains the point; false if not.
+ */
+
+bool CRect::contains(nxgl_coord_t x, nxgl_coord_t y) const
+{
+ return ((x >= m_pos.x) && (y >= m_pos.y) &&
+ (x < m_pos.x + m_size.w) && (y < m_pos.y + m_size.h));
+}
+
+/**
+ * Copy the properties of this rect to the destination rect.
+ *
+ * @param dest Destination rect to copy to.
+ */
+
+void CRect::copyTo(CRect &dest) const
+{
+ dest.setX(m_pos.x);
+ dest.setY(m_pos.y);
+ dest.setWidth(m_size.w);
+ dest.setHeight(m_size.h);
+}
+
+/**
+ * Overloaded & operator. Returns the intersect of this rectangle and the
+ * rectangle passed as the "rect" argument".
+ *
+ * @param rect The rectangle to intersect with this.
+ */
+
+CRect CRect::operator&(const CRect &rect)
+{
+ CRect dest;
+ getIntersect(rect, dest);
+ return dest;
+}
+
+/**
+ * Overloaded + operator. Returns the smallest rectangle that can contain
+ * this rectangle and the rectangle passed as the "rect" argument".
+ *
+ * @param rect The rectangle to add to this.
+ */
+
+CRect CRect::operator+(const CRect &rect)
+{
+ CRect dest;
+ getAddition(rect, dest);
+ return dest;
+}
diff --git a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx
new file mode 100644
index 000000000..99f7fdbba
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx
@@ -0,0 +1,437 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/crlepalettebitmap.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "crlepalettebitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param bitmap The bitmap structure being wrapped.
+ */
+
+CRlePaletteBitmap::CRlePaletteBitmap(const struct SRlePaletteBitmap *bitmap)
+{
+ m_bitmap = bitmap;
+ m_lut = bitmap->lut[0];
+ startOfImage();
+}
+
+/**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's width.
+ */
+
+const uint8_t CRlePaletteBitmap::getColorFormat(void) const
+{
+ return m_bitmap->fmt;
+}
+
+/**
+ * Get the bitmap's color format.
+ *
+ * @return The bitmap's color format.
+ */
+
+const uint8_t CRlePaletteBitmap::getBitsPerPixel(void) const
+{
+ return m_bitmap->bpp;
+}
+
+/**
+ * Get the bitmap's width (in pixels/columns).
+ *
+ * @return The bitmap's pixel depth.
+ */
+
+const nxgl_coord_t CRlePaletteBitmap::getWidth(void) const
+{
+ return m_bitmap->width;
+}
+
+/**
+ * Get the bitmap's height (in rows).
+ *
+ * @return The bitmap's height.
+ */
+
+const nxgl_coord_t CRlePaletteBitmap::getHeight(void) const
+{
+ return m_bitmap->height;
+}
+
+/**
+ * Get the bitmap's width (in bytes).
+ *
+ * @return The bitmap's width.
+ */
+
+const nxgl_coord_t CRlePaletteBitmap::getStride(void) const
+{
+ // This only works if the bpp is an even multiple of 8-bit bytes
+
+ return (m_bitmap->width * m_bitmap->bpp) >> 3;
+}
+
+/**
+ * Use the colors associated with a selected image.
+ *
+ * @param selected. true: Use colors for a selected widget,
+ * false: Use normal (default) colors.
+ */
+
+void CRlePaletteBitmap::setSelected(bool selected)
+{
+ m_lut = m_bitmap->lut[selected ? 1 : 0];
+}
+
+/**
+ * Get one row from the bit map image using the selected LUT.
+ *
+ * @param x The offset into the row to get
+ * @param y The row number to get
+ * @param width The number of pixels to get from the row
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @param True if the run was returned successfully.
+ */
+
+bool CRlePaletteBitmap::getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
+ FAR void *data)
+{
+ // Check ranges. Casts to unsigned int are ugly but permit one-sided comparisons
+
+ if (((unsigned int)x < (unsigned int)width) &&
+ ((unsigned int)(x + width) <= (unsigned int)m_bitmap->width))
+ {
+ // Seek to the requested row
+
+ if (!seekRow(y))
+ {
+ return false;
+ }
+
+ // Offset to the starting X position
+
+ if (x > 0)
+ {
+ if (!skipPixels(x))
+ {
+ return false;
+ }
+ }
+
+ // Then copy the requested number of pixels
+
+ return copyPixels(width, data);
+ }
+
+ return false;
+}
+
+/**
+ * Reset to the beginning of the image
+ */
+
+void CRlePaletteBitmap::startOfImage(void)
+{
+ m_row = 0;
+ m_col = 0;
+ m_rle = &m_bitmap->data[0];
+ m_remaining = m_rle->npixels;
+}
+
+/**
+ * Advance position data ahead. Called after npixels have
+ * have been consume.
+ *
+ * @param npixels The number of pixels to advance
+ * @return False if this goes beyond the end of the image
+ */
+
+bool CRlePaletteBitmap::advancePosition(nxgl_coord_t npixels)
+{
+ // Advance to the next column after consuming 'npixels' on this colum
+ int newcol = m_col + npixels;
+
+ // Have we consumed the entire row?
+
+ while (newcol >= m_bitmap->width)
+ {
+ // Advance to the next row
+
+ newcol -= m_bitmap->width;
+ m_row++;
+
+ // If we still have pixels to account for but we have exceeded the
+ // the size of the bitmap, then return false
+
+ if (newcol > 0 && m_row >= m_bitmap->height)
+ {
+ return false;
+ }
+ }
+
+ m_col = newcol;
+ return true;
+}
+
+/**
+ * Seek ahead the specific number of pixels -- discarding
+ * and advancing.
+ *
+ * @param npixels The number of pixels to skip
+ */
+
+bool CRlePaletteBitmap::skipPixels(nxgl_coord_t npixels)
+{
+ do
+ {
+ // Skip values in the current RLE entry
+
+ if (m_remaining > npixels)
+ {
+ // Subtract from the number of pixels remaining
+
+ m_remaining -= npixels;
+ return advancePosition(npixels);
+ }
+
+ // Not enough (or just enough) in the current entry. Take what we
+ // can from the current entry and move to the next entry
+
+ npixels -= m_remaining;
+ if (!advancePosition(m_remaining))
+ {
+ return false;
+ }
+
+ m_rle++;
+ m_remaining = m_rle->npixels;
+ }
+ while (npixels > 0);
+
+ return true;
+}
+
+/** Seek to the beginning of the next row
+ *
+ * @return False if this was the last row of the image
+ */
+
+bool CRlePaletteBitmap::nextRow(void)
+{
+ return skipPixels(m_bitmap->width - m_col);
+}
+
+/** Seek to the beignning specific row
+ *
+ * @param row The row number to seek to
+ * @return False if this goes beyond the end of the image
+ */
+
+bool CRlePaletteBitmap::seekRow(nxgl_coord_t row)
+{
+ // Is the current position already past the requested position?
+
+ if (row < m_row || (row == m_row && m_col != 0))
+ {
+ // Yes.. rewind to the beginning of the image
+
+ startOfImage();
+ }
+
+ // Seek ahead, row-by-row until we are at the beginning of
+ // the requested row
+
+ while (m_row < row)
+ {
+ if (!nextRow())
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/** Copy the pixels from the current RLE entry the specified number of times.
+ *
+ * @param npixels The number of pixels to copy. Must be less than or equal
+ * to m_remaining (not checked here, must be handled by higher level code).
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ */
+
+void CRlePaletteBitmap::copyColor(nxgl_coord_t npixels, FAR void *data)
+{
+ // Right now, only a single pixel depth is supported
+
+ nxwidget_pixel_t *nxlut = (nxwidget_pixel_t *)m_lut;
+ nxwidget_pixel_t color = nxlut[m_rle->lookup];
+
+ // Copy the requested pixels
+
+ FAR nxwidget_pixel_t *dest = (FAR nxwidget_pixel_t *)data;
+ for (int i = 0; i < npixels; i++)
+ {
+ *dest++ = color;
+ }
+
+ // Adjust the number of pixels remaining in the RLE entry
+
+ m_remaining -= npixels;
+}
+
+/** Copy pixels from the current position
+ *
+ * @param npixels The number of pixels to copy
+ * @param data The memory location provided by the caller
+ * in which to return the data. This should be at least
+ * (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
+ * and properly aligned for the pixel color format.
+ * @return False if this goes beyond the end of the image
+ */
+
+bool CRlePaletteBitmap::copyPixels(nxgl_coord_t npixels, FAR void *data)
+{
+ FAR nxwidget_pixel_t *ptr = (FAR nxwidget_pixel_t *)data;
+ do
+ {
+ // Get values in the current RLE entry
+
+ if (m_remaining > npixels)
+ {
+ // Copy npixels from the current RLE entry (it won't be empty)
+
+ copyColor(npixels, (FAR void *)ptr);
+
+ // Then advance row/column position information
+
+ return advancePosition(npixels);
+ }
+
+ // Not enough (or just enough) in the current entry. Take what we
+ // can from the current entry and move to the next entry
+
+ uint8_t nTaken = m_remaining; // Temporary.. copyColor clobbers m_remaining
+ npixels -= m_remaining; // New number of pixels needed
+
+ // Copy all of the colors available in this RLE entry
+
+ copyColor(m_remaining, (FAR void *)ptr);
+
+ // Then advance row/column position information
+
+ if (!advancePosition(nTaken))
+ {
+ return false;
+ }
+
+ // Advance the destination pointer by the number of pixels taken
+ // from the RLE entry
+
+ ptr += nTaken;
+
+ // Then move to the next RLE entry
+
+ m_rle++;
+ m_remaining = m_rle->npixels;
+ }
+ while (npixels > 0);
+
+ return true;
+}
diff --git a/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx b/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx
new file mode 100644
index 000000000..13e33815d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollbarhorizontal.cxx
@@ -0,0 +1,402 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollbarhorizontal.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "islider.hxx"
+#include "cscrollbarhorizontal.hxx"
+#include "cglyphbutton.hxx"
+#include "csliderhorizontal.hxx"
+#include "cnxtimer.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementation
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control instance for the window.
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScrollbarHorizontal::CScrollbarHorizontal(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle* style)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_BORDERLESS, style)
+{
+ m_buttonWidth = 10;
+
+ // Create the children
+
+ m_slider = new CSliderHorizontal(pWidgetControl, m_buttonWidth, 0,
+ width - (m_buttonWidth << 1), height);
+ m_slider->addWidgetEventHandler(this);
+
+ // Set up the left glyph button
+
+ m_leftButton = new CGlyphButton(pWidgetControl,
+ 0, 0,
+ m_buttonWidth, height,
+ 0, 0,
+ &g_arrowLeft, &g_arrowLeft, &m_style);
+ m_leftButton->addWidgetEventHandler(this);
+
+ // Set up the right glyph button
+
+ m_rightButton = new CGlyphButton(pWidgetControl,
+ width - m_buttonWidth, 0,
+ m_buttonWidth, height,
+ 0, 0,
+ &g_arrowRight, &g_arrowRight, &m_style);
+ m_rightButton->addWidgetEventHandler(this);
+
+ // Create timer
+
+ m_scrollTimeout = 10;
+ m_timer = new CNxTimer(pWidgetControl, m_scrollTimeout, true);
+ m_timer->addWidgetEventHandler(this);
+
+ addWidget(m_slider);
+ addWidget(m_leftButton);
+ addWidget(m_rightButton);
+ addWidget(m_timer);
+}
+
+/**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+const nxgl_coord_t CScrollbarHorizontal::getMinimumValue(void) const
+{
+ return m_slider->getMinimumValue();
+}
+
+/**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+const nxgl_coord_t CScrollbarHorizontal::getMaximumValue(void) const
+{
+ return m_slider->getMaximumValue();
+}
+
+/**
+ * Get the current value of the slider.
+ *
+ * @return The current slider value.
+ */
+
+const nxgl_coord_t CScrollbarHorizontal::getValue(void) const
+{
+ return m_slider->getValue();
+}
+
+/**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+const nxgl_coord_t CScrollbarHorizontal::getPageSize(void) const
+{
+ return m_slider->getPageSize();
+}
+
+/**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+void CScrollbarHorizontal::setMinimumValue(const nxgl_coord_t value)
+{
+ m_slider->setMinimumValue(value);
+}
+
+/**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+void CScrollbarHorizontal::setMaximumValue(const nxgl_coord_t value)
+{
+ m_slider->setMaximumValue(value);
+}
+
+/**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+void CScrollbarHorizontal::setValue(const nxgl_coord_t value)
+{
+ m_slider->setValue(value);
+}
+
+/**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+void CScrollbarHorizontal::setValueWithBitshift(const int32_t value)
+{
+ m_slider->setValueWithBitshift(value);
+}
+
+/**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+void CScrollbarHorizontal::setPageSize(nxgl_coord_t pageSize)
+{
+ m_slider->setPageSize(pageSize);
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarHorizontal::handleActionEvent(const CWidgetEventArgs &e)
+{
+ // Check which widget fired the event
+
+ if (e.getSource() == m_timer)
+ {
+ // Which widget is clicked?
+
+ if (m_leftButton->isClicked())
+ {
+ // Move the grip left
+
+ m_slider->setValue(m_slider->getValue() - m_slider->getMinimumStep());
+ }
+ else if (m_rightButton->isClicked())
+ {
+ // Move the grip right
+
+ m_slider->setValue(m_slider->getValue() + m_slider->getMinimumStep());
+ }
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarHorizontal::handleClickEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() == m_leftButton)
+ {
+ // Start the timer
+
+ m_timer->start();
+
+ // Move the grip left
+
+ m_slider->setValue(m_slider->getValue() - m_slider->getMinimumStep());
+ }
+ else if (e.getSource() == m_rightButton)
+ {
+ // Start the timer
+
+ m_timer->start();
+
+ // Move the grip right
+
+ m_slider->setValue(m_slider->getValue() + m_slider->getMinimumStep());
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarHorizontal::handleReleaseEvent(const CWidgetEventArgs &e)
+{
+ if ((e.getSource() == m_leftButton) || (e.getSource() == m_rightButton))
+ {
+ // Stop the timer
+
+ m_timer->stop();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarHorizontal::handleReleaseOutsideEvent(const CWidgetEventArgs &e)
+{
+ if ((e.getSource() == m_leftButton) || (e.getSource() == m_rightButton))
+ {
+ // Stop the timer
+
+ m_timer->stop();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarHorizontal::handleValueChangeEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() == m_slider)
+ {
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Resize the scrollbar to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CScrollbarHorizontal::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Remember current values
+
+ nxgl_coord_t value = getValue();
+ bool events = raisesEvents();
+
+ // Disable event raising
+
+ setRaisesEvents(false);
+
+ // Resize and move children
+
+ m_slider->resize(width - (m_buttonWidth << 1), height);
+ m_leftButton->moveTo(m_slider->getWidth(), 0);
+ m_rightButton->moveTo(m_slider->getWidth() + m_buttonWidth, 0);
+
+ // Set back to current value
+
+ setValue(value);
+
+ // Reset event raising
+
+ setRaisesEvents(events);
+}
diff --git a/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx b/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx
new file mode 100644
index 000000000..f21cd7766
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx
@@ -0,0 +1,438 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cscrollbarpanel.hxx"
+#include "cbutton.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags The usual widget flags.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScollbarPanel::CScollbarPanel(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags, CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, width, height, flags, style)
+{
+ m_scrollbarWidth = 10;
+ m_scrollbarHeight = 10;
+ m_hasVerticalScrollbar = true;
+ m_hasHorizontalScrollbar = true;
+
+ m_borderSize.top = 0;
+ m_borderSize.right = 0;
+ m_borderSize.left = 0;
+ m_borderSize.bottom = 0;
+ m_flags.borderless = true;
+
+ m_widgetControl = pWidgetControl;
+ m_panel = (CScrollingPanel *)NULL;
+ m_scrollbarVertical = (CScrollbarVertical *)NULL;
+ m_scrollbarHorizontal = (CScrollbarHorizontal *)NULL;
+
+ buildUI();
+}
+
+/**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+void CScollbarPanel::scroll(int32_t dx, int32_t dy)
+{
+ m_panel->scroll(dx, dy);
+}
+
+/**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+void CScollbarPanel::jump(int32_t x, int32_t y)
+{
+ m_panel->jump(x, y);
+}
+
+/**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+void CScollbarPanel::setAllowsVerticalScroll(bool allow)
+{
+ m_panel->setAllowsVerticalScroll(allow);
+
+ if (m_hasVerticalScrollbar)
+ {
+ if (allow)
+ {
+ m_scrollbarVertical->enable();
+ }
+ else
+ {
+ m_scrollbarVertical->disable();
+ }
+ }
+}
+
+/**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+void CScollbarPanel::setAllowsHorizontalScroll(bool allow)
+{
+ m_panel->setAllowsHorizontalScroll(allow);
+
+ if (m_hasHorizontalScrollbar)
+ {
+ if (allow)
+ {
+ m_scrollbarHorizontal->enable();
+ }
+ else
+ {
+ m_scrollbarHorizontal->disable();
+ }
+ }
+}
+
+/**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+void CScollbarPanel::setCanvasWidth(const int32_t width)
+{
+ m_panel->setCanvasWidth(width);
+ m_scrollbarHorizontal->setMaximumValue(width);
+}
+
+/**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+void CScollbarPanel::setCanvasHeight(const int32_t height)
+{
+ m_panel->setCanvasHeight(height);
+ m_scrollbarVertical->setMaximumValue(height);
+}
+
+/**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+bool CScollbarPanel::allowsVerticalScroll(void) const
+{
+ return m_panel->allowsVerticalScroll();
+}
+
+/**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+bool CScollbarPanel::allowsHorizontalScroll(void) const
+{
+ return m_panel->allowsHorizontalScroll();
+}
+
+/**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+const int32_t CScollbarPanel::getCanvasX(void) const
+{
+ return m_panel->getCanvasX();
+}
+
+/**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+const int32_t CScollbarPanel::getCanvasY(void) const
+{
+ return m_panel->getCanvasY();
+}
+
+/**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+const int32_t CScollbarPanel::getCanvasWidth(void) const
+{
+ return m_panel->getCanvasWidth();
+}
+
+/**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+const int32_t CScollbarPanel::getCanvasHeight(void) const
+{
+ return m_panel->getCanvasHeight();
+}
+
+/**
+ * Handle a widget scroll event.
+ *
+ * @param e The event data.
+ */
+
+void CScollbarPanel::handleScrollEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_panel)
+ {
+ if (m_scrollbarVertical != NULL)
+ {
+ m_scrollbarVertical->setRaisesEvents(false);
+ m_scrollbarVertical->setValue(0 - m_panel->getCanvasY());
+ m_scrollbarVertical->setRaisesEvents(true);
+ }
+ else if (m_scrollbarHorizontal != NULL)
+ {
+ m_scrollbarHorizontal->setRaisesEvents(false);
+ m_scrollbarHorizontal->setValue(0 - m_panel->getCanvasX());
+ m_scrollbarHorizontal->setRaisesEvents(true);
+ }
+ }
+ }
+}
+
+/**
+ * Handle a widget value change event.
+ *
+ * @param e The event data.
+ */
+
+void CScollbarPanel::handleValueChangeEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_scrollbarVertical)
+ {
+ if (m_panel != NULL)
+ {
+ m_panel->setRaisesEvents(false);
+ m_panel->jump(m_panel->getCanvasX(), 0 - m_scrollbarVertical->getValue());
+ m_panel->setRaisesEvents(true);
+ }
+ }
+ else if (e.getSource() == m_scrollbarHorizontal)
+ {
+ if (m_panel != NULL)
+ {
+ m_panel->setRaisesEvents(false);
+ m_panel->jump(0 - m_scrollbarHorizontal->getValue(), m_panel->getCanvasY());
+ m_panel->setRaisesEvents(true);
+ }
+ }
+ }
+}
+
+/**
+ * Creates the child widgets.
+ */
+
+void CScollbarPanel::buildUI(void)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ nxgl_coord_t panelWidth = rect.getWidth();
+ if (m_hasVerticalScrollbar)
+ {
+ panelWidth -= m_scrollbarWidth;
+ }
+
+ nxgl_coord_t panelHeight = rect.getHeight();
+ if (m_hasHorizontalScrollbar)
+ {
+ panelHeight -= m_scrollbarHeight;
+ }
+
+ m_panel = new CScrollingPanel(m_widgetControl, rect.getX(), rect.getY(),
+ panelWidth, panelHeight, 0, &m_style);
+ addWidget(m_panel);
+
+ CRect panelRect;
+ m_panel->getClientRect(panelRect);
+
+ // Disable content scrolling by default, as the panel cannot be drawn to
+ // without some additional programmer effort
+
+ m_panel->setContentScrolled(false);
+
+ // Adjust scrollbar dimensions based on scrollbar visibility
+
+ nxgl_coord_t verticalScrollHeight = rect.getHeight();
+ if (m_hasHorizontalScrollbar)
+ {
+ verticalScrollHeight -= m_scrollbarHeight;
+ }
+
+ nxgl_coord_t horizontalScrollWidth = rect.getWidth();
+ if (m_hasVerticalScrollbar)
+ {
+ horizontalScrollWidth -= m_scrollbarWidth;
+ }
+
+ if (m_hasHorizontalScrollbar)
+ {
+ m_scrollbarHorizontal =
+ new CScrollbarHorizontal(m_widgetControl,
+ rect.getX(), rect.getHeight() - m_scrollbarHeight,
+ horizontalScrollWidth, m_scrollbarHeight,
+ &m_style);
+ m_scrollbarHorizontal->setMinimumValue(0);
+ m_scrollbarHorizontal->setMaximumValue(getCanvasWidth());
+ m_scrollbarHorizontal->setPageSize(panelRect.getWidth());
+ m_scrollbarHorizontal->addWidgetEventHandler(this);
+ addWidget(m_scrollbarHorizontal);
+ }
+
+ if (m_hasVerticalScrollbar)
+ {
+ m_scrollbarVertical =
+ new CScrollbarVertical(m_widgetControl,
+ rect.getWidth() - m_scrollbarWidth,
+ rect.getY(), m_scrollbarWidth,
+ verticalScrollHeight, &m_style);
+ m_scrollbarVertical->setMinimumValue(0);
+ m_scrollbarVertical->setMaximumValue(getCanvasHeight());
+ m_scrollbarVertical->setPageSize(panelRect.getHeight());
+ m_scrollbarVertical->addWidgetEventHandler(this);
+ addWidget(m_scrollbarVertical);
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CScollbarPanel::drawContents(CGraphicsPort *port)
+{
+ port->drawFilledRect(0, 0, getWidth(), getHeight(), getBackgroundColor());
+}
diff --git a/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx b/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx
new file mode 100644
index 000000000..76b5c5dec
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollbarvertical.cxx
@@ -0,0 +1,404 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cscrollbarhorizontal.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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cscrollbarvertical.hxx"
+#include "cglyphbutton.hxx"
+#include "cslidervertical.hxx"
+#include "cnxtimer.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementation
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control instance for the window.
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScrollbarVertical::CScrollbarVertical(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_BORDERLESS, style)
+{
+ m_buttonHeight = 10;
+
+ // Create the children
+
+ m_slider = new CSliderVertical(pWidgetControl, 0, m_buttonHeight,
+ width, height - (m_buttonHeight << 1));
+ m_slider->addWidgetEventHandler(this);
+
+ // Setup the up button
+
+ m_upButton = new CGlyphButton(pWidgetControl,
+ 0, 0,
+ width, m_buttonHeight,
+ 0, 0,
+ &g_arrowUp, &g_arrowUp, &m_style);
+ m_upButton->addWidgetEventHandler(this);
+
+ // Setup the down button
+
+ m_downButton = new CGlyphButton(pWidgetControl,
+ 0, height - m_buttonHeight,
+ width, m_buttonHeight,
+ 0, 0,
+ &g_arrowDown, &g_arrowDown, &m_style);
+ m_downButton->addWidgetEventHandler(this);
+
+ // Create timer
+
+ m_scrollTimeout = 10;
+
+ m_timer = new CNxTimer(pWidgetControl, m_scrollTimeout, true);
+ m_timer->addWidgetEventHandler(this);
+
+ addWidget(m_slider);
+ addWidget(m_upButton);
+ addWidget(m_downButton);
+ addWidget(m_timer);
+}
+
+/**
+ * Get the smallest value that the slider can represent.
+ *
+ * @return The smallest value.
+ */
+
+const nxgl_coord_t CScrollbarVertical::getMinimumValue(void) const
+{
+ return m_slider->getMinimumValue();
+}
+
+/**
+ * Get the largest value that the slider can represent.
+ *
+ * @return The largest value.
+ */
+
+const nxgl_coord_t CScrollbarVertical::getMaximumValue(void) const
+{
+ return m_slider->getMaximumValue();
+}
+
+/**
+ * Get the current value of the slider.
+ *
+ * @return The current slider value.
+ */
+
+const nxgl_coord_t CScrollbarVertical::getValue(void) const
+{
+ return m_slider->getValue();
+}
+
+/**
+ * Get the value represented by the height of the grip.
+ * For sliders, this would typically be 1 (so each new
+ * grip position is worth 1). For scrollbars, this
+ * would be the height of the scrolling widget.
+ *
+ * @return The page size.
+ */
+
+const nxgl_coord_t CScrollbarVertical::getPageSize(void) const
+{
+ return m_slider->getPageSize();
+}
+
+/**
+ * Set the smallest value that the slider can represent.
+ *
+ * @param value The smallest value.
+ */
+
+void CScrollbarVertical::setMinimumValue(const nxgl_coord_t value)
+{
+ m_slider->setMinimumValue(value);
+}
+
+/**
+ * Set the largest value that the slider can represent.
+ *
+ * @param value The largest value.
+ */
+
+void CScrollbarVertical::setMaximumValue(const nxgl_coord_t value)
+{
+ m_slider->setMaximumValue(value);
+}
+
+/**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+void CScrollbarVertical::setValue(const nxgl_coord_t value)
+{
+ m_slider->setValue(value);
+}
+
+/**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+void CScrollbarVertical::setValueWithBitshift(const int32_t value)
+{
+ m_slider->setValueWithBitshift(value);
+}
+
+/**
+ * Set the page size represented by the grip.
+ *
+ * @param pageSize The page size.
+ * @see getPageSize().
+ */
+
+void CScrollbarVertical::setPageSize(nxgl_coord_t pageSize)
+{
+ m_slider->setPageSize(pageSize);
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarVertical::handleActionEvent(const CWidgetEventArgs &e)
+{
+ // Check which widget fired the event
+
+ if (e.getSource() == m_timer)
+ {
+ // Which widget is clicked?
+
+ if (m_upButton->isClicked())
+ {
+ // Move the grip up
+
+ m_slider->setValue(m_slider->getValue() - m_slider->getMinimumStep());
+ }
+ else if (m_downButton->isClicked())
+ {
+ // Move the grip down
+
+ m_slider->setValue(m_slider->getValue() + m_slider->getMinimumStep());
+ }
+
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarVertical::handleClickEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() == m_upButton)
+ {
+ // Start the timer
+
+ m_timer->start();
+
+ // Move the grip up
+
+ m_slider->setValue(m_slider->getValue() - m_slider->getMinimumStep());
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ else if (e.getSource() == m_downButton)
+ {
+ // Start the timer
+
+ m_timer->start();
+
+ // Move the grip down
+
+ m_slider->setValue(m_slider->getValue() + m_slider->getMinimumStep());
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarVertical::handleReleaseEvent(const CWidgetEventArgs &e)
+{
+ if ((e.getSource() == m_upButton) || (e.getSource() == m_downButton))
+ {
+ // Stop the timer
+
+ m_timer->stop();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarVertical::handleReleaseOutsideEvent(const CWidgetEventArgs &e)
+{
+ if ((e.getSource() == m_upButton) || (e.getSource() == m_downButton))
+ {
+ // Stop the timer
+
+ m_timer->stop();
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CScrollbarVertical::handleValueChangeEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() == m_slider)
+ {
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+}
+
+/**
+ * Resize the scrollbar to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CScrollbarVertical::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Remember current values
+
+ nxgl_coord_t value = getValue();
+ bool events = raisesEvents();
+
+ // Disable event raising
+
+ setRaisesEvents(false);
+
+ // Resize and move children
+
+ m_slider->resize(width, height - (m_buttonHeight << 1));
+ m_upButton->moveTo(0, m_slider->getHeight());
+ m_downButton->moveTo(0, m_slider->getHeight() + m_buttonHeight);
+
+ // Set back to current value
+
+ setValue(value);
+
+ // Reset event raising
+
+ setRaisesEvents(events);
+}
diff --git a/NxWidgets/libnxwidgets/src/cscrollinglistbox.cxx b/NxWidgets/libnxwidgets/src/cscrollinglistbox.cxx
new file mode 100644
index 000000000..e0d041d34
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollinglistbox.cxx
@@ -0,0 +1,415 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cscrollinglistbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cscrollinglistbox.hxx"
+#include "cscrollbarvertical.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScrollingListBox::CScrollingListBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, width, height, 0, style)
+{
+ m_scrollbarWidth = 10;
+
+ setBorderless(true);
+
+ m_listbox = new CListBox(pWidgetControl, 0, 0, width - m_scrollbarWidth,
+ height, &m_style);
+ m_listbox->addWidgetEventHandler(this);
+
+ // Create scrollbar
+
+ CRect rect;
+ m_listbox->getClientRect(rect);
+ m_scrollbar = new CScrollbarVertical(pWidgetControl, width - m_scrollbarWidth,
+ 0, m_scrollbarWidth, height, &m_style);
+ m_scrollbar->setMinimumValue(0);
+ m_scrollbar->setMaximumValue(0);
+ m_scrollbar->setPageSize(rect.getHeight() / m_listbox->getOptionHeight());
+ m_scrollbar->addWidgetEventHandler(this);
+
+ // Add children to child array
+
+ addWidget(m_listbox);
+ addWidget(m_scrollbar);
+}
+
+/**
+ * Add a new option to the widget using default colors.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ */
+
+void CScrollingListBox::addOption(const CNxString &text, const uint32_t value)
+{
+ m_listbox->addOption(text, value);
+ m_scrollbar->setMaximumValue(m_listbox->getOptionCount() - 1);
+}
+
+/**
+ * Add an option to the widget.
+ *
+ * @param option The option to add.
+ */
+
+void CScrollingListBox::addOption(CListBoxDataItem *item)
+{
+ m_listbox->addOption(item);
+ m_scrollbar->setMaximumValue(m_listbox->getOptionCount() - 1);
+}
+
+/**
+ * Add a new option to the widget.
+ *
+ * @param text Text to show in the option.
+ * @param value The value of the option.
+ * @param normalTextColor Color to draw the text with when not selected.
+ * @param normalBackColor Color to draw the background with when not selected.
+ * @param selectedTextColor Color to draw the text with when selected.
+ * @param selectedBackColor Color to draw the background with when selected.
+ */
+
+void CScrollingListBox::addOption(const CNxString &text, const uint32_t value,
+ const nxwidget_pixel_t normalTextColor,
+ const nxwidget_pixel_t normalBackColor,
+ const nxwidget_pixel_t selectedTextColor,
+ const nxwidget_pixel_t selectedBackColor)
+{
+ m_listbox->addOption(text, value, normalTextColor, normalBackColor,
+ selectedTextColor, selectedBackColor);
+ m_scrollbar->setMaximumValue(m_listbox->getOptionCount() - 1);
+}
+
+/**
+ * Remove an option from the widget by its index.
+ *
+ * @param index The index of the option to remove.
+ */
+
+void CScrollingListBox::removeOption(const int index)
+{
+ m_listbox->removeOption(index);
+ m_scrollbar->setMaximumValue(m_listbox->getOptionCount() - 1);
+
+ // Reposition grip if necessary
+
+ if (m_scrollbar->getValue() > m_listbox->getOptionCount())
+ {
+ m_scrollbar->setValue(0);
+ }
+}
+
+/**
+ * Remove all options from the widget.
+ */
+
+void CScrollingListBox::removeAllOptions(void)
+{
+ m_listbox->removeAllOptions();
+ m_scrollbar->setMaximumValue(0);
+ m_scrollbar->setValue(0);
+}
+
+/**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+void CScrollingListBox::handleValueChangeEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_scrollbar)
+ {
+ if (m_listbox != NULL)
+ {
+ m_listbox->setRaisesEvents(false);
+ m_listbox->jump(0, 0 - (m_scrollbar->getValue() * m_listbox->getOptionHeight()));
+ m_listbox->setRaisesEvents(true);
+ }
+ }
+ else if (e.getSource() == m_listbox)
+ {
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ }
+}
+
+/**
+ * Handle a widget action event.
+ *
+ * @param e The event data.
+ */
+
+void CScrollingListBox::handleActionEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_listbox)
+ {
+ // Raise action events from list box to event handler
+
+ m_widgetEventHandlers->raiseActionEvent();
+ }
+ }
+}
+
+/**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+void CScrollingListBox::handleScrollEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_listbox)
+ {
+ if (m_scrollbar != NULL)
+ {
+ m_scrollbar->setRaisesEvents(false);
+
+ int value = ((0 - m_listbox->getCanvasY()) << 16) / m_listbox->getOptionHeight();
+
+ m_scrollbar->setValueWithBitshift(value);
+ m_scrollbar->setRaisesEvents(true);
+ }
+ }
+ }
+}
+
+/**
+ * Handle a mouse button click event.
+ *
+ * @param e The event data.
+ */
+
+void CScrollingListBox::handleClickEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseClickEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+void CScrollingListBox::handleDoubleClickEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseDoubleClickEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handle a mouse button release event that occurred within the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+void CScrollingListBox::handleReleaseEvent(const CWidgetEventArgs &e)
+{
+ m_widgetEventHandlers->raiseReleaseEvent(e.getX(), e.getY());
+}
+
+/**
+ * Handle a mouse button release event that occurred outside the bounds of
+ * the source widget.
+ *
+ * @param e The event data.
+ */
+
+void CScrollingListBox::handleReleaseOutsideEvent(const CWidgetEventArgs &e)
+{
+ // Child raised a release outside event, but we need to raise a different
+ // event if the release occurred within the bounds of this parent widget
+
+ if (checkCollision(e.getX(), e.getY()))
+ {
+ m_widgetEventHandlers->raiseReleaseEvent(e.getX(), e.getY());
+ }
+ else
+ {
+ m_widgetEventHandlers->raiseReleaseOutsideEvent(e.getX(), e.getY());
+ }
+}
+
+/**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+void CScrollingListBox::setFont(CNxFont *font)
+{
+ m_style.font = font;
+ m_listbox->setFont(font);
+ m_scrollbar->setFont(font);
+}
+
+/**
+ * Insert the dimensions that this widget wants to have into the rect
+ * passed in as a parameter. All coordinates are relative to the widget's
+ * parent. Value is based on the length of the largest string in the
+ * set of options.
+ *
+ * @param rect Reference to a rect to populate with data.
+ */
+
+void CScrollingListBox::getPreferredDimensions(CRect &rect) const
+{
+ // Get the listbox's preferred dimensions
+
+ m_listbox->getPreferredDimensions(rect);
+
+ // Add on the scrollbar width
+
+ nxgl_coord_t width = rect.getWidth();
+ rect.setWidth(width + m_scrollbarWidth);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CScrollingListBox::drawContents(CGraphicsPort *port)
+{
+ port->drawFilledRect(0, 0, getWidth(), getHeight(), getBackgroundColor());
+}
+
+/**
+ * Resize the listbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CScrollingListBox::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Resize the children
+
+ m_listbox->resize(width - m_scrollbarWidth, height);
+ m_scrollbar->resize(m_scrollbarWidth, height);
+
+ // Adjust scrollbar page size
+
+ CRect rect;
+ getClientRect(rect);
+ m_scrollbar->setPageSize(rect.getHeight() / m_listbox->getOptionHeight());
+
+ // Move the scrollbar
+
+ m_scrollbar->moveTo(width - m_scrollbarWidth, 0);
+}
+
+
+
+
diff --git a/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
new file mode 100644
index 000000000..d3ee40cf9
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
@@ -0,0 +1,320 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cscrollingpanel.hxx"
+#include "cgraphicsport.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the widget.
+ * @param y The y coordinate of the widget.
+ * @param width The width of the widget.
+ * @param height The height of the widget.
+ * @param flags The usual widget flags.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScrollingPanel::CScrollingPanel(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ uint32_t flags, CWidgetStyle* style)
+: CNxWidget(pWidgetControl, x, y, width, height, flags, style)
+{
+ m_widgetControl = pWidgetControl;
+ CRect rect;
+ getClientRect(rect);
+
+ m_canvasWidth = rect.getWidth();
+ m_canvasHeight = rect.getHeight();
+ m_canvasX = 0;
+ m_canvasY = 0;
+
+ setAllowsVerticalScroll(true);
+ setAllowsHorizontalScroll(true);
+ setContentScrolled(true);
+
+ m_flags.permeable = true;
+}
+
+/**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+void CScrollingPanel::scroll(int32_t dx, int32_t dy)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ // Prevent scrolling outside boundaries
+
+ if (m_canvasX + dx < -(m_canvasWidth - rect.getWidth()))
+ {
+ dx = -(m_canvasWidth - rect.getWidth()) - m_canvasX;
+ }
+ else if (m_canvasX + dx > 0)
+ {
+ dx = -m_canvasX;
+ }
+
+ if (m_canvasY + dy < -(m_canvasHeight - rect.getHeight()))
+ {
+ dy = -(m_canvasHeight - rect.getHeight()) - m_canvasY;
+ }
+ else if (m_canvasY + dy > 0)
+ {
+ dy = -m_canvasY;
+ }
+
+ // Prevent scrolling in disallowed planes
+
+ if (!allowsVerticalScroll())
+ {
+ dy = 0;
+ }
+
+ if (!allowsHorizontalScroll())
+ {
+ dx = 0;
+ }
+
+ // Perform scroll if necessary
+
+ if ((dx != 0) || (dy != 0))
+ {
+ // Only scroll if content scrolling is enabled
+
+ if (m_isContentScrolled)
+ {
+ // Perform scroll
+
+ TNxArray<CRect> revealedRects;
+ CGraphicsPort *port = m_widgetControl->getGraphicsPort();
+ port->move(getX(), getY(), dx, dy, rect.getWidth(), rect.getHeight());
+
+ // Adjust the scroll values
+
+ m_canvasY += dy;
+ m_canvasX += dx;
+
+ if (revealedRects.size() > 0)
+ {
+ // Draw revealed sections
+
+ for (int i = 0; i < revealedRects.size(); ++i)
+ {
+ drawBorder(port);
+ drawContents(port);
+ }
+ }
+ }
+ else
+ {
+ // Adjust the scroll values
+
+ m_canvasY += dy;
+ m_canvasX += dx;
+ }
+
+ // Scroll all child widgets
+
+ scrollChildren(dx, dy);
+
+ // Notify event handlers
+
+ m_widgetEventHandlers->raiseScrollEvent(dx, dy);
+ }
+}
+
+/**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+void CScrollingPanel::jump(int32_t x, int32_t y)
+{
+ // Calculate difference between jump value and current value and scroll
+
+ scroll(x - m_canvasX, y - m_canvasY);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CScrollingPanel::drawContents(CGraphicsPort *port)
+{
+ port->drawFilledRect(getX(), getY(), getWidth(), getHeight(),
+ getBackgroundColor());
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CScrollingPanel::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Scrolls the panel to match the drag.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal drag distance.
+ * @param vY The vertical drag distance.
+ */
+
+void CScrollingPanel::onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ scroll(vX, vY);
+}
+
+/**
+ * Starts the dragging system.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CScrollingPanel::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ startDragging(x, y);
+}
+
+/**
+ * Scroll all child widgets by the specified amounts. Actually uses
+ * the widget's moveTo() function to reposition them.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+void CScrollingPanel::scrollChildren(int32_t dx, int32_t dy)
+{
+ nxgl_coord_t widgetX = 0;
+ nxgl_coord_t widgetY = 0;
+ nxgl_coord_t thisX = getX();
+ nxgl_coord_t thisY = getY();
+ CNxWidget *widget = (CNxWidget *)NULL;
+
+ for (int32_t i = 0; i < m_children.size(); i++)
+ {
+ widget = m_children[i];
+ widgetX = (widget->getX() - thisX) + dx;
+ widgetY = (widget->getY() - thisY) + dy;
+ widget->moveTo(widgetX, widgetY);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cscrollingtextbox.cxx b/NxWidgets/libnxwidgets/src/cscrollingtextbox.cxx
new file mode 100644
index 000000000..4de63fdf6
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cscrollingtextbox.cxx
@@ -0,0 +1,577 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cscrollingtextbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cscrollingtextbox.hxx"
+#include "cscrollbarvertical.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param flags Standard widget flag options.
+ * @param maxRows The maximum number of rows the textbox can track. Adding
+ * text beyond this number will cause rows at the start of the text to be
+ * forgotten; text is essentially stored as a queue, and adding to the back
+ * of a full queue causes the front items to be popped off. Setting this to
+ * 0 will make the textbox track only the visible rows.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * g_defaultWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CScrollingTextBox::CScrollingTextBox(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, uint32_t flags,
+ nxgl_coord_t maxRows, CWidgetStyle *style)
+: CNxWidget(pWidgetControl, x, y, width, height, flags, style)
+{
+ m_scrollbarWidth = 10;
+ setBorderless(true);
+
+ m_texbox = new CMultiLineTextBox(pWidgetControl,
+ 0, 0, width - m_scrollbarWidth, height,
+ text, flags, maxRows, &m_style);
+ m_texbox->addWidgetEventHandler(this);
+
+ // Create scrollbar
+
+ CRect rect;
+ m_texbox->getClientRect(rect);
+ m_scrollbar = new CScrollbarVertical(pWidgetControl,
+ width - m_scrollbarWidth, 0,
+ m_scrollbarWidth, height, &m_style);
+ m_scrollbar->setMinimumValue(0);
+ m_scrollbar->setMaximumValue(m_texbox->getCanvasHeight());
+ m_scrollbar->setPageSize(rect.getHeight());
+ m_scrollbar->setValue(0 - m_texbox->getCanvasY());
+ m_scrollbar->addWidgetEventHandler(this);
+
+ // Add children to child array
+
+ addWidget(m_texbox);
+ addWidget(m_scrollbar);
+}
+
+/**
+ * Set the horizontal alignment of text within the textbox.
+ *
+ * @param alignment The horizontal position of the text.
+ */
+
+void CScrollingTextBox::setTextAlignmentHoriz(CMultiLineTextBox::TextAlignmentHoriz alignment)
+{
+ m_texbox->setTextAlignmentHoriz(alignment);
+}
+
+/**
+ * Set the vertical alignment of text within the textbox.
+ *
+ * @param alignment The vertical position of the text.
+ */
+
+void CScrollingTextBox::setTextAlignmentVert(CMultiLineTextBox::TextAlignmentVert alignment)
+{
+ m_texbox->setTextAlignmentVert(alignment);
+}
+
+/**
+ * Returns the number of "pages" that the text spans. A page
+ * is defined as the amount of text that can be displayed within
+ * the textbox at one time.
+ *
+ * @return The page count.
+ */
+
+const uint16_t CScrollingTextBox::getPageCount(void) const
+{
+ return m_texbox->getPageCount();
+}
+
+/**
+ * Returns the current page.
+ *
+ * @return The current page.
+ * @see getPageCount().
+ */
+
+const uint16_t CScrollingTextBox::getCurrentPage(void) const
+{
+ return m_texbox->getCurrentPage();
+}
+
+/**
+ * Returns a pointer to the Text object that contains the
+ * wrapped text used in the textbox. It is used as the
+ * pre-processed data source for the textbox, and should
+ * not be altered.
+ *
+ * @return Pointer to the Text object.
+ */
+
+const CText *CScrollingTextBox::getText(void) const
+{
+ return m_texbox->getText();
+}
+
+/**
+ * Set the text displayed in the textbox.
+ *
+ * @param text String to display.
+ */
+
+void CScrollingTextBox::setText(const CNxString &text)
+{
+ m_texbox->setText(text);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Append new text to the end of the current text
+ * displayed in the textbox.
+ *
+ * @param text String to append.
+ */
+
+void CScrollingTextBox::appendText(const CNxString &text)
+{
+ m_texbox->appendText(text);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+void CScrollingTextBox::removeText(const unsigned int startIndex)
+{
+ m_texbox->removeText(startIndex);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+void CScrollingTextBox::removeText(const unsigned int startIndex,
+ const unsigned int count)
+{
+ m_texbox->removeText(startIndex, count);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Set the font used in the textbox.
+ *
+ * @param font Pointer to the new font.
+ */
+
+void CScrollingTextBox::setFont(CNxFont *font)
+{
+ m_style.font = font;
+ m_texbox->setFont(font);
+ m_scrollbar->setFont(font);
+}
+
+/**
+ * Get the length of the text string.
+ *
+ * @return The length of the text string.
+ */
+
+const unsigned int CScrollingTextBox::getTextLength(void) const
+{
+ return m_texbox->getTextLength();
+}
+
+/**
+ * Sets the cursor display mode.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+void CScrollingTextBox::showCursor(EShowCursor cursorMode)
+{
+ m_texbox->showCursor(cursorMode);
+}
+
+/**
+ * Enables/disables cursor wrapping
+ *
+ * @param wrap True enables cursor wrapping
+ */
+
+void CScrollingTextBox::wrapCursor(bool wrap)
+{
+ m_texbox->wrapCursor(wrap);
+}
+
+/**
+ * Move the cursor to the text position specified. 0 indicates the start
+ * of the string. If position is greater than the length of the string,
+ * the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+void CScrollingTextBox::moveCursorToPosition(const int32_t position)
+{
+ m_texbox->moveCursorToPosition(position);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Get the cursor position. This is the index within the string that
+ * the cursor is currently positioned over.
+ *
+ * @return position The cursor position.
+ */
+
+const int32_t CScrollingTextBox::getCursorPosition(void) const
+{
+ return m_texbox->getCursorPosition();
+}
+
+/**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+void CScrollingTextBox::insertText(const CNxString &text,
+ const unsigned int index)
+{
+ m_texbox->insertText(text, index);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+void CScrollingTextBox::insertTextAtCursor(const CNxString &text)
+{
+ m_texbox->insertTextAtCursor(text);
+ m_scrollbar->redraw();
+}
+
+/**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+void CScrollingTextBox::handleValueChangeEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_scrollbar)
+ {
+ if (m_texbox != NULL)
+ {
+ m_texbox->setRaisesEvents(false);
+ m_texbox->jump(0, 0 - m_scrollbar->getValue());
+ m_texbox->setRaisesEvents(true);
+ }
+ }
+ else if (e.getSource() == m_texbox)
+ {
+ if (m_scrollbar != NULL)
+ {
+ m_scrollbar->setRaisesEvents(false);
+ m_scrollbar->setMaximumValue(m_texbox->getCanvasHeight());
+ m_scrollbar->setValue(0 - m_texbox->getCanvasY());
+ m_scrollbar->setRaisesEvents(true);
+ }
+ }
+ }
+}
+
+/**
+ * Handles events raised by its sub-widgets.
+ *
+ * @param e Event arguments.
+ */
+
+void CScrollingTextBox::handleScrollEvent(const CWidgetEventArgs &e)
+{
+ if (e.getSource() != NULL)
+ {
+ if (e.getSource() == m_texbox)
+ {
+ if (m_scrollbar != NULL)
+ {
+ m_scrollbar->setRaisesEvents(false);
+ m_scrollbar->setValue(0 - m_texbox->getCanvasY());
+ m_scrollbar->setRaisesEvents(true);
+ }
+ }
+ }
+}
+
+/**
+ * Gets the x coordinate of the virtual canvas.
+ *
+ * @return The x coordinate of the virtual canvas.
+ */
+
+const int32_t CScrollingTextBox::getCanvasX(void) const
+{
+ return m_texbox->getCanvasX();
+}
+
+/**
+ * Gets the y coordinate of the virtual canvas.
+ *
+ * @return The y coordinate of the virtual canvas.
+ */
+
+const int32_t CScrollingTextBox::getCanvasY(void) const
+{
+ return m_texbox->getCanvasY();
+}
+
+/**
+ * Gets the width of the virtual canvas.
+ *
+ * @return The width of the virtual canvas.
+ */
+
+const int32_t CScrollingTextBox::getCanvasWidth(void) const
+{
+ return m_texbox->getCanvasWidth();
+}
+
+/**
+ * Gets the height of the virtual canvas.
+ *
+ * @return The height of the virtual canvas.
+ */
+
+const int32_t CScrollingTextBox::getCanvasHeight(void) const
+{
+ return m_texbox->getCanvasHeight();
+}
+
+/**
+ * Scroll the panel by the specified amounts.
+ *
+ * @param dx The horizontal distance to scroll.
+ * @param dy The vertical distance to scroll.
+ */
+
+void CScrollingTextBox::scroll(int32_t dx, int32_t dy)
+{
+ m_texbox->scroll(dx, dy);
+}
+
+/**
+ * Reposition the panel's scrolling region to the specified coordinates.
+ *
+ * @param x The new x coordinate of the scrolling region.
+ * @param y The new y coordinate of the scrolling region.
+ */
+
+void CScrollingTextBox::jump(int32_t x, int32_t y)
+{
+ m_texbox->jump(x, y);
+}
+
+/**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+void CScrollingTextBox::setAllowsVerticalScroll(bool allow)
+{
+ m_texbox->setAllowsVerticalScroll(allow);
+}
+
+/**
+ * Set whether or not horizontal scrolling is allowed.
+ *
+ * @param allow True to allow horizontal scrolling; false to deny it.
+ */
+
+void CScrollingTextBox::setAllowsHorizontalScroll(bool allow)
+{
+ // NOP
+}
+
+/**
+ * Sets the width of the virtual canvas.
+ *
+ * @param width The width of the virtual canvas.
+ */
+
+void CScrollingTextBox::setCanvasWidth(const int32_t width)
+{
+ // NOP
+}
+
+/**
+ * Sets the height of the virtual canvas.
+ *
+ * @param height The height of the virtual canvas.
+ */
+
+void CScrollingTextBox::setCanvasHeight(const int32_t height)
+{
+ // NOP
+}
+
+/**
+ * Returns true if vertical scrolling is allowed.
+ *
+ * @return True if vertical scrolling is allowed.
+ */
+
+bool CScrollingTextBox::allowsVerticalScroll(void) const
+{
+ return m_texbox->allowsVerticalScroll();
+}
+
+/**
+ * Returns true if horizontal scrolling is allowed.
+ *
+ * @return True if horizontal scrolling is allowed.
+ */
+
+bool CScrollingTextBox::allowsHorizontalScroll(void) const
+{
+ return m_texbox->allowsHorizontalScroll();
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CScrollingTextBox::drawContents(CGraphicsPort *port)
+{
+ port->drawFilledRect(0, 0, getWidth(), getHeight(), getBackgroundColor());
+}
+
+/**
+ * Resize the textbox to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CScrollingTextBox::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Resize the children
+
+ m_texbox->resize(width - m_scrollbarWidth, height);
+ m_scrollbar->resize(m_scrollbarWidth, height);
+
+ // Move the scrollbar
+
+ m_scrollbar->moveTo(width - m_scrollbarWidth, 0);
+}
diff --git a/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx b/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
new file mode 100644
index 000000000..2fe47556c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
@@ -0,0 +1,402 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/csliderhorizontal.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "csliderhorizontal.hxx"
+#include "csliderhorizontalgrip.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ */
+
+CSliderHorizontal::CSliderHorizontal(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE)
+{
+ m_minimumValue = 0;
+ m_maximumValue = 0;
+ m_contentSize = 0;
+ m_value = 0;
+ m_minimumGripWidth = 10;
+ m_pageSize = 1;
+
+ m_flags.permeable = false;
+ m_flags.borderless = false;
+ m_flags.doubleClickable = false;
+
+ // Create grip
+
+ CRect rect;
+ getClientRect(rect);
+
+ m_grip = new CSliderHorizontalGrip(pWidgetControl, rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight());
+ m_grip->addWidgetEventHandler(this);
+ addWidget(m_grip);
+
+ m_gutterWidth = rect.getWidth();
+}
+
+/**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+void CSliderHorizontal::setValue(const nxgl_coord_t value)
+{
+ setValueWithBitshift((int32_t)value << 16);
+}
+
+/**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+void CSliderHorizontal::setValueWithBitshift(const int32_t value)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ // Can the grip move?
+
+ if ((rect.getWidth() > m_grip->getWidth()) && (m_maximumValue != m_minimumValue))
+ {
+ int32_t newValue = value;
+ int32_t maxValue = getPhysicalMaximumValueWithBitshift();
+
+ // Limit to max/min values
+
+ if (newValue > maxValue)
+ {
+ newValue = maxValue;
+ }
+
+ if (newValue >> 16 < m_minimumValue)
+ {
+ newValue = m_minimumValue << 16;
+ }
+
+ uint32_t scrollRatio = newValue / m_contentSize;
+ int32_t newGripX = m_gutterWidth * scrollRatio;
+ newGripX += newGripX & 0x8000;
+ newGripX >>= 16;
+ newGripX += rect.getX();
+
+ m_grip->moveTo(newGripX, rect.getY());
+
+ // Update stored value if necessary
+
+ if (m_value != newValue)
+ {
+ m_value = newValue;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CSliderHorizontal::handleDragEvent(const CWidgetEventArgs &e)
+{
+ // Handle grip events
+
+ if ((e.getSource() == m_grip) && (e.getSource() != NULL))
+ {
+ int32_t newValue = getGripValue() >> 16;
+
+ // Grip has moved - compare values and raise event if the
+ // value has changed. Compare using integer values rather
+ // than fixed-point.
+
+ if (m_value >> 16 != newValue)
+ {
+ m_value = newValue << 16;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ }
+}
+
+/**
+ * Get the smallest value that the slider can move through when
+ * dragged.
+ *
+ * @return The smallest value that the slider can move through when
+ * dragged.
+ */
+
+nxgl_coord_t CSliderHorizontal::getMinimumStep(void) const
+{
+ // If the ratio of content to gutter is greater than or equal to one,
+ // the minimum step that the slider can represent will be that ratio.
+
+ uint32_t gutterRatio = m_contentSize << 16 / m_gutterWidth;
+ gutterRatio += gutterRatio & 0x8000;
+ gutterRatio >>= 16;
+
+ if (gutterRatio > 0)
+ {
+ return gutterRatio;
+ }
+
+ return 1;
+}
+
+/**
+ * Get the maximum possible value that the slider can represent. Useful when
+ * using the slider as a scrollbar, as the height of the grip prevents the full
+ * range of values being accessed (intentionally).
+ * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * calculations.
+ *
+ * @return The maximum possible value that the slider can represent.
+ */
+
+int32_t CSliderHorizontal::getPhysicalMaximumValueWithBitshift(void) const
+{
+ uint32_t maxX = m_gutterWidth - m_grip->getWidth();
+ uint32_t scrollRatio = (maxX << 16) / m_gutterWidth;
+ int32_t value = (scrollRatio * m_contentSize);
+
+ return value;
+}
+
+/**
+ * Get the value represented by the top of the grip.
+ * return The value represented by the top of the grip.
+ */
+
+const int32_t CSliderHorizontal::getGripValue(void) const
+{
+ // Calculate the current value represented by the top of the grip
+
+ CRect rect;
+ getClientRect(rect);
+
+ uint32_t gripPos = ((m_grip->getX() - getX()) - rect.getX());
+ uint32_t scrollRatio = (gripPos << 16) / m_gutterWidth;
+ int32_t value = (scrollRatio * m_contentSize);
+
+ return value;
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderHorizontal::drawContents(CGraphicsPort *port)
+{
+ CRect rect;
+ getRect(rect);
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ getSelectedBackgroundColor());
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderHorizontal::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Resize the slider to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CSliderHorizontal::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Remember current values
+
+ int32_t oldValue = m_value;
+ bool events = raisesEvents();
+
+ // Disable event raising
+
+ setRaisesEvents(false);
+ resizeGrip();
+
+ // Set back to current value
+
+ setValue(oldValue);
+
+ // Reset event raising
+
+ setRaisesEvents(events);
+}
+
+/**
+ * Moves the grip towards the mouse.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CSliderHorizontal::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Which way should the grip move?
+
+ if (x > m_grip->getX())
+ {
+ // Move grip right
+
+ setValueWithBitshift(m_value + (m_pageSize << 16));
+ }
+ else
+ {
+ // Move grip left
+
+ setValueWithBitshift(m_value - (m_pageSize << 16));
+ }
+}
+
+/**
+ * Resize and redraw the grip.
+ */
+
+void CSliderHorizontal::resizeGrip(void)
+{
+ // Get available size
+
+ CRect rect;
+ getClientRect(rect);
+
+ int32_t gripRatio = (m_pageSize << 16) / m_contentSize;
+ int32_t gripSize = rect.getWidth() * gripRatio;
+ gripSize >>= 16;
+ m_gutterWidth = rect.getWidth();
+
+ if (gripSize < m_minimumGripWidth)
+ {
+ // TODO: Need to implement scaling here. If we resize the grip to be
+ // artificially larger, we effectively reduce the scale (not just the
+ // height) of the gutter. Each position in the gutter needs to be
+ // reduced in value.
+ }
+
+ m_grip->resize(gripSize, rect.getHeight());
+}
+
+
diff --git a/NxWidgets/libnxwidgets/src/csliderhorizontalgrip.cxx b/NxWidgets/libnxwidgets/src/csliderhorizontalgrip.cxx
new file mode 100644
index 000000000..aebdbf51d
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/csliderhorizontalgrip.cxx
@@ -0,0 +1,246 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/csliderhorizontalgrip.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "csliderhorizontalgrip.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the grip, relative to its parent.
+ * @param y The y coordinate of the grip, relative to its parent.
+ * @param width The width of the grip.
+ * @param height The height of the grip.
+ */
+
+CSliderHorizontalGrip::CSliderHorizontalGrip(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE)
+{
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderHorizontalGrip::drawContents(CGraphicsPort *port)
+{
+ CRect rect;
+ getRect(rect);
+
+ nxwidget_pixel_t color;
+ if (!m_flags.clicked)
+ {
+ color = getSelectedBackgroundColor();
+ }
+ else
+ {
+ color = getHighlightColor();
+ }
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ color);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderHorizontalGrip::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ if (isClicked())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+ else
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShineEdgeColor(), getShadowEdgeColor());
+ }
+ }
+}
+
+/**
+ * Starts dragging the grip and redraws it.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CSliderHorizontalGrip::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ startDragging(x, y);
+ redraw();
+}
+
+/**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CSliderHorizontalGrip::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CSliderHorizontalGrip::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Moves the grip to follow the mouse.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance of the drag.
+ * @param vY The vertical distance of the drag.
+ */
+
+void CSliderHorizontalGrip::onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ // Work out where we're moving to
+
+ nxgl_coord_t destX = x - m_grabPointX - m_parent->getX();
+
+ // Do we need to move?
+
+ if (destX != m_rect.getX())
+ {
+ // Get parent rect
+
+ CRect rect;
+ m_parent->getClientRect(rect);
+
+ // Prevent grip from moving outside parent
+
+ if (destX < rect.getX())
+ {
+ destX = rect.getX();
+ }
+ else
+ {
+ if (destX + getWidth() > rect.getWidth() + rect.getX())
+ {
+ destX = (rect.getWidth() + rect.getX()) - getWidth() ;
+ }
+ }
+
+ // Move to new location
+
+ moveTo(destX, rect.getY());
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cslidervertical.cxx b/NxWidgets/libnxwidgets/src/cslidervertical.cxx
new file mode 100644
index 000000000..74d2d956b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cslidervertical.cxx
@@ -0,0 +1,402 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cslidervertical.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cwidgetcontrol.hxx"
+#include "cslidervertical.hxx"
+#include "csliderverticalgrip.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the slider, relative to its parent.
+ * @param y The y coordinate of the slider, relative to its parent.
+ * @param width The width of the slider.
+ * @param height The height of the slider.
+ */
+
+CSliderVertical::CSliderVertical(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE)
+{
+ m_minimumValue = 0;
+ m_maximumValue = 0;
+ m_contentSize = 0;
+ m_value = 0;
+ m_minimumGripHeight = 10;
+ m_pageSize = 1;
+
+ m_flags.permeable = false;
+ m_flags.borderless = false;
+ m_flags.doubleClickable = false;
+
+ // Create grip
+
+ CRect rect;
+ getClientRect(rect);
+
+ m_grip = new CSliderVerticalGrip(pWidgetControl,
+ rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight());
+ m_grip->addWidgetEventHandler(this);
+ addWidget(m_grip);
+
+ m_gutterHeight = rect.getHeight();
+}
+
+/**
+ * Set the value that of the slider. This will reposition
+ * and redraw the grip.
+ *
+ * @param value The new value.
+ */
+
+void CSliderVertical::setValue(const nxgl_coord_t value)
+{
+ setValueWithBitshift((int32_t)value << 16);
+}
+
+/**
+ * Set the value that of the slider. This will reposition and redraw
+ * the grip. The supplied value should be bitshifted left 16 places.
+ * This ensures greater accuracy than the standard setValue() method if
+ * the slider is being used as a scrollbar.
+ *
+ * @param value The new value.
+ */
+
+void CSliderVertical::setValueWithBitshift(const int32_t value)
+{
+ CRect rect;
+ getClientRect(rect);
+
+ // Can the grip move?
+
+ if ((rect.getHeight() > m_grip->getHeight()) && (m_maximumValue != m_minimumValue))
+ {
+ int32_t newValue = value;
+ int32_t maxValue = getPhysicalMaximumValueWithBitshift();
+
+ // Limit to max/min values
+
+ if (newValue > maxValue)
+ {
+ newValue = maxValue;
+ }
+
+ if (newValue >> 16 < m_minimumValue)
+ {
+ newValue = m_minimumValue << 16;
+ }
+
+ uint32_t scrollRatio = newValue / m_contentSize;
+ int32_t newGripY = m_gutterHeight * scrollRatio;
+ newGripY += newGripY & 0x8000;
+ newGripY >>= 16;
+ newGripY += rect.getY();
+
+ m_grip->moveTo(rect.getX(), newGripY);
+
+ // Update stored value if necessary
+
+ if (m_value != newValue)
+ {
+ m_value = newValue;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ }
+}
+
+/**
+ * Process events fired by the grip.
+ *
+ * @param e The event details.
+ */
+
+void CSliderVertical::handleDragEvent(const CWidgetEventArgs &e)
+{
+ // Handle grip events
+
+ if ((e.getSource() == m_grip) && (e.getSource() != NULL))
+ {
+ int32_t newValue = getGripValue() >> 16;
+
+ // Grip has moved - compare values and raise event if the
+ // value has changed. Compare using integer values rather
+ // than fixed-point.
+
+ if (m_value >> 16 != newValue)
+ {
+ m_value = newValue << 16;
+ m_widgetEventHandlers->raiseValueChangeEvent();
+ }
+ }
+}
+
+/**
+ * Get the smallest value that the slider can move through when
+ * dragged.
+ *
+ * @return The smallest value that the slider can move through when
+ * dragged.
+ */
+
+nxgl_coord_t CSliderVertical::getMinimumStep(void) const
+{
+ // If the ratio of content to gutter is greater than or equal to one,
+ // the minimum step that the slider can represent will be that ratio.
+
+ uint32_t gutterRatio = m_contentSize << 16 / m_gutterHeight;
+ gutterRatio += gutterRatio & 0x8000;
+ gutterRatio >>= 16;
+
+ if (gutterRatio > 0)
+ {
+ return gutterRatio;
+ }
+
+ return 1;
+}
+
+/**
+ * Get the maximum possible value that the slider can represent. Useful when
+ * using the slider as a scrollbar, as the height of the grip prevents the full
+ * range of values being accessed (intentionally).
+ * The returned value is bitshfted left 16 places for more accuracy in fixed-point
+ * calculations.
+ *
+ * @return The maximum possible value that the slider can represent.
+ */
+
+int32_t CSliderVertical::getPhysicalMaximumValueWithBitshift(void) const
+{
+ uint32_t maxY = m_gutterHeight - m_grip->getHeight();
+ uint32_t scrollRatio = (maxY << 16) / m_gutterHeight;
+ int32_t value = (scrollRatio * m_contentSize);
+
+ return value;
+}
+
+/**
+ * Get the value represented by the top of the grip. The value is
+ * bitshifted left 16 places for accuracy.
+ * return The value represented by the top of the grip.
+ */
+
+const int32_t CSliderVertical::getGripValue(void) const
+{
+ // Calculate the current value represented by the top of the grip
+
+ CRect rect;
+ getClientRect(rect);
+
+ uint32_t gripPos = ((m_grip->getY() - getY()) - rect.getY());
+ uint32_t scrollRatio = (gripPos << 16) / m_gutterHeight;
+ int32_t value = (scrollRatio * m_contentSize);
+
+ return value;
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderVertical::drawContents(CGraphicsPort *port)
+{
+ CRect rect;
+ getRect(rect);
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ getSelectedBackgroundColor());
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderVertical::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Resize the slider to the new dimensions.
+ *
+ * @param width The new width.
+ * @param height The new height.
+ */
+
+void CSliderVertical::onResize(nxgl_coord_t width, nxgl_coord_t height)
+{
+ // Remember current values
+
+ int32_t oldValue = m_value;
+ bool events = raisesEvents();
+
+ // Disable event raising
+
+ setRaisesEvents(false);
+ resizeGrip();
+
+ // Set back to current value
+
+ setValue(oldValue);
+
+ // Reset event raising
+
+ setRaisesEvents(events);
+}
+
+/**
+ * Moves the grip towards the mouse.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CSliderVertical::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Which way should the grip move?
+
+ if (y > m_grip->getY())
+ {
+ // Move grip down
+
+ setValueWithBitshift(m_value + (m_pageSize << 16));
+ }
+ else
+ {
+ // Move grip up
+
+ setValueWithBitshift(m_value - (m_pageSize << 16));
+ }
+}
+
+/**
+ * Resize and redraw the grip.
+ */
+
+void CSliderVertical::resizeGrip(void)
+{
+ // Get available size
+
+ CRect rect;
+ getClientRect(rect);
+
+ int32_t gripRatio = (m_pageSize << 16) / m_contentSize;
+ int32_t gripSize = rect.getHeight() * gripRatio;
+ gripSize >>= 16;
+ m_gutterHeight = rect.getHeight();
+
+ if (gripSize < m_minimumGripHeight)
+ {
+ // TODO: Need to implement scaling here. If we resize the grip to be
+ // artificially larger, we effectively reduce the scale (not just the
+ // height) of the gutter. Each position in the gutter needs to be
+ // reduced in value.
+ }
+
+ m_grip->resize(rect.getWidth(), gripSize);
+}
diff --git a/NxWidgets/libnxwidgets/src/csliderverticalgrip.cxx b/NxWidgets/libnxwidgets/src/csliderverticalgrip.cxx
new file mode 100644
index 000000000..2ddf364e8
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/csliderverticalgrip.cxx
@@ -0,0 +1,245 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cslidervertical.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "csliderverticalgrip.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+/**
+ * Constructor.
+ *
+ * @param pWidgetControl The controlling widget for the display
+ * @param x The x coordinate of the grip, relative to its parent.
+ * @param y The y coordinate of the grip, relative to its parent.
+ * @param width The width of the grip.
+ * @param height The height of the grip.
+ */
+
+CSliderVerticalGrip::CSliderVerticalGrip(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height)
+: CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE)
+{
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderVerticalGrip::drawContents(CGraphicsPort *port)
+{
+ CRect rect;
+ getRect(rect);
+
+ nxwidget_pixel_t color;
+ if (!m_flags.clicked)
+ {
+ color = getSelectedBackgroundColor();
+ }
+ else
+ {
+ color = getHighlightColor();
+ }
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(),
+ color);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CSliderVerticalGrip::drawBorder(CGraphicsPort *port)
+{
+ // Stop drawing if the widget indicates it should not have an outline
+
+ if (!isBorderless())
+ {
+ if (isClicked())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+ else
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShineEdgeColor(), getShadowEdgeColor());
+ }
+ }
+}
+
+/**
+ * Starts dragging the grip and redraws it.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CSliderVerticalGrip::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ startDragging(x, y);
+ redraw();
+}
+
+/**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CSliderVerticalGrip::onRelease(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Redraws the grip.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ */
+
+void CSliderVerticalGrip::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
+{
+ redraw();
+}
+
+/**
+ * Moves the grip to follow the mouse.
+ *
+ * @param x The x coordinate of the mouse.
+ * @param y The y coordinate of the mouse.
+ * @param vX The horizontal distance of the drag.
+ * @param vY The vertical distance of the drag.
+ */
+
+void CSliderVerticalGrip::onDrag(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ // Work out where we're moving to
+
+ nxgl_coord_t destY = y - m_grabPointY - m_parent->getY();
+
+ // Do we need to move?
+
+ if (destY != m_rect.getY())
+ {
+ // Get parent rect
+
+ CRect rect;
+ m_parent->getClientRect(rect);
+
+ // Prevent grip from moving outside parent
+
+ if (destY < rect.getY())
+ {
+ destY = rect.getY();
+ }
+ else
+ {
+ if (destY + getHeight() > rect.getHeight() + rect.getY())
+ {
+ destY = (rect.getHeight() + rect.getY()) - getHeight();
+ }
+ }
+
+ // Move to new location
+
+ moveTo(rect.getX(), destY);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cstickybutton.cxx b/NxWidgets/libnxwidgets/src/cstickybutton.cxx
new file mode 100644
index 000000000..76852eaf7
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cstickybutton.cxx
@@ -0,0 +1,168 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cstickybutton.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybutton.hxx"
+#include "cgraphicsport.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for buttons that display a string.
+ *
+ * @param pWidgetControl The controlling widget for the display.
+ * @param x The x coordinate of the button, relative to its parent.
+ * @param y The y coordinate of the button, relative to its parent.
+ * @param width The width of the button.
+ * @param height The height of the button.
+ * @param text The text for the button to display.
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CStickyButton::CStickyButton(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text,
+ CWidgetStyle *style)
+: CButton(pWidgetControl, x, y, width, height, text, style)
+{
+ m_isStuckDown = false;
+}
+
+/**
+ * Sets the key's stuck down state. If this is true, the key has a
+ * inwards-bevelled border when drawn. If it is false, the key has
+ * an outwards-bevelled border.
+ *
+ * @param stuckDown The new stuck down state.
+ */
+
+void CStickyButton::setStuckDown(bool stuckDown)
+ {
+ m_isStuckDown = stuckDown;
+ redraw();
+ }
+
+/**
+ * Draws the outline of the button.
+ *
+ * @param port Graphics port to draw to.
+ */
+
+void CStickyButton::drawOutline(CGraphicsPort *port)
+{
+ CButton::drawOutline(port, m_isStuckDown);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CStickyButton::drawContents(CGraphicsPort *port)
+{
+ CButton::drawContents(port, m_isStuckDown);
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CStickyButton::drawBorder(CGraphicsPort *port)
+{
+ CButton::drawBorder(port, m_isStuckDown);
+}
diff --git a/NxWidgets/libnxwidgets/src/cstickybuttonarray.cxx b/NxWidgets/libnxwidgets/src/cstickybuttonarray.cxx
new file mode 100644
index 000000000..05c9d8928
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cstickybuttonarray.cxx
@@ -0,0 +1,292 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/include/cstickybuttonarray.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "cstickybuttonarray.hxx"
+#include "cgraphicsport.hxx"
+#include "cwidgetstyle.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CStickyButtonArray Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for an array of sticky buttons.
+ *
+ * @param pWidgetControl The widget control for the display.
+ * @param x The x coordinate of the button array, relative to its parent.
+ * @param y The y coordinate of the button array, relative to its parent.
+ * @param buttonColumns The number of buttons in one row of the button array
+ * @param buttonRows The number of buttons in one column of the button array
+ * @param buttonWidth The width of one button
+ * @param buttonHeight The height of one button
+ * @param style The style that the button should use. If this is not
+ * specified, the button will use the global default widget
+ * style.
+ */
+
+CStickyButtonArray::CStickyButtonArray(CWidgetControl *pWidgetControl,
+ nxgl_coord_t x, nxgl_coord_t y,
+ uint8_t buttonColumns, uint8_t buttonRows,
+ nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
+ CWidgetStyle *style)
+: CButtonArray(pWidgetControl, x, y, buttonColumns, buttonRows, buttonWidth, buttonHeight, style)
+{
+ // Initialize state
+
+ m_isStuckDown = false;
+ m_stickDown = false;
+}
+
+/**
+ * Check if any button in the array is stuck down and, if so,
+ * return the indices of the stuck down button.
+ *
+ * @param column The location to return the column index of the button
+ * of interest
+ * @param row The location to return the row index of the button of
+ * interest
+ * @return True if a button in the array is clicked
+ */
+
+bool CStickyButtonArray::isAnyButtonStuckDown(int &column, int &row) const
+{
+ // Return the indices of the last stuck button
+
+ column = m_stickyColumn;
+ row = m_stickyRow;
+
+ // Return true if the button is currently stuck
+
+ return m_isStuckDown;
+}
+
+/**
+ * Check if this specific button in the array is stuck down
+ *
+ * @param column The column of the button to check.
+ * @param row The row of the button to check.
+ * @return True if this button is stuck down
+ */
+
+bool CStickyButtonArray::isThisButtonStuckDown(int column, int row) const
+{
+ // Does this match the index of the last stuck button?
+
+ if (column == m_stickyColumn && row == m_stickyRow)
+ {
+ // Yes.. return true if it is still stuck
+
+ return m_isStuckDown;
+ }
+ else
+ {
+ // This button is definitely not stuck down
+
+ return false;
+ }
+}
+
+/**
+ * Force the button at this position into the stuck down state
+ *
+ * @param column The column containing the button to stick down
+ * @param row The rowtcontaining the button to stick down
+ * @return False(0) is returned if the indices are out of range.
+ */
+
+bool CStickyButtonArray::stickDown(int column, int row)
+{
+ // Verify that the cursor position is within range
+
+ if ((unsigned)column < m_buttonColumns && (unsigned)row < m_buttonRows)
+ {
+ // First, unstick any currently stuck buttons
+
+ unstick();
+
+ // Then stick this button down
+
+ m_stickyColumn = column;
+ m_stickyRow = row;
+ m_isStuckDown = true;
+
+ // We only want to update the stuck down buttons
+
+ m_stickDown = true;
+ redraw();
+ m_stickDown = false;
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Unstick all buttons.
+ */
+
+void CStickyButtonArray::unstick(void)
+{
+ // Is any button stuck down?
+
+ if (m_isStuckDown)
+ {
+ // Yes.. unstick it and update the button display
+
+ m_isStuckDown = false;
+
+ // We only want to update the stuck down buttons
+
+ m_stickDown = true;
+ redraw();
+ m_stickDown = false;
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CStickyButtonArray::drawContents(CGraphicsPort *port)
+{
+ // Are we just updating the stuck down button?
+
+ if (m_stickDown)
+ {
+ // There are two cases: (1) A sticky button was unstuck, or (2) a new
+ // button is stuck down. m_isStuckDown will distinguish these
+ //
+ // Draw the button using the clicked style if either (1) it is
+ // stuck down OR (2) it is currently clicked. Draw the button in
+ // the normal style if is is un-stuck and not clicked.
+ //
+ // NOTE: If usedClicked is false, the button may revert to either
+ // (1) the "normal" button state, or (2) the "highlighted" button
+ // stated. drawButton() will handle that.
+
+ bool useClicked = m_isStuckDown || isThisButtonClicked(m_stickyColumn, m_stickyRow);
+ drawButton(port, m_stickyColumn, m_stickyRow, useClicked);
+ }
+
+ // Do we draw just one button (due to click or release)?
+
+ else if (m_redrawButton)
+ {
+ // Just one. Get the row/column indices from the last click
+
+ int column;
+ int row;
+ bool useClicked = isButtonClicked(column, row);
+
+ // If this is a press or release on the stuck down button, then don't
+ // redraw the button. Drawing of stuck down and unstuck buttons is
+ // controlled entirely by the m_stickDown case.
+
+ if (!isThisButtonStuckDown(column, row))
+ {
+ // Not a stuck down button. Re-draw that button
+
+ drawButton(port, column, row, useClicked);
+ }
+ }
+
+ // Do we just draw the hightlighted button?
+
+ else if (m_cursorChange)
+ {
+ // Do nothing if the highlighted button is also the stuck down button
+ // or the clicked button
+
+ if (!isThisButtonStuckDown(m_cursorColumn, m_cursorRow) &&
+ !isThisButtonClicked(m_cursorColumn, m_cursorRow))
+ {
+ drawButton(port, m_cursorColumn, m_cursorRow, false);
+ }
+ }
+
+ // Draw all buttons
+
+ else
+ {
+ // Visit each column
+
+ for (int column = 0; column < m_buttonColumns; column++)
+ {
+ // Visit each row
+
+ for (int row = 0; row < m_buttonRows; row++)
+ {
+ // Is the button clicked?
+
+ bool useClicked = isThisButtonClicked(column, row);
+
+ // If the button is not clicked but it is the stuck button,
+ // then draw it as clicked anyway.
+
+ if (!useClicked)
+ {
+ useClicked = isThisButtonStuckDown(column, row);
+ }
+
+ // Draw each button. If useClicked is false, then drawButton
+ // will do the right thing if the button is highlighted.
+
+ drawButton(port, column, row, useClicked);
+ }
+ }
+ }
+}
+
diff --git a/NxWidgets/libnxwidgets/src/cstringiterator.cxx b/NxWidgets/libnxwidgets/src/cstringiterator.cxx
new file mode 100644
index 000000000..2327af38f
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cstringiterator.cxx
@@ -0,0 +1,198 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cgraphicsport.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cnxstring.hxx"
+#include "cstringiterator.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor. Moves the iterator to the first character in the string.
+ *
+ * @param string Pointer to the string that will be iterated over.
+ */
+
+CStringIterator::CStringIterator(FAR const CNxString* string)
+{
+ m_pString = string;
+ m_pCurrentChar = m_pString->getCharArray();
+ m_currentIndex = 0;
+}
+
+/**
+ * Moves the iterator to the first character in the string.
+ *
+ * @param Returns false if the string is empty
+ */
+
+bool CStringIterator::moveToFirst()
+{
+ int length = m_pString->getLength();
+ if (length > 0)
+ {
+ m_pCurrentChar = m_pString->getCharArray();
+ m_currentIndex = 0;
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Moves the iterator to the last character in the string.
+ *
+ * @param Returns false if the string is empty
+ */
+
+bool CStringIterator::moveToLast(void)
+{
+ int length = m_pString->getLength();
+ if (length > 0)
+ {
+ m_pCurrentChar = m_pString->getCharArray() + length - 1;
+ m_currentIndex = length - 1;
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Move the iterator to the next character in the string.
+ *
+ * @return True if the iterator moved; false if not (indicates end of string).
+ */
+
+bool CStringIterator::moveToNext(void)
+{
+ if (m_currentIndex < m_pString->getLength() - 1)
+ {
+ m_pCurrentChar++;
+ m_currentIndex++;
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Move the iterator to the previous character in the string.
+ *
+ * @return True if the iterator moved; false if not (indicates start of string).
+ */
+
+bool CStringIterator::moveToPrevious(void)
+{
+ if (m_currentIndex > 0)
+ {
+ m_pCurrentChar--;
+ m_currentIndex--;
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Move the iterator to the specified index.
+ *
+ * @param index The index to move to.
+ * @return True if the iterator moved; false if not (indicates end of string).
+ */
+
+bool CStringIterator::moveTo(int index)
+{
+ // Abort if index exceeds the size of the string
+
+ if (index < m_pString->getLength())
+ {
+ // Move to the requested position
+
+ m_pCurrentChar = m_pString->getCharArray() + index;
+ m_currentIndex = index;
+ return true;
+ }
+ return false;
+}
diff --git a/NxWidgets/libnxwidgets/src/ctext.cxx b/NxWidgets/libnxwidgets/src/ctext.cxx
new file mode 100644
index 000000000..688031d88
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ctext.cxx
@@ -0,0 +1,675 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ctext.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "ctext.hxx"
+#include "cstringiterator.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param font The font to use for this text object.
+ * @param text A string that this text object should wrap around.
+ * @param width The pixel width at which the text should wrap.
+ */
+
+CText::CText(CNxFont *font, const CNxString &text, nxgl_coord_t width)
+: CNxString(text)
+{
+ m_font = font;
+ m_width = width;
+ m_lineSpacing = 1;
+ wrap();
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+void CText::setText(const CNxString &text)
+{
+ CNxString::setText(text);
+ wrap();
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text Char array to use as the new data for this string.
+ */
+
+void CText::setText(FAR const char *text)
+{
+ CNxString::setText(text);
+ wrap();
+}
+
+/**
+ * Set the text in the string.
+ *
+ * @param text Character to to use as the new data for this string.
+ */
+
+void CText::setText(const nxwidget_char_t text)
+{
+ CNxString::setText(text);
+ wrap();
+}
+
+/**
+ * Append text to the end of the string.
+ *
+ * @param text String to append.
+ */
+
+void CText::append(const CNxString &text)
+{
+ CNxString::append(text);
+ wrap(getLength() - 1);
+}
+
+/**
+ * Insert text at the specified character index.
+ *
+ * @param text The text to insert.
+ * @param index The char index to insert at.
+ */
+
+void CText::insert(const CNxString &text, const int index)
+{
+ CNxString::insert(text, index);
+ wrap(index);
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex The char index to start removing from.
+ */
+
+void CText::remove(const int startIndex)
+{
+ CNxString::remove(startIndex);
+ wrap(startIndex);
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex The char index to start removing from.
+ * @param count The number of chars to remove.
+ */
+
+void CText::remove(const int startIndex, const int count)
+{
+ CNxString::remove(startIndex, count);
+ wrap(startIndex);
+}
+
+
+/**
+ * Set the vertical spacing between rows of text.
+ *
+ * @param lineSpacing The line spacing.
+ */
+
+void CText::setLineSpacing(uint8_t lineSpacing)
+{
+ m_lineSpacing = lineSpacing;
+ wrap();
+}
+
+/**
+ * Sets the pixel width of the text; text wider than
+ * this will automatically wrap.
+ *
+ * @param width Maximum pixel width of the text.
+ */
+
+void CText::setWidth(nxgl_coord_t width)
+{
+ m_width = width;
+ wrap();
+}
+
+/**
+ * Set the font to use.
+ *
+ * @param font Pointer to the new font.
+ */
+
+void CText::setFont(CNxFont* font)
+{
+ m_font = font;
+ wrap();
+}
+
+/**
+ * Get the number of characters in the specified line number.
+ *
+ * @param lineNumber The line number to check.
+ * @return The number of characters in the line.
+ */
+
+const int CText::getLineLength(const int lineNumber) const
+{
+ if (lineNumber < getLineCount() - 1)
+ {
+ return m_linePositions[lineNumber + 1] - m_linePositions[lineNumber];
+ }
+
+ return getLength() - m_linePositions[lineNumber];
+}
+
+/**
+ * Get the number of characters in the specified line number,
+ * ignoring any trailing blank characters.
+ *
+ * @param lineNumber The line number to check.
+ * @return The number of characters in the line.
+ */
+
+const int CText::getLineTrimmedLength(const int lineNumber) const
+{
+ nxgl_coord_t length = getLineLength(lineNumber);
+
+ // Loop through string until the end
+
+ CStringIterator *iterator = newStringIterator();
+
+ // Get char at the end of the line
+
+ if (iterator->moveTo(m_linePositions[lineNumber] + length - 1))
+ {
+ do
+ {
+ if (!m_font->isCharBlank(iterator->getChar()))
+ {
+ break;
+ }
+ length--;
+ }
+ while (iterator->moveToPrevious() && (length > 0));
+ return length;
+ }
+
+ // May occur if data has been horribly corrupted somewhere
+
+ return 0;
+}
+
+/**
+ * Get the width in pixels of the specified line number.
+ *
+ * @param lineNumber The line number to check.
+ * @return The pixel width of the line.
+ */
+
+const nxgl_coord_t CText::getLinePixelLength(const int lineNumber) const
+{
+ return m_font->getStringWidth(*this, getLineStartIndex(lineNumber),
+ getLineLength(lineNumber));
+}
+
+/**
+ * Get the width in pixels of the specified line number,
+ * ignoring any trailing blank characters.
+ *
+ * @param lineNumber The line number to check.
+ * @return The pixel width of the line.
+ */
+
+const nxgl_coord_t CText::getLineTrimmedPixelLength(const int lineNumber) const
+{
+ return m_font->getStringWidth(*this, getLineStartIndex(lineNumber),
+ getLineTrimmedLength(lineNumber));
+}
+
+/**
+ * Get a pointer to the CText object's font.
+ *
+ * @return Pointer to the font.
+ */
+
+CNxFont *CText::getFont(void) const
+{
+ return m_font;
+}
+
+/**
+ * Removes lines of text from the start of the text buffer.
+ *
+ * @param lines Number of lines to remove
+ */
+
+void CText::stripTopLines(const int lines)
+{
+ // Get the start point of the text we want to keep
+
+ nxgl_coord_t textStart = 0;
+
+ for (int i = 0; i < lines; i++)
+ {
+ textStart += getLineLength(i);
+ }
+
+ // Remove the characters from the start of the string to the found location
+
+ remove(0, textStart);
+
+ // Rewrap the text
+
+ wrap();
+}
+
+/**
+ * Wrap all of the text.
+ */
+
+void CText::wrap(void)
+{
+ wrap(0);
+}
+
+/**
+ * Wrap the text from the line containing the specified char index onwards.
+ *
+ * @param charIndex The index of the char to start wrapping from; note
+ * that the wrapping function will re-wrap that entire line of text.
+ */
+
+void CText::wrap(int charIndex)
+{
+ // Declare vars in advance of loop
+
+ int pos = 0;
+ int lineWidth;
+ int breakIndex;
+ bool endReached = false;
+
+ if (m_linePositions.size() == 0)
+ {
+ charIndex = 0;
+ }
+
+ // If we're wrapping from an offset in the text, ensure that any existing data
+ // after the offset gets removed
+
+ if (charIndex > 0)
+ {
+ // Remove wrapping data past this point
+
+ // Get the index of the line in which the char index appears
+
+ int lineIndex = getLineContainingCharIndex(charIndex);
+
+ // Remove any longest line records that occur from the line index onwards
+
+ while ((m_longestLines.size() > 0) &&
+ (m_longestLines[m_longestLines.size() - 1].index >= lineIndex))
+ {
+ m_longestLines.pop_back();
+ }
+
+ // If there are any longest line records remaining, update the text pixel width
+ // The last longest line record will always be the last valid longest line as
+ // the vector is sorted by length
+
+ if (m_longestLines.size() > 0)
+ {
+ m_textPixelWidth = m_longestLines[m_longestLines.size() - 1].width;
+ }
+ else
+ {
+ m_textPixelWidth = 0;
+ }
+
+ // Remove any wrapping data from after this line index onwards
+
+ while ((m_linePositions.size() > 0) &&
+ (m_linePositions.size() - 1 > (int)lineIndex))
+ {
+ m_linePositions.pop_back();
+ }
+
+ // Adjust start position of wrapping loop so that it starts with
+ // the current line index
+
+ if (m_linePositions.size() > 0)
+ {
+ pos = m_linePositions[m_linePositions.size() - 1];
+ }
+ }
+ else
+ {
+ // Remove all wrapping data
+
+ // Wipe the width variable
+
+ m_textPixelWidth = 0;
+
+ // Empty existing longest lines
+
+ m_longestLines.clear();
+
+ // Empty existing line positions
+
+ m_linePositions.clear();
+
+ // Push first line start into vector
+
+ m_linePositions.push_back(0);
+ }
+
+ // Loop through string until the end
+
+ CStringIterator *iterator = newStringIterator();
+
+ while (!endReached)
+ {
+ breakIndex = 0;
+ lineWidth = 0;
+
+ if (iterator->moveTo(pos))
+ {
+ // Search for line breaks and valid breakpoints until we
+ // exceed the width of the text field or we run out of
+ // string to process
+
+ while (lineWidth + m_font->getCharWidth(iterator->getChar()) <= m_width)
+ {
+ lineWidth += m_font->getCharWidth(iterator->getChar());
+
+ // Check for line return
+
+ if (iterator->getChar() == '\n')
+ {
+ // Remember this breakpoint
+
+ breakIndex = iterator->getIndex();
+ break;
+ }
+ else if ((iterator->getChar() == ' ') ||
+ (iterator->getChar() == ',') ||
+ (iterator->getChar() == '.') ||
+ (iterator->getChar() == '-') ||
+ (iterator->getChar() == ':') ||
+ (iterator->getChar() == ';') ||
+ (iterator->getChar() == '?') ||
+ (iterator->getChar() == '!') ||
+ (iterator->getChar() == '+') ||
+ (iterator->getChar() == '=') ||
+ (iterator->getChar() == '/') ||
+ (iterator->getChar() == '\0'))
+ {
+ // Remember the most recent breakpoint
+
+ breakIndex = iterator->getIndex();
+ }
+
+ // Move to the next character
+
+ if (!iterator->moveToNext())
+ {
+ // No more text; abort loop
+
+ endReached = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ endReached = true;
+ }
+
+ if ((!endReached) && (iterator->getIndex() > pos))
+ {
+ // Process any found data
+
+ // If we didn't find a breakpoint split at the current position
+
+ if (breakIndex == 0)
+ {
+ breakIndex = iterator->getIndex() - 1;
+ }
+
+ // Trim blank space from the start of the next line
+
+ CStringIterator *breakIterator = newStringIterator();
+
+ if (breakIterator->moveTo(breakIndex + 1))
+ {
+ while (breakIterator->getChar() == ' ')
+ {
+ if (breakIterator->moveToNext())
+ {
+ breakIndex++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ delete breakIterator;
+
+ // Add the start of the next line to the vector
+
+ pos = breakIndex + 1;
+ m_linePositions.push_back(pos);
+
+ // Is this the longest line observed so far?
+
+ if (lineWidth > m_textPixelWidth)
+ {
+ m_textPixelWidth = lineWidth;
+
+ // Push the description of the line into the longest lines
+ // vector (note that we store the index in m_linePositions that
+ // refers to the start of the line, *not* the position of the
+ // line in the char array)
+
+ LongestLine line;
+ line.index = m_linePositions.size() - 2;
+ line.width = lineWidth;
+ m_longestLines.push_back(line);
+ }
+ }
+ else if (!endReached)
+ {
+ // Add a blank row if we're not at the end of the string
+
+ pos++;
+ m_linePositions.push_back(pos);
+ }
+ }
+
+ // Add marker indicating end of text
+ // If we reached the end of the text, append the stopping point
+
+ if (m_linePositions[m_linePositions.size() - 1] != getLength() + 1)
+ {
+ m_linePositions.push_back(getLength());
+ }
+
+ delete iterator;
+
+ // Calculate the total height of the text
+
+ m_textPixelHeight = getLineCount() * (m_font->getHeight() + m_lineSpacing);
+
+ // Ensure height is always at least one row
+
+ if (m_textPixelHeight == 0)
+ {
+ m_textPixelHeight = m_font->getHeight() + m_lineSpacing;
+ }
+}
+
+/**
+ * Get the index of the line of text that contains the specified index
+ * within the raw char array.
+ *
+ * @param index The index to locate within the wrapped lines of text.
+ * @return The number of the line of wrapped text that contains the
+ * specified index.
+ */
+
+const int CText::getLineContainingCharIndex(const int index) const
+{
+ // Early exit if there is no existing line data
+
+ if (m_linePositions.size() == 0)
+ {
+ return 0;
+ }
+
+ // Early exit if the character is in the last row
+
+ if (index >= m_linePositions[m_linePositions.size() - 2])
+ {
+ return m_linePositions.size() - 2;
+ }
+
+ // Binary search the line vector for the line containing the supplied index
+
+ int bottom = 0;
+ int top = m_linePositions.size() - 1;
+ int mid;
+
+ while (bottom <= top)
+ {
+ // Standard binary search
+
+ mid = (bottom + top) >> 1;
+
+ if (index < m_linePositions[mid])
+ {
+ // Index is somewhere in the lower search space
+
+ top = mid - 1;
+ }
+ else if (index > m_linePositions[mid])
+ {
+ // Index is somewhere in the upper search space
+
+ bottom = mid + 1;
+ }
+ else if (index == m_linePositions[mid])
+ {
+ // Located the index
+
+ return mid;
+ }
+
+ // Check to see if we've moved past the line that contains the index
+ // We have to do this because the index we're looking for can be within
+ // a line; it isn't necessarily the start of a line (which is what is
+ // stored in the m_linePositions vector)
+
+ if (index > m_linePositions[top])
+ {
+ // Search index falls within the line represented by the top position
+
+ return top;
+ }
+ else if (index < m_linePositions[bottom])
+ {
+ // Search index falls within the line represented by the bottom position
+
+ return bottom - 1;
+ }
+ }
+
+ // Line cannot be found
+
+ return 0;
+}
diff --git a/NxWidgets/libnxwidgets/src/ctextbox.cxx b/NxWidgets/libnxwidgets/src/ctextbox.cxx
new file mode 100644
index 000000000..9c22a2bfa
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/ctextbox.cxx
@@ -0,0 +1,679 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/ctextbox.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "ctextbox.hxx"
+#include "cgraphicsport.hxx"
+#include "cnxtimer.hxx"
+#include "cstringiterator.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * CButton Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor for a textbox containing a string.
+ *
+ * @param pWidgetControl The controlling widget for the window
+ * @param x The x coordinate of the text box, relative to its parent.
+ * @param y The y coordinate of the text box, relative to its parent.
+ * @param width The width of the textbox.
+ * @param height The height of the textbox.
+ * @param text Pointer to a string to display in the textbox.
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * defaultCWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CTextBox::CTextBox(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t width, nxgl_coord_t height,
+ const CNxString &text, CWidgetStyle *style)
+ : CLabel(pWidgetControl, x, y, width, height, text, style)
+{
+ // Initialize state
+
+ m_cursorPos = 0;
+ m_showCursor = SHOW_CURSOR_ONFOCUS;
+ m_wrapCursor = false;
+ m_textChange = false;
+ m_flags.doubleClickable = true;
+
+ // Set the border thickness (2 lines)
+
+ m_borderSize.top = 2;
+ m_borderSize.right = 2;
+ m_borderSize.bottom = 2;
+ m_borderSize.left = 2;
+
+ // Move the cursor to the end of the string
+
+ moveCursorToPosition(m_text.getLength());
+
+ // Register to receive keypress events
+
+ addWidgetEventHandler(static_cast<CWidgetEventHandler *>(this));
+}
+
+/**
+ * Shows the cursor.
+ *
+ * @param cursorMode Determines cursor display mode
+ */
+
+void CTextBox::showCursor(EShowCursor cursorMode)
+{
+ if (m_showCursor != cursorMode)
+ {
+ m_showCursor = cursorMode;
+ redraw();
+ }
+}
+
+/**
+ * Set the text displayed in the label.
+ *
+ * @param text String to display.
+ */
+
+void CTextBox::setText(const CNxString &text)
+{
+ m_text.setText(text);
+ repositionCursor(m_text.getLength());
+ onTextChange();
+}
+
+/**
+ * Append new text to the end of the current text displayed in the
+ * label.
+ *
+ * @param text String to append.
+ */
+
+void CTextBox::appendText(const CNxString &text)
+{
+ m_text.append(text);
+ repositionCursor(m_text.getLength());
+ onTextChange();
+}
+
+/**
+ * Remove all characters from the string from the start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ */
+
+void CTextBox::removeText(const unsigned int startIndex)
+{
+ m_text.remove(startIndex);
+ repositionCursor(startIndex);
+ onTextChange();
+}
+
+/**
+ * Remove specified number of characters from the string from the
+ * start index onwards.
+ *
+ * @param startIndex Index to remove from.
+ * @param count Number of characters to remove.
+ */
+
+void CTextBox::removeText(const unsigned int startIndex, const unsigned int count)
+{
+ m_text.remove(startIndex, count);
+ repositionCursor(startIndex);
+ onTextChange();
+}
+
+/**
+ * Insert text at the specified index.
+ *
+ * @param text The text to insert.
+ * @param index Index at which to insert the text.
+ */
+
+void CTextBox::insertText(const CNxString &text, const unsigned int index)
+{
+ m_text.insert(text, index);
+ repositionCursor(index + text.getLength());
+ onTextChange();
+}
+
+/**
+ * Insert text at the current cursor position.
+ *
+ * @param text The text to insert.
+ */
+
+void CTextBox::insertTextAtCursor(const CNxString &text)
+{
+ insertText(text, getCursorPosition());
+}
+
+/**
+ * Move the cursor to the text position specified. 0 indicates the
+ * start of the string. If position is greater than the length of the
+ * string, the cursor is moved to the end of the string.
+ *
+ * @param position The new cursor position.
+ */
+
+void CTextBox::moveCursorToPosition(const int position)
+{
+ if (repositionCursor(position))
+ {
+ calculateTextPositionHorizontal();
+ redraw();
+ }
+}
+
+/**
+ * Handle a keyboard press event.
+ *
+ * @param e The event data.
+ */
+
+void CTextBox::handleKeyPressEvent(const CWidgetEventArgs &e)
+{
+ nxwidget_char_t key = e.getKey();
+
+ if (key == KEY_CODE_BACKSPACE)
+ {
+ if (m_cursorPos == 0) return;
+
+ // Delete the character in front of the cursor
+
+ removeText(m_cursorPos - 1, 1);
+ }
+ else if (key == KEY_CODE_ENTER)
+ {
+ // Fire an action event
+
+ m_widgetEventHandlers->raiseActionEvent();
+ }
+ else if (key != KEY_CODE_NONE)
+ {
+ // Not modifier; append value
+
+ insertTextAtCursor(key);
+ }
+}
+
+/**
+ * Handle a cursor control event. Replaces CWidgetEventHandler method.
+ *
+ * @param e The event data.
+ */
+
+void CTextBox::handleCursorControlEvent(const CWidgetEventArgs &e)
+{
+ ECursorControl control = e.getCursorControl();
+
+ if (control == CURSOR_LEFT)
+ {
+ if (m_cursorPos > 0)
+ {
+ moveCursorToPosition(m_cursorPos - 1);
+ }
+ else if (m_wrapCursor)
+ {
+ moveCursorToPosition(m_text.getLength() - 1);
+ }
+ }
+ else if (control == CURSOR_RIGHT)
+ {
+ if (m_cursorPos < m_text.getLength())
+ {
+ moveCursorToPosition(m_cursorPos + 1);
+ }
+ else if (m_wrapCursor)
+ {
+ moveCursorToPosition(0);
+ }
+ }
+}
+
+/**
+ * Redraws the widget
+ */
+
+void CTextBox::onBlur(void)
+{
+ redraw();
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CTextBox::drawContents(CGraphicsPort *port)
+{
+ // Get the drawing area (excluding the border)
+
+ CRect rect;
+ getRect(rect);
+
+ // Determine the background and text color
+
+ nxgl_mxpixel_t textColor;
+ nxgl_mxpixel_t backColor;
+
+ if (!isEnabled())
+ {
+ textColor = getDisabledTextColor();
+ backColor = getBackgroundColor();
+ }
+ else if (m_highlighted)
+ {
+ textColor = getSelectedTextColor();
+ backColor = getSelectedBackgroundColor();
+ }
+ else
+ {
+ textColor = getEnabledTextColor();
+ backColor = getBackgroundColor();
+ }
+
+ // Draw the background (excluding the border)
+
+ port->drawFilledRect(rect.getX(), rect.getY(),
+ rect.getWidth(), rect.getHeight(), backColor);
+
+ // Get the X/Y position of the text within the textbox
+
+ struct nxgl_point_s pos;
+ pos.x = rect.getX() + m_align.x;
+ pos.y = rect.getY() + m_align.y;
+
+ // And draw the text
+
+ CNxFont *font = getFont();
+ port->drawText(&pos, &rect, font, m_text, 0, m_text.getLength(), textColor);
+
+ // Draw cursor
+
+ if (isCursorVisible())
+ {
+ // Calculate the (relative) cursor position
+ // Warning: drawText modifies pos!
+
+ pos.x = getCursorXPos() + m_align.x;
+ pos.y = m_align.y;
+
+ // Calculate the cursor width
+
+ struct nxgl_size_s size;
+ size.w = getCursorWidth();
+ size.h = getFont()->getHeight();
+
+ // Is the cursor wholly within the visible region?
+
+ if (pos.x >= 0 && pos.x + size.w < rect.getWidth())
+ {
+ // Invert the colors in the cursor region.
+
+ pos.x += rect.getX();
+ pos.y += rect.getY();
+
+ port->invert(pos.x, pos.y, size.w, size.h);
+ }
+ }
+}
+
+/**
+ * Moves the cursor without redrawing.
+ *
+ * @param position New cursor position.
+ */
+
+bool CTextBox::repositionCursor(const int position)
+{
+ int len = m_text.getLength();
+
+ // Set the cursor position if the new position is within the string.
+
+ if (m_cursorPos != position && position <= len)
+ {
+ m_cursorPos = position;
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Move the cursor to the specified coordinates. The coordinates
+ * are expected to be the result of a click, and therefore in
+ * world-space rather than widget-space.
+ */
+
+void CTextBox::moveCursorToClickLocation(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // Work out where in the string the click coordinates represent
+ // and move the cursor to that location
+
+ if (m_text.getLength() > 0)
+ {
+ // Transform click coordinates to widget-space coordinates
+
+ nxgl_coord_t clickX = x - getX() - m_borderSize.left;
+ nxgl_coord_t charX = m_align.x;
+
+ // Locate the first character that comes after the clicked character
+
+ CStringIterator *iterator = m_text.newStringIterator();
+
+ while (charX < clickX)
+ {
+ charX += getFont()->getCharWidth(iterator->getChar());
+
+ if (!iterator->moveToNext())
+ {
+ break;
+ }
+ }
+
+ int index = iterator->getIndex();
+
+ // Move back to the clicked character if we've moved past it
+
+ if (charX > clickX)
+ {
+ iterator->moveToPrevious();
+ index = iterator->getIndex();
+ }
+ else if (charX < clickX)
+ {
+ // Move past end of string if click is after the text
+
+ index++;
+ }
+
+ moveCursorToPosition(index);
+ delete iterator;
+ }
+}
+
+/**
+ * Draw the area of this widget that falls within the clipping region.
+ * Called by the redraw() function to draw all visible regions.
+ *
+ * @param port The CGraphicsPort to draw to.
+ * @see redraw()
+ */
+
+void CTextBox::drawBorder(CGraphicsPort *port)
+{
+ // Check if the widget indicates it should have an outline: That
+ // the outline is enabled and the this is not just a text-only
+ // redraw
+
+ if (!isBorderless() && !isTextChange())
+ {
+ port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(),
+ getShineEdgeColor(), getShadowEdgeColor());
+ port->drawBevelledRect(getX() + 1, getY() + 1, getWidth() - 2, getHeight() - 2,
+ getShadowEdgeColor(), getShineEdgeColor());
+ }
+}
+
+/**
+ * Moves the cursor to the clicked coordinates.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+void CTextBox::onClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ moveCursorToClickLocation(x, y);
+}
+
+/**
+ * Does nothing.
+ *
+ * @param x The x coordinates of the click.
+ * @param y The y coordinates of the click.
+ */
+
+void CTextBox::onDoubleClick(nxgl_coord_t x, nxgl_coord_t y)
+{
+ // No double click action
+}
+
+/**
+ * Return true if the cursor is visible
+ */
+
+bool CTextBox::isCursorVisible(void) const
+{
+ return (m_showCursor == SHOW_CURSOR_ALWAYS ||
+ (m_showCursor == SHOW_CURSOR_ONFOCUS && hasFocus()));
+}
+
+/**
+ * Get the x coordinate of the cursor in pixels relative
+ * to the left-hand edge of the client rect.
+ *
+ * @return The x coordinate of the cursor in pixels.
+ */
+
+const nxgl_coord_t CTextBox::getCursorXPos(void) const
+{
+ // Calculate position of cursor
+
+ nxgl_coord_t cursorX = 0;
+
+ CStringIterator *iterator = m_text.newStringIterator();
+
+ for (nxgl_coord_t i = 0; i < m_cursorPos; i++)
+ {
+ cursorX += getFont()->getCharWidth(iterator->getChar());
+ iterator->moveToNext();
+ }
+
+ delete iterator;
+ return cursorX;
+}
+
+/**
+ * Get the width of the cursor in pixels.
+ *
+ * @return The width of the cursor in pixels.
+ */
+
+nxgl_coord_t CTextBox::getCursorWidth(void) const
+{
+ if (m_cursorPos < m_text.getLength())
+ {
+ // Cursor within the string - get the width of the character
+
+ return getFont()->getCharWidth(m_text.getCharAt(m_cursorPos));
+ }
+ else
+ {
+ // Cursor past end of string - get the width of a space
+
+ return getFont()->getCharWidth(' ');
+ }
+}
+
+/**
+ * Calculate the horizontal position of the string based on its length
+ * and the alignment options. Alignment options are overridden if the
+ * width of the string exceeds the width of the textbox.
+ */
+
+void CTextBox::calculateTextPositionHorizontal(void)
+{
+ // Calculate the string width - if the width is longer than the box,
+ // ignore alignment and align left
+
+ nxgl_coord_t stringWidth = getFont()->getStringWidth(m_text);
+
+ // Add the width of a blank space to the width to ensure that we can
+ // see the cursor
+
+ if (isCursorVisible())
+ {
+ stringWidth += getFont()->getCharWidth(' ');
+ }
+
+ CRect rect;
+ getClientRect(rect);
+
+ // Use alignment options if cursor is hidden or string is smaller
+ // than textbox
+
+ nxgl_coord_t width = rect.getWidth();
+ if ((stringWidth < width) || !isCursorVisible())
+ {
+ // Text not wider than box, so apply alignment options
+
+ switch (m_hAlignment)
+ {
+ case TEXT_ALIGNMENT_HORIZ_CENTER:
+ m_align.x = (width - stringWidth) >> 1;
+ break;
+
+ case TEXT_ALIGNMENT_HORIZ_LEFT:
+ m_align.x = rect.getX();
+ break;
+
+ case TEXT_ALIGNMENT_HORIZ_RIGHT:
+ m_align.x = width - stringWidth;
+ break;
+ }
+
+ return;
+ }
+
+ // Text is wider than box - view needs to follow the cursor
+ // If cursor is at the end of the text, we can just right-align
+
+ if (m_cursorPos == m_text.getLength())
+ {
+ m_align.x = width - stringWidth;
+ return;
+ }
+
+ // Work out the coordinates of the left edge of the cursor
+
+ int cursorX1 = getCursorXPos();
+
+ // Work out the coordinates of the right edge of the cursor
+
+ int cursorX2 = cursorX1 + getCursorWidth();
+
+ // Ensure that the cursor is on-screen
+
+ if (cursorX1 + m_align.x < 0)
+ {
+ // Cursor is off left side of screen, so adjust m_align.x
+
+ m_align.x = 0 - cursorX1;
+ }
+ else if (cursorX2 + m_align.x > width)
+ {
+ // Cursor is off right side of screen, so adjust m_align.x
+
+ m_align.x = width - cursorX2;
+ }
+
+ // We need to ensure that the text cannot be positioned in
+ // such a way that there is a gap between the end of the
+ // text and the right edge of the textbox
+
+ if (stringWidth + m_align.x < width)
+ {
+ m_align.x = width - stringWidth;
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
new file mode 100644
index 000000000..644abd714
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
@@ -0,0 +1,942 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <cstring>
+#include <sched.h>
+#include <cerrno>
+
+#include "nxconfig.hxx"
+#include "cnxserver.hxx"
+#include "cnxwidget.hxx"
+#include "cnxfont.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxtimer.hxx"
+#include "cgraphicsport.hxx"
+#include "cwidgetcontrol.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Static Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+/**
+ * CWidgetControl constructor (for the case where the display size is known)
+ *
+ * @param style The style that the widget should use. If this is not
+ * specified, the widget will use the values stored in the global
+ * defaultCWidgetStyle object. The widget will copy the properties of
+ * the style into its own internal style object.
+ */
+
+CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
+{
+ // Initialize state
+
+ m_port = (CGraphicsPort *)NULL;
+ m_haveGeometry = false;
+ m_clickedWidget = (CNxWidget *)NULL;
+ m_focusedWidget = (CNxWidget *)NULL;
+
+ // Initialize data that we will get from the position callback
+
+ m_hWindow = NULL;
+ m_size.h = 0;
+ m_size.w = 0;
+ m_pos.x = 0;
+ m_pos.y = 0;
+ m_bounds.pt1.x = 0;
+ m_bounds.pt1.y = 0;
+ m_bounds.pt2.y = 0;
+ m_bounds.pt2.y = 0;
+
+ // Initialize the mouse/touchscreen event and keyboard data structures
+
+ memset(&m_mouse, 0, sizeof(struct SMouse));
+ m_nCh = 0;
+ m_nCc = 0;
+
+ // Intialize semaphores:
+ //
+ // m_waitSem. The semaphore that will wake up the external logic on mouse events,
+ // keypress events, or widget deletion events.
+ // m_geoSem. The semaphore that will synchronize window size and position
+ // information.
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ m_waiting = false;
+ sem_init(&m_waitSem, 0, 0);
+#endif
+#ifdef CONFIG_NX_MULTIUSER
+ sem_init(&m_geoSem, 0, 0);
+#endif
+
+ // Do we need to fetch the default style?
+
+ if (style == (CWidgetStyle *)NULL)
+ {
+ // Get the style from the controlling widget
+
+ copyWidgetStyle(&m_style, g_defaultWidgetStyle);
+ }
+ else
+ {
+ // Use specified style
+
+ copyWidgetStyle(&m_style, style);
+ }
+}
+
+
+/**
+ * Destructor.
+ */
+
+CWidgetControl::~CWidgetControl(void)
+{
+ // Notify any external waiters... this should not happen because it
+ // it is probably already too late
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ postWindowEvent();
+#endif
+
+ // Delete any contained instances
+
+ if (m_port)
+ {
+ delete m_port;
+ }
+
+ // Flush the delete queue
+
+ processDeleteQueue();
+
+ // Delete controlled widget list
+
+ while (m_widgets.size() > 0)
+ {
+ m_widgets[0]->destroy();
+ }
+}
+
+/**
+ * Wait for an interesting window event to occur (like a mouse or keyboard event).
+ * Caller's should exercise care to assure that the test for waiting and this
+ * call are "atomic" .. perhaps by locking the scheduler like:
+ *
+ * sched_lock();
+ * ...
+ * if (no interesting events)
+ * {
+ * window->waitForWindowEvent();
+ * }
+ * sched_unlock();
+ */
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+void CWidgetControl::waitForWindowEvent(void)
+{
+ m_waiting = true;
+ (void)sem_wait(&m_waitSem);
+ m_waiting = false;
+}
+#endif
+
+/**
+ * Wake up external logic waiting for a window event
+ */
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+void CWidgetControl::postWindowEvent(void)
+{
+ if (m_waiting)
+ {
+ (void)sem_post(&m_waitSem);
+ }
+}
+#endif
+
+/**
+ * Run all code that needs to take place on a periodic basis.
+ * This method normally called externally... either periodically
+ * or when a window event is detected. If CONFIG_NXWIDGET_EVENTWAIT
+ * is defined, then external logic want call waitWindow event and
+ * when awakened, they chould call this function. As an example:
+ *
+ * for (;;)
+ * {
+ * sched_lock(); // Make the sequence atomic
+ * if (!window->pollEvents(0))
+ * {
+ * window->waitWindowEvent();
+ * }
+ * sched_unlock();
+ * }
+ *
+ * This method is just a wrapper simply calls the following methods.
+ * It can easily be replace with custom, external logic.
+ *
+ * processDeleteQueue()
+ * pollMouseEvents(widget)
+ * pollKeyboardEvents()
+ * pollCursorControlEvents()
+ *
+ * @param widget. Specific widget to poll. Use NULL to run the
+ * all widgets in the window.
+ * @return True means some interesting event occurred
+ */
+
+bool CWidgetControl::pollEvents(CNxWidget *widget)
+{
+ // Delete any queued widgets
+
+ processDeleteQueue();
+
+ // Handle mouse input
+
+ bool mouseEvent = pollMouseEvents(widget);
+
+ // Handle keyboard input
+
+ bool keyboardEvent = pollKeyboardEvents();
+
+ // Handle cursor control input
+
+ bool cursorControlEvent = pollCursorControlEvents();
+ return mouseEvent || keyboardEvent || cursorControlEvent;
+}
+
+/**
+ * Get the index of the specified controlled widget.
+ *
+ * @param widget The widget to get the index of.
+ * @return The index of the widget. -1 if the widget is not found.
+ */
+
+const int CWidgetControl::getWidgetIndex(const CNxWidget *widget) const
+{
+ for (int i = 0; i < m_widgets.size(); i++)
+ {
+ if (m_widgets[i] == widget)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/**
+ * Remove a controlled widget
+ *
+ * @param widget The widget to be removed
+ */
+
+void CWidgetControl::removeControlledWidget(CNxWidget *widget)
+{
+ // Locate the widget
+
+ int index = getWidgetIndex(widget);
+ if (index >= 0)
+ {
+ m_widgets.erase(index);
+ }
+}
+
+/**
+ * Add a widget to the list of widgets to be deleted.
+ * Must never be called by anything other than the framework itself.
+ *
+ * @param widget The widget to add to the delete queue.
+ */
+
+void CWidgetControl::addToDeleteQueue(CNxWidget *widget)
+{
+ // Add the widget to the delete queue
+
+ m_deleteQueue.push_back(widget);
+
+ // Then wake up logic that may be waiting for a window event
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ postWindowEvent();
+#endif
+}
+
+/**
+ * Set the clicked widget pointer. Note that this should not be
+ * called by code other than within the CWidgetControl library itself.
+ *
+ * @param widget The new clicked widget.
+ */
+
+void CWidgetControl::setClickedWidget(CNxWidget *widget)
+{
+ // Do we have a clicked widget already?
+
+ if (m_clickedWidget != (CNxWidget *)NULL)
+ {
+ // Ensure that the existing clicked widget is released *outside* its bounds
+
+ m_clickedWidget->release(m_clickedWidget->getX() - 10, 0);
+ }
+
+ // Update the pointer
+
+ m_clickedWidget = widget;
+}
+
+/**
+ * Set the focused widget that will receive keyboard input.
+ *
+ * @param widget The new focused widget.
+ */
+
+void CWidgetControl::setFocusedWidget(CNxWidget *widget)
+{
+ if (m_focusedWidget != widget)
+ {
+ // This widget will now receive focus
+
+ m_focusedWidget = widget;
+
+ // Make sure that the widget knows that is has focus
+
+ widget->focus();
+ }
+}
+
+/**
+ * This event is called from CCallback instance to provide
+ * notifications of certain NX-server related events. This event,
+ * in particular, will occur when the position or size of the underlying
+ * window occurs.
+ *
+ * @param hWindow The window handle that should be used to communicate
+ * with the window
+ * @param pos The position of the window in the physical device space.
+ * @param size The size of the window.
+ * @param bounds The size of the underlying display (pixels x rows)
+ */
+
+void CWidgetControl::geometryEvent(NXHANDLE hWindow,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds)
+{
+ // Disable pre-emption so that we can be assured that the following
+ // operations are atomic
+
+ sched_lock();
+
+ // Save positional data that may change dynamically
+
+ m_pos.x = pos->x;
+ m_pos.y = pos->y;
+ m_size.h = size->h;
+ m_size.w = size->w;
+
+ // The first callback is important. This is the handshake that proves
+ // that we are truly communicating with the servier. This is also
+ // a critical point because this is when we know the physical
+ // dimensions of the underlying window.
+
+ if (!m_hWindow)
+ {
+ // Save one-time server specific information
+
+ m_hWindow = hWindow;
+ nxgl_rectcopy(&m_bounds, bounds);
+ }
+
+ // In the normal start up sequence, the window is created with zero size
+ // at position 0,0. The safe thing to do is to set the position (still
+ // with size 0, then then set the size. Assuming that is what is being
+ // done, we will not report that we have valid geometry until the size
+ // becomes nonzero.
+
+ if (!m_haveGeometry && size->h > 0 && size->w > 0)
+ {
+ // Wake up any threads waiting for initial position information.
+ // REVISIT: If the window is moved or repositioned, then the
+ // position and size data will be incorrect for a period of time.
+ // That case should be handled here as well.
+
+ m_haveGeometry = true;
+ giveGeoSem();
+ }
+
+ m_eventHandlers.raiseGeometryEvent();
+ sched_unlock();
+}
+
+/**
+ * This event is called from CCallback instance to provide
+ * notifications of certain NX-server related events. This event,
+ * in particular, will occur when the a portion of the window that was
+ * previously obscured is now exposed.
+ *
+ * @param rect The region in the window that must be redrawn.
+ * @param more True means that more re-draw requests will follow
+ */
+
+void CWidgetControl::redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more)
+{
+ // REVISIT. This is not not yet used and not fully implemented.
+ CRect rect;
+ rect.setNxRect(nxRect);
+ m_eventHandlers.raiseRedrawEvent();
+}
+
+/**
+ * This event is called from CCallback instance to provide notifications of
+ * certain NX-server related events. This event, in particular, means that
+ * new mouse data is available for the window.
+ *
+ * @param pos The (x,y) position of the mouse.
+ * @param buttons See NX_MOUSE_* definitions.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons)
+{
+ // Save the mouse X/Y position
+
+ m_mouse.x = pos->x;
+ m_mouse.y = pos->y;
+
+ // Update button press states
+
+ clearMouseEvents();
+
+ if ((buttons & NX_MOUSE_LEFTBUTTON) != 0)
+ {
+ // Handle left button press events. leftHeld means that the left mouse
+ // button was pressed on the previous sample as well.
+
+ if (m_mouse.leftHeld)
+ {
+ m_mouse.leftDrag = 1;
+ }
+ else
+ {
+ // New left button press
+
+ m_mouse.leftPressed = 1;
+
+ (void)clock_gettime(CLOCK_REALTIME, &m_mouse.leftPressTime);
+
+ // Check for double click event
+
+ if (elapsedTime(&m_mouse.leftReleaseTime) <= CONFIG_NXWIDGETS_DOUBLECLICK_TIME)
+ {
+ m_mouse.doubleClick = 1;
+ }
+ }
+
+ m_mouse.leftHeld = 1;
+ }
+ else
+ {
+ // Handle left button release events
+
+ if (m_mouse.leftHeld)
+ {
+ // New left button release
+
+ m_mouse.leftReleased = 1;
+ (void)clock_gettime(CLOCK_REALTIME, &m_mouse.leftReleaseTime);
+ }
+
+ m_mouse.leftHeld = 0;
+ }
+
+#if 0 // Center and right buttons not used
+ if ((buttons & NX_MOUSE_CENTERBUTTON) != 0)
+ {
+ // Handle center button press events. centerHeld means that the center mouse
+ // button was pressed on the previous sample as well.
+
+ if (m_mouse.centerHeld)
+ {
+ m_mouse.centerDrag = 1;
+ }
+ else
+ {
+ // New center button press
+
+ m_mouse.centerPressed = 1;
+ }
+
+ m_mouse.centerHeld = 1;
+ }
+ else
+ {
+ // Handle center button release events
+
+ if (m_mouse.centerHeld)
+ {
+ // New center button release
+
+ m_mouse.centerReleased = 1;
+ }
+
+ m_mouse.centerHeld = 0;
+ }
+
+ if ((buttons & NX_MOUSE_RIGHTBUTTON) != 0)
+ {
+ // Handle right button press events. rightHeld means that the right mouse
+ // button was pressed on the previous sample as well.
+
+ if (m_mouse.rightHeld)
+ {
+ m_mouse.rightDrag = 1;
+ }
+ else
+ {
+ // New right button press
+
+ m_mouse.rightPressed = 1;
+ }
+
+ m_mouse.rightHeld = 1;
+ }
+ else
+ {
+ // Handle right button release events
+
+ if (m_mouse.rightHeld)
+ {
+ // New right button release
+
+ m_mouse.rightReleased = 1;
+ }
+
+ m_mouse.rightHeld = 0;
+ }
+#endif
+
+ // Notify any external logic that a keyboard event has occurred
+
+ m_eventHandlers.raiseMouseEvent();
+
+ // Then wake up logic that may be waiting for a window event
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ postWindowEvent();
+#endif
+}
+#endif
+
+/**
+ * This event is called from CCallback instance to provide notifications of
+ * certain NX-server related events. This event, in particular, means that
+ * keyboard/keypad data is available for the window.
+ *
+ * @param nCh The number of characters that are available in pStr[].
+ * @param pStr The array of characters.
+ */
+
+#ifdef CONFIG_NX_KBD
+void CWidgetControl::newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr)
+{
+ FAR uint8_t *pBuffer = &m_kbdbuf[m_nCh];
+
+ // Append each new character to keyboard character buffer
+
+ for (uint8_t i = 0;
+ i < nCh && m_nCh < CONFIG_NXWIDGETS_KBDBUFFER_SIZE;
+ i++, m_nCh++)
+ {
+ *pBuffer++ = *pStr++;
+ }
+
+ // Notify any external logic that a keyboard event has occurred
+
+ m_eventHandlers.raiseKeyboardEvent();
+
+ // Then wake up logic that may be waiting for a window event
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ postWindowEvent();
+#endif
+}
+#endif
+
+/**
+ * This event means that cursor control data is available for the window.
+ *
+ * @param cursorControl The cursor control code received.
+ */
+
+void CWidgetControl::newCursorControlEvent(ECursorControl cursorControl)
+{
+ // Append the new cursor control
+
+ if (m_nCc < CONFIG_NXWIDGETS_CURSORCONTROL_SIZE)
+ {
+ m_controls[m_nCc] = (uint8_t)cursorControl;
+ m_nCc++;
+ }
+
+ // Then wake up logic that may be waiting for a window event
+
+#ifdef CONFIG_NXWIDGET_EVENTWAIT
+ postWindowEvent();
+#endif
+}
+
+/**
+ * The creation sequence is:
+ *
+ * 1) Create a dumb CWigetControl instance
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow.
+ * 3) The call this method with the static_cast to INxWindow to,
+ * finally, create the CGraphicsPort for this window.
+ * 4) After that, the fully smartend CWidgetControl instance can
+ * be used to generate additional widgets.
+ *
+ * @param window The instance of INxWindow needed to construct the
+ * CGraphicsPort instance
+ */
+
+bool CWidgetControl::createGraphicsPort(INxWindow *window)
+{
+#ifdef CONFIG_NX_WRITEONLY
+ m_port = new CGraphicsPort(window, m_style.colors.background);
+#else
+ m_port = new CGraphicsPort(window);
+#endif
+ return m_port != (CGraphicsPort *)NULL;
+}
+
+/**
+ * Copy a widget style
+ *
+ * @param dest The destination style
+ * @param src The source to use
+ */
+
+void CWidgetControl::copyWidgetStyle(CWidgetStyle *dest, const CWidgetStyle *src)
+{
+ dest->colors.background = src->colors.background;
+ dest->colors.selectedBackground = src->colors.selectedBackground;
+ dest->colors.shineEdge = src->colors.shineEdge;
+ dest->colors.shadowEdge = src->colors.shadowEdge;
+ dest->colors.highlight = src->colors.highlight;
+ dest->colors.disabledText = src->colors.disabledText;
+ dest->colors.enabledText = src->colors.enabledText;
+ dest->colors.selectedText = src->colors.selectedText;
+ dest->font = src->font;
+}
+
+/**
+ * Return the elapsed time in millisconds
+ *
+ * @param tp A time in the past from which to compute the elapsed time.
+ * @return The elapsed time since tp
+ */
+
+uint32_t CWidgetControl::elapsedTime(FAR const struct timespec *startTime)
+{
+ struct timespec endTime;
+
+ (void)clock_gettime(CLOCK_REALTIME, &endTime);
+ if (startTime->tv_sec <= endTime.tv_sec)
+ {
+ // Get the elapsed seconds
+
+ uint32_t seconds = endTime.tv_sec - startTime->tv_sec;
+
+ // Get the elapsed nanoseconds, borrowing from the seconds if necessary
+
+ int32_t endNanoSeconds = endTime.tv_nsec;
+ if (startTime->tv_nsec > endNanoSeconds)
+ {
+ // Are there any seconds to borrow from?
+
+ if (seconds < 1)
+ {
+ // startTime is in the future???
+
+ return 0;
+ }
+
+ // Borrow from the seconds
+
+ seconds--;
+ endNanoSeconds += 1000000000;
+ }
+ uint32_t nanoseconds = endNanoSeconds - startTime->tv_nsec;
+
+ // Then return the elapsed time in milliseconds
+
+ return seconds * 1000000 + nanoseconds / 1000;
+ }
+
+ // startTime is in the future???
+
+ return 0;
+}
+
+/**
+ * Pass clicks to the widget hierarchy. If a single widget
+ * is supplied, only that widget is sent the click.
+ *
+ * @param x Click xcoordinate.
+ * @param y Click ycoordinate.
+ * @param widget Pointer to a specific widget or NULL.
+ */
+
+void CWidgetControl::handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *widget)
+{
+ // Working with a specific widget or the whole structure?
+
+ if (widget == (CNxWidget *)NULL)
+ {
+ // All widgets
+
+ for (int i = m_widgets.size() - 1; i > -1; i--)
+ {
+ if (m_widgets[i]->click(x, y))
+ {
+ return;
+ }
+ }
+ }
+ else
+ {
+ // One widget
+
+ (void)widget->click(x, y);
+ }
+}
+
+/**
+ * Delete any widgets in the deletion queue.
+ */
+
+void CWidgetControl::processDeleteQueue(void)
+{
+ int i = 0;
+ while (i < m_deleteQueue.size())
+ {
+ m_deleteQueue[i]->destroy();
+ i++;
+ }
+
+ m_deleteQueue.clear();
+}
+
+/**
+ * Process mouse/touchscreen events and send throughout the hierarchy.
+ *
+ * @param widget. Specific widget to poll. Use NULL to run the
+ * all widgets in the window.
+ * @return True means a mouse event occurred
+ */
+
+bool CWidgetControl::pollMouseEvents(CNxWidget *widget)
+{
+ bool mouseEvent = true; // Assume that an interesting mouse event occurred
+
+ // All widgets
+
+ if (m_mouse.leftPressed)
+ {
+ // Handle a new left button press event
+
+ handleLeftClick(m_mouse.x, m_mouse.y, widget);
+ }
+ else if (m_mouse.leftDrag)
+ {
+ // The left button is still being held down
+
+ if (m_clickedWidget != (CNxWidget *)NULL)
+ {
+ // Handle a mouse drag event
+
+ m_clickedWidget->drag(m_mouse.x, m_mouse.y,
+ m_mouse.x - m_mouse.lastX,
+ m_mouse.y - m_mouse.lastY);
+ }
+ }
+ else if (m_clickedWidget != (CNxWidget *)NULL)
+ {
+ // Mouse left button release event
+
+ m_clickedWidget->release(m_mouse.x, m_mouse.y);
+ }
+ else
+ {
+ // No interesting mouse events
+
+ mouseEvent = false;
+ }
+
+ // Clear all press and release events once they have been processed
+
+ clearMouseEvents();
+
+ // Save the mouse position for the next poll
+
+ m_mouse.lastX = m_mouse.x;
+ m_mouse.lastY = m_mouse.y;
+ return mouseEvent;
+}
+
+/**
+ * Process keypad events and send throughout the hierarchy.
+ *
+ * @return True means a keyboard event occurred
+ */
+
+bool CWidgetControl::pollKeyboardEvents(void)
+{
+ bool keyboardEvent = false; // Assume no interesting keyboard events
+
+ // Keyboard presses with no focused widget is not an interesting
+ // event
+
+ if (m_focusedWidget != (CNxWidget *)NULL)
+ {
+ // Forward each character to the widget with the focus
+
+ for (uint8_t i = 0; i < m_nCh; i++)
+ {
+ m_focusedWidget->keyPress((nxwidget_char_t)m_kbdbuf[i]);
+ keyboardEvent = true;
+ }
+ }
+
+ // All of the buffered characters have been consumed
+
+ m_nCh = 0;
+ return keyboardEvent;
+}
+
+/**
+ * Process cursor control events and send throughout the hierarchy.
+ *
+ * @return True means a cursor control event was processes
+ */
+
+bool CWidgetControl::pollCursorControlEvents(void)
+{
+ bool cursorControlEvent = false; // Assume no interesting cursor events
+
+ // Cursor controls with no focused widget is not an interesting
+ // event
+
+ if (m_focusedWidget != (CNxWidget *)NULL)
+ {
+ // Forward each cursor control to the widget with the focus
+
+ for (uint8_t i = 0; i < m_nCc; i++)
+ {
+ m_focusedWidget->cursorControl((ECursorControl)m_controls[i]);
+ cursorControlEvent = true;
+ }
+ }
+
+ // All of the buffered events have been consumed
+
+ m_nCc = 0;
+ return cursorControlEvent;
+}
+
+/**
+ * Take the geometry semaphore (handling signal interruptions)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CWidgetControl::takeGeoSem(void)
+{
+ // Take the geometry semaphore. Retry is an error occurs (only if
+ // the error is due to a signal interruption).
+
+ int ret;
+ do
+ {
+ ret = sem_wait(&m_geoSem);
+ }
+ while (ret < 0 && errno == EINTR);
+}
+#endif
+
+/**
+ * Clear all mouse events
+ */
+
+void CWidgetControl::clearMouseEvents(void)
+{
+ // Clear all press and release events once they have been processed
+
+ m_mouse.leftPressed = 0;
+ m_mouse.leftReleased = 0;
+ m_mouse.leftDrag = 0;
+
+#if 0 // Center and right buttons are not used
+ m_mouse.centerPressed = 0;
+ m_mouse.centerReleased = 0;
+ m_mouse.centerDrag = 0;
+
+ m_mouse.rightPressed = 0;
+ m_mouse.rightReleased = 0;
+ m_mouse.rightDrag = 0;
+#endif
+
+ m_mouse.doubleClick = 0;
+}
diff --git a/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx
new file mode 100644
index 000000000..bebab89aa
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx
@@ -0,0 +1,538 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cnxwidget.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgeteventargs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+#define DOUBLE_CLICK_BOUNDS 10
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Constructor.
+ *
+ * @param widget The owning widget.
+ */
+
+CWidgetEventHandlerList::CWidgetEventHandlerList(CNxWidget *widget)
+{
+ m_widget = widget;
+ m_isEnabled = true;
+}
+
+/**
+ * Check if the object raises events or not.
+ *
+ * @return True if events are enabled.
+ */
+
+bool CWidgetEventHandlerList::isEnabled(void) const
+{
+ return m_isEnabled && !m_widget->isDeleted();
+}
+
+/**
+ * Adds a widget event handler. The event handler will receive
+ * all events raised by this object.
+ * @param eventHandler A pointer to the event handler.
+ */
+
+void CWidgetEventHandlerList::addWidgetEventHandler(CWidgetEventHandler *eventHandler)
+{
+ // Prevent insertion if the handler already exists
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ if (m_widgetEventHandlers.at(i) == eventHandler)
+ {
+ return;
+ }
+ }
+
+ // Add the new handler
+
+ m_widgetEventHandlers.push_back(eventHandler);
+}
+
+/**
+ * Remove a widget event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+void CWidgetEventHandlerList::removeWidgetEventHandler(CWidgetEventHandler *eventHandler)
+{
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ if (m_widgetEventHandlers.at(i) == eventHandler)
+ {
+ m_widgetEventHandlers.erase(i);
+ return;
+ }
+ }
+}
+
+/**
+ * Raise a click event to the event handler.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CWidgetEventHandlerList::raiseClickEvent(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleClickEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a double-click event to the event handler.
+ *
+ * @param x The x coordinate of the click.
+ * @param y The y coordinate of the click.
+ */
+
+void CWidgetEventHandlerList::raiseDoubleClickEvent(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleDoubleClickEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a mouse release event to the event handler.
+ *
+ * @param x The x coordinate of the release.
+ * @param y The y coordinate of the release.
+ */
+
+void CWidgetEventHandlerList::raiseReleaseEvent(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleReleaseEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a mouse release-outside event to the event handler.
+ *
+ * @param x The x coordinate of the release.
+ * @param y The y coordinate of the release.
+ */
+
+void CWidgetEventHandlerList::raiseReleaseOutsideEvent(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleReleaseOutsideEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a mouse drag event to the event handler.
+ *
+ * @param x The x coordinate of the mouse when the drag started.
+ * @param y The y coordinate of the mouse when the drag started.
+ * @param vX The horizontal distance dragged.
+ * @param vY The vertical distance dragged.
+ */
+
+void CWidgetEventHandlerList::raiseDragEvent(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, vX, vY, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleDragEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a widget drop event to the event handler.
+ *
+ * @param x The x coordinate of the mouse when the drop occurred.
+ * @param y The y coordinate of the mouse when the drop occurred.
+ */
+
+void CWidgetEventHandlerList::raiseDropEvent(nxgl_coord_t x, nxgl_coord_t y)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleDropEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a key press event to the event handler.
+ *
+ * @param key The code of the key that caused the event.
+ */
+
+void CWidgetEventHandlerList::raiseKeyPressEvent(nxwidget_char_t key)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, key);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleKeyPressEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a cursor control event to the event handler.
+ *
+ * @param cursorControl The cursor control code that caused the event.
+ */
+
+void CWidgetEventHandlerList::raiseCursorControlEvent(ECursorControl cursorControl)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, (nxwidget_char_t)cursorControl);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleCursorControlEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a focus event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseFocusEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleFocusEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a blur event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseBlurEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleBlurEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a close event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseCloseEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleCloseEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a hide event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseHideEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleHideEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a show event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseShowEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleShowEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise an enable event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseEnableEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleEnableEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a disable event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseDisableEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleDisableEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a value change event to the event handler.
+ */
+
+void CWidgetEventHandlerList::raiseValueChangeEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleValueChangeEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a resize event to the event handler.
+ *
+ * @param width The new width of the widget.
+ * @param height The new height of the widget.
+ */
+
+void CWidgetEventHandlerList::raiseResizeEvent(nxgl_coord_t width, nxgl_coord_t height)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleResizeEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise a move event to the event handler.
+ *
+ * @param x The new x coordinate of the widget.
+ * @param y The new y coordinate of the widget.
+ * @param vX The horizontal distance moved.
+ * @param vY The vertical distance moved.
+ */
+
+void CWidgetEventHandlerList::raiseMoveEvent(nxgl_coord_t x, nxgl_coord_t y,
+ nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, x, y, vX, vY, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleMoveEvent(e);
+ }
+ }
+}
+
+/**
+ * Raise an action event to the event handler. This should be called
+ * when a widget's purpose has been fulfilled. For example, in the case
+ * of a button, this event is raised when the button is released within
+ * its boundaries. The button has produced a valid click, and thus
+ * fulfilled its purpose, so it needs to raise an "action" event.
+ */
+
+void CWidgetEventHandlerList::raiseActionEvent(void)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleActionEvent(e);
+ }
+ }
+}
+
+/**
+ * Raises a scroll event. Fired when the panel scrolls.
+ *
+ * @param vX Horizontal distance scrolled.
+ * @param vY Vertical distance scrolled.
+ */
+
+void CWidgetEventHandlerList::raiseScrollEvent(nxgl_coord_t vX, nxgl_coord_t vY)
+{
+ if (isEnabled())
+ {
+ CWidgetEventArgs e(m_widget, 0, 0, vX, vY, KEY_CODE_NONE);
+
+ for (int i = 0; i < m_widgetEventHandlers.size(); i++)
+ {
+ m_widgetEventHandlers.at(i)->handleScrollEvent(e);
+ }
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
new file mode 100644
index 000000000..dfdabcf08
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
@@ -0,0 +1,175 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "nxconfig.hxx"
+
+#include "cwindoweventhandler.hxx"
+#include "cwindoweventhandlerlist.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/**
+ * Adds a window event handler. The event handler will receive
+ * all events raised by this object.
+ * @param eventHandler A pointer to the event handler.
+ */
+
+void CWindowEventHandlerList::addWindowEventHandler(CWindowEventHandler *eventHandler)
+{
+ // Make sure that the event handler does not already exist
+
+ int index;
+ if (!findWindowEventHandler(eventHandler, index))
+ {
+ // Add the new handler
+
+ m_eventHandlers.push_back(eventHandler);
+ }
+}
+
+/**
+ * Remove a window event handler.
+ *
+ * @param eventHandler A pointer to the event handler to remove.
+ */
+
+void CWindowEventHandlerList::removeWindowEventHandler(CWindowEventHandler *eventHandler)
+{
+ // Find the event handler to be removed
+
+ int index;
+ if (findWindowEventHandler(eventHandler, index))
+ {
+ // and remove it
+
+ m_eventHandlers.erase(index);
+ }
+}
+
+/**
+ * Return the index to the window event handler.
+ */
+
+bool CWindowEventHandlerList::findWindowEventHandler(CWindowEventHandler *eventHandler, int &index)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ if (m_eventHandlers.at(i) == eventHandler)
+ {
+ index = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Raise the NX window redraw event.
+ */
+
+void CWindowEventHandlerList::raiseRedrawEvent(void)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleRedrawEvent();
+ }
+}
+
+/**
+ * Raise an NX window position/size change event.
+ */
+
+void CWindowEventHandlerList::raiseGeometryEvent(void)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleGeometryEvent();
+ }
+}
+
+/**
+ * Raise an NX mouse window input event.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+void CWindowEventHandlerList::raiseMouseEvent(void)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleMouseEvent();
+ }
+}
+#endif
+
+/**
+ * Raise an NX keybord input event
+ */
+
+#ifdef CONFIG_NX_KBD
+void CWindowEventHandlerList::raiseKeyboardEvent(void)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleKeyboardEvent();
+ }
+#endif
+}
+
+/**
+ * Raise an NX window blocked event.
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+void CWindowEventHandlerList::raiseBlockedEvent(FAR void *arg)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleBlockedEvent(arg);
+ }
+}
diff --git a/NxWidgets/libnxwidgets/src/glyph_arrowdown.cxx b/NxWidgets/libnxwidgets/src/glyph_arrowdown.cxx
new file mode 100644
index 000000000..ec2a6baf0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_arrowdown.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_arrowdown.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_arrowDownGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_BLACK,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_BLACK,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_arrowDownGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_BLACK,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_BLACK,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_arrowDown =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 6, // width - Width in pixels
+ 10, // height - Height in rows
+ (6*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_arrowDownGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_arrowleft.cxx b/NxWidgets/libnxwidgets/src/glyph_arrowleft.cxx
new file mode 100644
index 000000000..6b3e8ee92
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_arrowleft.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_glypharrowleft.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_arrowLeftGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_arrowLeftGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_arrowLeft =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_arrowLeftGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_arrowright.cxx b/NxWidgets/libnxwidgets/src/glyph_arrowright.cxx
new file mode 100644
index 000000000..74763a6fd
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_arrowright.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_arrowright.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_arrowRightGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_arrowRightGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_arrowRight =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_arrowRightGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_arrowup.cxx b/NxWidgets/libnxwidgets/src/glyph_arrowup.cxx
new file mode 100644
index 000000000..9ec840d43
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_arrowup.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_arrowup.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_arrowUpGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_arrowUpGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_arrowUp =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 6, // width - Width in pixels
+ 10, // height - Height in rows
+ (6*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_arrowUpGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_backspace.cxx b/NxWidgets/libnxwidgets/src/glyph_backspace.cxx
new file mode 100644
index 000000000..967963347
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_backspace.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_backspace.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_backspaceGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_backspaceGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_backspace =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_backspaceGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_capslock.cxx b/NxWidgets/libnxwidgets/src/glyph_capslock.cxx
new file mode 100644
index 000000000..663e601f0
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_capslock.cxx
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_capslock.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_capslockGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_capslockGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_capslock =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_capslockGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
+
diff --git a/NxWidgets/libnxwidgets/src/glyph_checkboxmu.cxx b/NxWidgets/libnxwidgets/src/glyph_checkboxmu.cxx
new file mode 100644
index 000000000..681c17445
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_checkboxmu.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_checkboxmu.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_checkBoxMuGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP,
+ RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_checkBoxMuGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP,
+ RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_checkBoxMu =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_checkBoxMuGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_checkboxoff.cxx b/NxWidgets/libnxwidgets/src/glyph_checkboxoff.cxx
new file mode 100644
index 000000000..250d2455e
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_checkboxoff.cxx
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_checkboxoff.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_checkBoxOff =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 0, // width - Width in pixels
+ 0, // height - Height in rows
+ (0*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ (const nxgl_mxpixel_t*)NULL // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_checkboxon.cxx b/NxWidgets/libnxwidgets/src/glyph_checkboxon.cxx
new file mode 100644
index 000000000..5b9c18b78
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_checkboxon.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_checkboxon.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_checkBoxOnGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_checkBoxOnGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_checkBoxOn =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_checkBoxOnGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_control.cxx b/NxWidgets/libnxwidgets/src/glyph_control.cxx
new file mode 100644
index 000000000..ffbdf965b
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_control.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_control.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_controlGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_controlGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_control =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_controlGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_cycle.cxx b/NxWidgets/libnxwidgets/src/glyph_cycle.cxx
new file mode 100644
index 000000000..5c98b8b90
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_cycle.cxx
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_cycle.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_cycleGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_cycleGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_cycle =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_cycleGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
+
diff --git a/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx
new file mode 100644
index 000000000..5f1bd7dbf
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx
@@ -0,0 +1,3453 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "crlepalettebitmap.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define BITMAP_NLUTCODES 164 /* Number of unique RGB colors in the image */
+
+static const uint32_t g_nuttxLut[BITMAP_NLUTCODES] =
+{
+ 0x000000, 0x102028, 0x5898e0, 0x3c30e4, 0x3c34e4, 0x0c0828, 0x382ce4, 0x3c34e8, /* Codes 0-7 */
+ 0x3834d4, 0x241c74, 0x2c2490, 0x343c8c, 0x5ca0ec, 0x4454d0, 0x2c288c, 0x5ca0e8, /* Codes 8-15 */
+ 0x3830d4, 0x687078, 0xd0e4f0, 0x3428e4, 0x24282c, 0xcce4f0, 0x848cec, 0xdcf4f4, /* Codes 16-23 */
+ 0xd8ecf0, 0x2c24e0, 0xa8b8c4, 0xb4c4f0, 0x5854e4, 0xd8f0f0, 0xd8f0f4, 0x484890, /* Codes 24-31 */
+ 0x2c287c, 0x28287c, 0x282478, 0x342cb4, 0xcce0f0, 0xd8e8f4, 0xa8bcc8, 0x587c98, /* Codes 32-39 */
+ 0x5c98bc, 0x2c4c60, 0xe0f8fc, 0x1c1478, 0x2c2884, 0x302894, 0xfcfcfc, 0xd4e8f4, /* Codes 40-47 */
+ 0x5090b8, 0x101c20, 0xd8ecf8, 0x5c94bc, 0x8c90ec, 0x7c84bc, 0xc8e0f0, 0x98c0d8, /* Codes 48-55 */
+ 0xe8f0f8, 0x94bcd8, 0x3830e4, 0xb0bcec, 0xf4f8fc, 0xe4f0f8, 0x3c34ec, 0x142028, /* Codes 56-63 */
+ 0x5894bc, 0x5078ac, 0x5084b4, 0x282080, 0x3428b4, 0xd0e4f4, 0x70a4c8, 0x3c34d8, /* Codes 64-71 */
+ 0x7880b0, 0x5490b8, 0x5484b4, 0x281c78, 0x5ca4ec, 0xdcf4fc, 0x181078, 0x2c2880, /* Codes 72-79 */
+ 0x382cd0, 0x342cb8, 0x1c1888, 0x888cf0, 0xc4e0f0, 0x98c4dc, 0x180c74, 0x5080b0, /* Codes 80-87 */
+ 0x282480, 0x04000c, 0x282474, 0x4038f4, 0x3024ec, 0x302c9c, 0x7c84b4, 0x0c1c28, /* Codes 88-95 */
+ 0x5090e0, 0x3020e4, 0xd8f0f8, 0x7478b4, 0x100870, 0x08006c, 0x24188c, 0x201c7c, /* Codes 96-103 */
+ 0x2c2090, 0x5098d0, 0xd4e4f0, 0x589cd0, 0x3840e0, 0x4048e4, 0xc4dcf0, 0xdcf4f8, /* Codes 104-111 */
+ 0x3024e8, 0x342cac, 0x4878b8, 0x4048e0, 0x8084e8, 0x2c248c, 0x3430bc, 0x241c70, /* Codes 112-119 */
+ 0x141074, 0x3428e0, 0x342cec, 0x2c24b4, 0x201c78, 0x3028d0, 0x241c8c, 0x7078b4, /* Codes 120-127 */
+ 0x040028, 0xd4e8f0, 0x4c7cd4, 0x282078, 0x5484b0, 0x20285c, 0x20187c, 0x4c7cb0, /* Codes 128-135 */
+ 0x3830d0, 0x4034f0, 0x2820c8, 0xdcf0f4, 0x34408c, 0x98d4ec, 0x2c1ce0, 0x5080ac, /* Codes 136-143 */
+ 0x3c30e8, 0x7078a8, 0x04001c, 0x2c3034, 0x305064, 0x2c4458, 0x74a8c8, 0xf8f8fc, /* Codes 144-151 */
+ 0xdcecf8, 0xb0c0dc, 0xa0b0bc, 0xb4d4e4, 0x707880, 0x7c98a8, 0xdcf4f0, 0x2820ac, /* Codes 152-159 */
+ 0x201874, 0x302898, 0x3844ac, 0x507ce0, /* Codes 160-163 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+# define BITMAP_NLUTCODES 141 /* Number of unique RGB colors in the image */
+
+static const uint16_t g_nuttxLut[BITMAP_NLUTCODES] =
+{
+ 0x0000, 0x1105, 0x5cdc, 0x399c, 0x41bc, 0x0845, 0x397c, 0x39bc, 0x41bd, 0x39ba, /* Codes 0-9 */
+ 0x28ee, 0x3132, 0x31f2, 0x5d1d, 0x42ba, 0x3152, 0x399a, 0x6b8f, 0xd73e, 0x315c, /* Codes 10-19 */
+ 0x2945, 0x8c7d, 0xe7be, 0xdf7e, 0x313c, 0xadd9, 0xb63e, 0x5abd, 0xdf9e, 0xdf9f, /* Codes 20-29 */
+ 0x4a52, 0x2950, 0x292f, 0x3176, 0xcf1e, 0xdf5f, 0xadf9, 0x5bf3, 0x5cd8, 0x326c, /* Codes 30-39 */
+ 0xe7df, 0x18af, 0x3153, 0xdf5e, 0xffff, 0x5497, 0x10e4, 0xdf7f, 0x5cb8, 0x8c9d, /* Codes 40-49 */
+ 0x8437, 0x9e1b, 0xef9f, 0x9dfb, 0xb5fe, 0xffdf, 0x41be, 0x53d6, 0x5436, 0x2910, /* Codes 50-59 */
+ 0x3156, 0x7539, 0x39bb, 0x7c16, 0x95fb, 0x28ef, 0x653d, 0xe7bf, 0x188f, 0x397a, /* Codes 60-69 */
+ 0x3977, 0x20d1, 0x8c7e, 0xe79f, 0x9e3b, 0x186e, 0x5416, 0x2930, 0x0801, 0x41de, /* Codes 70-79 */
+ 0x313d, 0x3173, 0x7c36, 0x08e5, 0x549c, 0xd75f, 0x311c, 0x73d6, 0x3150, 0x315d, /* Codes 80-89 */
+ 0x104e, 0x080e, 0x20f0, 0x2912, 0x54da, 0xdf3e, 0x5cfa, 0x3a1c, 0x425c, 0xcefe, /* Codes 90-99 */
+ 0x4bd7, 0x843d, 0x2932, 0x3997, 0xf7df, 0x397d, 0x2936, 0x20ef, 0x315a, 0x20f1, /* Codes 100-109 */
+ 0x0005, 0xd75e, 0x53fa, 0x290f, 0x214b, 0x20cf, 0x4bf6, 0x2919, 0x3212, 0x9ebd, /* Codes 110-119 */
+ 0x28fc, 0x5415, 0x399d, 0x73d5, 0x0804, 0x3187, 0x328d, 0x2a2b, 0x7559, 0xe77f, /* Codes 120-129 */
+ 0xb61c, 0x3186, 0xa598, 0xbebd, 0x73d0, 0x84d5, 0x5cb7, 0x2916, 0x20ce, 0x3a35, /* Codes 130-139 */
+ 0x53fc /* Codes 140-140 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+# define BITMAP_NLUTCODES 116 /* Number of unique greyscale levels in the image */
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_nuttxLut[BITMAP_NLUTCODES] =
+{
+ 0x00, 0x19, 0x8b, 0x46, 0x4a, 0x0b, 0x8d, 0x41, 0x44, 0x27, 0x32, 0x92, 0x59, 0x34, 0x6d, 0xdb, /* Codes 0-15 */
+ 0x3f, 0x26, 0x91, 0xec, 0xe5, 0x39, 0xb4, 0xc0, 0x62, 0xe6, 0x4c, 0x2f, 0x2e, 0x3c, 0xda, 0xe4, /* Codes 16-31 */
+ 0x72, 0x86, 0xed, 0x1d, 0x35, 0xe2, 0xfc, 0xe3, 0x7d, 0x16, 0x97, 0x87, 0xee, 0xb2, 0x42, 0xbc, /* Codes 32-47 */
+ 0xf6, 0x4b, 0x1c, 0x70, 0x90, 0x77, 0x2c, 0xdf, 0x96, 0x29, 0x45, 0x7f, 0x81, 0xb1, 0x28, 0xea, /* Codes 48-63 */
+ 0x40, 0x3d, 0x23, 0x95, 0xe9, 0xd6, 0xb7, 0x2d, 0x02, 0x3a, 0x85, 0x17, 0x82, 0xe7, 0x7b, 0x33, /* Codes 64-79 */
+ 0x0e, 0x25, 0x84, 0xe0, 0x8c, 0x4d, 0x56, 0x1e, 0x3b, 0x6e, 0x31, 0x3e, 0xf3, 0x1a, 0x20, 0x04, /* Codes 80-95 */
+ 0xe1, 0x74, 0x2a, 0x79, 0x21, 0x71, 0xc4, 0x76, 0x48, 0x98, 0xf7, 0x94, 0xe8, 0xbe, 0xac, 0xc9, /* Codes 96-111 */
+ 0x75, 0x8e, 0x49, 0x7a /* Codes 112-115 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+# define BITMAP_NLUTCODES 27 /* Number of unique RGB colors in the image */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_nuttxLut[BITMAP_NLUTCODES] =
+{
+ 0x00, 0x25, 0x77, 0x4b, 0x01, 0x47, 0x26, 0x4a, 0x4f, 0x72, 0xdf, 0x93, 0xff, 0x27, 0xbb, 0xdb, /* Codes 0-15 */
+ 0x6f, 0x29, 0x53, 0x97, 0x73, 0x22, 0x05, 0x02, 0x57, 0xbf, 0x4e /* Codes 16-26 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const struct SRlePaletteBitmapEntry g_nuttxRleEntries[] =
+{
+ { 76, 0}, { 1, 1}, { 1, 2}, { 1, 3}, { 4, 4}, { 1, 5}, { 76, 0}, /* Row 0 */
+ { 75, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 2, 7}, { 3, 4}, { 1, 5}, /* Row 1 */
+ { 75, 0},
+ { 74, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 9}, { 1, 10}, /* Row 2 */
+ { 1, 7}, { 3, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 12}, /* Row 3 */
+ { 1, 13}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 4 */
+ { 1, 6}, { 1, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 5 */
+ { 1, 6}, { 3, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 71, 0},
+ { 70, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 6 */
+ { 1, 6}, { 5, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 70, 0},
+ { 69, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 7 */
+ { 1, 6}, { 7, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 69, 0},
+ { 68, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 8 */
+ { 1, 6}, { 9, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 68, 0},
+ { 67, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 9 */
+ { 1, 6}, { 11, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 67, 0},
+ { 66, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 10 */
+ { 1, 6}, { 13, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 66, 0},
+ { 65, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 11 */
+ { 1, 6}, { 15, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 65, 0},
+ { 64, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 12 */
+ { 1, 6}, { 17, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 64, 0},
+ { 63, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 13 */
+ { 1, 6}, { 19, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 63, 0},
+ { 62, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 14 */
+ { 1, 6}, { 21, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 62, 0},
+ { 61, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 15 */
+ { 1, 6}, { 23, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 61, 0},
+ { 60, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 16 */
+ { 1, 6}, { 25, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 60, 0},
+ { 59, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 17 */
+ { 1, 6}, { 27, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 59, 0},
+ { 58, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 18 */
+ { 1, 6}, { 29, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 26, 0},
+ { 1, 17}, { 5, 18}, { 1, 17}, { 25, 0},
+ { 57, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 19 */
+ { 1, 6}, { 10, 4}, { 5, 19}, { 16, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4},
+ { 1, 5}, { 23, 0}, { 1, 20}, { 1, 18}, { 1, 21}, { 5, 18}, { 1, 21}, { 1, 18},
+ { 1, 20}, { 23, 0},
+ { 56, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, /* Row 20 */
+ { 1, 6}, { 9, 4}, { 1, 19}, { 1, 22}, { 1, 23}, { 3, 24}, { 1, 23}, { 1, 22},
+ { 1, 25}, { 15, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 22, 0},
+ { 11, 18}, { 1, 20}, { 22, 0},
+ { 23, 0}, { 1, 17}, { 5, 18}, { 1, 26}, { 25, 0}, { 1, 1}, { 1, 2}, { 1, 6}, /* Row 21 */
+ { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 9, 4}, { 1, 19}, { 1, 27},
+ { 1, 21}, { 5, 18}, { 1, 21}, { 1, 23}, { 1, 28}, { 15, 4}, { 1, 16}, { 1, 14},
+ { 1, 7}, { 3, 4}, { 1, 5}, { 20, 0}, { 1, 17}, { 1, 21}, { 11, 18}, { 1, 20},
+ { 21, 0},
+ { 21, 0}, { 1, 20}, { 1, 18}, { 1, 21}, { 5, 18}, { 1, 21}, { 1, 18}, { 1, 20}, /* Row 22 */
+ { 22, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 9, 4}, { 1, 19}, { 1, 27}, { 1, 21}, { 8, 18}, { 1, 29}, { 1, 28},
+ { 4, 7}, { 11, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 19, 0},
+ { 14, 18}, { 21, 0},
+ { 21, 0}, { 11, 18}, { 1, 20}, { 20, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, /* Row 23 */
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 10, 4}, { 1, 22}, { 1, 21}, { 10, 18},
+ { 1, 30}, { 1, 31}, { 1, 32}, { 1, 33}, { 1, 34}, { 1, 35}, { 1, 7}, { 10, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 17, 0}, { 1, 17}, { 1, 21},
+ { 4, 18}, { 1, 36}, { 2, 37}, { 1, 36}, { 4, 18}, { 1, 21}, { 1, 17}, { 20, 0},
+ { 20, 0}, { 1, 38}, { 1, 21}, { 11, 18}, { 1, 39}, { 4, 40}, { 1, 41}, { 13, 0}, /* Row 24 */
+ { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 10, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 3, 36}, { 5, 18}, { 1, 42}, { 1, 43},
+ { 3, 44}, { 1, 45}, { 1, 7}, { 10, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4},
+ { 1, 5}, { 16, 0}, { 5, 18}, { 1, 37}, { 4, 46}, { 1, 37}, { 4, 18}, { 1, 47},
+ { 1, 48}, { 1, 49}, { 18, 0},
+ { 19, 0}, { 1, 17}, { 1, 21}, { 12, 18}, { 1, 50}, { 1, 48}, { 3, 40}, { 1, 51}, /* Row 25 */
+ { 1, 40}, { 11, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 11, 4}, { 1, 52}, { 1, 21}, { 3, 18}, { 1, 37}, { 3, 46},
+ { 1, 37}, { 4, 18}, { 1, 21}, { 1, 53}, { 4, 44}, { 1, 45}, { 1, 7}, { 10, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 14, 0}, { 1, 17}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 6, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 55}, { 1, 40},
+ { 1, 49}, { 17, 0},
+ { 19, 0}, { 5, 18}, { 1, 54}, { 2, 56}, { 1, 37}, { 5, 18}, { 1, 21}, { 1, 57}, /* Row 26 */
+ { 4, 40}, { 1, 51}, { 1, 41}, { 9, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 11, 4}, { 1, 58}, { 1, 59}, { 3, 18},
+ { 1, 21}, { 1, 60}, { 4, 46}, { 1, 37}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44},
+ { 1, 45}, { 1, 7}, { 10, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5},
+ { 13, 0}, { 5, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 4, 18}, { 1, 57}, { 2, 40},
+ { 1, 49}, { 16, 0},
+ { 18, 0}, { 1, 17}, { 1, 21}, { 3, 18}, { 1, 37}, { 4, 46}, { 1, 37}, { 5, 18}, /* Row 27 */
+ { 1, 50}, { 1, 48}, { 5, 40}, { 8, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 12, 4}, { 1, 19}, { 1, 24}, { 3, 18},
+ { 1, 37}, { 6, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35},
+ { 11, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 11, 0}, { 1, 17},
+ { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 57}, { 3, 40},
+ { 16, 0},
+ { 18, 0}, { 4, 18}, { 1, 54}, { 5, 46}, { 1, 60}, { 1, 36}, { 4, 18}, { 1, 21}, /* Row 28 */
+ { 1, 57}, { 4, 40}, { 1, 51}, { 1, 41}, { 6, 0}, { 1, 1}, { 1, 2}, { 1, 6},
+ { 1, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 13, 4}, { 1, 19}, { 1, 24},
+ { 3, 18}, { 1, 61}, { 6, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44},
+ { 1, 34}, { 1, 62}, { 11, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5},
+ { 10, 0}, { 5, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 55},
+ { 2, 40}, { 1, 51}, { 1, 41}, { 15, 0},
+ { 18, 0}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18}, { 1, 50}, { 1, 48}, /* Row 29 */
+ { 5, 40}, { 5, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 14, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 12, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 8, 0}, { 1, 17}, { 1, 21}, { 3, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 4, 40}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 57}, /* Row 30 */
+ { 4, 40}, { 1, 51}, { 1, 41}, { 3, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 15, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 8, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34},
+ { 1, 62}, { 12, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 7, 0},
+ { 5, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40},
+ { 1, 63}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 56}, { 5, 18}, { 1, 50}, { 1, 48}, /* Row 31 */
+ { 5, 40}, { 2, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 16, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 9, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 13, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 5, 0}, { 1, 17}, { 1, 21}, { 3, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 5, 40}, { 1, 41},
+ { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 9, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 57}, /* Row 32 */
+ { 4, 40}, { 1, 51}, { 1, 41}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 4}, { 1, 8},
+ { 1, 11}, { 1, 15}, { 1, 6}, { 17, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 9, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62},
+ { 13, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 4, 0}, { 5, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57}, { 6, 40}, { 1, 63},
+ { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 9, 46}, { 1, 56}, { 5, 18}, { 1, 50}, { 1, 48}, /* Row 33 */
+ { 3, 40}, { 1, 64}, { 1, 65}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 18, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 10, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 14, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 2, 0}, { 1, 17}, { 1, 21}, { 3, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 10, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 57}, /* Row 34 */
+ { 2, 40}, { 1, 64}, { 1, 66}, { 1, 67}, { 1, 68}, { 1, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 19, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 10, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 14, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 3, 4}, { 1, 5}, { 1, 0}, { 5, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 69}, { 1, 70}, { 5, 40}, { 1, 51}, { 1, 41},
+ { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 10, 46}, { 1, 56}, { 5, 18}, { 1, 50}, { 1, 48}, /* Row 35 */
+ { 1, 64}, { 1, 66}, { 1, 67}, { 1, 44}, { 1, 34}, { 1, 71}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 20, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 11, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 15, 4}, { 1, 16}, { 1, 14},
+ { 1, 7}, { 3, 4}, { 1, 72}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 50}, { 1, 73}, { 6, 40}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 11, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 57}, /* Row 36 */
+ { 1, 74}, { 1, 67}, { 3, 44}, { 1, 75}, { 1, 76}, { 1, 6}, { 21, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 11, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43},
+ { 4, 44}, { 1, 34}, { 1, 62}, { 15, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 1, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 11, 46}, { 1, 56}, { 5, 18}, { 1, 77}, { 1, 78}, /* Row 37 */
+ { 4, 44}, { 1, 79}, { 1, 80}, { 22, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 12, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 16, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 12, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, /* Row 38 */
+ { 5, 44}, { 1, 81}, { 22, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 12, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 16, 4},
+ { 1, 16}, { 1, 82}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 12, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, /* Row 39 */
+ { 4, 44}, { 1, 34}, { 1, 62}, { 21, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 13, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 17, 4},
+ { 1, 83}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50},
+ { 1, 48}, { 6, 40}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 13, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, /* Row 40 */
+ { 5, 44}, { 1, 35}, { 21, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 13, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 15, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 13, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, /* Row 41 */
+ { 4, 44}, { 1, 34}, { 1, 62}, { 20, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 14, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 15, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50},
+ { 1, 48}, { 6, 40}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 14, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, /* Row 42 */
+ { 5, 44}, { 1, 35}, { 20, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 14, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 13, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 14, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, /* Row 43 */
+ { 4, 44}, { 1, 34}, { 1, 62}, { 19, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 7, 46}, { 1, 61}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44},
+ { 1, 35}, { 13, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 15, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, /* Row 44 */
+ { 5, 44}, { 1, 35}, { 19, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46},
+ { 1, 84}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34},
+ { 1, 62}, { 11, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 61}, { 6, 46}, { 1, 56}, { 5, 18}, /* Row 45 */
+ { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 18, 4}, { 1, 19}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 11, 4}, { 1, 22}, { 1, 21}, { 3, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 84}, { 7, 46}, { 1, 54}, { 4, 18}, /* Row 46 */
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 18, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 9, 4}, { 1, 25}, { 1, 23}, { 4, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51},
+ { 1, 41}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 1, 56}, { 6, 46}, { 1, 56}, /* Row 47 */
+ { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 17, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 18}, { 1, 56}, { 7, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 9, 4}, { 1, 22},
+ { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48},
+ { 6, 40}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 1, 54}, { 7, 46}, { 1, 54}, /* Row 48 */
+ { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 17, 4}, { 1, 19}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 7, 4}, { 1, 25},
+ { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 85},
+ { 1, 51}, { 4, 40}, { 1, 51}, { 1, 41}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 1, 18}, { 1, 56}, { 6, 46}, /* Row 49 */
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 16, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 7, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 86}, { 1, 66}, { 1, 64}, { 4, 40}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 1, 18}, { 1, 54}, { 7, 46}, /* Row 50 */
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 16, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 5, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 1, 44}, { 1, 67}, { 1, 66}, { 1, 64}, { 1, 40}, { 1, 51}, { 1, 41},
+ { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 56}, { 6, 46}, /* Row 51 */
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 15, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 3, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 5, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 2, 44}, { 1, 67}, { 1, 66}, { 1, 64}, { 1, 40}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 54}, { 7, 46}, /* Row 52 */
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 15, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 3, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 4, 44}, { 1, 67}, { 1, 87}, { 1, 41}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 3, 18}, { 1, 56}, { 6, 46}, /* Row 53 */
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 14, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 4, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 3, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 5, 44}, { 1, 88}, { 1, 89}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 3, 18}, { 1, 54}, { 7, 46}, /* Row 54 */
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 14, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 4, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 1, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 90}, { 1, 62}, { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 4, 18}, { 1, 56}, { 6, 46}, /* Row 55 */
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 13, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 5, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 1, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 5, 44}, { 1, 33}, { 1, 91}, { 2, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 4, 18}, { 1, 54}, { 7, 46}, /* Row 56 */
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 13, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 5, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 92}, { 1, 23},
+ { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44},
+ { 1, 93}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 5, 18}, { 1, 56}, { 6, 46}, /* Row 57 */
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 12, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 6, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 94}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 5, 18}, { 1, 54}, { 7, 46}, /* Row 58 */
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 12, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 6, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 3, 44}, { 1, 43}, { 1, 42}, { 4, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35},
+ { 2, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 19, 0},
+ { 17, 0}, { 1, 95}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 6, 18}, { 1, 56}, /* Row 59 */
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62},
+ { 11, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 7, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 3, 44}, { 1, 53},
+ { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43},
+ { 5, 44}, { 1, 34}, { 1, 62}, { 3, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4},
+ { 1, 5}, { 18, 0},
+ { 16, 0}, { 1, 1}, { 1, 96}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, /* Row 60 */
+ { 6, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44},
+ { 1, 35}, { 11, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36},
+ { 2, 18}, { 1, 21}, { 1, 47}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 1, 44}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 7, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 5, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 17, 0},
+ { 15, 0}, { 1, 1}, { 1, 2}, { 1, 97}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, /* Row 61 */
+ { 1, 36}, { 7, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43},
+ { 4, 44}, { 1, 34}, { 1, 62}, { 10, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 99}, { 1, 21}, { 3, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 1, 44}, { 1, 53}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 6, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5},
+ { 16, 0},
+ { 14, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, /* Row 62 */
+ { 8, 46}, { 1, 36}, { 7, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21},
+ { 1, 53}, { 5, 44}, { 1, 35}, { 10, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 100}, { 1, 42}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 101}, { 1, 42}, { 4, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 8, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 15, 0},
+ { 13, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 102}, { 1, 98}, { 2, 18}, /* Row 63 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 21}, { 1, 47}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62},
+ { 9, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 98}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62}, { 9, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 14, 0},
+ { 12, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 105}, { 1, 106}, /* Row 64 */
+ { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 99}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44},
+ { 1, 35}, { 9, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36},
+ { 2, 18}, { 1, 98}, { 1, 103}, { 1, 43}, { 1, 42}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 9, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53},
+ { 6, 44}, { 1, 35}, { 11, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5},
+ { 13, 0},
+ { 11, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 108}, /* Row 65 */
+ { 1, 29}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 100},
+ { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43},
+ { 4, 44}, { 1, 34}, { 1, 62}, { 8, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36},
+ { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 1, 44}, { 1, 53}, { 1, 21},
+ { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 7, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62}, { 12, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 12, 0},
+ { 10, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 66 */
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 8, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 1, 44}, { 1, 43},
+ { 1, 42}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 7, 18}, { 1, 56}, { 7, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 14, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 11, 0},
+ { 9, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 67 */
+ { 1, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56},
+ { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 7, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 2, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 5, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34},
+ { 1, 62}, { 15, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 10, 0},
+ { 8, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 68 */
+ { 2, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 1, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 7, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 2, 44}, { 1, 43}, { 1, 42}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 5, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35},
+ { 17, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 9, 0},
+ { 7, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 69 */
+ { 3, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 1, 44}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 6, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 3, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 18, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5},
+ { 8, 0},
+ { 6, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 70 */
+ { 4, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 2, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 6, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 3, 44}, { 1, 43}, { 1, 42}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 3, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35},
+ { 20, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 7, 0},
+ { 5, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 71 */
+ { 5, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 2, 44}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 5, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 4, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 1, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 21, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5},
+ { 6, 0},
+ { 4, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 72 */
+ { 6, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 3, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 5, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 4, 44}, { 1, 43}, { 1, 42}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 1, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35},
+ { 23, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 5, 0},
+ { 3, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 73 */
+ { 7, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 3, 44}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 4, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 5, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 110},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62},
+ { 24, 4}, { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 4, 0},
+ { 2, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 74 */
+ { 8, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 4, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46},
+ { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 4, 4}, { 1, 19},
+ { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 43}, { 1, 111}, { 3, 18}, { 1, 54}, { 15, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 26, 4}, { 1, 16}, { 1, 14}, { 1, 7},
+ { 2, 4}, { 1, 5}, { 3, 0},
+ { 1, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, /* Row 75 */
+ { 9, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 4, 44}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 3, 4},
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 5, 44}, { 1, 32}, { 1, 83}, { 1, 21}, { 3, 18}, { 1, 56}, { 13, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62}, { 27, 4},
+ { 1, 16}, { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5}, { 2, 0},
+ { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, { 10, 4}, /* Row 76 */
+ { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 5, 44}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54},
+ { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 3, 4}, { 1, 19}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 33}, { 1, 112}, { 1, 23}, { 3, 18}, { 1, 54}, { 13, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 29, 4}, { 1, 16}, { 1, 14}, { 1, 7},
+ { 2, 4}, { 1, 5}, { 1, 0},
+ { 1, 2}, { 1, 6}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, { 11, 4}, { 1, 19}, /* Row 77 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 43}, { 1, 111}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18},
+ { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 2, 4}, { 1, 19}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 33}, { 1, 7}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 56}, { 11, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62}, { 30, 4}, { 1, 16},
+ { 1, 14}, { 1, 7}, { 2, 4}, { 1, 5},
+ { 1, 3}, { 1, 7}, { 1, 104}, { 1, 107}, { 1, 109}, { 12, 4}, { 1, 19}, { 1, 24}, /* Row 78 */
+ { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 32}, { 1, 83}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 2, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 25}, { 1, 23}, { 3, 18}, { 1, 54}, { 11, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 32, 4}, { 1, 16}, { 1, 14}, { 1, 7},
+ { 2, 4},
+ { 1, 4}, { 1, 113}, { 1, 114}, { 1, 115}, { 13, 4}, { 1, 19}, { 1, 24}, { 2, 18}, /* Row 79 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 112}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42},
+ { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 1, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 4}, { 1, 116}, { 4, 18}, { 1, 56}, { 9, 46}, { 1, 61}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 5, 44}, { 1, 34}, { 1, 62}, { 33, 4}, { 1, 16}, { 1, 14},
+ { 1, 62}, { 1, 4},
+ { 1, 4}, { 1, 7}, { 1, 117}, { 1, 8}, { 13, 4}, { 1, 19}, { 1, 24}, { 2, 18}, /* Row 80 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 1, 4}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 4}, { 1, 116}, { 4, 18}, { 1, 54}, { 9, 46}, { 1, 37}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 6, 44}, { 1, 35}, { 35, 4}, { 1, 118}, { 1, 119}, { 1, 7},
+ { 2, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 12, 4}, { 1, 19}, { 1, 24}, { 2, 18}, /* Row 81 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18},
+ { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 62}, { 1, 19}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 8, 46}, { 1, 60}, { 1, 21},
+ { 3, 18}, { 1, 98}, { 1, 120}, { 5, 44}, { 1, 33}, { 1, 62}, { 34, 4}, { 1, 8},
+ { 1, 11}, { 1, 76}, { 1, 3},
+ { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 11, 4}, { 1, 19}, { 1, 24}, { 2, 18}, /* Row 82 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54},
+ { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 35}, { 1, 121}, { 1, 24}, { 2, 18},
+ { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 10, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 33}, { 1, 62}, { 33, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 10, 4}, { 1, 19}, { 1, 24}, /* Row 83 */
+ { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 33}, { 1, 7}, { 1, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 34}, { 1, 122}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 33}, { 1, 112}, { 1, 23}, { 4, 18}, { 1, 56}, { 10, 46}, { 1, 56}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 5, 44}, { 1, 35}, { 32, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5},
+ { 1, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 9, 4}, { 1, 19}, /* Row 84 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 2, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 123}, { 1, 24},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 32}, { 1, 83}, { 1, 21}, { 3, 18}, { 1, 54}, { 12, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62}, { 30, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 1, 0},
+ { 2, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 8, 4}, { 1, 19}, /* Row 85 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 2, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 124}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 43}, { 1, 111}, { 4, 18}, { 1, 56}, { 12, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 5, 44}, { 1, 35}, { 29, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 2, 0},
+ { 3, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 7, 4}, { 1, 19}, /* Row 86 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 3, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 4, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 14, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62}, { 27, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 3, 0},
+ { 4, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 6, 4}, { 1, 19}, /* Row 87 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 3, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 3, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 4, 44},
+ { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 14, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 5, 44}, { 1, 35}, { 26, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 4, 0},
+ { 5, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 5, 4}, { 1, 19}, /* Row 88 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 4, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 3, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 4, 44},
+ { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 16, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62}, { 24, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 5, 0},
+ { 6, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 4, 4}, { 1, 19}, /* Row 89 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 4, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 2, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 3, 44},
+ { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 35}, { 23, 4}, { 1, 8},
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 6, 0},
+ { 7, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 3, 4}, { 1, 19}, /* Row 90 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 5, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 2, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 3, 44},
+ { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 8, 46}, { 1, 54}, { 1, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62},
+ { 21, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 7, 0},
+ { 8, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 2, 4}, { 1, 19}, /* Row 91 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 5, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 1, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 2, 44},
+ { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56}, { 2, 18}, { 1, 54},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 35}, { 20, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 8, 0},
+ { 9, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 1, 4}, { 1, 19}, /* Row 92 */
+ { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103},
+ { 5, 44}, { 1, 33}, { 1, 7}, { 6, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21}, { 1, 53}, { 1, 44}, { 1, 103}, { 1, 98},
+ { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 2, 44},
+ { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 8, 46}, { 1, 54}, { 3, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62},
+ { 18, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 9, 0},
+ { 10, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 1, 121}, { 1, 24}, /* Row 93 */
+ { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44},
+ { 1, 33}, { 1, 7}, { 6, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46},
+ { 1, 56}, { 5, 18}, { 1, 42}, { 1, 43}, { 1, 103}, { 1, 98}, { 2, 18}, { 1, 36},
+ { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 1, 44}, { 1, 43}, { 1, 42},
+ { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 54}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 35}, { 17, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 10, 0},
+ { 11, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 125}, { 1, 24}, { 2, 18}, /* Row 94 */
+ { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33},
+ { 1, 7}, { 7, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54},
+ { 4, 18}, { 1, 21}, { 1, 53}, { 1, 103}, { 1, 98}, { 2, 18}, { 1, 36}, { 7, 46},
+ { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 1, 44}, { 1, 53}, { 1, 21}, { 3, 18},
+ { 1, 54}, { 8, 46}, { 1, 54}, { 5, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62}, { 15, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 11, 0},
+ { 12, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 126}, { 1, 98}, { 2, 18}, { 1, 36}, /* Row 95 */
+ { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7},
+ { 7, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18},
+ { 1, 42}, { 1, 100}, { 1, 98}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18},
+ { 1, 98}, { 1, 103}, { 1, 43}, { 1, 42}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56},
+ { 6, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 35}, { 14, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 12, 0},
+ { 13, 0}, { 1, 5}, { 3, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, /* Row 96 */
+ { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7}, { 8, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 4, 18}, { 1, 21},
+ { 1, 99}, { 1, 98}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98},
+ { 1, 103}, { 1, 53}, { 1, 21}, { 3, 18}, { 1, 54}, { 8, 46}, { 1, 54}, { 7, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34},
+ { 1, 62}, { 12, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 13, 0},
+ { 14, 0}, { 1, 5}, { 2, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, /* Row 97 */
+ { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7}, { 8, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 5, 18}, { 1, 47},
+ { 1, 21}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 100},
+ { 1, 42}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 47}, { 1, 21},
+ { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 35}, { 11, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 14, 0},
+ { 15, 0}, { 1, 5}, { 1, 4}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, /* Row 98 */
+ { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7}, { 9, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 8, 18}, { 1, 36},
+ { 7, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 99}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 127}, { 1, 42}, { 3, 18}, { 1, 56},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62},
+ { 9, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 15, 0},
+ { 16, 0}, { 1, 5}, { 1, 19}, { 1, 24}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, /* Row 99 */
+ { 2, 18}, { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7}, { 9, 4}, { 1, 25},
+ { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 8, 18}, { 1, 36}, { 7, 46},
+ { 1, 36}, { 2, 18}, { 1, 21}, { 1, 47}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 1, 53}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44}, { 1, 35}, { 8, 4}, { 1, 8},
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 16, 0},
+ { 17, 0}, { 1, 128}, { 1, 129}, { 2, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, /* Row 100 */
+ { 1, 98}, { 1, 103}, { 5, 44}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 22}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 7, 46}, { 1, 54}, { 7, 18}, { 1, 36}, { 7, 46}, { 1, 36},
+ { 7, 18}, { 1, 54}, { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 1, 44},
+ { 1, 43}, { 1, 42}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 5, 44}, { 1, 34}, { 1, 62}, { 6, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 101 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 7, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 7, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 2, 44}, { 1, 53}, { 1, 21},
+ { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 35}, { 5, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 102 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 11, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 6, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 6, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 3, 44}, { 1, 43}, { 1, 42},
+ { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 3, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 103 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 11, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 6, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 6, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 4, 44}, { 1, 53}, { 1, 21},
+ { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 35}, { 2, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 104 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 5, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 5, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44}, { 1, 43}, { 1, 42},
+ { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 5, 44},
+ { 1, 34}, { 1, 62}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 105 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 5, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 5, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 94}, { 1, 21},
+ { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 5, 44},
+ { 1, 93}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 106 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 13, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 4, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 4, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 92},
+ { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53},
+ { 5, 44}, { 1, 88}, { 1, 130}, { 1, 6}, { 1, 4}, { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 107 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 13, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 4, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 4, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 1, 4},
+ { 1, 22}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 5, 44}, { 1, 131}, { 1, 7}, { 1, 5}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 108 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 14, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 3, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 3, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62},
+ { 1, 4}, { 1, 25}, { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 4, 44}, { 1, 67}, { 1, 132}, { 1, 133}, { 25, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 109 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 14, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 3, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 3, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 3, 4},
+ { 1, 22}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 2, 44}, { 1, 67}, { 1, 66}, { 1, 64}, { 1, 40}, { 25, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 110 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 15, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62},
+ { 3, 4}, { 1, 25}, { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 53}, { 1, 44}, { 1, 67}, { 1, 66}, { 1, 64}, { 1, 40}, { 1, 51},
+ { 1, 41}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 111 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 15, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 2, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 2, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 5, 4},
+ { 1, 22}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 86}, { 1, 66}, { 1, 64}, { 4, 40}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 112 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 16, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 1, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 18}, { 1, 54},
+ { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62},
+ { 5, 4}, { 1, 25}, { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18},
+ { 1, 21}, { 1, 85}, { 1, 51}, { 4, 40}, { 1, 51}, { 1, 41}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 113 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 16, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 1, 18}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 18}, { 1, 56},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 7, 4},
+ { 1, 22}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50},
+ { 1, 48}, { 6, 40}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 114 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 17, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 54}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 54}, { 8, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 7, 4}, { 1, 25},
+ { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57},
+ { 5, 40}, { 1, 51}, { 1, 41}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 103}, /* Row 115 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 17, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56},
+ { 6, 46}, { 1, 56}, { 1, 36}, { 7, 46}, { 1, 36}, { 1, 56}, { 7, 46}, { 1, 56},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 9, 4}, { 1, 22}, { 1, 21},
+ { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40},
+ { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 98}, { 1, 134}, /* Row 116 */
+ { 5, 44}, { 1, 33}, { 1, 7}, { 18, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54},
+ { 7, 46}, { 1, 84}, { 7, 46}, { 1, 84}, { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 9, 4}, { 1, 25}, { 1, 23}, { 3, 18},
+ { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51},
+ { 1, 41}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 135}, /* Row 117 */
+ { 1, 67}, { 4, 44}, { 1, 33}, { 1, 7}, { 18, 4}, { 1, 25}, { 1, 23}, { 4, 18},
+ { 1, 56}, { 6, 46}, { 1, 61}, { 7, 46}, { 1, 61}, { 7, 46}, { 1, 56}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 11, 4}, { 1, 22}, { 1, 21}, { 2, 18},
+ { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 118 */
+ { 1, 66}, { 1, 67}, { 3, 44}, { 1, 79}, { 1, 136}, { 19, 4}, { 1, 22}, { 1, 21},
+ { 3, 18}, { 1, 54}, { 22, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44},
+ { 1, 34}, { 1, 62}, { 11, 4}, { 1, 25}, { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46},
+ { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 119 */
+ { 1, 64}, { 1, 66}, { 1, 67}, { 2, 44}, { 1, 79}, { 1, 45}, { 1, 16}, { 18, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 20, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 13, 4}, { 1, 22}, { 1, 21}, { 2, 18}, { 1, 54},
+ { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 120 */
+ { 1, 40}, { 1, 64}, { 1, 66}, { 1, 67}, { 1, 44}, { 1, 33}, { 1, 137}, { 1, 14},
+ { 1, 16}, { 18, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 20, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 13, 4}, { 1, 138},
+ { 1, 139}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57},
+ { 5, 40}, { 1, 51}, { 1, 41}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 121 */
+ { 2, 40}, { 1, 64}, { 1, 66}, { 1, 67}, { 1, 33}, { 2, 7}, { 1, 14}, { 1, 16},
+ { 17, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 18, 46}, { 1, 56}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 13, 4}, { 1, 8}, { 1, 140}, { 1, 141},
+ { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48},
+ { 6, 40}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 122 */
+ { 3, 40}, { 1, 64}, { 1, 66}, { 1, 131}, { 1, 7}, { 1, 4}, { 1, 7}, { 1, 14},
+ { 1, 16}, { 17, 4}, { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 18, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 12, 4}, { 1, 8},
+ { 1, 11}, { 1, 15}, { 1, 142}, { 1, 23}, { 3, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 123 */
+ { 4, 40}, { 1, 64}, { 1, 143}, { 1, 144}, { 2, 4}, { 1, 7}, { 1, 14}, { 1, 16},
+ { 16, 4}, { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 16, 46}, { 1, 56}, { 4, 18},
+ { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 12, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 145}, { 3, 18}, { 1, 54}, { 7, 46}, { 1, 56}, { 4, 18},
+ { 1, 50}, { 1, 48}, { 6, 40}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 124 */
+ { 5, 40}, { 1, 64}, { 1, 146}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 16, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 16, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 11, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 1, 147}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 125 */
+ { 6, 40}, { 1, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 15, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 14, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 11, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 2, 0}, { 1, 17}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 126 */
+ { 6, 40}, { 2, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 15, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 14, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 10, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 4, 0}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 127 */
+ { 6, 40}, { 3, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 14, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 12, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 10, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 5, 0}, { 1, 17}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 128 */
+ { 6, 40}, { 4, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 14, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 12, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 9, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 7, 0}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 57}, { 5, 40}, { 1, 51}, { 1, 41}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 129 */
+ { 6, 40}, { 5, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 13, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 10, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 9, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 8, 0}, { 1, 17}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 50}, { 1, 48}, { 6, 40}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 130 */
+ { 6, 40}, { 6, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 13, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 10, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 8, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 10, 0}, { 4, 18}, { 1, 56}, { 7, 46}, { 1, 54},
+ { 3, 18}, { 1, 21}, { 1, 55}, { 5, 40}, { 1, 51}, { 1, 148}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 131 */
+ { 6, 40}, { 7, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 12, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 8, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 8, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 11, 0}, { 1, 17}, { 1, 21}, { 2, 18}, { 1, 54}, { 7, 46},
+ { 1, 56}, { 4, 18}, { 1, 57}, { 6, 40}, { 1, 149}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 132 */
+ { 6, 40}, { 8, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 12, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 54}, { 8, 46}, { 1, 54}, { 3, 18}, { 1, 21},
+ { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 7, 4}, { 1, 8}, { 1, 11}, { 1, 15},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 13, 0}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56},
+ { 4, 18}, { 1, 57}, { 7, 40}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 133 */
+ { 6, 40}, { 9, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 11, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 56}, { 6, 46}, { 1, 56}, { 4, 18}, { 1, 42},
+ { 1, 43}, { 6, 44}, { 1, 35}, { 7, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 14, 0}, { 1, 17}, { 1, 21}, { 2, 18}, { 1, 54}, { 6, 46},
+ { 1, 56}, { 3, 18}, { 1, 69}, { 1, 150}, { 6, 40}, { 1, 51}, { 1, 148}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 134 */
+ { 6, 40}, { 10, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 11, 4},
+ { 1, 22}, { 1, 21}, { 3, 18}, { 1, 36}, { 1, 151}, { 4, 46}, { 1, 151}, { 1, 36},
+ { 3, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62}, { 6, 4}, { 1, 8},
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 16, 0}, { 4, 18}, { 1, 56},
+ { 5, 46}, { 1, 54}, { 3, 18}, { 1, 50}, { 1, 73}, { 7, 40}, { 1, 41}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 135 */
+ { 6, 40}, { 11, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 10, 4},
+ { 1, 25}, { 1, 23}, { 4, 18}, { 1, 36}, { 1, 56}, { 2, 46}, { 1, 56}, { 1, 36},
+ { 4, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 6, 4}, { 1, 8}, { 1, 11},
+ { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 17, 0}, { 1, 17}, { 1, 21}, { 2, 18},
+ { 1, 36}, { 1, 56}, { 2, 46}, { 1, 56}, { 1, 54}, { 3, 18}, { 1, 21}, { 1, 57},
+ { 8, 40}, { 1, 41}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 136 */
+ { 6, 40}, { 12, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 10, 4},
+ { 1, 22}, { 1, 21}, { 5, 18}, { 2, 36}, { 5, 18}, { 1, 21}, { 1, 53}, { 6, 44},
+ { 1, 34}, { 1, 62}, { 5, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 19, 0}, { 5, 18}, { 2, 36}, { 5, 18}, { 1, 50}, { 1, 48}, { 8, 40},
+ { 1, 63}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 137 */
+ { 6, 40}, { 13, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 9, 4},
+ { 1, 25}, { 1, 23}, { 12, 18}, { 1, 42}, { 1, 43}, { 6, 44}, { 1, 35}, { 5, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 20, 0}, { 1, 17},
+ { 1, 21}, { 9, 18}, { 1, 47}, { 1, 70}, { 9, 40}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 36}, { 2, 18}, { 1, 47}, { 1, 73}, /* Row 138 */
+ { 6, 40}, { 14, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 9, 4},
+ { 1, 22}, { 1, 21}, { 10, 18}, { 1, 21}, { 1, 53}, { 6, 44}, { 1, 34}, { 1, 62},
+ { 4, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 9, 18}, { 1, 47}, { 1, 70}, { 8, 40}, { 1, 51}, { 1, 41}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 36}, { 8, 46}, { 1, 69}, { 2, 47}, { 1, 152}, { 1, 73}, /* Row 139 */
+ { 6, 40}, { 15, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 8, 4},
+ { 1, 19}, { 1, 27}, { 1, 21}, { 8, 18}, { 1, 21}, { 1, 153}, { 1, 103}, { 6, 44},
+ { 1, 35}, { 4, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 23, 0}, { 1, 147}, { 1, 154}, { 1, 18}, { 1, 21}, { 2, 18}, { 1, 21}, { 1, 47},
+ { 1, 155}, { 1, 150}, { 10, 40}, { 15, 0},
+ { 25, 0}, { 5, 48}, { 4, 73}, { 7, 40}, { 16, 0}, { 1, 5}, { 3, 4}, { 1, 7}, /* Row 140 */
+ { 1, 14}, { 1, 16}, { 8, 4}, { 1, 19}, { 1, 22}, { 1, 23}, { 1, 21}, { 4, 18},
+ { 1, 21}, { 1, 42}, { 1, 53}, { 1, 103}, { 6, 44}, { 1, 34}, { 1, 62}, { 3, 4},
+ { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 27, 0}, { 1, 156},
+ { 1, 17}, { 1, 157}, { 1, 55}, { 1, 48}, { 1, 64}, { 9, 40}, { 1, 51}, { 1, 41},
+ { 15, 0},
+ { 25, 0}, { 16, 40}, { 17, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 141 */
+ { 9, 4}, { 1, 25}, { 1, 22}, { 1, 158}, { 2, 98}, { 1, 77}, { 1, 53}, { 1, 43},
+ { 7, 44}, { 1, 33}, { 1, 136}, { 3, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 30, 0}, { 1, 63}, { 11, 40}, { 1, 51}, { 1, 40}, { 16, 0},
+ { 25, 0}, { 16, 40}, { 18, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 142 */
+ { 10, 4}, { 1, 19}, { 1, 159}, { 1, 160}, { 1, 103}, { 7, 44}, { 1, 79}, { 1, 161},
+ { 1, 136}, { 3, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 32, 0}, { 1, 41}, { 1, 51}, { 8, 40}, { 1, 51}, { 1, 40}, { 17, 0},
+ { 25, 0}, { 16, 40}, { 19, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 143 */
+ { 11, 4}, { 1, 62}, { 1, 35}, { 1, 34}, { 5, 33}, { 1, 161}, { 1, 136}, { 1, 7},
+ { 3, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 34, 0},
+ { 8, 40}, { 1, 51}, { 1, 40}, { 18, 0},
+ { 25, 0}, { 16, 40}, { 20, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 144 */
+ { 12, 4}, { 7, 7}, { 4, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 35, 0}, { 1, 49}, { 7, 40}, { 1, 41}, { 19, 0},
+ { 25, 0}, { 16, 40}, { 21, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 145 */
+ { 21, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 64, 0},
+ { 25, 0}, { 16, 40}, { 22, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, /* Row 146 */
+ { 19, 4}, { 1, 8}, { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 65, 0},
+ { 64, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 17, 4}, { 1, 8}, /* Row 147 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 66, 0},
+ { 65, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 15, 4}, { 1, 8}, /* Row 148 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 67, 0},
+ { 66, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 13, 4}, { 1, 8}, /* Row 149 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 68, 0},
+ { 67, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 11, 4}, { 1, 8}, /* Row 150 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 69, 0},
+ { 68, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 9, 4}, { 1, 8}, /* Row 151 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 70, 0},
+ { 69, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 7, 4}, { 1, 8}, /* Row 152 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 71, 0},
+ { 70, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 5, 4}, { 1, 8}, /* Row 153 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 3, 4}, { 1, 8}, /* Row 154 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 16}, { 1, 4}, { 1, 8}, /* Row 155 */
+ { 1, 11}, { 1, 15}, { 1, 6}, { 1, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 14}, { 1, 118}, { 1, 11}, { 1, 15}, /* Row 156 */
+ { 1, 6}, { 1, 4}, { 1, 5}, { 75, 0},
+ { 74, 0}, { 1, 5}, { 3, 4}, { 1, 7}, { 1, 162}, { 1, 15}, { 1, 6}, { 1, 4}, /* Row 157 */
+ { 1, 5}, { 76, 0},
+ { 75, 0}, { 1, 5}, { 2, 4}, { 1, 3}, { 1, 163}, { 1, 6}, { 1, 4}, { 1, 5}, /* Row 158 */
+ { 77, 0},
+ { 76, 0}, { 1, 5}, { 4, 4}, { 1, 5}, { 78, 0} /* Row 159 */
+ };
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const struct SRlePaletteBitmapEntry g_nuttxRleEntries[] =
+{
+ { 76, 0}, { 1, 1}, { 1, 2}, { 1, 3}, { 4, 4}, { 1, 5}, { 76, 0}, /* Row 0 */
+ { 75, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 2, 8}, { 3, 4}, { 1, 5}, /* Row 1 */
+ { 75, 0},
+ { 74, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 10}, { 1, 11}, /* Row 2 */
+ { 1, 8}, { 3, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 3 */
+ { 1, 14}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 4 */
+ { 1, 6}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 5 */
+ { 1, 6}, { 2, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 71, 0},
+ { 70, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 6 */
+ { 1, 6}, { 4, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 70, 0},
+ { 69, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 7 */
+ { 1, 6}, { 6, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 69, 0},
+ { 68, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 8 */
+ { 1, 6}, { 8, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 68, 0},
+ { 67, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 9 */
+ { 1, 6}, { 10, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 67, 0},
+ { 66, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 10 */
+ { 1, 6}, { 12, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 66, 0},
+ { 65, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 11 */
+ { 1, 6}, { 14, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 65, 0},
+ { 64, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 12 */
+ { 1, 6}, { 16, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 64, 0},
+ { 63, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 13 */
+ { 1, 6}, { 18, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 63, 0},
+ { 62, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 14 */
+ { 1, 6}, { 20, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 62, 0},
+ { 61, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 15 */
+ { 1, 6}, { 22, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 61, 0},
+ { 60, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 16 */
+ { 1, 6}, { 24, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 60, 0},
+ { 59, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 17 */
+ { 1, 6}, { 26, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 59, 0},
+ { 58, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 18 */
+ { 1, 6}, { 28, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 26, 0}, { 1, 17}, { 5, 18}, { 1, 17}, { 25, 0},
+ { 57, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 19 */
+ { 1, 6}, { 10, 4}, { 5, 19}, { 15, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8},
+ { 3, 4}, { 1, 5}, { 23, 0}, { 1, 20}, { 9, 18}, { 1, 20}, { 23, 0},
+ { 56, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, /* Row 20 */
+ { 1, 6}, { 9, 4}, { 1, 19}, { 1, 21}, { 1, 22}, { 3, 23}, { 1, 22}, { 1, 21},
+ { 1, 24}, { 14, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 22, 0}, { 11, 18}, { 1, 20}, { 22, 0},
+ { 23, 0}, { 1, 17}, { 5, 18}, { 1, 25}, { 25, 0}, { 1, 1}, { 1, 2}, { 1, 6}, /* Row 21 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 9, 4}, { 1, 19}, { 1, 26},
+ { 7, 18}, { 1, 22}, { 1, 27}, { 14, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8},
+ { 3, 4}, { 1, 5}, { 20, 0}, { 1, 17}, { 12, 18}, { 1, 20}, { 21, 0},
+ { 21, 0}, { 1, 20}, { 9, 18}, { 1, 20}, { 22, 0}, { 1, 1}, { 1, 2}, { 1, 6}, /* Row 22 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 9, 4}, { 1, 19}, { 1, 26},
+ { 9, 18}, { 1, 28}, { 1, 27}, { 4, 8}, { 1, 7}, { 9, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 19, 0}, { 14, 18}, { 21, 0},
+ { 21, 0}, { 11, 18}, { 1, 20}, { 20, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, /* Row 23 */
+ { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 10, 4}, { 1, 21}, { 11, 18}, { 1, 29},
+ { 1, 30}, { 2, 31}, { 1, 32}, { 1, 33}, { 1, 8}, { 9, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 17, 0}, { 1, 17}, { 5, 18}, { 1, 34},
+ { 2, 35}, { 1, 34}, { 5, 18}, { 1, 17}, { 20, 0},
+ { 20, 0}, { 1, 36}, { 12, 18}, { 1, 37}, { 4, 38}, { 1, 39}, { 13, 0}, { 1, 1}, /* Row 24 */
+ { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 10, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 3, 34}, { 5, 18}, { 1, 40}, { 1, 41}, { 3, 31},
+ { 1, 42}, { 1, 8}, { 9, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4},
+ { 1, 5}, { 16, 0}, { 5, 18}, { 1, 43}, { 4, 44}, { 1, 43}, { 4, 18}, { 1, 35},
+ { 1, 45}, { 1, 46}, { 18, 0},
+ { 19, 0}, { 1, 17}, { 13, 18}, { 1, 47}, { 1, 45}, { 3, 38}, { 1, 48}, { 1, 38}, /* Row 25 */
+ { 11, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 11, 4}, { 1, 49}, { 4, 18}, { 1, 35}, { 3, 44}, { 1, 43}, { 5, 18},
+ { 1, 50}, { 4, 31}, { 1, 42}, { 1, 8}, { 9, 4}, { 1, 7}, { 1, 16}, { 1, 15},
+ { 1, 8}, { 3, 4}, { 1, 5}, { 14, 0}, { 1, 17}, { 4, 18}, { 1, 34}, { 6, 44},
+ { 1, 34}, { 4, 18}, { 1, 51}, { 1, 38}, { 1, 46}, { 17, 0},
+ { 19, 0}, { 5, 18}, { 1, 34}, { 2, 52}, { 1, 35}, { 6, 18}, { 1, 53}, { 4, 38}, /* Row 26 */
+ { 1, 48}, { 1, 39}, { 9, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 11, 4}, { 1, 3}, { 1, 54}, { 4, 18}, { 1, 55},
+ { 4, 44}, { 1, 43}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 42}, { 1, 8},
+ { 9, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 13, 0},
+ { 5, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 4, 18}, { 1, 53}, { 2, 38}, { 1, 46},
+ { 16, 0},
+ { 18, 0}, { 1, 17}, { 4, 18}, { 1, 43}, { 4, 44}, { 1, 35}, { 5, 18}, { 1, 47}, /* Row 27 */
+ { 1, 45}, { 5, 38}, { 8, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 12, 4}, { 1, 19}, { 1, 23}, { 3, 18}, { 1, 35},
+ { 6, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 9, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 11, 0}, { 1, 17},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 53}, { 3, 38}, { 16, 0},
+ { 18, 0}, { 4, 18}, { 1, 34}, { 5, 44}, { 1, 55}, { 1, 34}, { 5, 18}, { 1, 53}, /* Row 28 */
+ { 4, 38}, { 1, 48}, { 1, 39}, { 6, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7},
+ { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 13, 4}, { 1, 19}, { 1, 23}, { 3, 18},
+ { 1, 52}, { 6, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32},
+ { 1, 56}, { 10, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5},
+ { 10, 0}, { 5, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 51}, { 2, 38},
+ { 1, 48}, { 1, 39}, { 15, 0},
+ { 18, 0}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 47}, { 1, 45}, /* Row 29 */
+ { 5, 38}, { 5, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 14, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 8, 0}, { 1, 17}, { 4, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 4, 38}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 5, 18}, { 1, 53}, { 4, 38}, /* Row 30 */
+ { 1, 48}, { 1, 39}, { 3, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 15, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 8, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56},
+ { 11, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 7, 0},
+ { 5, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53}, { 5, 38}, { 1, 1},
+ { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 52}, { 5, 18}, { 1, 47}, { 1, 45}, /* Row 31 */
+ { 5, 38}, { 2, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 16, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 9, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 11, 4}, { 1, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 5, 0}, { 1, 17}, { 4, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 5, 38}, { 1, 39},
+ { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 9, 44}, { 1, 34}, { 5, 18}, { 1, 53}, { 4, 38}, /* Row 32 */
+ { 1, 48}, { 1, 39}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 17, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 9, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 12, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 4, 0}, { 5, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53}, { 6, 38}, { 1, 1}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 9, 44}, { 1, 52}, { 5, 18}, { 1, 47}, { 1, 45}, /* Row 33 */
+ { 3, 38}, { 1, 48}, { 1, 57}, { 1, 13}, { 1, 6}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 18, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 10, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 2, 0}, { 1, 17}, { 4, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 10, 44}, { 1, 34}, { 5, 18}, { 1, 53}, { 2, 38}, /* Row 34 */
+ { 1, 48}, { 1, 58}, { 1, 59}, { 1, 60}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 19, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 10, 44}, { 1, 52},
+ { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 13, 4}, { 1, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 3, 4}, { 1, 5}, { 1, 0}, { 5, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 61}, { 5, 38}, { 1, 48}, { 1, 39}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 10, 44}, { 1, 52}, { 5, 18}, { 1, 47}, { 1, 45}, /* Row 35 */
+ { 1, 48}, { 1, 58}, { 1, 59}, { 1, 31}, { 1, 32}, { 1, 62}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 20, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 11, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 13, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 3, 4}, { 1, 63}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52},
+ { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 11, 44}, { 1, 34}, { 5, 18}, { 1, 64}, { 1, 58}, /* Row 36 */
+ { 1, 59}, { 3, 31}, { 1, 65}, { 1, 66}, { 1, 6}, { 21, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 11, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31},
+ { 1, 32}, { 1, 56}, { 14, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 1, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53},
+ { 5, 38}, { 1, 48}, { 1, 39}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 11, 44}, { 1, 52}, { 5, 18}, { 1, 67}, { 1, 68}, /* Row 37 */
+ { 5, 31}, { 1, 69}, { 22, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 12, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 14, 4}, { 1, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52},
+ { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 12, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, /* Row 38 */
+ { 1, 70}, { 1, 7}, { 21, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 12, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 15, 4},
+ { 1, 7}, { 1, 16}, { 1, 71}, { 1, 67}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 12, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, /* Row 39 */
+ { 4, 31}, { 1, 32}, { 1, 56}, { 21, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 13, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 16, 4},
+ { 1, 72}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45},
+ { 6, 38}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 13, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, /* Row 40 */
+ { 1, 33}, { 1, 7}, { 20, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 13, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 15, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53},
+ { 5, 38}, { 1, 48}, { 1, 39}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 13, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, /* Row 41 */
+ { 4, 31}, { 1, 32}, { 1, 56}, { 20, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 14, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 14, 4},
+ { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45},
+ { 6, 38}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 14, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, /* Row 42 */
+ { 1, 33}, { 1, 7}, { 19, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 14, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 13, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53},
+ { 5, 38}, { 1, 48}, { 1, 39}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 14, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, /* Row 43 */
+ { 4, 31}, { 1, 32}, { 1, 56}, { 19, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 73}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33},
+ { 1, 7}, { 12, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 47}, { 1, 45}, { 6, 38}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 15, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, /* Row 44 */
+ { 1, 33}, { 1, 7}, { 18, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32},
+ { 1, 56}, { 11, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 73}, { 6, 44}, { 1, 52}, { 5, 18}, /* Row 45 */
+ { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 18, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18},
+ { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 21}, { 4, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, /* Row 46 */
+ { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 17, 4}, { 1, 19}, { 1, 23}, { 2, 18},
+ { 1, 34}, { 7, 44}, { 2, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41},
+ { 4, 31}, { 1, 32}, { 1, 56}, { 9, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 1, 52}, { 6, 44}, { 1, 52}, /* Row 47 */
+ { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 17, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 1, 18}, { 1, 52}, { 7, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 8, 4}, { 1, 21},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38},
+ { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 2, 34}, { 7, 44}, { 1, 34}, { 5, 18}, /* Row 48 */
+ { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 16, 4}, { 1, 19}, { 1, 23}, { 2, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 1, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 7, 4}, { 1, 24}, { 1, 22},
+ { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 74}, { 1, 48}, { 4, 38},
+ { 1, 48}, { 1, 39}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 1, 18}, { 1, 52}, { 6, 44}, /* Row 49 */
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 16, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 6, 4},
+ { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 75},
+ { 1, 58}, { 1, 48}, { 4, 38}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 1, 18}, { 1, 34}, { 7, 44}, /* Row 50 */
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 15, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 5, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 1, 31}, { 1, 59}, { 1, 58}, { 1, 48}, { 1, 38}, { 1, 48}, { 1, 39}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 52}, { 6, 44}, /* Row 51 */
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 15, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 3, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 4, 4},
+ { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41},
+ { 2, 31}, { 1, 59}, { 1, 58}, { 1, 48}, { 1, 38}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 34}, { 7, 44}, /* Row 52 */
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 14, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 3, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 3, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 4, 31}, { 1, 59}, { 1, 76}, { 1, 39}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 3, 18}, { 1, 52}, { 6, 44}, /* Row 53 */
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 14, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 2, 4},
+ { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41},
+ { 5, 31}, { 1, 77}, { 1, 78}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 3, 18}, { 1, 34}, { 7, 44}, /* Row 54 */
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 13, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 1, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 4, 18}, { 1, 52}, { 6, 44}, /* Row 55 */
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 13, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 4}, { 1, 21},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31},
+ { 1, 79}, { 1, 7}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 4, 18}, { 1, 34}, { 7, 44}, /* Row 56 */
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 80}, { 1, 22},
+ { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 81},
+ { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 5, 18}, { 1, 52}, { 6, 44}, /* Row 57 */
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 12, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 6, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 82}, { 4, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 5, 18}, { 1, 34}, { 7, 44}, /* Row 58 */
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 11, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 6, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 3, 31}, { 1, 41}, { 1, 40}, { 4, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 2, 7},
+ { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 19, 0},
+ { 17, 0}, { 1, 83}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 6, 18}, { 1, 52}, /* Row 59 */
+ { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56},
+ { 11, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 7, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 3, 31}, { 1, 50}, { 4, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32},
+ { 1, 56}, { 2, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5},
+ { 18, 0},
+ { 16, 0}, { 1, 1}, { 1, 84}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, /* Row 60 */
+ { 6, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33},
+ { 1, 7}, { 10, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 3, 18}, { 1, 85}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 1, 31}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 3, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 17, 0},
+ { 15, 0}, { 1, 1}, { 1, 2}, { 1, 86}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, /* Row 61 */
+ { 1, 34}, { 7, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41},
+ { 4, 31}, { 1, 32}, { 1, 56}, { 10, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 87}, { 4, 18}, { 1, 52}, { 7, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 1, 88}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56}, { 5, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 16, 0},
+ { 14, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 89}, { 1, 23}, { 2, 18}, { 1, 34}, /* Row 62 */
+ { 8, 44}, { 1, 34}, { 7, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50},
+ { 5, 31}, { 1, 33}, { 1, 7}, { 9, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 90}, { 1, 40}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 91}, { 1, 40}, { 4, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 6, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 15, 0},
+ { 13, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 71}, { 1, 29}, { 2, 18}, /* Row 63 */
+ { 1, 34}, { 8, 44}, { 1, 34}, { 3, 18}, { 1, 85}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 9, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 1, 50}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 29},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31},
+ { 1, 32}, { 1, 56}, { 8, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4},
+ { 1, 5}, { 14, 0},
+ { 12, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 94}, { 1, 95}, /* Row 64 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 87}, { 4, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7},
+ { 8, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 1, 41}, { 1, 40}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52},
+ { 9, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33},
+ { 1, 7}, { 9, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5},
+ { 13, 0},
+ { 11, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 97}, /* Row 65 */
+ { 1, 28}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 90},
+ { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41},
+ { 4, 31}, { 1, 32}, { 1, 56}, { 8, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 1, 31}, { 1, 50}, { 4, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 7, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56}, { 11, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 12, 0},
+ { 10, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 66 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50},
+ { 5, 31}, { 1, 33}, { 1, 7}, { 7, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 1, 31}, { 1, 41}, { 1, 40},
+ { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 7, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 11, 0},
+ { 9, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 67 */
+ { 1, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52},
+ { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 7, 4}, { 1, 19},
+ { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92},
+ { 2, 31}, { 1, 50}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 14, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 10, 0},
+ { 8, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 68 */
+ { 2, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 1, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 6, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 2, 31},
+ { 1, 41}, { 1, 40}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 5, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 15, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 9, 0},
+ { 7, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 69 */
+ { 3, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 1, 31}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 6, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 3, 31}, { 1, 50}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32},
+ { 1, 56}, { 17, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5},
+ { 8, 0},
+ { 6, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 70 */
+ { 4, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 2, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 5, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 3, 31},
+ { 1, 41}, { 1, 40}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 3, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 18, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 7, 0},
+ { 5, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 71 */
+ { 5, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 2, 31}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 5, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 4, 31}, { 1, 50}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 1, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32},
+ { 1, 56}, { 20, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5},
+ { 6, 0},
+ { 4, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 72 */
+ { 6, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 3, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 4, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 4, 31},
+ { 1, 41}, { 1, 40}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 1, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33}, { 1, 7}, { 21, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 5, 0},
+ { 3, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 73 */
+ { 7, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 3, 31}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 4, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 5, 31}, { 1, 50}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 99}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56}, { 23, 4},
+ { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 4, 0},
+ { 2, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 74 */
+ { 8, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 4, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 3, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 5, 31},
+ { 1, 41}, { 1, 67}, { 3, 18}, { 1, 34}, { 15, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 33}, { 1, 7}, { 24, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8},
+ { 2, 4}, { 1, 5}, { 3, 0},
+ { 1, 0}, { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, /* Row 75 */
+ { 9, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18},
+ { 1, 29}, { 1, 92}, { 4, 31}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 3, 4},
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 72}, { 4, 18}, { 1, 52}, { 13, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56}, { 26, 4}, { 1, 7}, { 1, 16},
+ { 1, 15}, { 1, 8}, { 2, 4}, { 1, 5}, { 2, 0},
+ { 1, 1}, { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, { 10, 4}, /* Row 76 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 5, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18},
+ { 1, 50}, { 5, 31}, { 1, 33}, { 1, 7}, { 2, 4}, { 1, 19}, { 1, 23}, { 2, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 80},
+ { 1, 22}, { 3, 18}, { 1, 34}, { 13, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31},
+ { 1, 33}, { 1, 7}, { 27, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4},
+ { 1, 5}, { 1, 0},
+ { 1, 2}, { 1, 6}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, { 11, 4}, { 1, 19}, /* Row 77 */
+ { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92},
+ { 5, 31}, { 1, 41}, { 1, 67}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18},
+ { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 2, 4}, { 1, 19}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 8}, { 1, 21}, { 4, 18}, { 1, 52}, { 11, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 5, 31}, { 1, 32}, { 1, 56}, { 29, 4}, { 1, 7}, { 1, 16}, { 1, 15},
+ { 1, 8}, { 2, 4}, { 1, 5},
+ { 1, 3}, { 1, 8}, { 1, 93}, { 1, 96}, { 1, 98}, { 12, 4}, { 1, 19}, { 1, 23}, /* Row 78 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 72}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31},
+ { 1, 33}, { 1, 7}, { 1, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 1, 24}, { 1, 22},
+ { 3, 18}, { 1, 34}, { 11, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33},
+ { 1, 7}, { 30, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 8}, { 2, 4},
+ { 1, 4}, { 1, 33}, { 1, 100}, { 1, 98}, { 13, 4}, { 1, 19}, { 1, 23}, { 2, 18}, /* Row 79 */
+ { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 80},
+ { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41},
+ { 4, 31}, { 1, 32}, { 1, 56}, { 1, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 1, 4},
+ { 1, 101}, { 4, 18}, { 1, 52}, { 9, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41},
+ { 5, 31}, { 1, 32}, { 1, 56}, { 32, 4}, { 1, 7}, { 1, 16}, { 1, 15}, { 1, 56},
+ { 1, 7},
+ { 1, 4}, { 1, 8}, { 1, 102}, { 1, 9}, { 1, 7}, { 12, 4}, { 1, 19}, { 1, 23}, /* Row 80 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 8}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50},
+ { 5, 31}, { 1, 33}, { 1, 7}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 1, 4}, { 1, 101},
+ { 4, 18}, { 1, 34}, { 9, 44}, { 1, 35}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 33},
+ { 1, 7}, { 33, 4}, { 1, 7}, { 1, 103}, { 1, 10}, { 1, 8},
+ { 2, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 11, 4}, { 1, 19}, { 1, 23}, /* Row 81 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 8}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18},
+ { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 56}, { 1, 19}, { 1, 23}, { 2, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 8, 44}, { 1, 104}, { 4, 18}, { 1, 29},
+ { 1, 68}, { 6, 31}, { 1, 56}, { 33, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 66},
+ { 1, 3},
+ { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 10, 4}, { 1, 19}, { 1, 23}, /* Row 82 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 8}, { 1, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18},
+ { 1, 50}, { 5, 31}, { 1, 33}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 1, 21}, { 4, 18},
+ { 1, 34}, { 10, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 56}, { 32, 4},
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 9, 4}, { 1, 19}, /* Row 83 */
+ { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92},
+ { 6, 31}, { 1, 8}, { 1, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 32}, { 1, 105}, { 1, 23},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 80}, { 1, 22}, { 4, 18}, { 1, 52}, { 10, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 30, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 1, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 8, 4}, /* Row 84 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 2, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 5, 18}, { 1, 50}, { 5, 31}, { 1, 106}, { 1, 23}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 72}, { 4, 18},
+ { 1, 34}, { 12, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 29, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 1, 0},
+ { 2, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 7, 4}, /* Row 85 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 2, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 107}, { 1, 29},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 5, 31},
+ { 1, 41}, { 1, 67}, { 4, 18}, { 1, 52}, { 12, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 27, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 2, 0},
+ { 3, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 6, 4}, /* Row 86 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 3, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 5, 18}, { 1, 50}, { 4, 31}, { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 5, 31}, { 1, 50}, { 4, 18},
+ { 1, 34}, { 14, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 26, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 3, 0},
+ { 4, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 5, 4}, /* Row 87 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 3, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 3, 31}, { 1, 92}, { 1, 29},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 4, 31},
+ { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 14, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 24, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 4, 0},
+ { 5, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 4, 4}, /* Row 88 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 4, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 5, 18}, { 1, 50}, { 3, 31}, { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 4, 31}, { 1, 50}, { 4, 18},
+ { 1, 34}, { 16, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 23, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 5, 0},
+ { 6, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 3, 4}, /* Row 89 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 4, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 2, 31}, { 1, 92}, { 1, 29},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 3, 31},
+ { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 52}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 21, 4},
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 6, 0},
+ { 7, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 2, 4}, /* Row 90 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 5, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 5, 18}, { 1, 50}, { 2, 31}, { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 3, 31}, { 1, 50}, { 4, 18},
+ { 1, 34}, { 8, 44}, { 1, 34}, { 1, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18},
+ { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56}, { 20, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 7, 0},
+ { 8, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 1, 4}, /* Row 91 */
+ { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 6, 31}, { 1, 8}, { 5, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40}, { 1, 41}, { 1, 31}, { 1, 92}, { 1, 29},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 2, 31},
+ { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 52}, { 2, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7},
+ { 18, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 8, 0},
+ { 9, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 1, 19}, /* Row 92 */
+ { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92},
+ { 6, 31}, { 1, 8}, { 6, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 50}, { 1, 31}, { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 2, 31}, { 1, 50}, { 4, 18}, { 1, 34},
+ { 8, 44}, { 1, 34}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 5, 31}, { 1, 32}, { 1, 56}, { 17, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 9, 0},
+ { 10, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 19}, { 1, 23}, /* Row 93 */
+ { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31},
+ { 1, 8}, { 6, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52},
+ { 5, 18}, { 1, 40}, { 1, 41}, { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34}, { 7, 44},
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 1, 31}, { 1, 41}, { 1, 40}, { 4, 18},
+ { 1, 52}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 15, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 10, 0},
+ { 11, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 108}, { 1, 23}, { 2, 18}, /* Row 94 */
+ { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8},
+ { 7, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 50},
+ { 1, 92}, { 1, 29}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 1, 31}, { 1, 50}, { 4, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 5, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 14, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 11, 0},
+ { 12, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 109}, { 1, 29}, { 2, 18}, { 1, 34}, /* Row 95 */
+ { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 7, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 40},
+ { 1, 90}, { 1, 29}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29},
+ { 1, 92}, { 1, 41}, { 1, 40}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 52}, { 6, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33},
+ { 1, 7}, { 12, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 12, 0},
+ { 13, 0}, { 1, 5}, { 3, 4}, { 1, 89}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, /* Row 96 */
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 8, 4}, { 1, 21},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 87}, { 1, 29}, { 2, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 1, 50}, { 4, 18},
+ { 1, 34}, { 8, 44}, { 1, 34}, { 7, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18},
+ { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56}, { 11, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 13, 0},
+ { 14, 0}, { 1, 5}, { 2, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, /* Row 97 */
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 8, 4}, { 1, 24},
+ { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 5, 18}, { 1, 85}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 90}, { 1, 40}, { 4, 18},
+ { 1, 52}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 85}, { 3, 18}, { 1, 34}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 9, 4},
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 14, 0},
+ { 15, 0}, { 1, 5}, { 1, 4}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, /* Row 98 */
+ { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 9, 4}, { 1, 21},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 8, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 2, 18}, { 1, 29}, { 1, 87}, { 4, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 4, 18},
+ { 1, 87}, { 1, 40}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 5, 31}, { 1, 32}, { 1, 56}, { 8, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 15, 0},
+ { 16, 0}, { 1, 5}, { 1, 19}, { 1, 23}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, /* Row 99 */
+ { 2, 18}, { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 9, 4}, { 1, 24}, { 1, 22},
+ { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 8, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 3, 18}, { 1, 85}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 1, 50}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7}, { 6, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 16, 0},
+ { 17, 0}, { 1, 110}, { 1, 111}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, /* Row 100 */
+ { 1, 29}, { 1, 92}, { 6, 31}, { 1, 8}, { 10, 4}, { 1, 21}, { 4, 18}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 7, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 7, 18}, { 1, 34},
+ { 8, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 1, 31}, { 1, 41}, { 1, 40}, { 3, 18},
+ { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56},
+ { 5, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 101 */
+ { 6, 31}, { 1, 8}, { 10, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 7, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 7, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 2, 31}, { 1, 50}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 1, 7},
+ { 3, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5},
+ { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 102 */
+ { 6, 31}, { 1, 8}, { 11, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 6, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 6, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 3, 31}, { 1, 41}, { 1, 40}, { 3, 18}, { 1, 52}, { 7, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56}, { 2, 4}, { 1, 7},
+ { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 103 */
+ { 6, 31}, { 1, 8}, { 11, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 6, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 6, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 4, 31}, { 1, 50}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 33}, { 2, 7},
+ { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 104 */
+ { 6, 31}, { 1, 8}, { 12, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 5, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 5, 31}, { 1, 41}, { 1, 40}, { 3, 18}, { 1, 52}, { 7, 44},
+ { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 32}, { 1, 56}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 105 */
+ { 6, 31}, { 1, 8}, { 12, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 5, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 5, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 82}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31}, { 1, 81}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 106 */
+ { 6, 31}, { 1, 8}, { 13, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 80}, { 1, 22}, { 3, 18}, { 1, 52},
+ { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 5, 31}, { 1, 77}, { 1, 112}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 107 */
+ { 6, 31}, { 1, 8}, { 13, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 4}, { 1, 21},
+ { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 5, 31},
+ { 1, 113}, { 1, 8}, { 1, 5}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 108 */
+ { 6, 31}, { 1, 8}, { 14, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 3, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 1, 4}, { 1, 24}, { 1, 22},
+ { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 4, 31}, { 1, 59},
+ { 1, 58}, { 1, 114}, { 25, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 109 */
+ { 6, 31}, { 1, 8}, { 14, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 3, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 2, 4},
+ { 1, 21}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41},
+ { 2, 31}, { 1, 59}, { 1, 58}, { 1, 48}, { 1, 38}, { 25, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 110 */
+ { 6, 31}, { 1, 8}, { 15, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 3, 4}, { 1, 24}, { 1, 22},
+ { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 1, 31}, { 1, 59},
+ { 1, 58}, { 1, 48}, { 1, 38}, { 1, 48}, { 1, 39}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 111 */
+ { 6, 31}, { 1, 8}, { 15, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 2, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 2, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 4, 4},
+ { 1, 21}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40}, { 1, 75},
+ { 1, 58}, { 1, 48}, { 4, 38}, { 24, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 112 */
+ { 6, 31}, { 1, 8}, { 16, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 1, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 1, 18}, { 1, 34}, { 8, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 5, 4}, { 1, 24}, { 1, 22},
+ { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 74}, { 1, 48}, { 4, 38},
+ { 1, 48}, { 1, 39}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 113 */
+ { 6, 31}, { 1, 8}, { 16, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 1, 18}, { 1, 34}, { 7, 44}, { 1, 34}, { 1, 18}, { 1, 52}, { 7, 44},
+ { 1, 52}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 6, 4},
+ { 1, 21}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45},
+ { 6, 38}, { 23, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 114 */
+ { 6, 31}, { 1, 8}, { 17, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 2, 34},
+ { 7, 44}, { 2, 34}, { 8, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32},
+ { 1, 56}, { 7, 4}, { 1, 24}, { 1, 22}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 92}, /* Row 115 */
+ { 6, 31}, { 1, 8}, { 17, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44},
+ { 1, 52}, { 1, 34}, { 7, 44}, { 1, 34}, { 1, 52}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 8, 4}, { 1, 21}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 22, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 29}, { 1, 115}, /* Row 116 */
+ { 6, 31}, { 1, 8}, { 18, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 7, 44}, { 1, 34},
+ { 7, 44}, { 1, 34}, { 8, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32},
+ { 1, 56}, { 9, 4}, { 1, 24}, { 1, 22}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 116}, /* Row 117 */
+ { 1, 59}, { 5, 31}, { 1, 8}, { 18, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52},
+ { 6, 44}, { 1, 73}, { 7, 44}, { 1, 73}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 21}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 21, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 118 */
+ { 1, 58}, { 1, 59}, { 4, 31}, { 1, 16}, { 1, 7}, { 18, 4}, { 1, 21}, { 4, 18},
+ { 1, 34}, { 22, 44}, { 1, 34}, { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56},
+ { 11, 4}, { 1, 24}, { 1, 22}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18},
+ { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 119 */
+ { 1, 48}, { 1, 58}, { 1, 59}, { 3, 31}, { 1, 42}, { 1, 16}, { 1, 7}, { 17, 4},
+ { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 20, 44}, { 1, 52}, { 4, 18}, { 1, 40},
+ { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 12, 4}, { 1, 21}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 20, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 120 */
+ { 1, 38}, { 1, 48}, { 1, 58}, { 1, 59}, { 2, 31}, { 1, 56}, { 1, 15}, { 1, 16},
+ { 1, 7}, { 17, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 20, 44}, { 1, 34}, { 4, 18},
+ { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 12, 4}, { 1, 7}, { 1, 117}, { 1, 73},
+ { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34}, { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48},
+ { 1, 39}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 121 */
+ { 2, 38}, { 1, 48}, { 1, 58}, { 1, 59}, { 1, 31}, { 2, 8}, { 1, 15}, { 1, 16},
+ { 1, 7}, { 16, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 18, 44}, { 1, 52},
+ { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 11, 4}, { 1, 7},
+ { 1, 9}, { 1, 118}, { 1, 119}, { 3, 18}, { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18},
+ { 1, 47}, { 1, 45}, { 6, 38}, { 19, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 122 */
+ { 3, 38}, { 1, 48}, { 1, 58}, { 1, 113}, { 1, 8}, { 1, 4}, { 1, 8}, { 1, 15},
+ { 1, 16}, { 1, 7}, { 16, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 18, 44}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 11, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 120}, { 1, 22}, { 3, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 123 */
+ { 4, 38}, { 1, 48}, { 1, 121}, { 1, 122}, { 2, 4}, { 1, 8}, { 1, 15}, { 1, 16},
+ { 1, 7}, { 15, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 16, 44}, { 1, 52},
+ { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 10, 4}, { 1, 7},
+ { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 123}, { 3, 18}, { 1, 34},
+ { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 18, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 124 */
+ { 5, 38}, { 1, 48}, { 1, 124}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 15, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 16, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 10, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 1, 125}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 125 */
+ { 6, 38}, { 1, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 14, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 14, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 9, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 2, 0}, { 1, 17}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 17, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 126 */
+ { 6, 38}, { 2, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 14, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 14, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 9, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 4, 0}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 127 */
+ { 6, 38}, { 3, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 13, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 12, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 8, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 5, 0}, { 1, 17}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 16, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 128 */
+ { 6, 38}, { 4, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 13, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 12, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 8, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 7, 0}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 53}, { 5, 38}, { 1, 48}, { 1, 39}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 129 */
+ { 6, 38}, { 5, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 12, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 10, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 7, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 8, 0}, { 1, 17}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 47}, { 1, 45}, { 6, 38}, { 15, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 130 */
+ { 6, 38}, { 6, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 12, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 10, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 7, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 10, 0}, { 4, 18}, { 1, 52}, { 7, 44}, { 1, 34},
+ { 4, 18}, { 1, 51}, { 5, 38}, { 1, 48}, { 1, 126}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 131 */
+ { 6, 38}, { 7, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 11, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 8, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 6, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 11, 0}, { 1, 17}, { 3, 18},
+ { 1, 34}, { 7, 44}, { 1, 52}, { 4, 18}, { 1, 53}, { 6, 38}, { 1, 127}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 132 */
+ { 6, 38}, { 8, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 11, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 4, 18}, { 1, 50},
+ { 6, 31}, { 1, 32}, { 1, 56}, { 6, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13},
+ { 1, 6}, { 1, 4}, { 1, 5}, { 13, 0}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52},
+ { 4, 18}, { 1, 53}, { 7, 38}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 133 */
+ { 6, 38}, { 9, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 10, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 52}, { 6, 44}, { 1, 52}, { 4, 18},
+ { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 5, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 14, 0}, { 1, 17}, { 3, 18},
+ { 1, 34}, { 6, 44}, { 1, 52}, { 4, 18}, { 1, 128}, { 6, 38}, { 1, 48}, { 1, 126},
+ { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 134 */
+ { 6, 38}, { 10, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 10, 4}, { 1, 21}, { 4, 18}, { 1, 34}, { 1, 55}, { 4, 44}, { 1, 55}, { 1, 34},
+ { 4, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 5, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 16, 0}, { 4, 18}, { 1, 52},
+ { 5, 44}, { 1, 34}, { 3, 18}, { 1, 47}, { 1, 45}, { 7, 38}, { 1, 39}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 135 */
+ { 6, 38}, { 11, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 9, 4}, { 1, 24}, { 1, 22}, { 4, 18}, { 1, 34}, { 1, 52}, { 2, 44}, { 1, 52},
+ { 1, 34}, { 4, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33}, { 1, 7}, { 4, 4},
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 17, 0},
+ { 1, 17}, { 3, 18}, { 1, 34}, { 1, 52}, { 2, 44}, { 1, 52}, { 1, 34}, { 4, 18},
+ { 1, 53}, { 8, 38}, { 1, 39}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 136 */
+ { 6, 38}, { 12, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 9, 4}, { 1, 21}, { 6, 18}, { 2, 34}, { 6, 18}, { 1, 50}, { 6, 31}, { 1, 32},
+ { 1, 56}, { 4, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 19, 0}, { 5, 18}, { 2, 34}, { 5, 18}, { 1, 47}, { 1, 45}, { 8, 38},
+ { 1, 1}, { 13, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 137 */
+ { 6, 38}, { 13, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 8, 4}, { 1, 24}, { 1, 22}, { 12, 18}, { 1, 40}, { 1, 41}, { 6, 31}, { 1, 33},
+ { 1, 7}, { 3, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 20, 0}, { 1, 17}, { 10, 18}, { 1, 35}, { 1, 61}, { 9, 38}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 34}, { 2, 18}, { 1, 35}, { 1, 45}, /* Row 138 */
+ { 6, 38}, { 14, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 8, 4}, { 1, 21}, { 12, 18}, { 1, 50}, { 6, 31}, { 1, 32}, { 1, 56}, { 3, 4},
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 9, 18}, { 1, 35}, { 1, 61}, { 8, 38}, { 1, 48}, { 1, 39}, { 14, 0},
+ { 18, 0}, { 3, 18}, { 1, 34}, { 8, 44}, { 1, 18}, { 2, 35}, { 1, 129}, { 1, 45}, /* Row 139 */
+ { 6, 38}, { 15, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7},
+ { 7, 4}, { 1, 19}, { 1, 26}, { 10, 18}, { 1, 130}, { 1, 107}, { 6, 31}, { 1, 33},
+ { 1, 7}, { 2, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 23, 0}, { 1, 131}, { 1, 132}, { 5, 18}, { 1, 35}, { 1, 133}, { 1, 128},
+ { 10, 38}, { 15, 0},
+ { 25, 0}, { 9, 45}, { 7, 38}, { 16, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, /* Row 140 */
+ { 1, 16}, { 1, 7}, { 7, 4}, { 1, 19}, { 1, 21}, { 1, 22}, { 6, 18}, { 1, 40},
+ { 1, 50}, { 1, 107}, { 6, 31}, { 1, 32}, { 1, 56}, { 2, 4}, { 1, 7}, { 1, 9},
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 27, 0}, { 1, 134}, { 1, 17},
+ { 1, 135}, { 1, 51}, { 1, 45}, { 1, 136}, { 9, 38}, { 1, 48}, { 1, 39}, { 15, 0},
+ { 25, 0}, { 16, 38}, { 17, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 141 */
+ { 1, 7}, { 8, 4}, { 1, 24}, { 1, 21}, { 1, 22}, { 2, 29}, { 1, 67}, { 1, 50},
+ { 1, 41}, { 8, 31}, { 1, 16}, { 1, 7}, { 1, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 30, 0}, { 1, 1}, { 11, 38}, { 1, 48},
+ { 1, 38}, { 16, 0},
+ { 25, 0}, { 16, 38}, { 18, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 142 */
+ { 1, 7}, { 9, 4}, { 1, 89}, { 1, 137}, { 1, 138}, { 1, 92}, { 8, 31}, { 1, 42},
+ { 1, 16}, { 1, 7}, { 1, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 32, 0}, { 1, 39}, { 1, 48}, { 8, 38}, { 1, 48}, { 1, 38},
+ { 17, 0},
+ { 25, 0}, { 16, 38}, { 19, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 143 */
+ { 1, 7}, { 9, 4}, { 1, 7}, { 1, 56}, { 1, 33}, { 1, 32}, { 5, 31}, { 1, 42},
+ { 1, 16}, { 1, 8}, { 2, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6},
+ { 1, 4}, { 1, 5}, { 34, 0}, { 8, 38}, { 1, 48}, { 1, 38}, { 18, 0},
+ { 25, 0}, { 16, 38}, { 20, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 144 */
+ { 1, 7}, { 10, 4}, { 1, 7}, { 7, 8}, { 3, 4}, { 1, 7}, { 1, 9}, { 1, 12},
+ { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 35, 0}, { 1, 46}, { 7, 38}, { 1, 39},
+ { 19, 0},
+ { 25, 0}, { 16, 38}, { 21, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 145 */
+ { 1, 7}, { 19, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 64, 0},
+ { 25, 0}, { 16, 38}, { 22, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, /* Row 146 */
+ { 1, 7}, { 17, 4}, { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4},
+ { 1, 5}, { 65, 0},
+ { 64, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 15, 4}, /* Row 147 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 66, 0},
+ { 65, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 13, 4}, /* Row 148 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 67, 0},
+ { 66, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 11, 4}, /* Row 149 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 68, 0},
+ { 67, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 9, 4}, /* Row 150 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 69, 0},
+ { 68, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 7, 4}, /* Row 151 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 70, 0},
+ { 69, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 5, 4}, /* Row 152 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 71, 0},
+ { 70, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 3, 4}, /* Row 153 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 1, 4}, /* Row 154 */
+ { 1, 7}, { 1, 9}, { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 16}, { 1, 7}, { 1, 9}, /* Row 155 */
+ { 1, 12}, { 1, 13}, { 1, 6}, { 1, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 15}, { 1, 103}, { 1, 12}, { 1, 13}, /* Row 156 */
+ { 1, 6}, { 1, 4}, { 1, 5}, { 75, 0},
+ { 74, 0}, { 1, 5}, { 3, 4}, { 1, 8}, { 1, 139}, { 1, 13}, { 1, 6}, { 1, 4}, /* Row 157 */
+ { 1, 5}, { 76, 0},
+ { 75, 0}, { 1, 5}, { 2, 4}, { 1, 3}, { 1, 140}, { 1, 6}, { 1, 4}, { 1, 5}, /* Row 158 */
+ { 77, 0},
+ { 76, 0}, { 1, 5}, { 4, 4}, { 1, 5}, { 78, 0} /* Row 159 */
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+ { 76, 0}, { 1, 1}, { 1, 2}, { 1, 3}, { 4, 4}, { 1, 5}, { 76, 0}, /* Row 0 */
+ { 75, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 5, 4}, { 1, 5}, { 75, 0}, /* Row 1 */
+ { 74, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 9}, { 1, 10}, /* Row 2 */
+ { 4, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 3 */
+ { 1, 12}, { 1, 13}, { 4, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 4 */
+ { 1, 7}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 5 */
+ { 1, 7}, { 2, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 71, 0},
+ { 70, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 6 */
+ { 1, 7}, { 4, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 70, 0},
+ { 69, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 7 */
+ { 1, 7}, { 6, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 69, 0},
+ { 68, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 8 */
+ { 1, 7}, { 8, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 68, 0},
+ { 67, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 9 */
+ { 1, 7}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 67, 0},
+ { 66, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 10 */
+ { 1, 7}, { 12, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 66, 0},
+ { 65, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 11 */
+ { 1, 7}, { 14, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 65, 0},
+ { 64, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 12 */
+ { 1, 7}, { 16, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 64, 0},
+ { 63, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 13 */
+ { 1, 7}, { 18, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 63, 0},
+ { 62, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 14 */
+ { 1, 7}, { 20, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 62, 0},
+ { 61, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 15 */
+ { 1, 7}, { 22, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 61, 0},
+ { 60, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 16 */
+ { 1, 7}, { 24, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 60, 0},
+ { 59, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 17 */
+ { 1, 7}, { 26, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 59, 0},
+ { 58, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 18 */
+ { 1, 7}, { 28, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 26, 0},
+ { 1, 14}, { 5, 15}, { 1, 14}, { 25, 0},
+ { 57, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 19 */
+ { 1, 7}, { 10, 4}, { 5, 16}, { 15, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4},
+ { 1, 5}, { 23, 0}, { 1, 17}, { 9, 15}, { 1, 17}, { 23, 0},
+ { 56, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, /* Row 20 */
+ { 1, 7}, { 9, 4}, { 1, 16}, { 1, 18}, { 1, 19}, { 3, 20}, { 1, 19}, { 1, 18},
+ { 1, 21}, { 14, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 22, 0},
+ { 11, 15}, { 1, 17}, { 22, 0},
+ { 23, 0}, { 1, 14}, { 5, 15}, { 1, 22}, { 25, 0}, { 1, 1}, { 1, 6}, { 1, 7}, /* Row 21 */
+ { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 9, 4}, { 1, 16}, { 1, 23},
+ { 7, 15}, { 1, 19}, { 1, 24}, { 14, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4},
+ { 1, 5}, { 20, 0}, { 1, 14}, { 12, 15}, { 1, 17}, { 21, 0},
+ { 21, 0}, { 1, 17}, { 9, 15}, { 1, 17}, { 22, 0}, { 1, 1}, { 1, 6}, { 1, 7}, /* Row 22 */
+ { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 9, 4}, { 1, 16}, { 1, 23},
+ { 9, 15}, { 1, 20}, { 1, 24}, { 4, 4}, { 1, 3}, { 9, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 4, 4}, { 1, 5}, { 19, 0}, { 14, 15}, { 21, 0},
+ { 21, 0}, { 11, 15}, { 1, 17}, { 20, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, /* Row 23 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 10, 4}, { 1, 18}, { 11, 15}, { 1, 25},
+ { 1, 26}, { 2, 27}, { 1, 28}, { 1, 29}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 13},
+ { 4, 4}, { 1, 5}, { 17, 0}, { 1, 14}, { 5, 15}, { 1, 30}, { 2, 31}, { 1, 30},
+ { 5, 15}, { 1, 14}, { 20, 0},
+ { 20, 0}, { 1, 22}, { 12, 15}, { 1, 32}, { 4, 33}, { 1, 7}, { 13, 0}, { 1, 1}, /* Row 24 */
+ { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 10, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 3, 30}, { 5, 15}, { 1, 34}, { 1, 35}, { 3, 27},
+ { 1, 36}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 16, 0},
+ { 5, 15}, { 1, 37}, { 4, 38}, { 1, 37}, { 4, 15}, { 1, 39}, { 1, 40}, { 1, 41},
+ { 18, 0},
+ { 19, 0}, { 1, 14}, { 13, 15}, { 1, 31}, { 1, 40}, { 5, 33}, { 11, 0}, { 1, 1}, /* Row 25 */
+ { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 11, 4},
+ { 1, 42}, { 4, 15}, { 1, 31}, { 3, 38}, { 1, 37}, { 5, 15}, { 1, 43}, { 4, 27},
+ { 1, 36}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 14, 0},
+ { 1, 14}, { 4, 15}, { 1, 30}, { 6, 38}, { 1, 30}, { 4, 15}, { 1, 22}, { 1, 33},
+ { 1, 41}, { 17, 0},
+ { 19, 0}, { 5, 15}, { 1, 30}, { 1, 44}, { 1, 34}, { 1, 31}, { 6, 15}, { 1, 45}, /* Row 26 */
+ { 5, 33}, { 1, 7}, { 9, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 11, 4}, { 1, 46}, { 1, 47}, { 4, 15}, { 1, 48},
+ { 4, 38}, { 1, 37}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 36}, { 10, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 13, 0}, { 5, 15}, { 1, 34},
+ { 6, 38}, { 1, 44}, { 4, 15}, { 1, 45}, { 2, 33}, { 1, 41}, { 16, 0},
+ { 18, 0}, { 1, 14}, { 4, 15}, { 1, 37}, { 4, 38}, { 1, 31}, { 5, 15}, { 1, 31}, /* Row 27 */
+ { 1, 40}, { 5, 33}, { 8, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 12, 4}, { 1, 16}, { 1, 20}, { 3, 15}, { 1, 31},
+ { 6, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 9, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 11, 0}, { 1, 14}, { 4, 15},
+ { 1, 30}, { 7, 38}, { 1, 44}, { 4, 15}, { 1, 45}, { 3, 33}, { 16, 0},
+ { 18, 0}, { 4, 15}, { 1, 30}, { 5, 38}, { 1, 48}, { 1, 30}, { 5, 15}, { 1, 45}, /* Row 28 */
+ { 5, 33}, { 1, 7}, { 6, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 13, 4}, { 1, 16}, { 1, 20}, { 3, 15}, { 1, 19},
+ { 6, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49},
+ { 10, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 10, 0}, { 5, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 22}, { 3, 33}, { 1, 7}, { 15, 0},
+ { 18, 0}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 31}, { 1, 40}, /* Row 29 */
+ { 5, 33}, { 5, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 14, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 10, 4}, { 1, 3},
+ { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 8, 0}, { 1, 14}, { 4, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 4, 33}, { 15, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 5, 15}, { 1, 45}, { 5, 33}, /* Row 30 */
+ { 1, 7}, { 3, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 15, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 11, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 7, 0}, { 5, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45}, { 5, 33}, { 1, 50}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 34}, { 5, 15}, { 1, 31}, { 1, 40}, /* Row 31 */
+ { 5, 33}, { 2, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 16, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 9, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 11, 4}, { 1, 3},
+ { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 5, 0}, { 1, 14}, { 4, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 5, 33}, { 1, 7}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 9, 38}, { 1, 30}, { 5, 15}, { 1, 45}, { 5, 33}, /* Row 32 */
+ { 1, 7}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 17, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 9, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 12, 4}, { 1, 3},
+ { 1, 8}, { 1, 13}, { 4, 4}, { 1, 5}, { 4, 0}, { 5, 15}, { 1, 34}, { 7, 38},
+ { 1, 30}, { 4, 15}, { 1, 45}, { 6, 33}, { 1, 50}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 9, 38}, { 1, 34}, { 5, 15}, { 1, 31}, { 1, 40}, /* Row 33 */
+ { 4, 33}, { 1, 51}, { 1, 52}, { 1, 7}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 18, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 10, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 12, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 4, 4}, { 1, 5}, { 2, 0}, { 1, 14}, { 4, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 15, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 10, 38}, { 1, 30}, { 5, 15}, { 1, 45}, { 3, 33}, /* Row 34 */
+ { 1, 53}, { 1, 54}, { 1, 21}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 19, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 10, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 13, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 4, 4}, { 1, 5}, { 1, 0}, { 5, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 3, 15}, { 1, 55}, { 1, 56}, { 6, 33}, { 1, 7}, { 15, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 10, 38}, { 1, 34}, { 5, 15}, { 1, 31}, { 1, 40}, /* Row 35 */
+ { 1, 33}, { 1, 53}, { 1, 57}, { 1, 27}, { 1, 28}, { 1, 58}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 20, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 11, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 13, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 4, 4}, { 1, 59}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15},
+ { 1, 31}, { 1, 60}, { 6, 33}, { 16, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 11, 38}, { 1, 30}, { 5, 15}, { 1, 61}, { 1, 53}, /* Row 36 */
+ { 1, 57}, { 3, 27}, { 1, 62}, { 1, 56}, { 1, 7}, { 21, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 11, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27},
+ { 1, 28}, { 1, 49}, { 14, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 2, 4}, { 1, 21},
+ { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45}, { 6, 33},
+ { 1, 7}, { 16, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 11, 38}, { 1, 34}, { 5, 15}, { 1, 63}, { 1, 35}, /* Row 37 */
+ { 5, 27}, { 1, 64}, { 22, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 12, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 14, 4}, { 1, 3},
+ { 1, 8}, { 1, 13}, { 1, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 17, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 12, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, /* Row 38 */
+ { 1, 65}, { 1, 3}, { 21, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 12, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 15, 4},
+ { 1, 3}, { 1, 8}, { 1, 66}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 45}, { 6, 33}, { 1, 7}, { 17, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 12, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, /* Row 39 */
+ { 4, 27}, { 1, 28}, { 1, 49}, { 21, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 13, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 16, 4},
+ { 1, 67}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40},
+ { 6, 33}, { 18, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 13, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, /* Row 40 */
+ { 1, 29}, { 1, 3}, { 20, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 13, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 15, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45},
+ { 6, 33}, { 1, 7}, { 18, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 13, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, /* Row 41 */
+ { 4, 27}, { 1, 28}, { 1, 49}, { 20, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 14, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 14, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40},
+ { 6, 33}, { 19, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 14, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, /* Row 42 */
+ { 1, 29}, { 1, 3}, { 19, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 14, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 13, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45},
+ { 6, 33}, { 1, 7}, { 19, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 14, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, /* Row 43 */
+ { 4, 27}, { 1, 28}, { 1, 49}, { 19, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 68}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29},
+ { 1, 3}, { 12, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15},
+ { 1, 31}, { 1, 40}, { 6, 33}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 15, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, /* Row 44 */
+ { 1, 29}, { 1, 3}, { 18, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38},
+ { 1, 69}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28},
+ { 1, 49}, { 11, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 45}, { 6, 33}, { 1, 7}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 68}, { 6, 38}, { 1, 34}, { 5, 15}, /* Row 45 */
+ { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 18, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 10, 4}, { 1, 18}, { 4, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 69}, { 7, 38}, { 1, 30}, { 5, 15}, /* Row 46 */
+ { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 17, 4}, { 1, 16}, { 1, 20}, { 2, 15},
+ { 1, 30}, { 7, 38}, { 2, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 4, 27}, { 1, 28}, { 1, 49}, { 9, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45}, { 6, 33}, { 1, 7}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 1, 34}, { 6, 38}, { 1, 34}, /* Row 47 */
+ { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 17, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 1, 15}, { 1, 34}, { 7, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 8, 4}, { 1, 18},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33},
+ { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 2, 30}, { 7, 38}, { 1, 30}, { 5, 15}, /* Row 48 */
+ { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 16, 4}, { 1, 16}, { 1, 20}, { 2, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 1, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 7, 4}, { 1, 21}, { 1, 19},
+ { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 70}, { 6, 33}, { 1, 7},
+ { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 1, 15}, { 1, 34}, { 6, 38}, /* Row 49 */
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 16, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 6, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 1},
+ { 1, 53}, { 5, 33}, { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 1, 15}, { 1, 30}, { 7, 38}, /* Row 50 */
+ { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 15, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 5, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 1, 27}, { 1, 57}, { 1, 53}, { 3, 33}, { 1, 7}, { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 34}, { 6, 38}, /* Row 51 */
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 15, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 4, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 2, 27}, { 1, 57}, { 1, 53}, { 2, 33}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 30}, { 7, 38}, /* Row 52 */
+ { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 14, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 3, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 4, 27}, { 1, 57}, { 1, 53}, { 1, 7}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 3, 15}, { 1, 34}, { 6, 38}, /* Row 53 */
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 14, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 2, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 5, 27}, { 1, 71}, { 1, 72}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 3, 15}, { 1, 30}, { 7, 38}, /* Row 54 */
+ { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 13, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 1, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 6, 27}, { 1, 28}, { 1, 49}, { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 34}, { 6, 38}, /* Row 55 */
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 13, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 4}, { 1, 18},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27},
+ { 1, 49}, { 1, 3}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 30}, { 7, 38}, /* Row 56 */
+ { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 12, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 73}, { 1, 19},
+ { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 36},
+ { 1, 13}, { 3, 4}, { 1, 5}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 5, 15}, { 1, 34}, { 6, 38}, /* Row 57 */
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 12, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 6, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 74}, { 4, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49},
+ { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 5, 15}, { 1, 30}, { 7, 38}, /* Row 58 */
+ { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 11, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 6, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 3, 27}, { 1, 35}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 2, 3},
+ { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 19, 0},
+ { 17, 0}, { 1, 75}, { 1, 55}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 6, 15}, /* Row 59 */
+ { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28},
+ { 1, 49}, { 11, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 7, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 3, 27}, { 1, 43},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 28}, { 1, 49}, { 2, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5},
+ { 18, 0},
+ { 16, 0}, { 1, 1}, { 1, 76}, { 1, 37}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, /* Row 60 */
+ { 6, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29},
+ { 1, 3}, { 10, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 3, 15}, { 1, 37}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 1, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 3, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 3, 4}, { 1, 5}, { 17, 0},
+ { 15, 0}, { 1, 1}, { 1, 6}, { 1, 73}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, /* Row 61 */
+ { 1, 30}, { 7, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35},
+ { 4, 27}, { 1, 28}, { 1, 49}, { 10, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 77}, { 1, 78}, { 4, 15}, { 1, 34}, { 7, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 1, 79}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49}, { 5, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 16, 0},
+ { 14, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, /* Row 62 */
+ { 8, 38}, { 1, 30}, { 7, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43},
+ { 5, 27}, { 1, 29}, { 1, 3}, { 9, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 41}, { 1, 34}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 80}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 6, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 15, 0},
+ { 13, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 9}, { 1, 77}, { 2, 15}, /* Row 63 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 3, 15}, { 1, 37}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 9, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 1, 43}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 68},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 28}, { 1, 49}, { 8, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5},
+ { 14, 0},
+ { 12, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 82}, { 1, 83}, /* Row 64 */
+ { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 77}, { 1, 78}, { 4, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3},
+ { 8, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 1, 35}, { 1, 34}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34},
+ { 9, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29},
+ { 1, 3}, { 9, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 13, 0},
+ { 11, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 85}, /* Row 65 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 41},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35},
+ { 4, 27}, { 1, 28}, { 1, 49}, { 8, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 1, 27}, { 1, 43}, { 4, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 7, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49}, { 11, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 3, 4}, { 1, 5}, { 12, 0},
+ { 10, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 66 */
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43},
+ { 5, 27}, { 1, 29}, { 1, 3}, { 7, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 1, 27}, { 1, 35}, { 1, 34},
+ { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 7, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 12, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 3, 4}, { 1, 5}, { 11, 0},
+ { 9, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 67 */
+ { 1, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 7, 4}, { 1, 16},
+ { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 2, 27}, { 1, 43}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49},
+ { 14, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 10, 0},
+ { 8, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 68 */
+ { 2, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 1, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 6, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 2, 27},
+ { 1, 35}, { 1, 34}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 5, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 15, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 9, 0},
+ { 7, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 69 */
+ { 3, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 1, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 6, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 3, 27}, { 1, 43}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 3, 15},
+ { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28},
+ { 1, 49}, { 17, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 8, 0},
+ { 6, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 70 */
+ { 4, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 2, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 5, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 3, 27},
+ { 1, 35}, { 1, 34}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 3, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 18, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 7, 0},
+ { 5, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 71 */
+ { 5, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 2, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 5, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 4, 27}, { 1, 43}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 1, 15},
+ { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28},
+ { 1, 49}, { 20, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 6, 0},
+ { 4, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 72 */
+ { 6, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 3, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 4, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 4, 27},
+ { 1, 35}, { 1, 34}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 1, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 21, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 5, 0},
+ { 3, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 73 */
+ { 7, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 3, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 4, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 5, 27}, { 1, 43}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 69}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49}, { 23, 4},
+ { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5}, { 4, 0},
+ { 2, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 74 */
+ { 8, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 4, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 5, 15}, { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 3, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 5, 27},
+ { 1, 87}, { 1, 34}, { 3, 15}, { 1, 30}, { 15, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 6, 27}, { 1, 29}, { 1, 3}, { 24, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4},
+ { 1, 5}, { 3, 0},
+ { 1, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, /* Row 75 */
+ { 9, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 4, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 3, 4},
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 6, 27}, { 1, 67}, { 4, 15}, { 1, 34}, { 13, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49}, { 26, 4}, { 1, 3}, { 1, 8},
+ { 1, 13}, { 3, 4}, { 1, 5}, { 2, 0},
+ { 1, 1}, { 1, 6}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, { 10, 4}, /* Row 76 */
+ { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25},
+ { 1, 81}, { 5, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 43}, { 5, 27}, { 1, 29}, { 1, 3}, { 2, 4}, { 1, 16}, { 1, 20}, { 2, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 21},
+ { 1, 19}, { 3, 15}, { 1, 30}, { 13, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 29}, { 1, 3}, { 27, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4}, { 1, 5},
+ { 1, 0},
+ { 1, 2}, { 1, 7}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, { 11, 4}, { 1, 16}, /* Row 77 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 5, 27}, { 1, 87}, { 1, 34}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15},
+ { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 2, 4}, { 1, 16}, { 1, 20},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27},
+ { 1, 4}, { 1, 18}, { 4, 15}, { 1, 34}, { 11, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 5, 27}, { 1, 28}, { 1, 49}, { 29, 4}, { 1, 3}, { 1, 8}, { 1, 13},
+ { 3, 4}, { 1, 5},
+ { 1, 3}, { 1, 4}, { 1, 28}, { 1, 84}, { 1, 86}, { 12, 4}, { 1, 16}, { 1, 20}, /* Row 78 */
+ { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27},
+ { 1, 67}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27},
+ { 1, 29}, { 1, 3}, { 1, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38},
+ { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 4}, { 1, 21}, { 1, 19},
+ { 3, 15}, { 1, 30}, { 11, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29},
+ { 1, 3}, { 30, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 3, 4},
+ { 1, 4}, { 1, 88}, { 1, 89}, { 1, 86}, { 13, 4}, { 1, 16}, { 1, 20}, { 2, 15}, /* Row 79 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 21},
+ { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 35},
+ { 4, 27}, { 1, 28}, { 1, 49}, { 1, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 2, 4}, { 1, 6},
+ { 4, 15}, { 1, 34}, { 9, 38}, { 1, 19}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 28}, { 1, 49}, { 32, 4}, { 1, 3}, { 1, 8}, { 1, 13}, { 1, 49}, { 1, 3},
+ { 2, 4}, { 1, 90}, { 1, 8}, { 1, 3}, { 12, 4}, { 1, 16}, { 1, 20}, { 2, 15}, /* Row 80 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27},
+ { 1, 29}, { 1, 3}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 2, 4}, { 1, 6}, { 4, 15}, { 1, 69},
+ { 9, 38}, { 1, 31}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 29}, { 1, 3}, { 33, 4},
+ { 1, 3}, { 1, 91}, { 1, 81}, { 1, 4},
+ { 3, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 11, 4}, { 1, 16}, { 1, 20}, { 2, 15}, /* Row 81 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34},
+ { 1, 35}, { 4, 27}, { 1, 28}, { 1, 49}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 4}, { 1, 21},
+ { 1, 19}, { 4, 15}, { 1, 34}, { 8, 38}, { 1, 92}, { 4, 15}, { 1, 68}, { 1, 93},
+ { 6, 27}, { 1, 49}, { 33, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 56}, { 1, 8},
+ { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 10, 4}, { 1, 16}, { 1, 20}, { 2, 15}, /* Row 82 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 2, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 5, 27},
+ { 1, 29}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 6, 27}, { 1, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 10, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 49}, { 32, 4}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4},
+ { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 9, 4}, { 1, 16}, { 1, 20}, /* Row 83 */
+ { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27},
+ { 2, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15},
+ { 1, 34}, { 1, 35}, { 4, 27}, { 1, 28}, { 1, 7}, { 1, 20}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 21}, { 1, 19},
+ { 4, 15}, { 1, 34}, { 10, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 29}, { 1, 3}, { 30, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5},
+ { 1, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 8, 4}, { 1, 16}, /* Row 84 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 3, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 43}, { 5, 27}, { 1, 10}, { 1, 20}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 1, 67}, { 4, 15}, { 1, 30}, { 12, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 29, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 1, 0},
+ { 2, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 7, 4}, { 1, 16}, /* Row 85 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 3, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 81}, { 1, 77}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 5, 27}, { 1, 87}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 12, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 29}, { 1, 3}, { 27, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 2, 0},
+ { 3, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 6, 4}, { 1, 16}, /* Row 86 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 4, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 43}, { 4, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 2, 15}, { 1, 25}, { 1, 81}, { 5, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 14, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 26, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 3, 0},
+ { 4, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 5, 4}, { 1, 16}, /* Row 87 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 4, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 34}, { 1, 35}, { 3, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 4, 27}, { 1, 35}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 14, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27},
+ { 1, 29}, { 1, 3}, { 24, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 4, 0},
+ { 5, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 4, 4}, { 1, 16}, /* Row 88 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 5, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 43}, { 3, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 2, 15}, { 1, 25}, { 1, 81}, { 4, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 16, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 23, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 5, 0},
+ { 6, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 3, 4}, { 1, 16}, /* Row 89 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 5, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 34}, { 1, 35}, { 2, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 3, 27}, { 1, 35}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 7, 38}, { 1, 34}, { 1, 69}, { 7, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 1, 3}, { 21, 4}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 6, 0},
+ { 7, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 2, 4}, { 1, 16}, /* Row 90 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 6, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 43}, { 2, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30},
+ { 2, 15}, { 1, 25}, { 1, 81}, { 3, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 8, 38},
+ { 1, 30}, { 1, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27},
+ { 1, 28}, { 1, 49}, { 20, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 7, 0},
+ { 8, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 1, 4}, { 1, 16}, /* Row 91 */
+ { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81},
+ { 6, 27}, { 6, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 34}, { 1, 35}, { 1, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 2, 27}, { 1, 35}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 7, 38}, { 1, 34}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 1, 3}, { 18, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 8, 0},
+ { 9, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 1, 16}, { 1, 20}, /* Row 92 */
+ { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27},
+ { 7, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43},
+ { 1, 27}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 2, 27}, { 1, 43}, { 4, 15}, { 1, 30}, { 8, 38}, { 1, 30},
+ { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28},
+ { 1, 49}, { 17, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4},
+ { 1, 5}, { 9, 0},
+ { 10, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 16}, { 1, 20}, { 2, 15}, /* Row 93 */
+ { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 7, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34},
+ { 1, 35}, { 1, 81}, { 1, 25}, { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 25}, { 1, 81}, { 1, 27}, { 1, 35}, { 1, 34}, { 4, 15}, { 1, 34}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 5, 27}, { 1, 29}, { 1, 3}, { 15, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 1, 4}, { 1, 5}, { 10, 0},
+ { 11, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 73}, { 1, 20}, { 2, 15}, { 1, 30}, /* Row 94 */
+ { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 8, 4}, { 1, 18},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 43}, { 1, 81}, { 1, 25},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 1, 27},
+ { 1, 43}, { 4, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 5, 15}, { 1, 34}, { 7, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 14, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 11, 0},
+ { 12, 0}, { 1, 5}, { 4, 4}, { 1, 57}, { 1, 77}, { 2, 15}, { 1, 30}, { 8, 38}, /* Row 95 */
+ { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 8, 4}, { 1, 21}, { 1, 19},
+ { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 34}, { 1, 41}, { 1, 25},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 1, 35},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 34}, { 6, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 1, 3}, { 12, 4},
+ { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 12, 0},
+ { 13, 0}, { 1, 5}, { 3, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, /* Row 96 */
+ { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 9, 4}, { 1, 18}, { 4, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 78}, { 1, 77}, { 2, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 1, 43}, { 4, 15}, { 1, 30},
+ { 8, 38}, { 1, 30}, { 7, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 5, 27}, { 1, 28}, { 1, 49}, { 11, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 1, 4}, { 1, 5}, { 13, 0},
+ { 14, 0}, { 1, 5}, { 2, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, /* Row 97 */
+ { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 9, 4}, { 1, 21}, { 1, 19},
+ { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 5, 15}, { 1, 37}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 41}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 37}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 1, 3}, { 9, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 14, 0},
+ { 15, 0}, { 1, 5}, { 1, 4}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, /* Row 98 */
+ { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 10, 4}, { 1, 18}, { 4, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 8, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 77}, { 1, 78}, { 4, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 78},
+ { 1, 34}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27},
+ { 1, 28}, { 1, 49}, { 8, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 15, 0},
+ { 16, 0}, { 1, 5}, { 1, 16}, { 1, 20}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, /* Row 99 */
+ { 2, 15}, { 1, 25}, { 1, 81}, { 6, 27}, { 10, 4}, { 1, 21}, { 1, 19}, { 4, 15},
+ { 1, 34}, { 6, 38}, { 1, 34}, { 8, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15},
+ { 1, 37}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 94},
+ { 1, 43}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 5, 27}, { 1, 29}, { 1, 3}, { 6, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 1, 4}, { 1, 5}, { 16, 0},
+ { 17, 0}, { 1, 95}, { 1, 96}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, /* Row 100 */
+ { 1, 25}, { 1, 81}, { 6, 27}, { 11, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38},
+ { 1, 30}, { 7, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 7, 15}, { 1, 30}, { 8, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 1, 27}, { 1, 35}, { 1, 34}, { 3, 15}, { 1, 34},
+ { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 5, 4},
+ { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 17, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 101 */
+ { 6, 27}, { 11, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 7, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 7, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 2, 27}, { 1, 43}, { 3, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 1, 3}, { 3, 4},
+ { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 18, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 102 */
+ { 6, 27}, { 12, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 6, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 6, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 3, 27}, { 1, 35}, { 1, 34}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 2, 4}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 19, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 103 */
+ { 6, 27}, { 12, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 6, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 6, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 4, 27}, { 1, 43}, { 3, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 29}, { 2, 3}, { 1, 8},
+ { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 104 */
+ { 6, 27}, { 13, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 5, 27}, { 1, 35}, { 1, 34}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30},
+ { 4, 15}, { 1, 43}, { 5, 27}, { 1, 28}, { 1, 49}, { 1, 8}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 1, 4}, { 1, 5}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 105 */
+ { 6, 27}, { 13, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 5, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 5, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 74}, { 3, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 36}, { 1, 7}, { 1, 11},
+ { 1, 7}, { 1, 4}, { 1, 5}, { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 106 */
+ { 6, 27}, { 14, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 6, 27}, { 1, 28}, { 1, 73}, { 1, 19}, { 3, 15}, { 1, 34}, { 7, 38},
+ { 1, 30}, { 4, 15}, { 1, 43}, { 5, 27}, { 1, 54}, { 1, 97}, { 1, 7}, { 1, 4},
+ { 1, 5}, { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 107 */
+ { 6, 27}, { 14, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 4}, { 1, 18}, { 3, 15},
+ { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 5, 27}, { 1, 98},
+ { 1, 4}, { 1, 5}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 108 */
+ { 6, 27}, { 15, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49}, { 1, 4}, { 1, 21}, { 1, 19}, { 3, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 4, 27}, { 1, 57}, { 1, 99},
+ { 1, 9}, { 25, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 109 */
+ { 6, 27}, { 15, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 3, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 2, 4}, { 1, 18},
+ { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35}, { 2, 27},
+ { 1, 57}, { 1, 53}, { 2, 33}, { 25, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 110 */
+ { 6, 27}, { 16, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49}, { 3, 4}, { 1, 21}, { 1, 19}, { 3, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 1, 27}, { 1, 57}, { 1, 53},
+ { 3, 33}, { 1, 7}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 111 */
+ { 6, 27}, { 16, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 2, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 2, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 4, 4}, { 1, 18},
+ { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 1}, { 1, 53},
+ { 5, 33}, { 24, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 112 */
+ { 6, 27}, { 17, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 1, 15},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 1, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49}, { 5, 4}, { 1, 21}, { 1, 19}, { 3, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 70}, { 6, 33}, { 1, 7}, { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 113 */
+ { 6, 27}, { 17, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 1, 15}, { 1, 30}, { 7, 38}, { 1, 30}, { 1, 15}, { 1, 34}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 6, 4}, { 1, 18},
+ { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33},
+ { 23, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 114 */
+ { 6, 27}, { 18, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 2, 30}, { 7, 38},
+ { 2, 30}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49},
+ { 7, 4}, { 1, 21}, { 1, 19}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 45}, { 6, 33}, { 1, 7}, { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 25}, { 1, 81}, /* Row 115 */
+ { 6, 27}, { 18, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34},
+ { 1, 30}, { 7, 38}, { 1, 30}, { 1, 34}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 8, 4}, { 1, 18}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 22, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 77}, { 1, 100}, /* Row 116 */
+ { 6, 27}, { 19, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 7, 38}, { 1, 69}, { 7, 38},
+ { 1, 69}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49},
+ { 9, 4}, { 1, 21}, { 1, 19}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 45}, { 6, 33}, { 1, 7}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 101}, /* Row 117 */
+ { 1, 57}, { 5, 27}, { 19, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38},
+ { 1, 68}, { 7, 38}, { 1, 68}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 34}, { 1, 35},
+ { 6, 27}, { 1, 29}, { 1, 3}, { 10, 4}, { 1, 18}, { 3, 15}, { 1, 30}, { 7, 38},
+ { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 21, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 118 */
+ { 1, 53}, { 1, 57}, { 4, 27}, { 1, 8}, { 1, 3}, { 18, 4}, { 1, 18}, { 4, 15},
+ { 1, 30}, { 22, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49},
+ { 11, 4}, { 1, 21}, { 1, 19}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 45}, { 6, 33}, { 1, 7}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 119 */
+ { 1, 33}, { 1, 53}, { 1, 57}, { 3, 27}, { 1, 36}, { 1, 8}, { 1, 3}, { 17, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 20, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 12, 4}, { 1, 18}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 20, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 120 */
+ { 2, 33}, { 1, 53}, { 1, 57}, { 2, 27}, { 1, 49}, { 1, 13}, { 1, 8}, { 1, 3},
+ { 17, 4}, { 1, 18}, { 4, 15}, { 1, 30}, { 20, 38}, { 1, 30}, { 4, 15}, { 1, 43},
+ { 6, 27}, { 1, 28}, { 1, 49}, { 12, 4}, { 1, 3}, { 1, 79}, { 1, 63}, { 3, 15},
+ { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45}, { 6, 33}, { 1, 7}, { 19, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 121 */
+ { 3, 33}, { 1, 53}, { 1, 57}, { 1, 27}, { 2, 4}, { 1, 13}, { 1, 8}, { 1, 3},
+ { 16, 4}, { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 18, 38}, { 1, 34}, { 4, 15},
+ { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 11, 4}, { 1, 3}, { 1, 8},
+ { 1, 7}, { 1, 102}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31},
+ { 1, 40}, { 6, 33}, { 19, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 122 */
+ { 4, 33}, { 1, 53}, { 1, 62}, { 3, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 16, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 18, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 28}, { 1, 49}, { 11, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 79},
+ { 1, 19}, { 3, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45}, { 6, 33},
+ { 1, 7}, { 18, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 123 */
+ { 5, 33}, { 1, 103}, { 1, 3}, { 3, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 15, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 16, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 53}, { 3, 15}, { 1, 30}, { 7, 38}, { 1, 34},
+ { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 18, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 124 */
+ { 6, 33}, { 1, 95}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 15, 4}, { 1, 18},
+ { 4, 15}, { 1, 30}, { 16, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27}, { 1, 28},
+ { 1, 49}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4},
+ { 1, 5}, { 1, 27}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15}, { 1, 45},
+ { 6, 33}, { 1, 7}, { 17, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 125 */
+ { 6, 33}, { 1, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 14, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 14, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 9, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 2, 0}, { 1, 14}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 17, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 126 */
+ { 6, 33}, { 2, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 14, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 14, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 28}, { 1, 49}, { 9, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 4, 0}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 45}, { 6, 33}, { 1, 7}, { 16, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 127 */
+ { 6, 33}, { 3, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 13, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 12, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 8, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 5, 0}, { 1, 14}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 16, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 128 */
+ { 6, 33}, { 4, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 13, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 12, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 28}, { 1, 49}, { 8, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 7, 0}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 45}, { 6, 33}, { 1, 7}, { 15, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 129 */
+ { 6, 33}, { 5, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 12, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 10, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 7, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 8, 0}, { 1, 14}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 34}, { 4, 15}, { 1, 31}, { 1, 40}, { 6, 33}, { 15, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 130 */
+ { 6, 33}, { 6, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 12, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 10, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 28}, { 1, 49}, { 7, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 10, 0}, { 4, 15}, { 1, 34}, { 7, 38}, { 1, 30}, { 4, 15},
+ { 1, 22}, { 6, 33}, { 1, 104}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 131 */
+ { 6, 33}, { 7, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 11, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 8, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 6, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 11, 0}, { 1, 14}, { 3, 15}, { 1, 30},
+ { 7, 38}, { 1, 44}, { 4, 15}, { 1, 45}, { 6, 33}, { 1, 65}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 132 */
+ { 6, 33}, { 8, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 11, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 4, 15}, { 1, 43}, { 6, 27},
+ { 1, 28}, { 1, 49}, { 6, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 13, 0}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 4, 15},
+ { 1, 45}, { 7, 33}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 133 */
+ { 6, 33}, { 9, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 10, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 34}, { 6, 38}, { 1, 34}, { 4, 15}, { 1, 34},
+ { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 5, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 14, 0}, { 1, 14}, { 3, 15}, { 1, 30},
+ { 6, 38}, { 1, 44}, { 3, 15}, { 1, 55}, { 1, 105}, { 7, 33}, { 1, 104}, { 13, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 134 */
+ { 6, 33}, { 10, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 10, 4},
+ { 1, 18}, { 4, 15}, { 1, 30}, { 1, 106}, { 4, 38}, { 1, 106}, { 1, 30}, { 4, 15},
+ { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49}, { 5, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 16, 0}, { 4, 15}, { 1, 34}, { 5, 38},
+ { 1, 30}, { 3, 15}, { 1, 31}, { 1, 60}, { 7, 33}, { 1, 7}, { 13, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 135 */
+ { 6, 33}, { 11, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 9, 4},
+ { 1, 21}, { 1, 19}, { 4, 15}, { 1, 30}, { 1, 34}, { 2, 38}, { 1, 34}, { 1, 30},
+ { 4, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3}, { 4, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 17, 0}, { 1, 14},
+ { 3, 15}, { 1, 30}, { 1, 34}, { 2, 38}, { 1, 34}, { 1, 30}, { 4, 15}, { 1, 45},
+ { 8, 33}, { 1, 7}, { 13, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 136 */
+ { 6, 33}, { 12, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 9, 4},
+ { 1, 18}, { 6, 15}, { 2, 30}, { 6, 15}, { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49},
+ { 4, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 19, 0}, { 5, 15}, { 2, 30}, { 5, 15}, { 1, 31}, { 1, 40}, { 8, 33}, { 1, 50},
+ { 13, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 137 */
+ { 6, 33}, { 13, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 8, 4},
+ { 1, 21}, { 1, 19}, { 12, 15}, { 1, 34}, { 1, 35}, { 6, 27}, { 1, 29}, { 1, 3},
+ { 3, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 20, 0}, { 1, 14}, { 10, 15}, { 1, 39}, { 1, 107}, { 9, 33}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 30}, { 2, 15}, { 1, 96}, { 1, 60}, /* Row 138 */
+ { 6, 33}, { 14, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 8, 4},
+ { 1, 18}, { 12, 15}, { 1, 43}, { 6, 27}, { 1, 28}, { 1, 49}, { 3, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 22, 0}, { 9, 15},
+ { 1, 39}, { 1, 107}, { 9, 33}, { 1, 7}, { 14, 0},
+ { 18, 0}, { 3, 15}, { 1, 30}, { 8, 38}, { 1, 55}, { 2, 96}, { 1, 108}, { 1, 60}, /* Row 139 */
+ { 6, 33}, { 15, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 7, 4},
+ { 1, 16}, { 1, 23}, { 10, 15}, { 1, 109}, { 1, 81}, { 6, 27}, { 1, 29}, { 1, 3},
+ { 2, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 23, 0}, { 1, 28}, { 1, 110}, { 5, 15}, { 1, 39}, { 1, 111}, { 1, 105}, { 10, 33},
+ { 15, 0},
+ { 25, 0}, { 1, 59}, { 4, 40}, { 4, 60}, { 7, 33}, { 16, 0}, { 1, 5}, { 4, 4}, /* Row 140 */
+ { 1, 13}, { 1, 8}, { 1, 3}, { 7, 4}, { 1, 16}, { 1, 18}, { 1, 19}, { 6, 15},
+ { 1, 34}, { 1, 43}, { 1, 81}, { 6, 27}, { 1, 28}, { 1, 49}, { 2, 4}, { 1, 3},
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 27, 0}, { 1, 112},
+ { 1, 14}, { 1, 113}, { 1, 22}, { 1, 40}, { 1, 76}, { 10, 33}, { 1, 7}, { 15, 0},
+ { 25, 0}, { 16, 33}, { 17, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 141 */
+ { 8, 4}, { 1, 21}, { 1, 18}, { 1, 19}, { 1, 77}, { 1, 25}, { 1, 34}, { 1, 43},
+ { 1, 35}, { 8, 27}, { 1, 8}, { 1, 3}, { 1, 4}, { 1, 3}, { 1, 8}, { 1, 7},
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 30, 0}, { 1, 50}, { 13, 33}, { 16, 0},
+ { 25, 0}, { 16, 33}, { 18, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 142 */
+ { 9, 4}, { 1, 16}, { 1, 10}, { 1, 66}, { 1, 81}, { 8, 27}, { 1, 36}, { 1, 8},
+ { 1, 3}, { 1, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4},
+ { 1, 5}, { 32, 0}, { 1, 7}, { 11, 33}, { 17, 0},
+ { 25, 0}, { 16, 33}, { 19, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 143 */
+ { 9, 4}, { 1, 3}, { 1, 49}, { 1, 29}, { 1, 28}, { 5, 27}, { 1, 36}, { 1, 8},
+ { 3, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 34, 0}, { 10, 33}, { 18, 0},
+ { 25, 0}, { 16, 33}, { 20, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 144 */
+ { 10, 4}, { 1, 3}, { 10, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7},
+ { 1, 4}, { 1, 5}, { 35, 0}, { 1, 41}, { 7, 33}, { 1, 7}, { 19, 0},
+ { 25, 0}, { 16, 33}, { 21, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 145 */
+ { 19, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 64, 0},
+ { 25, 0}, { 16, 33}, { 22, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, /* Row 146 */
+ { 17, 4}, { 1, 3}, { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5},
+ { 65, 0},
+ { 64, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 15, 4}, { 1, 3}, /* Row 147 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 66, 0},
+ { 65, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 13, 4}, { 1, 3}, /* Row 148 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 67, 0},
+ { 66, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 11, 4}, { 1, 3}, /* Row 149 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 68, 0},
+ { 67, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 9, 4}, { 1, 3}, /* Row 150 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 69, 0},
+ { 68, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 7, 4}, { 1, 3}, /* Row 151 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 70, 0},
+ { 69, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 5, 4}, { 1, 3}, /* Row 152 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 71, 0},
+ { 70, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 3, 4}, { 1, 3}, /* Row 153 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 72, 0},
+ { 71, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 1, 4}, { 1, 3}, /* Row 154 */
+ { 1, 8}, { 1, 7}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 73, 0},
+ { 72, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 8}, { 1, 3}, { 1, 8}, { 1, 7}, /* Row 155 */
+ { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, { 74, 0},
+ { 73, 0}, { 1, 5}, { 4, 4}, { 1, 13}, { 1, 91}, { 1, 7}, { 1, 11}, { 1, 7}, /* Row 156 */
+ { 1, 4}, { 1, 5}, { 75, 0},
+ { 74, 0}, { 1, 5}, { 4, 4}, { 1, 114}, { 1, 11}, { 1, 7}, { 1, 4}, { 1, 5}, /* Row 157 */
+ { 76, 0},
+ { 75, 0}, { 1, 5}, { 2, 4}, { 1, 8}, { 1, 115}, { 1, 7}, { 1, 4}, { 1, 5}, /* Row 158 */
+ { 77, 0},
+ { 76, 0}, { 1, 5}, { 4, 4}, { 1, 5}, { 78, 0} /* Row 159 */
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+static const struct SRlePaletteBitmapEntry g_nuttxRleEntries[] =
+{
+ { 76, 0}, { 1, 1}, { 1, 2}, { 5, 3}, { 1, 4}, { 76, 0}, /* Row 0 */
+ { 75, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 6, 3}, { 1, 4}, { 75, 0}, /* Row 1 */
+ { 74, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 2, 6}, { 4, 3}, { 1, 4}, /* Row 2 */
+ { 74, 0},
+ { 73, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 8}, /* Row 3 */
+ { 1, 6}, { 4, 3}, { 1, 4}, { 73, 0},
+ { 72, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 4 */
+ { 2, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 72, 0},
+ { 71, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 5 */
+ { 4, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 71, 0},
+ { 70, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 6 */
+ { 6, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 70, 0},
+ { 69, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 7 */
+ { 8, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 69, 0},
+ { 68, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 8 */
+ { 10, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 68, 0},
+ { 67, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 9 */
+ { 12, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 67, 0},
+ { 66, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 10 */
+ { 14, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 66, 0},
+ { 65, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 11 */
+ { 16, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 65, 0},
+ { 64, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 12 */
+ { 18, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 64, 0},
+ { 63, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 13 */
+ { 20, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 63, 0},
+ { 62, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 14 */
+ { 22, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 62, 0},
+ { 61, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 15 */
+ { 24, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 61, 0},
+ { 60, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 16 */
+ { 26, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 60, 0},
+ { 59, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 17 */
+ { 28, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 59, 0},
+ { 58, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 18 */
+ { 30, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 26, 0}, { 1, 9}, { 5, 10}, { 1, 9},
+ { 25, 0},
+ { 57, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 19 */
+ { 10, 3}, { 5, 5}, { 17, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 23, 0}, { 1, 1},
+ { 9, 10}, { 1, 1}, { 23, 0},
+ { 56, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 20 */
+ { 9, 3}, { 1, 5}, { 1, 11}, { 5, 12}, { 1, 11}, { 1, 13}, { 16, 3}, { 1, 6},
+ { 4, 3}, { 1, 4}, { 22, 0}, { 11, 10}, { 1, 1}, { 22, 0},
+ { 23, 0}, { 1, 9}, { 5, 10}, { 1, 14}, { 25, 0}, { 1, 1}, { 1, 2}, { 1, 5}, /* Row 21 */
+ { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 9, 3}, { 1, 5}, { 1, 15}, { 7, 10},
+ { 1, 12}, { 1, 16}, { 16, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 20, 0}, { 1, 9},
+ { 12, 10}, { 1, 1}, { 21, 0},
+ { 21, 0}, { 1, 1}, { 9, 10}, { 1, 1}, { 22, 0}, { 1, 1}, { 1, 2}, { 1, 5}, /* Row 22 */
+ { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 9, 3}, { 1, 5}, { 1, 15}, { 9, 10},
+ { 1, 12}, { 1, 16}, { 16, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 19, 0}, { 14, 10},
+ { 21, 0},
+ { 21, 0}, { 11, 10}, { 1, 1}, { 20, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, /* Row 23 */
+ { 1, 7}, { 1, 2}, { 1, 5}, { 10, 3}, { 1, 11}, { 11, 10}, { 1, 12}, { 1, 7},
+ { 3, 6}, { 1, 5}, { 12, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 17, 0}, { 1, 9},
+ { 6, 10}, { 2, 12}, { 6, 10}, { 1, 9}, { 20, 0},
+ { 20, 0}, { 1, 14}, { 12, 10}, { 1, 9}, { 4, 2}, { 1, 17}, { 13, 0}, { 1, 1}, /* Row 24 */
+ { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 10, 3}, { 1, 13},
+ { 1, 12}, { 12, 10}, { 1, 12}, { 5, 6}, { 12, 3}, { 1, 6}, { 4, 3}, { 1, 4},
+ { 16, 0}, { 5, 10}, { 6, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 1, 1}, { 18, 0},
+ { 19, 0}, { 1, 9}, { 13, 10}, { 1, 12}, { 1, 18}, { 5, 2}, { 11, 0}, { 1, 1}, /* Row 25 */
+ { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 11, 3}, { 1, 19},
+ { 4, 10}, { 5, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 12, 3}, { 1, 6}, { 4, 3},
+ { 1, 4}, { 14, 0}, { 1, 9}, { 5, 10}, { 6, 12}, { 5, 10}, { 1, 14}, { 1, 2},
+ { 1, 1}, { 17, 0},
+ { 19, 0}, { 6, 10}, { 3, 12}, { 6, 10}, { 1, 14}, { 5, 2}, { 1, 17}, { 9, 0}, /* Row 26 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 11, 3},
+ { 1, 5}, { 1, 14}, { 4, 10}, { 6, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 12, 3},
+ { 1, 6}, { 4, 3}, { 1, 4}, { 13, 0}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 14},
+ { 2, 2}, { 1, 1}, { 16, 0},
+ { 18, 0}, { 1, 9}, { 4, 10}, { 6, 12}, { 5, 10}, { 1, 12}, { 1, 18}, { 5, 2}, /* Row 27 */
+ { 8, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5},
+ { 12, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 5, 10}, { 1, 11}, { 5, 6},
+ { 1, 5}, { 12, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 11, 0}, { 1, 9}, { 5, 10},
+ { 8, 12}, { 4, 10}, { 1, 14}, { 3, 2}, { 16, 0},
+ { 18, 0}, { 5, 10}, { 6, 12}, { 6, 10}, { 1, 14}, { 5, 2}, { 1, 17}, { 6, 0}, /* Row 28 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 13, 3},
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 13, 3},
+ { 1, 6}, { 4, 3}, { 1, 4}, { 10, 0}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 3, 2}, { 1, 17}, { 15, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 1, 18}, { 5, 2}, { 5, 0}, /* Row 29 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 14, 3},
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5},
+ { 13, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 8, 0}, { 1, 9}, { 5, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 1, 18}, { 4, 2}, { 15, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 6, 10}, { 1, 14}, { 5, 2}, { 1, 17}, { 3, 0}, /* Row 30 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 15, 3},
+ { 1, 5}, { 1, 12}, { 3, 10}, { 9, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 14, 3},
+ { 1, 6}, { 4, 3}, { 1, 4}, { 7, 0}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 5, 2}, { 1, 1}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 9, 12}, { 5, 10}, { 1, 12}, { 1, 18}, { 5, 2}, { 2, 0}, /* Row 31 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 16, 3},
+ { 1, 5}, { 1, 12}, { 3, 10}, { 9, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5},
+ { 14, 3}, { 1, 6}, { 4, 3}, { 1, 4}, { 5, 0}, { 1, 9}, { 5, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 1, 18}, { 5, 2}, { 1, 17}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 9, 12}, { 6, 10}, { 1, 14}, { 5, 2}, { 1, 17}, { 1, 1}, /* Row 32 */
+ { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 17, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 10, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 15, 3}, { 1, 6},
+ { 4, 3}, { 1, 4}, { 4, 0}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2},
+ { 1, 1}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 10, 12}, { 5, 10}, { 1, 12}, { 1, 18}, { 4, 2}, { 1, 18}, /* Row 33 */
+ { 1, 2}, { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 18, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 10, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 15, 3},
+ { 1, 6}, { 4, 3}, { 1, 4}, { 2, 0}, { 1, 9}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 18}, { 6, 2}, { 15, 0},
+ { 18, 0}, { 4, 10}, { 10, 12}, { 6, 10}, { 1, 14}, { 3, 2}, { 1, 20}, { 1, 6}, /* Row 34 */
+ { 1, 5}, { 2, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 19, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 11, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 16, 3}, { 1, 6}, { 4, 3},
+ { 1, 4}, { 1, 0}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 2}, { 1, 17},
+ { 15, 0},
+ { 18, 0}, { 4, 10}, { 11, 12}, { 5, 10}, { 1, 12}, { 1, 18}, { 1, 2}, { 1, 20}, /* Row 35 */
+ { 3, 6}, { 1, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 20, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 11, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 16, 3}, { 1, 6},
+ { 4, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 2}, { 16, 0},
+ { 18, 0}, { 4, 10}, { 11, 12}, { 6, 10}, { 1, 14}, { 1, 20}, { 5, 6}, { 1, 2}, /* Row 36 */
+ { 1, 5}, { 21, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 12, 12}, { 4, 10}, { 1, 12},
+ { 6, 6}, { 17, 3}, { 1, 6}, { 2, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 16, 0},
+ { 18, 0}, { 4, 10}, { 12, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 1, 5}, { 22, 3}, /* Row 37 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 12, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5},
+ { 17, 3}, { 1, 6}, { 1, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12},
+ { 1, 18}, { 6, 2}, { 17, 0},
+ { 18, 0}, { 4, 10}, { 12, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 22, 3}, /* Row 38 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 13, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 18, 3},
+ { 1, 6}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17},
+ { 17, 0},
+ { 18, 0}, { 4, 10}, { 13, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 22, 3}, { 1, 5}, /* Row 39 */
+ { 1, 12}, { 3, 10}, { 13, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 17, 3},
+ { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2}, { 18, 0},
+ { 18, 0}, { 4, 10}, { 13, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 21, 3}, /* Row 40 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 14, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 16, 3},
+ { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17},
+ { 18, 0},
+ { 18, 0}, { 4, 10}, { 14, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 21, 3}, { 1, 5}, /* Row 41 */
+ { 1, 12}, { 3, 10}, { 14, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 15, 3},
+ { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2}, { 19, 0},
+ { 18, 0}, { 4, 10}, { 14, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 20, 3}, /* Row 42 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 15, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 14, 3},
+ { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17},
+ { 19, 0},
+ { 18, 0}, { 4, 10}, { 15, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 20, 3}, { 1, 5}, /* Row 43 */
+ { 1, 12}, { 3, 10}, { 15, 12}, { 5, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 13, 3},
+ { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2}, { 20, 0},
+ { 18, 0}, { 4, 10}, { 15, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 19, 3}, /* Row 44 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 1, 10}, { 8, 12}, { 4, 10}, { 1, 12},
+ { 6, 6}, { 12, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 6, 2}, { 1, 17}, { 20, 0},
+ { 18, 0}, { 4, 10}, { 16, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 19, 3}, { 1, 5}, /* Row 45 */
+ { 1, 12}, { 3, 10}, { 7, 12}, { 1, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 5, 6},
+ { 1, 5}, { 11, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18},
+ { 6, 2}, { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 1, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 46 */
+ { 1, 5}, { 18, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 2, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 10, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 1, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 47 */
+ { 18, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 2, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 9, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 18}, { 6, 2}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 2, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 48 */
+ { 1, 5}, { 17, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 8, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 2, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 49 */
+ { 17, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 7, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 21}, { 1, 20}, { 5, 2}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 50 */
+ { 1, 5}, { 16, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 4, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 6, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 11}, { 2, 6}, { 1, 20}, { 3, 2}, { 1, 17}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 51 */
+ { 16, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 5, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 4, 6}, { 1, 20}, { 2, 2}, { 24, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 4, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 52 */
+ { 1, 5}, { 15, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 5, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 4, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 11}, { 5, 6}, { 1, 20}, { 1, 17}, { 24, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 53 */
+ { 15, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 5, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 3, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 25, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 54 */
+ { 1, 5}, { 14, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 6, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 2, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 11}, { 7, 6}, { 1, 3}, { 1, 4}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 55 */
+ { 14, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 6, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 1, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 3, 3}, { 1, 4}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 6, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 56 */
+ { 1, 5}, { 13, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 7, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 6, 6}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 8, 6}, { 3, 3}, { 1, 4}, { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 6, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, /* Row 57 */
+ { 13, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 7, 10}, { 8, 12}, { 5, 10},
+ { 1, 11}, { 5, 6}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6},
+ { 2, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 20, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 7, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, /* Row 58 */
+ { 1, 5}, { 12, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 8, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 5, 6}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 1, 5}, { 3, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 19, 0},
+ { 17, 0}, { 1, 22}, { 1, 12}, { 3, 10}, { 8, 12}, { 7, 10}, { 8, 12}, { 5, 10}, /* Row 59 */
+ { 1, 12}, { 6, 6}, { 12, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 8, 10},
+ { 8, 12}, { 5, 10}, { 1, 11}, { 3, 6}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 5, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 18, 0},
+ { 16, 0}, { 1, 1}, { 1, 18}, { 1, 12}, { 3, 10}, { 8, 12}, { 8, 10}, { 7, 12}, /* Row 60 */
+ { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 11, 3}, { 1, 5}, { 1, 12}, { 3, 10},
+ { 7, 12}, { 4, 10}, { 1, 12}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 3, 6},
+ { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 6, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 17, 0},
+ { 15, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 8, 10}, /* Row 61 */
+ { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 11, 3}, { 1, 5}, { 1, 12}, { 3, 10},
+ { 7, 12}, { 3, 10}, { 1, 12}, { 1, 11}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 1, 6}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 8, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 16, 0},
+ { 14, 0}, { 1, 1}, { 1, 2}, { 2, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 9, 10}, /* Row 62 */
+ { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 10, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 1, 21}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 1, 23}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 1, 5}, { 9, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 15, 0},
+ { 13, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 12}, { 3, 10}, /* Row 63 */
+ { 8, 12}, { 4, 10}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6},
+ { 10, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 1, 6},
+ { 1, 11}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 11, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 14, 0},
+ { 12, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 24}, { 1, 12}, /* Row 64 */
+ { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10},
+ { 1, 11}, { 5, 6}, { 1, 5}, { 9, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12},
+ { 3, 10}, { 1, 12}, { 2, 6}, { 1, 12}, { 4, 10}, { 8, 12}, { 9, 10}, { 8, 12},
+ { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 12, 3}, { 1, 6}, { 3, 3}, { 1, 4},
+ { 13, 0},
+ { 11, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 1, 3}, /* Row 65 */
+ { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 1, 21}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 9, 3}, { 1, 5}, { 1, 12}, { 3, 10},
+ { 7, 12}, { 3, 10}, { 1, 12}, { 2, 6}, { 1, 11}, { 4, 10}, { 8, 12}, { 9, 10},
+ { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 14, 3}, { 1, 6}, { 3, 3}, { 1, 4},
+ { 12, 0},
+ { 10, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 1, 3}, /* Row 66 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 1, 6}, { 1, 11},
+ { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 8, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 3, 6}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 7, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 15, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 11, 0},
+ { 9, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 2, 3}, /* Row 67 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 2, 6}, { 1, 12},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 8, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 3, 6}, { 1, 11}, { 4, 10}, { 8, 12},
+ { 7, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 17, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 10, 0},
+ { 8, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 3, 3}, /* Row 68 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 2, 6}, { 1, 11},
+ { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 7, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 4, 6}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 18, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 9, 0},
+ { 7, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 4, 3}, /* Row 69 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 3, 6}, { 1, 12},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 7, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 4, 6}, { 1, 11}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 20, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 8, 0},
+ { 6, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 5, 3}, /* Row 70 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 3, 6}, { 1, 11},
+ { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 6, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 5, 6}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 21, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 7, 0},
+ { 5, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 6, 3}, /* Row 71 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 4, 6}, { 1, 12},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 6, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 5, 6}, { 1, 11}, { 4, 10}, { 8, 12},
+ { 3, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 23, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 6, 0},
+ { 4, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 7, 3}, /* Row 72 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 4, 6}, { 1, 11},
+ { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 5, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 6, 6}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 1, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 24, 3},
+ { 1, 6}, { 3, 3}, { 1, 4}, { 5, 0},
+ { 3, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 8, 3}, /* Row 73 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 5, 6}, { 1, 12},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 5, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 6, 6}, { 1, 11}, { 4, 10}, { 8, 12},
+ { 1, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 26, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 4, 0},
+ { 2, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 9, 3}, /* Row 74 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 5, 6}, { 1, 11},
+ { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 4, 3}, { 1, 5},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 1, 12}, { 4, 10},
+ { 15, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 27, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 3, 0},
+ { 1, 0}, { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 10, 3}, /* Row 75 */
+ { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 6, 6}, { 1, 12},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 4, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 1, 11}, { 4, 10}, { 15, 12},
+ { 4, 10}, { 1, 12}, { 7, 6}, { 29, 3}, { 1, 6}, { 3, 3}, { 1, 4}, { 2, 0},
+ { 1, 1}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 11, 3}, { 1, 5}, /* Row 76 */
+ { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 6, 6}, { 1, 11}, { 5, 10},
+ { 7, 12}, { 6, 10}, { 1, 11}, { 5, 6}, { 1, 5}, { 3, 3}, { 1, 5}, { 1, 12},
+ { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 13, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 1, 5}, { 30, 3}, { 1, 6}, { 3, 3},
+ { 1, 4}, { 1, 0},
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 6}, { 1, 2}, { 12, 3}, { 1, 5}, { 1, 12}, /* Row 77 */
+ { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 12}, { 6, 6}, { 3, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12},
+ { 3, 10}, { 1, 12}, { 7, 6}, { 1, 3}, { 1, 11}, { 4, 10}, { 13, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 32, 3}, { 1, 6}, { 3, 3}, { 1, 4},
+ { 2, 3}, { 1, 6}, { 1, 2}, { 13, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, /* Row 78 */
+ { 3, 10}, { 1, 12}, { 7, 6}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11},
+ { 5, 6}, { 1, 5}, { 2, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 1, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 11, 12}, { 5, 10},
+ { 1, 11}, { 6, 6}, { 1, 5}, { 33, 3}, { 1, 6}, { 3, 3},
+ { 1, 3}, { 1, 5}, { 1, 18}, { 14, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, /* Row 79 */
+ { 3, 10}, { 1, 12}, { 7, 6}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 12}, { 6, 6}, { 2, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 2, 3}, { 1, 11}, { 4, 10}, { 11, 12}, { 4, 10}, { 1, 12},
+ { 7, 6}, { 35, 3}, { 1, 6}, { 2, 3},
+ { 2, 3}, { 1, 6}, { 14, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 80 */
+ { 1, 12}, { 7, 6}, { 1, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11},
+ { 5, 6}, { 1, 5}, { 1, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 2, 3}, { 1, 11}, { 5, 10}, { 10, 12}, { 4, 10}, { 1, 11},
+ { 6, 6}, { 1, 5}, { 35, 3}, { 1, 5}, { 1, 6}, { 1, 3},
+ { 3, 3}, { 1, 6}, { 13, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 81 */
+ { 1, 12}, { 7, 6}, { 1, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 12}, { 6, 6}, { 1, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 1, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 10, 12}, { 4, 10},
+ { 1, 12}, { 1, 21}, { 6, 6}, { 36, 3}, { 1, 7}, { 1, 2}, { 1, 5},
+ { 4, 3}, { 1, 6}, { 12, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 82 */
+ { 1, 12}, { 7, 6}, { 2, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11},
+ { 5, 6}, { 2, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 7, 6},
+ { 1, 3}, { 1, 11}, { 5, 10}, { 10, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 35, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 4, 3}, { 1, 6}, { 11, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, /* Row 83 */
+ { 3, 10}, { 1, 12}, { 7, 6}, { 2, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12},
+ { 5, 10}, { 1, 12}, { 6, 6}, { 1, 5}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 1, 13}, { 1, 12}, { 4, 10}, { 12, 12}, { 4, 10}, { 1, 12},
+ { 6, 6}, { 1, 5}, { 33, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4},
+ { 1, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 10, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 84 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 3, 3}, { 1, 11}, { 5, 10}, { 7, 12},
+ { 6, 10}, { 1, 11}, { 5, 6}, { 1, 13}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 1, 11}, { 5, 10}, { 12, 12}, { 5, 10}, { 1, 11}, { 6, 6},
+ { 32, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 1, 0},
+ { 2, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 9, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 85 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 3, 3}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 6, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 7, 6}, { 1, 12}, { 4, 10}, { 14, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 30, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 2, 0},
+ { 3, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 8, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 86 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 4, 3}, { 1, 11}, { 5, 10}, { 7, 12},
+ { 6, 10}, { 1, 11}, { 5, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12},
+ { 6, 6}, { 1, 11}, { 5, 10}, { 14, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 29, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 3, 0},
+ { 4, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 7, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 87 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 4, 3}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 5, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 6, 6}, { 1, 12}, { 4, 10}, { 16, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 27, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 4, 0},
+ { 5, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 6, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 88 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 5, 3}, { 1, 11}, { 5, 10}, { 7, 12},
+ { 6, 10}, { 1, 11}, { 4, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12},
+ { 5, 6}, { 1, 11}, { 5, 10}, { 16, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 26, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 5, 0},
+ { 6, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 5, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 89 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 5, 3}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 4, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 5, 6}, { 1, 12}, { 4, 10}, { 9, 12}, { 1, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 6, 6}, { 1, 5}, { 24, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 6, 0},
+ { 7, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 4, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 90 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 6, 3}, { 1, 11}, { 5, 10}, { 7, 12},
+ { 6, 10}, { 1, 11}, { 3, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12},
+ { 4, 6}, { 1, 11}, { 5, 10}, { 8, 12}, { 2, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 23, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 7, 0},
+ { 8, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 3, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 91 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 6, 3}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 3, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 4, 6}, { 1, 12}, { 4, 10}, { 9, 12}, { 3, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 6, 6}, { 1, 5}, { 21, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 8, 0},
+ { 9, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 2, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 92 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 7, 3}, { 1, 11}, { 5, 10}, { 7, 12},
+ { 6, 10}, { 1, 11}, { 2, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12},
+ { 3, 6}, { 1, 11}, { 5, 10}, { 8, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 20, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 9, 0},
+ { 10, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 1, 3}, { 1, 5}, { 1, 12}, { 3, 10}, /* Row 93 */
+ { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 7, 3}, { 1, 13}, { 1, 12}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 12}, { 2, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10},
+ { 1, 12}, { 3, 6}, { 1, 12}, { 4, 10}, { 9, 12}, { 5, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 6, 6}, { 1, 5}, { 18, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 10, 0},
+ { 11, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, /* Row 94 */
+ { 3, 10}, { 1, 12}, { 7, 6}, { 8, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10},
+ { 1, 11}, { 1, 6}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 2, 6},
+ { 1, 11}, { 5, 10}, { 8, 12}, { 6, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6},
+ { 17, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 11, 0},
+ { 12, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 95 */
+ { 1, 12}, { 7, 6}, { 8, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 12}, { 1, 21}, { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 2, 6},
+ { 1, 12}, { 4, 10}, { 9, 12}, { 7, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 15, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 12, 0},
+ { 13, 0}, { 1, 4}, { 3, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 96 */
+ { 1, 12}, { 7, 6}, { 9, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 6, 10}, { 1, 11},
+ { 1, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 1, 6}, { 1, 11}, { 5, 10},
+ { 8, 12}, { 8, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 14, 3}, { 1, 7},
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 13, 0},
+ { 14, 0}, { 1, 4}, { 2, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 97 */
+ { 1, 12}, { 7, 6}, { 9, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10},
+ { 1, 12}, { 4, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 1, 21}, { 1, 12}, { 4, 10},
+ { 9, 12}, { 4, 10}, { 1, 12}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 12, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 14, 0},
+ { 15, 0}, { 1, 4}, { 1, 3}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, /* Row 98 */
+ { 1, 12}, { 7, 6}, { 10, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 10, 10}, { 7, 12},
+ { 3, 10}, { 1, 12}, { 1, 11}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 1, 12},
+ { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 11, 3}, { 1, 7}, { 1, 2},
+ { 1, 5}, { 1, 3}, { 1, 4}, { 15, 0},
+ { 16, 0}, { 1, 4}, { 1, 5}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, /* Row 99 */
+ { 7, 6}, { 10, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 9, 10}, { 7, 12},
+ { 4, 10}, { 1, 12}, { 4, 10}, { 9, 12}, { 4, 10}, { 1, 12}, { 1, 6}, { 1, 11},
+ { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6}, { 1, 5}, { 9, 3}, { 1, 7},
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 16, 0},
+ { 17, 0}, { 1, 4}, { 1, 12}, { 3, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, /* Row 100 */
+ { 11, 3}, { 1, 11}, { 5, 10}, { 7, 12}, { 9, 10}, { 7, 12}, { 9, 10}, { 8, 12},
+ { 5, 10}, { 1, 11}, { 2, 6}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 8, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 17, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 11, 3}, { 1, 13}, /* Row 101 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 8, 10}, { 7, 12}, { 8, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 3, 6}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 6, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 18, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 12, 3}, { 1, 11}, /* Row 102 */
+ { 5, 10}, { 7, 12}, { 8, 10}, { 7, 12}, { 8, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 4, 6}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 5, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 19, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 12, 3}, { 1, 13}, /* Row 103 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 7, 10}, { 7, 12}, { 7, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 5, 6}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 6, 6},
+ { 1, 5}, { 3, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 20, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 13, 3}, { 1, 11}, /* Row 104 */
+ { 5, 10}, { 7, 12}, { 7, 10}, { 7, 12}, { 7, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 6, 6}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6}, { 2, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 13, 3}, { 1, 13}, /* Row 105 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 6, 10}, { 7, 12}, { 6, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 7, 6},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 14, 3}, { 1, 11}, /* Row 106 */
+ { 5, 10}, { 7, 12}, { 6, 10}, { 7, 12}, { 6, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11}, { 6, 6},
+ { 1, 18}, { 1, 5}, { 1, 3}, { 1, 4}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 14, 3}, { 1, 13}, /* Row 107 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 7, 12}, { 5, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 1, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 3}, { 1, 4}, { 24, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 15, 3}, { 1, 11}, /* Row 108 */
+ { 5, 10}, { 7, 12}, { 5, 10}, { 7, 12}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 2, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 5, 6}, { 1, 20}, { 1, 1}, { 25, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 15, 3}, { 1, 13}, /* Row 109 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 4, 10}, { 7, 12}, { 4, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 3, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 4, 6}, { 1, 20}, { 2, 2}, { 25, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 16, 3}, { 1, 11}, /* Row 110 */
+ { 5, 10}, { 7, 12}, { 4, 10}, { 7, 12}, { 4, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 4, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 2, 6}, { 1, 20}, { 3, 2}, { 1, 17}, { 24, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 16, 3}, { 1, 13}, /* Row 111 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 5, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 21}, { 1, 20}, { 5, 2}, { 24, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 17, 3}, { 1, 11}, /* Row 112 */
+ { 5, 10}, { 7, 12}, { 3, 10}, { 7, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 6, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 6, 2}, { 1, 17}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 17, 3}, { 1, 13}, /* Row 113 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 2, 10}, { 7, 12}, { 2, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 7, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 18}, { 6, 2}, { 23, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 18, 3}, { 1, 11}, /* Row 114 */
+ { 5, 10}, { 7, 12}, { 2, 10}, { 7, 12}, { 2, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 8, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 6, 2}, { 1, 17}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 18, 3}, { 1, 13}, /* Row 115 */
+ { 1, 12}, { 4, 10}, { 8, 12}, { 1, 10}, { 7, 12}, { 1, 10}, { 9, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 9, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 1, 18}, { 6, 2}, { 22, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 6}, { 19, 3}, { 1, 11}, /* Row 116 */
+ { 5, 10}, { 7, 12}, { 1, 10}, { 7, 12}, { 1, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 10, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 6, 2}, { 1, 17}, { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 1, 18}, { 6, 6}, { 19, 3}, /* Row 117 */
+ { 1, 13}, { 1, 12}, { 4, 10}, { 24, 12}, { 4, 10}, { 1, 12}, { 7, 6}, { 1, 5},
+ { 11, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2},
+ { 21, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 1, 2}, { 1, 20}, { 5, 6}, /* Row 118 */
+ { 20, 3}, { 1, 11}, { 5, 10}, { 22, 12}, { 5, 10}, { 1, 11}, { 7, 6}, { 12, 3},
+ { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17},
+ { 20, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 2, 2}, { 1, 20}, { 5, 6}, /* Row 119 */
+ { 19, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 22, 12}, { 4, 10}, { 1, 12}, { 7, 6},
+ { 1, 5}, { 13, 3}, { 1, 11}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18},
+ { 6, 2}, { 20, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 3, 2}, { 1, 20}, { 3, 6}, /* Row 120 */
+ { 1, 3}, { 1, 6}, { 19, 3}, { 1, 11}, { 5, 10}, { 20, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 14, 3}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12}, { 5, 10}, { 1, 14},
+ { 6, 2}, { 1, 17}, { 19, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 4, 2}, { 1, 20}, { 2, 6}, /* Row 121 */
+ { 2, 3}, { 1, 6}, { 18, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 20, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 14, 3}, { 1, 7}, { 1, 25}, { 4, 10}, { 8, 12},
+ { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2}, { 19, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 5, 2}, { 1, 20}, { 1, 6}, /* Row 122 */
+ { 3, 3}, { 1, 6}, { 18, 3}, { 1, 11}, { 5, 10}, { 18, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 14, 3}, { 1, 7}, { 1, 2}, { 1, 13}, { 1, 12}, { 3, 10}, { 8, 12},
+ { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 18, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 6, 2}, { 1, 20}, { 4, 3}, /* Row 123 */
+ { 1, 6}, { 17, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 18, 12}, { 4, 10}, { 1, 12},
+ { 7, 6}, { 1, 5}, { 13, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 20},
+ { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18}, { 6, 2}, { 18, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 1, 0}, { 4, 3}, /* Row 124 */
+ { 1, 6}, { 17, 3}, { 1, 11}, { 5, 10}, { 16, 12}, { 5, 10}, { 1, 11}, { 7, 6},
+ { 13, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 1, 17}, { 4, 10},
+ { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 17, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 1, 0}, { 1, 4}, /* Row 125 */
+ { 4, 3}, { 1, 6}, { 16, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 16, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 12, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 2, 0}, { 1, 9}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18},
+ { 6, 2}, { 17, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 2, 0}, { 1, 4}, /* Row 126 */
+ { 4, 3}, { 1, 6}, { 16, 3}, { 1, 11}, { 5, 10}, { 14, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 12, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 4, 0},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 16, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 3, 0}, { 1, 4}, /* Row 127 */
+ { 4, 3}, { 1, 6}, { 15, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 14, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 11, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 5, 0}, { 1, 9}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18},
+ { 6, 2}, { 16, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 4, 0}, { 1, 4}, /* Row 128 */
+ { 4, 3}, { 1, 6}, { 15, 3}, { 1, 11}, { 5, 10}, { 12, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 11, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 7, 0},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 17}, { 15, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 5, 0}, { 1, 4}, /* Row 129 */
+ { 4, 3}, { 1, 6}, { 14, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 12, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 10, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 8, 0}, { 1, 9}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 12}, { 1, 18},
+ { 6, 2}, { 15, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 6, 0}, { 1, 4}, /* Row 130 */
+ { 4, 3}, { 1, 6}, { 14, 3}, { 1, 11}, { 5, 10}, { 10, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 10, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 10, 0},
+ { 4, 10}, { 8, 12}, { 5, 10}, { 1, 14}, { 6, 2}, { 1, 26}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 7, 0}, { 1, 4}, /* Row 131 */
+ { 4, 3}, { 1, 6}, { 13, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 10, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 9, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 11, 0}, { 1, 9}, { 4, 10}, { 8, 12}, { 4, 10}, { 1, 14}, { 6, 2},
+ { 1, 17}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 8, 0}, { 1, 4}, /* Row 132 */
+ { 4, 3}, { 1, 6}, { 13, 3}, { 1, 11}, { 5, 10}, { 8, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 9, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 13, 0},
+ { 4, 10}, { 8, 12}, { 4, 10}, { 1, 14}, { 7, 2}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 9, 0}, { 1, 4}, /* Row 133 */
+ { 4, 3}, { 1, 6}, { 12, 3}, { 1, 13}, { 1, 12}, { 4, 10}, { 8, 12}, { 4, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 8, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 14, 0}, { 1, 9}, { 4, 10}, { 7, 12}, { 3, 10}, { 1, 12}, { 1, 19},
+ { 7, 2}, { 1, 26}, { 13, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 10, 0}, { 1, 4}, /* Row 134 */
+ { 4, 3}, { 1, 6}, { 12, 3}, { 1, 11}, { 5, 10}, { 6, 12}, { 5, 10}, { 1, 11},
+ { 7, 6}, { 8, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 16, 0},
+ { 4, 10}, { 6, 12}, { 4, 10}, { 1, 12}, { 8, 2}, { 1, 17}, { 13, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 11, 0}, { 1, 4}, /* Row 135 */
+ { 4, 3}, { 1, 6}, { 11, 3}, { 1, 13}, { 1, 12}, { 5, 10}, { 4, 12}, { 5, 10},
+ { 1, 12}, { 7, 6}, { 1, 5}, { 7, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3},
+ { 1, 4}, { 17, 0}, { 1, 9}, { 4, 10}, { 4, 12}, { 5, 10}, { 1, 14}, { 8, 2},
+ { 1, 17}, { 13, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 12, 0}, { 1, 4}, /* Row 136 */
+ { 4, 3}, { 1, 6}, { 11, 3}, { 1, 11}, { 14, 10}, { 1, 11}, { 7, 6}, { 7, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 19, 0}, { 12, 10}, { 1, 12},
+ { 1, 18}, { 8, 2}, { 1, 1}, { 13, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 13, 0}, { 1, 4}, /* Row 137 */
+ { 4, 3}, { 1, 6}, { 10, 3}, { 1, 13}, { 1, 12}, { 12, 10}, { 1, 12}, { 7, 6},
+ { 1, 5}, { 6, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 20, 0},
+ { 1, 9}, { 10, 10}, { 1, 12}, { 10, 2}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 8, 12}, { 3, 10}, { 1, 12}, { 7, 2}, { 14, 0}, { 1, 4}, /* Row 138 */
+ { 4, 3}, { 1, 6}, { 10, 3}, { 1, 11}, { 12, 10}, { 1, 11}, { 7, 6}, { 6, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 22, 0}, { 9, 10}, { 1, 12},
+ { 10, 2}, { 1, 17}, { 14, 0},
+ { 18, 0}, { 4, 10}, { 12, 12}, { 7, 2}, { 15, 0}, { 1, 4}, { 4, 3}, { 1, 6}, /* Row 139 */
+ { 9, 3}, { 1, 5}, { 1, 15}, { 10, 10}, { 1, 15}, { 7, 6}, { 1, 5}, { 5, 3},
+ { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 23, 0}, { 1, 17}, { 1, 14},
+ { 5, 10}, { 1, 12}, { 1, 10}, { 1, 19}, { 10, 2}, { 15, 0},
+ { 25, 0}, { 1, 20}, { 4, 18}, { 11, 2}, { 16, 0}, { 1, 4}, { 4, 3}, { 1, 6}, /* Row 140 */
+ { 9, 3}, { 1, 5}, { 1, 11}, { 1, 12}, { 6, 10}, { 1, 12}, { 1, 11}, { 8, 6},
+ { 5, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 27, 0}, { 2, 9},
+ { 1, 19}, { 1, 14}, { 1, 18}, { 11, 2}, { 1, 17}, { 15, 0},
+ { 25, 0}, { 16, 2}, { 17, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 10, 3}, { 1, 13}, /* Row 141 */
+ { 1, 11}, { 4, 12}, { 1, 11}, { 9, 6}, { 5, 3}, { 1, 7}, { 1, 2}, { 1, 5},
+ { 1, 3}, { 1, 4}, { 30, 0}, { 1, 1}, { 13, 2}, { 16, 0},
+ { 25, 0}, { 16, 2}, { 18, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 11, 3}, { 1, 5}, /* Row 142 */
+ { 1, 13}, { 11, 6}, { 5, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4},
+ { 32, 0}, { 1, 17}, { 11, 2}, { 17, 0},
+ { 25, 0}, { 16, 2}, { 19, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 13, 3}, { 1, 5}, /* Row 143 */
+ { 7, 6}, { 6, 3}, { 1, 7}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 34, 0},
+ { 10, 2}, { 18, 0},
+ { 25, 0}, { 16, 2}, { 20, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 25, 3}, { 1, 7}, /* Row 144 */
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 35, 0}, { 1, 1}, { 7, 2}, { 1, 17},
+ { 19, 0},
+ { 25, 0}, { 16, 2}, { 21, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 23, 3}, { 1, 7}, /* Row 145 */
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 64, 0},
+ { 25, 0}, { 16, 2}, { 22, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 21, 3}, { 1, 7}, /* Row 146 */
+ { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 65, 0},
+ { 64, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 19, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 147 */
+ { 1, 3}, { 1, 4}, { 66, 0},
+ { 65, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 17, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 148 */
+ { 1, 3}, { 1, 4}, { 67, 0},
+ { 66, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 15, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 149 */
+ { 1, 3}, { 1, 4}, { 68, 0},
+ { 67, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 13, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 150 */
+ { 1, 3}, { 1, 4}, { 69, 0},
+ { 68, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 11, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 151 */
+ { 1, 3}, { 1, 4}, { 70, 0},
+ { 69, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 9, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 152 */
+ { 1, 3}, { 1, 4}, { 71, 0},
+ { 70, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 7, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 153 */
+ { 1, 3}, { 1, 4}, { 72, 0},
+ { 71, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 5, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 154 */
+ { 1, 3}, { 1, 4}, { 73, 0},
+ { 72, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 3, 3}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 155 */
+ { 1, 3}, { 1, 4}, { 74, 0},
+ { 73, 0}, { 1, 4}, { 4, 3}, { 1, 6}, { 1, 5}, { 1, 7}, { 1, 2}, { 1, 5}, /* Row 156 */
+ { 1, 3}, { 1, 4}, { 75, 0},
+ { 74, 0}, { 1, 4}, { 5, 3}, { 1, 2}, { 1, 5}, { 1, 3}, { 1, 4}, { 76, 0}, /* Row 157 */
+ { 75, 0}, { 1, 4}, { 2, 3}, { 1, 5}, { 1, 20}, { 1, 5}, { 1, 3}, { 1, 4}, /* Row 158 */
+ { 77, 0},
+ { 76, 0}, { 1, 4}, { 4, 3}, { 1, 4}, { 78, 0} /* Row 159 */
+};
+
+# endif
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SRlePaletteBitmap NXWidgets::g_nuttxBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ 160, // width - Width in pixels
+ 160, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_nuttxLut, // Index 0: Unselected LUT
+ g_nuttxLut, // Index 1: Selected LUT
+ },
+ g_nuttxRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/libnxwidgets/src/glyph_radiobuttonmu.cxx b/NxWidgets/libnxwidgets/src/glyph_radiobuttonmu.cxx
new file mode 100644
index 000000000..a9e4d6708
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_radiobuttonmu.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_radiobuttonmu.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_radioButtonMuGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_radioButtonMuGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_radioButtonMu =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_radioButtonMuGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_radiobuttonoff.cxx b/NxWidgets/libnxwidgets/src/glyph_radiobuttonoff.cxx
new file mode 100644
index 000000000..029b93896
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_radiobuttonoff.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_radiobuttonoff.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_radioButtonOffGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_radioButtonOffGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_radioButtonOff =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_radioButtonOffGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_radiobuttonon.cxx b/NxWidgets/libnxwidgets/src/glyph_radiobuttonon.cxx
new file mode 100644
index 000000000..242f6f373
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_radiobuttonon.cxx
@@ -0,0 +1,156 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_radiobuttonon.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+# define RGB16_COLOR RGBTO16(216,196,96)
+
+static const uint16_t g_radioButtonOnGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_COLOR, RGB16_COLOR, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_COLOR, RGB16_COLOR, RGB16_COLOR, RGB16_COLOR, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_COLOR, RGB16_COLOR, RGB16_COLOR, RGB16_COLOR, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_COLOR, RGB16_COLOR, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+# define RGB24_COLOR RGBTO24(216,196,96)
+
+static const uint32_t g_radioButtonOnGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_COLOR, RGB24_COLOR, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_COLOR, RGB24_COLOR, RGB24_COLOR, RGB24_COLOR, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_COLOR, RGB24_COLOR, RGB24_COLOR, RGB24_COLOR, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_COLOR, RGB24_COLOR, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_radioButtonOn =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_radioButtonOnGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_return.cxx b/NxWidgets/libnxwidgets/src/glyph_return.cxx
new file mode 100644
index 000000000..47314f65c
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_return.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_return.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_returnGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_returnGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_return =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_returnGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_screendepthdown.cxx b/NxWidgets/libnxwidgets/src/glyph_screendepthdown.cxx
new file mode 100644
index 000000000..c3f0e15ee
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_screendepthdown.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_screendepthdown.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_screenDepthDownGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_screenDepthDownGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_screenDepthDown =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_screenDepthDownGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_screendepthup.cxx b/NxWidgets/libnxwidgets/src/glyph_screendepthup.cxx
new file mode 100644
index 000000000..e4574a367
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_screendepthup.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_screendepthup.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_screenDepthUpGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_screenDepthUpGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_screenDepthUp =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_screenDepthUpGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_screenflipdown.cxx b/NxWidgets/libnxwidgets/src/glyph_screenflipdown.cxx
new file mode 100644
index 000000000..253ad6afb
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_screenflipdown.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_screenflipdown.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_screenFlipDownGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_screenFlipDownGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_screenFlipDown =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_screenFlipDownGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_screenflipup.cxx b/NxWidgets/libnxwidgets/src/glyph_screenflipup.cxx
new file mode 100644
index 000000000..63b58a4a6
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_screenflipup.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_screenflipup.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_screenFlipUpGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_screenFlipUpGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_screenFlipUp =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 7, // width - Width in pixels
+ 10, // height - Height in rows
+ (7*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_screenFlipUpGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_shift.cxx b/NxWidgets/libnxwidgets/src/glyph_shift.cxx
new file mode 100644
index 000000000..193fd1719
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_shift.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_shift.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_shiftGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_shiftGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_shift =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_shiftGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_windowclose.cxx b/NxWidgets/libnxwidgets/src/glyph_windowclose.cxx
new file mode 100644
index 000000000..3a60aa137
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_windowclose.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_windowclose.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_windowCloseGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_windowCloseGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_windowClose =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 6, // width - Width in pixels
+ 10, // height - Height in rows
+ (6*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_windowCloseGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_windowdepthdown.cxx b/NxWidgets/libnxwidgets/src/glyph_windowdepthdown.cxx
new file mode 100644
index 000000000..d75b7d676
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_windowdepthdown.cxx
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_windowdepthdown.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_windowDepthDownGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_windowDepthDownGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_windowDepthDown =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_windowDepthDownGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
diff --git a/NxWidgets/libnxwidgets/src/glyph_windowdepthup.cxx b/NxWidgets/libnxwidgets/src/glyph_windowdepthup.cxx
new file mode 100644
index 000000000..f5d67e968
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/glyph_windowdepthup.cxx
@@ -0,0 +1,156 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/glyph_windowdepthup.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "nxconfig.hxx"
+#include "cbitmap.hxx"
+#include "glyphs.hxx"
+
+#if CONFIG_NXWIDGETS_BPP != 8 // No support for 8-bit color format
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Bitmap Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+#if CONFIG_NXWIDGETS_BPP == 16
+# define COLOR_FMT FB_FMT_RGB16_565
+# define RGB16_TRANSP 0x0000
+
+static const uint16_t g_windowDepthUpGlyph[] =
+{
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_TRANSP, RGB16_TRANSP,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_WHITE, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED, RGB16_DARKRED,
+ RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP, RGB16_TRANSP,
+};
+
+#elif CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# define COLOR_FMT FB_FMT_RGB24
+# define RGB24_TRANSP 0x00000000
+
+static const uint32_t g_windowDepthUpGlyph[] =
+{
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_TRANSP, RGB24_TRANSP,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_WHITE, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED, RGB24_DARKRED,
+ RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP, RGB24_TRANSP,
+};
+
+#else
+# warning "Other pixel depths not yet supported"
+#endif
+
+/****************************************************************************
+ * Public Bitmap Structure Defintions
+ ****************************************************************************/
+
+const struct SBitmap NXWidgets::g_windowDepthUp =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ COLOR_FMT, // fmt - Color format
+ 8, // width - Width in pixels
+ 10, // height - Height in rows
+ (8*CONFIG_NXWIDGETS_BPP + 7) / 8, // stride - Width in bytes
+ g_windowDepthUpGlyph // data - Pointer to the beginning of pixel data
+};
+
+#endif // CONFIG_NXWIDGETS_BPP != 8
+
+
diff --git a/NxWidgets/libnxwidgets/src/singletons.cxx b/NxWidgets/libnxwidgets/src/singletons.cxx
new file mode 100644
index 000000000..fc5d919e6
--- /dev/null
+++ b/NxWidgets/libnxwidgets/src/singletons.cxx
@@ -0,0 +1,202 @@
+/****************************************************************************
+ * NxWidgets/libnxwidgets/src/singletons.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************
+ *
+ * Portions of this package derive from Woopsi (http://woopsi.org/) and
+ * portions are original efforts. It is difficult to determine at this
+ * point what parts are original efforts and which parts derive from Woopsi.
+ * However, in any event, the work of Antony Dzeryn will be acknowledged
+ * in most NxWidget files. Thanks Antony!
+ *
+ * Copyright (c) 2007-2011, Antony Dzeryn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the names "Woopsi", "Simian Zombie" nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``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 Antony Dzeryn 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <sched.h>
+#include <debug.h>
+
+#include "nxconfig.hxx"
+#include "cnxserver.hxx"
+#include "cnxstring.hxx"
+#include "cwidgetstyle.hxx"
+#include "cnxfont.hxx"
+#include "singletons.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Static Data
+ ****************************************************************************/
+
+using namespace NXWidgets;
+
+CWidgetStyle *NXWidgets::g_defaultWidgetStyle; /**< The default widget style */
+CNxString *NXWidgets::g_nullString; /**< The reusable empty string */
+TNxArray<CNxTimer*> *NXWidgets::g_nxTimers; /**< An array of all timers */
+
+/****************************************************************************
+ * Method Implementations
+ ****************************************************************************/
+
+/**
+ * Setup misc singleton instances. Why is there here? Because it needs to be
+ * done one time before any widgets are created. So why isn't it just the
+ * default style just a statically constructed class? Because not all platforms
+ * will support static class constructions.
+ */
+
+void NXWidgets::instantiateSingletons(void)
+{
+ // Disable pre-emption. Since we are dealing with global resources here we
+ // are not inherently thread-safe.
+
+ sched_lock();
+
+ // Create a global, empty string that may be used whereever a string is
+ // required, but not needed.
+
+ if (!g_nullString)
+ {
+ g_nullString = new CNxString();
+ }
+
+ // Setup the default widget style
+
+ if (!g_defaultWidgetStyle)
+ {
+ // Create the singleton
+
+ g_defaultWidgetStyle = new CWidgetStyle();
+
+ // Default colors
+
+ g_defaultWidgetStyle->colors.background = CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR;
+ g_defaultWidgetStyle->colors.selectedBackground = CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR;
+ g_defaultWidgetStyle->colors.shineEdge = CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR;
+ g_defaultWidgetStyle->colors.shadowEdge = CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR;
+ g_defaultWidgetStyle->colors.highlight = CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR;
+
+ g_defaultWidgetStyle->colors.disabledText = CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR;
+ g_defaultWidgetStyle->colors.enabledText = CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR;
+ g_defaultWidgetStyle->colors.selectedText = CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR;
+
+ // Default font using the default font ID and the default font colors
+
+ g_defaultWidgetStyle->font = new CNxFont((enum nx_fontid_e)CONFIG_NXWIDGETS_DEFAULT_FONTID,
+ CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR,
+ CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
+ }
+
+ // Create the timer list
+
+ if (!g_nxTimers)
+ {
+ g_nxTimers = new TNxArray<CNxTimer*>();
+ }
+
+ sched_unlock();
+}
+
+/**
+ * Free the singleton instances when the last NX server is destroyed.
+ */
+
+void NXWidgets::freeSingletons(void)
+{
+ // Delete the null string singleton
+
+ if (g_nullString)
+ {
+ delete g_nullString;
+ g_nullString = (CNxString *)NULL;
+ }
+
+ // Delete the default widget style singleton
+
+ if (g_defaultWidgetStyle)
+ {
+ if (g_defaultWidgetStyle->font)
+ {
+ delete g_defaultWidgetStyle->font;
+ }
+
+ delete g_defaultWidgetStyle;
+ g_defaultWidgetStyle = (CWidgetStyle *)NULL;
+ }
+
+ // Free the timer list
+
+ if (g_nxTimers)
+ {
+ delete g_nxTimers;
+ g_nxTimers = (TNxArray<CNxTimer*> *)NULL;
+ }
+
+}
+
diff --git a/NxWidgets/nxwm/COPYING b/NxWidgets/nxwm/COPYING
new file mode 100644
index 000000000..4273aec03
--- /dev/null
+++ b/NxWidgets/nxwm/COPYING
@@ -0,0 +1,41 @@
+COPYING -- Describes the terms under which NxWM is distributed. A
+copy of the BSD-style licensing is included in this file. In my
+words -- I believe that you should free to use NxWM in any
+environment, private, private, commercial, open, closed, etc.
+provided only that you repect the modest copyright notices as
+described in license (below). Please feel free to contact me if you
+have any licensing concerns.
+
+/*************************************************************************
+ *
+ * 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, NxWM nor the names of its
+ * contributors may 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.
+ *
+ *************************************************************************/
diff --git a/NxWidgets/nxwm/Makefile b/NxWidgets/nxwm/Makefile
new file mode 100644
index 000000000..e50863494
--- /dev/null
+++ b/NxWidgets/nxwm/Makefile
@@ -0,0 +1,143 @@
+#################################################################################
+# NxWidgets/nxwm/Makefile
+#
+# 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.
+#
+#################################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+
+NXWMDIR := ${shell pwd | sed -e 's/ /\\ /g'}
+NXWIDGETDIR := $(NXWMDIR)/../libnxwidgets
+
+ASRCS =
+CSRCS =
+
+# Window Manager
+CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
+
+# Device support
+
+ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
+CXXSRCS += ctouchscreen.cxx
+endif
+
+ifeq ($(CONFIG_NXWM_KEYBOARD),y)
+CXXSRCS += ckeyboard.cxx
+endif
+
+# Applications
+
+CXXSRCS += cstartwindow.cxx cnxconsole.cxx chexcalculator.cxx
+
+ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
+CXXSRCS += ccalibration.cxx
+endif
+
+# Images
+CXXSRCS += glyph_calculator.cxx glyph_calibration.cxx glyph_cmd.cxx
+CXXSRCS += glyph_minimize.cxx glyph_nsh.cxx glyph_play.cxx glyph_start.cxx
+CXXSRCS += glyph_stop.cxx
+
+SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
+OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
+
+BIN = libnxwm$(LIBEXT)
+
+ifeq ($(WINTOOL),y)
+INCDIROPT = -w
+endif
+
+CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWMDIR)/include}
+CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWIDGETDIR)/include}
+CXXFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWMDIR)/include}
+CXXFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(NXWIDGETDIR)/include}
+
+DEPPATH = --dep-path src
+VPATH = src
+
+all: $(BIN)
+.PHONY = check_nuttx depend clean distclean export
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(CXXOBJS): %$(OBJEXT): %.cxx
+ $(call COMPILEXX, $<, $@)
+
+check_nuttx:
+ @( \
+ if [ -z "$(TOPDIR)" ]; then \
+ echo "The path to the nuttx directory must be provided on the command line."; \
+ echo "Usage: make -C $(NXWMDIR) TOPDIR=\"<nuttx directory>\""; \
+ exit 1; \
+ fi; \
+ if [ ! -d "$(TOPDIR)" ]; then \
+ echo "The nuttx directory (TOPDIR) does not exist: $(TOPDIR)"; \
+ exit 1; \
+ fi; \
+ if [ ! -f "$(TOPDIR)/.config" ]; then \
+ echo "The nuttx directory (TOPDIR) has not been configured"; \
+ echo "Please configure NuttX and try again"; \
+ exit 1; \
+ fi; \
+ )
+
+$(BIN): check_nuttx $(OBJS)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $@, $${obj}); \
+ done ; )
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f $(BIN) *.a *.o *~ .*.sw*
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+export: $(BIN)
+ zip -r nxwm-export.zip include $(BIN) COPYING
+
+-include Make.dep
diff --git a/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt b/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt
new file mode 100644
index 000000000..1b7b43622
--- /dev/null
+++ b/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt
Binary files differ
diff --git a/NxWidgets/nxwm/images/calculator.png b/NxWidgets/nxwm/images/calculator.png
new file mode 100644
index 000000000..fe3ad3e86
--- /dev/null
+++ b/NxWidgets/nxwm/images/calculator.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/calibration.png b/NxWidgets/nxwm/images/calibration.png
new file mode 100644
index 000000000..76a84127f
--- /dev/null
+++ b/NxWidgets/nxwm/images/calibration.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/cmd.png b/NxWidgets/nxwm/images/cmd.png
new file mode 100644
index 000000000..3e6cf667c
--- /dev/null
+++ b/NxWidgets/nxwm/images/cmd.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/minimize.png b/NxWidgets/nxwm/images/minimize.png
new file mode 100644
index 000000000..7080533dd
--- /dev/null
+++ b/NxWidgets/nxwm/images/minimize.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/nxlogo.png b/NxWidgets/nxwm/images/nxlogo.png
new file mode 100644
index 000000000..63ece46e5
--- /dev/null
+++ b/NxWidgets/nxwm/images/nxlogo.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/play.png b/NxWidgets/nxwm/images/play.png
new file mode 100644
index 000000000..02ff75414
--- /dev/null
+++ b/NxWidgets/nxwm/images/play.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/start.png b/NxWidgets/nxwm/images/start.png
new file mode 100644
index 000000000..8cad18756
--- /dev/null
+++ b/NxWidgets/nxwm/images/start.png
Binary files differ
diff --git a/NxWidgets/nxwm/images/stop.png b/NxWidgets/nxwm/images/stop.png
new file mode 100644
index 000000000..365068b4a
--- /dev/null
+++ b/NxWidgets/nxwm/images/stop.png
Binary files differ
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx
new file mode 100644
index 000000000..46e4e90d2
--- /dev/null
+++ b/NxWidgets/nxwm/include/capplicationwindow.hxx
@@ -0,0 +1,233 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/capplicationwindow.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_CAPPLICATIONWINDOW_NXX
+#define __INCLUDE_CAPPLICATIONWINDOW_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "cnxtkwindow.hxx"
+#include "cnxtoolbar.hxx"
+#include "cwidgetcontrol.hxx"
+#include "cwidgeteventargs.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cimage.hxx"
+#include "clabel.hxx"
+#include "crlepalettebitmap.hxx"
+
+#include "iapplicationwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * This class represents that application window. This class contains that the
+ * framed window and its toolbar. It manages callbacks from the toolbar minimize
+ * and close buttions and passes these to the application via callbacks.
+ */
+
+ class CApplicationWindow : public IApplicationWindow,
+ private NXWidgets::CWidgetEventHandler
+ {
+ public:
+ /**
+ * Enumeration describing the bit settings for each window flag
+ */
+
+ enum EWindowFlags
+ {
+ WINDOW_PERSISTENT = 0x01 /**< Persistent windows have no stop button */
+ };
+
+ protected:
+ NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
+ NXWidgets::CNxToolbar *m_toolbar; /**< The toolbar */
+ NXWidgets::CImage *m_minimizeImage; /**< The minimize icon */
+ NXWidgets::CImage *m_stopImage; /**< The close icon */
+ NXWidgets::CLabel *m_windowLabel; /**< The window title */
+ NXWidgets::CRlePaletteBitmap *m_minimizeBitmap; /**< The minimize icon bitmap */
+ NXWidgets::CRlePaletteBitmap *m_stopBitmap; /**< The stop icon bitmap */
+ NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
+ IApplicationCallback *m_callback; /**< Toolbar action callbacks */
+ uint8_t m_flags; /**< Window flags */
+
+ /**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+ void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
+
+ public:
+
+ /**
+ * CApplicationWindow Constructor
+ *
+ * @param window. The window to be used by this application.
+ * @param flags. Optional flags to control the window configuration (See EWindowFlags).
+ */
+
+ CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags = 0);
+
+ /**
+ * CApplicationWindow Destructor
+ */
+
+ ~CApplicationWindow(void);
+
+ /**
+ * Initialize window. Window initialization is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+ bool open(void);
+
+ /**
+ * Re-draw the application window
+ */
+
+ void redraw(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+ void hide(void);
+
+ /**
+ * Recover the contained NXTK window instance
+ *
+ * @return. The window used by this application
+ */
+
+ NXWidgets::INxWindow *getWindow(void) const;
+
+ /**
+ * Recover the contained widget control
+ *
+ * @return. The widget control used by this application
+ */
+
+ NXWidgets::CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ *
+ * @param app. The application to be blocked
+ */
+
+ void block(IApplication *app);
+
+ /**
+ * Set the window label
+ *
+ * @param appname. The name of the application to place on the window
+ */
+
+ void setWindowLabel(NXWidgets::CNxString &appname);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+
+ /**
+ * Register to receive callbacks when toolbar icons are selected
+ */
+
+ void registerCallbacks(IApplicationCallback *callback);
+
+ /**
+ * Check if this window is configured for a persistent application (i.e.,
+ * an application that has no STOP icon
+ *
+ * @return True if the window is configured for a persistent application.
+ */
+
+ inline bool isPersistent(void) const
+ {
+ return (m_flags & WINDOW_PERSISTENT) != 0;
+ }
+
+ /**
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickMinimizePosition(bool click);
+#endif
+
+ /**
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickStopIcon(bool click);
+#endif
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CAPPLICATIONWINDOW_NXX
diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx
new file mode 100644
index 000000000..a54a35bf7
--- /dev/null
+++ b/NxWidgets/nxwm/include/ccalibration.hxx
@@ -0,0 +1,370 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/ccalibration.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_CCALIBRATION_HXX
+#define __INCLUDE_CCALIBRATION_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/nx/nxglib.h>
+
+#include <pthread.h>
+#include <fixedmath.h>
+
+#include "cnxstring.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgetcontrol.hxx"
+
+#include "ctaskbar.hxx"
+#include "iapplication.hxx"
+#include "cfullscreenwindow.hxx"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+/**
+ * Calibration indices
+ */
+
+#define CALIB_UPPER_LEFT_INDEX 0
+#define CALIB_UPPER_RIGHT_INDEX 1
+#define CALIB_LOWER_RIGHT_INDEX 2
+#define CALIB_LOWER_LEFT_INDEX 3
+
+#define CALIB_DATA_POINTS 4
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+namespace NxWM
+{
+ /**
+ * Forward references
+ */
+
+ struct CTouchscreen;
+
+ /**
+ * Touchscreen calibration data
+ */
+
+ struct SCalibrationData
+ {
+ b16_t xSlope; // X conversion: xSlope*(x) + xOffset
+ b16_t xOffset;
+ b16_t ySlope; // Y conversion: ySlope*(y) + yOffset
+ b16_t yOffset;
+ };
+
+ /**
+ * The CCalibration class provides the the calibration window and obtains
+ * callibration data.
+ */
+
+ class CCalibration : public IApplication
+ {
+ private:
+ /**
+ * The state of the calibration thread.
+ */
+
+ enum ECalThreadState
+ {
+ CALTHREAD_NOTRUNNING = 0, /**< The calibration thread has not yet been started */
+ CALTHREAD_STARTED, /**< The calibration thread has been started, but is not yet running */
+ CALTHREAD_RUNNING, /**< The calibration thread is running normally */
+ CALTHREAD_STOPREQUESTED, /**< The calibration thread has been requested to stop */
+ CALTHREAD_HIDE, /**< The hide() called by calibration thread running */
+ CALTHREAD_SHOW, /**< The redraw() called by calibration thread running */
+ CALTHREAD_TERMINATED /**< The calibration thread terminated normally */
+ };
+
+ /**
+ * Identifies the current display state
+ */
+
+ enum ECalibrationPhase
+ {
+ CALPHASE_NOT_STARTED = 0, /**< Constructed, but not yet started */
+ CALPHASE_UPPER_LEFT, /**< Touch point is in the upper left corner */
+ CALPHASE_UPPER_RIGHT, /**< Touch point is in the upper right corner */
+ CALPHASE_LOWER_RIGHT, /**< Touch point is in the lower left corner */
+ CALPHASE_LOWER_LEFT, /**< Touch point is in the lower right corner */
+ CALPHASE_COMPLETE /**< Calibration is complete */
+ };
+
+ /**
+ * Characterizes one calibration screen
+ */
+
+ struct SCalibScreenInfo
+ {
+ struct nxgl_point_s pos; /**< The position of the touch point */
+ nxgl_mxpixel_t lineColor; /**< The color of the cross-hair lines */
+ nxgl_mxpixel_t circleFillColor; /**< The color of the circle */
+ };
+
+ /**
+ * CCalibration state data
+ */
+
+ CTaskbar *m_taskbar; /**< The taskbar (used to terminate calibration) */
+ CFullScreenWindow *m_window; /**< The window for the calibration display */
+ CTouchscreen *m_touchscreen; /**< The touchscreen device */
+ pthread_t m_thread; /**< The calibration thread ID */
+ struct SCalibScreenInfo m_screenInfo; /**< Describes the current calibration display */
+ struct nxgl_point_s m_touchPos; /**< This is the last touch position */
+ volatile uint8_t m_calthread; /**< Current calibration display state (See ECalibThreadState)*/
+ uint8_t m_calphase; /**< Current calibration display state (See ECalibrationPhase)*/
+ bool m_stop; /**< True: We have been asked to stop the calibration */
+ bool m_touched; /**< True: The screen is touched */
+ uint8_t m_touchId; /**< The ID of the touch */
+ struct nxgl_point_s m_calibData[CALIB_DATA_POINTS];
+
+ /**
+ * Accept raw touchscreen input.
+ *
+ * @param sample Touchscreen input sample
+ */
+
+ void touchscreenInput(struct touch_sample_s &sample);
+
+ /**
+ * Start the calibration thread.
+ *
+ * @param initialState. The initial state of the calibration thread
+ * @return True if the thread was successfully started.
+ */
+
+ bool startCalibration(enum ECalThreadState initialState);
+
+ /**
+ * Return true if the calibration thread is running normally. There are
+ * lots of potential race conditions. Let's hope that things are running
+ * orderly and we that we do not have to concern ourself with them
+ *
+ * @return True if the calibration thread is runnning normally.
+ */
+
+ inline bool isRunning(void) const
+ {
+ // What if the boundary states CALTHREAD_STARTED and CALTHREAD_STOPREQUESTED?
+
+ return (m_calthread == CALTHREAD_RUNNING ||
+ m_calthread == CALTHREAD_HIDE ||
+ m_calthread == CALTHREAD_SHOW);
+ }
+
+ /**
+ * The calibration thread. This is the entry point of a thread that provides the
+ * calibration displays, waits for input, and collects calibration data.
+ *
+ * @param arg. The CCalibration 'this' pointer cast to a void*.
+ * @return This function always returns NULL when the thread exits
+ */
+
+ static FAR void *calibration(FAR void *arg);
+
+ /**
+ * This is the calibration state machine. It is called initially and then
+ * as new touchscreen data is received.
+ */
+
+ void stateMachine(void);
+
+ /**
+ * Presents the next calibration screen
+ */
+
+ void showCalibration(void);
+
+ /**
+ * Finish calibration steps and provide the calibration data to the
+ * touchscreen driver.
+ */
+
+ void finishCalibration(void);
+
+ /**
+ * Given the raw touch data collected by the calibration thread, create the
+ * massaged calibration data needed by CTouchscreen.
+ *
+ * @param data. A reference to the location to save the calibration data
+ * @return True if the calibration data was successfully created.
+ */
+
+ bool createCalibrationData(struct SCalibrationData &data);
+
+ public:
+
+ /**
+ * CCalibration Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ * @param window. The window to use for the calibration display
+ * @param touchscreen. An instance of the class that wraps the
+ * touchscreen device.
+ */
+
+ CCalibration(CTaskbar *taskbar, CFullScreenWindow *window,
+ CTouchscreen *touchscreen);
+
+ /**
+ * CCalibration Destructor
+ */
+
+ ~CCalibration(void);
+
+ /**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained IApplicationWindow instance.
+ */
+
+ IApplicationWindow *getWindow(void) const;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+
+ /**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+ NXWidgets::CNxString getName(void);
+
+ /**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+ bool run(void);
+
+ /**
+ * Stop the application.
+ */
+
+ void stop(void);
+
+ /**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+ void hide(void);
+
+ /**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is called from
+ * CTaskbar when the application window must be displayed
+ */
+
+ void redraw(void);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+ };
+
+ class CCalibrationFactory : public IApplicationFactory
+ {
+ private:
+ CTaskbar *m_taskbar; /**< The taskbar */
+ CTouchscreen *m_touchscreen; /**< The touchscreen device */
+
+ public:
+ /**
+ * CCalibrationFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ * @param touchscreen. An instance of the class that wraps the
+ * touchscreen device.
+ */
+
+ CCalibrationFactory(CTaskbar *taskbar, CTouchscreen *touchscreen);
+
+ /**
+ * CCalibrationFactory Destructor
+ */
+
+ inline ~CCalibrationFactory(void) { }
+
+ /**
+ * Create a new instance of an CCalibration (as IApplication).
+ */
+
+ IApplication *create(void);
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+ };
+}
+
+#endif // __INCLUDE_CCALIBRATION_HXX
diff --git a/NxWidgets/nxwm/include/cfullscreenwindow.hxx b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
new file mode 100644
index 000000000..70da9fee5
--- /dev/null
+++ b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
@@ -0,0 +1,185 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/cfullscreenwindow.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_CFULLSCREENWINDOW_NXX
+#define __INCLUDE_CFULLSCREENWINDOW_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "cnxwindow.hxx"
+#include "cwidgetcontrol.hxx"
+
+#include "iapplicationwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * This class represents a generic window. This bland window is used,
+ * for example, to support full screen displays.
+ */
+
+ class CFullScreenWindow : public IApplicationWindow
+ {
+ protected:
+ NXWidgets::CNxWindow *m_window; /**< The generic window used by the application */
+
+ public:
+
+ /**
+ * CFullScreenWindow Constructor
+ *
+ * @param window. The raw window to be used by this full screen application.
+ */
+
+ CFullScreenWindow(NXWidgets::CNxWindow *window);
+
+ /**
+ * CFullScreenWindow Destructor
+ */
+
+ ~CFullScreenWindow(void);
+
+ /**
+ * Initialize window. Window initialization is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+ bool open(void);
+
+ /**
+ * Re-draw the application window
+ */
+
+ void redraw(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+ void hide(void);
+
+ /**
+ * Recover the contained NXTK window instance
+ *
+ * @return. The window used by this application
+ */
+
+ NXWidgets::INxWindow *getWindow(void) const;
+
+ /**
+ * Recover the contained widget control
+ *
+ * @return. The widget control used by this application
+ */
+
+ NXWidgets::CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ *
+ * @param app. The application to be blocked
+ */
+
+ void block(IApplication *app);
+
+ /**
+ * Set the window label
+ *
+ * @param appname. The name of the application to place on the window
+ */
+
+ void setWindowLabel(NXWidgets::CNxString &appname);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+
+ /**
+ * Register to receive callbacks when toolbar icons are selected
+ */
+
+ void registerCallbacks(IApplicationCallback *callback);
+
+ /**
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickMinimizePosition(bool click);
+#endif
+
+ /**
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickStopIcon(bool click);
+#endif
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CFULLSCREENWINDOW_NXX
diff --git a/NxWidgets/nxwm/include/chexcalculator.hxx b/NxWidgets/nxwm/include/chexcalculator.hxx
new file mode 100644
index 000000000..69ee37624
--- /dev/null
+++ b/NxWidgets/nxwm/include/chexcalculator.hxx
@@ -0,0 +1,330 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/chexcalculator.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_CHEXCALCULATOR_HXX
+#define __INCLUDE_CHEXCALCULATOR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <nuttx/nx/nxtk.h>
+#include <nuttx/nx/nxconsole.h>
+
+#include "cbuttonarray.hxx"
+#include "clabel.hxx"
+#include "cnxfont.hxx"
+
+#include "iapplication.hxx"
+#include "capplicationwindow.hxx"
+#include "ctaskbar.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+#define NXWM_HEXCALCULATOR_NROWS 6
+#define NXWM_HEXCALCULATOR_NCOLUMNS 6
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * This class implements the NxConsole application.
+ */
+
+ class CHexCalculator : public IApplication,
+ private IApplicationCallback,
+ private NXWidgets::CWidgetEventHandler
+ {
+ private:
+ /**
+ * The structure defines a pending operation.
+ */
+
+ struct SPendingOperation
+ {
+ int64_t value; /**< Accumulated value */
+ uint8_t operation; /**< Identifies the operations */
+ };
+
+ /**
+ * Calculator state data.
+ */
+
+ /**
+ * Cached constructor parameters.
+ */
+
+ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
+ CApplicationWindow *m_window; /**< Reference to the application window */
+
+ /**
+ * Widgets
+ */
+
+ NXWidgets::CButtonArray *m_keypad; /**< The calculator keyboard */
+ NXWidgets::CLabel *m_text; /**< The accumulator text display */
+ NXWidgets::CNxFont *m_font; /**< The font used in the calculator */
+
+ /**
+ * Calculator geometry. This stuff does not really have to be retained
+ * in memory. If you are pinched for memory, get rid of these.
+ */
+
+ struct nxgl_size_s m_windowSize; /**< The size of the calculator window */
+ struct nxgl_size_s m_keypadSize; /**< The size the calculator keypad */
+ struct nxgl_size_s m_buttonSize; /**< The size of one calculator button */
+ struct nxgl_size_s m_textSize; /**< The size of the calculator textbox */
+ struct nxgl_point_s m_keypadPos; /**< The position the calculator keypad */
+ struct nxgl_point_s m_textPos; /**< The position of the calculator textbox */
+
+ /**
+ * Calculator computational data. Note: Since we do not support
+ * parentheses and support only two levels of operator precedence, it is
+ * not necessary to maintain a stack of operations. Within there
+ * limitations, there can be at most only one pending low prececence
+ * operation and one pending high precedence operation. If you want
+ * to support parentheses or more levels of precedence, they you will
+ * have to extend the design.
+ */
+
+ int64_t m_accum; /**< The current accumulated value */
+ int64_t m_memory; /**< The current value saved in memory */
+ struct SPendingOperation m_low; /**< Low precedence pending operation */
+ struct SPendingOperation m_high; /**< Hight precedence pending operation */
+ bool m_hexMode; /**< True if in hex mode */
+ bool m_result ; /**< True if the accumulator holds a previoius result */
+
+ /**
+ * Select the geometry of the calculator given the current window size.
+ * Only called as part of construction.
+ */
+
+ inline void setGeometry(void);
+
+ /**
+ * Create the calculator keypad. Only start as part of the applicaiton
+ * start method.
+ */
+
+ inline bool createCalculator(void);
+
+ /**
+ * Applies labels to the keys.
+ */
+
+ void labelKeypad(void);
+
+ /**
+ * Evaluate a binary operation.
+ *
+ * @param value1. The first value
+ * @param value2. The second value
+ *
+ * @return The result of the operation
+ */
+
+ int64_t evaluateBinaryOperation(uint8_t operation, int64_t value1, int64_t value2);
+
+ /**
+ * Show the current value of the accumulator.
+ */
+
+ void updateText(void);
+
+ /**
+ * Called when the window minimize button is pressed.
+ */
+
+ void minimize(void);
+
+ /**
+ * Called when the window minimize close is pressed.
+ */
+
+ void close(void);
+
+ /**
+ * Handle a widget action event. For CImage, this is a button pre-
+ * release event.
+ *
+ * @param e The event data.
+ */
+
+ void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
+
+ public:
+ /**
+ * CHexCalculator constructor
+ *
+ * @param window. The application window
+ *
+ * @param taskbar. A pointer to the parent task bar instance
+ * @param window. The window to be used by this application.
+ */
+
+ CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window);
+
+ /**
+ * CHexCalculator destructor
+ */
+
+ ~CHexCalculator(void);
+
+ /**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+ IApplicationWindow *getWindow(void) const;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+
+ /**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+ NXWidgets::CNxString getName(void);
+
+ /**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+ bool run(void);
+
+ /**
+ * Stop the application.
+ */
+
+ void stop(void);
+
+ /**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+ void hide(void);
+
+ /**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+ void redraw(void);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+ };
+
+ class CHexCalculatorFactory : public IApplicationFactory
+ {
+ private:
+ CTaskbar *m_taskbar; /**< The taskbar */
+
+ public:
+ /**
+ * CHexCalculatorFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ */
+
+ CHexCalculatorFactory(CTaskbar *taskbar);
+
+ /**
+ * CHexCalculatorFactory Destructor
+ */
+
+ inline ~CHexCalculatorFactory(void) { }
+
+ /**
+ * Create a new instance of an CHexCalculator (as IApplication).
+ */
+
+ IApplication *create(void);
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+ };
+}
+#endif // __cplusplus
+
+#endif // __INCLUDE_CHEXCALCULATOR_HXX
diff --git a/NxWidgets/nxwm/include/ckeyboard.hxx b/NxWidgets/nxwm/include/ckeyboard.hxx
new file mode 100644
index 000000000..8f16bd506
--- /dev/null
+++ b/NxWidgets/nxwm/include/ckeyboard.hxx
@@ -0,0 +1,133 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/keyboard.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_CKEYBOARD_HXX
+#define __INCLUDE_CKEYBOARD_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/nx/nxglib.h>
+
+#include <semaphore.h>
+#include <pthread.h>
+
+#include <nuttx/input/touchscreen.h>
+
+#include "cnxserver.hxx"
+#include "ccalibration.hxx"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+namespace NxWM
+{
+ /**
+ * The CKeyboard class provides the the calibration window and obtains
+ * callibration data.
+ */
+
+ class CKeyboard
+ {
+ private:
+ /**
+ * The state of the listener thread.
+ */
+
+ enum EListenerState
+ {
+ LISTENER_NOTRUNNING = 0, /**< The listener thread has not yet been started */
+ LISTENER_STARTED, /**< The listener thread has been started, but is not yet running */
+ LISTENER_RUNNING, /**< The listener thread is running normally */
+ LISTENER_STOPREQUESTED, /**< The listener thread has been requested to stop */
+ LISTENER_TERMINATED, /**< The listener thread terminated normally */
+ LISTENER_FAILED /**< The listener thread terminated abnormally */
+ };
+
+ /**
+ * CKeyboard state data
+ */
+
+ NXWidgets::CNxServer *m_server; /**< The current NX server */
+ int m_kbdFd; /**< File descriptor of the opened keyboard device */
+ pthread_t m_thread; /**< The listener thread ID */
+ volatile enum EListenerState m_state; /**< The state of the listener thread */
+ sem_t m_waitSem; /**< Used to synchronize with the listener thread */
+
+ /**
+ * The keyboard listener thread. This is the entry point of a thread that
+ * listeners for and dispatches keyboard events to the NX server.
+ *
+ * @param arg. The CKeyboard 'this' pointer cast to a void*.
+ * @return This function normally does not return but may return NULL on
+ * error conditions.
+ */
+
+ static FAR void *listener(FAR void *arg);
+
+ public:
+
+ /**
+ * CKeyboard Constructor
+ *
+ * @param server. An instance of the NX server. This will be needed for
+ * injecting mouse data.
+ */
+
+ CKeyboard(NXWidgets::CNxServer *server);
+
+ /**
+ * CKeyboard Destructor
+ */
+
+ ~CKeyboard(void);
+
+ /**
+ * Start the keyboard listener thread.
+ *
+ * @return True if the keyboard listener thread was correctly started.
+ */
+
+ bool start(void);
+ };
+}
+
+#endif // __INCLUDE_CKEYBOARD_HXX
diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx
new file mode 100644
index 000000000..f33f1182d
--- /dev/null
+++ b/NxWidgets/nxwm/include/cnxconsole.hxx
@@ -0,0 +1,245 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/cnxconsole.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_CNXCONSOLE_HXX
+#define __INCLUDE_CNXCONSOLE_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <nuttx/nx/nxtk.h>
+#include <nuttx/nx/nxconsole.h>
+
+#include "iapplication.hxx"
+#include "capplicationwindow.hxx"
+#include "ctaskbar.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * One time NSH initialization. This function must be called exactly
+ * once during the boot-up sequence to initialize the NSH library.
+ *
+ * @return True on successful initialization
+ */
+
+ bool nshlibInitialize(void);
+
+ /**
+ * This class implements the NxConsole application.
+ */
+
+ class CNxConsole : public IApplication, private IApplicationCallback
+ {
+ private:
+ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
+ CApplicationWindow *m_window; /**< Reference to the application window */
+ NXCONSOLE m_nxcon; /**< NxConsole handle */
+ pid_t m_pid; /**< Task ID of the NxConsole thread */
+
+ /**
+ * This is the NxConsole task. This function first redirects output to the
+ * console window then calls to start the NSH logic.
+ */
+
+ static int nxconsole(int argc, char *argv[]);
+
+ /**
+ * This is the NxConsole task exit handler. It is registered with on_exit()
+ * and called automatically when the nxconsole task exits.
+ */
+
+ static void exitHandler(int code, FAR void *arg);
+
+ /**
+ * Called when the window minimize button is pressed.
+ */
+
+ void minimize(void);
+
+ /**
+ * Called when the window close button is pressed.
+ */
+
+ void close(void);
+
+ public:
+ /**
+ * CNxConsole constructor
+ *
+ * @param window. The application window
+ *
+ * @param taskbar. A pointer to the parent task bar instance
+ * @param window. The window to be used by this application.
+ */
+
+ CNxConsole(CTaskbar *taskbar, CApplicationWindow *window);
+
+ /**
+ * CNxConsole destructor
+ */
+
+ ~CNxConsole(void);
+
+ /**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+ IApplicationWindow *getWindow(void) const;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+
+ /**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+ NXWidgets::CNxString getName(void);
+
+ /**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+ bool run(void);
+
+ /**
+ * Stop the application.
+ */
+
+ void stop(void);
+
+ /**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+ void hide(void);
+
+ /**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+ void redraw(void);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+ };
+
+ class CNxConsoleFactory : public IApplicationFactory
+ {
+ private:
+ CTaskbar *m_taskbar; /**< The taskbar */
+
+ public:
+ /**
+ * CNxConsoleFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ */
+
+ CNxConsoleFactory(CTaskbar *taskbar);
+
+ /**
+ * CNxConsoleFactory Destructor
+ */
+
+ inline ~CNxConsoleFactory(void) { }
+
+ /**
+ * Create a new instance of an CNxConsole (as IApplication).
+ */
+
+ IApplication *create(void);
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+ };
+}
+#endif // __cplusplus
+
+#endif // __INCLUDE_CNXCONSOLE_HXX
diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx
new file mode 100644
index 000000000..671b01087
--- /dev/null
+++ b/NxWidgets/nxwm/include/cstartwindow.hxx
@@ -0,0 +1,305 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/cnxstart.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_CSTARTWINDOW_NXX
+#define __INCLUDE_CSTARTWINDOW_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include "tnxarray.hxx"
+
+#include "iapplication.hxx"
+#include "capplicationwindow.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * Forward references
+ */
+
+ class CTaskbar;
+
+ /**
+ * Start window message opcodes and format
+ */
+
+ enum EStartWindowMessageOpcodes
+ {
+ MSGID_POSITIONAL_CHANGE = 1, /**< Change in window positional data (not used) */
+ MSGID_REDRAW_REQUEST, /**< Request to redraw a portion of the window (not used) */
+ MSGID_MOUSE_INPUT, /**< New mouse input is available */
+ MSGID_KEYBOARD_INPUT, /**< New keyboard input is available */
+ MSGID_DESTROY_APP /**< Destroy the application */
+ };
+
+ struct SStartWindowMessage
+ {
+ enum EStartWindowMessageOpcodes msgId; /**< The message opcode */
+ FAR void *instance; /**< Object instance. */
+ };
+
+ /**
+ * The well-known name for the Start Window's message queue.
+ */
+
+ extern FAR const char *g_startWindowMqName;
+
+ /**
+ * This class is the the start window application.
+ */
+
+ class CStartWindow : public IApplication,
+ private IApplicationCallback,
+ private NXWidgets::CWidgetEventHandler
+ {
+ protected:
+ /**
+ * This structure represents an application and its associated icon image
+ */
+
+ struct SStartWindowSlot
+ {
+ IApplicationFactory *app; /**< A reference to the icon */
+ NXWidgets::CImage *image; /**< The icon image that goes with the application */
+ };
+
+ /**
+ * CStartWindow state data
+ */
+
+ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
+ CApplicationWindow *m_window; /**< Reference to the application window */
+ TNxArray<struct SStartWindowSlot> m_slots; /**< List of apps in the start window */
+ struct nxgl_size_s m_iconSize; /**< A box big enough to hold the largest icon */
+ pid_t m_taskId; /**< ID of the start window task */
+
+ /**
+ * This is the start window task. This function receives window events from
+ * the NX listener threads indirectly through this sequence:
+ *
+ * 1. The NX listener thread receives a windows event. The NX listener thread
+ * which is part of CTaskBar and was created when NX server connection was
+ * established). This event may be a positional change notification, a
+ * redraw request, or mouse or keyboard input.
+ * 2. The NX listener thread handles the message by calling nx_eventhandler().
+ * nx_eventhandler() dispatches the message by calling a method in the
+ * NXWidgets::CCallback instance associated with the window.
+ * NXWidgets::CCallback is a part of the CWidgetControl.
+ * 3. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process
+ * the event.
+ * 4. NXWidgets::CWidgetControl records the new state data and raises a
+ * window event.
+ * 5. NXWidgets::CWindowEventHandlerList will give the event to
+ * NxWM::CWindowMessenger.
+ * 6. NxWM::CWindowMessenger will send the a message on a well-known message
+ * queue.
+ * 7. This CStartWindow::startWindow task will receive and process that
+ * message.
+ */
+
+ static int startWindow(int argc, char *argv[]);
+
+ /**
+ * Called when the window minimize button is pressed.
+ */
+
+ void minimize(void);
+
+ /**
+ * Called when the window close button is pressed.
+ */
+
+ void close(void);
+
+ /**
+ * Calculate the icon bounding box
+ */
+
+ void getIconBounds(void);
+
+ /**
+ * Stop all applications
+ */
+
+ void removeAllApplications(void);
+
+ /**
+ * Handle a widget action event. For CButtonArray, this is a mouse
+ * button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+ void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
+
+ public:
+
+ /**
+ * CStartWindow Constructor
+ *
+ * @param taskbar. A pointer to the parent task bar instance
+ * @param window. The window to be used by this application.
+ */
+
+ CStartWindow(CTaskbar *taskbar, CApplicationWindow *window);
+
+ /**
+ * CStartWindow Constructor
+ */
+
+ ~CStartWindow(void);
+
+ /**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+ IApplicationWindow *getWindow(void) const;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ NXWidgets::IBitmap *getIcon(void);
+
+ /**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+ NXWidgets::CNxString getName(void);
+
+ /**
+ * Start the application.
+ *
+ * @return True if the application was successfully started.
+ */
+
+ bool run(void);
+
+ /**
+ * Stop the application.
+ */
+
+ void stop(void);
+
+ /**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+ void hide(void);
+
+ /**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hiearchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+ void redraw(void);
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ bool isFullScreen(void) const;
+
+ /**
+ * Add the application to the start window. The general sequence for
+ * setting up the start window is:
+ *
+ * 1. Call IAppicationFactory::create to a new instance of the application
+ * 2. Call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * @param app. The new application to add to the start window
+ * @return true on success
+ */
+
+ bool addApplication(IApplicationFactory *app);
+
+ /**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickIcon(int index, bool click);
+#endif
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_CSTARTWINDOW_NXX
diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx
new file mode 100644
index 000000000..5aab9e6bf
--- /dev/null
+++ b/NxWidgets/nxwm/include/ctaskbar.hxx
@@ -0,0 +1,428 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/cnxtaskbar.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 __NXWM_INCLUDE_CTASKBAR_HXX
+#define __NXWM_INCLUDE_CTASKBAR_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "nxconfig.hxx"
+#include "tnxarray.hxx"
+#include "cnxwindow.hxx"
+#include "cnxserver.hxx"
+#include "cwidgeteventhandler.hxx"
+#include "cwidgeteventargs.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+#include "capplicationwindow.hxx"
+#include "cfullscreenwindow.hxx"
+#include "iapplication.hxx"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Class Definition
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * This class describes the NX window manager's task bar. That task bar is,
+ * of course, used to dock active applications. But in NxWM, it is also
+ * the heart of the window manager: It inherits for CNxServer and, hence,
+ * represents the NX server itself. It also then serves as the NxWM
+ * window factory.
+ *
+ * Why do it this way? The only reason is so that if you have an instance
+ * of CTaskbar, you have everything you need to manage new applications.
+ * It might have been a better decision to separate the window factory into
+ * a separate class instead of making the task bar of such central importance
+ * (and I may still do that someday)
+ */
+
+ class CTaskbar : public NXWidgets::CNxServer,
+ private NXWidgets::CWidgetEventHandler
+ {
+ private:
+ /**
+ * This structure represents an application and its associated icon image
+ */
+
+ struct STaskbarSlot
+ {
+ IApplication *app; /**< A reference to the icon */
+ NXWidgets::CImage *image; /**< The icon image that goes with the application */
+ };
+
+ /**
+ * Taskbar state
+ */
+
+ NXWidgets::CNxWindow *m_taskbar; /**< The task bar window */
+ NXWidgets::CNxWindow *m_background; /**< The background window */
+ NXWidgets::CImage *m_backImage; /**< The background image */
+ IApplication *m_topApp; /**< The top application in the hierarchy */
+ TNxArray<struct STaskbarSlot> m_slots; /**< List of application slots in the task bar */
+ bool m_started; /**< True if window manager has been started */
+
+ /**
+ * Create a raw window.
+ *
+ * 1) Create a dumb NXWidgets::CWidgetControl instance (See not).
+ * 2) Pass the dumb NXWidgets::CWindowMessenger instance to the window constructor
+ * that inherits from INxWindow. This will "smarten" the NXWidgets::CWidgetControl
+ * instance with some window knowlede
+ * 3) Call the open() method on the window to display the window.
+ * 4) After that, the fully smartened NXWidgets::CWidgetControl instance can
+ * be used to generate additional widgets by passing it to the
+ * widget constructor
+ *
+ * NOTE: Actually, NxWM uses the CWindowMessenger class that inherits from
+ * CWidgetControl. That class just adds some unrelated messaging capability;
+ * It cohabitates with CWidgetControl only becuase it needs the CWidgetControl
+ * this point.
+ */
+
+ NXWidgets::CNxWindow *openRawWindow(void);
+
+ /**
+ * Create a framed application window
+ *
+ * This may be used to provide the window parater to the IApplication constructor
+ *
+ * @return A partially initialized application window instance.
+ */
+
+ NXWidgets::CNxTkWindow *openFramedWindow(void);
+
+ /**
+ * Set size and position of a window in the application area.
+ *
+ * @param window. The window to be resized and repositioned
+ * @param fullscreen. True: Use full screen
+ */
+
+ void setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen);
+
+ /**
+ * Create the task bar window.
+ *
+ * @return true on success
+ */
+
+ bool createTaskbarWindow(void);
+
+ /**
+ * Create the background window.
+ *
+ * @return true on success
+ */
+
+ bool createBackgroundWindow(void);
+
+ /**
+ * Create the background image.
+ *
+ * @return true on success
+ */
+
+ bool createBackgroundImage(void);
+
+ /**
+ * (Re-)draw the task bar window.
+ *
+ * @return true on success
+ */
+
+ bool redrawTaskbarWindow(void);
+
+ /**
+ * Redraw the window at the top of the heirarchy.
+ *
+ * @return true on success
+ */
+
+ bool redrawTopApplication(void);
+
+ /**
+ * Raise the top window to the top of the NXheirarchy.
+ *
+ * @return true on success
+ */
+
+ void raiseTopApplication(void);
+
+ /**
+ * (Re-)draw the background window.
+ *
+ * @return true on success
+ */
+
+ bool redrawBackgroundWindow(void);
+
+ /**
+ * Redraw the last application in the list of application maintained by
+ * the task bar.
+ *
+ * @param app. The new top application to draw
+ * @return true on success
+ */
+
+ bool redrawApplicationWindow(IApplication *app);
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ *
+ * @param app. The application to hide
+ */
+
+ void hideApplicationWindow(IApplication *app);
+
+ /**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+ void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
+
+ public:
+ /**
+ * CTaskbar Constructor
+ *
+ * @param hWnd - NX server handle
+ */
+
+ CTaskbar(void);
+
+ /**
+ * CTaskbar Destructor
+ */
+
+ ~CTaskbar(void);
+
+ /**
+ * Connect to the server
+ */
+
+ bool connect(void);
+
+ /**
+ * Disconnect from the server
+ */
+
+ void disconnect(void);
+
+ /**
+ * Initialize task bar. Task bar initialization is separate from
+ * object instantiation so that failures can be reported. The window
+ * manager start-up sequence is:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ * inherits the connect method from CNxServer),
+ * 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ * 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ * 5. Call CTaskBar::startWindowManager() to start the display with applications in place
+ *
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+ bool initWindowManager(void);
+
+ /**
+ * Start the window manager and present the initial displays. The window
+ * manager start-up sequence is:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ * inherits the connect method from CNxServer),
+ * 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ * 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ * 5. Call CTaskBar::startWindowManager to start the display with applications in place
+ *
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * CTaskBar::startWindowManager() will present the task bar and the background image.
+ * The The initial taskbar will contain only the start window icon.
+ *
+ * @return true on success
+ */
+
+ bool startWindowManager(void);
+
+ /**
+ * Create an normal application window. Creating a normal application in the
+ * start window requires three steps:
+ *
+ * 1. Call CTaskBar::openApplicationWindow to create a window for the application,
+ * 2. Instantiate the application, providing the window to the application's
+ * constructor,
+ * 3. Then call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call CTaskBar::startApplication start the application and bring its window to
+ * the top.
+ *
+ * @param flags. CApplicationWindow flugs for window customization.
+ */
+
+ CApplicationWindow *openApplicationWindow(uint8_t flags = 0);
+
+ /**
+ * Create a full screen application window. Creating a new full screen application
+ * requires three steps:
+ *
+ * 1. Call CTaskBar::FullScreenWindow to create a window for the application,
+ * 2. Instantiate the application, providing the window to the application's
+ * constructor,
+ * 3. Then call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call CTaskBar::startApplication start the application and bring its window to
+ * the top.
+ */
+
+ CFullScreenWindow *openFullScreenWindow(void);
+
+ /**
+ * Start an application and add its icon to the taskbar. The applications's
+ * window is brought to the top. Creating a new application in the start
+ * window requires three steps:
+ *
+ * 1. Call CTaskBar::openApplicationWindow to create a window for the application,
+ * 2. Instantiate the application, providing the window to the application's
+ * constructor,
+ * 3. Then call CStartWindow::addApplication to add the application to the start window.
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call CTaskBar::startApplication start the application and bring its window to
+ * the top.
+ *
+ * @param app. The new application to add to the task bar
+ * @param minimized. The new application starts in the minimized state
+ * @return true on success
+ */
+
+ bool startApplication(IApplication *app, bool minimized);
+
+ /**
+ * Move window to the top of the hierarchy and re-draw it. This method
+ * does nothing if the application is minimized.
+ *
+ * @param app. The new application to show
+ * @return true on success
+ */
+
+ bool topApplication(IApplication *app);
+
+ /**
+ * Maximize an application by moving its window to the top of the hierarchy
+ * and re-drawing it. If the application was already maximized, then this
+ * method is equivalent to topApplication().
+ *
+ * @param app. The new application to add to the task bar
+ * @return true on success
+ */
+
+ bool maximizeApplication(IApplication *app);
+
+ /**
+ * Minimize an application by moving its window to the bottom of the
+ * and redrawing the next visible appliation.
+ *
+ * @param app. The new application to add to the task bar
+ * @return true on success
+ */
+
+ bool minimizeApplication(IApplication *app);
+
+ /**
+ * Destroy an application. Move its window to the bottom and remove its
+ * icon from the task bar.
+ *
+ * @param app. The new application to remove from the task bar
+ * @return true on success
+ */
+
+ bool stopApplication(IApplication *app);
+
+ /**
+ * Get the size of the physical display device as it is known to the task
+ * bar.
+ *
+ * @return The size of the display
+ */
+
+ void getDisplaySize(FAR struct nxgl_size_s &size);
+
+ /**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ void clickIcon(int index, bool click);
+#endif
+ };
+}
+
+#endif // __cplusplus
+#endif // __NXWM_INCLUDE_CTASKBAR_HXX
diff --git a/NxWidgets/nxwm/include/ctouchscreen.hxx b/NxWidgets/nxwm/include/ctouchscreen.hxx
new file mode 100644
index 000000000..396400204
--- /dev/null
+++ b/NxWidgets/nxwm/include/ctouchscreen.hxx
@@ -0,0 +1,221 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/ctouchscreen.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_CTOUCHSCREEN_HXX
+#define __INCLUDE_CTOUCHSCREEN_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/nx/nxglib.h>
+
+#include <semaphore.h>
+#include <pthread.h>
+
+#include <nuttx/input/touchscreen.h>
+
+#include "cnxserver.hxx"
+#include "ccalibration.hxx"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+namespace NxWM
+{
+ /**
+ * The CTouchscreen class provides the the calibration window and obtains
+ * callibration data.
+ */
+
+ class CTouchscreen
+ {
+ private:
+ /**
+ * The state of the listener thread.
+ */
+
+ enum EListenerState
+ {
+ LISTENER_NOTRUNNING = 0, /**< The listener thread has not yet been started */
+ LISTENER_STARTED, /**< The listener thread has been started, but is not yet running */
+ LISTENER_RUNNING, /**< The listener thread is running normally */
+ LISTENER_STOPREQUESTED, /**< The listener thread has been requested to stop */
+ LISTENER_TERMINATED, /**< The listener thread terminated normally */
+ LISTENER_FAILED /**< The listener thread terminated abnormally */
+ };
+
+ /**
+ * CTouchscreen state data
+ */
+
+ NXWidgets::CNxServer *m_server; /**< The current NX server */
+ int m_touchFd; /**< File descriptor of the opened touchscreen device */
+ sem_t m_waitSem; /**< Semaphore the supports waits for touchscreen data */
+ pthread_t m_thread; /**< The listener thread ID */
+ volatile enum EListenerState m_state; /**< The state of the listener thread */
+ volatile bool m_enabled; /**< True: Normal touchscreen processing */
+ volatile bool m_capture; /**< True: There is a thread waiting for raw touch data */
+ volatile bool m_calibrated; /**< True: If have calibration data */
+ struct nxgl_size_s m_windowSize; /**< The size of the physical display */
+ struct SCalibrationData m_calibData; /**< Calibration data */
+ struct touch_sample_s m_sample; /**< In normal mode, touch data is collected here */
+ struct touch_sample_s *m_touch; /**< Points to the current touch data buffer */
+
+ /**
+ * The touchscreen listener thread. This is the entry point of a thread that
+ * listeners for and dispatches touchscreens events to the NX server.
+ *
+ * @param arg. The CTouchscreen 'this' pointer cast to a void*.
+ * @return This function normally does not return but may return NULL on
+ * error conditions.
+ */
+
+ static FAR void *listener(FAR void *arg);
+
+ /**
+ * Inject touchscreen data into NX as mouse intput
+ *
+ * @param sample. The buffer where data was collected.
+ */
+
+ void handleMouseInput(struct touch_sample_s *sample);
+
+ public:
+
+ /**
+ * CTouchscreen Constructor
+ *
+ * @param server. An instance of the NX server. This will be needed for
+ * injecting mouse data.
+ * @param windowSize. The size of the physical window in pixels. This
+ * is needed for touchscreen scaling.
+ */
+
+ CTouchscreen(NXWidgets::CNxServer *server, struct nxgl_size_s *windowSize);
+
+ /**
+ * CTouchscreen Destructor
+ */
+
+ ~CTouchscreen(void);
+
+ /**
+ * Start the touchscreen listener thread.
+ *
+ * @return True if the touchscreen listener thread was correctly started.
+ */
+
+ bool start(void);
+
+ /**
+ * Enable/disable touchscreen data processing. When enabled, touchscreen events
+ * are calibrated and forwarded to the NX layer which dispatches the touchscreen
+ * events in window-relative positions to the correct NX window.
+ *
+ * When disabled, touchscreen data is not forwarded to NX, but is instead captured
+ * and made available for touchscreen calibration. The touchscreen driver is
+ * initially disabled and must be specifically enabled be begin normal processing.
+ * Normal processing also requires calibration data (see method setCalibrationData)
+ *
+ * @param capture. True enables capture mode; false disables.
+ */
+
+ inline void setEnabled(bool enable)
+ {
+ // Set the capture flag. m_calibrated must also be set to get to normal
+ // mode where touchscreen data is forwarded to NX.
+
+ m_enabled = enable;
+ }
+
+ /**
+ * Is the touchscreen calibrated?
+ *
+ * @return True if the touchscreen has been calibrated.
+ */
+
+ inline bool isCalibrated(void) const
+ {
+ return m_calibrated;
+ }
+
+ /**
+ * Provide touchscreen calibration data. If calibration data is received (and
+ * the touchscreen is enabled), then received touchscreen data will be scaled
+ * using the calibration data and forward to the NX layer which dispatches the
+ * touchscreen events in window-relative positions to the correct NX window.
+ *
+ * @param data. A reference to the touchscreen data.
+ */
+
+ void setCalibrationData(const struct SCalibrationData &caldata);
+
+ /**
+ * Recover the calibration data so that it can be saved to non-volatile storage.
+ *
+ * @param data. A reference to the touchscreen data.
+ * @return True if calibration data was successfully returned.
+ */
+
+ inline bool getCalibrationData(struct SCalibrationData &caldata) const
+ {
+ if (m_calibrated)
+ {
+ caldata = m_calibData;
+ }
+ return m_calibrated;
+ }
+
+ /**
+ * Capture raw driver data. This method will capture mode one raw touchscreen
+ * input. The normal use of this method is for touchscreen calibration.
+ *
+ * This function is not re-entrant: There may be only one thread waiting for
+ * raw touchscreen data.
+ *
+ * @return True if the raw touchscreen data was sucessfully obtained
+ */
+
+ bool waitRawTouchData(struct touch_sample_s *touch);
+ };
+}
+
+#endif // __INCLUDE_CTOUCHSCREEN_HXX
diff --git a/NxWidgets/nxwm/include/cwindowmessenger.hxx b/NxWidgets/nxwm/include/cwindowmessenger.hxx
new file mode 100644
index 000000000..11a48645b
--- /dev/null
+++ b/NxWidgets/nxwm/include/cwindowmessenger.hxx
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/cwindowmessenger.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_CWINDOWMESSENGER_HXX
+#define __INCLUDE_CWINDOWMESSENGER_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <mqueue.h>
+
+#include <nuttx/nx/nxtk.h>
+#include <nuttx/nx/nxconsole.h>
+
+#include "cwindoweventhandler.hxx"
+#include "cwidgetstyle.hxx"
+#include "cwidgetcontrol.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Implementation Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * Forward references.
+ */
+
+ class IApplication;
+
+ /**
+ * The class CWindowMessenger integrates the widget control with some special
+ * handling of mouse and keyboard inputs needs by NxWM. It use used
+ * in place of CWidgetControl whenever an NxWM window is created.
+ *
+ * CWindowMessenger cohabitates with CWidgetControl only because it needs the
+ * CWidgetControl as an argument in its messaging.
+ */
+
+ class CWindowMessenger : public NXWidgets::CWindowEventHandler,
+ public NXWidgets::CWidgetControl
+ {
+ private:
+ mqd_t m_mqd; /**< Message queue descriptor used to commincate with the
+ ** start window thread. */
+
+ /**
+ * Handle an NX window mouse input event.
+ *
+ * @param e The event data.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+ void handleMouseEvent(void);
+#endif
+
+ /**
+ * Handle a NX window keyboard input event.
+ */
+
+#ifdef CONFIG_NX_KBD
+ void handleKeyboardEvent(void);
+#endif
+
+ /**
+ * Handle a NX window blocked event
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+ void handleBlockedEvent(FAR void *arg);
+
+ public:
+
+ /**
+ * CWindowMessenger Constructor
+ *
+ * @param style The default style that all widgets on this display
+ * should use. If this is not specified, the widget will use the
+ * values stored in the defaultCWidgetStyle object.
+ */
+
+ CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style = (const NXWidgets::CWidgetStyle *)NULL);
+
+ /**
+ * CWindowMessenger Destructor.
+ */
+
+ ~CWindowMessenger(void);
+ };
+}
+#endif // __cplusplus
+
+#endif // __INCLUDE_CWINDOWMESSENGER_HXX
diff --git a/NxWidgets/nxwm/include/iapplication.hxx b/NxWidgets/nxwm/include/iapplication.hxx
new file mode 100644
index 000000000..456202c6d
--- /dev/null
+++ b/NxWidgets/nxwm/include/iapplication.hxx
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/iapplication.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_IAPPLICATION_NXX
+#define __INCLUDE_IAPPLICATION_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "cnxstring.hxx"
+#include "ibitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Classes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * Foward references
+ */
+
+ class IApplicationWindow;
+
+ /**
+ * IApplication provides the abstract base class for each NxWM application.
+ */
+
+ class IApplication
+ {
+ protected:
+ /**
+ * These values (and the accessors that go with them) violate the "purity"
+ * of the base class. These are really part of the task bar implementation:
+ * Each application provides this state information needed by the taskbar.
+ */
+
+ bool m_minimized; /**< True if the application is minimized */
+ bool m_topapp; /**< True if this application is at the top in the hiearchy */
+
+ public:
+ /**
+ * A virtual destructor is required in order to override the IApplication
+ * destructor. We do this because if we delete IApplication, we want the
+ * destructor of the class that inherits from IApplication to run, not this
+ * one.
+ */
+
+ virtual ~IApplication(void) { }
+
+ /**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+ virtual IApplicationWindow *getWindow(void) const = 0;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ virtual NXWidgets::IBitmap *getIcon(void) = 0;
+
+ /**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+ virtual NXWidgets::CNxString getName(void) = 0;
+
+ /**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+ virtual bool run(void) = 0;
+
+ /**
+ * Stop the application, put all widgets in a deactivated/disabled state
+ * and wait to see what happens next.
+ */
+
+ virtual void stop(void) = 0;
+
+ /**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ virtual void destroy(void) = 0;
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+ virtual void hide(void) = 0;
+
+ /**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+ virtual void redraw(void) = 0;
+
+ /**
+ * Set the application's minimized state
+ *
+ * @param minimized. True if the application is minimized
+ */
+
+ inline void setMinimized(bool minimized)
+ {
+ m_minimized = minimized;
+ }
+
+ /**
+ * Set the application's top state
+ *
+ * @param topapp. True if the application is the new top application
+ */
+
+ inline void setTopApplication(bool topapp)
+ {
+ m_topapp = topapp;
+ }
+
+ /**
+ * Get the application's minimized state
+ *
+ * @return True if the application is minimized
+ */
+
+ inline bool isMinimized(void) const
+ {
+ return m_minimized;
+ }
+
+ /**
+ * Return true if this is the top application
+ *
+ * @return True if the application is the new top application
+ */
+
+ inline bool isTopApplication(void) const
+ {
+ return m_topapp;
+ }
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ virtual bool isFullScreen(void) const = 0;
+ };
+
+ /**
+ * IApplicationFactory provides a mechanism for creating multiple instances
+ * of an application.
+ */
+
+ class IApplicationFactory
+ {
+ public:
+ /**
+ * Create a new instance of an application.
+ */
+
+ virtual IApplication *create(void) = 0;
+
+ /**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+ virtual NXWidgets::IBitmap *getIcon(void) = 0;
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_IAPPLICATION_NXX
diff --git a/NxWidgets/nxwm/include/iapplicationwindow.hxx b/NxWidgets/nxwm/include/iapplicationwindow.hxx
new file mode 100644
index 000000000..60f1b332c
--- /dev/null
+++ b/NxWidgets/nxwm/include/iapplicationwindow.hxx
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/iapplicationwindow.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_IAPPLICATIONWINDOW_NXX
+#define __INCLUDE_IAPPLICATIONWINDOW_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "inxwindow.hxx"
+#include "cnxstring.hxx"
+#include "cwidgetcontrol.hxx"
+
+#include "iapplication.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Abstract Base Class
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ /**
+ * Foward references
+ */
+
+ class IApplication;
+
+ /**
+ * This callback class is used by the application to get notification of toolbar
+ * related events.
+ */
+
+ class IApplicationCallback
+ {
+ public:
+ /**
+ * Called when the window minimize button is pressed.
+ */
+
+ virtual void minimize(void) = 0;
+
+ /**
+ * Called when the window minimize close is pressed.
+ */
+
+ virtual void close(void) = 0;
+ };
+
+ /**
+ * This class represents the general application window. The actual window
+ * may be a contained, framed window or and unframed, fullscreen window.
+ */
+
+ class IApplicationWindow
+ {
+ public:
+ /**
+ * A virtual destructor is required in order to override the IApplicationWindow
+ * destructor. We do this because if we delete IApplicationWindow, we want the
+ * destructor of the class that inherits from IApplicationWindow to run, not this
+ * one.
+ */
+
+ virtual ~IApplicationWindow(void) { }
+
+ /**
+ * Initialize window. Window initialization is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+ virtual bool open(void) = 0;
+
+ /**
+ * Re-draw the application window
+ */
+
+ virtual void redraw(void) = 0;
+
+ /**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+ virtual void hide(void) = 0;
+
+ /**
+ * Recover the contained window instance
+ *
+ * @return. The window used by this application
+ */
+
+ virtual NXWidgets::INxWindow *getWindow(void) const = 0;
+
+ /**
+ * Recover the contained widget control
+ *
+ * @return. The widget control used by this application
+ */
+
+ virtual NXWidgets::CWidgetControl *getWidgetControl(void) const = 0;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ *
+ * @param app. The application to be blocked
+ */
+
+ virtual void block(IApplication *app) = 0;
+
+ /**
+ * Set the window label
+ *
+ * @param appname. The name of the application to place on the window
+ */
+
+ virtual void setWindowLabel(NXWidgets::CNxString &appname) = 0;
+
+ /**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+ virtual bool isFullScreen(void) const = 0;
+
+ /**
+ * Register to receive callbacks when toolbar icons are selected
+ */
+
+ virtual void registerCallbacks(IApplicationCallback *callback) = 0;
+
+ /**
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ virtual void clickMinimizePosition(bool click) = 0;
+#endif
+
+ /**
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+ virtual void clickStopIcon(bool click) = 0;
+#endif
+ };
+}
+
+#endif // __cplusplus
+
+#endif // __INCLUDE_IAPPLICATIONWINDOW_NXX
diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx
new file mode 100644
index 000000000..578fc5be8
--- /dev/null
+++ b/NxWidgets/nxwm/include/nxwmconfig.hxx
@@ -0,0 +1,555 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/nxwmconfig.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_NXWMCONFIG_HXX
+#define __INCLUDE_NXWMCONFIG_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/input/touchscreen.h>
+
+#include "nxconfig.hxx"
+#include "crlepalettebitmap.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* General Configuration ****************************************************/
+/**
+ * Required settings:
+ *
+ * CONFIG_HAVE_CXX : C++ support is required
+ * CONFIG_NX : NX must enabled
+ * CONFIG_NX_MULTIUSER=y : NX must be configured in multiuse mode
+ * CONFIG_NXCONSOLE=y : For NxConsole support
+ * CONFIG_SCHED_ONEXIT : Support for on_exit()
+ *
+ * General settings:
+ *
+ * CONFIG_NXWM_DEFAULT_FONTID - the NxWM default font ID. Default:
+ * NXFONT_DEFAULT
+ * CONFIG_NXWM_TOUCHSCREEN - Define to build in touchscreen support.
+ * CONFIG_NXWM_KEYBOARD - Define to build in touchscreen support.
+ */
+
+#ifndef CONFIG_HAVE_CXX
+# error "C++ support is required (CONFIG_HAVE_CXX)"
+#endif
+
+/**
+ * NX Multi-user support is required
+ */
+
+#ifndef CONFIG_NX
+# error "NX support is required (CONFIG_NX)"
+#endif
+
+#ifndef CONFIG_NX_MULTIUSER
+# error "NX multi-user support is required (CONFIG_NX_MULTIUSER)"
+#endif
+
+/**
+ * NxConsole support is (probably) required
+ */
+
+#ifndef CONFIG_NXCONSOLE
+# warning "NxConsole support may be needed (CONFIG_NXCONSOLE)"
+#endif
+
+/**
+ * on_exit() support is (probably) required. on_exit() is the normal
+ * mechanism used by NxWM applications to clean-up on a application task
+ * exit.
+ */
+
+#ifndef CONFIG_SCHED_ONEXIT
+# warning "on_exit() support may be needed (CONFIG_SCHED_ONEXIT)"
+#endif
+
+/**
+ * Default font ID
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_FONTID
+# define CONFIG_NXWM_DEFAULT_FONTID NXFONT_DEFAULT
+#endif
+
+/* Colors *******************************************************************/
+/**
+ * Color configuration
+ *
+ * CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR - Normal background color. Default:
+ * MKRGB(148,189,215)
+ * CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR - Select background color.
+ * Default: MKRGB(206,227,241)
+ * CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR - Color of the bright edge of a border.
+ * Default: MKRGB(255,255,255)
+ * CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR - Color of the shadowed edge of a border.
+ * Default: MKRGB(0,0,0)
+ * CONFIG_NXWM_DEFAULT_FONTCOLOR - Default fong color. Default:
+ * MKRGB(0,0,0)
+ * CONFIG_NXWM_TRANSPARENT_COLOR - The "transparent" color. Default:
+ * MKRGB(0,0,0)
+ */
+
+/**
+ * Normal background color
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+# define CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR MKRGB(148,189,215)
+#endif
+
+/**
+ * Default selected background color
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR
+# define CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(206,227,241)
+#endif
+
+/**
+ * Border colors
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR
+# define CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
+#endif
+
+#ifndef CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR
+# define CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR MKRGB(35,58,73)
+#endif
+
+/**
+ * The default font color
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_FONTCOLOR
+# define CONFIG_NXWM_DEFAULT_FONTCOLOR MKRGB(255,255,255)
+#endif
+
+/**
+ * The transparent color
+ */
+
+#ifndef CONFIG_NXWM_TRANSPARENT_COLOR
+# define CONFIG_NXWM_TRANSPARENT_COLOR MKRGB(0,0,0)
+#endif
+
+/* Task Bar Configuation ***************************************************/
+/**
+ * Horizontal and vertical spacing of icons in the task bar.
+ *
+ * CONFIG_NXWM_TASKBAR_VSPACING - Vertical spacing. Default: 2 pixels
+ * CONFIG_NXWM_TASKBAR_HSPACING - Horizontal spacing. Default: 2 rows
+ *
+ * Task bar location. Default is CONFIG_NXWM_TASKBAR_TOP.
+ *
+ * CONFIG_NXWM_TASKBAR_TOP - Task bar is at the top of the display
+ * CONFIG_NXWM_TASKBAR_BOTTOM - Task bar is at the bottom of the display
+ * CONFIG_NXWM_TASKBAR_LEFT - Task bar is on the left side of the display
+ * CONFIG_NXWM_TASKBAR_RIGHT - Task bar is on the right side of the display
+ *
+ * CONFIG_NXWM_TASKBAR_WIDTH - Task bar thickness (either vertical or
+ * horizontal). Default: 25 + 2*spacing
+ */
+
+/**
+ * Horizontal and vertical spacing of icons in the task bar.
+ */
+
+#ifndef CONFIG_NXWM_TASKBAR_VSPACING
+# define CONFIG_NXWM_TASKBAR_VSPACING (2)
+#endif
+
+#ifndef CONFIG_NXWM_TASKBAR_HSPACING
+# define CONFIG_NXWM_TASKBAR_HSPACING (2)
+#endif
+
+/**
+ * Check task bar location
+ */
+
+#if defined(CONFIG_NXWM_TASKBAR_TOP)
+# if defined(CONFIG_NXWM_TASKBAR_BOTTOM) || defined (CONFIG_NXWM_TASKBAR_LEFT) || defined (CONFIG_NXWM_TASKBAR_RIGHT)
+# warning "Multiple task bar positions specified"
+# endif
+#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+# if defined (CONFIG_NXWM_TASKBAR_LEFT) || defined (CONFIG_NXWM_TASKBAR_RIGHT)
+# warning "Multiple task bar positions specified"
+# endif
+#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
+# if defined (CONFIG_NXWM_TASKBAR_RIGHT)
+# warning "Multiple task bar positions specified"
+# endif
+#elif !defined(CONFIG_NXWM_TASKBAR_RIGHT)
+# warning "No task bar position specified"
+# define CONFIG_NXWM_TASKBAR_TOP 1
+#endif
+
+/**
+ * At present, all icons are 25 pixels in "width" and, hence require a
+ * task bar of at least that size.
+ */
+
+#ifndef CONFIG_NXWM_TASKBAR_WIDTH
+# if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_HSPACING)
+# else
+# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_VSPACING)
+# endif
+#endif
+
+/* Tool Bar Configuration ***************************************************/
+/**
+ * CONFIG_NXWM_TOOLBAR_HEIGHT. The height of the tool bar in each
+ * application window. At present, all icons are 21 pixels in height and,
+ * hence require a task bar of at least that size.
+ */
+
+#ifndef CONFIG_NXWM_TOOLBAR_HEIGHT
+# define CONFIG_NXWM_TOOLBAR_HEIGHT (21+2*CONFIG_NXWM_TASKBAR_HSPACING)
+#endif
+
+/* Background Image **********************************************************/
+/**
+ * CONFIG_NXWM_BACKGROUND_IMAGE - The name of the image to use in the
+ * background window. Default:NXWidgets::g_nuttxBitmap
+ */
+
+#ifndef CONFIG_NXWM_BACKGROUND_IMAGE
+# define CONFIG_NXWM_BACKGROUND_IMAGE NXWidgets::g_nuttxBitmap
+#endif
+
+/* Start Window Configuration ***********************************************/
+/**
+ * Horizontal and vertical spacing of icons in the task bar.
+ *
+ * CONFIG_NXWM_STARTWINDOW_VSPACING - Vertical spacing. Default: 4 pixels
+ * CONFIG_NXWM_STARTWINDOW_HSPACING - Horizontal spacing. Default: 4 rows
+ * CONFIG_NXWM_STARTWINDOW_ICON - The glyph to use as the start window icon
+ * CONFIG_NXWM_STARTWINDOW_MQNAME - The well known name of the message queue
+ * Used to communicated from CWindowMessenger to the start window thread.
+ * Default: "/dev/nxwm"
+ * CONFIG_NXWM_STARTWINDOW_MXMSGS - The maximum number of messages to queue
+ * before blocking. Defualt 32
+ * CONFIG_NXWM_STARTWINDOW_MXMPRIO - The message priority. Default: 42.
+ * CONFIG_NXWM_STARTWINDOW_PRIO - Priority of the NxConsole task. Default:
+ * SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than
+ * CONFIG_NXWIDGETS_SERVERPRIO or else there may be data overrun errors.
+ * Such errors would most likely appear as duplicated rows of data on the
+ * display.
+ * CONFIG_NXWM_STARTWINDOW_STACKSIZE - The stack size to use when starting the
+ * NxConsole task. Default: 2048 bytes.
+ */
+
+#ifndef CONFIG_NXWM_STARTWINDOW_VSPACING
+# define CONFIG_NXWM_STARTWINDOW_VSPACING (4)
+#endif
+
+#ifndef CONFIG_NXWM_STARTWINDOW_HSPACING
+# define CONFIG_NXWM_STARTWINDOW_HSPACING (4)
+#endif
+
+/**
+ * The start window glyph
+ */
+
+#ifndef CONFIG_NXWM_STARTWINDOW_ICON
+# define CONFIG_NXWM_STARTWINDOW_ICON NxWM::g_playBitmap
+#endif
+
+/**
+ * Start window task parameters
+ */
+
+#ifndef CONFIG_NXWM_STARTWINDOW_MQNAME
+# define CONFIG_NXWM_STARTWINDOW_MQNAME "/dev/nxwm"
+#endif
+
+#ifndef CONFIG_NXWM_STARTWINDOW_MXMSGS
+# ifdef CONFIG_NX_MXCLIENTMSGS
+# define CONFIG_NXWM_STARTWINDOW_MXMSGS CONFIG_NX_MXCLIENTMSGS
+# else
+# define CONFIG_NXWM_STARTWINDOW_MXMSGS 32
+# endif
+#endif
+
+#ifndef CONFIG_NXWM_STARTWINDOW_MXMPRIO
+# define CONFIG_NXWM_STARTWINDOW_MXMPRIO 42
+#endif
+
+#ifndef CONFIG_NXWM_STARTWINDOW_PRIO
+# define CONFIG_NXWM_STARTWINDOW_PRIO SCHED_PRIORITY_DEFAULT
+#endif
+
+#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO
+# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO"
+# warning" -- This can result in data overrun errors"
+#endif
+
+#ifndef CONFIG_NXWM_STARTWINDOW_STACKSIZE
+# define CONFIG_NXWM_STARTWINDOW_STACKSIZE 2048
+#endif
+
+/* NxConsole Window *********************************************************/
+/**
+ * NxConsole Window Configuration
+ *
+ * CONFIG_NXWM_NXCONSOLE_PRIO - Priority of the NxConsole task. Default:
+ * SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than
+ * CONFIG_NXWIDGETS_SERVERPRIO or else there may be data overrun errors.
+ * Such errors would most likely appear as duplicated rows of data on the
+ * display.
+ * CONFIG_NXWM_NXCONSOLE_STACKSIZE - The stack size to use when starting the
+ * NxConsole task. Default: 2048 bytes.
+ * CONFIG_NXWM_NXCONSOLE_WCOLOR - The color of the NxConsole window background.
+ * Default: MKRGB(192,192,192)
+ * CONFIG_NXWM_NXCONSOLE_FONTCOLOR - The color of the fonts to use in the
+ * NxConsole window. Default: MKRGB(0,0,0)
+ * CONFIG_NXWM_NXCONSOLE_FONTID - The ID of the font to use in the NxConsole
+ * window. Default: CONFIG_NXWM_DEFAULT_FONTID
+ * CONFIG_NXWM_NXCONSOLE_ICON - The glyph to use as the NxConsole icon
+ */
+
+#ifndef CONFIG_NXWM_NXCONSOLE_PRIO
+# define CONFIG_NXWM_NXCONSOLE_PRIO SCHED_PRIORITY_DEFAULT
+#endif
+
+#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_NXCONSOLE_PRIO
+# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_NXCONSOLE_PRIO"
+# warning" -- This can result in data overrun errors"
+#endif
+
+#ifndef CONFIG_NXWM_NXCONSOLE_STACKSIZE
+# define CONFIG_NXWM_NXCONSOLE_STACKSIZE 2048
+#endif
+
+#ifndef CONFIG_NXWM_NXCONSOLE_WCOLOR
+# define CONFIG_NXWM_NXCONSOLE_WCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_NXWM_NXCONSOLE_FONTCOLOR
+# define CONFIG_NXWM_NXCONSOLE_FONTCOLOR CONFIG_NXWM_DEFAULT_FONTCOLOR
+#endif
+
+#ifndef CONFIG_NXWM_NXCONSOLE_FONTID
+# define CONFIG_NXWM_NXCONSOLE_FONTID CONFIG_NXWM_DEFAULT_FONTID
+#endif
+
+/**
+ * The NxConsole window glyph
+ */
+
+#ifndef CONFIG_NXWM_NXCONSOLE_ICON
+# define CONFIG_NXWM_NXCONSOLE_ICON NxWM::g_cmdBitmap
+#endif
+
+/* Touchscreen device *******************************************************/
+/**
+ * Touchscreen device settings
+ *
+ * CONFIG_NXWM_TOUCHSCREEN_DEVNO - Touchscreen device minor number, i.e., the
+ * N in /dev/inputN. Default: 0
+ * CONFIG_NXWM_TOUCHSCREEN_DEVPATH - The full path to the touchscreen device.
+ * Default: "/dev/input0"
+ * CONFIG_NXWM_TOUCHSCREEN_SIGNO - The realtime signal used to wake up the
+ * touchscreen listener thread. Default: 5
+ * CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO - Priority of the touchscreen listener
+ * thread. Default: SCHED_PRIORITY_DEFAULT
+ * CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK - Touchscreen listener thread stack
+ * size. Default 1024
+ */
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN_DEVNO
+# define CONFIG_NXWM_TOUCHSCREEN_DEVNO 0
+#endif
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN_DEVPATH
+# define CONFIG_NXWM_TOUCHSCREEN_DEVPATH "/dev/input0"
+#endif
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN_SIGNO
+# define CONFIG_NXWM_TOUCHSCREEN_SIGNO 5
+#endif
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO
+# define CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO SCHED_PRIORITY_DEFAULT
+#endif
+
+#ifndef CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK
+# define CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK 1024
+#endif
+
+/* Keyboard device **********************************************************/
+/**
+ * Keyboard device settings
+ *
+ * CONFIG_NXWM_KEYBOARD_DEVNO - The full path to the touchscreen device.
+ * Default: "/dev/console"
+ * CONFIG_NXWM_KEYBOARD_SIGNO - The realtime signal used to wake up the
+ * touchscreen listener thread. Default: 6
+ * CONFIG_NXWM_KEYBOARD_BUFSIZE - The size of the keyboard read data buffer.
+ * Default: 16
+ * CONFIG_NXWM_KEYBOARD_LISTENERPRIO - Priority of the touchscreen listener
+ * thread. Default: SCHED_PRIORITY_DEFAULT
+ * CONFIG_NXWM_KEYBOARD_LISTENERSTACK - Keyboard listener thread stack
+ * size. Default 1024
+ */
+
+#ifndef CONFIG_NXWM_KEYBOARD_DEVPATH
+# define CONFIG_NXWM_KEYBOARD_DEVPATH "/dev/console"
+#endif
+
+#ifndef CONFIG_NXWM_KEYBOARD_SIGNO
+# define CONFIG_NXWM_KEYBOARD_SIGNO 6
+#endif
+
+#ifndef CONFIG_NXWM_KEYBOARD_BUFSIZE
+# define CONFIG_NXWM_KEYBOARD_BUFSIZE 6
+#endif
+
+#ifndef CONFIG_NXWM_KEYBOARD_LISTENERPRIO
+# define CONFIG_NXWM_KEYBOARD_LISTENERPRIO SCHED_PRIORITY_DEFAULT
+#endif
+
+#ifndef CONFIG_NXWM_KEYBOARD_LISTENERSTACK
+# define CONFIG_NXWM_KEYBOARD_LISTENERSTACK 1024
+#endif
+
+/* Calibration display ******************************************************/
+/**
+ * Calibration display settings:
+ *
+ * CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR - The background color of the
+ * touchscreen calibration display. Default: Same as
+ * CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+ * CONFIG_NXWM_CALIBRATION_LINECOLOR - The color of the lines used in the
+ * touchscreen calibration display. Default: MKRGB(0, 0, 128) (dark blue)
+ * CONFIG_NXWM_CALIBRATION_CIRCLECOLOR - The color of the circle in the
+ * touchscreen calibration display. Default: MKRGB(255, 255, 255) (white)
+ * CONFIG_NXWM_CALIBRATION_CIRCLECOLOR - The color of the circle in the
+ * touchscreen calibration display after the touch is recorder. Default:
+ * MKRGB(255, 255, 96) (very light yellow)
+ * CONFIG_NXWM_CALIBRATION_ICON - The ICON to use for the touchscreen
+ * calibration application. Default: NxWM::g_calibrationBitmap
+ * CONFIG_NXWM_CALIBRATION_SIGNO - The realtime signal used to wake up the
+ * touchscreen calibration thread. Default: 5
+ * CONFIG_NXWM_CALIBRATION_LISTENERPRIO - Priority of the touchscreen listener
+ * thread. Default: SCHED_PRIORITY_DEFAULT
+ * CONFIG_NXWM_CALIBRATION_LISTENERSTACK - Touchscreen listener thread stack
+ * size. Default 2048
+ */
+
+#ifndef CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR
+# define CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_LINECOLOR
+# define CONFIG_NXWM_CALIBRATION_LINECOLOR MKRGB(0, 0, 128)
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_CIRCLECOLOR
+# define CONFIG_NXWM_CALIBRATION_CIRCLECOLOR MKRGB(255, 255, 255)
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_TOUCHEDCOLOR
+# define CONFIG_NXWM_CALIBRATION_TOUCHEDCOLOR MKRGB(255, 255, 96)
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_ICON
+# define CONFIG_NXWM_CALIBRATION_ICON NxWM::g_calibrationBitmap
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_SIGNO
+# define CONFIG_NXWM_CALIBRATION_SIGNO 5
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_LISTENERPRIO
+# define CONFIG_NXWM_CALIBRATION_LISTENERPRIO SCHED_PRIORITY_DEFAULT
+#endif
+
+#ifndef CONFIG_NXWM_CALIBRATION_LISTENERSTACK
+# define CONFIG_NXWM_CALIBRATION_LISTENERSTACK 2048
+#endif
+
+/* Hexcalculator applications ***********************************************/
+/**
+ * Calibration display settings:
+ *
+ * CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR - The background color of the
+ * calculator display. Default: Same as CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+ * CONFIG_NXWM_HEXCALCULATOR_ICON - The ICON to use for the hex calculator
+ * application. Default: NxWM::g_calculatorBitmap
+ * CONFIG_NXWM_HEXCALCULATOR_FONTID - The font used with the calculator.
+ * Default: CONFIG_NXWM_DEFAULT_FONTID
+ */
+
+#ifndef CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR
+# define CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
+#endif
+
+#ifndef CONFIG_NXWM_HEXCALCULATOR_ICON
+# define CONFIG_NXWM_HEXCALCULATOR_ICON NxWM::g_calculatorBitmap
+#endif
+
+#ifndef CONFIG_NXWM_HEXCALCULATOR_FONTID
+# define CONFIG_NXWM_HEXCALCULATOR_FONTID CONFIG_NXWM_DEFAULT_FONTID
+#endif
+
+/****************************************************************************
+ * Global Function Prototypes
+ ****************************************************************************/
+/**
+ * Hook to support monitoring of memory usage by the NxWM unit test.
+ */
+
+#ifdef CONFIG_NXWM_UNITTEST
+# ifdef CONFIG_HAVE_FILENAME
+void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg);
+# define showTestStepMemory(msg) \
+ _showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+# else
+void showTestStepMemory(FAR const char *msg);
+# endif
+#else
+# define showTestStepMemory(msg)
+#endif
+
+#endif // __INCLUDE_NXWMCONFIG_HXX
diff --git a/NxWidgets/nxwm/include/nxwmglyphs.hxx b/NxWidgets/nxwm/include/nxwmglyphs.hxx
new file mode 100644
index 000000000..7db02fd17
--- /dev/null
+++ b/NxWidgets/nxwm/include/nxwmglyphs.hxx
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * NxWidgets/nxwm/include/nxwmconfig.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_NXWMGLYPHS_HXX
+#define __INCLUDE_NXWMGLYPHS_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "nxconfig.hxx"
+#include "glyphs.hxx"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Bitmap Glyphs
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+
+namespace NxWM
+{
+ extern const struct NXWidgets::SRlePaletteBitmap g_calculatorBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_calibrationBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_cmdBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_minimizeBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_nshBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_playBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_startBitmap;
+ extern const struct NXWidgets::SRlePaletteBitmap g_stopBitmap;
+}
+
+#endif // __cplusplus
+#endif // __INCLUDE_NXWMGLYPHS_HXX
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx
new file mode 100644
index 000000000..65de1b1a4
--- /dev/null
+++ b/NxWidgets/nxwm/src/capplicationwindow.cxx
@@ -0,0 +1,581 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/capplicationwindow.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "cgraphicsport.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "cwindowmessenger.hxx"
+#include "capplicationwindow.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CApplicationWindow Method Implementations
+ ********************************************************************************************/
+
+ using namespace NxWM;
+
+/**
+ * CApplicationWindow Constructor
+ *
+ * @param taskbar. A pointer to the parent task bar instance.
+ * @param flags. Optional flags to control the window configuration (See EWindowFlags).
+ */
+
+CApplicationWindow::CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags)
+{
+ // Save the window and window flags for later use
+
+ m_window = window;
+ m_flags = flags;
+
+ // These will be created with the open method is called
+
+ m_toolbar = (NXWidgets::CNxToolbar *)0;
+
+ m_minimizeImage = (NXWidgets::CImage *)0;
+ m_stopImage = (NXWidgets::CImage *)0;
+ m_windowLabel = (NXWidgets::CLabel *)0;
+
+ m_minimizeBitmap = (NXWidgets::CRlePaletteBitmap *)0;
+ m_stopBitmap = (NXWidgets::CRlePaletteBitmap *)0;
+
+ m_windowFont = (NXWidgets::CNxFont *)0;
+
+ // This will be initialized when the registerCallbacks() method is called
+
+ m_callback = (IApplicationCallback *)0;
+}
+
+/**
+ * CApplicationWindow Destructor
+ */
+
+CApplicationWindow::~CApplicationWindow(void)
+{
+ // Free the resources that we are responsible for
+
+ if (m_minimizeImage)
+ {
+ delete m_minimizeImage;
+ }
+
+ if (m_stopImage)
+ {
+ delete m_stopImage;
+ }
+
+ if (m_windowLabel)
+ {
+ delete m_windowLabel;
+ }
+
+ if (m_minimizeBitmap)
+ {
+ delete m_minimizeBitmap;
+ }
+
+ if (m_stopBitmap)
+ {
+ delete m_stopBitmap;
+ }
+
+ if (m_windowFont)
+ {
+ delete m_windowFont;
+ }
+
+ if (m_toolbar)
+ {
+ delete m_toolbar;
+ }
+
+ // We didn't create the window. That was done by the task bar,
+ // But we will handle destruction of with window as a courtesy.
+
+ if (m_window)
+ {
+ delete m_window;
+ }
+}
+
+/**
+ * Initialize window. Window initialization is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+bool CApplicationWindow::open(void)
+{
+ // Create the widget control (with the window messenger) using the default style
+
+ CWindowMessenger *control = new CWindowMessenger();
+ if (!control)
+ {
+ return false;
+ }
+
+ // Open the toolbar using the widget control
+
+ m_toolbar = m_window->openToolbar(CONFIG_NXWM_TOOLBAR_HEIGHT, control);
+ if (!m_toolbar)
+ {
+ // We failed to open the toolbar
+
+ return false;
+ }
+
+ // Get the width of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_toolbar->getSize(&windowSize))
+ {
+ return false;
+ }
+
+ // Start positioning icons from the right side of the tool bar
+
+ struct nxgl_point_s iconPos;
+ struct nxgl_size_s iconSize;
+
+ iconPos.x = windowSize.w;
+
+ // Create the STOP icon only if this is a non-persistent application
+
+ if (!isPersistent())
+ {
+ // Create STOP bitmap container
+
+ m_stopBitmap = new NXWidgets::CRlePaletteBitmap(&g_stopBitmap);
+ if (!m_stopBitmap)
+ {
+ return false;
+ }
+
+ // Create the STOP application icon at the right of the toolbar
+ // Get the height and width of the stop bitmap
+
+ iconSize.w = m_stopBitmap->getWidth();
+ iconSize.h = m_stopBitmap->getHeight();
+
+ // The default CImage has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height.
+ // (We could let CImage do this for us by calling
+ // CImage::getPreferredDimensions())
+
+ iconSize.w += 2 * 1;
+ iconSize.h += 2 * 1;
+
+ // Pick an X/Y position such that the image will position at the right of
+ // the toolbar and centered vertically.
+
+ iconPos.x -= iconSize.w;
+
+ if (iconSize.h >= windowSize.h)
+ {
+ iconPos.y = 0;
+ }
+ else
+ {
+ iconPos.y = (windowSize.h - iconSize.h) >> 1;
+ }
+
+ // Now we have enough information to create the image
+
+ m_stopImage = new NXWidgets::CImage(control, iconPos.x, iconPos.y, iconSize.w,
+ iconSize.h, m_stopBitmap);
+ if (!m_stopImage)
+ {
+ return false;
+ }
+
+ // Configure 'this' to receive mouse click inputs from the image
+
+ m_stopImage->setBorderless(true);
+ m_stopImage->addWidgetEventHandler(this);
+ }
+
+ // Create MINIMIZE application bitmap container
+
+ m_minimizeBitmap = new NXWidgets::CRlePaletteBitmap(&g_minimizeBitmap);
+ if (!m_minimizeBitmap)
+ {
+ return false;
+ }
+
+ // Get the height and width of the stop bitmap
+
+ iconSize.w = m_minimizeBitmap->getWidth();
+ iconSize.h = m_minimizeBitmap->getHeight();
+
+ // The default CImage has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height.
+ // (We could let CImage do this for us by calling
+ // CImage::getPreferredDimensions())
+
+ iconSize.w += 2 * 1;
+ iconSize.h += 2 * 1;
+
+ // Pick an X/Y position such that the image will position at the right of
+ // the toolbar and centered vertically.
+
+ iconPos.x -= iconSize.w;
+
+ if (iconSize.h >= windowSize.h)
+ {
+ iconPos.y = 0;
+ }
+ else
+ {
+ iconPos.y = (windowSize.h - iconSize.h) >> 1;
+ }
+
+ // Now we have enough information to create the image
+
+ m_minimizeImage = new NXWidgets::CImage(control, iconPos.x, iconPos.y, iconSize.w,
+ iconSize.h, m_minimizeBitmap);
+ if (!m_minimizeImage)
+ {
+ return false;
+ }
+
+ // Configure 'this' to receive mouse click inputs from the image
+
+ m_minimizeImage->setBorderless(true);
+ m_minimizeImage->addWidgetEventHandler(this);
+
+ // The rest of the toolbar will hold the left-justified application label
+ // Create the default font instance
+
+ m_windowFont = new NXWidgets::CNxFont(CONFIG_NXWM_DEFAULT_FONTID,
+ CONFIG_NXWM_DEFAULT_FONTCOLOR,
+ CONFIG_NXWM_TRANSPARENT_COLOR);
+ if (!m_windowFont)
+ {
+ return false;
+ }
+
+ // Get the height and width of the text display area
+
+ iconSize.w = iconPos.x;
+ iconSize.h = windowSize.h;
+
+ iconPos.x = 0;
+ iconPos.y = 0;
+
+ // Now we have enough information to create the label
+
+ m_windowLabel = new NXWidgets::CLabel(control, iconPos.x, iconPos.y,
+ iconSize.w, iconSize.h, "");
+ if (!m_windowLabel)
+ {
+ return false;
+ }
+
+ // Configure the label
+
+ m_windowLabel->setBorderless(true);
+ m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT);
+ m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER);
+ m_windowLabel->setRaisesEvents(false);
+ return true;
+}
+
+/**
+ * Re-draw the application window
+ */
+
+void CApplicationWindow::redraw(void)
+{
+ // Get the widget control from the task bar
+
+ NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
+
+ // Get the graphics port for drawing on the background window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Get the size of the window
+
+ struct nxgl_size_s windowSize;
+ if (!m_toolbar->getSize(&windowSize))
+ {
+ return;
+ }
+
+ // Fill the entire tool bar with the non-shadowed border color
+
+ port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXTK_BORDERCOLOR1);
+
+ // Then draw the stop image (which may not be present if this is a
+ // "persistent" application)
+
+ if (m_stopImage)
+ {
+ m_stopImage->enableDrawing();
+ m_stopImage->redraw();
+ m_stopImage->setRaisesEvents(true);
+ }
+
+ // Draw the minimize image
+
+ m_minimizeImage->enableDrawing();
+ m_minimizeImage->redraw();
+ m_minimizeImage->setRaisesEvents(true);
+
+ // And finally draw the window label
+
+ m_windowLabel->enableDrawing();
+ m_windowLabel->redraw();
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+void CApplicationWindow::hide(void)
+{
+ // Disable the stop image (which may not be present if this is a
+ // "persistent" application)
+
+ if (m_stopImage)
+ {
+ m_stopImage->disableDrawing();
+ m_stopImage->setRaisesEvents(false);
+ }
+
+ // Disable the minimize image
+
+ m_minimizeImage->disableDrawing();
+ m_minimizeImage->setRaisesEvents(false);
+
+ // Disable the window label
+
+ m_windowLabel->disableDrawing();
+}
+
+/**
+ * Recover the contained NXTK window instance
+ *
+ * @return. The window used by this application
+ */
+
+NXWidgets::INxWindow *CApplicationWindow::getWindow(void) const
+{
+ return static_cast<NXWidgets::INxWindow*>(m_window);
+}
+
+/**
+ * Recover the contained widget control
+ *
+ * @return. The widget control used by this application
+ */
+
+NXWidgets::CWidgetControl *CApplicationWindow::getWidgetControl(void) const
+{
+ return m_window->getWidgetControl();
+}
+
+/**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ *
+ * @param app. The application to be blocked
+ */
+
+void CApplicationWindow::block(IApplication *app)
+{
+ // Get the widget control from the NXWidgets::CNxWindow instance
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+
+ // And then block further reporting activity on the underlying
+ // NX framed window
+
+ nxtk_block(control->getWindowHandle(), (FAR void *)app);
+}
+
+/**
+ * Set the window label
+ *
+ * @param appname. The name of the application to place on the window
+ */
+
+void CApplicationWindow::setWindowLabel(NXWidgets::CNxString &appname)
+{
+ m_windowLabel->setText(appname);
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CApplicationWindow::isFullScreen(void) const
+{
+ return false;
+}
+
+/**
+ * Register to receive callbacks when toolbar icons are selected
+ */
+
+void CApplicationWindow::registerCallbacks(IApplicationCallback *callback)
+{
+ m_callback = callback;
+}
+
+/**
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CApplicationWindow::clickMinimizePosition(bool click)
+{
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ m_minimizeImage->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ m_minimizeImage->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ m_minimizeImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ m_minimizeImage->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+}
+#endif
+
+/**
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CApplicationWindow::clickStopIcon(bool click)
+{
+ // The stop icon will not be available for "persistent" applications
+
+ if (m_stopImage)
+ {
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ m_stopImage->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ m_stopImage->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ m_stopImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ m_stopImage->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ }
+}
+#endif
+
+/**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+void CApplicationWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
+{
+ // Ignore the event if no callback is registered
+
+ if (m_callback)
+ {
+ // Check the stop application image
+
+ if (m_stopImage && m_stopImage->isClicked())
+ {
+ // Notify the controlling logic that the application should be stopped
+
+ m_callback->close();
+ }
+
+ // Check the minimize image (only if the stop application image is not pressed)
+
+ else if (m_minimizeImage->isClicked())
+ {
+ // Notify the controlling logic that the application should be miminsed
+
+ m_callback->minimize();
+ }
+ }
+}
+
diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx
new file mode 100644
index 000000000..32aeb5ee6
--- /dev/null
+++ b/NxWidgets/nxwm/src/ccalibration.cxx
@@ -0,0 +1,883 @@
+/****************************************************************************
+ * NxWidgets/nxwm/src/ccalibration.cxx
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <cunistd>
+#include <cerrno>
+
+#include <sched.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "ctouchscreen.hxx"
+#include "ccalibration.hxx"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+/****************************************************************************
+ * Configuration
+ */
+
+#ifndef CONFIG_NX
+# error "NX is not enabled (CONFIG_NX)"
+#endif
+
+/**
+ * Positional/size data for the calibration lines and circles
+ */
+
+#define CALIBRATION_LEFTX 40
+#define CALIBRATION_RIGHTX (windowSize.w - 41)
+#define CALIBRATION_TOPY 40
+#define CALIBRATION_BOTTOMY (windowSize.h - 41)
+
+#define CALIBRATION_CIRCLE_RADIUS 16
+#define CALIBRATION_LINE_THICKNESS 2
+
+/****************************************************************************
+ * CCalibration Implementation Classes
+ ****************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CCalibration Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ * @param window. The window to use for the calibration display
+ * @param touchscreen. An instance of the class that wraps the touchscreen
+ * device.
+ */
+
+CCalibration::CCalibration(CTaskbar *taskbar, CFullScreenWindow *window,
+ CTouchscreen *touchscreen)
+{
+ // Initialize state data
+
+ m_taskbar = taskbar;
+ m_window = window;
+ m_touchscreen = touchscreen;
+ m_thread = 0;
+ m_calthread = CALTHREAD_NOTRUNNING;
+ m_calphase = CALPHASE_NOT_STARTED;
+ m_touched = false;
+}
+
+/**
+ * CCalibration Destructor
+ */
+
+CCalibration::~CCalibration(void)
+{
+ // Make sure that the application is not running (it should already
+ // have been stopped)
+
+ stop();
+
+ // Although we did not create the window, the rule is that I have to dispose
+ // of it
+
+ delete m_window;
+}
+
+/**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained IApplicationWindow instance.
+ */
+
+IApplicationWindow *CCalibration::getWindow(void) const
+{
+ return static_cast<IApplicationWindow*>(m_window);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CCalibration::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_CALIBRATION_ICON);
+
+ return bitmap;
+}
+
+/**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+NXWidgets::CNxString CCalibration::getName(void)
+{
+ return NXWidgets::CNxString("Touchscreen Calibration");
+}
+
+/**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+bool CCalibration::run(void)
+{
+ gvdbg("Starting calibration: m_calthread=%d\n", (int)m_calthread);
+
+ return startCalibration(CALTHREAD_STARTED);
+}
+
+/**
+ * Stop the application.
+ */
+
+void CCalibration::stop(void)
+{
+ gvdbg("Stopping calibration: m_calthread=%d\n", (int)m_calthread);
+
+ // Was the calibration thread created?
+
+ if (m_thread != 0)
+ {
+ // Is the calibration thread running?
+
+ if (isRunning())
+ {
+ // The main thread is stuck waiting for the next touchscreen input...
+ // We can signal that we would like the thread to stop, but we will be
+ // stuck here until the next touch
+
+ m_calthread = CALTHREAD_STOPREQUESTED;
+
+ // Try to wake up the calibration thread so that it will see our
+ // terminatin request
+
+ gvdbg("Stopping calibration: m_calthread=%d\n", (int)m_calthread);
+ (void)pthread_kill(m_thread, CONFIG_NXWM_CALIBRATION_SIGNO);
+ }
+ }
+}
+
+/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CCalibration::destroy(void)
+{
+ // Make sure that the application is stopped (should already be stopped)
+
+ stop();
+
+ // Block any further window messages
+
+ m_window->block(this);
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but it is not at the top of the hierarchy)
+ */
+
+void CCalibration::hide(void)
+{
+ gvdbg("Entry\n");
+
+ // Is the calibration thread running?
+
+ if (m_calthread == CALTHREAD_RUNNING || m_calthread == CALTHREAD_SHOW)
+ {
+ // Ask the calibration thread to hide the display
+
+ m_calthread = CALTHREAD_HIDE;
+ (void)pthread_kill(m_thread, CONFIG_NXWM_CALIBRATION_SIGNO);
+ }
+}
+
+/**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is called from
+ * CTaskbar when the application window must be displayed
+ */
+
+void CCalibration::redraw(void)
+{
+ gvdbg("Entry\n");
+
+ // Is the calibration thread running? We might have to restart it if
+ // we have completed the calibration early but are being brought to
+ // top of the display again
+
+ // Is the calibration thread running?
+
+ if (!isRunning())
+ {
+ gvdbg("Starting calibration: m_calthread=%d\n", (int)m_calthread);
+ (void)startCalibration(CALTHREAD_SHOW);
+ }
+
+ // The calibration thread is running. Make sure that is is not
+ // already processing a redraw
+
+ else if (m_calthread != CALTHREAD_SHOW)
+ {
+ // Ask the calibration thread to restart the calibration and redraw the display
+
+ m_calthread = CALTHREAD_SHOW;
+ (void)pthread_kill(m_thread, CONFIG_NXWM_CALIBRATION_SIGNO);
+ }
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CCalibration::isFullScreen(void) const
+{
+ return m_window->isFullScreen();
+}
+
+/**
+ * Accept raw touchscreen input.
+ *
+ * @param sample Touchscreen input sample
+ */
+
+void CCalibration::touchscreenInput(struct touch_sample_s &sample)
+{
+ // Is this a new touch event? Or is it a drag event?
+
+ if ((sample.point[0].flags & (TOUCH_DOWN|TOUCH_MOVE)) != 0)
+ {
+ // Yes.. but ignore drag events if we did not see the matching
+ // touch down event
+
+ if ((sample.point[0].flags & TOUCH_DOWN) != 0 ||
+ (m_touched && sample.point[0].id == m_touchId))
+ {
+ // Yes.. save the touch position and wait for the TOUCH_UP report
+
+ m_touchPos.x = sample.point[0].x;
+ m_touchPos.y = sample.point[0].y;
+
+ gvdbg("Touch id: %d flags: %02x x: %d y: %d h: %d w: %d pressure: %d\n",
+ sample.point[0].id, sample.point[0].flags, sample.point[0].x,
+ sample.point[0].y, sample.point[0].h, sample.point[0].w,
+ sample.point[0].pressure);
+
+ // Show calibration screen again, changing the color of the circle to
+ // make it clear that the touch has been noticed.
+
+ if (!m_touched)
+ {
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_TOUCHEDCOLOR;
+ showCalibration();
+ m_touched = true;
+ }
+
+ // Remember the ID of the touch down event
+
+ m_touchId = sample.point[0].id;
+ }
+ }
+
+ // Was the touch released?
+
+ else if ((sample.point[0].flags & TOUCH_UP) != 0)
+ {
+ // Yes.. did we see the pen down event?
+
+ if (m_touched)
+ {
+ // Yes.. For the matching touch ID?
+
+ if (sample.point[0].id == m_touchId)
+ {
+ // Yes.. invoke the state machine.
+
+ gvdbg("State: %d Screen x: %d y: %d Touch x: %d y: %d\n",
+ m_calphase, m_screenInfo.pos.x, m_screenInfo.pos.y,
+ m_touchPos.x, m_touchPos.y);
+
+ stateMachine();
+ }
+ else
+ {
+ // No... restore the un-highlighted circle
+
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_CIRCLECOLOR;
+ showCalibration();
+ }
+ }
+
+ // In any event, the screen is not touched
+
+ m_touched = false;
+ }
+}
+
+/**
+ * Start the calibration thread.
+ *
+ * @param initialState. The initial state of the calibration thread
+ * @return True if the thread was successfully started.
+ */
+
+bool CCalibration::startCalibration(enum ECalThreadState initialState)
+{
+
+ // Verify that the thread is not already running
+
+ if (isRunning())
+ {
+ gdbg("The calibration thread is already running\n");
+ return false;
+ }
+
+ // Configure the calibration thread
+
+ pthread_attr_t attr;
+ (void)pthread_attr_init(&attr);
+
+ struct sched_param param;
+ param.sched_priority = CONFIG_NXWM_CALIBRATION_LISTENERPRIO;
+ (void)pthread_attr_setschedparam(&attr, &param);
+
+ (void)pthread_attr_setstacksize(&attr, CONFIG_NXWM_CALIBRATION_LISTENERSTACK);
+
+ // Set the initial state of the thread
+
+ m_calthread = initialState;
+
+ // Start the thread that will perform the calibration process
+
+ int ret = pthread_create(&m_thread, &attr, calibration, (FAR void *)this);
+ if (ret != 0)
+ {
+ gdbg("pthread_create failed: %d\n", ret);
+ return false;
+ }
+
+ // Detach from the pthread so that we do not have any memory leaks
+
+ (void)pthread_detach(m_thread);
+
+ gvdbg("Calibration thread m_calthread=%d\n", (int)m_calthread);
+ return true;
+}
+
+/**
+ * The calibration thread. This is the entry point of a thread that provides the
+ * calibration displays, waits for input, and collects calibration data.
+ *
+ * @param arg. The CCalibration 'this' pointer cast to a void*.
+ * @return This function always returns NULL when the thread exits
+ */
+
+FAR void *CCalibration::calibration(FAR void *arg)
+{
+ CCalibration *This = (CCalibration *)arg;
+ bool stalled = true;
+
+ // The calibration thread is now running
+
+ This->m_calthread = CALTHREAD_RUNNING;
+ This->m_calphase = CALPHASE_NOT_STARTED;
+ gvdbg("Started: m_calthread=%d\n", (int)This->m_calthread);
+
+ // Loop until calibration completes or we have been requested to terminate
+
+ while (This->m_calthread != CALTHREAD_STOPREQUESTED &&
+ This->m_calphase != CALPHASE_COMPLETE)
+ {
+ // Check for state changes due to display order changes
+
+ if (This->m_calthread == CALTHREAD_HIDE)
+ {
+ // This state is set by hide() when our display is no longer visible
+
+ This->m_calthread = CALTHREAD_RUNNING;
+ This->m_calphase = CALPHASE_NOT_STARTED;
+ stalled = true;
+ }
+ else if (This->m_calthread == CALTHREAD_SHOW)
+ {
+ // This state is set by redraw() when our display has become visible
+
+ This->m_calthread = CALTHREAD_RUNNING;
+ This->m_calphase = CALPHASE_NOT_STARTED;
+ stalled = false;
+ This->stateMachine();
+ }
+
+ // The calibration thread will stall if has been asked to hide the
+ // display. While stalled, we will just sleep for a bit abd test
+ // the state again. If we are re-awakened by a redraw(), then we
+ // will be given a signal which will wake us up immediately.
+ //
+ // Note that stalled is also initially true so we have to receive
+ // redraw() before we attempt to draw anything
+
+ if (stalled)
+ {
+ // Sleep for a while (or until we receive a signal)
+
+ std::usleep(500*1000);
+ }
+ else
+ {
+ // Wait for the next raw touchscreen input (or possibly a signal)
+
+ struct touch_sample_s sample;
+ while (!This->m_touchscreen->waitRawTouchData(&sample) &&
+ This->m_calthread == CALTHREAD_RUNNING);
+
+ // Then process the raw touchscreen input
+
+ if (This->m_calthread == CALTHREAD_RUNNING)
+ {
+ This->touchscreenInput(sample);
+ }
+ }
+ }
+
+ // Perform the final steps of calibration
+
+ This->finishCalibration();
+
+ gvdbg("Terminated: m_calthread=%d\n", (int)This->m_calthread);
+ return (FAR void *)0;
+}
+
+/**
+ * This is the calibration state machine. It is called initially and then
+ * as new touchscreen data is received.
+ */
+
+void CCalibration::stateMachine(void)
+{
+ gvdbg("Old m_calphase=%d\n", m_calphase);
+
+ // Recover the window instance contained in the full screen window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the size of the fullscreen window
+
+ struct nxgl_size_s windowSize;
+ if (!window->getSize(&windowSize))
+ {
+ return;
+ }
+
+ switch (m_calphase)
+ {
+ default:
+ case CALPHASE_NOT_STARTED:
+ {
+ // Clear the entire screen
+ // Get the widget control associated with the full screen window
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+
+ // Get the CCGraphicsPort instance for this window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR);
+
+ // Then draw the first calibration screen
+
+ m_screenInfo.pos.x = CALIBRATION_LEFTX;
+ m_screenInfo.pos.y = CALIBRATION_TOPY;
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_LINECOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_CIRCLECOLOR;
+ showCalibration();
+
+ // Then set up the current state
+
+ m_calphase = CALPHASE_UPPER_LEFT;
+ }
+ break;
+
+ case CALPHASE_UPPER_LEFT:
+ {
+ // A touch has been received while in the CALPHASE_UPPER_LEFT state.
+ // Save the touch data and set up the next calibration display
+
+ m_calibData[CALIB_UPPER_LEFT_INDEX].x = m_touchPos.x;
+ m_calibData[CALIB_UPPER_LEFT_INDEX].y = m_touchPos.y;
+
+ // Clear the previous screen by re-drawing it using the backgro9und
+ // color. That is much faster than clearing the whole display
+
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ showCalibration();
+
+ // Then draw the next calibration screen
+
+ m_screenInfo.pos.x = CALIBRATION_RIGHTX;
+ m_screenInfo.pos.y = CALIBRATION_TOPY;
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_LINECOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_CIRCLECOLOR;
+ showCalibration();
+
+ // Then set up the current state
+
+ m_calphase = CALPHASE_UPPER_RIGHT;
+ }
+ break;
+
+ case CALPHASE_UPPER_RIGHT:
+ {
+ // A touch has been received while in the CALPHASE_UPPER_RIGHT state.
+ // Save the touch data and set up the next calibration display
+
+ m_calibData[CALIB_UPPER_RIGHT_INDEX].x = m_touchPos.x;
+ m_calibData[CALIB_UPPER_RIGHT_INDEX].y = m_touchPos.y;
+
+ // Clear the previous screen by re-drawing it using the backgro9und
+ // color. That is much faster than clearing the whole display
+
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ showCalibration();
+
+ // Then draw the next calibration screen
+
+ m_screenInfo.pos.x = CALIBRATION_RIGHTX;
+ m_screenInfo.pos.y = CALIBRATION_BOTTOMY;
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_LINECOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_CIRCLECOLOR;
+ showCalibration();
+
+ // Then set up the current state
+
+ m_calphase = CALPHASE_LOWER_RIGHT;
+ }
+ break;
+
+ case CALPHASE_LOWER_RIGHT:
+ {
+ // A touch has been received while in the CALPHASE_LOWER_RIGHT state.
+ // Save the touch data and set up the next calibration display
+
+ m_calibData[CALIB_LOWER_RIGHT_INDEX].x = m_touchPos.x;
+ m_calibData[CALIB_LOWER_RIGHT_INDEX].y = m_touchPos.y;
+
+ // Clear the previous screen by re-drawing it using the backgro9und
+ // color. That is much faster than clearing the whole display
+
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ showCalibration();
+
+ // Then draw the next calibration screen
+
+ m_screenInfo.pos.x = CALIBRATION_LEFTX;
+ m_screenInfo.pos.y = CALIBRATION_BOTTOMY;
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_LINECOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_CIRCLECOLOR;
+ showCalibration();
+
+ // Then set up the current state
+
+ m_calphase = CALPHASE_LOWER_LEFT;
+ }
+ break;
+
+ case CALPHASE_LOWER_LEFT:
+ {
+ // A touch has been received while in the CALPHASE_LOWER_LEFT state.
+ // Save the touch data and set up the next calibration display
+
+ m_calibData[CALIB_LOWER_LEFT_INDEX].x = m_touchPos.x;
+ m_calibData[CALIB_LOWER_LEFT_INDEX].y = m_touchPos.y;
+
+ // Clear the previous screen by re-drawing it using the backgro9und
+ // color. That is much faster than clearing the whole display
+
+ m_screenInfo.lineColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ m_screenInfo.circleFillColor = CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR;
+ showCalibration();
+
+ // Inform any waiter that calibration is complete
+
+ m_calphase = CALPHASE_COMPLETE;
+ }
+ break;
+
+ case CALPHASE_COMPLETE:
+ // Might happen... do nothing if it does
+ break;
+ }
+
+ gvdbg("New m_calphase=%d Screen x: %d y: %d\n",
+ m_calphase, m_screenInfo.pos.x, m_screenInfo.pos.y);
+}
+
+/**
+ * Presents the next calibration screen
+ *
+ * @param screenInfo Describes the next calibration screen
+ */
+
+void CCalibration::showCalibration(void)
+{
+ // Recover the window instance contained in the full screen window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the widget control associated with the full screen window
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+
+ // Get the CCGraphicsPort instance for this window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Get the size of the fullscreen window
+
+ struct nxgl_size_s windowSize;
+ if (!window->getSize(&windowSize))
+ {
+ return;
+ }
+
+ // Draw the circle at the center of the touch position
+
+ port->drawFilledCircle(&m_screenInfo.pos, CALIBRATION_CIRCLE_RADIUS,
+ m_screenInfo.circleFillColor);
+
+ /* Draw horizontal line */
+
+ port->drawFilledRect(0, m_screenInfo.pos.y, windowSize.w, CALIBRATION_LINE_THICKNESS,
+ m_screenInfo.lineColor);
+
+ /* Draw vertical line */
+
+ port->drawFilledRect(m_screenInfo.pos.x, 0, CALIBRATION_LINE_THICKNESS, windowSize.h,
+ m_screenInfo.lineColor);
+}
+
+/**
+ * Finish calibration steps and provide the calibration data to the
+ * touchscreen driver.
+ */
+
+void CCalibration::finishCalibration(void)
+{
+ // Did we finish calibration successfully?
+
+ if (m_calphase == CALPHASE_COMPLETE)
+ {
+ // Yes... Get the final Calibration data
+
+ struct SCalibrationData caldata;
+ if (createCalibrationData(caldata))
+ {
+ // And provide this to the touchscreen, enabling touchscreen processing
+
+ m_touchscreen->setEnabled(false);
+ m_touchscreen->setCalibrationData(caldata);
+ m_touchscreen->setEnabled(true);
+ }
+ }
+
+ // Remove the touchscreen application from the taskbar
+
+ m_taskbar->stopApplication(this);
+
+ // And set the terminated stated
+
+ m_calthread = CALTHREAD_TERMINATED;
+}
+
+/**
+ * Given the raw touch data collected by the calibration thread, create the
+ * massaged calibration data needed by CTouchscreen.
+ *
+ * @param data. A reference to the location to save the calibration data
+ * @return True if the calibration data was successfully created.
+ */
+
+bool CCalibration::createCalibrationData(struct SCalibrationData &data)
+{
+ // Recover the window instance contained in the full screen window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the size of the fullscreen window
+
+ struct nxgl_size_s windowSize;
+ if (!window->getSize(&windowSize))
+ {
+ gdbg("NXWidgets::INxWindow::getSize failed\n");
+ return false;
+ }
+
+ // Calculate the calibration parameters
+ //
+ // (scaledX - LEFTX) / (rawX - leftX) = (RIGHTX - LEFTX) / (rightX - leftX)
+ // scaledX = (rawX - leftX) * (RIGHTX - LEFTX) / (rightX - leftX) + LEFTX
+ // = rawX * xSlope + (LEFTX - leftX * xSlope)
+ // = rawX * xSlope + xOffset
+ //
+ // where:
+ // xSlope = (RIGHTX - LEFTX) / (rightX - leftX)
+ // xOffset = (LEFTX - leftX * xSlope)
+
+ b16_t leftX = (m_calibData[CALIB_UPPER_LEFT_INDEX].x +
+ m_calibData[CALIB_LOWER_LEFT_INDEX].x) << 15;
+ b16_t rightX = (m_calibData[CALIB_UPPER_RIGHT_INDEX].x +
+ m_calibData[CALIB_LOWER_RIGHT_INDEX].x) << 15;
+
+ data.xSlope = b16divb16(itob16(CALIBRATION_RIGHTX - CALIBRATION_LEFTX), (rightX - leftX));
+ data.xOffset = itob16(CALIBRATION_LEFTX) - b16mulb16(leftX, data.xSlope);
+
+ gdbg("New xSlope: %08x xOffset: %08x\n", data.xSlope, data.xOffset);
+
+ // Similarly for Y
+ //
+ // (scaledY - TOPY) / (rawY - topY) = (BOTTOMY - TOPY) / (bottomY - topY)
+ // scaledY = (rawY - topY) * (BOTTOMY - TOPY) / (bottomY - topY) + TOPY
+ // = rawY * ySlope + (TOPY - topY * ySlope)
+ // = rawY * ySlope + yOffset
+ //
+ // where:
+ // ySlope = (BOTTOMY - TOPY) / (bottomY - topY)
+ // yOffset = (TOPY - topY * ySlope)
+
+ b16_t topY = (m_calibData[CALIB_UPPER_LEFT_INDEX].y +
+ m_calibData[CALIB_UPPER_RIGHT_INDEX].y) << 15;
+ b16_t bottomY = (m_calibData[CALIB_LOWER_LEFT_INDEX].y +
+ m_calibData[CALIB_LOWER_RIGHT_INDEX].y) << 15;
+
+ data.ySlope = b16divb16(itob16(CALIBRATION_BOTTOMY - CALIBRATION_TOPY), (bottomY - topY));
+ data.yOffset = itob16(CALIBRATION_TOPY) - b16mulb16(topY, data.ySlope);
+
+ gdbg("New ySlope: %08x yOffset: %08x\n", data.ySlope, data.yOffset);
+ return true;
+}
+
+/**
+ * CCalibrationFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate calibration
+ * @param touchscreen. An instance of the class that wraps the
+ * touchscreen device.
+ */
+
+CCalibrationFactory::CCalibrationFactory(CTaskbar *taskbar, CTouchscreen *touchscreen)
+{
+ m_taskbar = taskbar;
+ m_touchscreen = touchscreen;
+}
+
+/**
+ * Create a new instance of an CCalibration (as IApplication).
+ */
+
+IApplication *CCalibrationFactory::create(void)
+{
+ // Call CTaskBar::openFullScreenWindow to create a full screen window for
+ // the calibation application
+
+ CFullScreenWindow *window = m_taskbar->openFullScreenWindow();
+ if (!window)
+ {
+ gdbg("ERROR: Failed to create CFullScreenWindow\n");
+ return (IApplication *)0;
+ }
+
+ // Open the window (it is hot in here)
+
+ if (!window->open())
+ {
+ gdbg("ERROR: Failed to open CFullScreenWindow \n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ // Instantiate the application, providing the window to the application's
+ // constructor
+
+ CCalibration *calibration = new CCalibration(m_taskbar, window, m_touchscreen);
+ if (!calibration)
+ {
+ gdbg("ERROR: Failed to instantiate CCalibration\n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ return static_cast<IApplication*>(calibration);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CCalibrationFactory::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_CALIBRATION_ICON);
+
+ return bitmap;
+}
diff --git a/NxWidgets/nxwm/src/cfullscreenwindow.cxx b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
new file mode 100644
index 000000000..6ec5bf802
--- /dev/null
+++ b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
@@ -0,0 +1,217 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/cfullscreenwindow.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "cgraphicsport.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "cfullscreenwindow.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CFullScreenWindow Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CFullScreenWindow Constructor
+ *
+ * @param window. The raw window to be used by this application.
+ */
+
+CFullScreenWindow::CFullScreenWindow(NXWidgets::CNxWindow *window)
+{
+ // Save the window for later use
+
+ m_window = window;
+}
+
+/**
+ * CFullScreenWindow Destructor
+ */
+
+CFullScreenWindow::~CFullScreenWindow(void)
+{
+ // We didn't create the window. That was done by the task bar,
+ // But we will handle destruction of with window as a courtesy.
+
+ if (m_window)
+ {
+ delete m_window;
+ }
+}
+
+/**
+ * Initialize window. Window initialization is separate from
+ * object instantiation so that failures can be reported.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+bool CFullScreenWindow::open(void)
+{
+ return true;
+}
+
+/**
+ * Re-draw the application window
+ */
+
+void CFullScreenWindow::redraw(void)
+{
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ */
+
+void CFullScreenWindow::hide(void)
+{
+}
+
+/**
+ * Recover the contained raw window instance
+ *
+ * @return. The window used by this application
+ */
+
+NXWidgets::INxWindow *CFullScreenWindow::getWindow(void) const
+{
+ return static_cast<NXWidgets::INxWindow*>(m_window);
+}
+
+/**
+ * Recover the contained widget control
+ *
+ * @return. The widget control used by this application
+ */
+
+NXWidgets::CWidgetControl *CFullScreenWindow::getWidgetControl(void) const
+{
+ return m_window->getWidgetControl();
+}
+
+/**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ *
+ * @param app. The application to be blocked
+ */
+
+void CFullScreenWindow::block(IApplication *app)
+{
+ // Get the widget control from the NXWidgets::CNxWindow instance
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+
+ // And then block further reporting activity on the underlying
+ // NX raw window
+
+ nx_block(control->getWindowHandle(), (FAR void *)app);
+}
+
+/**
+ * Set the window label
+ *
+ * @param appname. The name of the application to place on the window
+ */
+
+void CFullScreenWindow::setWindowLabel(NXWidgets::CNxString &appname)
+{
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CFullScreenWindow::isFullScreen(void) const
+{
+ return true;
+}
+
+/**
+ * Register to receive callbacks when toolbar icons are selected
+ */
+
+void CFullScreenWindow::registerCallbacks(IApplicationCallback *callback)
+{
+}
+
+/**
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CFullScreenWindow::clickMinimizePosition(bool click)
+{
+}
+#endif
+
+/**
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CFullScreenWindow::clickStopIcon(bool click)
+{
+}
+#endif
+
+
diff --git a/NxWidgets/nxwm/src/chexcalculator.cxx b/NxWidgets/nxwm/src/chexcalculator.cxx
new file mode 100644
index 000000000..167c114b7
--- /dev/null
+++ b/NxWidgets/nxwm/src/chexcalculator.cxx
@@ -0,0 +1,1020 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/chexcalculator.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cstdio>
+#include <debug.h>
+
+#include "cwidgetcontrol.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "chexcalculator.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Private Types
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Private Data
+ ********************************************************************************************/
+
+namespace NxWM
+{
+ /**
+ * This enumeration value describes a key
+ */
+
+ enum EKeyType
+ {
+ KEY_NONE = 0, // Used to represent no pending operation
+
+ // Values: {0-9, A-F}
+
+ KEY_VALUE, // Key is a value
+
+ // Unary operators
+
+ KEY_NOT, // 1's complement
+ KEY_NEGATE, // 2's complement
+
+ // Binary operators
+
+ KEY_XOR, // Exclusive OR
+ KEY_DIVIDE, // Division
+ KEY_RSH, // Right shift
+ KEY_LSH, // Left shift
+ KEY_MULTIPLY, // Multiplication
+ KEY_AND, // Bit-wise AND
+ KEY_OR, // Bit-wise OR
+ KEY_MINUS, // Subtraction
+ KEY_PLUS, // Additions
+
+ // Special operations
+
+ KEY_EQUAL, // Equal/Enter key
+
+ KEY_DECIMAL, // Decimal mode
+ KEY_HEXADECIMAL, // Hexadecimal mode
+
+ KEY_MRECALL, // Recall from memory
+ KEY_MPLUS, // Add to memory
+ KEY_MMINUS, // Subtract from memory
+
+ KEY_MCLR, // Clear memory
+ KEY_CLRENTRY, // Clear entry
+ KEY_CLR // Clear all
+ };
+
+ /**
+ * This structure value describes a key
+ */
+
+ struct SKeyDesc
+ {
+ uint16_t hexMode : 1; // Key applies in hex mode
+ uint16_t decMode : 1; // Key applies in decimal mode
+ uint16_t keyType : 5; // Describes the key (see enum EKeyType)
+ uint16_t value : 4; // Value (if the key has an associated value)
+ };
+
+ /**
+ * This array provides the possible labels for each key
+ */
+
+ static FAR const char *g_labels[NXWM_HEXCALCULATOR_NCOLUMNS*NXWM_HEXCALCULATOR_NROWS] =
+ {
+ "MR", "M+", "M-", "MC", "CE", "C",
+ "A", "B", "C", "D", "E", "F",
+ "NOT", "XOR", "7", "8", "9", "/",
+ "RSH", "LSH", "4", "5", "6", "*",
+ "AND", "OR", "1", "2", "3", "-",
+ "DEC", "HEX", "+/-", "0", "=", "+"
+ };
+
+ /**
+ * This array manages the behavior when each key is pressed
+ */
+
+ static struct SKeyDesc g_keyDesc[NXWM_HEXCALCULATOR_NCOLUMNS*NXWM_HEXCALCULATOR_NROWS] =
+ {
+ {1, 1, KEY_MRECALL, 0},
+ {1, 1, KEY_MPLUS, 0},
+ {1, 1, KEY_MMINUS, 0},
+ {1, 1, KEY_MCLR, 0},
+ {1, 1, KEY_CLRENTRY, 0},
+ {1, 1, KEY_CLR, 0},
+
+ {1, 0, KEY_VALUE, 10},
+ {1, 0, KEY_VALUE, 11},
+ {1, 0, KEY_VALUE, 12},
+ {1, 0, KEY_VALUE, 13},
+ {1, 0, KEY_VALUE, 14},
+ {1, 0, KEY_VALUE, 15},
+
+ {1, 0, KEY_NOT, 0},
+ {1, 0, KEY_XOR, 0},
+ {1, 1, KEY_VALUE, 7},
+ {1, 1, KEY_VALUE, 8},
+ {1, 1, KEY_VALUE, 9},
+ {1, 1, KEY_DIVIDE, 0},
+
+ {1, 0, KEY_RSH, 0},
+ {1, 0, KEY_LSH, 0},
+ {1, 1, KEY_VALUE, 4},
+ {1, 1, KEY_VALUE, 5},
+ {1, 1, KEY_VALUE, 6},
+ {1, 1, KEY_MULTIPLY, 0},
+
+ {1, 0, KEY_AND, 0},
+ {1, 0, KEY_OR, 0},
+ {1, 1, KEY_VALUE, 1},
+ {1, 1, KEY_VALUE, 2},
+ {1, 1, KEY_VALUE, 3},
+ {1, 1, KEY_MINUS, 0},
+
+ {1, 0, KEY_DECIMAL, 0},
+ {0, 1, KEY_HEXADECIMAL, 0},
+ {1, 1, KEY_NEGATE, 0},
+ {1, 1, KEY_VALUE, 0},
+ {1, 1, KEY_EQUAL, 0},
+ {1, 1, KEY_PLUS, 0}
+ };
+}
+
+/********************************************************************************************
+ * Private Functions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CHexCalculator Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CHexCalculator constructor
+ *
+ * @param window. The application window
+ */
+
+CHexCalculator::CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window)
+{
+ // Save the constructor data
+
+ m_taskbar = taskbar;
+ m_window = window;
+
+ // Nullify widgets that will be instantiated when the window is started
+
+ m_keypad = (NXWidgets::CButtonArray *)0;
+ m_text = (NXWidgets::CLabel *)0;
+ m_font = (NXWidgets::CNxFont *)0;
+
+ // Reset other values
+
+ m_accum = 0; // The accumulator is initially zero
+ m_memory = 0; // No value in memory
+ m_high.operation = (uint8_t)KEY_NONE; // No pending high precedence operation
+ m_high.value = 0;
+ m_low.operation = (uint8_t)KEY_NONE; // No pending high precedence operation
+ m_low.value = 0;
+ m_hexMode = false; // Decimal mode
+ m_result = false; // Accumulator does not hot a result
+
+ // Add our personalized window label
+
+ NXWidgets::CNxString myName = getName();
+ window->setWindowLabel(myName);
+
+ // Add our callbacks with the application window
+
+ window->registerCallbacks(static_cast<IApplicationCallback *>(this));
+
+ // Set the geometry of the calculator
+
+ setGeometry();
+}
+
+/**
+ * CHexCalculator destructor
+ *
+ * @param window. The application window
+ */
+
+CHexCalculator::~CHexCalculator(void)
+{
+ // Destroy widgets
+
+ if (m_text)
+ {
+ delete m_text;
+ }
+
+ if (m_keypad)
+ {
+ delete m_keypad;
+ }
+
+ if (m_font)
+ {
+ delete m_font;
+ }
+
+ // Although we didn't create it, we are responsible for deleting the
+ // application window
+
+ delete m_window;
+}
+
+/**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+IApplicationWindow *CHexCalculator::getWindow(void) const
+{
+ return static_cast<IApplicationWindow*>(m_window);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CHexCalculator::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_HEXCALCULATOR_ICON);
+
+ return bitmap;
+}
+
+/**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+NXWidgets::CNxString CHexCalculator::getName(void)
+{
+ return NXWidgets::CNxString("Hex Calculator");
+}
+
+/**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+bool CHexCalculator::run(void)
+{
+ // Create the widgets (if we have not already done so)
+
+ if (!m_keypad)
+ {
+ // Create the widgets
+
+ if (!createCalculator())
+ {
+ gdbg("ERROR: Failed to create widgets\n");
+ return false;
+ }
+
+ // Apply initial labels
+
+ labelKeypad();
+ }
+
+ return true;
+}
+
+/**
+ * Stop the application.
+ */
+
+void CHexCalculator::stop(void)
+{
+ // Just disable further drawing
+
+ m_keypad->disableDrawing();
+ m_keypad->setRaisesEvents(false);
+
+ m_text->disableDrawing();
+}
+
+/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CHexCalculator::destroy(void)
+{
+ // Make sure that the widgets are stopped
+
+ stop();
+
+ // Block any further window messages
+
+ m_window->block(this);
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+void CHexCalculator::hide(void)
+{
+ // Disable drawing and events
+
+ stop();
+}
+
+/**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+void CHexCalculator::redraw(void)
+{
+ // Get the widget control associated with the application window
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+
+ // Get the CCGraphicsPort instance for this window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, m_windowSize.w, m_windowSize.h,
+ CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR);
+
+ // Enable and redraw widgets
+
+ m_keypad->enableDrawing();
+ m_keypad->redraw();
+ m_keypad->setRaisesEvents(true);
+
+ m_text->enableDrawing();
+ m_text->redraw();
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CHexCalculator::isFullScreen(void) const
+{
+ return m_window->isFullScreen();
+}
+
+/**
+ * Select the geometry of the calculator given the current window size.
+ */
+
+void CHexCalculator::setGeometry(void)
+{
+ // Recover the NXTK window instance contained in the application window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the size of the window
+
+ (void)window->getSize(&m_windowSize);
+
+ // Pick a height and width of a button to fill the entire window.
+ // For the height, we will assume that the text window is 1.5 times
+ // as high as a button
+
+ m_buttonSize.w = m_windowSize.w / NXWM_HEXCALCULATOR_NCOLUMNS;
+ m_buttonSize.h = (m_windowSize.h << 1) / (2 * NXWM_HEXCALCULATOR_NROWS + 3);
+
+ // Limit aspect ratio. (1) Button should no be taller than it is wide,
+ // (2) Button should be no more than twice as wide as it is tall.
+
+ if (m_buttonSize.h > m_buttonSize.w)
+ {
+ m_buttonSize.h = m_buttonSize.w;
+ }
+ else if (m_buttonSize.w > (m_buttonSize.h << 1))
+ {
+ m_buttonSize.w = (m_buttonSize.h << 1);
+ }
+
+ // Get the size of the entry calculator m_keypad
+
+ m_keypadSize.w = NXWM_HEXCALCULATOR_NCOLUMNS * m_buttonSize.w;
+ m_keypadSize.h = NXWM_HEXCALCULATOR_NROWS * m_buttonSize.h;
+
+ // Get the size of the text box. Same width as the m_keypad
+
+ m_textSize.w = m_keypadSize.w;
+ m_textSize.h = m_windowSize.h - m_keypadSize.h;
+
+ // Limit the height of the text box to twice the height of a button.
+
+ if (m_textSize.h > (m_buttonSize.h << 1))
+ {
+ m_textSize.h = (m_buttonSize.h << 1);
+ }
+
+ // Pick an X/Y position such that the m_keypad+textbox will be centered
+ // in the display
+
+ struct nxgl_point_s calculatorPos;
+ calculatorPos.x = (m_windowSize.w - m_keypadSize.w) >> 1;
+ calculatorPos.y = (m_windowSize.h - m_textSize.h - m_keypadSize.h) >> 1;
+
+ // Now pick the set of the text box and the m_keypad
+
+ m_textPos.x = calculatorPos.x;
+ m_textPos.y = calculatorPos.y;
+
+ m_keypadPos.x = calculatorPos.x;
+ m_keypadPos.y = calculatorPos.y + m_textSize.h;
+}
+
+/**
+ * Create the calculator widgets. Only start as part of the applicaiton
+ * start method.
+ */
+
+bool CHexCalculator::createCalculator(void)
+{
+ // Select a font for the calculator
+
+ m_font = new NXWidgets::CNxFont((nx_fontid_e)CONFIG_NXWM_HEXCALCULATOR_FONTID,
+ CONFIG_NXWM_DEFAULT_FONTCOLOR,
+ CONFIG_NXWM_TRANSPARENT_COLOR);
+ if (!m_font)
+ {
+ gdbg("ERROR failed to create font\n");
+ return false;
+ }
+
+ // Get the widget control associated with the application window
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+
+ // Create the button array
+
+ m_keypad = new NXWidgets::CButtonArray(control,
+ m_keypadPos.x, m_keypadPos.y,
+ NXWM_HEXCALCULATOR_NCOLUMNS,
+ NXWM_HEXCALCULATOR_NROWS,
+ m_buttonSize.w, m_buttonSize.h);
+ if (!m_keypad)
+ {
+ gdbg("ERROR: Failed to create CButtonArray\n");
+ return false;
+ }
+
+ // Disable drawing and events until we are asked to redraw the window
+
+ m_keypad->disableDrawing();
+ m_keypad->setRaisesEvents(false);
+
+ // Select the font
+
+ m_keypad->setFont(m_font);
+
+ // Register to receive events from the keypad
+
+ m_keypad->addWidgetEventHandler(this);
+
+ // Create a label to show the accumulator. A simple label is used
+ // because the power of a text box is un-necessary in this application.
+
+ m_text = new NXWidgets::CLabel(control,
+ m_textPos.x, m_textPos.y,
+ m_textSize.w, m_textSize.h,
+ "0");
+ if (!m_text)
+ {
+ gdbg("ERROR: Failed to create CLabel\n");
+ return false;
+ }
+
+ // Align text on the left
+
+ m_text->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_RIGHT);
+
+ // Disable drawing and events until we are asked to redraw the window
+
+ m_text->disableDrawing();
+ m_text->setRaisesEvents(false);
+
+ // Select the font
+
+ m_text->setFont(m_font);
+ return true;
+}
+
+/**
+ * Applies labels to the keys.
+ */
+
+void CHexCalculator::labelKeypad(void)
+{
+ // Make sure that drawing is disabled from this operation
+
+ bool isEnabled = m_keypad->isDrawingEnabled();
+ m_keypad->disableDrawing();
+
+ // Add the labels to each button.
+
+ for (int j = 0; j < NXWM_HEXCALCULATOR_NROWS; j++)
+ {
+ for (int i = 0; i < NXWM_HEXCALCULATOR_NCOLUMNS; i++)
+ {
+ int index = j * NXWM_HEXCALCULATOR_NCOLUMNS + i;
+
+ // What mode are we in? Does the button label appear in this mode?
+
+ FAR const char *label;
+ if ((m_hexMode && g_keyDesc[index].hexMode) ||
+ (!m_hexMode && g_keyDesc[index].decMode))
+ {
+ label = g_labels[index];
+ }
+ else
+ {
+ label = "";
+ }
+
+ // Set the text in the label
+
+ m_keypad->setText(i, j, label);
+ }
+ }
+
+ // Then redraw the display
+
+ if (isEnabled)
+ {
+ m_keypad->enableDrawing();
+ m_keypad->redraw();
+ }
+}
+
+/**
+ * Evaluate a binary operation. The result is left in m_accum.
+ *
+ * @param value1. The first value
+ * @param value2. The second value
+ *
+ * @return The result of the operation
+ */
+
+int64_t CHexCalculator::evaluateBinaryOperation(uint8_t operation, int64_t value1, int64_t value2)
+{
+ switch (operation)
+ {
+ case KEY_NONE: // Do nothing if there is no pending operation
+ return 0;
+
+ case KEY_XOR: // Exclusive OR
+ return value1 ^ value2;
+
+ case KEY_DIVIDE: // Division
+ return value1 / value2;
+
+ case KEY_RSH: // Right shift
+ return value1 >> value2;
+
+ case KEY_LSH: // Left shift
+ return value1 << value2;
+
+ case KEY_MULTIPLY: // Multiplication
+ return value1 * value2;
+
+ case KEY_AND: // Bit-wise AND
+ return value1 & value2;
+
+ case KEY_OR: // Bit-wise OR
+ return value1 | value2;
+
+ case KEY_MINUS: // Subtraction
+ return value1 - value2;
+
+ case KEY_PLUS: // Additions
+ return value1 + value2;
+
+ default:
+ gdbg("ERROR: Unexpected pending operation %d\n", m_pending);
+ return 0;
+ }
+}
+
+/**
+ * Show the current value of the accumulator.
+ */
+
+void CHexCalculator::updateText(void)
+{
+ char buffer[24];
+
+ if (m_hexMode)
+ {
+ std::snprintf(buffer, 24, "%16llX", m_accum);
+ }
+ else
+ {
+ std::snprintf(buffer, 24, "%lld", m_accum);
+ }
+
+ // setText will perform the redraw as well
+
+ m_text->setText(buffer);
+}
+
+/**
+ * Called when the window minimize button is pressed.
+ */
+
+void CHexCalculator::minimize(void)
+{
+ m_taskbar->minimizeApplication(static_cast<IApplication*>(this));
+}
+
+/**
+ * Called when the window close button is pressed.
+ */
+
+void CHexCalculator::close(void)
+{
+ m_taskbar->stopApplication(static_cast<IApplication*>(this));
+}
+
+/**
+ * Handle a widget action event. For CButtonArray, this is a button pre-
+ * release event.
+ *
+ * @param e The event data.
+ */
+
+void CHexCalculator::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
+{
+ // A button should now be clicked
+
+ int column;
+ int row;
+
+ if (m_keypad->isButtonClicked(column, row))
+ {
+ // Handle the key according to its type
+
+ int index = row * NXWM_HEXCALCULATOR_NCOLUMNS + column;
+
+ // First, make sure that the keypress is valid in this mode
+
+ if ((m_hexMode && !g_keyDesc[index].hexMode) ||
+ (!m_hexMode && !g_keyDesc[index].decMode))
+ {
+ // Ignore the key in this mode
+
+ return;
+ }
+
+ // Process the keypress
+
+ bool result = false;
+ switch (g_keyDesc[index].keyType)
+ {
+ // Values: {0-9, A-F}
+
+ case KEY_VALUE: // Key is a value
+ {
+ // If the accumulator current holds the result of a previous
+ // operation, then start fresh
+
+ if (m_result)
+ {
+ m_accum = (uint64_t)g_keyDesc[index].value;
+ }
+
+ // Otherwise, add the new value to the accumulator. The way
+ // in which it is added depends on the mode
+
+ else if (m_hexMode)
+ {
+ m_accum <<= 4;
+ m_accum |= (uint64_t)g_keyDesc[index].value;
+ }
+ else
+ {
+ m_accum *= 10;
+ m_accum += (uint64_t)g_keyDesc[index].value;
+ }
+ updateText();
+ }
+ break;
+
+ // Unary operators
+
+ case KEY_NOT: // 1's complement
+ {
+ m_accum = ~m_accum;
+ updateText();
+ }
+ break;
+
+ case KEY_NEGATE: // 2's complement
+ {
+ m_accum = -m_accum;
+ updateText();
+ }
+ break;
+
+ // Low precedence Binary operators
+
+ case KEY_XOR: // Exclusive OR
+ case KEY_OR: // Bit-wise OR
+ case KEY_MINUS: // Subtraction
+ case KEY_PLUS: // Additions
+ {
+ // Is there a high precedence operation?
+
+ if (m_high.operation != (uint8_t)KEY_NONE)
+ {
+ m_accum = evaluateBinaryOperation(m_high.operation, m_high.value, m_accum);
+ m_high.operation = (uint8_t)KEY_NONE;
+ m_high.value = 0;
+ }
+
+ // Is there a pending low precedence operation?
+
+ if (m_low.operation != (uint8_t)KEY_NONE)
+ {
+ m_accum = evaluateBinaryOperation(m_low.operation, m_low.value, m_accum);
+ }
+
+ // Save the new low precedence operation
+
+ m_low.operation = (uint8_t) g_keyDesc[index].keyType;
+ m_low.value = m_accum;
+
+ // Update the display with the value in the accumulator, but
+ // then clear the accumulator in preparation for the next input
+
+ updateText();
+ m_accum = 0;
+ }
+ break;
+
+ // High precedence Binary operators
+
+ case KEY_DIVIDE: // Division
+ case KEY_RSH: // Right shift
+ case KEY_LSH: // Left shift
+ case KEY_MULTIPLY: // Multiplication
+ case KEY_AND: // Bit-wise AND
+ {
+ // Is there a high precedence operation?
+
+ if (m_high.operation != (uint8_t)KEY_NONE)
+ {
+ m_accum = evaluateBinaryOperation(m_high.operation, m_high.value, m_accum);
+ }
+
+ // Save the new high precedence operation
+
+ m_high.operation = (uint8_t) g_keyDesc[index].keyType;
+ m_high.value = m_accum;
+
+ // Update the display with the value in the accumulator, but
+ // then clear the accumulator in preparation for the next input
+
+ updateText();
+ m_accum = 0;
+ }
+ break;
+
+ // Special operations
+
+ case KEY_EQUAL: // Equal/Enter key
+ {
+ // Is there a high precedence operation?
+
+ if (m_high.operation != (uint8_t)KEY_NONE)
+ {
+ m_accum = evaluateBinaryOperation(m_high.operation, m_high.value, m_accum);
+ m_high.operation = (uint8_t)KEY_NONE;
+ m_high.value = 0;
+ }
+
+ // Is there a pending low precedence operation?
+
+ if (m_low.operation != (uint8_t)KEY_NONE)
+ {
+ m_accum = evaluateBinaryOperation(m_low.operation, m_low.value, m_accum);
+ m_low.operation = (uint8_t)KEY_NONE;
+ m_low.value = 0;
+ }
+
+ // Update the display with the value in the accumulator. Flag that
+ // this is a result meaning that (1) it can be used as an accumulator
+ // for the next operation, but new input values cannot be appended to it.
+
+ updateText();
+ result = true;
+ }
+ break;
+
+ case KEY_DECIMAL: // Decimal mode
+ {
+ if (m_hexMode)
+ {
+ m_hexMode = false;
+ labelKeypad();
+ updateText();
+ }
+ }
+ break;
+
+ case KEY_HEXADECIMAL: // Hexadecimal mode
+ {
+ if (!m_hexMode)
+ {
+ m_hexMode = true;
+ labelKeypad();
+ updateText();
+ }
+ }
+ break;
+
+ case KEY_MRECALL: // Recall from memory
+ {
+ m_accum = m_memory;
+ updateText();
+ }
+ break;
+
+ case KEY_MPLUS: // Add to memory
+ {
+ m_memory += m_accum;
+ }
+ break;
+
+ case KEY_MMINUS: // Subtract from memory
+ {
+ m_memory -= m_accum;
+ }
+ break;
+
+ case KEY_MCLR: // Clear memory
+ {
+ m_memory = 0;
+ }
+ break;
+
+ case KEY_CLRENTRY: // Clear entry
+ {
+ m_accum = 0;
+ updateText();
+ }
+ break;
+
+ case KEY_CLR: // Clear all
+ {
+ m_accum = 0;
+ m_high.operation = (uint8_t)KEY_NONE;
+ m_high.value = 0;
+ m_low.operation = (uint8_t)KEY_NONE;
+ m_low.value = 0;
+ updateText();
+ }
+ break;
+
+ case KEY_NONE:
+ default:
+ gdbg("ERROR: Invalid key type %d\n", g_keyDesc[index].keyType);
+ break;
+ }
+
+ // Remember if the accumulator contains a special reault
+
+ m_result = result;
+ }
+}
+
+/**
+ * CHexCalculatorFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate the console
+ */
+
+CHexCalculatorFactory::CHexCalculatorFactory(CTaskbar *taskbar)
+{
+ m_taskbar = taskbar;
+}
+
+/**
+ * Create a new instance of an CHexCalculator (as IApplication).
+ */
+
+IApplication *CHexCalculatorFactory::create(void)
+{
+ // Call CTaskBar::openFullScreenWindow to create a application window for
+ // the NxConsole application
+
+ CApplicationWindow *window = m_taskbar->openApplicationWindow();
+ if (!window)
+ {
+ gdbg("ERROR: Failed to create CApplicationWindow\n");
+ return (IApplication *)0;
+ }
+
+ // Open the window (it is hot in here)
+
+ if (!window->open())
+ {
+ gdbg("ERROR: Failed to open CApplicationWindow\n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ // Instantiate the application, providing the window to the application's
+ // constructor
+
+ CHexCalculator *hexCalculator = new CHexCalculator(m_taskbar, window);
+ if (!hexCalculator)
+ {
+ gdbg("ERROR: Failed to instantiate CHexCalculator\n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ return static_cast<IApplication*>(hexCalculator);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CHexCalculatorFactory::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_HEXCALCULATOR_ICON);
+
+ return bitmap;
+}
diff --git a/NxWidgets/nxwm/src/ckeyboard.cxx b/NxWidgets/nxwm/src/ckeyboard.cxx
new file mode 100644
index 000000000..0f3f11d37
--- /dev/null
+++ b/NxWidgets/nxwm/src/ckeyboard.cxx
@@ -0,0 +1,240 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/ckeyboard.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cunistd>
+#include <cerrno>
+#include <cfcntl>
+
+#include <sched.h>
+#include <pthread.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "nxwmconfig.hxx"
+#include "ckeyboard.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CKeyboard Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CKeyboard Constructor
+ *
+ * @param server. An instance of the NX server. This will be needed for
+ * injecting mouse data.
+ */
+
+CKeyboard::CKeyboard(NXWidgets::CNxServer *server)
+{
+ m_server = server; // Save the NX server
+ m_kbdFd = -1; // Device driver is not opened
+ m_state = LISTENER_NOTRUNNING; // The listener thread is not running yet
+
+ // Initialize the semaphore used to synchronize with the listener thread
+
+ sem_init(&m_waitSem, 0, 0);
+}
+
+/**
+ * CKeyboard Destructor
+ */
+
+CKeyboard::~CKeyboard(void)
+{
+ // Stop the listener thread
+
+ m_state = LISTENER_STOPREQUESTED;
+
+ // Wake up the listener thread so that it will use our buffer
+ // to receive data
+ // REVISIT: Need wait here for the listener thread to terminate
+
+ (void)pthread_kill(m_thread, CONFIG_NXWM_KEYBOARD_SIGNO);
+
+ // Close the keyboard device (or should these be done when the thread exits?)
+
+ if (m_kbdFd >= 0)
+ {
+ std::close(m_kbdFd);
+ }
+}
+
+/**
+ * Start the keyboard listener thread.
+ *
+ * @return True if the keyboard listener thread was correctly started.
+ */
+
+bool CKeyboard::start(void)
+{
+ pthread_attr_t attr;
+
+ gvdbg("Starting listener\n");
+
+ // Start a separate thread to listen for keyboard events
+
+ (void)pthread_attr_init(&attr);
+
+ struct sched_param param;
+ param.sched_priority = CONFIG_NXWM_KEYBOARD_LISTENERPRIO;
+ (void)pthread_attr_setschedparam(&attr, &param);
+
+ (void)pthread_attr_setstacksize(&attr, CONFIG_NXWM_KEYBOARD_LISTENERSTACK);
+
+ m_state = LISTENER_STARTED; // The listener thread has been started, but is not yet running
+
+ int ret = pthread_create(&m_thread, &attr, listener, (FAR void *)this);
+ if (ret != 0)
+ {
+ gdbg("CKeyboard::start: pthread_create failed: %d\n", ret);
+ return false;
+ }
+
+ // Detach from the thread
+
+ (void)pthread_detach(m_thread);
+
+ // Don't return until we are sure that the listener thread is running
+ // (or until it reports an error).
+
+ while (m_state == LISTENER_STARTED)
+ {
+ // Wait for the listener thread to wake us up when we really
+ // are connected.
+
+ (void)sem_wait(&m_waitSem);
+ }
+
+ // Then return true only if the listener thread reported successful
+ // initialization.
+
+ gvdbg("Listener m_state=%d\n", (int)m_state);
+ return m_state == LISTENER_RUNNING;
+}
+
+ /**
+ * The keyboard listener thread. This is the entry point of a thread that
+ * listeners for and dispatches keyboard events to the NX server.
+ *
+ * @param arg. The CKeyboard 'this' pointer cast to a void*.
+ * @return This function normally does not return but may return NULL on
+ * error conditions.
+ */
+
+FAR void *CKeyboard::listener(FAR void *arg)
+{
+ CKeyboard *This = (CKeyboard *)arg;
+
+ gvdbg("Listener started\n");
+
+ // Open the keyboard device
+
+ This->m_kbdFd = std::open(CONFIG_NXWM_KEYBOARD_DEVPATH, O_RDONLY);
+ if (This->m_kbdFd < 0)
+ {
+ gdbg("ERROR Failed to open %s for reading: %d\n",
+ CONFIG_NXWM_KEYBOARD_DEVPATH, errno);
+ This->m_state = LISTENER_FAILED;
+ sem_post(&This->m_waitSem);
+ return (FAR void *)0;
+ }
+
+ // Indicate that we have successfully initialized
+
+ This->m_state = LISTENER_RUNNING;
+ sem_post(&This->m_waitSem);
+
+ // Now loop, reading and dispatching keyboard data
+
+ while (This->m_state == LISTENER_RUNNING)
+ {
+ // Read one keyboard sample
+
+ gvdbg("Listening for keyboard input\n");
+
+ uint8_t rxbuffer[CONFIG_NXWM_KEYBOARD_BUFSIZE];
+ ssize_t nbytes = read(This->m_kbdFd, rxbuffer, CONFIG_NXWM_KEYBOARD_BUFSIZE);
+
+ // Check for errors
+
+ if (nbytes < 0)
+ {
+ // The only expect error is to be interrupt by a signal
+#ifdef CONFIG_DEBUG
+ int errval = errno;
+
+ gdbg("ERROR: read %s failed: %d\n", CONFIG_NXWM_KEYBOARD_DEVPATH, errval);
+ DEBUGASSERT(errval == EINTR);
+#endif
+ }
+
+ // Give the keyboard input to NX
+
+ else if (nbytes > 0)
+ {
+ // Looks like good keyboard input... process it.
+ // First, get the server handle
+
+ NXHANDLE handle = This->m_server->getServer();
+
+ // Then inject the keyboard input into NX
+
+ int ret = nx_kbdin(handle, (uint8_t)nbytes, rxbuffer);
+ if (ret < 0)
+ {
+ gdbg("ERROR: nx_kbdin failed\n");
+ }
+ }
+ }
+
+ // We should get here only if we were asked to terminate via
+ // m_state = LISTENER_STOPREQUESTED
+
+ gvdbg("Listener exiting\n");
+ This->m_state = LISTENER_TERMINATED;
+ return (FAR void *)0;
+}
diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx
new file mode 100644
index 000000000..41e153400
--- /dev/null
+++ b/NxWidgets/nxwm/src/cnxconsole.cxx
@@ -0,0 +1,664 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/cnxconsole.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cstdio>
+#include <cstdlib>
+#include <cunistd>
+#include <ctime>
+
+#include <fcntl.h>
+#include <semaphore.h>
+#include <sched.h>
+#include <debug.h>
+
+#include <apps/nsh.h>
+
+#include "cwidgetcontrol.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "cnxconsole.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Private Types
+ ********************************************************************************************/
+
+namespace NxWM
+{
+ /**
+ * This structure is used to pass start up parameters to the NxConsole task and to assure the
+ * the NxConsole is successfully started.
+ */
+
+ struct SNxConsole
+ {
+ FAR void *console; /**< The console 'this' pointer use with on_exit() */
+ sem_t exclSem; /**< Sem that gives exclusive access to this structure */
+ sem_t waitSem; /**< Sem that posted when the task is initialized */
+ NXTKWINDOW hwnd; /**< Window handle */
+ NXCONSOLE nxcon; /**< NxConsole handle */
+ int minor; /**< Next device minor number */
+ struct nxcon_window_s wndo; /**< Describes the NxConsole window */
+ bool result; /**< True if successfully initialized */
+ };
+
+/********************************************************************************************
+ * Private Data
+ ********************************************************************************************/
+
+ /**
+ * This global data structure is used to pass start parameters to NxConsole task and to
+ * assure that the NxConsole is successfully started.
+ */
+
+ static struct SNxConsole g_nxconvars;
+}
+
+/********************************************************************************************
+ * Private Functions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CNxConsole Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CNxConsole constructor
+ *
+ * @param window. The application window
+ */
+
+CNxConsole::CNxConsole(CTaskbar *taskbar, CApplicationWindow *window)
+{
+ // Save the constructor data
+
+ m_taskbar = taskbar;
+ m_window = window;
+
+ // The NxConsole is not runing
+
+ m_pid = -1;
+ m_nxcon = 0;
+
+ // Add our personalized window label
+
+ NXWidgets::CNxString myName = getName();
+ window->setWindowLabel(myName);
+
+ // Add our callbacks with the application window
+
+ window->registerCallbacks(static_cast<IApplicationCallback *>(this));
+}
+
+/**
+ * CNxConsole destructor
+ *
+ * @param window. The application window
+ */
+
+CNxConsole::~CNxConsole(void)
+{
+ // There would be a problem if we were stopped with the NxConsole task
+ // running... that should never happen but we'll check anyway:
+
+ stop();
+
+ // Although we didn't create it, we are responsible for deleting the
+ // application window
+
+ delete m_window;
+}
+
+/**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained CApplicationWindow instance.
+ */
+
+IApplicationWindow *CNxConsole::getWindow(void) const
+{
+ return static_cast<IApplicationWindow*>(m_window);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CNxConsole::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_NXCONSOLE_ICON);
+
+ return bitmap;
+}
+
+/**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+NXWidgets::CNxString CNxConsole::getName(void)
+{
+ return NXWidgets::CNxString("NuttShell");
+}
+
+/**
+ * Start the application (perhaps in the minimized state).
+ *
+ * @return True if the application was successfully started.
+ */
+
+bool CNxConsole::run(void)
+{
+ // Some sanity checking
+
+ if (m_pid >= 0 || m_nxcon != 0)
+ {
+ gdbg("ERROR: All ready running or connected\n");
+ return false;
+ }
+
+ // Get exclusive access to the global data structure
+
+ if (sem_wait(&g_nxconvars.exclSem) != 0)
+ {
+ // This might fail if a signal is received while we are waiting.
+
+ gdbg("ERROR: Failed to get semaphore\n");
+ return false;
+ }
+
+ // Recover the NXTK window instance contained in the application window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the widget control associated with the NXTK window
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+
+ // Get the window handle from the widget control
+
+ g_nxconvars.hwnd = control->getWindowHandle();
+
+ // Describe the NxConsole
+
+ g_nxconvars.wndo.wcolor[0] = CONFIG_NXWM_NXCONSOLE_WCOLOR;
+ g_nxconvars.wndo.fcolor[0] = CONFIG_NXWM_NXCONSOLE_FONTCOLOR;
+ g_nxconvars.wndo.fontid = CONFIG_NXWM_NXCONSOLE_FONTID;
+
+ // Get the size of the window
+
+ (void)window->getSize(&g_nxconvars.wndo.wsize);
+
+ // Start the NxConsole task
+
+ g_nxconvars.console = (FAR void *)this;
+ g_nxconvars.result = false;
+ g_nxconvars.nxcon = 0;
+
+ sched_lock();
+ m_pid = TASK_CREATE("NxConsole", CONFIG_NXWM_NXCONSOLE_PRIO,
+ CONFIG_NXWM_NXCONSOLE_STACKSIZE, nxconsole,
+ (FAR const char **)0);
+
+ // Did we successfully start the NxConsole task?
+
+ bool result = true;
+ if (m_pid < 0)
+ {
+ gdbg("ERROR: Failed to create the NxConsole task\n");
+ result = false;
+ }
+ else
+ {
+ // Wait for up to two seconds for the task to initialize
+
+ struct timespec abstime;
+ clock_gettime(CLOCK_REALTIME, &abstime);
+ abstime.tv_sec += 2;
+
+ int ret = sem_timedwait(&g_nxconvars.waitSem, &abstime);
+ sched_unlock();
+
+ if (ret == OK && g_nxconvars.result)
+ {
+ // Re-direct NX keyboard input to the new NxConsole driver
+
+ DEBUGASSERT(g_nxconvars.nxcon != 0);
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ window->redirectNxConsole(g_nxconvars.nxcon);
+#endif
+ // Save the handle to use in the stop method
+
+ m_nxcon = g_nxconvars.nxcon;
+ }
+ else
+ {
+ // sem_timedwait failed OR the NxConsole task reported a
+ // failure. Stop the application
+
+ gdbg("ERROR: Failed start the NxConsole task\n");
+ stop();
+ result = false;
+ }
+ }
+
+ sem_post(&g_nxconvars.exclSem);
+ return result;
+}
+
+/**
+ * Stop the application.
+ */
+
+void CNxConsole::stop(void)
+{
+ // Delete the NxConsole task if it is still running (this could strand
+ // resources). If we get here due to CTaskbar::stopApplication() processing
+ // initialed by CNxConsole::exitHandler, then do *not* delete the task (it
+ // is already being deleted).
+
+ if (m_pid >= 0)
+ {
+ // Calling task_delete() will also invoke the on_exit() handler. We se
+ // m_pid = -1 before calling task_delete() to let the on_exit() handler,
+ // CNxConsole::exitHandler(), know that it should not do anything
+
+ pid_t pid = m_pid;
+ m_pid = -1;
+
+ // Then delete the NSH task, possibly stranding resources
+
+ task_delete(pid);
+ }
+
+ // Destroy the NX console device
+
+ if (m_nxcon)
+ {
+ // Re-store NX keyboard input routing
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ NXWidgets::INxWindow *window = m_window->getWindow();
+ window->redirectNxConsole((NXCONSOLE)0);
+#endif
+
+ // Unregister the NxConsole driver
+
+ nxcon_unregister(m_nxcon);
+ m_nxcon = 0;
+ }
+}
+
+/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CNxConsole::destroy(void)
+{
+ // Block any further window messages
+
+ m_window->block(this);
+
+ // Make sure that the application is stopped
+
+ stop();
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+void CNxConsole::hide(void)
+{
+ // Disable drawing and events
+}
+
+/**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hierarchy. This method is call from
+ * CTaskbar when the application window must be displayed
+ */
+
+void CNxConsole::redraw(void)
+{
+ // Recover the NXTK window instance contained in the application window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the size of the window
+
+ struct nxgl_size_s windowSize;
+ (void)window->getSize(&windowSize);
+
+ // Redraw the entire NxConsole window
+
+ struct nxgl_rect_s rect;
+ rect.pt1.x = 0;
+ rect.pt1.y = 0;
+ rect.pt2.x = windowSize.w - 1;
+ rect.pt2.y = windowSize.h - 1;
+
+ nxcon_redraw(m_nxcon, &rect, false);
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CNxConsole::isFullScreen(void) const
+{
+ return m_window->isFullScreen();
+}
+
+/**
+ * This is the NxConsole task. This function first redirects output to the
+ * console window then calls to start the NSH logic.
+ */
+
+int CNxConsole::nxconsole(int argc, char *argv[])
+{
+ // To stop compiler complaining about "jump to label crosses initialization
+ // of 'int fd'
+
+ int fd = -1;
+
+ // Set up an on_exit() event that will be called when this task exits
+
+ if (on_exit(exitHandler, g_nxconvars.console) != 0)
+ {
+ gdbg("ERROR: on_exit failed\n");
+ goto errout;
+ }
+
+ // Use the window handle to create the NX console
+
+ g_nxconvars.nxcon = nxtk_register(g_nxconvars.hwnd, &g_nxconvars.wndo,
+ g_nxconvars.minor);
+ if (!g_nxconvars.nxcon)
+ {
+ gdbg("ERROR: Failed register the console device\n");
+ goto errout;
+ }
+
+ // Construct the driver name using this minor number
+
+ char devname[32];
+ snprintf(devname, 32, "/dev/nxcon%d", g_nxconvars.minor);
+
+ // Increment the minor number while it is protect by the semaphore
+
+ g_nxconvars.minor++;
+
+ // Open the NxConsole driver
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ fd = open(devname, O_RDWR);
+#else
+ fd = open(devname, O_WRONLY);
+#endif
+ if (fd < 0)
+ {
+ gdbg("ERROR: Failed open the console device\n");
+ goto errout_with_nxcon;
+ }
+
+ // Now re-direct stdout and stderr so that they use the NX console driver.
+ // Notes: (1) stdin is retained (file descriptor 0, probably the the serial
+ // console). (2) Don't bother trying to put debug instrumentation in the
+ // following becaue it will end up in the NxConsole window.
+
+ (void)std::fflush(stdout);
+ (void)std::fflush(stderr);
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ (void)std::fclose(stdin);
+#endif
+ (void)std::fclose(stdout);
+ (void)std::fclose(stderr);
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ (void)std::dup2(fd, 0);
+#endif
+ (void)std::dup2(fd, 1);
+ (void)std::dup2(fd, 2);
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+ (void)std::fdopen(0, "r");
+#endif
+ (void)std::fdopen(1, "w");
+ (void)std::fdopen(2, "w");
+
+ // And we can close our original driver file descriptor
+
+ std::close(fd);
+
+ // Inform the parent thread that we successfully initialized
+
+ g_nxconvars.result = true;
+ sem_post(&g_nxconvars.waitSem);
+
+ // Run the NSH console
+
+#ifdef CONFIG_NSH_CONSOLE
+ (void)nsh_consolemain(argc, argv);
+#endif
+
+ // We get here if the NSH console should exits. nsh_consolemain() ALWAYS
+ // exits by calling nsh_exit() (which is a pointer to nsh_consoleexit())
+ // which, in turn, calls exit()
+
+ return EXIT_SUCCESS;
+
+errout_with_nxcon:
+ nxcon_unregister(g_nxconvars.nxcon);
+
+errout:
+ g_nxconvars.nxcon = 0;
+ g_nxconvars.result = false;
+ sem_post(&g_nxconvars.waitSem);
+ return EXIT_FAILURE;
+}
+
+/**
+ * This is the NxConsole task exit handler. It registered with on_exit()
+ * and called automatically when the nxconsole task exits.
+ */
+
+void CNxConsole::exitHandler(int code, FAR void *arg)
+{
+ CNxConsole *This = (CNxConsole *)arg;
+
+ // If we got here because of the task_delete() call in CNxConsole::stop(),
+ // then m_pid will be set to -1 to let us know that we do not need to do
+ // anything
+
+ if (This->m_pid >= 0)
+ {
+ // Set m_pid to -1 to prevent calling detlete_task() in CNxConsole::stop().
+ // CNxConsole::stop() is called by the processing initiated by the following
+ // call to CTaskbar::stopApplication()
+
+ This->m_pid = -1;
+
+ // Remove the NxConsole application from the taskbar
+
+ This->m_taskbar->stopApplication(This);
+ }
+}
+
+/**
+ * Called when the window minimize button is pressed.
+ */
+
+void CNxConsole::minimize(void)
+{
+ m_taskbar->minimizeApplication(static_cast<IApplication*>(this));
+}
+
+/**
+ * Called when the window close button is pressed.
+ */
+
+void CNxConsole::close(void)
+{
+ m_taskbar->stopApplication(static_cast<IApplication*>(this));
+}
+
+/**
+ * CNxConsoleFactory Constructor
+ *
+ * @param taskbar. The taskbar instance used to terminate the console
+ */
+
+CNxConsoleFactory::CNxConsoleFactory(CTaskbar *taskbar)
+{
+ m_taskbar = taskbar;
+}
+
+/**
+ * Create a new instance of an CNxConsole (as IApplication).
+ */
+
+IApplication *CNxConsoleFactory::create(void)
+{
+ // Call CTaskBar::openFullScreenWindow to create a full screen window for
+ // the NxConsole application
+
+ CApplicationWindow *window = m_taskbar->openApplicationWindow();
+ if (!window)
+ {
+ gdbg("ERROR: Failed to create CApplicationWindow\n");
+ return (IApplication *)0;
+ }
+
+ // Open the window (it is hot in here)
+
+ if (!window->open())
+ {
+ gdbg("ERROR: Failed to open CApplicationWindow\n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ // Instantiate the application, providing the window to the application's
+ // constructor
+
+ CNxConsole *nxconsole = new CNxConsole(m_taskbar, window);
+ if (!nxconsole)
+ {
+ gdbg("ERROR: Failed to instantiate CNxConsole\n");
+ delete window;
+ return (IApplication *)0;
+ }
+
+ return static_cast<IApplication*>(nxconsole);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CNxConsoleFactory::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_NXCONSOLE_ICON);
+
+ return bitmap;
+}
+
+/**
+ * One time NSH initialization. This function must be called exactly
+ * once during the boot-up sequence to initialize the NSH library.
+ *
+ * @return True on successful initialization
+ */
+
+bool NxWM::nshlibInitialize(void)
+{
+ // Initialize the global data structure
+
+ sem_init(&g_nxconvars.exclSem, 0, 1);
+ sem_init(&g_nxconvars.waitSem, 0, 0);
+
+ // Initialize the NSH library
+
+ nsh_initialize();
+
+ // If the Telnet console is selected as a front-end, then start the
+ // Telnet daemon.
+
+#ifdef CONFIG_NSH_TELNET
+ int ret = nsh_telnetstart();
+ if (ret < 0)
+ {
+ // The daemon is NOT running!
+
+ return false;
+ }
+#endif
+ return true;
+}
+
diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx
new file mode 100644
index 000000000..5c54cba3a
--- /dev/null
+++ b/NxWidgets/nxwm/src/cstartwindow.cxx
@@ -0,0 +1,696 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/cstartwindow.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cstdlib>
+#include <cfcntl>
+#include <csched>
+#include <cerrno>
+
+#include <mqueue.h>
+
+#include "cwidgetcontrol.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "ctaskbar.hxx"
+#include "cstartwindow.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Global Data
+ ********************************************************************************************/
+
+/**
+ * The well-known name for the Start Window's message queue.
+ */
+
+FAR const char *NxWM::g_startWindowMqName = CONFIG_NXWM_STARTWINDOW_MQNAME;
+
+/********************************************************************************************
+ * CStartWindow Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CStartWindow Constructor
+ *
+ * @param taskbar. A pointer to the parent task bar instance
+ * @param window. The window to be used by this application.
+ */
+
+CStartWindow::CStartWindow(CTaskbar *taskbar, CApplicationWindow *window)
+{
+ // Save the constructor data
+
+ m_taskbar = taskbar;
+ m_window = window;
+
+ // The start window task is not running
+
+ m_taskId = -1;
+
+ // Add our personalized window label
+
+ NXWidgets::CNxString myName = getName();
+ window->setWindowLabel(myName);
+
+ // Add our callbacks to the application window
+
+ window->registerCallbacks(static_cast<IApplicationCallback *>(this));
+}
+
+/**
+ * CStartWindow Constructor
+ */
+
+CStartWindow::~CStartWindow(void)
+{
+ // There would be a problem if we were stopped with the start window task
+ // running... that should never happen but we'll check anyway:
+
+ stop();
+
+ // Although we didn't create it, we are responsible for deleting the
+ // application window
+
+ delete m_window;
+
+ // Then stop and delete all applications
+
+ removeAllApplications();
+}
+
+/**
+ * Each implementation of IApplication must provide a method to recover
+ * the contained IApplicationWindow instance.
+ */
+
+IApplicationWindow *CStartWindow::getWindow(void) const
+{
+ return static_cast<IApplicationWindow*>(m_window);
+}
+
+/**
+ * Get the icon associated with the application
+ *
+ * @return An instance if IBitmap that may be used to rend the
+ * application's icon. This is an new IBitmap instance that must
+ * be deleted by the caller when it is no long needed.
+ */
+
+NXWidgets::IBitmap *CStartWindow::getIcon(void)
+{
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_STARTWINDOW_ICON);
+
+ return bitmap;
+}
+
+/**
+ * Get the name string associated with the application
+ *
+ * @return A copy if CNxString that contains the name of the application.
+ */
+
+NXWidgets::CNxString CStartWindow::getName(void)
+{
+ return NXWidgets::CNxString("Start Window");
+}
+
+/**
+ * Start the application.
+ *
+ * @return True if the application was successfully started.
+ */
+
+bool CStartWindow::run(void)
+{
+ // Some sanity checking
+
+ if (m_taskId >= 0)
+ {
+ // The start window task is already running???
+
+ return false;
+ }
+
+ // Start the start window task
+
+ m_taskId = TASK_CREATE("StartWindow", CONFIG_NXWM_STARTWINDOW_PRIO,
+ CONFIG_NXWM_STARTWINDOW_STACKSIZE, startWindow,
+ (FAR const char **)0);
+
+ // Did we successfully start the NxConsole task?
+
+ return m_taskId >= 0;
+}
+
+/**
+ * Stop the application.
+ */
+
+void CStartWindow::stop(void)
+{
+ // Delete the start window task --- what are we doing? This should never
+ // happen because the start window task is persistent!
+
+ if (m_taskId >= 0)
+ {
+ // Call task_delete(), possibly stranding resources
+
+ pid_t pid = m_taskId;
+ m_taskId = -1;
+
+ // Then delete the NSH task
+
+ task_delete(pid);
+ }
+}
+/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CStartWindow::destroy(void)
+{
+ // What are we doing? This should never happen because the start
+ // window task is persistent!
+
+ // Block any further window messages
+
+ m_window->block(this);
+
+ // Make sure that the application is stopped
+
+ stop();
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy
+ */
+
+void CStartWindow::hide(void)
+{
+ // Disable drawing and events on all icons
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ NXWidgets::CImage *image = m_slots.at(i).image;
+ image->disableDrawing();
+ image->setRaisesEvents(false);
+ }
+}
+
+/**
+ * Redraw the entire window. The application has been maximized or
+ * otherwise moved to the top of the hiearchy
+ */
+
+void CStartWindow::redraw(void)
+{
+ // Recover the NXTK window instance contained in the application window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the widget control associated with the NXTK window
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+
+ // Get the graphics port for drawing on the widget control
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Get the size of the application window
+
+ struct nxgl_size_s windowSize;
+ if (!window->getSize(&windowSize))
+ {
+ return;
+ }
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR);
+
+ // Begin adding icons in the upper left corner
+
+ struct nxgl_point_s iconPos;
+ iconPos.x = CONFIG_NXWM_STARTWINDOW_HSPACING;
+ iconPos.y = CONFIG_NXWM_STARTWINDOW_VSPACING;
+
+ // Add each icon in the list of applications
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Get the icon associated with this application
+
+ NXWidgets::CImage *image = m_slots.at(i).image;
+
+ // Disable drawing of the icon image; disable events from the icon
+
+ image->disableDrawing();
+ image->setRaisesEvents(false);
+
+ // Get the size of the icon image
+
+ NXWidgets::CRect rect;
+ image->getPreferredDimensions(rect);
+
+ // Center the image in the region defined by the maximum icon size
+
+ struct nxgl_point_s imagePos;
+ imagePos.x = iconPos.x;
+ imagePos.y = iconPos.y;
+
+ if (rect.getWidth() < m_iconSize.w)
+ {
+ imagePos.x += ((m_iconSize.w - rect.getWidth()) >> 1);
+ }
+
+ if (rect.getHeight() < m_iconSize.h)
+ {
+ imagePos.y += ((m_iconSize.h - rect.getHeight()) >> 1);
+ }
+
+ // Set the position of the icon bitmap
+
+ image->moveTo(imagePos.x, imagePos.y);
+
+ // Then re-draw the icon at the new position
+
+ image->enableDrawing();
+ image->redraw();
+ image->setRaisesEvents(true);
+
+ // Advance the next icon position to the left
+
+ iconPos.x += m_iconSize.w + CONFIG_NXWM_TASKBAR_HSPACING;
+
+ // If there is insufficient space on on this row for the next
+ // max-sized icon, then advance to the next row
+
+ if (iconPos.x + m_iconSize.w >= windowSize.w)
+ {
+ iconPos.x = CONFIG_NXWM_STARTWINDOW_HSPACING;
+ iconPos.y += m_iconSize.h + CONFIG_NXWM_TASKBAR_VSPACING;
+
+ // Don't try drawing past the bottom of the window
+
+ if (iconPos.y >= windowSize.w)
+ {
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Report of this is a "normal" window or a full screen window. The
+ * primary purpose of this method is so that window manager will know
+ * whether or not it show draw the task bar.
+ *
+ * @return True if this is a full screen window.
+ */
+
+bool CStartWindow::isFullScreen(void) const
+{
+ return m_window->isFullScreen();
+}
+
+/**
+ * Add the application to the start window. The general sequence is:
+ *
+ * 1. Call IAppicationFactory::create to a new instance of the application
+ * 2. Call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * @param app. The new application to add to the start window
+ * @return true on success
+ */
+
+bool CStartWindow::addApplication(IApplicationFactory *app)
+{
+ // Recover the NXTK window instance contained in the application window
+
+ NXWidgets::INxWindow *window = m_window->getWindow();
+
+ // Get the widget control associated with the NXTK window
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+
+ // Get the bitmap icon that goes with this application
+
+ NXWidgets::IBitmap *bitmap = app->getIcon();
+
+ // Create a CImage instance to manage the application icon
+
+ NXWidgets::CImage *image =
+ new NXWidgets::CImage(control, 0, 0, bitmap->getWidth(),
+ bitmap->getHeight(), bitmap, 0);
+ if (!image)
+ {
+ return false;
+ }
+
+ // Configure the image, disabling drawing for now
+
+ image->setBorderless(true);
+ image->disableDrawing();
+
+ // Register to get events from the mouse clicks on the image
+
+ image->addWidgetEventHandler(this);
+
+ // Add the application to end of the list of applications managed by
+ // the start window
+
+ struct SStartWindowSlot slot;
+ slot.app = app;
+ slot.image = image;
+ m_slots.push_back(slot);
+
+ // Re-calculate the icon bounding box
+
+ getIconBounds();
+ return true;
+}
+
+/**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CStartWindow::clickIcon(int index, bool click)
+{
+ if (index < m_slots.size())
+ {
+ // Get the image widget at this index
+
+ NXWidgets::CImage *image = m_slots.at(index).image;
+
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ image->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ image->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ image->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ image->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ }
+}
+#endif
+
+/**
+ * Called when the window minimize button is pressed.
+ */
+
+void CStartWindow::minimize(void)
+{
+ m_taskbar->minimizeApplication(static_cast<IApplication*>(this));
+}
+
+/**
+ * Called when the window minimize close is pressed.
+ */
+
+void CStartWindow::close(void)
+{
+ // Do nothing... you can't close the start window!!!
+}
+
+/**
+ * Calculate the icon bounding box
+ */
+
+void CStartWindow::getIconBounds(void)
+{
+ // Visit each icon
+
+ struct nxgl_size_s maxSize;
+ maxSize.w = 0;
+ maxSize.h = 0;
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Get the icon associated with this application
+
+ NXWidgets::CImage *image = m_slots.at(i).image;
+
+ // Get the size of the icon image
+
+ NXWidgets::CRect rect;
+ image->getPreferredDimensions(rect);
+
+ // Keep the maximum height and width
+
+ if (rect.getWidth() > maxSize.h)
+ {
+ maxSize.w = rect.getWidth() ;
+ }
+
+ if (rect.getHeight() > maxSize.h)
+ {
+ maxSize.h = rect.getHeight();
+ }
+ }
+
+ // And save the new maximum size
+
+ m_iconSize.w = maxSize.w;
+ m_iconSize.h = maxSize.h;
+}
+
+/**
+ * Stop all applications
+ */
+
+void CStartWindow::removeAllApplications(void)
+{
+ // Stop all applications and remove them from the start window. Clearly, there
+ // are some ordering issues here... On an orderly system shutdown, disconnection
+ // should really occur priority to deleting instances
+
+ while (!m_slots.empty())
+ {
+ // Remove the application factory from the start menu
+
+ IApplicationFactory *app = m_slots.at(0).app;
+
+ // Now, delete the image and the application
+
+ delete app;
+ delete m_slots.at(0).image;
+
+ // And discard the data in this slot
+
+ m_slots.erase(0);
+ }
+}
+
+/**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+void CStartWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
+{
+ // Was an ICON clicked?
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Is this the clicked icon?
+
+ NXWidgets::CImage *image = m_slots.at(i).image;
+ if (image->isClicked())
+ {
+ // Create a new copy of the application
+
+ IApplication *app = m_slots.at(i).app->create();
+ if (app)
+ {
+ // Start the new copy of the application
+
+ if (m_taskbar->startApplication(app, false))
+ {
+ // Then break out of the loop
+
+ break;
+ }
+ else
+ {
+ // If we cannot start the app. Destroy the instance we
+ // created and see what happens next. Could be interesting.
+
+ app->stop();
+ app->destroy();
+ }
+ }
+ }
+ }
+}
+
+/**
+ * This is the start window task. This function receives window events from
+ * the NX listener threads indirectly through this sequence:
+ *
+ * 1. NX listener thread receives a windows event. This may be a
+ * positional change notification, a redraw request, or mouse or
+ * keyboard input.
+ * 2. The NX listener thread performs the callback by calling a
+ * NXWidgets::CCallback method associated with the window.
+ * 3. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process
+ * the event.
+ * 4. NXWidgets::CWidgetControl records the new state data and raises a
+ * window event.
+ * 5. NXWidgets::CWindowEventHandlerList will give the event to
+ * NxWM::CWindowMessenger.
+ * 6. NxWM::CWindowMessenger will send the a message on a well-known message
+ * queue.
+ * 7. This CStartWindow::startWindow task will receive and process that
+ * message.
+ */
+
+int CStartWindow::startWindow(int argc, char *argv[])
+{
+ /* Open a well-known message queue for reading */
+
+ struct mq_attr attr;
+ attr.mq_maxmsg = CONFIG_NXWM_STARTWINDOW_MXMSGS;
+ attr.mq_msgsize = sizeof(struct SStartWindowMessage);
+ attr.mq_flags = 0;
+
+ mqd_t mqd = mq_open(g_startWindowMqName, O_RDONLY|O_CREAT, 0666, &attr);
+ if (mqd == (mqd_t)-1)
+ {
+ gdbg("ERROR: mq_open(%s) failed: %d\n", g_startWindowMqName, errno);
+ return EXIT_FAILURE;
+ }
+
+ // Now loop forever, receiving and processing messages. Ultimately, all
+ // widget driven events (button presses, etc.) are driven by this logic
+ // on this thread.
+
+ for (;;)
+ {
+ // Receive the next message
+
+ struct SStartWindowMessage msg;
+ ssize_t nbytes = mq_receive(mqd, &msg, sizeof(struct SStartWindowMessage), 0);
+ if (nbytes < 0)
+ {
+ int errval = errno;
+
+ // EINTR is not an error. The wait was interrupted by a signal and
+ // we just need to try reading again.
+
+ if (errval != EINTR)
+ {
+ gdbg("ERROR: mq_receive failed: %d\n", errval);
+ }
+ }
+ while (nbytes < 0);
+
+ gvdbg("Received msgid=%d nbytes=%d\n", msg.msgId, nbytes);
+ DEBUGASSERT(nbytes = sizeof(struct SStartWindowMessage) && msg.instance);
+
+ // Dispatch the message to the appropriate CWidgetControl and to the
+ // appropriate CWidgetControl method
+
+ switch (msg.msgId)
+ {
+ break;
+
+ case MSGID_MOUSE_INPUT: // New mouse input is available
+ case MSGID_KEYBOARD_INPUT: // New keyboard input is available
+ {
+ // Handle all new window input events by calling the CWidgetControl::pollEvents() method
+
+ NXWidgets::CWidgetControl *control = (NXWidgets::CWidgetControl *)msg.instance;
+ control->pollEvents();
+ }
+ break;
+
+ case MSGID_DESTROY_APP: // Destroy the application
+ {
+ // Handle all destroy application events
+
+ gdbg("Deleting app=%p\n", msg.instance);
+ IApplication *app = (IApplication *)msg.instance;
+ delete app;
+ }
+ break;
+
+ case MSGID_POSITIONAL_CHANGE: // Change in window positional data (not used)
+ case MSGID_REDRAW_REQUEST: // Request to redraw a portion of the window (not used)
+ default:
+ gdbg("ERROR: Unrecognized or unsupported msgId: %d\n", (int)msg.msgId);
+ break;
+ }
+ }
+}
+
diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx
new file mode 100644
index 000000000..c494fcba3
--- /dev/null
+++ b/NxWidgets/nxwm/src/ctaskbar.cxx
@@ -0,0 +1,1427 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/ctaskbar.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "crect.hxx"
+#include "cwidgetcontrol.hxx"
+#include "cnxtkwindow.hxx"
+
+#include "cwindowmessenger.hxx"
+#include "ctaskbar.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CNxConsole Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CTaskbar Constructor
+ *
+ * @param hWnd - NX server handle
+ */
+
+CTaskbar::CTaskbar(void)
+{
+ m_taskbar = (NXWidgets::CNxWindow *)0;
+ m_background = (NXWidgets::CNxWindow *)0;
+ m_backImage = (NXWidgets::CImage *)0;
+ m_topApp = (IApplication *)0;
+ m_started = false;
+}
+
+/**
+ * CTaskbar Destructor
+ */
+
+CTaskbar::~CTaskbar(void)
+{
+ // The disconnect,putting the instance back in the state that it
+ // was before it was constructed.
+
+ disconnect();
+}
+
+/**
+ * Connect to the server
+ */
+
+bool CTaskbar::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR))
+ {
+ // Failed
+ }
+ }
+
+ return nxConnected;
+}
+
+/**
+ * Disconnect from the server. This method restores the taskbar to the
+ * same state that it was in when it was constructed.
+ */
+
+void CTaskbar::disconnect(void)
+{
+ // Stop all applications and remove them from the task bar. Clearly, there
+ // are some ordering issues here... On an orderly system shutdown, disconnection
+ // should really occur priority to deleting instances
+
+ while (!m_slots.empty())
+ {
+ IApplication *app = m_slots.at(0).app;
+ stopApplication(app);
+ }
+
+ // Close the windows
+
+ NXWidgets::CWidgetControl *control;
+ if (m_taskbar)
+ {
+ // Get the contained widget control
+
+ control = m_taskbar->getWidgetControl();
+
+ // Delete the widget control. We are responsible for it because we created it
+
+ if (control)
+ {
+ delete control;
+ }
+
+ // Then delete the task bar window
+
+ delete m_taskbar;
+ m_taskbar = (NXWidgets::CNxWindow *)0;
+ }
+
+ if (m_background)
+ {
+ // Delete the contained widget control. We are responsible for it
+ // because we created it
+
+ control = m_background->getWidgetControl();
+ if (control)
+ {
+ delete control;
+ }
+
+ // Then delete the background
+
+ delete m_background;
+ m_background = (NXWidgets::CNxWindow *)0;
+ }
+
+ // Delete the background image
+
+ if (m_backImage)
+ {
+ delete m_backImage;
+ m_backImage = (NXWidgets::CImage *)0;
+ }
+
+ // Reset other variables
+
+ m_topApp = (IApplication *)0;
+ m_started = false;
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+/**
+ * Initialize task bar. Task bar initialization is separate from
+ * object instantiation so that failures can be reported. The window
+ * manager start-up sequence is:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ * inherits the connect method from CNxServer),
+ * 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ * 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ * 5. Call CTaskBar::startWindowManager to start the display with applications in place
+ *
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+bool CTaskbar::initWindowManager(void)
+{
+ // Create the taskbar window
+
+ if (!createTaskbarWindow())
+ {
+ return false;
+ }
+
+ // Create the background window
+
+ if (!createBackgroundWindow())
+ {
+ return false;
+ }
+
+ // Create the background image
+
+ if (!createBackgroundImage())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Start the window manager and present the initial displays. The window
+ * manager start-up sequence is:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call startApplication repeatedly to add applications to the task bar
+ * 3. Call startWindowManager to start the display with applications in place
+ *
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * startWindowManager will present the task bar and the background image. The
+ * initial taskbar will contain only the start window icon.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::startWindowManager(void)
+{
+ // Have we already been started
+
+ if (!m_started)
+ {
+ // We are now started
+
+ m_started = true;
+
+ // Decide which application will be the initial 'top' application
+
+ m_topApp = (IApplication *)0;
+ int topIndex = -1;
+
+ // No.. Search for that last, non-minimized application (there might not be one)
+
+ for (int i = m_slots.size() - 1; i >= 0; i--)
+ {
+ IApplication *candidate = m_slots.at(i).app;
+ if (!candidate->isMinimized())
+ {
+ m_topApp = candidate;
+ topIndex = i;
+ break;
+ }
+ }
+ gvdbg("m_topApp=%p topIndex=%d\n", m_topApp, topIndex);
+
+ // Now start each application (whatever that means to the application)
+
+ for (int i = 0; i < m_slots.size(); )
+ {
+ IApplication *app = m_slots.at(i).app;
+
+ gvdbg("Starting app[%d]\n", i);
+ if (!app->run())
+ {
+ // Call stopApplication on a failure to start. This will call
+ // app->stop() (which is probably not necesary for the application
+ // but it should be prepared/ to handle it). stopApplication()
+ // will also removed the icon image from the list and delete it.
+
+ stopApplication(app);
+
+ // Then continue with the next application. Notice that i is
+ // not incremented in this case and we will continue with the
+ // next application which will not be at this same index
+
+ continue;
+ }
+
+ // Hide all applications except for the top application. NOTE:
+ // topIndex may still be -1, meaning that there is no application
+ // and that all applications should be hidden.
+
+ if (i != topIndex)
+ {
+ // Bring the application up in the non-visible state (the
+ // application may or may not be minimized, but it is not
+ // visible now).
+
+ gvdbg("Hiding app[%d]\n", i);
+ hideApplicationWindow(app);
+ }
+ else
+ {
+ // Bring up the application as the new top application
+
+ gvdbg("Showing app[%d]\n", i);
+ topApplication(app);
+ }
+
+ // The application was successfully initialized.. index to the next application
+
+ i++;
+ }
+
+ // If there is no top appliation (i.e., no applications or all applications
+ // are minimized), then draw the background image
+
+ if (!m_topApp)
+ {
+ if (!redrawBackgroundWindow())
+ {
+ return false;
+ }
+ }
+
+ // Draw the taskbar. It will be draw at a higher level than the application.
+
+ return redrawTaskbarWindow();
+ }
+
+ return false;
+}
+
+/**
+ * Create an normal application window. Creating a normal application in the
+ * start window requires three steps:
+ *
+ * 1. Call CTaskBar::openApplicationWindow to create a window for the application,
+ * 2. Instantiate the application, providing the window to the application's
+ * constructor,
+ * 3. Then call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call CTaskBar::startApplication start the application and bring its window to
+ * the top.
+ *
+ * @param flags. CApplicationWindow flugs for window customization.
+ */
+
+CApplicationWindow *CTaskbar::openApplicationWindow(uint8_t flags)
+{
+ // Get a framed window for the application
+
+ NXWidgets::CNxTkWindow *window = openFramedWindow();
+ if (!window)
+ {
+ return (CApplicationWindow *)0;
+ }
+
+ // Set size and position of a window in the application area.
+
+ setApplicationGeometry(window, false);
+
+ // Use this window to instantiate the application window
+
+ CApplicationWindow *appWindow = new CApplicationWindow(window, flags);
+ if (!appWindow)
+ {
+ delete window;
+ }
+
+ return appWindow;
+}
+
+/**
+ * Create a full screen application window. Creating a new full screen application
+ * requires three steps:
+ *
+ * 1. Call CTaskBar::FullScreenWindow to create a window for the application,
+ * 2. Instantiate the application, providing the window to the application's
+ * constructor,
+ * 3. Then call CStartWindow::addApplication to add the application to the
+ * start window.
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call CTaskBar::startApplication start the application and bring its window to
+ * the top.
+ */
+
+CFullScreenWindow *CTaskbar::openFullScreenWindow(void)
+{
+ // Get a raw window for the application
+
+ NXWidgets::CNxWindow *window = openRawWindow();
+ if (!window)
+ {
+ return (CFullScreenWindow *)0;
+ }
+
+ // Set size and position of a window in the application area.
+
+ setApplicationGeometry(window, true);
+
+ // Use this window to instantiate the generia application window
+
+ CFullScreenWindow *appWindow = new CFullScreenWindow(window);
+ if (!appWindow)
+ {
+ delete window;
+ }
+
+ return appWindow;
+}
+
+/**
+ * Start an application and add its icon to the taskbar. The applications's
+ * window is brought to the top. Creating a new application in the start
+ * window requires three steps:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call startApplication repeatedly to add applications to the task bar
+ * 3. Call startWindowManager to start the display with applications in place
+ *
+ * When the application is selected from the start window:
+ *
+ * 4. Call startApplication start the application and bring its window to
+ * the top.
+ *
+ * @param app. The new application to add to the task bar
+ * @param minimized. The new application starts in the minimized state
+ * @return true on success
+ */
+
+bool CTaskbar::startApplication(IApplication *app, bool minimized)
+{
+ // Get the widget control associated with the task bar window
+
+ NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
+
+ // Get the bitmap icon that goes with this application
+
+ NXWidgets::IBitmap *bitmap = app->getIcon();
+
+ // Create a CImage instance to manage the applications icon
+
+ NXWidgets::CImage *image =
+ new NXWidgets::CImage(control, 0, 0, bitmap->getWidth(),
+ bitmap->getHeight(), bitmap, 0);
+ if (!image)
+ {
+ return false;
+ }
+
+ // Configure the image, disabling drawing for now
+
+ image->setBorderless(true);
+ image->disableDrawing();
+ image->setRaisesEvents(false);
+
+ // Register to get events from the mouse clicks on the image
+
+ image->addWidgetEventHandler(this);
+
+ // Add the application to end of the list of applications managed by
+ // the task bar
+
+ struct STaskbarSlot slot;
+ slot.app = app;
+ slot.image = image;
+ m_slots.push_back(slot);
+
+ // Initialize the application states
+
+ app->setTopApplication(false);
+ app->setMinimized(minimized);
+
+ // Has the window manager been started?
+
+ if (m_started)
+ {
+ // Yes.. Start the application (whatever that means).
+
+ if (!app->run())
+ {
+ // Call stopApplication on a failure to start. This will call
+ // app->stop() (which is probably not necesary for the application
+ // but it should be prepared/ to handle it). stopApplication()
+ // will also removed the icon image from the list and delete it.
+
+ stopApplication(app);
+ return false;
+ }
+
+ // Were we ask to start the application minimized?
+
+ if (minimized)
+ {
+ // Bring the minimized application up in non-visible state
+
+ hideApplicationWindow(app);
+ }
+ else
+ {
+ // Bring up the application as the new top application if we are running
+ // If not, we will select and bring up the top application when the
+ // window manager is started
+
+ topApplication(app);
+ }
+
+ // Redraw the task bar with the new icon (if we have been started)
+
+ redrawTaskbarWindow();
+ }
+
+ return true;
+}
+
+/**
+ * Move window to the top of the hierarchy and re-draw it. This method
+ * does nothing if the application is minimized.
+ *
+ * @param app. The new application to show
+ * @return true on success
+ */
+
+bool CTaskbar::topApplication(IApplication *app)
+{
+ // Verify that the application is not minimized and is not already the top application
+
+ if (!app->isMinimized() && !app->isTopApplication())
+ {
+ // It is not minimized. We are going to bring it to the top of the display.
+ // Is there already a top application?
+
+ if (m_topApp)
+ {
+ // Yes.. make the application non-visible (it is still maximized and
+ // will reappear when the window above it is minimized or closed).
+
+ hideApplicationWindow(m_topApp);
+ }
+
+ // Make the application the top application and redraw it
+
+ return redrawApplicationWindow(app);
+ }
+
+ return false;
+}
+
+/**
+ * Maximize an application by moving its window to the top of the hierarchy
+ * and re-drawing it. If the application was already maximized, then this
+ * method is equivalent to topApplication().
+ *
+ * @param app. The new application to add to the task bar
+ * @return true on success
+ */
+
+bool CTaskbar::maximizeApplication(IApplication *app)
+{
+ // Mark that the application is no longer minimized
+
+ app->setMinimized(false);
+
+ // Then bring the application to the top of the hierarchy
+
+ return topApplication(app);
+}
+
+/**
+ * Minimize an application by moving its window to the bottom of the and
+ * redrawing the next visible appliation.
+ *
+ * @param app. The new application to add to the task bar
+ * @return true on success
+ */
+
+bool CTaskbar::minimizeApplication(IApplication *app)
+{
+ // Verify that the application is not already minimized
+
+ if (!app->isMinimized())
+ {
+ // No, then we are going to minimize it but disabling its components,
+ // marking it as minimized, then raising a new window to the top window.
+
+ app->setMinimized(true);
+ hideApplicationWindow(app);
+
+ // Re-draw the new top, non-minimized application
+
+ return redrawTopApplication();
+ }
+
+ return false;
+}
+
+/**
+ * Destroy an application. Move its window to the bottom and remove its
+ * icon from the task bar.
+ *
+ * @param app. The new application to remove from the task bar
+ * @return true on success
+ */
+
+bool CTaskbar::stopApplication(IApplication *app)
+{
+ // Make the application minimized and make sure that it is not the top
+ // application.
+
+ app->setMinimized(true);
+ if (app->isTopApplication())
+ {
+ app->setTopApplication(false);
+ m_topApp = (IApplication *)0;
+ }
+
+ // Hide the application window. That will move the application to the
+ // bottom of the hiearachy.
+
+ hideApplicationWindow(app);
+
+ // Stop the application (whatever this means to the application). We
+ // separate stopping from destroying to get the application a chance
+ // to put things in order before being destroyed.
+
+ app->stop();
+
+ // Find the application in the list of applications
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Is this it?
+
+ IApplication *candidate = m_slots.at(i).app;
+ if (candidate == app)
+ {
+ // Yes.. found it. Delete the icon image and remove the entry
+ // from the list of applications
+
+ delete m_slots.at(i).image;
+ m_slots.erase(i);
+ break;
+ }
+ }
+
+ // Destroy the application (actually, this just sets up the application for
+ // later destruction.
+
+ app->destroy();
+
+ // Re-draw the new top, non-minimized application
+
+ bool ret = redrawTopApplication();
+ if (ret)
+ {
+ // And redraw the task bar (without the icon for this task)
+
+ ret = redrawTaskbarWindow();
+ }
+ return ret;
+}
+
+/**
+ * Get the size of the physical display device as it is known to the task
+ * bar.
+ *
+ * @return The size of the display
+ */
+
+void CTaskbar::getDisplaySize(FAR struct nxgl_size_s &size)
+{
+ // Get the widget control from the task bar window. The physical window geometry
+ // should be the same for all windows.
+
+ NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
+
+ // Get the window bounding box from the widget control
+
+ NXWidgets::CRect rect = control->getWindowBoundingBox();
+
+ // And return the size of the window
+
+ rect.getSize(size);
+}
+
+/**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CTaskbar::clickIcon(int index, bool click)
+{
+ if (index < m_slots.size())
+ {
+ // Get the image widget at this index
+
+ NXWidgets::CImage *image = m_slots.at(index).image;
+
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ image->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ image->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ image->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ image->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ }
+}
+#endif
+
+/**
+ * Create a raw window.
+ *
+ * 1) Create a dumb CWigetControl instance (see note below)
+ * 2) Pass the dumb CWidgetControl instance to the window constructor
+ * that inherits from INxWindow. This will "smarten" the CWidgetControl
+ * instance with some window knowlede
+ * 3) Call the open() method on the window to display the window.
+ * 4) After that, the fully smartened CWidgetControl instance can
+ * be used to generate additional widgets by passing it to the
+ * widget constructor
+ *
+ * NOTE: Actually, NxWM uses the CWindowMessenger class that inherits from
+ * CWidgetControl. That class just adds some unrelated messaging capability;
+ * It cohabitates with CWidgetControl only becuase it needs the CWidgetControl
+ * this point.
+ */
+
+NXWidgets::CNxWindow *CTaskbar::openRawWindow(void)
+{
+ // Create the widget control (with the window messenger) using the default style
+
+ CWindowMessenger *control = new CWindowMessenger((NXWidgets::CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the background window as a class
+ // that derives from INxWindow.
+
+ NXWidgets::CNxWindow *window = createRawWindow(control);
+ if (!window)
+ {
+ delete control;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = window->open();
+ if (!success)
+ {
+ delete window;
+ window = (NXWidgets::CNxWindow *)0;
+ return false;
+ }
+
+ return window;
+}
+
+/**
+ * Create a framed application window
+ *
+ * This may be used to provide the window parater to the IApplication constructor
+ *
+ * @return A partially initialized application window instance.
+ */
+
+NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
+{
+ // Create the widget control (with the window messenger) using the default style
+
+ CWindowMessenger *control = new CWindowMessenger((NXWidgets::CWidgetStyle *)NULL);
+
+ // Get an (uninitialized) instance of the framed window as a class
+ // that derives from INxWindow.
+
+ NXWidgets::CNxTkWindow *window = createFramedWindow(control);
+ if (!window)
+ {
+ delete control;
+ return false;
+ }
+
+ // Open (and initialize) the window
+
+ bool success = window->open();
+ if (!success)
+ {
+ delete window;
+ window = (NXWidgets::CNxTkWindow *)0;
+ return false;
+ }
+
+ return window;
+}
+
+/**
+ * Set size and position of a window in the application area.
+ *
+ * @param window. The window to be resized and repositioned
+ * @param fullscreen. True: Use full screen
+ *
+ * @return true on success
+ */
+
+void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen)
+{
+ // Get the physical size of the display
+
+ struct nxgl_size_s displaySize;
+ getDisplaySize(displaySize);
+
+ // Now position and size the application. This will depend on the position and
+ // orientation of the task bar.
+
+ struct nxgl_point_s pos;
+ struct nxgl_size_s size;
+
+ // In fullscreen mode, the application window gets everything
+
+ if (fullscreen)
+ {
+ pos.x = 0;
+ pos.y = 0;
+
+ size.w = displaySize.w;
+ size.h = displaySize.h;
+ }
+ else
+ {
+#if defined(CONFIG_NXWM_TASKBAR_TOP)
+ pos.x = 0;
+ pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
+
+ size.w = displaySize.w;
+ size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
+#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+ pos.x = 0;
+ pos.y = 0;
+
+ size.w = displaySize.w;
+ size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
+#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
+ pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
+ pos.y = 0;
+
+ size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
+ size.h = displaySize.h;
+#else
+ pos.x = 0;
+ pos.y = 0;
+
+ size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
+ size.h = displaySize.h;
+#endif
+ }
+
+ /* Set the size and position the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on failure.
+ */
+
+ window->setPosition(&pos);
+ window->setSize(&size);
+}
+
+/**
+ * Create the task bar window.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::createTaskbarWindow(void)
+{
+ // Create a raw window to present the task bar
+
+ m_taskbar = openRawWindow();
+ if (!m_taskbar)
+ {
+ return false;
+ }
+
+ // Get the size of the physical display
+
+ struct nxgl_size_s displaySize;
+ getDisplaySize(displaySize);
+
+ // Now position and size the task bar. This will depend on the position and
+ // orientation of the task bar.
+
+ struct nxgl_point_s pos;
+ struct nxgl_size_s size;
+
+#if defined(CONFIG_NXWM_TASKBAR_TOP)
+ pos.x = 0;
+ pos.y = 0;
+
+ size.w = displaySize.w;
+ size.h = CONFIG_NXWM_TASKBAR_WIDTH;
+#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+ pos.x = 0;
+ pos.y = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
+
+ size.w = displaySize.w;
+ size.h = CONFIG_NXWM_TASKBAR_WIDTH;
+#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
+ pos.x = 0;
+ pos.y = 0;
+
+ size.w = CONFIG_NXWM_TASKBAR_WIDTH;
+ size.h = displaySize.h;
+#else
+ pos.x = rect.getWidgth() - CONFIG_NXWM_TASKBAR_WIDTH;
+ pos.y = 0;
+
+ size.w = CONFIG_NXWM_TASKBAR_WIDTH;
+ size.h = displaySize.h;
+#endif
+
+ /* Set the size and position the window.
+ *
+ * @param pPos The new position of the window.
+ * @return True on success, false on failure.
+ */
+
+ m_taskbar->setPosition(&pos);
+ m_taskbar->setSize(&size);
+ return true;
+}
+
+/**
+ * Create the background window.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::createBackgroundWindow(void)
+{
+ // Create a raw window to present the background image
+
+ m_background = openRawWindow();
+ if (!m_background)
+ {
+ return false;
+ }
+
+ // Set the geometry to fit in the application window space
+
+ setApplicationGeometry(static_cast<NXWidgets::INxWindow*>(m_background), false);
+ return true;
+}
+
+/**
+ * Create the background image.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::createBackgroundImage(void)
+{
+ // Get the size of the display
+
+ struct nxgl_size_s windowSize;
+ if (!m_background->getSize(&windowSize))
+ {
+ return false;
+ }
+
+ // Get the widget control from the background window
+
+ NXWidgets::CWidgetControl *control = m_background->getWidgetControl();
+
+ // Create the bitmap object
+
+ NXWidgets::CRlePaletteBitmap *bitmap =
+ new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_BACKGROUND_IMAGE);
+
+ if (!bitmap)
+ {
+ return false;
+ }
+
+ // Get the size of the bitmap image
+
+ struct nxgl_size_s imageSize;
+ imageSize.w = bitmap->getWidth();
+ imageSize.h = (nxgl_coord_t)bitmap->getHeight();
+
+ // Pick an X/Y position such that the image will be centered in the display
+
+ struct nxgl_point_s imagePos;
+ if (imageSize.w >= windowSize.w)
+ {
+ imagePos.x = 0;
+ }
+ else
+ {
+ imagePos.x = (windowSize.w - imageSize.w) >> 1;
+ }
+
+ if (imageSize.h >= windowSize.h)
+ {
+ imagePos.y = 0;
+ }
+ else
+ {
+ imagePos.y = (windowSize.h - imageSize.h) >> 1;
+ }
+
+ // Now we have enough information to create the image
+
+ m_backImage = new NXWidgets::CImage(control, imagePos.x, imagePos.y,
+ imageSize.w, imageSize.h, bitmap);
+ if (!m_backImage)
+ {
+ delete bitmap;
+ return false;
+ }
+
+ // Configure the background image
+
+ m_backImage->setBorderless(true);
+ m_backImage->setRaisesEvents(false);
+ return true;
+}
+
+/**
+ * (Re-)draw the task bar window.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::redrawTaskbarWindow(void)
+{
+ // Only redraw the task bar if (1) the window manager has been started, AND
+ // (2) there is no top window (i.e., we are showing the background image), OR
+ // (3) there is a top window, but it is not full screen
+
+ if (m_started && (!m_topApp || !m_topApp->isFullScreen()))
+ {
+ // Get the widget control from the task bar
+
+ NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
+
+ // Get the graphics port for drawing on the background window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Get the size of the window
+
+ struct nxgl_size_s windowSize;
+ if (!m_taskbar->getSize(&windowSize))
+ {
+ return false;
+ }
+
+ // Raise the task bar to the top of the display. This is only necessary
+ // after stopping a full screen application. Other applications do not
+ // overlap the task bar and, hence, do not interfere.
+
+ m_taskbar->raise();
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR);
+
+ // Add a border to the task bar to delineate it from the background window
+
+ port->drawBevelledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR,
+ CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR);
+
+ // Begin adding icons in the upper left corner
+
+ struct nxgl_point_s taskbarPos;
+#if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+ taskbarPos.x = CONFIG_NXWM_TASKBAR_HSPACING;
+ taskbarPos.y = 0;
+#else
+ taskbarPos.x = 0;
+ taskbarPos.y = CONFIG_NXWM_TASKBAR_VSPACING;
+#endif
+
+ // Add each icon in the list of applications
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Get the icon associated with this application
+
+ NXWidgets::CImage *image = m_slots.at(i).image;
+
+ // Disable drawing of the icon image; disable events from the icon
+
+ image->disableDrawing();
+ image->setRaisesEvents(false);
+
+ // Get the size of the icon image
+
+ NXWidgets::CRect rect;
+ image->getPreferredDimensions(rect);
+
+ // Position the icon
+
+ struct nxgl_point_s iconPos;
+
+#if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+ // For horizontal task bars, the icons will be aligned along the top of
+ // the task bar
+
+ iconPos.x = taskbarPos.x;
+ iconPos.y = taskbarPos.y + CONFIG_NXWM_TASKBAR_VSPACING;
+#else
+ // For vertical task bars, the icons will be centered horizontally
+
+ iconPos.x = (windowSize.w - rect.getWidth()) >> 1;
+ iconPos.y = taskbarPos.y;
+#endif
+
+ // Set the position of the icon bitmap
+
+ (void)image->moveTo(iconPos.x, iconPos.y);
+
+ // Then re-draw the icon at the new position
+
+ image->enableDrawing();
+ image->redraw();
+ image->setRaisesEvents(true);
+
+ // Do we add icons left-to-right? Or top-to-bottom?
+
+#if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+ // left-to-right ... increment the X display position
+
+ taskbarPos.x += rect.getWidth() + CONFIG_NXWM_TASKBAR_HSPACING;
+ if (taskbarPos.x > windowSize.w)
+ {
+ break;
+ }
+#else
+ // top-to-bottom ... increment the Y display position
+
+ taskbarPos.y += rect.getHeight() + CONFIG_NXWM_TASKBAR_VSPACING;
+ if (taskbarPos.y > windowSize.h)
+ {
+ break;
+ }
+#endif
+ }
+
+ // If there is a top application then we must now raise it above the task
+ // bar so that itwill get the keyboard input.
+
+ raiseTopApplication();
+ }
+
+ // Return success (it is not a failure if the window manager is not started
+ // or the task bar is occluded by a full screen window.
+
+ return true;
+}
+
+/**
+ * Redraw the window at the top of the heirarchy.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::redrawTopApplication(void)
+{
+ // Check if there is already a top application
+
+ IApplication *app = m_topApp;
+ if (!app)
+ {
+ // No.. Search for that last, non-minimized application
+
+ for (int i = m_slots.size() - 1; i >= 0; i--)
+ {
+ IApplication *candidate = m_slots.at(i).app;
+ if (!candidate->isMinimized())
+ {
+ app = candidate;
+ break;
+ }
+ }
+ }
+
+ // Did we find one?
+
+ if (app)
+ {
+ // Yes.. make it the top application window and redraw it
+
+ return redrawApplicationWindow(app);
+ return true;
+ }
+ else
+ {
+ // Otherwise, there is no top application. Re-draw the background image.
+
+ m_topApp = (IApplication *)0;
+ return redrawBackgroundWindow();
+ }
+}
+
+/**
+ * Raise the top window to the top of the NXheirarchy.
+ *
+ * @return true on success
+ */
+
+void CTaskbar::raiseTopApplication(void)
+{
+ if (m_topApp)
+ {
+ // Every application provides a method to obtain its application window
+
+ IApplicationWindow *appWindow = m_topApp->getWindow();
+
+ // Each application window provides a method to get the underlying NX window
+
+ NXWidgets::INxWindow *window = appWindow->getWindow();
+
+ // Raise the application window to the top of the hierarchy
+
+ window->raise();
+ }
+}
+
+/**
+ * (Re-)draw the background window.
+ *
+ * @return true on success
+ */
+
+bool CTaskbar::redrawBackgroundWindow(void)
+{
+ // Get the widget control from the background window
+
+ NXWidgets::CWidgetControl *control = m_background->getWidgetControl();
+
+ // Get the graphics port for drawing on the background window
+
+ NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
+
+ // Get the size of the window
+
+ struct nxgl_size_s windowSize;
+ if (!m_background->getSize(&windowSize))
+ {
+ return false;
+ }
+
+ // Raise the background window to the top of the hierarchy
+
+ m_background->raise();
+
+ // Fill the entire window with the background color
+
+ port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR);
+
+ // Add a border to the task bar to delineate it from the task bar
+
+ port->drawBevelledRect(0, 0, windowSize.w, windowSize.h,
+ CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR,
+ CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR);
+
+ // Then re-draw the background image on the window
+
+ m_backImage->enableDrawing();
+ m_backImage->redraw();
+ return true;
+}
+
+/**
+ * Redraw the last application in the list of application maintained by
+ * the task bar.
+ *
+ * @param app. The new top application to draw
+ * @return true on success
+ */
+
+bool CTaskbar::redrawApplicationWindow(IApplication *app)
+{
+ // Mark the window as the top application
+
+ m_topApp = app;
+ app->setTopApplication(true);
+
+ // Disable drawing of the background image.
+
+ m_backImage->disableDrawing();
+
+ // Raise to top application to the top of the NX window heirarchy
+
+ raiseTopApplication();
+
+ // Every application provides a method to obtain its application window
+
+ IApplicationWindow *appWindow = app->getWindow();
+
+ // Re-draw the application window toolbar
+
+ appWindow->redraw();
+
+ // And re-draw the application window itself
+
+ app->redraw();
+ return true;
+}
+
+/**
+ * The application window is hidden (either it is minimized or it is
+ * maximized, but not at the top of the hierarchy)
+ *
+ * @param app. The application to hide
+ */
+
+void CTaskbar::hideApplicationWindow(IApplication *app)
+{
+ // The hidden window is certainly not the top application any longer
+ // If it was before then redrawTopApplication() will pick a new one (rather
+ // arbitrarily).
+
+ if (app->isTopApplication())
+ {
+ m_topApp = (IApplication *)0;
+ app->setTopApplication(false);
+ }
+
+ // We do not need to lower the application to the back.. the new top
+ // window will be raised instead.
+ //
+ // So all that we really have to do is to make sure that all of the
+ // components of the hidden window are inactive.
+
+ // Every application provides a method to obtain its application window
+
+ IApplicationWindow *appWindow = app->getWindow();
+
+ // Hide the application window toolbar
+
+ appWindow->hide();
+
+ // The hide the application window itself
+
+ app->hide();
+}
+
+/**
+ * Handle a widget action event. For CImage, this is a mouse button pre-release event.
+ *
+ * @param e The event data.
+ */
+
+void CTaskbar::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
+{
+ // Was a n ICON clicked?
+
+ for (int i = 0; i < m_slots.size(); i++)
+ {
+ // Is this it?
+
+ NXWidgets::CImage *image = m_slots.at(i).image;
+ if (image->isClicked())
+ {
+ // Was the icon minimized
+
+ IApplication *app = m_slots.at(i).app;
+ if (app->isMinimized())
+ {
+ // Maximize the application by moving its window to the top of
+ // the hierarchy and re-drawing it.
+
+ (void)maximizeApplication(app);
+ }
+
+ // No, it is not minimized. Is it already the top application?
+
+ else if (!app->isTopApplication())
+ {
+ /* Move window to the top of the hierarchy and re-draw it. */
+
+ (void)topApplication(app);
+ }
+
+ // Then break out of the loop
+
+ break;
+ }
+ }
+}
diff --git a/NxWidgets/nxwm/src/ctouchscreen.cxx b/NxWidgets/nxwm/src/ctouchscreen.cxx
new file mode 100644
index 000000000..ba25dd95f
--- /dev/null
+++ b/NxWidgets/nxwm/src/ctouchscreen.cxx
@@ -0,0 +1,530 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/ctouchscreen.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cunistd>
+#include <cerrno>
+#include <cfcntl>
+
+#include <sched.h>
+#include <pthread.h>
+#include <assert.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxconfig.hxx"
+#include "cwidgetcontrol.hxx"
+#include "cgraphicsport.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+#include "ctouchscreen.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+/* We want debug output from this file if either input/touchscreen or graphics debug is
+ * enabled.
+ */
+
+#if !defined(CONFIG_DEBUG_INPUT) && !defined(CONFIG_DEBUG_GRAPHICS)
+# undef dbg
+# undef vdbg
+# ifdef CONFIG_CPP_HAVE_VARARGS
+# define dbg(x...)
+# define vdbg(x...)
+# else
+# define dbg (void)
+# define vdbg (void)
+# endif
+#endif
+
+/********************************************************************************************
+ * CTouchscreen Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CTouchscreen Constructor
+ *
+ * @param server. An instance of the NX server. This will be needed for
+ * injecting mouse data.
+ * @param windowSize. The size of the physical window in pixels. This
+ * is needed for touchscreen scaling.
+ */
+
+CTouchscreen::CTouchscreen(NXWidgets::CNxServer *server, struct nxgl_size_s *windowSize)
+{
+ m_server = server; // Save the NX server
+ m_touchFd = -1; // Device driver is not opened
+ m_state = LISTENER_NOTRUNNING; // The listener thread is not running yet
+ m_enabled = false; // Normal forwarding is not enabled
+ m_capture = false; // There is no thread waiting for touchscreen data
+ m_calibrated = false; // We have no calibration data
+
+ // Save the window size
+
+ m_windowSize = *windowSize;
+
+ // Use the default touch data buffer
+
+ m_touch = &m_sample;
+
+ // Initialize the m_waitSem semaphore so that any waits for data will block
+
+ sem_init(&m_waitSem, 0, 0);
+}
+
+/**
+ * CTouchscreen Destructor
+ */
+
+CTouchscreen::~CTouchscreen(void)
+{
+ // Stop the listener thread
+
+ m_state = LISTENER_STOPREQUESTED;
+
+ // Wake up the listener thread so that it will use our buffer
+ // to receive data
+ // REVISIT: Need wait here for the listener thread to terminate
+
+ (void)pthread_kill(m_thread, CONFIG_NXWM_TOUCHSCREEN_SIGNO);
+
+ // Close the touchscreen device (or should these be done when the thread exits?)
+
+ if (m_touchFd >= 0)
+ {
+ std::close(m_touchFd);
+ }
+
+ // Destroy the semaphores that we created.
+
+ sem_destroy(&m_waitSem);
+}
+
+/**
+ * Start the touchscreen listener thread.
+ *
+ * @return True if the touchscreen listener thread was correctly started.
+ */
+
+bool CTouchscreen::start(void)
+{
+ pthread_attr_t attr;
+
+ vdbg("Starting listener\n");
+
+ // Start a separate thread to listen for touchscreen events
+
+ (void)pthread_attr_init(&attr);
+
+ struct sched_param param;
+ param.sched_priority = CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO;
+ (void)pthread_attr_setschedparam(&attr, &param);
+
+ (void)pthread_attr_setstacksize(&attr, CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK);
+
+ m_state = LISTENER_STARTED; // The listener thread has been started, but is not yet running
+
+ int ret = pthread_create(&m_thread, &attr, listener, (FAR void *)this);
+ if (ret != 0)
+ {
+ dbg("CTouchscreen::start: pthread_create failed: %d\n", ret);
+ return false;
+ }
+
+ // Detach from the thread
+
+ (void)pthread_detach(m_thread);
+
+ // Don't return until we are sure that the listener thread is running
+ // (or until it reports an error).
+
+ while (m_state == LISTENER_STARTED)
+ {
+ // Wait for the listener thread to wake us up when we really
+ // are connected.
+
+ (void)sem_wait(&m_waitSem);
+ }
+
+ // Then return true only if the listener thread reported successful
+ // initialization.
+
+ vdbg("Listener m_state=%d\n", (int)m_state);
+ return m_state == LISTENER_RUNNING;
+}
+
+/**
+ * Provide touchscreen calibration data. If calibration data is received (and
+ * the touchscreen is enabled), then received touchscreen data will be scaled
+ * using the calibration data and forward to the NX layer which dispatches the
+ * touchscreen events in window-relative positions to the correct NX window.
+ *
+ * @param data. A reference to the touchscreen data.
+ */
+
+void CTouchscreen::setCalibrationData(const struct SCalibrationData &caldata)
+{
+ // Save a copy of the calibration data
+
+ m_calibData = caldata;
+
+ // Note that we have calibration data. Data will now be scaled and forwarded
+ // to NX (unless we are still in cpature mode)
+
+ m_calibrated = true;
+
+ // Wake up the listener thread so that it will use our buffer
+ // to receive data
+
+ (void)pthread_kill(m_thread, CONFIG_NXWM_TOUCHSCREEN_SIGNO);
+}
+
+/**
+ * Capture raw driver data. This method will capture mode one raw touchscreen
+ * input. The normal use of this method is for touchscreen calibration.
+ *
+ * This function is not re-entrant: There may be only one thread waiting for
+ * raw touchscreen data.
+ *
+ * @return True if the raw touchscreen data was sucessfully obtained
+ */
+
+bool CTouchscreen::waitRawTouchData(struct touch_sample_s *touch)
+{
+ vdbg("Capturing touch input\n");
+
+ // Setup to cpature raw data into the user provided buffer
+
+ sched_lock();
+ m_touch = touch;
+ m_capture = true;
+
+ // Wake up the listener thread so that it will use our buffer
+ // to receive data
+
+ (void)pthread_kill(m_thread, CONFIG_NXWM_TOUCHSCREEN_SIGNO);
+
+ // And wait for touch data
+
+ int ret = OK;
+ while (m_capture)
+ {
+ ret = sem_wait(&m_waitSem);
+ DEBUGASSERT(ret == 0 || errno == EINTR);
+ }
+ sched_unlock();
+
+ // And return success. The listener thread will have (1) reset both
+ // m_touch and m_capture and (2) posted m_waitSem
+
+ vdbg("Returning touch input: %d\n", ret);
+ return ret == OK;
+}
+
+/**
+ * The touchscreen listener thread. This is the entry point of a thread that
+ * listeners for and dispatches touchscreens events to the NX server.
+ *
+ * @param arg. The CTouchscreen 'this' pointer cast to a void*.
+ * @return This function normally does not return but may return NULL on
+ * error conditions.
+ */
+
+FAR void *CTouchscreen::listener(FAR void *arg)
+{
+ CTouchscreen *This = (CTouchscreen *)arg;
+
+ vdbg("Listener started\n");
+
+ // Initialize the touchscreen device
+
+ int ret = arch_tcinitialize(CONFIG_NXWM_TOUCHSCREEN_DEVNO);
+ if (ret < 0)
+ {
+ dbg("ERROR Failed initialize the touchscreen device: %d\n", ret);
+ This->m_state = LISTENER_FAILED;
+ sem_post(&This->m_waitSem);
+ return (FAR void *)0;
+ }
+
+ // Open the touchscreen device that we just created.
+
+ This->m_touchFd = std::open(CONFIG_NXWM_TOUCHSCREEN_DEVPATH, O_RDONLY);
+ if (This->m_touchFd < 0)
+ {
+ dbg("ERROR Failed to open %s for reading: %d\n",
+ CONFIG_NXWM_TOUCHSCREEN_DEVPATH, errno);
+ This->m_state = LISTENER_FAILED;
+ sem_post(&This->m_waitSem);
+ return (FAR void *)0;
+ }
+
+ // Indicate that we have successfully initialized
+
+ This->m_state = LISTENER_RUNNING;
+ sem_post(&This->m_waitSem);
+
+ // Now loop, reading and dispatching touchscreen data
+
+ while (This->m_state == LISTENER_RUNNING)
+ {
+ // We may be running in one of three states
+ //
+ // 1. Disabled or no calibration data: In this case, just wait for a signal
+ // indicating that the state has changed.
+ // 2. Performing calibration and reporting raw touchscreen data
+ // 3. Normal operation, reading touchscreen data and forwarding it to NX
+
+ // Check if we need to collect touchscreen data. That is, that we are enabled,
+ // AND have calibratation data OR if we need to collect data for the calbration
+ // process.
+
+ while ((!This->m_enabled || !This->m_calibrated) && !This->m_capture)
+ {
+ // No.. just sleep. This sleep will be awakened by a signal if there
+ // is anything for this thread to do
+
+ sleep(1);
+
+ // We woke up here either because the one second elapsed or because we
+ // were signalled. In either case we need to check the conditions and
+ // determine what to do next.
+ }
+
+ // We are going to collect a sample..
+ //
+ // The sample pointer can change dynamically let's sample it once
+ // and stick with that pointer.
+
+ struct touch_sample_s *sample = This->m_touch;
+
+ // Read one touchscreen sample
+
+ vdbg("Listening for sample %p\n", sample);
+ DEBUGASSERT(sample);
+ ssize_t nbytes = read(This->m_touchFd, sample,
+ sizeof(struct touch_sample_s));
+
+ // Check for errors
+
+ if (nbytes < 0)
+ {
+ // The only expect error is to be interrupt by a signal
+#ifdef CONFIG_DEBUG
+ int errval = errno;
+
+ dbg("read %s failed: %d\n",
+ CONFIG_NXWM_TOUCHSCREEN_DEVPATH, errval);
+ DEBUGASSERT(errval == EINTR);
+#endif
+ }
+
+ // On a truly success read, the size of the returned data will
+ // be exactly the size of one touchscreen sample
+
+ else if (nbytes == sizeof(struct touch_sample_s))
+ {
+ // Looks like good touchscreen input... process it
+
+ This->handleMouseInput(sample);
+ }
+ else
+ {
+ dbg("ERROR Unexpected read size=%d, expected=%d\n",
+ nbytes, sizeof(struct touch_sample_s));
+ }
+ }
+
+ // We should get here only if we were asked to terminate via
+ // m_state = LISTENER_STOPREQUESTED
+
+ vdbg("Listener exiting\n");
+ This->m_state = LISTENER_TERMINATED;
+ return (FAR void *)0;
+}
+
+/**
+ * Inject touchscreen data into NX as mouse intput
+ */
+
+void CTouchscreen::handleMouseInput(struct touch_sample_s *sample)
+{
+ vdbg("Touch id: %d flags: %02x x: %d y: %d h: %d w: %d pressure: %d\n",
+ sample->point[0].id, sample->point[0].flags, sample->point[0].x,
+ sample->point[0].y, sample->point[0].h, sample->point[0].w,
+ sample->point[0].pressure);
+
+ // Verify the touchscreen data
+
+ if (sample->npoints < 1 ||
+ ((sample->point[0].flags & TOUCH_POS_VALID) == 0 &&
+ (sample->point[0].flags & TOUCH_UP) == 0))
+ {
+ // The pen is (probably) down, but we have do not have valid
+ // X/Y position data to report. This should not happen.
+
+ return;
+ }
+
+ // Was this data captured by some external logic? (probably the
+ // touchscreen calibration logic)
+
+ if (m_capture && sample != &m_sample)
+ {
+ // Yes.. let waitRawTouchData know that the data is available
+ // and restore normal buffering
+
+ m_touch = &m_sample;
+ m_capture = false;
+ sem_post(&m_waitSem);
+ return;
+ }
+
+ // Sanity checks. Re-directed touch data should never reach this point.
+ // After posting m_waitSem, m_touch might change asynchronously.
+
+ DEBUGASSERT(sample == &m_sample);
+
+ // Check if normal processing of touchscreen data is enaable. Check if
+ // we have been given calibration data.
+
+ if (!m_enabled || !m_calibrated)
+ {
+ // No.. we are not yet ready to process touchscreen data (We don't
+ // really every get to this condition.
+
+ return;
+ }
+
+ // Now we will inject the touchscreen into NX as mouse input. First
+ // massage the data a litle so that it behaves a little more like a
+ // mouse with only a left button
+ //
+ // Was the button up or down?
+
+ uint8_t buttons;
+ if ((sample->point[0].flags & (TOUCH_DOWN|TOUCH_MOVE)) != 0)
+ {
+ buttons = NX_MOUSE_LEFTBUTTON;
+ }
+ else if ((sample->point[0].flags & TOUCH_UP) != 0)
+ {
+ buttons = NX_MOUSE_NOBUTTONS;
+ }
+ else
+ {
+ // The pen is neither up nor down. This should not happen
+
+ return;
+ }
+
+ // Get the "raw" touch coordinates (if they are valid)
+
+ nxgl_coord_t x;
+ nxgl_coord_t y;
+
+ if ((sample->point[0].flags & TOUCH_POS_VALID) == 0)
+ {
+ x = 0;
+ y = 0;
+ }
+ else
+ {
+ // We have valid coordinates. Get the raw touch
+ // position from the sample
+
+ uint32_t rawX = (uint32_t)sample->point[0].x;
+ uint32_t rawY = (uint32_t)sample->point[0].y;
+
+ // Get the fixed precision, scaled X and Y values
+
+ b16_t scaledX = rawX * m_calibData.xSlope + m_calibData.xOffset;
+ b16_t scaledY = rawY * m_calibData.ySlope + m_calibData.yOffset;
+
+ // Get integer scaled X and Y positions and clip
+ // to fix in the window
+
+ int32_t bigX = b16toi(scaledX + b16HALF);
+ int32_t bigY = b16toi(scaledY + b16HALF);
+
+ // Clip to the display
+
+ if (bigX < 0)
+ {
+ x = 0;
+ }
+ else if (bigX >= m_windowSize.w)
+ {
+ x = m_windowSize.w - 1;
+ }
+ else
+ {
+ x = (nxgl_coord_t)bigX;
+ }
+
+ if (bigY < 0)
+ {
+ y = 0;
+ }
+ else if (bigY >= m_windowSize.h)
+ {
+ y = m_windowSize.h - 1;
+ }
+ else
+ {
+ y = (nxgl_coord_t)bigY;
+ }
+
+ vdbg("raw: (%d, %d) scaled: (%d, %d)\n", rawX, rawY, x, y);
+ }
+
+ // Get the server handle and "inject the mouse data
+
+ NXHANDLE handle = m_server->getServer();
+ (void)nx_mousein(handle, x, y, buttons);
+}
+
+
+
diff --git a/NxWidgets/nxwm/src/cwindowmessenger.cxx b/NxWidgets/nxwm/src/cwindowmessenger.cxx
new file mode 100644
index 000000000..032dd1bf2
--- /dev/null
+++ b/NxWidgets/nxwm/src/cwindowmessenger.cxx
@@ -0,0 +1,230 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/cwindowmessenger.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <cfcntl>
+#include <cerrno>
+
+#include <debug.h>
+
+#include "nxwmconfig.hxx"
+#include "cstartwindow.hxx"
+#include "cwindowmessenger.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * CWindowMessenger Method Implementations
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/**
+ * CWindowMessenger Constructor
+ *
+ * @param style The default style that all widgets on this display
+ * should use. If this is not specified, the widget will use the
+ * values stored in the defaultCWidgetStyle object.
+ */
+
+CWindowMessenger::CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style)
+: NXWidgets::CWidgetControl(style)
+{
+ // Open a message queue to communicate with the start window task. We need to create
+ // the message queue if it does not exist.
+
+ struct mq_attr attr;
+ attr.mq_maxmsg = CONFIG_NXWM_STARTWINDOW_MXMSGS;
+ attr.mq_msgsize = sizeof(struct SStartWindowMessage);
+ attr.mq_flags = 0;
+
+ m_mqd = mq_open(g_startWindowMqName, O_WRONLY|O_CREAT, 0666, &attr);
+ if (m_mqd == (mqd_t)-1)
+ {
+ gdbg("ERROR: mq_open(%s) failed: %d\n", g_startWindowMqName, errno);
+ }
+
+ // Add ourself to the list of window event handlers
+
+ addWindowEventHandler(this);
+}
+
+/**
+ * CWindowMessenger Destructor.
+ */
+
+CWindowMessenger::~CWindowMessenger(void)
+{
+ // Remove ourself from the list of the window event handlers
+
+ removeWindowEventHandler(this);
+
+ // Close the message queue
+
+ (void)mq_close(m_mqd);
+}
+
+/**
+ * Handle an NX window mouse input event.
+ *
+ * @param e The event data.
+ */
+
+#ifdef CONFIG_NX_MOUSE
+void CWindowMessenger::handleMouseEvent(void)
+{
+ // The logic path here is tortuous but flexible:
+ //
+ // 1. A listener thread receives mouse or touchscreen input and injects
+ // that into NX via nx_mousein
+ // 2. In the multi-user mode, this will send a message to the NX server
+ // 3. The NX server will determine which window gets the mouse input
+ // and send a window event message to the NX listener thread.
+ // 4. The NX listener thread receives a windows event. The NX listener thread
+ // which is part of CTaskBar and was created when NX server connection was
+ // established). This event may be a positional change notification, a
+ // redraw request, or mouse or keyboard input. In this case, mouse input.
+ // 5. The NX listener thread handles the message by calling nx_eventhandler().
+ // nx_eventhandler() dispatches the message by calling a method in the
+ // NXWidgets::CCallback instance associated with the window.
+ // NXWidgets::CCallback is a part of the CWidgetControl.
+ // 6. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process
+ // the event.
+ // 7. NXWidgets::CWidgetControl records the new state data and raises a
+ // window event.
+ // 8. NXWidgets::CWindowEventHandlerList will give the event to this method
+ // NxWM::CWindowMessenger.
+ // 9. This NxWM::CWindowMessenger method will send the a message on a well-
+ // known message queue.
+ // 10. This CStartWindow::startWindow task will receive and process that
+ // message by calling CWidgetControl::pollEvents()
+
+ struct SStartWindowMessage outmsg;
+ outmsg.msgId = MSGID_MOUSE_INPUT;
+ outmsg.instance = (FAR void *)static_cast<CWidgetControl*>(this);
+
+ int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
+ CONFIG_NXWM_STARTWINDOW_MXMPRIO);
+ if (ret < 0)
+ {
+ gdbg("ERROR: mq_send failed: %d\n", errno);
+ }
+}
+#endif
+
+/**
+ * Handle a NX window keyboard input event.
+ */
+
+#ifdef CONFIG_NX_KBD
+void CWindowMessenger::handleKeyboardEvent(void)
+{
+ // The logic path here is tortuous but flexible:
+ //
+ // 1. A listener thread receives keyboard input and injects that into NX
+ // via nx_kbdin.
+ // 2. In the multi-user mode, this will send a message to the NX server
+ // 3. The NX server will determine which window gets the keyboard input
+ // and send a window event message to the NX listener thread.
+ // 4. The NX listener thread receives a windows event. The NX listener thread
+ // which is part of CTaskBar and was created when NX server connection was
+ // established). This event may be a positional change notification, a
+ // redraw request, or mouse or keyboard input. In this case, keyboard input.
+ // 5. The NX listener thread handles the message by calling nx_eventhandler().
+ // nx_eventhandler() dispatches the message by calling a method in the
+ // NXWidgets::CCallback instance associated with the window.
+ // NXWidgets::CCallback is a part of the CWidgetControl.
+ // 6. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process
+ // the event.
+ // 7. NXWidgets::CWidgetControl records the new state data and raises a
+ // window event.
+ // 8. NXWidgets::CWindowEventHandlerList will give the event to this method
+ // NxWM::CWindowMessenger.
+ // 9. This NxWM::CWindowMessenger method will send the a message on a well-
+ // known message queue.
+ // 10. This CStartWindow::startWindow task will receive and process that
+ // message by calling CWidgetControl::pollEvents()
+
+ struct SStartWindowMessage outmsg;
+ outmsg.msgId = MSGID_KEYBOARD_INPUT;
+ outmsg.instance = (FAR void *)static_cast<CWidgetControl*>(this);
+
+ int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
+ CONFIG_NXWM_STARTWINDOW_MXMPRIO);
+ if (ret < 0)
+ {
+ gdbg("ERROR: mq_send failed: %d\n", errno);
+ }
+}
+#endif
+
+/**
+ * Handle a NX window blocked event. This handler is called when we
+ * receive the BLOCKED message meaning that there are no further pending
+ * actions on the window. It is now safe to delete the window.
+ *
+ * This is handled by sending a message to the start window thread (vs just
+ * calling the destructors) because in the case where an application
+ * destroys itself (because of pressing the stop button), then we need to
+ * unwind and get out of the application logic before destroying all of its
+ * objects.
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+void CWindowMessenger::handleBlockedEvent(FAR void *arg)
+{
+ // Send a message to destroy the window isntance at a later time
+
+ struct SStartWindowMessage outmsg;
+ outmsg.msgId = MSGID_DESTROY_APP;
+ outmsg.instance = arg;
+
+ gdbg("Sending MSGID_DESTROY_APP with instance=%p\n", arg);
+ int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
+ CONFIG_NXWM_STARTWINDOW_MXMPRIO);
+ if (ret < 0)
+ {
+ gdbg("ERROR: mq_send failed: %d\n", errno);
+ }
+}
+
diff --git a/NxWidgets/nxwm/src/glyph_calculator.cxx b/NxWidgets/nxwm/src/glyph_calculator.cxx
new file mode 100644
index 000000000..3d8bb97bd
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_calculator.cxx
@@ -0,0 +1,191 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_calculator.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 25
+#define BITMAP_NCOLUMNS 24
+#define BITMAP_NLUTCODES 8
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xfcfcfc, 0xb8bcbc, 0xf8f8f8, 0x6890c8, 0x384c80, 0xe8e8e8, 0x646464, 0x909090 /* Codes 0-7 */
+};
+
+static const uint32_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xffffff, 0xc9cccc, 0xf9f9f9, 0x8dabd5, 0x69789f, 0xededed, 0x8a8a8a, 0xababab /* Codes 0-7 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xffff, 0xbdf7, 0xffdf, 0x6c99, 0x3a70, 0xef5d, 0x632c, 0x9492 /* Codes 0-7 */
+};
+
+static const uint16_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xffff, 0xce79, 0xffdf, 0x8d5a, 0x6bd3, 0xef7d, 0x8c51, 0xad55 /* Codes 0-7 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+static const uint8_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xfc, 0xba, 0xf8, 0x8a, 0x4b, 0xe8, 0x64, 0x90 /* Codes 0-7 */
+};
+
+static const uint8_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xff, 0xcb, 0xf9, 0xa6, 0x77, 0xed, 0x8a, 0xab /* Codes 0-7 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+static const nxgl_mxpixel_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xff, 0xb7, 0xff, 0x73, 0x2a, 0xff, 0x6d, 0x92 /* Codes 0-7 */
+};
+
+static const nxgl_mxpixel_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xff, 0xdb, 0xff, 0x97, 0x6e, 0xff, 0x92, 0xb6 /* Codes 0-7 */
+};
+
+# endif /* CONFIG_NXWIDGETS_GREYSCALE */
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_calculatorRleEntries[] =
+{
+ { 23, 0}, { 1, 1}, /* Row 0 */
+ { 1, 0}, { 21, 1}, { 1, 2}, { 1, 1}, /* Row 1 */
+ { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 2 */
+ { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 3 */
+ { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 4 */
+ { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 5 */
+ { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 6 */
+ { 1, 2}, { 1, 1}, { 20, 4}, { 1, 0}, { 1, 1}, /* Row 7 */
+ { 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 8 */
+ { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 9 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 10 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 11 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 12 */
+ { 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 13 */
+ { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 14 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 15 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 16 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 17 */
+ { 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 18 */
+ { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 19 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 20 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 21 */
+ { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
+ { 1, 2}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 22 */
+ { 23, 0}, { 1, 1}, /* Row 23 */
+ { 24, 1} /* Row 24 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_calculatorBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_calculatorNormalLut, // Index 0: Unselected LUT
+ g_calculatorBrightlLut, // Index 1: Selected LUT
+ },
+ g_calculatorRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_calibration.cxx b/NxWidgets/nxwm/src/glyph_calibration.cxx
new file mode 100644
index 000000000..fab2902fe
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_calibration.cxx
@@ -0,0 +1,198 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_calibration.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 21
+#define BITMAP_NCOLUMNS 24
+#define BITMAP_NLUTCODES 6
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xfcfcfc, 0xacacac, 0xd8d8d8, 0xd8881c, 0x9c6014 /* Codes 1-5 */
+};
+
+static const uint32_t g_calibrationSelectedLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xffffff, 0xc0c0c0, 0xe1e1e1, 0xe1a554, 0xb4874e /* Codes 1-5 */
+};
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xffff, 0xad75, 0xdedb, 0xdc43, 0x9b02 /* Codes 1-5 */
+};
+
+static const uint16_t g_calibrationSelectedLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xffff, 0xc618, 0xe71c, 0xe52a, 0xb429 /* Codes 1-5 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xfc, 0xac, 0xd8, 0x93, 0x69 /* Codes 1-5 */
+};
+
+static const uint8_t g_calibrationSelectedLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xff, 0xc0, 0xe1, 0xad, 0x8d /* Codes 1-5 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xff, 0xb6, 0xdb, 0xd0, 0x8c /* Codes 1-5 */
+};
+
+static const nxgl_mxpixel_t g_calibrationSelectedLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xff, 0xdb, 0xff, 0xf5, 0xb1 /* Codes 1-5 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[] =
+{
+ { 11, 0}, { 1, 1}, { 1, 2}, { 6, 0}, { 1, 3}, { 1, 2}, { 3, 0}, /* Row 0 */
+ { 11, 0}, { 1, 1}, { 1, 2}, { 4, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 0}, /* Row 1 */
+ { 11, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 3}, { 1, 2}, /* Row 2 */
+ { 3, 0},
+ { 11, 0}, { 1, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 3}, { 4, 0}, /* Row 3 */
+ { 9, 0}, { 2, 1}, { 2, 3}, { 2, 2}, { 4, 0}, { 1, 3}, { 4, 0}, /* Row 4 */
+ { 3, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 1}, { 1, 2}, /* Row 5 */
+ { 5, 0}, { 1, 1}, { 2, 3}, { 3, 0},
+ { 2, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 1}, { 1, 2}, /* Row 6 */
+ { 4, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 2, 0},
+ { 3, 0}, { 1, 2}, { 1, 3}, { 2, 2}, { 4, 0}, { 1, 1}, { 1, 2}, { 4, 0}, /* Row 7 */
+ { 1, 1}, { 3, 0}, { 1, 3}, { 2, 0},
+ { 4, 0}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, { 1, 3}, /* Row 8 */
+ { 3, 0}, { 2, 3}, { 1, 0},
+ { 3, 0}, { 1, 1}, { 2, 3}, { 5, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, /* Row 9 */
+ { 5, 0}, { 1, 3}, { 1, 0},
+ { 2, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 4, 0}, { 1, 1}, { 1, 2}, /* Row 10 */
+ { 3, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0},
+ { 2, 0}, { 1, 1}, { 3, 0}, { 1, 3}, { 4, 0}, { 1, 1}, { 1, 2}, { 3, 0}, /* Row 11 */
+ { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0},
+ { 1, 0}, { 1, 1}, { 1, 3}, { 2, 4}, { 1, 5}, { 2, 3}, { 3, 0}, { 1, 1}, /* Row 12 */
+ { 1, 2}, { 2, 0}, { 9, 3},
+ { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 13 */
+ { 1, 1}, { 1, 2}, { 11, 0},
+ { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 14 */
+ { 1, 1}, { 1, 2}, { 11, 0},
+ { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 15 */
+ { 1, 1}, { 1, 2}, { 11, 0},
+ { 9, 3}, { 2, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 16 */
+ { 11, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 17 */
+ { 10, 0}, { 1, 1}, { 2, 3}, { 1, 2}, { 10, 0}, /* Row 18 */
+ { 5, 0}, { 4, 1}, { 6, 3}, { 4, 2}, { 5, 0}, /* Row 19 */
+ { 4, 0}, { 4, 1}, { 8, 3}, { 4, 2}, { 4, 0}, /* Row 20 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_calibrationBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_calibrationNormalLut, // Index 0: Unselected LUT
+ g_calibrationSelectedLut, // Index 1: Selected LUT
+ },
+ g_calibrationRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_cmd.cxx b/NxWidgets/nxwm/src/glyph_cmd.cxx
new file mode 100644
index 000000000..816c888c5
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_cmd.cxx
@@ -0,0 +1,181 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_cmd.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 22
+#define BITMAP_NCOLUMNS 25
+#define BITMAP_NLUTCODES 8
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_cmdNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x909090, 0x000000, 0xb4fcfc, 0xb4d8fc, 0x6cb4fc, 0x6c6c6c, 0xfcfcfc, 0x484848
+};
+
+static const uint32_t g_cmdBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xababab, 0x3f3f3f, 0xc6fcfc, 0xc6e1fc, 0x90c6fc, 0x909090, 0xfcfcfc, 0x757575
+};
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_cmdNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x9492, 0x0000, 0xb7ff, 0xb6df, 0x6dbf, 0x6b6d, 0xffff, 0x4a49
+};
+
+static const uint16_t g_cmdBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xad55, 0x39e7, 0xc7ff, 0xc71f, 0x963f, 0x9492, 0xffff, 0x73ae
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_cmdNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x90, 0x00, 0xe6, 0xd1, 0xa6, 0x6c, 0xfc, 0x48
+};
+
+static const uint8_t g_cmdBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xab, 0x3f, 0xeb, 0xdc, 0xbc, 0x90, 0xfc, 0x75
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_cmdNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x92, 0x00, 0xbf, 0xbb, 0x77, 0x6d, 0xff, 0x49
+};
+
+static const nxgl_mxpixel_t g_cmdBrightlLut[BITMAP_NLUTCODES] =
+{
+ 0xb6, 0x24, 0xdf, 0xdf, 0x9b, 0x92, 0xff, 0x6d
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_cmdRleEntries[] =
+{
+ { 24, 0}, { 1, 1}, /* Row 0 */
+ { 24, 0}, { 1, 1}, /* Row 1 */
+ { 2, 0}, { 1, 2}, { 13, 3}, { 7, 4}, { 1, 0}, { 1, 1}, /* Row 2 */
+ { 2, 0}, { 3, 3}, { 18, 4}, { 1, 0}, { 1, 1}, /* Row 3 */
+ { 2, 0}, { 3, 3}, { 18, 4}, { 1, 0}, { 1, 1}, /* Row 4 */
+ { 24, 0}, { 1, 1}, /* Row 5 */
+ { 1, 0}, { 22, 1}, { 1, 0}, { 1, 1}, /* Row 6 */
+ { 1, 0}, { 1, 1}, { 21, 5}, { 1, 0}, { 1, 1}, /* Row 7 */
+ { 1, 0}, { 1, 1}, { 21, 5}, { 1, 0}, { 1, 1}, /* Row 8 */
+ { 1, 0}, { 1, 1}, { 2, 5}, { 1, 6}, { 18, 5}, { 1, 0}, { 1, 1}, /* Row 9 */
+ { 1, 0}, { 1, 1}, { 3, 5}, { 1, 6}, { 17, 5}, { 1, 0}, { 1, 1}, /* Row 10 */
+ { 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 16, 5}, { 1, 0}, { 1, 1}, /* Row 11 */
+ { 1, 0}, { 1, 1}, { 5, 5}, { 1, 6}, { 15, 5}, { 1, 0}, { 1, 1}, /* Row 12 */
+ { 1, 0}, { 1, 1}, { 6, 5}, { 1, 6}, { 14, 5}, { 1, 0}, { 1, 1}, /* Row 13 */
+ { 1, 0}, { 1, 1}, { 5, 5}, { 1, 6}, { 1, 7}, { 14, 5}, { 1, 0}, { 1, 1}, /* Row 14 */
+ { 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 1, 7}, { 15, 5}, { 1, 0}, { 1, 1}, /* Row 15 */
+ { 1, 0}, { 1, 1}, { 3, 5}, { 1, 6}, { 1, 7}, { 4, 5}, { 9, 6}, { 3, 5}, /* Row 16 */
+ { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 2, 5}, { 1, 6}, { 1, 7}, { 6, 5}, { 9, 7}, { 2, 5}, /* Row 17 */
+ { 1, 0}, { 1, 1},
+ { 1, 0}, { 1, 1}, { 2, 5}, { 1, 7}, { 18, 5}, { 1, 0}, { 1, 1}, /* Row 18 */
+ { 1, 0}, { 1, 1}, { 21, 5}, { 1, 0}, { 1, 1}, /* Row 19 */
+ { 24, 0}, { 1, 1}, /* Row 20 */
+ { 25, 1}, /* Row 21 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_cmdBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_cmdNormalLut, // Index 0: Unselected LUT
+ g_cmdBrightlLut, // Index 1: Selected LUT
+ },
+ g_cmdRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_minimize.cxx b/NxWidgets/nxwm/src/glyph_minimize.cxx
new file mode 100644
index 000000000..4dd95f9f2
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_minimize.cxx
@@ -0,0 +1,179 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_minimize.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 21
+#define BITMAP_NCOLUMNS 21
+#define BITMAP_NLUTCODES 8
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x2448b4, 0x486cd8, 0x0024b4, 0x0024d8, 0x242490, 0x0000b4, 0xfcfcfc, 0xd8fcfc /* Codes 0-7 */
+};
+
+static const uint32_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
+{
+ 0x5a75c6, 0x7590e1, 0x3f5ac6, 0x3f5ae1, 0x5a5aab, 0x3f3fc6, 0xfcfcfc, 0xe1fcfc /* Codes 0-7 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x2256, 0x4b7b, 0x0136, 0x013b, 0x2132, 0x0016, 0xffff, 0xdfff /* Codes 0-7 */
+};
+
+static const uint16_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
+{
+ 0x5bb8, 0x749c, 0x3ad8, 0x3adc, 0x5ad5, 0x39f8, 0xffff, 0xe7ff /* Codes 0-7 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x49, 0x6d, 0x29, 0x2d, 0x30, 0x14, 0xfc, 0xf1 /* Codes 0-7 */
+};
+
+static const uint8_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
+{
+ 0x76, 0x91, 0x5e, 0x61, 0x63, 0x4e, 0xfc, 0xf3 /* Codes 0-7 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
+{
+ 0x2a, 0x4f, 0x06, 0x07, 0x26, 0x02, 0xff, 0xdf /* Codes 0-7 */
+};
+
+static const uint8_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
+{
+ 0x4f, 0x73, 0x2b, 0x2b, 0x4a, 0x27, 0xff, 0xff /* Codes 0-7 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_minimizeRleEntries[] =
+{
+ { 1, 0}, { 20, 1}, /* Row 0 */
+ { 1, 1}, { 5, 2}, { 5, 3}, { 8, 2}, { 1, 4}, { 1, 0}, /* Row 1 */
+ { 1, 1}, { 3, 2}, { 8, 3}, { 8, 2}, { 1, 4}, /* Row 2 */
+ { 1, 1}, { 2, 2}, { 10, 3}, { 7, 2}, { 1, 4}, /* Row 3 */
+ { 1, 1}, { 1, 2}, { 10, 3}, { 8, 2}, { 1, 4}, /* Row 4 */
+ { 1, 1}, { 1, 2}, { 9, 3}, { 9, 2}, { 1, 4}, /* Row 5 */
+ { 1, 1}, { 9, 3}, { 9, 2}, { 1, 5}, { 1, 4}, /* Row 6 */
+ { 1, 1}, { 8, 3}, { 10, 2}, { 1, 5}, { 1, 4}, /* Row 7 */
+ { 1, 1}, { 7, 3}, { 11, 2}, { 1, 5}, { 1, 4}, /* Row 8 */
+ { 1, 1}, { 1, 2}, { 4, 3}, { 12, 2}, { 2, 5}, { 1, 4}, /* Row 9 */
+ { 1, 1}, { 2, 2}, { 1, 3}, { 14, 2}, { 2, 5}, { 1, 4}, /* Row 10 */
+ { 1, 1}, { 16, 2}, { 3, 5}, { 1, 4}, /* Row 11 */
+ { 1, 1}, { 15, 2}, { 4, 5}, { 1, 4}, /* Row 12 */
+ { 1, 1}, { 13, 2}, { 6, 5}, { 1, 4}, /* Row 13 */
+ { 1, 1}, { 11, 2}, { 8, 5}, { 1, 4}, /* Row 14 */
+ { 1, 1}, { 8, 2}, { 11, 5}, { 1, 4}, /* Row 15 */
+ { 1, 1}, { 4, 2}, { 15, 5}, { 1, 4}, /* Row 16 */
+ { 1, 1}, { 2, 2}, { 14, 6}, { 1, 7}, { 2, 5}, { 1, 4}, /* Row 17 */
+ { 1, 1}, { 1, 2}, { 1, 5}, { 15, 7}, { 2, 5}, { 1, 4}, /* Row 18 */
+ { 1, 1}, { 19, 5}, { 1, 0}, /* Row 19 */
+ { 1, 1}, { 1, 0}, { 17, 4}, { 1, 0}, { 1, 1}, /* Row 20 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_minimizeBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_minimizeNormalLut, // Index 0: Unselected LUT
+ g_minimizeBrightLut, // Index 1: Selected LUT
+ },
+ g_minimizeRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_nsh.cxx b/NxWidgets/nxwm/src/glyph_nsh.cxx
new file mode 100644
index 000000000..69bccd344
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_nsh.cxx
@@ -0,0 +1,215 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_nsh.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 25
+#define BITMAP_NCOLUMNS 25
+#define BITMAP_NLUTCODES 36
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_nshLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xffffdb, 0x4949db, 0x2424db, 0x4924db, 0xdbdbff, 0x6d6ddb, 0x6d92db, 0x2424b6, /* Codes 1-8 */
+ 0xffdbdb, 0xdbffff, 0x4992db, 0x24246d, 0xffffff, 0x6db6db, 0x242492, 0x4924ff, /* Codes 9-16 */
+ 0x49b6db, 0x6d6db6, 0x92b6db, 0xb6dbdb, 0xb6dbff, 0x2424ff, 0x9292db, 0x9292b6, /* Codes 17-24 */
+ 0x00006d, 0x9292ff, 0x240092, 0x24006d, 0x4949ff, 0x494992, 0x92b6ff, 0xb6b6db, /* Codes 25-32 */
+ 0x4924b6, 0x92dbdb, 0x926ddb /* Codes 33-35 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_nshLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xfffb, 0x4a5b, 0x213b, 0x493b, 0xdedf, 0x6b7b, 0x6c9b, 0x2136, 0xfedb, 0xdfff, /* Codes 1-10 */
+ 0x4c9b, 0x212d, 0xffff, 0x6dbb, 0x2132, 0x493f, 0x4dbb, 0x6b76, 0x95bb, 0xb6db, /* Codes 11-20 */
+ 0xb6df, 0x213f, 0x949b, 0x9496, 0x000d, 0x949f, 0x2012, 0x200d, 0x4a5f, 0x4a52, /* Codes 21-30 */
+ 0x95bf, 0xb5bb, 0x4936, 0x96db, 0x937b /* Codes 31-35 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_nshLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xfa, 0x59, 0x38, 0x43, 0xdf, 0x79, 0x8f, 0x34, 0xe5, 0xf4, 0x84, 0x2c, 0xff, /* Codes 1-13 */
+ 0xa4, 0x30, 0x48, 0x99, 0x75, 0xaf, 0xcf, 0xd4, 0x3c, 0x9a, 0x96, 0x0c, 0x9e, /* Codes 14-16 */
+ 0x1b, 0x17, 0x5d, 0x51, 0xb3, 0xba, 0x3f, 0xc5, 0x84 /* Codes 27-35 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_nshLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0xff, 0x4b, 0x27, 0x47, 0xdb, 0x6f, 0x73, 0x26, 0xfb, 0xdf, 0x53, 0x25, 0xff, /* Codes 1-13 */
+ 0x77, 0x26, 0x47, 0x57, 0x6e, 0x97, 0xbb, 0xbb, 0x27, 0x93, 0x92, 0x01, 0x93, /* Codes 14-16 */
+ 0x22, 0x21, 0x4b, 0x4a, 0x97, 0xb7, 0x46, 0x9b, 0x8f /* Codes 27-35 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_nshRleEntries[] =
+{
+ { 11, 0}, { 1, 1}, { 1, 2}, { 1, 1}, { 11, 0}, /* Row 0 */
+ { 11, 0}, { 3, 3}, { 11, 0}, /* Row 1 */
+ { 9, 0}, { 4, 3}, { 1, 4}, { 2, 3}, { 9, 0}, /* Row 2 */
+ { 4, 0}, { 1, 5}, { 4, 0}, { 2, 3}, { 1, 6}, { 1, 7}, { 1, 8}, { 1, 4}, /* Row 3 */
+ { 1, 3}, { 6, 0}, { 1, 9}, { 2, 0},
+ { 3, 0}, { 1, 5}, { 1, 10}, { 1, 11}, { 2, 0}, { 1, 3}, { 1, 4}, { 1, 3}, /* Row 4 */
+ { 2, 10}, { 1, 12}, { 1, 3}, { 1, 4}, { 1, 3}, { 3, 0}, { 1, 13}, { 1, 5},
+ { 1, 14}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 10}, { 1, 15}, { 1, 16}, { 2, 4}, { 1, 3}, /* Row 5 */
+ { 1, 10}, { 1, 13}, { 1, 10}, { 1, 12}, { 1, 3}, { 1, 4}, { 1, 3}, { 1, 2},
+ { 1, 10}, { 1, 5}, { 1, 17}, { 1, 15}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 10}, { 1, 18}, { 1, 8}, { 2, 4}, { 1, 3}, /* Row 6 */
+ { 1, 10}, { 2, 13}, { 1, 19}, { 1, 12}, { 1, 4}, { 1, 3}, { 1, 19}, { 1, 13},
+ { 1, 20}, { 1, 15}, { 1, 9}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 2, 13}, { 1, 10}, { 1, 12}, { 1, 16}, { 1, 4}, { 1, 3}, /* Row 7 */
+ { 1, 10}, { 1, 5}, { 1, 13}, { 1, 10}, { 1, 12}, { 1, 4}, { 1, 2}, { 1, 10},
+ { 1, 13}, { 1, 17}, { 1, 15}, { 3, 0},
+ { 3, 0}, { 1, 10}, { 2, 13}, { 1, 10}, { 1, 18}, { 1, 8}, { 1, 4}, { 1, 3}, /* Row 8 */
+ { 1, 10}, { 1, 21}, { 2, 13}, { 1, 19}, { 1, 22}, { 1, 23}, { 2, 13}, { 1, 15},
+ { 1, 1}, { 3, 0},
+ { 2, 0}, { 1, 2}, { 2, 13}, { 1, 5}, { 1, 13}, { 1, 10}, { 1, 18}, { 1, 4}, /* Row 9 */
+ { 1, 3}, { 1, 10}, { 1, 5}, { 1, 24}, { 2, 13}, { 1, 24}, { 2, 13}, { 1, 19},
+ { 1, 16}, { 1, 3}, { 1, 2}, { 2, 0},
+ { 2, 0}, { 1, 2}, { 2, 13}, { 1, 18}, { 2, 13}, { 1, 10}, { 1, 16}, { 1, 3}, /* Row 10 */
+ { 2, 10}, { 1, 12}, { 1, 10}, { 1, 13}, { 1, 10}, { 1, 13}, { 1, 10}, { 1, 12},
+ { 2, 4}, { 1, 3}, { 1, 1}, { 1, 0},
+ { 1, 1}, { 1, 3}, { 1, 2}, { 2, 13}, { 1, 25}, { 1, 10}, { 1, 13}, { 1, 10}, /* Row 11 */
+ { 1, 15}, { 1, 3}, { 2, 10}, { 1, 25}, { 1, 26}, { 1, 13}, { 1, 10}, { 1, 13},
+ { 1, 19}, { 1, 12}, { 3, 4}, { 1, 2}, { 1, 1},
+ { 1, 2}, { 1, 3}, { 1, 2}, { 2, 13}, { 1, 15}, { 1, 3}, { 1, 10}, { 1, 13}, /* Row 12 */
+ { 1, 18}, { 1, 27}, { 2, 10}, { 1, 28}, { 1, 22}, { 1, 23}, { 1, 13}, { 1, 20},
+ { 1, 25}, { 1, 16}, { 3, 4}, { 1, 3}, { 1, 2},
+ { 1, 1}, { 1, 3}, { 1, 2}, { 2, 13}, { 1, 15}, { 1, 3}, { 1, 23}, { 1, 13}, /* Row 13 */
+ { 1, 10}, { 1, 25}, { 2, 10}, { 1, 25}, { 1, 29}, { 1, 10}, { 1, 13}, { 1, 10},
+ { 1, 30}, { 1, 8}, { 3, 4}, { 1, 3}, { 1, 1},
+ { 2, 0}, { 1, 2}, { 2, 13}, { 1, 15}, { 1, 4}, { 1, 3}, { 2, 10}, { 1, 18}, /* Row 14 */
+ { 1, 5}, { 1, 10}, { 1, 25}, { 1, 31}, { 1, 13}, { 1, 10}, { 1, 13}, { 1, 32},
+ { 1, 28}, { 2, 4}, { 1, 3}, { 2, 0},
+ { 2, 0}, { 1, 2}, { 2, 13}, { 1, 15}, { 1, 4}, { 1, 3}, { 1, 23}, { 1, 13}, /* Row 15 */
+ { 1, 5}, { 1, 21}, { 1, 10}, { 1, 12}, { 1, 10}, { 1, 13}, { 1, 5}, { 1, 13},
+ { 1, 10}, { 1, 30}, { 1, 4}, { 2, 3}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 2, 4}, { 1, 3}, { 2, 13}, { 2, 21}, /* Row 16 */
+ { 1, 10}, { 1, 13}, { 1, 5}, { 1, 3}, { 1, 10}, { 1, 13}, { 1, 10}, { 1, 33},
+ { 4, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 3, 4}, { 1, 10}, { 1, 13}, { 2, 21}, /* Row 17 */
+ { 2, 13}, { 1, 18}, { 1, 3}, { 1, 6}, { 2, 13}, { 1, 15}, { 1, 1}, { 3, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 3, 4}, { 1, 23}, { 1, 13}, { 1, 10}, /* Row 18 */
+ { 1, 5}, { 1, 13}, { 1, 5}, { 1, 28}, { 1, 4}, { 1, 3}, { 1, 5}, { 1, 13},
+ { 1, 14}, { 1, 15}, { 3, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 1, 4}, { 1, 3}, { 1, 4}, { 1, 3}, /* Row 19 */
+ { 1, 10}, { 3, 13}, { 1, 18}, { 1, 15}, { 1, 4}, { 1, 3}, { 1, 6}, { 1, 10},
+ { 1, 21}, { 1, 15}, { 1, 9}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 1, 1}, { 1, 0}, { 1, 3}, { 1, 4}, /* Row 20 */
+ { 1, 3}, { 1, 10}, { 1, 13}, { 1, 18}, { 1, 15}, { 1, 4}, { 1, 2}, { 1, 1},
+ { 2, 0}, { 1, 13}, { 1, 34}, { 1, 15}, { 2, 0},
+ { 3, 0}, { 1, 10}, { 1, 13}, { 1, 15}, { 1, 9}, { 2, 0}, { 2, 3}, { 1, 23}, /* Row 21 */
+ { 1, 20}, { 1, 25}, { 1, 4}, { 1, 3}, { 1, 1}, { 3, 0}, { 1, 5}, { 1, 14},
+ { 1, 15}, { 2, 0},
+ { 3, 0}, { 1, 9}, { 2, 15}, { 1, 9}, { 2, 0}, { 3, 3}, { 1, 12}, { 1, 8}, /* Row 22 */
+ { 1, 3}, { 1, 2}, { 4, 0}, { 1, 14}, { 1, 15}, { 1, 20}, { 2, 0},
+ { 11, 0}, { 2, 3}, { 1, 6}, { 1, 1}, { 10, 0}, /* Row 23 */
+ { 11, 0}, { 1, 1}, { 1, 35}, { 1, 1}, { 11, 0}, /* Row 24 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_nshBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_nshLut, // Index 0: Unselected LUT
+ g_nshLut, // Index 1: Selected LUT
+ },
+ g_nshRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_play.cxx b/NxWidgets/nxwm/src/glyph_play.cxx
new file mode 100644
index 000000000..8c16addae
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_play.cxx
@@ -0,0 +1,258 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_play.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 24
+#define BITMAP_NCOLUMNS 24
+#define BITMAP_NLUTCODES 5
+
+#define DARK_PLAY_ICON 1
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+# ifdef DARK_PLAY_ICON
+
+static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x00bd00, 0x008100, 0x006300, 0x003600 /* Codes 1-4 */
+};
+
+static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
+};
+
+# else /* DARK_PLAY_ICON */
+
+static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
+};
+
+static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x00fc00, 0x00c000, 0x00a200, 0x007500 /* Codes 1-4 */
+};
+# endif /* DARK_PLAY_ICON */
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+# ifdef DARK_PLAY_ICON
+
+static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x05e0, 0x0400, 0x0300, 0x01a0 /* Codes 1-4 */
+};
+
+static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
+};
+
+# else /* DARK_PLAY_ICON */
+
+static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
+};
+
+static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x07e0, 0x0600, 0x0500, 0x03a0 /* Codes 1-4 */
+};
+
+# endif /* DARK_PLAY_ICON */
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+# ifdef DARK_PLAY_ICON
+
+static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x6e, 0x4b, 0x3a, 0x1f /* Codes 1-4 */
+};
+
+static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
+};
+
+# else /* DARK_PLAY_ICON */
+
+static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
+};
+
+static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x93, 0x70, 0x5f, 0x44 /* Codes 1-4 */
+};
+
+# endif /* DARK_PLAY_ICON */
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+# ifdef DARK_PLAY_ICON
+static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x14, 0x10, 0x0c, 0x04 /* Codes 1-4 */
+};
+
+static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
+};
+
+# else /* DARK_PLAY_ICON */
+
+static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
+};
+
+static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x1c, 0x18, 0x14, 0x0c /* Codes 1-4 */
+};
+
+# endif /* DARK_PLAY_ICON */
+# endif /* CONFIG_NXWIDGETS_GREYSCALE */
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_playRleEntries[] =
+{
+ { 2, 1}, { 22, 0}, /* Row 0 */
+ { 2, 2}, { 2, 1}, { 20, 0}, /* Row 1 */
+ { 4, 2}, { 2, 1}, { 18, 0}, /* Row 2 */
+ { 6, 2}, { 2, 1}, { 16, 0}, /* Row 3 */
+ { 8, 2}, { 2, 1}, { 14, 0}, /* Row 4 */
+ { 10, 2}, { 2, 1}, { 12, 0}, /* Row 5 */
+ { 12, 2}, { 2, 1}, { 10, 0}, /* Row 6 */
+ { 14, 2}, { 2, 1}, { 8, 0}, /* Row 7 */
+ { 16, 2}, { 2, 1}, { 6, 0}, /* Row 8 */
+ { 18, 2}, { 2, 1}, { 4, 0}, /* Row 9 */
+ { 20, 2}, { 2, 1}, { 2, 0}, /* Row 10 */
+ { 22, 2}, { 2, 1}, /* Row 11 */
+ { 22, 3}, { 2, 4}, /* Row 12 */
+ { 20, 3}, { 2, 4}, { 2, 0}, /* Row 13 */
+ { 18, 3}, { 2, 4}, { 4, 0}, /* Row 14 */
+ { 16, 3}, { 2, 4}, { 6, 0}, /* Row 15 */
+ { 14, 3}, { 2, 4}, { 8, 0}, /* Row 16 */
+ { 12, 3}, { 2, 4}, { 10, 0}, /* Row 17 */
+ { 10, 3}, { 2, 4}, { 12, 0}, /* Row 18 */
+ { 8, 3}, { 2, 4}, { 14, 0}, /* Row 19 */
+ { 6, 3}, { 2, 4}, { 16, 0}, /* Row 20 */
+ { 4, 3}, { 2, 4}, { 18, 0}, /* Row 21 */
+ { 2, 3}, { 2, 4}, { 20, 0}, /* Row 22 */
+ { 2, 4}, { 22, 0}, /* Row 23 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_playBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_playNormalLut, // Index 0: Unselected LUT
+ g_playBrightlLut, // Index 1: Selected LUT
+ },
+ g_playRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_start.cxx b/NxWidgets/nxwm/src/glyph_start.cxx
new file mode 100644
index 000000000..e7937faea
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_start.cxx
@@ -0,0 +1,216 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_start.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 25
+#define BITMAP_NCOLUMNS 25
+#define BITMAP_NLUTCODES 34
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_startLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x6db66d, 0x006d00, 0x246d00, 0x6d9249, 0xdbffb6, 0xb6b692, 0x246d24, 0x249224, /* Codes 1-8 */
+ 0x49b649, 0x6db649, 0x499249, 0xdbffdb, 0x92b692, 0xb6dbb6, 0x6ddb6d, 0x92b66d, /* Codes 9-16 */
+ 0x6d926d, 0x92db92, 0x49926d, 0x49b624, 0x92db6d, 0xb6ffb6, 0xffffff, 0x496d49, /* Codes 17-24 */
+ 0x92ff92, 0x24b624, 0x496d24, 0xb6db92, 0x499224, 0x249200, 0x92dbb6, 0x004900, /* Codes 25-32 */
+ 0x009200 /* Code 33 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_startLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x6dad, 0x0360, 0x2360, 0x6c89, 0xdff6, 0xb5b2, 0x2364, 0x2484, 0x4da9, 0x6da9, /* Codes 0-10 */
+ 0x4c89, 0xdffb, 0x95b2, 0xb6d6, 0x6ecd, 0x95ad, 0x6c8d, 0x96d2, 0x4c8d, 0x4da4, /* Codes 11-20 */
+ 0x96cd, 0xb7f6, 0xffff, 0x4b69, 0x97f2, 0x25a4, 0x4b64, 0xb6d2, 0x4c84, 0x2480, /* Codes 21-30 */
+ 0x96d6, 0x0240, 0x0480 /* Codes 31-33 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_startLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x97, 0x3f, 0x4a, 0x7e, 0xeb, 0xb1, 0x4e, 0x64, 0x88, 0x93, 0x73, 0xf0, 0xa7, /* Codes 1-13 */
+ 0xcb, 0xad, 0xa2, 0x82, 0xbc, 0x77, 0x84, 0xb8, 0xe0, 0xff, 0x5e, 0xd1, 0x79, /* Codes 14-26 */
+ 0x59, 0xc7, 0x6f, 0x60, 0xc0, 0x2a, 0x55 /* Codes 27-33 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_startLut[BITMAP_NLUTCODES] =
+{
+ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
+ 0x75, 0x0c, 0x2c, 0x71, 0xde, 0xb6, 0x2c, 0x30, 0x55, 0x75, 0x51, 0xdf, 0x96, /* Codes 1-13 */
+ 0xba, 0x79, 0x95, 0x71, 0x9a, 0x51, 0x54, 0x99, 0xbe, 0xff, 0x4d, 0x9e, 0x34, /* Codes 14-26 */
+ 0x4c, 0xba, 0x50, 0x30, 0x9a, 0x08, 0x10 /* Codes 27-33 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_startRleEntries[] =
+{
+ { 7, 0}, { 1, 1}, { 3, 2}, { 1, 3}, { 4, 2}, { 1, 4}, { 1, 5}, { 7, 0}, /* Row 0 */
+ { 5, 0}, { 1, 6}, { 2, 7}, { 1, 8}, { 1, 9}, { 2, 1}, { 1, 10}, { 2, 9}, /* Row 1 */
+ { 1, 11}, { 2, 7}, { 1, 1}, { 1, 12}, { 5, 0},
+ { 4, 0}, { 1, 13}, { 1, 7}, { 1, 3}, { 1, 9}, { 8, 1}, { 1, 9}, { 1, 3}, /* Row 2 */
+ { 1, 7}, { 1, 11}, { 1, 14}, { 4, 0},
+ { 3, 0}, { 1, 13}, { 1, 7}, { 1, 3}, { 1, 9}, { 1, 15}, { 4, 1}, { 1, 16}, /* Row 3 */
+ { 3, 1}, { 1, 15}, { 1, 9}, { 1, 8}, { 1, 7}, { 1, 17}, { 4, 0},
+ { 2, 0}, { 1, 14}, { 1, 11}, { 1, 3}, { 1, 9}, { 1, 15}, { 4, 1}, { 1, 18}, /* Row 4 */
+ { 1, 14}, { 1, 13}, { 1, 1}, { 1, 15}, { 1, 10}, { 1, 1}, { 1, 10}, { 2, 7},
+ { 1, 13}, { 3, 0},
+ { 2, 0}, { 1, 19}, { 1, 7}, { 1, 20}, { 1, 10}, { 2, 1}, { 1, 21}, { 1, 1}, /* Row 5 */
+ { 1, 18}, { 1, 22}, { 1, 23}, { 1, 14}, { 1, 1}, { 2, 15}, { 1, 1}, { 1, 10},
+ { 1, 9}, { 1, 2}, { 1, 11}, { 1, 14}, { 2, 0},
+ { 1, 0}, { 1, 14}, { 1, 7}, { 1, 8}, { 1, 9}, { 1, 10}, { 1, 1}, { 1, 18}, /* Row 6 */
+ { 1, 23}, { 1, 1}, { 1, 15}, { 1, 14}, { 1, 23}, { 1, 14}, { 1, 1}, { 2, 23},
+ { 1, 1}, { 2, 9}, { 1, 8}, { 1, 2}, { 1, 4}, { 2, 0},
+ { 1, 0}, { 1, 24}, { 1, 2}, { 1, 8}, { 1, 9}, { 1, 1}, { 1, 13}, { 2, 23}, /* Row 7 */
+ { 1, 1}, { 1, 21}, { 1, 22}, { 1, 23}, { 1, 14}, { 1, 1}, { 1, 25}, { 1, 23},
+ { 1, 14}, { 1, 1}, { 1, 9}, { 1, 26}, { 1, 2}, { 1, 7}, { 1, 14}, { 1, 0},
+ { 1, 22}, { 1, 7}, { 1, 8}, { 2, 9}, { 1, 1}, { 1, 5}, { 1, 23}, { 1, 18}, /* Row 8 */
+ { 1, 9}, { 1, 1}, { 1, 14}, { 1, 23}, { 1, 14}, { 1, 11}, { 1, 1}, { 1, 22},
+ { 1, 23}, { 1, 21}, { 1, 9}, { 1, 26}, { 1, 8}, { 1, 7}, { 1, 1}, { 1, 0},
+ { 1, 13}, { 1, 7}, { 2, 8}, { 1, 9}, { 1, 18}, { 1, 23}, { 1, 14}, { 2, 9}, /* Row 9 */
+ { 1, 1}, { 1, 14}, { 1, 23}, { 1, 14}, { 1, 11}, { 1, 9}, { 1, 1}, { 1, 23},
+ { 1, 14}, { 1, 10}, { 2, 8}, { 1, 2}, { 1, 24}, { 1, 0},
+ { 1, 1}, { 1, 7}, { 2, 8}, { 1, 9}, { 1, 14}, { 1, 23}, { 1, 1}, { 2, 9}, /* Row 10 */
+ { 1, 1}, { 1, 14}, { 1, 23}, { 1, 18}, { 1, 11}, { 2, 9}, { 1, 22}, { 1, 23},
+ { 1, 1}, { 2, 8}, { 1, 3}, { 1, 27}, { 1, 14},
+ { 1, 11}, { 1, 2}, { 2, 8}, { 1, 10}, { 2, 23}, { 1, 9}, { 2, 20}, { 1, 1}, /* Row 11 */
+ { 1, 14}, { 1, 23}, { 1, 18}, { 1, 11}, { 2, 9}, { 1, 18}, { 1, 23}, { 1, 1},
+ { 2, 8}, { 2, 7}, { 1, 14},
+ { 1, 11}, { 1, 2}, { 2, 8}, { 1, 10}, { 1, 23}, { 1, 22}, { 1, 9}, { 2, 26}, /* Row 12 */
+ { 1, 1}, { 1, 14}, { 1, 23}, { 1, 18}, { 1, 11}, { 2, 9}, { 1, 18}, { 1, 23},
+ { 1, 1}, { 2, 8}, { 2, 7}, { 1, 13},
+ { 1, 1}, { 1, 3}, { 2, 8}, { 1, 9}, { 1, 23}, { 1, 22}, { 1, 9}, { 2, 8}, /* Row 13 */
+ { 1, 1}, { 1, 22}, { 1, 23}, { 1, 18}, { 2, 8}, { 1, 11}, { 1, 18}, { 1, 23},
+ { 1, 1}, { 2, 8}, { 2, 7}, { 1, 14},
+ { 1, 13}, { 1, 7}, { 2, 8}, { 1, 11}, { 1, 18}, { 1, 23}, { 1, 1}, { 2, 8}, /* Row 14 */
+ { 1, 10}, { 1, 28}, { 1, 22}, { 1, 21}, { 2, 8}, { 1, 11}, { 1, 22}, { 1, 23},
+ { 1, 9}, { 2, 8}, { 1, 7}, { 1, 24}, { 1, 0},
+ { 1, 14}, { 1, 7}, { 3, 8}, { 1, 1}, { 1, 23}, { 1, 14}, { 1, 11}, { 1, 8}, /* Row 15 */
+ { 1, 11}, { 1, 10}, { 1, 1}, { 1, 9}, { 1, 8}, { 1, 29}, { 1, 1}, { 1, 12},
+ { 1, 23}, { 1, 11}, { 2, 8}, { 1, 7}, { 1, 11}, { 1, 0},
+ { 1, 0}, { 1, 7}, { 1, 3}, { 2, 8}, { 1, 9}, { 1, 28}, { 1, 23}, { 1, 18}, /* Row 16 */
+ { 1, 11}, { 5, 8}, { 1, 9}, { 1, 22}, { 1, 23}, { 1, 10}, { 2, 8}, { 1, 30},
+ { 1, 7}, { 1, 13}, { 1, 0},
+ { 1, 0}, { 1, 17}, { 1, 7}, { 3, 8}, { 1, 1}, { 2, 23}, { 1, 31}, { 1, 15}, /* Row 17 */
+ { 2, 26}, { 1, 9}, { 1, 21}, { 1, 22}, { 1, 23}, { 1, 13}, { 1, 29}, { 2, 8},
+ { 1, 2}, { 1, 8}, { 2, 0},
+ { 2, 0}, { 1, 24}, { 1, 2}, { 3, 8}, { 1, 9}, { 1, 22}, { 4, 23}, { 1, 14}, /* Row 18 */
+ { 2, 23}, { 1, 1}, { 1, 29}, { 2, 8}, { 2, 7}, { 1, 13}, { 2, 0},
+ { 2, 0}, { 1, 13}, { 1, 7}, { 1, 3}, { 3, 8}, { 1, 9}, { 1, 1}, { 1, 18}, /* Row 19 */
+ { 1, 14}, { 2, 23}, { 1, 18}, { 1, 10}, { 4, 8}, { 1, 2}, { 1, 17}, { 3, 0},
+ { 3, 0}, { 1, 17}, { 1, 2}, { 1, 7}, { 3, 8}, { 1, 29}, { 1, 11}, { 1, 10}, /* Row 20 */
+ { 1, 1}, { 1, 9}, { 1, 11}, { 4, 8}, { 1, 2}, { 1, 27}, { 1, 14}, { 3, 0},
+ { 3, 0}, { 1, 14}, { 1, 11}, { 2, 3}, { 10, 8}, { 1, 30}, { 1, 32}, { 1, 7}, /* Row 21 */
+ { 1, 13}, { 4, 0},
+ { 4, 0}, { 1, 14}, { 1, 24}, { 1, 7}, { 1, 3}, { 8, 8}, { 1, 7}, { 1, 32}, /* Row 22 */
+ { 1, 27}, { 1, 13}, { 5, 0},
+ { 5, 0}, { 1, 14}, { 1, 17}, { 2, 7}, { 2, 2}, { 2, 33}, { 1, 3}, { 3, 7}, /* Row 23 */
+ { 1, 24}, { 1, 6}, { 6, 0},
+ { 6, 0}, { 1, 14}, { 1, 13}, { 1, 4}, { 1, 7}, { 4, 2}, { 1, 7}, { 1, 11}, /* Row 24 */
+ { 1, 13}, { 1, 14}, { 7, 0},
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_startBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_startLut, // Index 0: Unselected LUT
+ g_startLut, // Index 1: Selected LUT
+ },
+ g_startRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/nxwm/src/glyph_stop.cxx b/NxWidgets/nxwm/src/glyph_stop.cxx
new file mode 100644
index 000000000..a60b75ce8
--- /dev/null
+++ b/NxWidgets/nxwm/src/glyph_stop.cxx
@@ -0,0 +1,194 @@
+/********************************************************************************************
+ * NxWidgets/nxwm/src/glyph_stop.cxx
+ *
+ * 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.
+ *
+ ********************************************************************************************/
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nxglib.h>
+#include <nuttx/fb.h>
+#include <nuttx/rgbcolors.h>
+
+#include "crlepalettebitmap.hxx"
+
+#include "nxwmconfig.hxx"
+#include "nxwmglyphs.hxx"
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+#define BITMAP_NROWS 21
+#define BITMAP_NCOLUMNS 21
+#define BITMAP_NLUTCODES 11
+
+/********************************************************************************************
+ * Private Bitmap Data
+ ********************************************************************************************/
+
+using namespace NxWM;
+
+/* RGB24 (8-8-8) Colors */
+
+#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
+
+static const uint32_t g_stopNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xd8d8d8, 0xfc6c6c, 0xfcb4b4, 0xd80000, 0xfc0000, 0x902424, 0xfcfcfc, 0xd8fcfc, /* Codes 0-7 */
+ 0xb40000, 0xb40024, 0xfcd8d8 /* Codes 8-10 */
+};
+
+static const uint32_t g_stopBrightLut[BITMAP_NLUTCODES] =
+{
+ 0xe1e1e1, 0xfc9090, 0xfcc6c6, 0xe13f3f, 0xfc3f3f, 0xab5a5a, 0xfcfcfc, 0xe1fcfc, /* Codes 0-7 */
+ 0xc63f3f, 0xc63f5a, 0xfce1e1 /* Codes 8-10 */
+};
+
+/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
+
+#elif CONFIG_NXWIDGETS_BPP == 16
+
+static const uint16_t g_stopNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xdedb, 0xfb6d, 0xfdb6, 0xd800, 0xf800, 0x9124, 0xffff, 0xdfff, 0xb000, 0xb004, /* Codes 0-9 */
+ 0xfedb /* Codes 10-10 */
+};
+
+static const uint16_t g_stopBrightLut[BITMAP_NLUTCODES] =
+{
+ 0xe71c, 0xfc92, 0xfe38, 0xe1e7, 0xf9e7, 0xaacb, 0xffff, 0xe7ff, 0xc1e7, 0xc1eb, /* Codes 0-9 */
+ 0xff1c /* Codes 10-10 */
+};
+
+/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
+ * to lookup an 8-bit value. There is no savings in that! It would be better to just put
+ * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
+ * pointless lookups. But these p;ointless lookups do make the logic compatible with the
+ * 16- and 24-bit types.
+ */
+
+#elif CONFIG_NXWIDGETS_BPP == 8
+# ifdef CONFIG_NXWIDGETS_GREYSCALE
+
+/* 8-bit Greyscale */
+
+static const uint8_t g_stopNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xd8, 0x97, 0xc9, 0x40, 0x4b, 0x44, 0xfc, 0xf1, 0x35, 0x39, 0xe2 /* Codes 0-10 */
+};
+
+static const uint8_t g_stopBrightLut[BITMAP_NLUTCODES] =
+{
+ 0xe1, 0xb0, 0xd6, 0x6f, 0x77, 0x72, 0xfc, 0xf3, 0x67, 0x6a, 0xe9 /* Codes 0-10 */
+};
+
+# else /* CONFIG_NXWIDGETS_GREYSCALE */
+
+/* RGB8 (332) Colors */
+
+static const nxgl_mxpixel_t g_stopNormalLut[BITMAP_NLUTCODES] =
+{
+ 0xdb, 0xed, 0xf6, 0xc0, 0xe0, 0x84, 0xff, 0xdf, 0xa0, 0xa0, 0xfb /* Codes 0-10 */
+};
+
+static const uint8_t g_stopBrightLut[BITMAP_NLUTCODES] =
+{
+ 0xff, 0xf2, 0xfb, 0xe4, 0xe4, 0xa9, 0xff, 0xff, 0xc4, 0xc5, 0xff /* Codes 0-10 */
+};
+
+# endif
+#else
+# error "Unsupport pixel format"
+#endif
+
+static const struct NXWidgets::SRlePaletteBitmapEntry g_stopRleEntries[] =
+{
+ { 1, 0}, { 1, 1}, { 17, 2}, { 1, 1}, { 1, 2}, /* Row 0 */
+ { 1, 1}, { 4, 3}, { 6, 4}, { 9, 3}, { 1, 1}, /* Row 1 */
+ { 1, 2}, { 2, 3}, { 9, 4}, { 8, 3}, { 1, 5}, /* Row 2 */
+ { 1, 2}, { 1, 3}, { 1, 4}, { 2, 6}, { 1, 7}, { 7, 4}, { 2, 3}, { 2, 6}, /* Row 3 */
+ { 1, 7}, { 2, 3}, { 1, 5},
+ { 1, 2}, { 1, 3}, { 1, 4}, { 3, 6}, { 1, 7}, { 5, 4}, { 2, 3}, { 3, 6}, /* Row 4 */
+ { 1, 7}, { 2, 3}, { 1, 5},
+ { 1, 2}, { 3, 4}, { 3, 6}, { 1, 7}, { 4, 4}, { 1, 3}, { 3, 6}, { 1, 7}, /* Row 5 */
+ { 3, 3}, { 1, 5},
+ { 1, 2}, { 4, 4}, { 3, 6}, { 1, 7}, { 2, 4}, { 1, 3}, { 3, 6}, { 1, 7}, /* Row 6 */
+ { 4, 3}, { 1, 5},
+ { 1, 2}, { 5, 4}, { 3, 6}, { 1, 7}, { 1, 3}, { 3, 6}, { 1, 7}, { 4, 3}, /* Row 7 */
+ { 1, 8}, { 1, 5},
+ { 1, 2}, { 6, 4}, { 6, 6}, { 1, 7}, { 5, 3}, { 1, 8}, { 1, 5}, /* Row 8 */
+ { 1, 2}, { 1, 3}, { 4, 4}, { 2, 3}, { 2, 6}, { 3, 7}, { 6, 3}, { 1, 8}, /* Row 9 */
+ { 1, 5},
+ { 1, 2}, { 2, 3}, { 1, 4}, { 4, 3}, { 2, 6}, { 3, 7}, { 5, 3}, { 2, 8}, /* Row 10 */
+ { 1, 5},
+ { 1, 2}, { 7, 3}, { 4, 6}, { 1, 7}, { 5, 3}, { 2, 8}, { 1, 5}, /* Row 11 */
+ { 1, 2}, { 6, 3}, { 6, 6}, { 1, 7}, { 3, 3}, { 3, 8}, { 1, 5}, /* Row 12 */
+ { 1, 2}, { 5, 3}, { 2, 6}, { 2, 7}, { 1, 3}, { 2, 6}, { 2, 7}, { 1, 3}, /* Row 13 */
+ { 4, 8}, { 1, 5},
+ { 1, 2}, { 4, 3}, { 3, 6}, { 1, 7}, { 3, 3}, { 3, 6}, { 1, 7}, { 4, 8}, /* Row 14 */
+ { 1, 5},
+ { 1, 2}, { 3, 3}, { 3, 6}, { 1, 7}, { 5, 3}, { 3, 6}, { 1, 7}, { 3, 8}, /* Row 15 */
+ { 1, 5},
+ { 1, 2}, { 2, 3}, { 3, 6}, { 1, 7}, { 4, 3}, { 3, 8}, { 3, 6}, { 1, 7}, /* Row 16 */
+ { 2, 8}, { 1, 5},
+ { 1, 2}, { 2, 3}, { 3, 7}, { 3, 3}, { 6, 8}, { 3, 7}, { 2, 8}, { 1, 5}, /* Row 17 */
+ { 1, 2}, { 6, 3}, { 2, 8}, { 1, 9}, { 10, 8}, { 1, 5}, /* Row 18 */
+ { 1, 1}, { 1, 3}, { 10, 8}, { 1, 9}, { 8, 8}, /* Row 19 */
+ { 1, 10}, { 1, 1}, { 17, 5}, { 1, 8}, { 1, 1}, /* Row 20 */
+};
+
+/********************************************************************************************
+ * Public Bitmap Structure Defintions
+ ********************************************************************************************/
+
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_stopBitmap =
+{
+ CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
+ CONFIG_NXWIDGETS_FMT, // fmt - Color format
+ BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
+ BITMAP_NCOLUMNS, // width - Width in pixels
+ BITMAP_NROWS, // height - Height in rows
+ { // lut - Pointer to the beginning of the Look-Up Table (LUT)
+ g_stopNormalLut, // Index 0: Unselected LUT
+ g_stopBrightLut, // Index 1: Selected LUT
+ },
+ g_stopRleEntries // data - Pointer to the beginning of the RLE data
+};
diff --git a/NxWidgets/tools/addobjs.sh b/NxWidgets/tools/addobjs.sh
new file mode 100755
index 000000000..5ccb289c5
--- /dev/null
+++ b/NxWidgets/tools/addobjs.sh
@@ -0,0 +1,141 @@
+#!/bin/bash
+#################################################################################
+# NxWidgets/tools/addobjs.sh
+#
+# 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.
+#
+#################################################################################
+
+# set -x
+
+# Get input parameters
+
+usage="Usage: $0 [OPTIONS] <lib-path> <obj-dir>"
+advice="Try '$0 -h' for more information"
+
+unset prefix
+wintool=n
+
+while [ ! -z "$1" ]; do
+ case $1 in
+ -d )
+ set -x
+ ;;
+ -p )
+ shift
+ prefix=$1
+ ;;
+ -w )
+ wintool=y
+ ;;
+ -h )
+ echo "$0 will add all object (.o) files in directory to an archive."
+ echo ""
+ echo $usage
+ echo ""
+ echo "Where:"
+ echo " <lib-path> is the full, absolute path to the library to use"
+ echo " <obj-dir> is full path to the directory containing the object files to be added"
+ echo "OPTIONS include:"
+ echo " -p Prefix to use. For example, to use arm-elf-ar, add '-p arm-elf-'"
+ echo " -w Use Windows style paths insted of POSIX paths"
+ echo " -d Enable script debug"
+ echo " -h Show this usage information"
+ exit 0
+ ;;
+ * )
+ break;
+ ;;
+ esac
+ shift
+done
+
+libpath=$1
+objdir=$2
+archiver="${prefix}"ar
+
+# Verify input parameters
+
+if [ -z "${libpath}" ]; then
+ echo "Missing required arguments"
+ echo ""
+ echo $usage
+ echo $advice
+ exit 1
+fi
+
+if [ -z "${objdir}" ]; then
+ echo "Missing required argument <obj-dir>"
+ echo ""
+ echo $usage
+ echo $advice
+ exit 1
+fi
+
+if [ ! -w ${libpath} ]; then
+ if [ -e ${libpath} ]; then
+ echo "${libpath} exists but is not a write-able file"
+ echo $advice
+ else
+ echo "${libpath} does not exist"
+ echo $advice
+ fi
+ exit 1
+fi
+
+if [ ! -d ${objdir} ]; then
+ if [ -e ${objdir} ]; then
+ echo "${objdir} exists but is not a directory"
+ echo $advice
+ else
+ echo "${objdir} does not exist"
+ echo $advice
+ fi
+ exit 1
+fi
+
+# Add each object file in <obj-dir> to the archive at <lib-path>
+
+for obj in `ls "${objdir}"/*.o`; do
+ name=`basename "${obj}"`
+ if [ "X${wintool}" = "Xy" ]; then
+ objpath=`cygpath -w "${obj}"`
+ else
+ objpath=${obj}
+ fi
+ echo "AR: ${name}"
+ ${archiver} rcs ${libpath} ${objpath} || \
+ { echo "Failed to archive the object file:"; \
+ echo " Archive: ${libpath}"; \
+ echo " Object: ${obj}"; \
+ exit 1; \
+ }
+done \ No newline at end of file
diff --git a/NxWidgets/tools/indent.sh b/NxWidgets/tools/indent.sh
new file mode 100755
index 000000000..e763cff37
--- /dev/null
+++ b/NxWidgets/tools/indent.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#################################################################################
+# NxWidgets/tools/install.sh
+#
+# 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.
+#
+#################################################################################
+#
+# This script uses the Linux 'indent' utility to re-format C source files
+# to match the coding style that I use. It differs from my coding style in that
+#
+# - I normally put the traiing */ of a multi-line comment on a separate line,
+# - I usually align things vertically (like '='in assignments.
+#
+
+indent -nbad -bap -bbb -nbbo -nbc -bl -bl2 -bls -nbs -cbi2 -ncdw -nce -ci2 -cli0 -cp40 -ncs -nbfda -nbfde -di1 -nfc1 -fca -i2 -l80 -lp -ppi2 -lps -npcs -pmt -nprs -npsl -saf -sai -sbi2 -saw -sc -sob -nss -nut "$@"
+
diff --git a/NxWidgets/tools/install.sh b/NxWidgets/tools/install.sh
new file mode 100755
index 000000000..6917b4b03
--- /dev/null
+++ b/NxWidgets/tools/install.sh
@@ -0,0 +1,152 @@
+#!/bin/bash
+#################################################################################
+# NxWidgets/tools/install.sh
+#
+# 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.
+#
+#################################################################################
+#
+# set -x
+# Functions
+
+function ShowUsage()
+{
+ echo ""
+ echo "USAGE: $0 <apps-directory-path> <test-sub-directory>"
+ echo ""
+ echo "Where:"
+ echo " <apps-directory-path> is the full, absolute path to the NuttX apps/ directory"
+ echo " <test-sub-directory> is the name of a sub-directory in the UnitTests directory"
+ echo ""
+}
+
+function ShowTests()
+{
+ for testdir in ${UNITTEST_DIRPATH}/*; do
+ subdir=`basename ${testdir}`
+ if [ -d "${UNITTEST_DIRPATH}/${subdir}" ]; then
+ if [ -f "${UNITTEST_DIRPATH}/${subdir}/Makefile" ]; then
+ echo $subdir
+ fi
+ fi
+ done
+}
+
+# Input parameters
+
+APPS_DIRPATH=$1
+TEST_SUBDIR=$2
+
+if [ -z "${APPS_DIRPATH}" ]; then
+ echo "Missing required arguments"
+ ShowUsage
+ exit 1
+fi
+
+if [ -z "${TEST_SUBDIR}" ]; then
+ echo "Missing required argument <test-sub-directory>"
+ ShowUsage
+ exit 1
+fi
+
+# Make sure that we know where we are and where we are going
+
+WD=`pwd`
+if [ -x install.sh ]; then
+ UNITTEST_DIRPATH="${WD}/../UnitTests"
+ TOOLS_DIRPATH="${WD}"
+else
+ if [ -x tools/install.sh ]; then
+ UNITTEST_DIRPATH="${WD}/UnitTests"
+ TOOLS_DIRPATH="${WD}/tools"
+ else
+ echo "This script must be executed in the NxWidgets or NxWidgets/tools directory"
+ ShowUsage
+ exit 1
+ fi
+fi
+
+if [ ! -d "${APPS_DIRPATH}" ]; then
+ echo "Directory ${APPS_DIRPATH} does not exist"
+ ShowUsage
+ exit 1
+fi
+
+if [ ! -f "${APPS_DIRPATH}/Makefile" ]; then
+ echo "Directory ${APPS_DIRPATH} does not look like a NuttX apps directory"
+ ShowUsage
+ exit 1
+fi
+
+TEST_PATH="${UNITTEST_DIRPATH}/${TEST_SUBDIR}"
+if [ ! -d "${TEST_PATH}" ]; then
+ echo "Directory ${TEST_PATH} does not exist"
+ ShowUsage
+ ShowTests
+ exit 1
+fi
+
+if [ ! -f "${TEST_PATH}/Makefile" ]; then
+ echo "Directory ${TEST_PATH} does not look like a unit test directory"
+ ShowUsage
+ ShowTests
+ exit 1
+fi
+
+# Check if the symbolic link "external" exists in the NuttX apps directory
+
+if [ -e "${APPS_DIRPATH}/external" ]; then
+ echo "${APPS_DIRPATH}/external already exists..."
+ if [ -h "${APPS_DIRPATH}/external" ]; then
+ echo " Removing the old symbolic link."
+ rm "${APPS_DIRPATH}/external" || \
+ { echo " ERROR: Failed to remove old symbolic link"; \
+ exit 1;
+ }
+ else
+ echo " ERROR: But it is not a symbolic link!"
+ echo " Please remove ${APPS_DIRPATH}/external"
+ echo " and run this script again"
+ fi
+fi
+
+# Then set up the symbolic link "external" in the NuttX apps to point to the
+# UnitTest subdirectory
+
+echo "Creating symbolic link"
+echo " - To ${TEST_PATH}"
+echo " - At ${APPS_DIRPATH}/external"
+
+ln -s "${TEST_PATH}" "${APPS_DIRPATH}/external" || \
+ { echo "Failed to create symbollic link"; \
+ exit 1;
+ }
+
diff --git a/NxWidgets/tools/zipme.sh b/NxWidgets/tools/zipme.sh
new file mode 100755
index 000000000..ae62d64f9
--- /dev/null
+++ b/NxWidgets/tools/zipme.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+#################################################################################
+# NxWidgets/tools/zipme.sh
+#
+# 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.
+#
+#################################################################################
+
+#set -x
+
+WD=`pwd`
+VERSION=$1
+
+TAR="tar cvf"
+ZIP=gzip
+
+# Make sure we know what is going on
+
+if [ -z ${VERSION} ] ; then
+ echo "You must supply a version like xx.yy as a parameter"
+ exit 1;
+fi
+
+# Find the directory we were executed from and were we expect to
+# see the directory to tar up
+
+MYNAME=`basename $0`
+
+if [ -x ${WD}/${MYNAME} ] ; then
+ NXWIDGETS=`dirname ${WD}`
+else
+ if [ -x ${WD}/tools/${MYNAME} ] ; then
+ NXWIDGETS=${WD}
+ else
+ echo "You must cd into the NxWidgets or NxWidgets/tools directory to execute this script."
+ exit 1
+ fi
+fi
+
+# Get the NxWidgets directory name and the path to the parent directory
+
+NXWIDGETSDIR=`basename ${NXWIDGETS}`
+PROJECTS=`dirname ${NXWIDGETS}`
+
+# The name of the directory must match the version number
+
+if [ "X${NXWIDGETSDIR}" != "XNxWidgets-${VERSION}" ]; then
+ echo "Expected directory name to be NxWidgets-${VERSION} found ${NXWIDGETSDIR}"
+ exit 1
+fi
+
+cd ${PROJECTS} || \
+ { echo "Failed to cd to ${PROJECTS}" ; exit 1 ; }
+
+if [ ! -d ${NXWIDGETSDIR} ] ; then
+ echo "${PROJECTS}/${NXWIDGETSDIR} does not exist!"
+ exit 1
+fi
+
+TAR_NAME=NxWidgets-${VERSION}.tar
+ZIP_NAME=${TAR_NAME}.gz
+
+# Prepare the NxWidgets directory -- Remove editor garbage
+
+find ${NXWIDGETSDIR} -name '*~' -exec rm -f '{}' ';' || \
+ { echo "Removal of emacs garbage failed!" ; exit 1 ; }
+
+find ${NXWIDGETSDIR} -name '#*' -exec rm -f '{}' ';' || \
+ { echo "Removal of VI garbage failed!" ; exit 1 ; }
+
+find ${NXWIDGETSDIR} -name '*.swp' -exec rm -f '{}' ';' || \
+ { echo "Removal of VI garbage failed!" ; exit 1 ; }
+
+# Perform a full clean for the distribution
+
+make -C ${NXWIDGETSDIR} distclean
+
+# Remove any previous tarballs
+
+if [ -f ${TAR_NAME} ] ; then
+ echo "Removing ${PROJECTS}/${TAR_NAME}"
+ rm -f ${TAR_NAME} || \
+ { echo "rm ${TAR_NAME} failed!" ; exit 1 ; }
+fi
+
+if [ -f ${ZIP_NAME} ] ; then
+ echo "Removing ${PROJECTS}/${ZIP_NAME}"
+ rm -f ${ZIP_NAME} || \
+ { echo "rm ${ZIP_NAME} failed!" ; exit 1 ; }
+fi
+
+# Then zip it
+
+${TAR} ${TAR_NAME} ${NXWIDGETSDIR} || \
+ { echo "tar of ${NXWIDGETSDIR} failed!" ; exit 1 ; }
+${ZIP} ${TAR_NAME} || \
+ { echo "zip of ${TAR_NAME} failed!" ; exit 1 ; }