summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-20 18:56:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-20 18:56:14 +0000
commit01bce341a9d065e8250f655c246c07a525779bc0 (patch)
tree8420c219c8f334bb6ec77acb5e51a3872bb2461e /NxWidgets/libnxwidgets
parentc5ff7843f26438947da8fa0b0fc9b255aeb1d638 (diff)
downloadpx4-nuttx-01bce341a9d065e8250f655c246c07a525779bc0.tar.gz
px4-nuttx-01bce341a9d065e8250f655c246c07a525779bc0.tar.bz2
px4-nuttx-01bce341a9d065e8250f655c246c07a525779bc0.zip
NxWM::CNxConsole and NXWidgets::CCallback can now redirect keyboard input to the NxConsole driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4754 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets')
-rw-r--r--NxWidgets/libnxwidgets/include/cbgwindow.hxx21
-rw-r--r--NxWidgets/libnxwidgets/include/ccallback.hxx32
-rw-r--r--NxWidgets/libnxwidgets/include/cnxtkwindow.hxx21
-rw-r--r--NxWidgets/libnxwidgets/include/cnxtoolbar.hxx21
-rw-r--r--NxWidgets/libnxwidgets/include/cnxwindow.hxx21
-rw-r--r--NxWidgets/libnxwidgets/include/inxwindow.hxx22
-rw-r--r--NxWidgets/libnxwidgets/include/nxconfig.hxx8
-rw-r--r--NxWidgets/libnxwidgets/src/cbgwindow.cxx3
-rw-r--r--NxWidgets/libnxwidgets/src/ccallback.cxx61
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtkwindow.cxx3
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtoolbar.cxx2
-rw-r--r--NxWidgets/libnxwidgets/src/cnxwindow.cxx3
12 files changed, 196 insertions, 22 deletions
diff --git a/NxWidgets/libnxwidgets/include/cbgwindow.hxx b/NxWidgets/libnxwidgets/include/cbgwindow.hxx
index 435fdffbf..21b75799d 100644
--- a/NxWidgets/libnxwidgets/include/cbgwindow.hxx
+++ b/NxWidgets/libnxwidgets/include/cbgwindow.hxx
@@ -207,6 +207,27 @@ namespace NXWidgets
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.
diff --git a/NxWidgets/libnxwidgets/include/ccallback.hxx b/NxWidgets/libnxwidgets/include/ccallback.hxx
index 09cb83a8a..8d3c13cd2 100644
--- a/NxWidgets/libnxwidgets/include/ccallback.hxx
+++ b/NxWidgets/libnxwidgets/include/ccallback.hxx
@@ -48,7 +48,10 @@
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nx.h>
-#include <nuttx/nx/nxtk.h>
+
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
#include "crect.hxx"
@@ -88,7 +91,11 @@ namespace NXWidgets
class CCallback
{
private:
- struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */
+ 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
@@ -235,6 +242,27 @@ namespace NXWidgets
{
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
};
}
diff --git a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx
index 8fda121a9..16a0bee92 100644
--- a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx
+++ b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx
@@ -228,6 +228,27 @@ namespace NXWidgets
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.
diff --git a/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx
index 8e016c15e..69a004da5 100644
--- a/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx
+++ b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx
@@ -197,6 +197,27 @@ namespace NXWidgets
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.
diff --git a/NxWidgets/libnxwidgets/include/cnxwindow.hxx b/NxWidgets/libnxwidgets/include/cnxwindow.hxx
index e39c3cc81..50822cc83 100644
--- a/NxWidgets/libnxwidgets/include/cnxwindow.hxx
+++ b/NxWidgets/libnxwidgets/include/cnxwindow.hxx
@@ -201,6 +201,27 @@ namespace NXWidgets
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.
diff --git a/NxWidgets/libnxwidgets/include/inxwindow.hxx b/NxWidgets/libnxwidgets/include/inxwindow.hxx
index 750994a71..210a1e6ce 100644
--- a/NxWidgets/libnxwidgets/include/inxwindow.hxx
+++ b/NxWidgets/libnxwidgets/include/inxwindow.hxx
@@ -47,6 +47,10 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@@ -169,6 +173,24 @@ namespace NXWidgets
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.
diff --git a/NxWidgets/libnxwidgets/include/nxconfig.hxx b/NxWidgets/libnxwidgets/include/nxconfig.hxx
index 5ab883ab1..699686822 100644
--- a/NxWidgets/libnxwidgets/include/nxconfig.hxx
+++ b/NxWidgets/libnxwidgets/include/nxconfig.hxx
@@ -184,6 +184,14 @@
# 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)
diff --git a/NxWidgets/libnxwidgets/src/cbgwindow.cxx b/NxWidgets/libnxwidgets/src/cbgwindow.cxx
index 58ecc1f51..268bc5d80 100644
--- a/NxWidgets/libnxwidgets/src/cbgwindow.cxx
+++ b/NxWidgets/libnxwidgets/src/cbgwindow.cxx
@@ -101,7 +101,8 @@ bool CBgWindow::open(void)
// Request the background the window
- int ret = nx_requestbkgd(m_hNxServer, vtable, (FAR void *)m_widgetControl);
+ int ret = nx_requestbkgd(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
if (ret < 0)
{
return false;
diff --git a/NxWidgets/libnxwidgets/src/ccallback.cxx b/NxWidgets/libnxwidgets/src/ccallback.cxx
index b2256c6bb..374502a38 100644
--- a/NxWidgets/libnxwidgets/src/ccallback.cxx
+++ b/NxWidgets/libnxwidgets/src/ccallback.cxx
@@ -44,6 +44,10 @@
#include <stdbool.h>
#include <debug.h>
+#ifdef CONFIG_NXCONSOLE_NXKBDIN
+# include <nuttx/nx/nxconsole.h>
+#endif
+
#include "cwidgetcontrol.hxx"
#include "ccallback.hxx"
@@ -65,6 +69,10 @@ using namespace NXWidgets;
CCallback::CCallback(CWidgetControl *widgetControl)
{
+ // Save the widgetControl
+
+ m_widgetControl = widgetControl;
+
// Initialize the callback vtable
m_callbacks.redraw = redraw;
@@ -76,6 +84,12 @@ CCallback::CCallback(CWidgetControl *widgetControl)
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
}
/**
@@ -98,13 +112,13 @@ void CCallback::redraw(NXHANDLE hwnd,
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
bMore ? "true" : "false");
- // The argument must be the CWidgetControl instance
+ // The argument must be the CCallback instance
- CWidgetControl *This = (CWidgetControl *)arg;
+ CCallback *This = (CCallback *)arg;
// Just forward the callback to the CWidgetControl::redrawEvent method
- This->redrawEvent(rect, bMore);
+ This->m_widgetControl->redrawEvent(rect, bMore);
}
/**
@@ -132,13 +146,13 @@ void CCallback::position(NXHANDLE hwnd,
arg);
- // The argument must be the CWidgetControl instance
+ // The argument must be the CCallback instance
- CWidgetControl *This = (CWidgetControl *)arg;
+ CCallback *This = (CCallback *)arg;
// Just forward the callback to the CWidgetControl::geometry method
- This->geometryEvent(hwnd, size, pos, bounds);
+ This->m_widgetControl->geometryEvent(hwnd, size, pos, bounds);
}
/**
@@ -160,13 +174,13 @@ void CCallback::newMouseEvent(NXHANDLE hwnd,
gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n",
hwnd, pos->x, pos->y, buttons, arg);
- // The argument must be the CWidgetControl instance
+ // The argument must be the CCallback instance
- CWidgetControl *This = (CWidgetControl *)arg;
+ CCallback *This = (CCallback *)arg;
// Just forward the callback to the CWidgetControl::newMouseEvent method
- This->newMouseEvent(pos, buttons);
+ This->m_widgetControl->newMouseEvent(pos, buttons);
}
#endif /* CONFIG_NX_MOUSE */
@@ -188,13 +202,28 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
{
gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg);
- // The argument must be the CWidgetControl instance
+ // The argument must be the CCallback instance
+
+ CCallback *This = (CCallback *)arg;
- CWidgetControl *This = (CWidgetControl *)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?
- // Just forward the callback to the CWidgetControl::newKeyboardEvent method
+#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->newKeyboardEvent(nCh, str);
+ This->m_widgetControl->newKeyboardEvent(nCh, str);
+ }
}
/**
@@ -221,13 +250,13 @@ 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 CWidgetControl instance
+ // The first argument must be the CCallback instance
- CWidgetControl *This = (CWidgetControl *)arg1;
+ CCallback *This = (CCallback *)arg1;
// Just forward the callback to the CWidgetControl::windowBlocked method
- This->windowBlocked(arg2);
+ This->m_widgetControl->windowBlocked(arg2);
}
#endif
diff --git a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
index 6a9c115e1..b1d7be9e2 100644
--- a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
@@ -118,7 +118,8 @@ bool CNxTkWindow::open(void)
// Create the window
- m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl);
+ m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
return m_hNxTkWindow != NULL;
}
diff --git a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
index 12b6bea4c..725a368fa 100644
--- a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx
@@ -119,7 +119,7 @@ bool CNxToolbar::open(void)
// Create the toolbar
int ret = nxtk_opentoolbar(m_hNxTkWindow, m_height, vtable,
- (FAR void *)m_widgetControl);
+ (FAR void *)static_cast<CCallback*>(this));
return ret == OK;
}
diff --git a/NxWidgets/libnxwidgets/src/cnxwindow.cxx b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
index 5ba4d734c..b38667d8d 100644
--- a/NxWidgets/libnxwidgets/src/cnxwindow.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
@@ -99,7 +99,8 @@ bool CNxWindow::open(void)
// Create the window
- m_hNxWindow = nx_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl);
+ m_hNxWindow = nx_openwindow(m_hNxServer, vtable,
+ (FAR void *)static_cast<CCallback*>(this));
return m_hNxWindow != NULL;
}