summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-03 15:27:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-03 15:27:40 +0000
commit148215506db4a47326caf083d90ffed788583061 (patch)
tree2a6cf811d1e1c86821e0cd284c056bb2e7f531f7
parent37b3d65d15fa5e041a5cdb03d404505ae293e38e (diff)
downloadpx4-nuttx-148215506db4a47326caf083d90ffed788583061.tar.gz
px4-nuttx-148215506db4a47326caf083d90ffed788583061.tar.bz2
px4-nuttx-148215506db4a47326caf083d90ffed788583061.zip
Modify examples/nx to use NXTK; fix related bugs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1407 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/configs/sim/nx/defconfig5
-rw-r--r--nuttx/configs/sim/nx/defconfig-x115
-rw-r--r--nuttx/examples/README.txt3
-rw-r--r--nuttx/examples/nx/nx_events.c277
-rw-r--r--nuttx/examples/nx/nx_internal.h26
-rw-r--r--nuttx/examples/nx/nx_main.c306
-rw-r--r--nuttx/graphics/nxmu/nxmu_openwindow.c2
-rw-r--r--nuttx/graphics/nxtk/nxtk_drawframe.c25
-rw-r--r--nuttx/include/nuttx/nxtk.h18
9 files changed, 525 insertions, 142 deletions
diff --git a/nuttx/configs/sim/nx/defconfig b/nuttx/configs/sim/nx/defconfig
index 27c5baf60..d33a70c54 100644
--- a/nuttx/configs/sim/nx/defconfig
+++ b/nuttx/configs/sim/nx/defconfig
@@ -437,6 +437,9 @@ CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
# CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
# CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
# CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
+# CONFIG_EXAMPLES_NX_TBCOLOR -- The color ofthe toolbar. Default: '3'
+# CONFIG_EXAMPLES_NX_RAWWINDOWS -- Use raw windows; Default is to
+# use pretty, framed NXTK windows with toolbars.
# CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating
# the NX server. Default 2048
# CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80
@@ -447,6 +450,8 @@ CONFIG_EXAMPLES_NX_VPLANE=0
#CONFIG_EXAMPLES_NX_BGCOLOR
#CONFIG_EXAMPLES_NX_COLOR1
#CONFIG_EXAMPLES_NX_COLOR2
+#CONFIG_EXAMPLES_NX_TBCOLOR
+CONFIG_EXAMPLES_NX_RAWWINDOWS=n
CONFIG_EXAMPLES_NX_STACKSIZE=8192
CONFIG_EXAMPLES_NX_CLIENTPRIO=80
CONFIG_EXAMPLES_NX_SERVERPRIO=120
diff --git a/nuttx/configs/sim/nx/defconfig-x11 b/nuttx/configs/sim/nx/defconfig-x11
index 397159148..5cd232cea 100644
--- a/nuttx/configs/sim/nx/defconfig-x11
+++ b/nuttx/configs/sim/nx/defconfig-x11
@@ -437,6 +437,9 @@ CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
# CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
# CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
# CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
+# CONFIG_EXAMPLES_NX_TBCOLOR -- The color ofthe toolbar. Default: '3'
+# CONFIG_EXAMPLES_NX_RAWWINDOWS -- Use raw windows; Default is to
+# use pretty, framed NXTK windows with toolbars.
# CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating
# the NX server. Default 2048
# CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80
@@ -447,6 +450,8 @@ CONFIG_EXAMPLES_NX_VPLANE=0
#CONFIG_EXAMPLES_NX_BGCOLOR
#CONFIG_EXAMPLES_NX_COLOR1
#CONFIG_EXAMPLES_NX_COLOR2
+#CONFIG_EXAMPLES_NX_TBCOLOR
+CONFIG_EXAMPLES_NX_RAWWINDOWS=n
CONFIG_EXAMPLES_NX_STACKSIZE=8192
CONFIG_EXAMPLES_NX_CLIENTPRIO=80
CONFIG_EXAMPLES_NX_SERVERPRIO=120
diff --git a/nuttx/examples/README.txt b/nuttx/examples/README.txt
index f3b7aba5c..d4d7017a7 100644
--- a/nuttx/examples/README.txt
+++ b/nuttx/examples/README.txt
@@ -66,6 +66,9 @@ examples/nx
CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
+ CONFIG_EXAMPLES_NX_TBCOLOR -- The color of the toolbar. Default: '3'
+ CONFIG_EXAMPLES_NX_RAWWINDOWS -- Use raw windows; Default is to
+ use pretty, framed NXTK windows with toolbars.
This test can be performed with either the single-user version of
NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER.
diff --git a/nuttx/examples/nx/nx_events.c b/nuttx/examples/nx/nx_events.c
index 9d6b2f055..a3c7d7830 100644
--- a/nuttx/examples/nx/nx_events.c
+++ b/nuttx/examples/nx/nx_events.c
@@ -46,12 +46,19 @@
#include <errno.h>
#include <nuttx/nx.h>
+#include <nuttx/nxtk.h>
#include "nx_internal.h"
/****************************************************************************
* Definitions
****************************************************************************/
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+# define NXEGWINDOW NXWINDOW
+#else
+# define NXEGWINDOW NXTKWINDOW
+#endif
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -60,26 +67,34 @@
* Private Function Prototypes
****************************************************************************/
-static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- boolean morem, FAR void *arg);
-static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- boolean more, FAR void *arg);
-static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg);
-static void nxeg_position2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg);
+static void nxeg_redraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean morem, FAR void *arg);
+static void nxeg_position(NXEGWINDOW 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);
#ifdef CONFIG_NX_MOUSE
-static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- ubyte buttons, FAR void *arg);
-static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- ubyte buttons, FAR void *arg);
+static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons, FAR void *arg);
#endif
#ifdef CONFIG_NX_KBD
-static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
+static void nxeg_kbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch);
+#endif
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean morem, FAR void *arg);
+static void nxeg_tbposition(NXEGWINDOW 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);
+#ifdef CONFIG_NX_MOUSE
+static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons, FAR void *arg);
+#endif
+#ifdef CONFIG_NX_KBD
+static void nxeg_tbkbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch);
+#endif
#endif
/****************************************************************************
@@ -90,77 +105,115 @@ static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
* Public Data
****************************************************************************/
-const struct nx_callback_s g_nxcb1 =
+const struct nx_callback_s g_nxcb =
{
- nxeg_redraw1, /* redraw */
- nxeg_position1 /* position */
+ nxeg_redraw, /* redraw */
+ nxeg_position /* position */
#ifdef CONFIG_NX_MOUSE
- , nxeg_mousein1 /* mousein */
+ , nxeg_mousein /* mousein */
#endif
#ifdef CONFIG_NX_KBD
- , nxeg_kbdin1 /* my kbdin */
+ , nxeg_kbdin /* my kbdin */
#endif
};
-const struct nx_callback_s g_nxcb2 =
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+const struct nx_callback_s g_tbcb =
{
- nxeg_redraw2, /* redraw */
- nxeg_position2 /* position */
+ nxeg_tbredraw, /* redraw */
+ nxeg_tbposition /* position */
#ifdef CONFIG_NX_MOUSE
- , nxeg_mousein2 /* mousein */
+ , nxeg_tbmousein /* mousein */
#endif
#ifdef CONFIG_NX_KBD
- , nxeg_kbdin2 /* my kbdin */
+ , nxeg_tbkbdin /* my kbdin */
#endif
};
+#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
- * Name: nxeg_redraw1
+ * Name: nxeg_fillwindow
****************************************************************************/
-static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- boolean more, FAR void *arg)
+static inline void nxeg_fillwindow(NXEGWINDOW hwnd,
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
- message("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
- (int)arg, hwnd,
- rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
- more ? "TRUE" : "FALSE");
- nx_fill(hwnd, rect, g_color1);
+ int ret;
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+ ret = nx_fill(hwnd, rect, color);
+ if (ret < 0)
+ {
+ message("nxeg_fillwindow: nx_fill failed: %d\n", errno);
+ }
+#else
+ ret = nxtk_fillwindow(hwnd, rect, color);
+ if (ret < 0)
+ {
+ message("nxeg_fillwindow: nxtk_fillwindow failed: %d\n", errno);
+ }
+#endif
+}
+
+/****************************************************************************
+ * Name: nxeg_fillwindow
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline void nxeg_filltoolbar(NXTKTOOLBAR htb,
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
+{
+ int ret;
+
+ ret = nxtk_filltoolbar(htb, rect, color);
+ if (ret < 0)
+ {
+ message("nxeg_filltoolbar: nxtk_filltoolbar failed: %d\n", errno);
+ }
}
+#endif
/****************************************************************************
- * Name: nxeg_redraw2
+ * Name: nxeg_redraw1
****************************************************************************/
-static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- boolean more, FAR void *arg)
+static void nxeg_redraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more, FAR void *arg)
{
message("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
(int)arg, hwnd,
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
more ? "TRUE" : "FALSE");
- nx_fill(hwnd, rect, g_color2);
+
+ if (arg == (FAR void *)2)
+ {
+ nxeg_fillwindow(hwnd, rect, g_color2);
+ }
+ else
+ {
+ nxeg_fillwindow(hwnd, rect, g_color1);
+ }
}
/****************************************************************************
- * Name: nxeg_position1
+ * Name: nxeg_position
****************************************************************************/
-static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg)
+static void nxeg_position(NXEGWINDOW 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)
{
/* Report the position */
- message("nxeg_position%d: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
- arg, hwnd,
- size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y,
- pos->x, pos->y,
+ message("nxeg_position%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
+ arg, hwnd, size->w, size->h, pos->x, pos->y,
bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
/* Have we picked off the window bounds yet? */
@@ -179,30 +232,12 @@ static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
}
/****************************************************************************
- * Name: nxeg_position2
- ****************************************************************************/
-
-static void nxeg_position2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg)
-{
- /* Report the position */
-
- message("nxeg_position%d: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
- arg, hwnd,
- size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y,
- pos->x, pos->y,
- bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
-}
-
-/****************************************************************************
- * Name: nxeg_mousein1
+ * Name: nxeg_mousein
****************************************************************************/
#ifdef CONFIG_NX_MOUSE
-static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- ubyte buttons, FAR void *arg)
+static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons, FAR void *arg)
{
message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n",
(int)arg, hwnd, pos->x, pos->y, buttons);
@@ -210,19 +245,6 @@ static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
#endif
/****************************************************************************
- * Name: nxeg_mousein2
- ****************************************************************************/
-
-#ifdef CONFIG_NX_MOUSE
-static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- ubyte buttons, FAR void *arg)
-{
- message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n",
- (int)arg, hwnd, pos->x, pos->y, buttons);
-}
-#endif
-
-/****************************************************************************
* Name: nxeg_kbdinfo
****************************************************************************/
@@ -245,28 +267,109 @@ static void nxeg_kbdinfo(ubyte nch, const ubyte *ch)
#endif
/****************************************************************************
- * Name: nxeg_kbdin1
+ * Name: nxeg_kbdin
****************************************************************************/
#ifdef CONFIG_NX_KBD
-static void nxeg_kbdin1(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
+static void nxeg_kbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch)
{
- message("nxeg_kbdin1: hwnd=%p nch=%d\n", hwnd, nch);
+ message("nxeg_kbdin: hwnd=%p nch=%d\n", hwnd, nch);
nxeg_kbdinfo(nch, ch);
}
#endif
/****************************************************************************
+ * Name: nxeg_tbredraw
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more, FAR void *arg)
+{
+ message("nxeg_tbredraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
+ (int)arg, hwnd,
+ rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
+ more ? "TRUE" : "FALSE");
+ nxeg_filltoolbar(hwnd, rect, g_tbcolor);
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_position1
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static void nxeg_tbposition(NXEGWINDOW 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)
+{
+ /* Report the position */
+
+ message("nxeg_ptbosition%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
+ arg, hwnd, size->w, size->h, pos->x, pos->y,
+ bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_tbmousein
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+#ifdef CONFIG_NX_MOUSE
+static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons, FAR void *arg)
+{
+ message("nxeg_tbmousein%d: hwnd=%p pos=(%d,%d) button=%02x\n",
+ (int)arg, hwnd, pos->x, pos->y, buttons);
+}
+#endif
+#endif
+
+/****************************************************************************
+ * Name: nxeg_tbkbdin
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+#ifdef CONFIG_NX_KBD
+static void nxeg_tbkbdin(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch)
+{
+ message("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n";
+ message("nxeg_tbkbdin: hwnd=%p nch=%d\n", hwnd, nch);
+ nxeg_kbdinfo(nch, ch);
+}
+#endif
+#endif
+
+/****************************************************************************
* Name: nxeg_kbdin2
****************************************************************************/
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
#ifdef CONFIG_NX_KBD
-static void nxeg_kbdin2(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
+static void nxeg_kbdin2(NXEGWINDOW hwnd, ubyte nch, const ubyte *ch)
{
message("nxeg_kbdin2: hwnd=%p nch=%d\n", hwnd, nch);
nxeg_kbdinfo(nch, ch);
}
#endif
+#endif
+
+/****************************************************************************
+ * Name: nxeg_mousein2
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+#ifdef CONFIG_NX_MOUSE
+static void nxeg_mousein2(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons, FAR void *arg)
+{
+ message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n",
+ (int)arg, hwnd, pos->x, pos->y, buttons);
+}
+#endif
+#endif
/****************************************************************************
* Public Functions
@@ -281,8 +384,6 @@ FAR void *nx_listenerthread(FAR void *arg)
{
int ret;
- /* Set up to catch a signal */
-
/* Process events forever */
for (;;)
diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h
index 32164eac3..58febc5b7 100644
--- a/nuttx/examples/nx/nx_internal.h
+++ b/nuttx/examples/nx/nx_internal.h
@@ -88,6 +88,20 @@
# endif
#endif
+#ifndef CONFIG_EXAMPLES_NX_TBCOLOR
+# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
+# define CONFIG_EXAMPLES_NX_TBCOLOR 0x00a9a9a9
+# elif CONFIG_SIM_FBBPP = 16
+# define CONFIG_EXAMPLES_NX_TBCOLOR 0xad55
+# else
+# define CONFIG_EXAMPLES_NX_TBCOLOR '3'
+# endif
+#endif
+
+#ifndef CONFIG_TOOLBAR_HEIGHT
+# define CONFIG_TOOLBAR_HEIGHT 16
+#endif
+
#ifdef CONFIG_NX_MULTIUSER
# ifdef CONFIG_DISABLE_MQUEUE
# error "The multi-threaded example requires MQ support (CONFIG_DISABLE_MQUEUE=n)"
@@ -153,11 +167,14 @@ enum exitcode_e
NXEXIT_FBINITIALIZE,
NXEXIT_FBGETVPLANE,
NXEXIT_NXOPEN,
+ NXEXIT_NXOPENTOOLBAR,
NXEXIT_NXCONNECT,
NXEXIT_NXSETBGCOLOR,
NXEXIT_NXOPENWINDOW,
NXEXIT_NXSETSIZE,
NXEXIT_NXSETPOSITION,
+ NXEXIT_NXLOWER,
+ NXEXIT_NXRAISE,
NXEXIT_NXCLOSEWINDOW,
NXEXIT_LOSTSERVERCONN
};
@@ -172,8 +189,10 @@ extern NXHANDLE g_hnx;
/* NX callback vtables */
-extern const struct nx_callback_s g_nxcb1;
-extern const struct nx_callback_s g_nxcb2;
+extern const struct nx_callback_s g_nxcb;
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+extern const struct nx_callback_s g_tbcb;
+#endif
/* The screen resolution */
@@ -190,6 +209,9 @@ extern sem_t g_semevent;
extern nxgl_mxpixel_t g_color1[CONFIG_NX_NPLANES];
extern nxgl_mxpixel_t g_color2[CONFIG_NX_NPLANES];
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+extern nxgl_mxpixel_t g_tbcolor[CONFIG_NX_NPLANES];
+#endif
/****************************************************************************
* Public Function Prototypes
diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c
index ee3182576..7e68b47bd 100644
--- a/nuttx/examples/nx/nx_main.c
+++ b/nuttx/examples/nx/nx_main.c
@@ -51,6 +51,7 @@
#include <nuttx/fb.h>
#include <nuttx/arch.h>
#include <nuttx/nx.h>
+#include <nuttx/nxtk.h>
#include "nx_internal.h"
/****************************************************************************
@@ -94,6 +95,9 @@ sem_t g_semevent = {0};
nxgl_mxpixel_t g_color1[CONFIG_NX_NPLANES];
nxgl_mxpixel_t g_color2[CONFIG_NX_NPLANES];
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+nxgl_mxpixel_t g_tbcolor[CONFIG_NX_NPLANES];
+#endif
/****************************************************************************
* Private Functions
@@ -123,6 +127,200 @@ static void nxeg_drivemouse(void)
#endif
/****************************************************************************
+ * Name: nxeg_openwindow
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline NXWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
+ FAR void *arg)
+{
+ NXWINDOW hwnd;
+
+ hwnd = nx_openwindow(g_hnx, cb, arg);
+ if (!hwnd)
+ {
+ message("user_start: nx_openwindow failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXOPENWINDOW;
+ }
+ return hwnd;
+}
+#else
+static inline NXTKWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
+ FAR void *arg)
+{
+ NXTKWINDOW hwnd;
+
+ hwnd = nxtk_openwindow(g_hnx, cb, arg);
+ if (!hwnd)
+ {
+ message("user_start: nxtk_openwindow failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXOPENWINDOW;
+ }
+ return hwnd;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_closewindow
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline int nxeg_closewindow(NXWINDOW hwnd)
+{
+ int ret = nx_closewindow(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nx_openwindow failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXCLOSEWINDOW;
+ }
+ return ret;
+}
+#else
+static inline int nxeg_closewindow(NXTKWINDOW hwnd)
+{
+ int ret = nxtk_closewindow(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nxtk_openwindow failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXCLOSEWINDOW;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_setsize
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline int nxeg_setsize(NXWINDOW hwnd, FAR struct nxgl_size_s *size)
+{
+ int ret = nx_setsize(hwnd, size);
+ if (ret < 0)
+ {
+ message("user_start: nx_setsize failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXSETSIZE;
+ }
+ return ret;
+}
+#else
+static inline int nxeg_setsize(NXTKWINDOW hwnd, FAR struct nxgl_size_s *size)
+{
+ int ret = nxtk_setsize(hwnd, size);
+ if (ret < 0)
+ {
+ message("user_start: nxtk_setsize failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXSETSIZE;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_setposition
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline int nxeg_setposition(NXWINDOW hwnd, FAR struct nxgl_point_s *pos)
+{
+ int ret = nx_setposition(hwnd, pos);
+ if (ret < 0)
+ {
+ message("user_start: nx_setposition failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXSETPOSITION;
+ }
+ return ret;
+}
+#else
+static inline int nxeg_setposition(NXTKWINDOW hwnd, FAR struct nxgl_point_s *pos)
+{
+ int ret = nxtk_setposition(hwnd, pos);
+ if (ret < 0)
+ {
+ message("user_start: nxtk_setposition failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXSETPOSITION;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeq_opentoolbar
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline NXTKTOOLBAR nxeq_opentoolbar(NXTKWINDOW hwnd, nxgl_coord_t height,
+ FAR const struct nx_callback_s *cb,
+ FAR void *arg)
+{
+ NXTKTOOLBAR htb;
+ htb = nxtk_opentoolbar(hwnd, height, cb, arg);
+ if (!htb < 0)
+ {
+ message("user_start: nxtk_opentoolbar failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXOPENTOOLBAR;
+ }
+ return htb;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_lower
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline int nxeg_lower(NXWINDOW hwnd)
+{
+ int ret = nx_lower(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nx_lower failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXLOWER;
+ }
+ return ret;
+}
+#else
+static inline int nxeg_lower(NXTKWINDOW hwnd)
+{
+ int ret = nxtk_lower(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nxtk_lower failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXLOWER;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_raise
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
+static inline int nxeg_raise(NXWINDOW hwnd)
+{
+ int ret = nx_raise(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nx_raise failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXRAISE;
+ }
+ return ret;
+}
+#else
+static inline int nxeg_raise(NXTKWINDOW hwnd)
+{
+ int ret = nxtk_raise(hwnd);
+ if (ret < 0)
+ {
+ message("user_start: nxtk_raise failed: %d\n", errno);
+ g_exitcode = NXEXIT_NXRAISE;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
* Name: nxeg_suinitialize
****************************************************************************/
@@ -262,8 +460,11 @@ static int nxeg_initialize(void)
for (i = 0; i < CONFIG_NX_NPLANES; i++)
{
- g_color1[i] = CONFIG_EXAMPLES_NX_COLOR1;
- g_color2[i] = CONFIG_EXAMPLES_NX_COLOR2;
+ g_color1[i] = CONFIG_EXAMPLES_NX_COLOR1;
+ g_color2[i] = CONFIG_EXAMPLES_NX_COLOR2;
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+ g_tbcolor[i] = CONFIG_EXAMPLES_NX_TBCOLOR;
+#endif
}
#ifdef CONFIG_NX_MULTIUSER
@@ -291,8 +492,15 @@ void user_initialize(void)
int user_start(int argc, char *argv[])
{
+#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
NXWINDOW hwnd1;
NXWINDOW hwnd2;
+#else
+ NXTKWINDOW hwnd1;
+ NXTKWINDOW hwnd2;
+ NXTKTOOLBAR htb1;
+ NXTKTOOLBAR htb2;
+#endif
struct nxgl_size_s size;
struct nxgl_point_s pt;
nxgl_mxpixel_t color;
@@ -324,13 +532,10 @@ int user_start(int argc, char *argv[])
/* Create window #1 */
message("user_start: Create window #1\n");
- hwnd1 = nx_openwindow(g_hnx, &g_nxcb1, (FAR void *)1);
+ hwnd1 = nxeg_openwindow(&g_nxcb, (FAR void *)1);
message("user_start: hwnd1=%p\n", hwnd1);
-
if (!hwnd1)
{
- message("user_start: nx_openwindow failed: %d\n", errno);
- g_exitcode = NXEXIT_NXOPENWINDOW;
goto errout_with_nx;
}
@@ -347,12 +552,10 @@ int user_start(int argc, char *argv[])
size.w = g_xres / 2;
size.h = g_yres / 2;
- message("user_start: Set hwnd1 size to (%d,%d)\n", size.w, size.h);
- ret = nx_setsize(hwnd1, &size);
+ message("user_start: Set window #1 size to (%d,%d)\n", size.w, size.h);
+ ret = nxeg_setsize(hwnd1, &size);
if (ret < 0)
{
- message("user_start: nx_setsize failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETSIZE;
goto errout_with_hwnd1;
}
@@ -369,30 +572,41 @@ int user_start(int argc, char *argv[])
pt.x = g_xres / 8;
pt.y = g_yres / 8;
- message("user_start: Set hwnd1 postion to (%d,%d)\n", pt.x, pt.y);
- ret = nx_setposition(hwnd1, &pt);
+ message("user_start: Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
+ ret = nxeg_setposition(hwnd1, &pt);
if (ret < 0)
{
- message("user_start: nx_setposition failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETPOSITION;
goto errout_with_hwnd1;
}
/* Sleep a bit */
message("user_start: Sleeping\n\n");
- sleep(2);
+ sleep(1);
+
+ /* Open the toolbar */
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+ message("user_start: Add toolbar to window #1\n");
+ htb1 = nxeq_opentoolbar(hwnd1, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)1);
+ if (!htb1)
+ {
+ goto errout_with_hwnd1;
+ }
+
+ /* Sleep a bit */
+
+ message("user_start: Sleeping\n\n");
+ sleep(1);
+#endif
/* Create window #2 */
message("user_start: Create window #2\n");
- hwnd2 = nx_openwindow(g_hnx, &g_nxcb2, (FAR void *)2);
- message("user_start: hwnd2=%p\n", hwnd2);
-
- if (!hwnd2)
+ hwnd2 = nxeg_openwindow(&g_nxcb, (FAR void *)2);
+ message("user_start: hwnd1=%p\n", hwnd1);
+ if (!hwnd1)
{
- message("user_start: nx_openwindow failed: %d\n", errno);
- g_exitcode = NXEXIT_NXOPENWINDOW;
goto errout_with_hwnd1;
}
@@ -404,11 +618,9 @@ int user_start(int argc, char *argv[])
/* Set the size of the window 2 == size of window 1*/
message("user_start: Set hwnd2 size to (%d,%d)\n", size.w, size.h);
- ret = nx_setsize(hwnd2, &size);
+ ret = nxeg_setsize(hwnd2, &size);
if (ret < 0)
{
- message("user_start: nx_setsize failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETSIZE;
goto errout_with_hwnd2;
}
@@ -423,27 +635,37 @@ int user_start(int argc, char *argv[])
pt.y = g_yres - size.h - pt.y;
message("user_start: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
- ret = nx_setposition(hwnd2, &pt);
+ ret = nxeg_setposition(hwnd2, &pt);
if (ret < 0)
{
- message("user_start: nx_setposition failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETPOSITION;
goto errout_with_hwnd2;
}
/* Sleep a bit */
message("user_start: Sleeping\n\n");
- sleep(2);
+ sleep(1);
+
+#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
+ message("user_start: Add toolbar to window #2\n");
+ htb2 = nxeq_opentoolbar(hwnd2, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)2);
+ if (!htb2)
+ {
+ goto errout_with_hwnd2;
+ }
+
+ /* Sleep a bit */
+
+ message("user_start: Sleeping\n\n");
+ sleep(1);
+#endif
/* Lower window 2 */
message("user_start: Lower window #2\n");
- ret = nx_lower(hwnd2);
+ ret = nxeg_lower(hwnd2);
if (ret < 0)
{
- message("user_start: nx_lower failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETPOSITION;
goto errout_with_hwnd2;
}
@@ -466,11 +688,9 @@ int user_start(int argc, char *argv[])
/* Raise window 2 */
message("user_start: Raise window #2\n");
- ret = nx_raise(hwnd2);
+ ret = nxeg_raise(hwnd2);
if (ret < 0)
{
- message("user_start: nx_raise failed: %d\n", errno);
- g_exitcode = NXEXIT_NXSETPOSITION;
goto errout_with_hwnd2;
}
@@ -489,25 +709,13 @@ int user_start(int argc, char *argv[])
errout_with_hwnd2:
message("user_start: Close window\n");
- ret = nx_closewindow(hwnd2);
- if (ret < 0)
- {
- message("user_start: nx_openwindow failed: %d\n", errno);
- g_exitcode = NXEXIT_NXCLOSEWINDOW;
- goto errout_with_nx;
- }
+ (void)nxeg_closewindow(hwnd2);
/* Close the window1 */
errout_with_hwnd1:
- message("user_start: Close window\n");
- ret = nx_closewindow(hwnd1);
- if (ret < 0)
- {
- message("user_start: nx_openwindow failed: %d\n", errno);
- g_exitcode = NXEXIT_NXCLOSEWINDOW;
- goto errout_with_nx;
- }
+ message("user_start: Close window #1\n");
+ (void)nxeg_closewindow(hwnd1);
errout_with_nx:
#ifdef CONFIG_NX_MULTIUSER
diff --git a/nuttx/graphics/nxmu/nxmu_openwindow.c b/nuttx/graphics/nxmu/nxmu_openwindow.c
index a458bc676..706d00a2d 100644
--- a/nuttx/graphics/nxmu/nxmu_openwindow.c
+++ b/nuttx/graphics/nxmu/nxmu_openwindow.c
@@ -104,7 +104,7 @@ void nxmu_openwindow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd)
/* Report the initial size/position of the window to the client */
- nxfe_reportposition((NXWINDOW)wnd);
+ nxfe_reportposition(wnd);
/* Provide the initial mouse settings to the client */
diff --git a/nuttx/graphics/nxtk/nxtk_drawframe.c b/nuttx/graphics/nxtk/nxtk_drawframe.c
index 0b8a73361..9fb85fc56 100644
--- a/nuttx/graphics/nxtk/nxtk_drawframe.c
+++ b/nuttx/graphics/nxtk/nxtk_drawframe.c
@@ -187,7 +187,11 @@ int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd,
nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2);
#endif
- /* Draw the inner left side, Thickness: 1, Color: CONFIG_NXTK_BORDERCOLOR2 */
+ /* Draw the inner left side, Thickness: 1, Color: CONFIG_NXTK_BORDERCOLOR2.
+ * This segment stops at the bottom of the toolbar. If there is a
+ * tool bar, then we have to continue this to the top of the display
+ * using g_bordercolor1 (see below)
+ */
#if CONFIG_NXTK_BORDERWIDTH > 1
frame.pt1.y = CONFIG_NXTK_BORDERWIDTH - 1 + tbsize.h;
@@ -203,7 +207,7 @@ int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd,
/* Draw the inner left side, Thickness: CONFIG_NXTK_BORDERWIDTH-1,
* Color: CONFIG_NXTK_BORDERCOLOR1
- */
+ */
#if CONFIG_NXTK_BORDERWIDTH > 1
frame.pt1.x = wndsize.w - CONFIG_NXTK_BORDERWIDTH;
@@ -213,5 +217,22 @@ int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd,
frame.pt2.x = frame.pt1.x;
#endif
nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1);
+
+ /* When there is a toolbar, we also have to patch in this tiny
+ * line segment -- Is there a better way?
+ */
+
+#if CONFIG_NXTK_BORDERWIDTH > 1
+ if (tbsize.h > 0)
+ {
+ frame.pt1.y = 0;
+ frame.pt2.y = CONFIG_NXTK_BORDERWIDTH + tbsize.h;
+
+ frame.pt1.x = CONFIG_NXTK_BORDERWIDTH - 1;
+ frame.pt2.x = frame.pt1.x;
+ nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1);
+ }
+#endif
+
return OK;
}
diff --git a/nuttx/include/nuttx/nxtk.h b/nuttx/include/nuttx/nxtk.h
index 4a6d9d5cd..44ba800af 100644
--- a/nuttx/include/nuttx/nxtk.h
+++ b/nuttx/include/nuttx/nxtk.h
@@ -189,6 +189,24 @@ EXTERN int nxtk_setsize(NXTKWINDOW hfwnd, FAR struct nxgl_size_s *size);
EXTERN int nxtk_raise(NXTKWINDOW hfwnd);
/****************************************************************************
+ * Name: nxtk_lower
+ *
+ * Description:
+ * Lower the window containing the specified client sub-window to the
+ * bottom of the display.
+ *
+ * Input parameters:
+ * hfwnd - the window to be lowered. This must have been previously created
+ * by nxtk_openwindow().
+ *
+ * Returned value:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+EXTERN int nxtk_lower(NXTKWINDOW hfwnd);
+
+/****************************************************************************
* Name: nxtk_fillwindow
*
* Description: