summaryrefslogtreecommitdiff
path: root/NxWidgets/nxwm
diff options
context:
space:
mode:
Diffstat (limited to 'NxWidgets/nxwm')
-rw-r--r--NxWidgets/nxwm/images/nxconsole.gifbin0 -> 131 bytes
-rw-r--r--NxWidgets/nxwm/include/cnxconsole.hxx98
-rw-r--r--NxWidgets/nxwm/include/inxapplication.hxx76
-rw-r--r--NxWidgets/nxwm/include/nxwmconfig.hxx84
-rw-r--r--NxWidgets/nxwm/src/snxconsole.cxx180
5 files changed, 438 insertions, 0 deletions
diff --git a/NxWidgets/nxwm/images/nxconsole.gif b/NxWidgets/nxwm/images/nxconsole.gif
new file mode 100644
index 000000000..acb56754b
--- /dev/null
+++ b/NxWidgets/nxwm/images/nxconsole.gif
Binary files differ
diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx
new file mode 100644
index 000000000..eb76ba10b
--- /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 <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_NXX
+#define __INCLUDE_CNXCONSOLE_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#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 000000000..367ba871f
--- /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 <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_INXAPPLICATION_NXX
+#define __INCLUDE_INXAPPLICATION_NXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#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 000000000..18b35d83a
--- /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 <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_NXWM_CONFIG_HXX
+#define __INCLUDE_NXWM_CONFIG_HXX
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#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 000000000..34912933e
--- /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 <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 "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
+};