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
This commit is contained in:
patacongo 2012-05-12 13:50:21 +00:00
parent 5e475e79d5
commit 6e07395780
15 changed files with 403 additions and 310 deletions

View File

@ -58,5 +58,7 @@
* NxWM::CCalibration: Beef up touch input handling logic. Now changes the * NxWM::CCalibration: Beef up touch input handling logic. Now changes the
color of the touch circle to yellow when it is touched. color of the touch circle to yellow when it is touched.
* NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer. * 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.

View File

@ -403,13 +403,9 @@ static bool createTouchScreen(void)
#ifdef CONFIG_NXWM_TOUCHSCREEN #ifdef CONFIG_NXWM_TOUCHSCREEN
static bool createCalibration(void) 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 // 2. Instantiate the application, providing the window to the application's
// constructor, // 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"); printf(MAIN_STRING "Opening the calibration application window\n");
NxWM::CFullScreenWindow *window = g_nxwmtest.taskbar->openFullScreenWindow(); NxWM::CFullScreenWindow *window = g_nxwmtest.taskbar->openFullScreenWindow();
@ -438,16 +434,6 @@ static bool createCalibration(void)
return false; return false;
} }
showTestCaseMemory("After creating CCalibration application"); 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; return true;
} }
#endif #endif
@ -502,6 +488,26 @@ static bool runCalibration(void)
} }
#endif #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 // Name: createNxConsole
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -605,14 +611,6 @@ int MAIN_NAME(int argc, char *argv[])
testCleanUpAndExit(EXIT_FAILURE); 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 // Create the touchscreen device
#ifdef CONFIG_NXWM_TOUCHSCREEN #ifdef CONFIG_NXWM_TOUCHSCREEN
@ -645,6 +643,27 @@ int MAIN_NAME(int argc, char *argv[])
} }
#endif #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 // Add the NxConsole application to the start window
if (!createNxConsole()) if (!createNxConsole())

View File

@ -44,6 +44,7 @@ CSRCS =
# Window Manager # Window Manager
CXXSRCS = capplicationwindow.cxx ccalibration.cxx cfullscreenwindow.cxx CXXSRCS = capplicationwindow.cxx ccalibration.cxx cfullscreenwindow.cxx
CXXSRCS += cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx ctouchscreen.cxx CXXSRCS += cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx ctouchscreen.cxx
CXXSRCS += cwindowcontrol.cxx
# Images # Images
CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx
CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 415 B

View File

@ -49,7 +49,6 @@
#include "cimage.hxx" #include "cimage.hxx"
#include "clabel.hxx" #include "clabel.hxx"
#include "crlepalettebitmap.hxx" #include "crlepalettebitmap.hxx"
#include "cwindoweventhandler.hxx"
#include "iapplicationwindow.hxx" #include "iapplicationwindow.hxx"
@ -72,8 +71,7 @@ namespace NxWM
*/ */
class CApplicationWindow : public IApplicationWindow, class CApplicationWindow : public IApplicationWindow,
private NXWidgets::CWidgetEventHandler, private NXWidgets::CWidgetEventHandler
private NXWidgets::CWindowEventHandler
{ {
protected: protected:
NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */ NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
@ -86,24 +84,6 @@ namespace NxWM
NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */ NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
IApplicationCallback *m_callback; /**< Toolbar action callbacks */ 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. * Handle a mouse button click event.
* *

View File

@ -63,30 +63,11 @@ namespace NxWM
* for example, to support full screen displays. * for example, to support full screen displays.
*/ */
class CFullScreenWindow : public IApplicationWindow, class CFullScreenWindow : public IApplicationWindow
private NXWidgets::CWindowEventHandler
{ {
protected: protected:
NXWidgets::CNxWindow *m_window; /**< The generic window used by the application */ 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: public:
/** /**

View File

@ -61,7 +61,8 @@ namespace NxWM
{ {
class CTaskbar; class CTaskbar;
class CStartWindow : public IApplication, private IApplicationCallback, class CStartWindow : public IApplication,
private IApplicationCallback,
private NXWidgets::CWidgetEventHandler private NXWidgets::CWidgetEventHandler
{ {
protected: protected:

View File

@ -82,7 +82,8 @@ namespace NxWM
* (and I may still do that someday) * (and I may still do that someday)
*/ */
class CTaskbar : public NXWidgets::CNxServer, private NXWidgets::CWidgetEventHandler class CTaskbar : public NXWidgets::CNxServer,
private NXWidgets::CWidgetEventHandler
{ {
private: private:
/** /**
@ -109,12 +110,12 @@ namespace NxWM
/** /**
* Create a raw window. * Create a raw window.
* *
* 1) Create a dumb CWigetControl instance * 1) Create a dumb CWindowControl instance
* 2) Pass the dumb CWidgetControl instance to the window constructor * 2) Pass the dumb CWindowControl instance to the window constructor
* that inherits from INxWindow. This will "smarten" the CWidgetControl * that inherits from INxWindow. This will "smarten" the CWindowControl
* instance with some window knowlede * instance with some window knowlede
* 3) Call the open() method on the window to display the window. * 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 * be used to generate additional widgets by passing it to the
* widget constructor * widget constructor
*/ */

View File

@ -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

View File

@ -313,14 +313,6 @@ bool CApplicationWindow::open(void)
m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT); m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT);
m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER); m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER);
m_windowLabel->setRaisesEvents(false); 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; return true;
} }
@ -462,76 +454,6 @@ void CApplicationWindow::clickStopIcon(int index)
} }
#endif #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. * Handle a mouse button click event.
* *

