diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-12 13:50:21 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-12 13:50:21 +0000 |
commit | fb8f25a3f43d6c5a10dfa5a99b9cec55feec97f6 (patch) | |
tree | ce467469470404655e332c2ca8bc05d64283c85f | |
parent | e88d1ff1f09ba0ea6999ab2e5e2d55dc88434646 (diff) | |
download | nuttx-fb8f25a3f43d6c5a10dfa5a99b9cec55feec97f6.tar.gz nuttx-fb8f25a3f43d6c5a10dfa5a99b9cec55feec97f6.tar.bz2 nuttx-fb8f25a3f43d6c5a10dfa5a99b9cec55feec97f6.zip |
Add NxWM::CWindowControl; task bar and start window icons now functional
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4725 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-x | NxWidgets/ChangeLog.txt | 2 | ||||
-rw-r--r-- | NxWidgets/UnitTests/nxwm/main.cxx | 65 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx | 2 | ||||
-rw-r--r-- | NxWidgets/nxwm/Makefile | 1 | ||||
-rw-r--r-- | NxWidgets/nxwm/images/calibration.png | bin | 494 -> 415 bytes | |||
-rw-r--r-- | NxWidgets/nxwm/include/capplicationwindow.hxx | 22 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cfullscreenwindow.hxx | 21 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cstartwindow.hxx | 3 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/ctaskbar.hxx | 11 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cwindowcontrol.hxx | 112 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/capplicationwindow.cxx | 78 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cfullscreenwindow.cxx | 77 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/ctaskbar.cxx | 29 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cwindowcontrol.cxx | 143 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/glyph_calibration.cxx | 147 |
15 files changed, 403 insertions, 310 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index 38e902242..5d316d081 100755 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -58,5 +58,7 @@ * NxWM::CCalibration: Beef up touch input handling logic. Now changes the color of the touch circle to yellow when it is touched. * NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer. +* NxWM::CWindowControl: Add new class to wrap CWidgetControl and provide + some special mouse and keyboard input event handling. diff --git a/NxWidgets/UnitTests/nxwm/main.cxx b/NxWidgets/UnitTests/nxwm/main.cxx index c7433f36e..c230b9f87 100644 --- a/NxWidgets/UnitTests/nxwm/main.cxx +++ b/NxWidgets/UnitTests/nxwm/main.cxx @@ -403,13 +403,9 @@ static bool createTouchScreen(void) #ifdef CONFIG_NXWM_TOUCHSCREEN static bool createCalibration(void) { - // 1. Call CTaskBar::FullScreenWindow to create a window for the application, + // 1. Call CTaskBar::openFullScreenWindow to create a window for the application, // 2. Instantiate the application, providing the window to the application's // constructor, - // 3. Then call CStartWindow::addApplication to add the application to the - // start window. - // 4. Call CTaskBar::startApplication start the application and bring its window to - // the top. printf(MAIN_STRING "Opening the calibration application window\n"); NxWM::CFullScreenWindow *window = g_nxwmtest.taskbar->openFullScreenWindow(); @@ -438,16 +434,6 @@ static bool createCalibration(void) return false; } showTestCaseMemory("After creating CCalibration application"); - - printf(MAIN_STRING "Adding CCalibration application to the start window\n"); - if (!g_nxwmtest.startwindow->addApplication(g_nxwmtest.calibration)) - { - printf(MAIN_STRING "ERROR: Failed to add CCalibration to the start window\n"); - delete g_nxwmtest.calibration; - return false; - } - - showTestCaseMemory("After adding CCalibration application"); return true; } #endif @@ -503,6 +489,26 @@ static bool runCalibration(void) #endif ///////////////////////////////////////////////////////////////////////////// +// Name: addCalibrationToStartWindow +///////////////////////////////////////////////////////////////////////////// + +#ifdef CONFIG_NXWM_TOUCHSCREEN +static bool addCalibrationToStartWindow(void) +{ + printf(MAIN_STRING "Adding CCalibration application to the start window\n"); + if (!g_nxwmtest.startwindow->addApplication(g_nxwmtest.calibration)) + { + printf(MAIN_STRING "ERROR: Failed to add CCalibration to the start window\n"); + delete g_nxwmtest.calibration; + return false; + } + + showTestCaseMemory("After adding CCalibration application"); + return true; +} +#endif + +///////////////////////////////////////////////////////////////////////////// // Name: createNxConsole ///////////////////////////////////////////////////////////////////////////// @@ -605,14 +611,6 @@ int MAIN_NAME(int argc, char *argv[]) testCleanUpAndExit(EXIT_FAILURE); } - // Create the start window. - - if (!createStartWindow()) - { - printf(MAIN_STRING "ERROR: Failed to create the start window\n"); - testCleanUpAndExit(EXIT_FAILURE); - } - // Create the touchscreen device #ifdef CONFIG_NXWM_TOUCHSCREEN @@ -645,6 +643,27 @@ int MAIN_NAME(int argc, char *argv[]) } #endif + + // Create the start window. + + if (!createStartWindow()) + { + printf(MAIN_STRING "ERROR: Failed to create the start window\n"); + testCleanUpAndExit(EXIT_FAILURE); + } + +#ifdef CONFIG_NXWM_TOUCHSCREEN + // Add the calibration application to the start window. It can't really + // be used to re-calibrate (because there is nothing to get the calibration + // data). But is a good case to test a full screen appliation + + if (!addCalibrationToStartWindow()) + { + printf(MAIN_STRING "ERROR: Failed to add calibration to the start window\n"); + testCleanUpAndExit(EXIT_FAILURE); + } +#endif + // Add the NxConsole application to the start window if (!createNxConsole()) diff --git a/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx index 68f5e9d47..1c95264d1 100644 --- a/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx +++ b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx @@ -36,7 +36,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include "nxconfig.hxx" #include "cwindoweventhandler.hxx" diff --git a/NxWidgets/nxwm/Makefile b/NxWidgets/nxwm/Makefile index 3059934c9..d951d11b2 100644 --- a/NxWidgets/nxwm/Makefile +++ b/NxWidgets/nxwm/Makefile @@ -44,6 +44,7 @@ CSRCS = # Window Manager CXXSRCS = capplicationwindow.cxx ccalibration.cxx cfullscreenwindow.cxx CXXSRCS += cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx ctouchscreen.cxx +CXXSRCS += cwindowcontrol.cxx # Images CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx diff --git a/NxWidgets/nxwm/images/calibration.png b/NxWidgets/nxwm/images/calibration.png Binary files differindex 6cdb95e3b..76a84127f 100644 --- a/NxWidgets/nxwm/images/calibration.png +++ b/NxWidgets/nxwm/images/calibration.png diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx index e8ce53740..7736a3081 100644 --- a/NxWidgets/nxwm/include/capplicationwindow.hxx +++ b/NxWidgets/nxwm/include/capplicationwindow.hxx @@ -49,7 +49,6 @@ #include "cimage.hxx" #include "clabel.hxx" #include "crlepalettebitmap.hxx" -#include "cwindoweventhandler.hxx" #include "iapplicationwindow.hxx" @@ -72,8 +71,7 @@ namespace NxWM */ class CApplicationWindow : public IApplicationWindow, - private NXWidgets::CWidgetEventHandler, - private NXWidgets::CWindowEventHandler + private NXWidgets::CWidgetEventHandler { protected: NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */ @@ -87,24 +85,6 @@ namespace NxWM IApplicationCallback *m_callback; /**< Toolbar action callbacks */ /** - * Handle an NX window mouse input event. - * - * @param e The event data. - */ - -#ifdef CONFIG_NX_MOUSE - void handleMouseEvent(void); -#endif - - /** - * Handle a NX window keyboard input event. - */ - -#ifdef CONFIG_NX_KBD - void handleKeyboardEvent(void); -#endif - - /** * Handle a mouse button click event. * * @param e The event data. diff --git a/NxWidgets/nxwm/include/cfullscreenwindow.hxx b/NxWidgets/nxwm/include/cfullscreenwindow.hxx index 41425bf4c..fb4788830 100644 --- a/NxWidgets/nxwm/include/cfullscreenwindow.hxx +++ b/NxWidgets/nxwm/include/cfullscreenwindow.hxx @@ -63,30 +63,11 @@ namespace NxWM * for example, to support full screen displays. */ - class CFullScreenWindow : public IApplicationWindow, - private NXWidgets::CWindowEventHandler + class CFullScreenWindow : public IApplicationWindow { protected: NXWidgets::CNxWindow *m_window; /**< The generic window used by the application */ - /** - * Handle an NX window mouse input event. - * - * @param e The event data. - */ - -#ifdef CONFIG_NX_MOUSE - void handleMouseEvent(void); -#endif - - /** - * Handle a NX window keyboard input event. - */ - -#ifdef CONFIG_NX_KBD - void handleKeyboardEvent(void); -#endif - public: /** diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx index 226fbdf03..5e4fa7564 100644 --- a/NxWidgets/nxwm/include/cstartwindow.hxx +++ b/NxWidgets/nxwm/include/cstartwindow.hxx @@ -61,7 +61,8 @@ namespace NxWM { class CTaskbar; - class CStartWindow : public IApplication, private IApplicationCallback, + class CStartWindow : public IApplication, + private IApplicationCallback, private NXWidgets::CWidgetEventHandler { protected: diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx index 398087f84..1f2f69580 100644 --- a/NxWidgets/nxwm/include/ctaskbar.hxx +++ b/NxWidgets/nxwm/include/ctaskbar.hxx @@ -82,7 +82,8 @@ namespace NxWM * (and I may still do that someday) */ - class CTaskbar : public NXWidgets::CNxServer, private NXWidgets::CWidgetEventHandler + class CTaskbar : public NXWidgets::CNxServer, + private NXWidgets::CWidgetEventHandler { private: /** @@ -109,12 +110,12 @@ namespace NxWM /** * Create a raw window. * - * 1) Create a dumb CWigetControl instance - * 2) Pass the dumb CWidgetControl instance to the window constructor - * that inherits from INxWindow. This will "smarten" the CWidgetControl + * 1) Create a dumb CWindowControl instance + * 2) Pass the dumb CWindowControl instance to the window constructor + * that inherits from INxWindow. This will "smarten" the CWindowControl * instance with some window knowlede * 3) Call the open() method on the window to display the window. - * 4) After that, the fully smartened CWidgetControl instance can + * 4) After that, the fully smartened CWindowControl instance can * be used to generate additional widgets by passing it to the * widget constructor */ diff --git a/NxWidgets/nxwm/include/cwindowcontrol.hxx b/NxWidgets/nxwm/include/cwindowcontrol.hxx new file mode 100644 index 000000000..acec12727 --- /dev/null +++ b/NxWidgets/nxwm/include/cwindowcontrol.hxx @@ -0,0 +1,112 @@ +/**************************************************************************** + * NxWidgets/nxwm/include/cwindowcontrol.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_CWINDOWCONTROL_HXX +#define __INCLUDE_CWINDOWCONTROL_HXX + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <nuttx/nx/nxtk.h> +#include <nuttx/nx/nxconsole.h> + +#include "cwindoweventhandler.hxx" +#include "cwidgetcontrol.hxx" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Implementation Classes + ****************************************************************************/ + +#if defined(__cplusplus) + +namespace NxWM +{ + /** + * The class CWindowControl integrates the widget control with some special + * handling of mouse and keyboard inputs neesed by NxWM + */ + + class CWindowControl : public NXWidgets::CWidgetControl, + private NXWidgets::CWindowEventHandler + { + private: + /** + * Handle an NX window mouse input event. + * + * @param e The event data. + */ + +#ifdef CONFIG_NX_MOUSE + void handleMouseEvent(void); +#endif + + /** + * Handle a NX window keyboard input event. + */ + +#ifdef CONFIG_NX_KBD + void handleKeyboardEvent(void); +#endif + + public: + + /** + * Constructor + * + * @param style The default style that all widgets on this display + * should use. If this is not specified, the widget will use the + * values stored in the defaultCWidgetStyle object. + */ + + CWindowControl(FAR const NXWidgets::CWidgetStyle *style = (const NXWidgets::CWidgetStyle *)NULL); + + /** + * Destructor. + */ + + ~CWindowControl(void); + }; +} +#endif // __cplusplus + +#endif // __INCLUDE_CWINDOWCONTROL_HXX diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx index ad57ba4b2..f57c04297 100644 --- a/NxWidgets/nxwm/src/capplicationwindow.cxx +++ b/NxWidgets/nxwm/src/capplicationwindow.cxx @@ -313,14 +313,6 @@ bool CApplicationWindow::open(void) m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT); m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER); m_windowLabel->setRaisesEvents(false); - - // Get the window control - - NXWidgets::CWidgetControl *windowControl = m_window->getWidgetControl(); - - // Register to receive callbacks on a few select window events - - windowControl->addWindowEventHandler(this); return true; } @@ -463,76 +455,6 @@ void CApplicationWindow::clickStopIcon(int index) #endif /** - * Handle an NX window mouse input event. - * - * @param e The event data. - */ - -#ifdef CONFIG_NX_MOUSE -void CApplicationWindow::handleMouseEvent(void) -{ - // The logic path here is tortuous but flexible: - // - // 1. A listener thread receives mouse input and injects that into NX - // 2. In the multi-user mode, this will send a message to the NX server - // 3. The NX server will determine which window gets the mouse input - // and send a message to the listener. - // 4. The listener will call the NX message dispatcher will will do the - // message callback. - // 5. The callback goes into an instance of NXWidgets::CCallback that is - // part of the CWidget control. - // 6. That callback will update mouse information then raise the - // mouse event, - // 7. Which will finally call this function -- still running deep on the - // stack in the listener thread. - // 8. This function will then call back into the wiget control to process - // the mouse input. - - // Get the CWidgetControl associated with the window - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - - // And perform a poll - - control->pollEvents(); -} -#endif - -/** - * Handle a NX window keyboard input event. - */ - -#ifdef CONFIG_NX_KBD -void CApplicationWindow::handleKeyboardEvent(void) -{ - // The logic path here is tortuous but flexible: - // - // 1. A listener thread receives keyboard input and injects that into NX - // 2. In the multi-user mode, this will send a message to the NX server - // 3. The NX server will determine which window gets the keyboard input - // and send a message to the listener. - // 4. The listener will call the NX message dispatcher will will do the - // message callback. - // 5. The callback goes into an instance of NXWidgets::CCallback that is - // part of the CWidget control. - // 6. That callback will update keyboard information then raise the - // keyboard event, - // 7. Which will finally call this function -- still running deep on the - // stack in the listener thread. - // 8. This function will then call back into the wiget control to process - // the keyboard input. - - // Get the CWidgetControl associated with the window - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - - // And perform a poll - - control->pollEvents(); -} -#endif - -/** * Handle a mouse button click event. * * @param e The event data. diff --git a/NxWidgets/nxwm/src/cfullscreenwindow.cxx b/NxWidgets/nxwm/src/cfullscreenwindow.cxx index 6b0d13fa0..2087543cd 100644 --- a/NxWidgets/nxwm/src/cfullscreenwindow.cxx +++ b/NxWidgets/nxwm/src/cfullscreenwindow.cxx @@ -96,13 +96,6 @@ CFullScreenWindow::~CFullScreenWindow(void) bool CFullScreenWindow::open(void) { - // Get the window control - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - - // Register to receive callbacks on a few select window events - - control->addWindowEventHandler(this); return true; } @@ -174,74 +167,4 @@ void CFullScreenWindow::clickStopIcon(int index) } #endif -/** - * Handle an NX window mouse input event. - * - * @param e The event data. - */ - -#ifdef CONFIG_NX_MOUSE -void CFullScreenWindow::handleMouseEvent(void) -{ - // The logic path here is tortuous but flexible: - // - // 1. A listener thread receives mouse input and injects that into NX - // 2. In the multi-user mode, this will send a message to the NX server - // 3. The NX server will determine which window gets the mouse input - // and send a message to the listener. - // 4. The listener will call the NX message dispatcher will will do the - // message callback. - // 5. The callback goes into an instance of NXWidgets::CCallback that is - // part of the CWidget control. - // 6. That callback will update mouse information then raise the - // mouse event, - // 7. Which will finally call this function -- still running deep on the - // stack in the listener thread. - // 8. This function will then call back into the wiget control to process - // the mouse input. - - // Get the CWidgetControl associated with the window - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - - // And perform a poll - - control->pollEvents(); -} -#endif - -/** - * Handle a NX window keyboard input event. - */ - -#ifdef CONFIG_NX_KBD -void CFullScreenWindow::handleKeyboardEvent(void) -{ - // The logic path here is tortuous but flexible: - // - // 1. A listener thread receives keyboard input and injects that into NX - // 2. In the multi-user mode, this will send a message to the NX server - // 3. The NX server will determine which window gets the keyboard input - // and send a message to the listener. - // 4. The listener will call the NX message dispatcher will will do the - // message callback. - // 5. The callback goes into an instance of NXWidgets::CCallback that is - // part of the CWidget control. - // 6. That callback will update keyboard information then raise the - // keyboard event, - // 7. Which will finally call this function -- still running deep on the - // stack in the listener thread. - // 8. This function will then call back into the wiget control to process - // the keyboard input. - - // Get the CWidgetControl associated with the window - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - - // And perform a poll - - control->pollEvents(); -} -#endif - diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index 9edb3fff5..a840fdcb2 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -45,6 +45,7 @@ #include "cwidgetcontrol.hxx" #include "cnxtkwindow.hxx" +#include "cwindowcontrol.hxx" #include "ctaskbar.hxx" /******************************************************************************************** @@ -124,10 +125,12 @@ void CTaskbar::disconnect(void) NXWidgets::CWidgetControl *control; if (m_taskbar) { - // Delete the contained widget control. We are responsible for it - // because we created it + // Get the contained widget control control = m_taskbar->getWidgetControl(); + + // Delete the widget control. We are responsible for it because we created it + if (control) { delete control; @@ -226,7 +229,7 @@ bool CTaskbar::startWindowManager(void) { // Have we already been started - if (!m_started) + if (!m_started) { // We are now started @@ -234,10 +237,10 @@ bool CTaskbar::startWindowManager(void) // Draw the taskbar - if (!redrawTaskbarWindow()) - { - return false; - } + if (!redrawTaskbarWindow()) + { + return false; + } // Draw the top application window @@ -562,15 +565,15 @@ NXWidgets::CNxWindow *CTaskbar::openRawWindow(void) { // Initialize the widget control using the default style - NXWidgets::CWidgetControl *widgetControl = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL); + CWindowControl *control = new CWindowControl((NXWidgets::CWidgetStyle *)NULL); // Get an (uninitialized) instance of the background window as a class // that derives from INxWindow. - NXWidgets::CNxWindow *window = createRawWindow(widgetControl); + NXWidgets::CNxWindow *window = createRawWindow(control); if (!window) { - delete widgetControl; + delete control; return false; } @@ -599,15 +602,15 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void) { // Initialize the widget control using the default style - NXWidgets::CWidgetControl *widgetControl = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL); + CWindowControl *control = new CWindowControl((NXWidgets::CWidgetStyle *)NULL); // Get an (uninitialized) instance of the framed window as a class // that derives from INxWindow. - NXWidgets::CNxTkWindow *window = createFramedWindow(widgetControl); + NXWidgets::CNxTkWindow *window = createFramedWindow(control); if (!window) { - delete widgetControl; + delete control; return false; } diff --git a/NxWidgets/nxwm/src/cwindowcontrol.cxx b/NxWidgets/nxwm/src/cwindowcontrol.cxx new file mode 100644 index 000000000..841397a14 --- /dev/null +++ b/NxWidgets/nxwm/src/cwindowcontrol.cxx @@ -0,0 +1,143 @@ +/******************************************************************************************** + * NxWidgets/nxwm/src/cwindowcontrol.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 "cwindowcontrol.hxx" + +/******************************************************************************************** + * Pre-Processor Definitions + ********************************************************************************************/ + +/******************************************************************************************** + * CWindowControl Method Implementations + ********************************************************************************************/ + +using namespace NxWM; + +/** + * Constructor + * + * @param style The default style that all widgets on this display + * should use. If this is not specified, the widget will use the + * values stored in the defaultCWidgetStyle object. + */ + +CWindowControl::CWindowControl(FAR const NXWidgets::CWidgetStyle *style) +: NXWidgets::CWidgetControl(style) +{ + // Add ourself as the window callback + + addWindowEventHandler(this); +} + +/** + * Destructor. + */ + +CWindowControl::~CWindowControl(void) +{ + // Remove ourself from the window callback + + removeWindowEventHandler(this); +} + +/** + * Handle an NX window mouse input event. + * + * @param e The event data. + */ + +#ifdef CONFIG_NX_MOUSE +void CWindowControl::handleMouseEvent(void) +{ + // The logic path here is tortuous but flexible: + // + // 1. A listener thread receives mouse input and injects that into NX + // 2. In the multi-user mode, this will send a message to the NX server + // 3. The NX server will determine which window gets the mouse input + // and send a message to the listener. + // 4. The listener will call the NX message dispatcher will will do the + // message callback. + // 5. The callback goes into an instance of NXWidgets::CCallback that is + // part of the CWidget control. + // 6. That callback will update mouse information then raise the + // mouse event, + // 7. Which will finally call this function -- still running deep on the + // stack in the listener thread. + // 8. This function will then call back into the widget control to process + // the mouse input. + + // Perform the poll + + pollEvents(); +} +#endif + +/** + * Handle a NX window keyboard input event. + */ + +#ifdef CONFIG_NX_KBD +void CWindowControl::handleKeyboardEvent(void) +{ + // The logic path here is tortuous but flexible: + // + // 1. A listener thread receives keyboard input and injects that into NX + // 2. In the multi-user mode, this will send a message to the NX server + // 3. The NX server will determine which window gets the keyboard input + // and send a message to the listener. + // 4. The listener will call the NX message dispatcher will will do the + // message callback. + // 5. The callback goes into an instance of NXWidgets::CCallback that is + // part of the CWidget control. + // 6. That callback will update keyboard information then raise the + // keyboard event, + // 7. Which will finally call this function -- still running deep on the + // stack in the listener thread. + // 8. This function will then call back into the widget control to process + // the keyboard input. + + // Perform the poll + + pollEvents(); +} +#endif + + diff --git a/NxWidgets/nxwm/src/glyph_calibration.cxx b/NxWidgets/nxwm/src/glyph_calibration.cxx index 95df5a7dd..fab2902fe 100644 --- a/NxWidgets/nxwm/src/glyph_calibration.cxx +++ b/NxWidgets/nxwm/src/glyph_calibration.cxx @@ -57,8 +57,8 @@ ********************************************************************************************/ #define BITMAP_NROWS 21 -#define BITMAP_NCOLUMNS 21 -#define BITMAP_NLUTCODES 17 +#define BITMAP_NCOLUMNS 24 +#define BITMAP_NLUTCODES 6 /******************************************************************************************** * Private Bitmap Data @@ -70,23 +70,31 @@ using namespace NxWM; #if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32 -static const uint32_t g_calibrationLut[BITMAP_NLUTCODES] = +static const uint32_t g_calibrationNormalLut[BITMAP_NLUTCODES] = { CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ - 0x202020, 0x404040, 0x808080, 0xfcfcfc, 0x606060, 0x9c9c9c, 0xdcdcdc, /* Codes 1-7 */ - 0xececec, 0xacacac, 0x707070, 0x303030, 0x101010, 0xcccccc, 0x505050, /* Codes 8-15 */ - 0x8c8c8c, 0xbcbcbc, /* Codes 15-16 */ + 0xfcfcfc, 0xacacac, 0xd8d8d8, 0xd8881c, 0x9c6014 /* Codes 1-5 */ }; +static const uint32_t g_calibrationSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ + 0xffffff, 0xc0c0c0, 0xe1e1e1, 0xe1a554, 0xb4874e /* Codes 1-5 */ +}; /* RGB16 (565) Colors (four of the colors in this map are duplicates) */ #elif CONFIG_NXWIDGETS_BPP == 16 -static const uint16_t g_calibrationLut[BITMAP_NLUTCODES] = +static const uint16_t g_calibrationNormalLut[BITMAP_NLUTCODES] = { - CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ - 0x2104, 0x4208, 0x8410, 0xffff, 0x630c, 0x9cf3, 0xdefb, 0xef7d, 0xad75, /* Codes 1-9 */ - 0x738e, 0x3186, 0x1082, 0xce79, 0x528a, 0x8c71, 0xbdf7 /* Codes 10-16 */ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ + 0xffff, 0xad75, 0xdedb, 0xdc43, 0x9b02 /* Codes 1-5 */ +}; + +static const uint16_t g_calibrationSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ + 0xffff, 0xc618, 0xe71c, 0xe52a, 0xb429 /* Codes 1-5 */ }; /* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used @@ -101,22 +109,32 @@ static const uint16_t g_calibrationLut[BITMAP_NLUTCODES] = /* 8-bit Greyscale */ -static const uint8_t g_calibrationLut[BITMAP_NLUTCODES] = +static const uint8_t g_calibrationNormalLut[BITMAP_NLUTCODES] = { CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ - 0x20, 0x40, 0x80, 0xfc, 0x60, 0x9c, 0xdc, 0xec, 0xac, 0x70, 0x30, 0x10, /* Codes 1-12 */ - 0xcc, 0x50, 0x8c, 0xbc, /* Codes 13-16 */ + 0xfc, 0xac, 0xd8, 0x93, 0x69 /* Codes 1-5 */ +}; + +static const uint8_t g_calibrationSelectedLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ + 0xff, 0xc0, 0xe1, 0xad, 0x8d /* Codes 1-5 */ }; # else /* CONFIG_NXWIDGETS_GREYSCALE */ /* RGB8 (332) Colors */ -static const nxgl_mxpixel_t g_calibrationLut[BITMAP_NLUTCODES] = +static const nxgl_mxpixel_t g_calibrationNormalLut[BITMAP_NLUTCODES] = +{ + CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ + 0xff, 0xb6, 0xdb, 0xd0, 0x8c /* Codes 1-5 */ +}; + +static const nxgl_mxpixel_t g_calibrationSelectedLut[BITMAP_NLUTCODES] = { CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */ - 0x24, 0x49, 0x92, 0xff, 0x6d, 0x92, 0xdb, 0xff, 0xb6, 0x6d, 0x24, 0x00, /* Codes 1-12 */ - 0xdb, 0x49, 0x92, 0xb7 /* Codes 13-16 */ + 0xff, 0xdb, 0xff, 0xf5, 0xb1 /* Codes 1-5 */ }; # endif @@ -126,52 +144,39 @@ static const nxgl_mxpixel_t g_calibrationLut[BITMAP_NLUTCODES] = static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[] = { - { 25, 0}, /* Row 0 */ - { 25, 0}, /* Row 1 */ - { 12, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 2 */ - { 12, 0}, { 1, 3}, { 1, 4}, { 6, 0}, { 1, 1}, { 2, 5}, { 2, 0}, /* Row 3 */ - { 12, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 1}, { 1, 5}, { 1, 6}, { 1, 7}, /* Row 4 */ - { 2, 4}, { 1, 7}, { 2, 0}, - { 12, 0}, { 1, 3}, { 1, 4}, { 1, 6}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 5 */ - { 1, 7}, { 1, 9}, { 3, 0}, - { 8, 0}, { 1, 1}, { 1, 5}, { 1, 6}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 6 */ - { 1, 10}, { 1, 11}, { 1, 0}, { 1, 12}, { 2, 13}, { 3, 0}, - { 4, 0}, { 1, 12}, { 1, 14}, { 1, 15}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 7 */ - { 1, 16}, { 1, 4}, { 5, 0}, { 1, 10}, { 1, 5}, { 1, 3}, { 1, 5}, { 2, 0}, - { 3, 0}, { 1, 1}, { 2, 4}, { 1, 8}, { 1, 9}, { 1, 10}, { 1, 11}, { 2, 0}, /* Row 8 */ - { 1, 3}, { 1, 4}, { 5, 0}, { 1, 13}, { 1, 0}, { 1, 1}, { 1, 9}, { 2, 0}, - { 4, 0}, { 1, 15}, { 1, 4}, { 1, 5}, { 5, 0}, { 1, 3}, { 1, 4}, { 4, 0}, /* Row 9 */ - { 1, 14}, { 1, 15}, { 2, 0}, { 1, 16}, { 1, 1}, { 1, 0}, - { 4, 0}, { 1, 5}, { 1, 10}, { 1, 13}, { 5, 0}, { 1, 3}, { 1, 4}, { 4, 0}, /* Row 10 */ - { 1, 9}, { 1, 1}, { 2, 0}, { 1, 5}, { 1, 10}, { 1, 0}, - { 4, 0}, { 1, 13}, { 1, 12}, { 1, 6}, { 1, 1}, { 4, 0}, { 1, 3}, { 1, 4}, /* Row 11 */ - { 3, 0}, { 1, 1}, { 1, 16}, { 1, 0}, { 1, 6}, { 1, 14}, { 1, 12}, { 1, 13}, - { 1, 0}, - { 3, 0}, { 1, 2}, { 1, 6}, { 1, 0}, { 1, 14}, { 1, 15}, { 4, 0}, { 1, 3}, /* Row 12 */ - { 1, 4}, { 3, 0}, { 1, 3}, { 1, 5}, { 1, 1}, { 1, 8}, { 1, 6}, { 1, 0}, - { 1, 6}, { 1, 11}, - { 3, 0}, { 1, 6}, { 1, 11}, { 2, 0}, { 1, 16}, { 4, 0}, { 1, 3}, { 1, 4}, /* Row 13 */ - { 3, 0}, { 1, 16}, { 1, 0}, { 1, 2}, { 1, 4}, { 1, 16}, { 1, 0}, { 1, 2}, - { 1, 6}, - { 2, 0}, { 1, 12}, { 1, 13}, { 1, 12}, { 1, 16}, { 1, 1}, { 1, 15}, { 1, 14}, /* Row 14 */ - { 3, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 10}, { 1, 13}, { 1, 3}, { 1, 6}, - { 1, 4}, { 1, 7}, { 2, 3}, { 1, 8}, - { 2, 0}, { 1, 10}, { 1, 5}, { 1, 9}, { 1, 4}, { 1, 16}, { 1, 2}, { 1, 6}, /* Row 15 */ - { 3, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 11}, { 1, 16}, { 5, 4}, { 1, 8}, - { 1, 15}, - { 2, 0}, { 1, 13}, { 1, 0}, { 3, 4}, { 1, 2}, { 1, 13}, { 1, 12}, { 2, 0}, /* Row 16 */ - { 1, 3}, { 1, 4}, { 4, 0}, { 1, 12}, { 3, 2}, { 1, 11}, { 2, 0}, - { 1, 0}, { 1, 14}, { 1, 15}, { 1, 0}, { 3, 4}, { 1, 2}, { 2, 5}, { 2, 0}, /* Row 17 */ - { 1, 3}, { 1, 4}, { 11, 0}, - { 1, 0}, { 1, 16}, { 1, 13}, { 1, 16}, { 3, 4}, { 2, 13}, { 1, 7}, { 2, 0}, /* Row 18 */ - { 1, 3}, { 1, 4}, { 11, 0}, - { 1, 0}, { 1, 1}, { 1, 6}, { 1, 7}, { 3, 4}, { 1, 7}, { 1, 6}, { 1, 11}, /* Row 19 */ - { 2, 0}, { 1, 3}, { 1, 4}, { 11, 0}, - { 12, 0}, { 1, 3}, { 1, 4}, { 11, 0}, /* Row 20 */ - { 5, 0}, { 1, 2}, { 14, 4}, { 1, 3}, { 4, 0}, /* Row 21 */ - { 5, 0}, { 1, 2}, { 14, 4}, { 1, 3}, { 4, 0}, /* Row 22 */ - { 25, 0}, /* Row 23 */ - { 25, 0}, /* Row 24 */ + { 11, 0}, { 1, 1}, { 1, 2}, { 6, 0}, { 1, 3}, { 1, 2}, { 3, 0}, /* Row 0 */ + { 11, 0}, { 1, 1}, { 1, 2}, { 4, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 0}, /* Row 1 */ + { 11, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 3}, { 1, 2}, /* Row 2 */ + { 3, 0}, + { 11, 0}, { 1, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 3}, { 4, 0}, /* Row 3 */ + { 9, 0}, { 2, 1}, { 2, 3}, { 2, 2}, { 4, 0}, { 1, 3}, { 4, 0}, /* Row 4 */ + { 3, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 1}, { 1, 2}, /* Row 5 */ + { 5, 0}, { 1, 1}, { 2, 3}, { 3, 0}, + { 2, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 1}, { 1, 2}, /* Row 6 */ + { 4, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 2, 0}, + { 3, 0}, { 1, 2}, { 1, 3}, { 2, 2}, { 4, 0}, { 1, 1}, { 1, 2}, { 4, 0}, /* Row 7 */ + { 1, 1}, { 3, 0}, { 1, 3}, { 2, 0}, + { 4, 0}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, { 1, 3}, /* Row 8 */ + { 3, 0}, { 2, 3}, { 1, 0}, + { 3, 0}, { 1, 1}, { 2, 3}, { 5, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, /* Row 9 */ + { 5, 0}, { 1, 3}, { 1, 0}, + { 2, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 4, 0}, { 1, 1}, { 1, 2}, /* Row 10 */ + { 3, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0}, + { 2, 0}, { 1, 1}, { 3, 0}, { 1, 3}, { 4, 0}, { 1, 1}, { 1, 2}, { 3, 0}, /* Row 11 */ + { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0}, + { 1, 0}, { 1, 1}, { 1, 3}, { 2, 4}, { 1, 5}, { 2, 3}, { 3, 0}, { 1, 1}, /* Row 12 */ + { 1, 2}, { 2, 0}, { 9, 3}, + { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 13 */ + { 1, 1}, { 1, 2}, { 11, 0}, + { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 14 */ + { 1, 1}, { 1, 2}, { 11, 0}, + { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 15 */ + { 1, 1}, { 1, 2}, { 11, 0}, + { 9, 3}, { 2, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 16 */ + { 11, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 17 */ + { 10, 0}, { 1, 1}, { 2, 3}, { 1, 2}, { 10, 0}, /* Row 18 */ + { 5, 0}, { 4, 1}, { 6, 3}, { 4, 2}, { 5, 0}, /* Row 19 */ + { 4, 0}, { 4, 1}, { 8, 3}, { 4, 2}, { 4, 0}, /* Row 20 */ }; /******************************************************************************************** @@ -180,14 +185,14 @@ static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[] const struct NXWidgets::SRlePaletteBitmap NxWM::g_calibrationBitmap = { - CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel - CONFIG_NXWIDGETS_FMT, // fmt - Color format - BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT) - BITMAP_NCOLUMNS, // width - Width in pixels - BITMAP_NROWS, // height - Height in rows - { // lut - Pointer to the beginning of the Look-Up Table (LUT) - g_calibrationLut, // Index 0: Unselected LUT - g_calibrationLut, // Index 1: Selected LUT + CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel + CONFIG_NXWIDGETS_FMT, // fmt - Color format + BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT) + BITMAP_NCOLUMNS, // width - Width in pixels + BITMAP_NROWS, // height - Height in rows + { // lut - Pointer to the beginning of the Look-Up Table (LUT) + g_calibrationNormalLut, // Index 0: Unselected LUT + g_calibrationSelectedLut, // Index 1: Selected LUT }, - g_calibrationRleEntries // data - Pointer to the beginning of the RLE data + g_calibrationRleEntries // data - Pointer to the beginning of the RLE data }; |