From ba5e400fb344ef2f1b01e38435f348ed33052244 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 19 May 2012 04:20:56 +0000 Subject: [PATCH] NxWM unit test now appears bug free (other than some NxConsole-related issues). git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4750 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt | Bin 126464 -> 126464 bytes NxWidgets/nxwm/include/ccalibration.hxx | 2 -- NxWidgets/nxwm/include/cnxconsole.hxx | 2 -- NxWidgets/nxwm/include/cstartwindow.hxx | 2 -- NxWidgets/nxwm/include/ctaskbar.hxx | 9 +++++++-- NxWidgets/nxwm/include/cwindowmessenger.hxx | 16 +++++++++++++--- NxWidgets/nxwm/src/capplicationwindow.cxx | 7 ++++--- NxWidgets/nxwm/src/ccalibration.cxx | 10 ---------- NxWidgets/nxwm/src/cnxconsole.cxx | 14 ++------------ NxWidgets/nxwm/src/cstartwindow.cxx | 10 ---------- NxWidgets/nxwm/src/ctaskbar.cxx | 16 +++++++++++----- NxWidgets/nxwm/src/ctouchscreen.cxx | 2 +- NxWidgets/nxwm/src/cwindowmessenger.cxx | 19 ++++++++++++++++--- 13 files changed, 54 insertions(+), 55 deletions(-) diff --git a/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt b/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt index b532eaa659e45903c928aa6d20d60f0e62a4842c..acae788c2d15f44d8e880f13edb894af282722c6 100644 GIT binary patch delta 1109 zcmY+BZA_b06vxkf?$bW^d3syQplgQ>Qo!(1#tPU?8K8cUFgIu>A-aJ@aDLFatpnY} zLBiI}FC&h6bS3JPWK$M}NVy6+JKWqHiGleNAflZ!(->k@z%bnAOU+aGpdW6|x&QOa zx#xdwXH4mgDTCdNOo|Yzmu;5-fCB&l00jUf07w(WJZ6^L?UyJ%T97KfPveBP+g}iK zx4j|J1!Il~r8f~;Y0be8cuh9?Fbvi#S<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+#=99?vy({g1C0; z>k_-}@QGN?BgpP|`zV%^DfHY*WL=(>W=~!P-tBVR3x8wk%Hk*hKq?sWRH}_q@{3e} zTu_tt+_X!zd6o={Yj8RhpRTK(%=%hc$hEqM17uZbi_)U5$5R})XeUoL|qALL( z1p_7p@`G}T>c?gBSpG%I$T#Wex}fYz|DRk{@Dm+eXOgQh$V${q>&Z7F_Gn=V^1J3)iR9;u;>+}VC{sW|4~n_PJ~HRD2=hpX`j;Z<_OPn{F{-U*(VBiPa2p-|FrgCKXr%Ww`~Q0fPG59dtBJ~kAFAqO zS`r_XFKN{KgqMb@SBtHOPcoj+4oMwKh{|VvrKMOid&p=Pq5ck;)+cuHcU6~~t~OAK z)uTS6Kc}{6bt(NvyyBu|BA?aUwd2k?fdku8c$x7n9y4l0?a+2jD$vAh?@uw?9)HQU zXZ%bbjCMLL?Qaar9z7MD$!Wq(>9phQwD5{-#tnU+)T|t$@|hn+PQ1n7f4Vj(8IozZ1&xT!66oSn1d7fCrvNR-diAbZ%@FDOx;$(!{SX^Rn|-{3QRD__Q%w z;REP;93ZeCVC)ru4W|J5t^%|t0h+D@RLlbuT3^fPK{GyUgXLE6z?cI!Z<7YVy0-?` uT3CT=Eq4W)@i%L*-)GfVVR0;6YrU}-bFAE_aeI7q2Ywg91MwSIkmG-7{z&8i diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx index e9b5d400f3..a54a35bf70 100644 --- a/NxWidgets/nxwm/include/ccalibration.hxx +++ b/NxWidgets/nxwm/include/ccalibration.hxx @@ -52,7 +52,6 @@ #include "ctaskbar.hxx" #include "iapplication.hxx" #include "cfullscreenwindow.hxx" -#include "cwindowmessenger.hxx" /**************************************************************************** * Pre-processor Definitions @@ -144,7 +143,6 @@ namespace NxWM * CCalibration state data */ - CWindowMessenger m_messenger; /**< Window event handler/messenger */ CTaskbar *m_taskbar; /**< The taskbar (used to terminate calibration) */ CFullScreenWindow *m_window; /**< The window for the calibration display */ CTouchscreen *m_touchscreen; /**< The touchscreen device */ diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx index bf3606f053..c04caeff9a 100644 --- a/NxWidgets/nxwm/include/cnxconsole.hxx +++ b/NxWidgets/nxwm/include/cnxconsole.hxx @@ -49,7 +49,6 @@ #include "iapplication.hxx" #include "capplicationwindow.hxx" #include "ctaskbar.hxx" -#include "cwindowmessenger.hxx" /**************************************************************************** * Pre-Processor Definitions @@ -79,7 +78,6 @@ namespace NxWM class CNxConsole : public IApplication, private IApplicationCallback { private: - CWindowMessenger m_messenger; /**< Window event handler/messenger */ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */ CApplicationWindow *m_window; /**< Reference to the application window */ NXCONSOLE m_nxcon; /**< NxConsole handle */ diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx index 3a5325cb75..c7a812abf1 100644 --- a/NxWidgets/nxwm/include/cstartwindow.hxx +++ b/NxWidgets/nxwm/include/cstartwindow.hxx @@ -48,7 +48,6 @@ #include "iapplication.hxx" #include "capplicationwindow.hxx" -#include "cwindowmessenger.hxx" /**************************************************************************** * Pre-Processor Definitions @@ -116,7 +115,6 @@ namespace NxWM * CStartWindow state data */ - CWindowMessenger m_messenger; /**< Window event handler/messenger */ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */ CApplicationWindow *m_window; /**< Reference to the application window */ TNxArray m_slots; /**< List of apps in the start window */ diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx index a78fb17394..c8468877a5 100644 --- a/NxWidgets/nxwm/include/ctaskbar.hxx +++ b/NxWidgets/nxwm/include/ctaskbar.hxx @@ -110,14 +110,19 @@ namespace NxWM /** * Create a raw window. * - * 1) Create a dumb NXWidgets::CWidgetControl instance - * 2) Pass the dumb NXWidgets::CWidgetControl instance to the window constructor + * 1) Create a dumb NXWidgets::CWidgetControl instance (See not). + * 2) Pass the dumb NXWidgets::CWindowMessenger instance to the window constructor * that inherits from INxWindow. This will "smarten" the NXWidgets::CWidgetControl * instance with some window knowlede * 3) Call the open() method on the window to display the window. * 4) After that, the fully smartened NXWidgets::CWidgetControl instance can * be used to generate additional widgets by passing it to the * widget constructor + * + * NOTE: Actually, NxWM uses the CWindowMessenger class that inherits from + * CWidgetControl. That class just adds some unrelated messenging capability; + * It cohabitates with CWidgetControl only becuase it nees the CWidgetControl + * this point. */ NXWidgets::CNxWindow *openRawWindow(void); diff --git a/NxWidgets/nxwm/include/cwindowmessenger.hxx b/NxWidgets/nxwm/include/cwindowmessenger.hxx index 0aa8961bb8..d2e862a7c7 100644 --- a/NxWidgets/nxwm/include/cwindowmessenger.hxx +++ b/NxWidgets/nxwm/include/cwindowmessenger.hxx @@ -49,6 +49,7 @@ #include #include "cwindoweventhandler.hxx" +#include "cwidgetstyle.hxx" #include "cwidgetcontrol.hxx" /**************************************************************************** @@ -71,10 +72,15 @@ namespace NxWM /** * The class CWindowMessenger integrates the widget control with some special - * handling of mouse and keyboard inputs neesed by NxWM + * handling of mouse and keyboard inputs neesed by NxWM. It use used + * in place of CWidgetControl whenever an NxWM window is created. + * + * CWindowMessenger cohabitates with CWidgetControl only becuase it nees the + * CWidgetControl as an argument in its messenging. */ - class CWindowMessenger : public NXWidgets::CWindowEventHandler + class CWindowMessenger : public NXWidgets::CWindowEventHandler, + public NXWidgets::CWidgetControl { private: mqd_t m_mqd; /**< Message queue descriptor used to commincate with the @@ -110,9 +116,13 @@ namespace NxWM /** * CWindowMessenger 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. */ - CWindowMessenger(void); + CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style = (const NXWidgets::CWidgetStyle *)NULL); /** * CWindowMessenger Destructor. diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx index 5cf172ea62..65de1b1a4c 100644 --- a/NxWidgets/nxwm/src/capplicationwindow.cxx +++ b/NxWidgets/nxwm/src/capplicationwindow.cxx @@ -47,6 +47,7 @@ #include "nxwmconfig.hxx" #include "nxwmglyphs.hxx" +#include "cwindowmessenger.hxx" #include "capplicationwindow.hxx" /******************************************************************************************** @@ -152,15 +153,15 @@ CApplicationWindow::~CApplicationWindow(void) bool CApplicationWindow::open(void) { - // Create a widget control for the tool bar + // Create the widget control (with the window messenger) using the default style - NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl(); + CWindowMessenger *control = new CWindowMessenger(); if (!control) { return false; } - // Open the toolbar + // Open the toolbar using the widget control m_toolbar = m_window->openToolbar(CONFIG_NXWM_TOOLBAR_HEIGHT, control); if (!m_toolbar) diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx index 6f5976100b..8ba8d01736 100644 --- a/NxWidgets/nxwm/src/ccalibration.cxx +++ b/NxWidgets/nxwm/src/ccalibration.cxx @@ -99,11 +99,6 @@ CCalibration::CCalibration(CTaskbar *taskbar, CFullScreenWindow *window, m_calthread = CALTHREAD_NOTRUNNING; m_calphase = CALPHASE_NOT_STARTED; m_touched = false; - - // Add our messenger as the window callback - - NXWidgets::CWidgetControl *control = window->getWidgetControl(); - control->addWindowEventHandler(&m_messenger); } /** @@ -117,11 +112,6 @@ CCalibration::~CCalibration(void) stop(); - // Remove ourself from the window callback - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - control->removeWindowEventHandler(&m_messenger); - // Although we did not create the window, the rule is that I have to dispose // of it diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx index 6a64afc1be..30105910b0 100644 --- a/NxWidgets/nxwm/src/cnxconsole.cxx +++ b/NxWidgets/nxwm/src/cnxconsole.cxx @@ -132,11 +132,6 @@ CNxConsole::CNxConsole(CTaskbar *taskbar, CApplicationWindow *window) // Add our callbacks with the application window window->registerCallbacks(static_cast(this)); - - // Add our messenger as the window callback - - NXWidgets::CWidgetControl *control = window->getWidgetControl(); - control->addWindowEventHandler(&m_messenger); } /** @@ -152,11 +147,6 @@ CNxConsole::~CNxConsole(void) stop(); - // Remove ourself from the window callback - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - control->removeWindowEventHandler(&m_messenger); - // Although we didn't create it, we are responsible for deleting the // application window @@ -303,7 +293,7 @@ void CNxConsole::stop(void) // Delete the NxConsole task if it is still running (this could strand // resources). If we get here due to CTaskbar::stopApplication() processing // initialed by CNxConsole::exitHandler, then do *not* delete the task (it - // is already being delete). + // is already being deleted). if (m_pid >= 0) { @@ -320,7 +310,7 @@ void CNxConsole::stop(void) } // Destroy the NX console device - + if (m_nxcon) { nxcon_unregister(m_nxcon); diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx index af46e7b826..5c54cba3ac 100644 --- a/NxWidgets/nxwm/src/cstartwindow.cxx +++ b/NxWidgets/nxwm/src/cstartwindow.cxx @@ -99,11 +99,6 @@ CStartWindow::CStartWindow(CTaskbar *taskbar, CApplicationWindow *window) // Add our callbacks to the application window window->registerCallbacks(static_cast(this)); - - // Add our messenger as the window callback - - NXWidgets::CWidgetControl *control = window->getWidgetControl(); - control->addWindowEventHandler(&m_messenger); } /** @@ -117,11 +112,6 @@ CStartWindow::~CStartWindow(void) stop(); - // Remove ourself from the window callback - - NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); - control->removeWindowEventHandler(&m_messenger); - // Although we didn't create it, we are responsible for deleting the // application window diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index b4df0bb862..6b05100175 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -47,6 +47,7 @@ #include "cwidgetcontrol.hxx" #include "cnxtkwindow.hxx" +#include "cwindowmessenger.hxx" #include "ctaskbar.hxx" /******************************************************************************************** @@ -748,7 +749,7 @@ void CTaskbar::clickIcon(int index, bool click) /** * Create a raw window. * - * 1) Create a dumb CWigetControl instance + * 1) Create a dumb CWigetControl instance (see note below) * 2) Pass the dumb CWidgetControl instance to the window constructor * that inherits from INxWindow. This will "smarten" the CWidgetControl * instance with some window knowlede @@ -756,13 +757,18 @@ void CTaskbar::clickIcon(int index, bool click) * 4) After that, the fully smartened CWidgetControl instance can * be used to generate additional widgets by passing it to the * widget constructor + * + * NOTE: Actually, NxWM uses the CWindowMessenger class that inherits from + * CWidgetControl. That class just adds some unrelated messenging capability; + * It cohabitates with CWidgetControl only becuase it nees the CWidgetControl + * this point. */ NXWidgets::CNxWindow *CTaskbar::openRawWindow(void) { - // Initialize the widget control using the default style + // Create the widget control (with the window messenger) using the default style - NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL); + CWindowMessenger *control = new CWindowMessenger((NXWidgets::CWidgetStyle *)NULL); // Get an (uninitialized) instance of the background window as a class // that derives from INxWindow. @@ -797,9 +803,9 @@ NXWidgets::CNxWindow *CTaskbar::openRawWindow(void) NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void) { - // Initialize the widget control using the default style + // Create the widget control (with the window messenger) using the default style - NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL); + CWindowMessenger *control = new CWindowMessenger((NXWidgets::CWidgetStyle *)NULL); // Get an (uninitialized) instance of the framed window as a class // that derives from INxWindow. diff --git a/NxWidgets/nxwm/src/ctouchscreen.cxx b/NxWidgets/nxwm/src/ctouchscreen.cxx index 1a8a5e967d..ba25dd95fd 100644 --- a/NxWidgets/nxwm/src/ctouchscreen.cxx +++ b/NxWidgets/nxwm/src/ctouchscreen.cxx @@ -36,7 +36,7 @@ /******************************************************************************************** * Included Files ********************************************************************************************/ - + #include #include diff --git a/NxWidgets/nxwm/src/cwindowmessenger.cxx b/NxWidgets/nxwm/src/cwindowmessenger.cxx index b467f533cf..032dd1bf26 100644 --- a/NxWidgets/nxwm/src/cwindowmessenger.cxx +++ b/NxWidgets/nxwm/src/cwindowmessenger.cxx @@ -60,9 +60,14 @@ using namespace NxWM; /** * CWindowMessenger 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. */ -CWindowMessenger::CWindowMessenger(void) +CWindowMessenger::CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style) +: NXWidgets::CWidgetControl(style) { // Open a message queue to communicate with the start window task. We need to create // the message queue if it does not exist. @@ -77,6 +82,10 @@ CWindowMessenger::CWindowMessenger(void) { gdbg("ERROR: mq_open(%s) failed: %d\n", g_startWindowMqName, errno); } + + // Add ourself to the list of window event handlers + + addWindowEventHandler(this); } /** @@ -85,6 +94,10 @@ CWindowMessenger::CWindowMessenger(void) CWindowMessenger::~CWindowMessenger(void) { + // Remove ourself from the list of the window event handlers + + removeWindowEventHandler(this); + // Close the message queue (void)mq_close(m_mqd); @@ -127,7 +140,7 @@ void CWindowMessenger::handleMouseEvent(void) struct SStartWindowMessage outmsg; outmsg.msgId = MSGID_MOUSE_INPUT; - outmsg.instance = (FAR void *)this; + outmsg.instance = (FAR void *)static_cast(this); int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage), CONFIG_NXWM_STARTWINDOW_MXMPRIO); @@ -173,7 +186,7 @@ void CWindowMessenger::handleKeyboardEvent(void) struct SStartWindowMessage outmsg; outmsg.msgId = MSGID_KEYBOARD_INPUT; - outmsg.instance = (FAR void *)this; + outmsg.instance = (FAR void *)static_cast(this); int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage), CONFIG_NXWM_STARTWINDOW_MXMPRIO);