View File

@ -96,13 +96,6 @@ CFullScreenWindow::~CFullScreenWindow(void)
bool CFullScreenWindow::open(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; return true;
} }
@ -174,74 +167,4 @@ void CFullScreenWindow::clickStopIcon(int index)
} }
#endif #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

View File

@ -45,6 +45,7 @@
#include "cwidgetcontrol.hxx" #include "cwidgetcontrol.hxx"
#include "cnxtkwindow.hxx" #include "cnxtkwindow.hxx"
#include "cwindowcontrol.hxx"
#include "ctaskbar.hxx" #include "ctaskbar.hxx"
/******************************************************************************************** /********************************************************************************************
@ -124,10 +125,12 @@ void CTaskbar::disconnect(void)
NXWidgets::CWidgetControl *control; NXWidgets::CWidgetControl *control;
if (m_taskbar) if (m_taskbar)
{ {
// Delete the contained widget control. We are responsible for it // Get the contained widget control
// because we created it
control = m_taskbar->getWidgetControl(); control = m_taskbar->getWidgetControl();
// Delete the widget control. We are responsible for it because we created it
if (control) if (control)
{ {
delete control; delete control;
@ -562,15 +565,15 @@ NXWidgets::CNxWindow *CTaskbar::openRawWindow(void)
{ {
// Initialize the widget control using the default style // 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 // Get an (uninitialized) instance of the background window as a class
// that derives from INxWindow. // that derives from INxWindow.
NXWidgets::CNxWindow *window = createRawWindow(widgetControl); NXWidgets::CNxWindow *window = createRawWindow(control);
if (!window) if (!window)
{ {
delete widgetControl; delete control;
return false; return false;
} }
@ -599,15 +602,15 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
{ {
// Initialize the widget control using the default style // 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 // Get an (uninitialized) instance of the framed window as a class
// that derives from INxWindow. // that derives from INxWindow.
NXWidgets::CNxTkWindow *window = createFramedWindow(widgetControl); NXWidgets::CNxTkWindow *window = createFramedWindow(control);
if (!window) if (!window)
{ {
delete widgetControl; delete control;
return false; return false;
} }

143
nxwm/src/cwindowcontrol.cxx Normal file
View File

@ -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

View File

@ -57,8 +57,8 @@
********************************************************************************************/ ********************************************************************************************/
#define BITMAP_NROWS 21 #define BITMAP_NROWS 21
#define BITMAP_NCOLUMNS 21 #define BITMAP_NCOLUMNS 24
#define BITMAP_NLUTCODES 17 #define BITMAP_NLUTCODES 6
/******************************************************************************************** /********************************************************************************************
* Private Bitmap Data * Private Bitmap Data
@ -70,23 +70,31 @@ using namespace NxWM;
#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32 #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 */ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
0x202020, 0x404040, 0x808080, 0xfcfcfc, 0x606060, 0x9c9c9c, 0xdcdcdc, /* Codes 1-7 */ 0xfcfcfc, 0xacacac, 0xd8d8d8, 0xd8881c, 0x9c6014 /* Codes 1-5 */
0xececec, 0xacacac, 0x707070, 0x303030, 0x101010, 0xcccccc, 0x505050, /* Codes 8-15 */
0x8c8c8c, 0xbcbcbc, /* Codes 15-16 */
}; };
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) */ /* RGB16 (565) Colors (four of the colors in this map are duplicates) */
#elif CONFIG_NXWIDGETS_BPP == 16 #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 */ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
0x2104, 0x4208, 0x8410, 0xffff, 0x630c, 0x9cf3, 0xdefb, 0xef7d, 0xad75, /* Codes 1-9 */ 0xffff, 0xad75, 0xdedb, 0xdc43, 0x9b02 /* Codes 1-5 */
0x738e, 0x3186, 0x1082, 0xce79, 0x528a, 0x8c71, 0xbdf7 /* Codes 10-16 */ };
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 /* 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 */ /* 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 */ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
0x20, 0x40, 0x80, 0xfc, 0x60, 0x9c, 0xdc, 0xec, 0xac, 0x70, 0x30, 0x10, /* Codes 1-12 */ 0xfc, 0xac, 0xd8, 0x93, 0x69 /* Codes 1-5 */
0xcc, 0x50, 0x8c, 0xbc, /* Codes 13-16 */ };
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 */ # else /* CONFIG_NXWIDGETS_GREYSCALE */
/* RGB8 (332) Colors */ /* 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 */ CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
0x24, 0x49, 0x92, 0xff, 0x6d, 0x92, 0xdb, 0xff, 0xb6, 0x6d, 0x24, 0x00, /* Codes 1-12 */ 0xff, 0xb6, 0xdb, 0xd0, 0x8c /* Codes 1-5 */
0xdb, 0x49, 0x92, 0xb7 /* Codes 13-16 */ };
static const nxgl_mxpixel_t g_calibrationSelectedLut[BITMAP_NLUTCODES] =
{
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
0xff, 0xdb, 0xff, 0xf5, 0xb1 /* Codes 1-5 */
}; };
# endif # endif
@ -126,52 +144,39 @@ static const nxgl_mxpixel_t g_calibrationLut[BITMAP_NLUTCODES] =
static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[] = static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[] =
{ {
{ 25, 0}, /* Row 0 */ { 11, 0}, { 1, 1}, { 1, 2}, { 6, 0}, { 1, 3}, { 1, 2}, { 3, 0}, /* Row 0 */
{ 25, 0}, /* Row 1 */ { 11, 0}, { 1, 1}, { 1, 2}, { 4, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 0}, /* Row 1 */
{ 12, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 2 */ { 11, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 3}, { 1, 2}, /* Row 2 */
{ 12, 0}, { 1, 3}, { 1, 4}, { 6, 0}, { 1, 1}, { 2, 5}, { 2, 0}, /* Row 3 */ { 3, 0},
{ 12, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 1}, { 1, 5}, { 1, 6}, { 1, 7}, /* Row 4 */ { 11, 0}, { 1, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 3}, { 4, 0}, /* Row 3 */
{ 2, 4}, { 1, 7}, { 2, 0}, { 9, 0}, { 2, 1}, { 2, 3}, { 2, 2}, { 4, 0}, { 1, 3}, { 4, 0}, /* Row 4 */
{ 12, 0}, { 1, 3}, { 1, 4}, { 1, 6}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 5 */ { 3, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 1}, { 1, 2}, /* Row 5 */
{ 1, 7}, { 1, 9}, { 3, 0}, { 5, 0}, { 1, 1}, { 2, 3}, { 3, 0},
{ 8, 0}, { 1, 1}, { 1, 5}, { 1, 6}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 6 */ { 2, 0}, { 2, 1}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 1}, { 1, 2}, /* Row 6 */
{ 1, 10}, { 1, 11}, { 1, 0}, { 1, 12}, { 2, 13}, { 3, 0}, { 4, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 2, 0},
{ 4, 0}, { 1, 12}, { 1, 14}, { 1, 15}, { 1, 7}, { 2, 4}, { 1, 8}, { 1, 9}, /* Row 7 */ { 3, 0}, { 1, 2}, { 1, 3}, { 2, 2}, { 4, 0}, { 1, 1}, { 1, 2}, { 4, 0}, /* Row 7 */
{ 1, 16}, { 1, 4}, { 5, 0}, { 1, 10}, { 1, 5}, { 1, 3}, { 1, 5}, { 2, 0}, { 1, 1}, { 3, 0}, { 1, 3}, { 2, 0},
{ 3, 0}, { 1, 1}, { 2, 4}, { 1, 8}, { 1, 9}, { 1, 10}, { 1, 11}, { 2, 0}, /* Row 8 */ { 4, 0}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, { 1, 3}, /* Row 8 */
{ 1, 3}, { 1, 4}, { 5, 0}, { 1, 13}, { 1, 0}, { 1, 1}, { 1, 9}, { 2, 0}, { 3, 0}, { 2, 3}, { 1, 0},
{ 4, 0}, { 1, 15}, { 1, 4}, { 1, 5}, { 5, 0}, { 1, 3}, { 1, 4}, { 4, 0}, /* Row 9 */ { 3, 0}, { 1, 1}, { 2, 3}, { 5, 0}, { 1, 1}, { 1, 2}, { 3, 0}, { 1, 1}, /* Row 9 */
{ 1, 14}, { 1, 15}, { 2, 0}, { 1, 16}, { 1, 1}, { 1, 0}, { 5, 0}, { 1, 3}, { 1, 0},
{ 4, 0}, { 1, 5}, { 1, 10}, { 1, 13}, { 5, 0}, { 1, 3}, { 1, 4}, { 4, 0}, /* Row 10 */ { 2, 0}, { 1, 1}, { 1, 3}, { 1, 0}, { 2, 3}, { 4, 0}, { 1, 1}, { 1, 2}, /* Row 10 */
{ 1, 9}, { 1, 1}, { 2, 0}, { 1, 5}, { 1, 10}, { 1, 0}, { 3, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0},
{ 4, 0}, { 1, 13}, { 1, 12}, { 1, 6}, { 1, 1}, { 4, 0}, { 1, 3}, { 1, 4}, /* Row 11 */ { 2, 0}, { 1, 1}, { 3, 0}, { 1, 3}, { 4, 0}, { 1, 1}, { 1, 2}, { 3, 0}, /* Row 11 */
{ 3, 0}, { 1, 1}, { 1, 16}, { 1, 0}, { 1, 6}, { 1, 14}, { 1, 12}, { 1, 13}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 1, 0},
{ 1, 0}, { 1, 0}, { 1, 1}, { 1, 3}, { 2, 4}, { 1, 5}, { 2, 3}, { 3, 0}, { 1, 1}, /* Row 12 */
{ 3, 0}, { 1, 2}, { 1, 6}, { 1, 0}, { 1, 14}, { 1, 15}, { 4, 0}, { 1, 3}, /* Row 12 */ { 1, 2}, { 2, 0}, { 9, 3},
{ 1, 4}, { 3, 0}, { 1, 3}, { 1, 5}, { 1, 1}, { 1, 8}, { 1, 6}, { 1, 0}, { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 13 */
{ 1, 6}, { 1, 11}, { 1, 1}, { 1, 2}, { 11, 0},
{ 3, 0}, { 1, 6}, { 1, 11}, { 2, 0}, { 1, 16}, { 4, 0}, { 1, 3}, { 1, 4}, /* Row 13 */ { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 14 */
{ 3, 0}, { 1, 16}, { 1, 0}, { 1, 2}, { 1, 4}, { 1, 16}, { 1, 0}, { 1, 2}, { 1, 1}, { 1, 2}, { 11, 0},
{ 1, 6}, { 1, 0}, { 1, 1}, { 1, 0}, { 2, 4}, { 1, 5}, { 1, 0}, { 1, 3}, { 3, 0}, /* Row 15 */
{ 2, 0}, { 1, 12}, { 1, 13}, { 1, 12}, { 1, 16}, { 1, 1}, { 1, 15}, { 1, 14}, /* Row 14 */ { 1, 1}, { 1, 2}, { 11, 0},
{ 3, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 10}, { 1, 13}, { 1, 3}, { 1, 6}, { 9, 3}, { 2, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 16 */
{ 1, 4}, { 1, 7}, { 2, 3}, { 1, 8}, { 11, 0}, { 1, 1}, { 1, 2}, { 11, 0}, /* Row 17 */
{ 2, 0}, { 1, 10}, { 1, 5}, { 1, 9}, { 1, 4}, { 1, 16}, { 1, 2}, { 1, 6}, /* Row 15 */ { 10, 0}, { 1, 1}, { 2, 3}, { 1, 2}, { 10, 0}, /* Row 18 */
{ 3, 0}, { 1, 3}, { 1, 4}, { 2, 0}, { 1, 11}, { 1, 16}, { 5, 4}, { 1, 8}, { 5, 0}, { 4, 1}, { 6, 3}, { 4, 2}, { 5, 0}, /* Row 19 */
{ 1, 15}, { 4, 0}, { 4, 1}, { 8, 3}, { 4, 2}, { 4, 0}, /* Row 20 */
{ 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 */
}; };
/******************************************************************************************** /********************************************************************************************
@ -186,8 +191,8 @@ const struct NXWidgets::SRlePaletteBitmap NxWM::g_calibrationBitmap =
BITMAP_NCOLUMNS, // width - Width in pixels BITMAP_NCOLUMNS, // width - Width in pixels
BITMAP_NROWS, // height - Height in rows BITMAP_NROWS, // height - Height in rows
{ // lut - Pointer to the beginning of the Look-Up Table (LUT) { // lut - Pointer to the beginning of the Look-Up Table (LUT)
g_calibrationLut, // Index 0: Unselected LUT g_calibrationNormalLut, // Index 0: Unselected LUT
g_calibrationLut, // Index 1: Selected 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
}; };