diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index c9c1bc8a5f..8064137e03 100755 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -1,9 +1,15 @@ -1.0 2012-03-22 Gregory Nutt - -* The initial release of the NxWidgets package - -1.1 2012-xx-xx Gregory Nutt - -* Updated and verified the NxWidgets DOxygen documentation. Contributed - by Jose Pablo Carballo. - +1.0 2012-03-22 Gregory Nutt + +* The initial release of the NxWidgets package + +1.1 2012-xx-xx Gregory Nutt + +* 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: This directory will, hopefully, eventually hold the NX tiny + desktop (NxWM). diff --git a/NxWidgets/UnitTests/README.txt b/NxWidgets/UnitTests/README.txt index 2360e24258..8534efb9d8 100644 --- a/NxWidgets/UnitTests/README.txt +++ b/NxWidgets/UnitTests/README.txt @@ -115,7 +115,7 @@ Installing and Building the Unit Tests Then reconfigure that to use the Unit Test of your choice: - cd /trunk/UnitTests/tools + cd /tools ./install.sh Where: @@ -144,10 +144,10 @@ Installing and Building the Unit Tests 5. Build the NXWidgets Library - cd /trunk/NXWidgets/libnxwidgets + cd /libnxwidgets make TOPDIR= -6. Build NuttX including the unit test and the NXWidget library +6. Build NuttX including the unit test and the NXWidgets library cd . ./setenv.sh @@ -283,7 +283,7 @@ Example Do nothing... sim/nsh2 already has C++ support enabled. 3. Install the CButton C++ application (for example) - Where: NXWidgets/trunk/UnitTests/tool + Where: /tool $ ./install.sh ~/projects/nuttx/nuttx/trunk/apps/ CButton /home/patacongo/projects/nuttx/nuttx/trunk/apps//external already exists... @@ -309,7 +309,7 @@ Example of unit test stack as described above under "Stack Size Issues." 7. Build the NXWdigets Library - Where XWidgets/trunk/NXWidgets/libnxwidgets + Where /libnxwidgets $ cd /home/patacongo/projects/nuttx/nuttx/trunk/NxWidgets/libnxwidgets $ make TOPDIR=/home/patacongo/projects/nuttx/nuttx/trunk/nuttx diff --git a/NxWidgets/libnxwidgets/include/cbitmap.hxx b/NxWidgets/libnxwidgets/include/cbitmap.hxx index 473403aa88..4828ca9ccf 100644 --- a/NxWidgets/libnxwidgets/include/cbitmap.hxx +++ b/NxWidgets/libnxwidgets/include/cbitmap.hxx @@ -181,6 +181,15 @@ namespace NXWidgets 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. * diff --git a/NxWidgets/libnxwidgets/include/cbuttonarray.hxx b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx index d5f8be4497..487a6cb9fa 100644 --- a/NxWidgets/libnxwidgets/include/cbuttonarray.hxx +++ b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx @@ -80,7 +80,7 @@ namespace NXWidgets 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; hightlighted button displayed */ + 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 */ diff --git a/NxWidgets/libnxwidgets/include/cimage.hxx b/NxWidgets/libnxwidgets/include/cimage.hxx index 47f4d557f2..a1c2823938 100644 --- a/NxWidgets/libnxwidgets/include/cimage.hxx +++ b/NxWidgets/libnxwidgets/include/cimage.hxx @@ -109,8 +109,9 @@ namespace NXWidgets class CImage : public CNxWidget { protected: - FAR IBitmap *m_bitmap; /**< Source bitmap image */ - struct nxgl_point_s m_origin; /**< Origin for offset image display position */ + 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. @@ -191,6 +192,17 @@ namespace NXWidgets */ void setImageTop(nxgl_coord_t row); + + /** + * Control the highlight state. + * + * @param highlightOn True(1), the image will be highlighted + */ + + inline void highlight(bool highlightOn) + { + m_highlighted = highlightOn; + } }; } diff --git a/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx index 2b1e4f0652..451b472f42 100644 --- a/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx +++ b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx @@ -84,7 +84,7 @@ namespace NXWidgets 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; /**< Pointer to the beginning of the Look-Up Table (LUT) */ + FAR const void *lut[2]; /**< Pointers to the beginning of the Look-Up Tables (LUTs) */ /** * The pointer to the beginning of the RLE data @@ -113,6 +113,7 @@ namespace NXWidgets 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 */ /** @@ -237,7 +238,16 @@ namespace NXWidgets const nxgl_coord_t getStride(void) const; /** - * Get one row from the bit map image. + * 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 diff --git a/NxWidgets/libnxwidgets/include/ibitmap.hxx b/NxWidgets/libnxwidgets/include/ibitmap.hxx index c4bb3b5acb..5eaa5b3c95 100644 --- a/NxWidgets/libnxwidgets/include/ibitmap.hxx +++ b/NxWidgets/libnxwidgets/include/ibitmap.hxx @@ -143,7 +143,16 @@ namespace NXWidgets virtual const nxgl_coord_t getStride(void) const = 0; /** - * Get one row from the bit map image. + * 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 diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx index 5e46b801b0..c905737fd0 100644 --- a/NxWidgets/libnxwidgets/src/cimage.cxx +++ b/NxWidgets/libnxwidgets/src/cimage.cxx @@ -156,7 +156,7 @@ void CImage::getPreferredDimensions(CRect &rect) const * @param port The CGraphicsPort to draw to. * @see redraw() */ - + void CImage::drawContents(CGraphicsPort *port) { // Get the the drawable region @@ -178,6 +178,10 @@ void CImage::drawContents(CGraphicsPort *port) 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; @@ -261,12 +265,21 @@ void CImage::drawContents(CGraphicsPort *port) // And put these on the display - port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1, - &bitmap, 0, 0); + 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 top of the display? + // Are we going to draw any rows at the bottom of the display? if (nTopRows < rect.getHeight()) { @@ -286,8 +299,18 @@ void CImage::drawContents(CGraphicsPort *port) { // Put the padded row on the display - port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1, - &bitmap, 0, 0); + 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); + } } } @@ -304,11 +327,34 @@ void CImage::drawContents(CGraphicsPort *port) void CImage::drawBorder(CGraphicsPort *port) { - if (!isBorderless()) + // Stop drawing if the widget indicates it should not have an outline + + if (isBorderless()) { - port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), - getShadowEdgeColor(), getShineEdgeColor()); + 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); } /** diff --git a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx index 25e9473eda..79a614349a 100644 --- a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx +++ b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx @@ -101,6 +101,7 @@ using namespace NXWidgets; CRlePaletteBitmap::CRlePaletteBitmap(const struct SRlePaletteBitmap *bitmap) { m_bitmap = bitmap; + m_lut = bitmap->lut[0]; startOfImage(); } @@ -162,7 +163,19 @@ const nxgl_coord_t CRlePaletteBitmap::getStride(void) const } /** - * Get one row from the bit map image. + * 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 @@ -337,7 +350,7 @@ 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_bitmap->lut; + nxwidget_pixel_t *nxlut = (nxwidget_pixel_t *)m_lut; nxwidget_pixel_t color = nxlut[m_rle->lookup]; // Copy the requested pixels diff --git a/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx index 1b3aab1431..5f1bd7dbf6 100644 --- a/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx +++ b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx @@ -3445,6 +3445,9 @@ const struct SRlePaletteBitmap NXWidgets::g_nuttxBitmap = BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT) 160, // width - Width in pixels 160, // height - Height in rows - g_nuttxLut, // lut - Pointer to the beginning of the Look-Up Table (LUT) + { // 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/nxwm/images/nxconsole.gif b/NxWidgets/nxwm/images/nxconsole.gif new file mode 100644 index 0000000000..acb56754bb Binary files /dev/null and b/NxWidgets/nxwm/images/nxconsole.gif differ diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx new file mode 100644 index 0000000000..eb76ba10bd --- /dev/null +++ b/NxWidgets/nxwm/include/cnxconsole.hxx @@ -0,0 +1,98 @@ +/**************************************************************************** + * NxWidgets/nxwm/include/cnxconsole.hxx + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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_NXX +#define __INCLUDE_CNXCONSOLE_NXX + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "crlepalettebitmap.hxx" +#include "cnxapplication.hxx" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Bitmap Glyph References + ****************************************************************************/ + +#if defined(__cplusplus) + +namespace NxWM +{ + extern const struct NxWidgets::SRlePaletteBitmap g_nshBitmap; + +/**************************************************************************** + * Implementation Classes + ****************************************************************************/ + + /** + * This class implements the NxConsole application. + */ + + class CNxConsole : public CNxApplication + { + public: + /** + * CNxConsole constructor + */ + + CNxConsole(void); + + /** + * CNxConsole destructor + */ + + ~CNxConsole(void); + + /** + * Get the icon associated with the application + * + * @return An instance if INxBitmap that may be used to rend the + * application's icon. This is an new INxBitmap instance that must + * be deleted by the caller when it is no long needed. + */ + + NXWidgets::INxBitmap *getIcon(void); + }; +} +#endif // __cplusplus + +#endif // __INCLUDE_CNXCONSOLE_NXX diff --git a/NxWidgets/nxwm/include/inxapplication.hxx b/NxWidgets/nxwm/include/inxapplication.hxx new file mode 100644 index 0000000000..367ba871f5 --- /dev/null +++ b/NxWidgets/nxwm/include/inxapplication.hxx @@ -0,0 +1,76 @@ +/**************************************************************************** + * NxWidgets/nxwm/include/inxapplication.hxx + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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_INXAPPLICATION_NXX +#define __INCLUDE_INXAPPLICATION_NXX + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "ibitmap.hxx" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Abstract Base Classes + ****************************************************************************/ + +#if defined(__cplusplus) + +namespace NxWM +{ + class INxApplication + { + public: + /** + * Get the icon associated with the application + * + * @return An instance if INxBitmap that may be used to rend the + * application's icon. This is an new INxBitmap instance that must + * be deleted by the caller when it is no long needed. + */ + + virtual NXWidgets::INxBitmap *getIcon(void) = 0; + }; +} + +#endif // __cplusplus + +#endif // __INCLUDE_INXAPPLICATION_NXX diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx new file mode 100644 index 0000000000..18b35d83af --- /dev/null +++ b/NxWidgets/nxwm/include/nxwmconfig.hxx @@ -0,0 +1,84 @@ +/**************************************************************************** + * NxWidgets/nxwm/include/nxwmconfig.hxx + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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_NXWM_CONFIG_HXX +#define __INCLUDE_NXWM_CONFIG_HXX + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "nxconfig.hxx" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/** + * Normal background color + */ + +#ifndef CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR +# define CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR +#endif + +/** + * Default selected background color + */ + +#ifndef CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR +# define CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR +#endif + +/** + * Default foreground color + */ + +#ifndef CONFIG_NXWM_DEFAULT_FOREGROUNDCOLOR +# define CONFIG_NXWM_DEFAULT_FOREGROUNDCOLOR MKRGB(192,192,192) +#endif + +/** + * Default selected forecround color + */ + +#ifndef CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR +# define CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR MKRGB(248,248,248) +#endif + + +#endif // __INCLUDE_NXWM_CONFIG_HXX diff --git a/NxWidgets/nxwm/src/snxconsole.cxx b/NxWidgets/nxwm/src/snxconsole.cxx new file mode 100644 index 0000000000..34912933eb --- /dev/null +++ b/NxWidgets/nxwm/src/snxconsole.cxx @@ -0,0 +1,180 @@ +/******************************************************************************************** + * NxWidgets/nxwm/src/snxconsole.cxx + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include +#include + +#include "nxwmconfig.hxx" +#include "crlepalettebitmap.hxx" +#include "cnxconsole.hxx" + +/******************************************************************************************** + * Pre-Processor Definitions + ********************************************************************************************/ + +#define BITMAP_NROWS 26 +#define BITMAP_NCOLUMNS 25 +#define BITMAP_NLUTCODES 2 + +/******************************************************************************************** + * 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_nshNormalLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_FOREGROUNDCOLOR +}; + +static const uint32_t g_nshSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR +}; + +/* RGB16 (565) Colors (four of the colors in this map are duplicates) */ + +#elif CONFIG_NXWIDGETS_BPP == 16 + +static const uint16_t g_nshNormalLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_FOREGROUNDCOLOR +}; + +static const uint16_t g_nshSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR +}; + +/* 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 pointless lookups do make the logic compatible with the + * 16- and 24-bit types. + */ + +#elif CONFIG_NXWIDGETS_BPP == 8 + +/* RGB8 (332) Colors or 8-bit greyscale */ + +static const nxgl_mxpixel_t g_nshNormalLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_FOREGROUNDCOLOR +}; + +static const nxgl_mxpixel_t g_nshSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_SELECTEDBACKGROUNDCOLOR, CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR +}; + +#else +# error "Unsupport pixel format" +#endif + +static const struct SRlePaletteBitmapEntry g_nshRleEntries[] = +{ + {11, 0}, {4, 1}, {10, 0}, /* Row 0 */ + {7, 0}, {1, 1}, {2, 0}, {5, 1}, {2, 0}, {1, 1}, {7, 0}, /* Row 1 */ + {6, 0}, {3, 1}, {2, 0}, {4, 1}, {2, 0}, {2, 1}, {6, 0}, /* Row 2 */ + {5, 0}, {4, 1}, {2, 0}, {4, 1}, {2, 0}, {4, 1}, {4, 0}, /* Row 3 */ + {6, 0}, {3, 1}, {2, 0}, {4, 1}, {2, 0}, {3, 1}, {5, 0}, /* Row 4 */ + {3, 0}, {1, 1}, {2, 0}, {3, 1}, {2, 0}, {4, 1}, {1, 0}, {4, 1}, /* Row 5 */ + {2, 0}, {1, 1}, {2, 0}, + {2, 0}, {3, 1}, {1, 0}, {3, 1}, {2, 0}, {4, 1}, {1, 0}, {4, 1}, /* Row 6 */ + {1, 0}, {3, 1}, {1, 0}, + {1, 0}, {4, 1}, {2, 0}, {3, 1}, {1, 0}, {4, 1}, {1, 0}, {3, 1}, /* Row 7 */ + {2, 0}, {3, 1}, {1, 0}, + {1, 0}, {5, 1}, {1, 0}, {3, 1}, {1, 0}, {4, 1}, {1, 0}, {3, 1}, /* Row 8 */ + {1, 0}, {4, 1}, {1, 0}, + {2, 0}, {4, 1}, {1, 0}, {3, 1}, {1, 0}, {3, 1}, {2, 0}, {2, 1}, /* Row 9 */ + {2, 0}, {4, 1}, {1, 0}, + {3, 0}, {3, 1}, {2, 0}, {2, 1}, {1, 0}, {3, 1}, {2, 0}, {2, 1}, /* Row 10 */ + {1, 0}, {4, 1}, {2, 0}, + {2, 1}, {2, 0}, {3, 1}, {1, 0}, {2, 1}, {2, 0}, {2, 1}, {2, 0}, /* Row 11 */ + {2, 1}, {1, 0}, {3, 1}, {2, 0}, {1, 1}, + {3, 1}, {1, 0}, {3, 1}, {1, 0}, {3, 1}, {1, 0}, {2, 1}, {1, 0}, /* Row 12 */ + {2, 1}, {2, 0}, {3, 1}, {1, 0}, {2, 1}, + {4, 1}, {1, 0}, {3, 1}, {1, 0}, {2, 1}, {1, 0}, {2, 1}, {1, 0}, /* Row 13 */ + {2, 1}, {1, 0}, {3, 1}, {1, 0}, {3, 1}, + {4, 1}, {2, 0}, {2, 1}, {1, 0}, {2, 1}, {1, 0}, {2, 1}, {1, 0}, /* Row 14 */ + {2, 1}, {1, 0}, {2, 1}, {2, 0}, {3, 1}, + {1, 0}, {4, 1}, {2, 0}, {1, 1}, {1, 0}, {2, 1}, {1, 0}, {2, 1}, /* Row 15 */ + {1, 0}, {1, 1}, {1, 0}, {2, 1}, {2, 0}, {3, 1}, {1, 0}, + {2, 0}, {4, 1}, {1, 0}, {2, 1}, {1, 0}, {1, 1}, {1, 0}, {2, 1}, /* Row 16 */ + {1, 0}, {1, 1}, {1, 0}, {2, 1}, {1, 0}, {4, 1}, {1, 0}, + {3, 0}, {4, 1}, {1, 0}, {1, 1}, {1, 0}, {1, 1}, {1, 0}, {6, 1}, /* Row 17 */ + {1, 0}, {4, 1}, {2, 0}, + {5, 0}, {2, 1}, {1, 0}, {9, 1}, {1, 0}, {3, 1}, {4, 0}, /* Row 18 */ + {6, 0}, {14, 1}, {5, 0}, /* Row 19 */ + {5, 0}, {16, 1}, {4, 0}, /* Row 20 */ + {4, 0}, {18, 1}, {3, 0}, /* Row 21 */ + {4, 0}, {18, 1}, {3, 0}, /* Row 22 */ + {4, 0}, {18, 1}, {3, 0}, /* Row 23 */ + {4, 0}, {18, 1}, {3, 0}, /* Row 24 */ + {5, 0}, {16, 1}, {4, 0}, /* Row 25 */ +}; + +/******************************************************************************************** + * Public Bitmap Structure Defintions + ********************************************************************************************/ + +const struct 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_nshNormalLut, // Index 0: Unselected LUT + g_nshSelectedLut, // Index 1: Selected LUT + }, + g_nshRleEntries // data - Pointer to the beginning of the RLE data +};