diff options
Diffstat (limited to 'NxWidgets/nxwm/include')
-rw-r--r-- | NxWidgets/nxwm/include/capplicationwindow.hxx | 8 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/ccalibration.hxx | 40 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cfullscreenwindow.hxx | 8 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cnxconsole.hxx | 37 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cstartwindow.hxx | 71 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/cwindowcontrol.hxx | 21 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/iapplication.hxx | 56 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/iapplicationwindow.hxx | 19 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/nxwmconfig.hxx | 50 |
9 files changed, 289 insertions, 21 deletions
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx index 8eda8d28a..f923f28b4 100644 --- a/NxWidgets/nxwm/include/capplicationwindow.hxx +++ b/NxWidgets/nxwm/include/capplicationwindow.hxx @@ -151,6 +151,14 @@ namespace NxWM NXWidgets::INxWindow *getWindow(void) const; /** + * Recover the contained window control + * + * @return. The window control used by this application + */ + + CWindowControl *getWindowControl(void) const ; + + /** * Set the window label * * @param appname. The name of the application to place on the window diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx index 3d90d59a8..55cef6d84 100644 --- a/NxWidgets/nxwm/include/ccalibration.hxx +++ b/NxWidgets/nxwm/include/ccalibration.hxx @@ -314,6 +314,46 @@ namespace NxWM bool isFullScreen(void) const; }; + + class CCalibrationFactory : public IApplicationFactory + { + private: + CTaskbar *m_taskbar; /**< The taskbar */ + CTouchscreen *m_touchscreen; /**< The touchscreen device */ + + public: + /** + * CCalibrationFactory Constructor + * + * @param taskbar. The taskbar instance used to terminate calibration + * @param touchscreen. An instance of the class that wraps the + * touchscreen device. + */ + + CCalibrationFactory(CTaskbar *taskbar, CTouchscreen *touchscreen); + + /** + * CCalibrationFactory Destructor + */ + + inline ~CCalibrationFactory(void) { } + + /** + * Create a new instance of an CCalibration (as IApplication). + */ + + IApplication *create(void); + + /** + * Get the icon associated with the application + * + * @return An instance if IBitmap that may be used to rend the + * application's icon. This is an new IBitmap instance that must + * be deleted by the caller when it is no long needed. + */ + + NXWidgets::IBitmap *getIcon(void); + }; } #endif // __INCLUDE_CCALIBRATION_HXX diff --git a/NxWidgets/nxwm/include/cfullscreenwindow.hxx b/NxWidgets/nxwm/include/cfullscreenwindow.hxx index 3c4117689..2e3fbd45d 100644 --- a/NxWidgets/nxwm/include/cfullscreenwindow.hxx +++ b/NxWidgets/nxwm/include/cfullscreenwindow.hxx @@ -115,6 +115,14 @@ namespace NxWM NXWidgets::INxWindow *getWindow(void) const; /** + * Recover the contained window control + * + * @return. The window control used by this application + */ + + CWindowControl *getWindowControl(void) const; + + /** * Set the window label * * @param appname. The name of the application to place on the window diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx index 91fb941d8..b95c86406 100644 --- a/NxWidgets/nxwm/include/cnxconsole.hxx +++ b/NxWidgets/nxwm/include/cnxconsole.hxx @@ -191,6 +191,43 @@ namespace NxWM bool isFullScreen(void) const; }; + + class CNxConsoleFactory : public IApplicationFactory + { + private: + CTaskbar *m_taskbar; /**< The taskbar */ + + public: + /** + * CNxConsoleFactory Constructor + * + * @param taskbar. The taskbar instance used to terminate calibration + */ + + CNxConsoleFactory(CTaskbar *taskbar); + + /** + * CNxConsoleFactory Destructor + */ + + inline ~CNxConsoleFactory(void) { } + + /** + * Create a new instance of an CNxConsole (as IApplication). + */ + + IApplication *create(void); + + /** + * Get the icon associated with the application + * + * @return An instance if IBitmap that may be used to rend the + * application's icon. This is an new IBitmap instance that must + * be deleted by the caller when it is no long needed. + */ + + NXWidgets::IBitmap *getIcon(void); + }; } #endif // __cplusplus diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx index d0ae5ec84..b0cad6127 100644 --- a/NxWidgets/nxwm/include/cstartwindow.hxx +++ b/NxWidgets/nxwm/include/cstartwindow.hxx @@ -42,6 +42,8 @@ #include <nuttx/config.h> +#include <debug.h> + #include "tnxarray.hxx" #include "iapplication.hxx" @@ -59,8 +61,35 @@ namespace NxWM { + /** + * Forward references + */ + class CTaskbar; + /** + * Start window message opcodes and format + */ + + enum EStartWindowMessageOpcodes + { + MSGID_POSITIONAL_CHANGE = 1, /**< Change in window positional data (not used) */ + MSGID_REDRAW_REQUEST, /**< Request to redraw a portion of the window (not used) */ + MSGID_MOUSE_INPUT, /**< New mouse input is available */ + MSGID_KEYBOARD_INPUT, /**< New keyboard input is available */ + MSGID_DESTROY_APP /**< Destroy the application */ + }; + + struct SStartWindowMessage + { + enum EStartWindowMessageOpcodes msgId; /**< The message opcode */ + FAR void *instance; /**< Object instance. */ + }; + + /** + * This class is the the start window application. + */ + class CStartWindow : public IApplication, private IApplicationCallback, private NXWidgets::CWidgetEventHandler @@ -72,7 +101,7 @@ namespace NxWM struct SStartWindowSlot { - IApplication *app; /**< A reference to the icon */ + IApplicationFactory *app; /**< A reference to the icon */ NXWidgets::CImage *image; /**< The icon image that goes with the application */ }; @@ -84,6 +113,33 @@ namespace NxWM CApplicationWindow *m_window; /**< Reference to the application window */ TNxArray<struct SStartWindowSlot> m_slots; /**< List of apps in the start window */ struct nxgl_size_s m_iconSize; /**< A box big enough to hold the largest icon */ + pid_t m_taskId; /**< ID of the start window task */ + + /** + * This is the start window task. This function receives window events from + * the NX listener threads indirectly through this sequence: + * + * 1. The NX listener thread receives a windows event. The NX listener thread + * which is part of CTaskBar and was created when NX server connection was + * established). This event may be a positional change notification, a + * redraw request, or mouse or keyboard input. + * 2. The NX listener thread handles the message by calling nx_eventhandler(). + * nx_eventhandler() dispatches the message by calling a method in the + * NXWidgets::CCallback instance associated with the window. + * NXWidgets::CCallback is a part of the CWidgetControl. + * 3. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process + * the event. + * 4. NXWidgets::CWidgetControl records the new state data and raises a + * window event. + * 5. NXWidgets::CWindowEventHandlerList will give the event to + * NxWM::CWindowControl. + * 6. NxWM::CWindowControl will send the a message on a well-known message + * queue. + * 7. This CStartWindow::startWindow task will receive and process that + * message. + */ + + static int startWindow(int argc, char *argv[]); /** * Called when the window minimize button is pressed. @@ -107,7 +163,7 @@ namespace NxWM * Stop all applications */ - void stopAllApplications(void); + void removeAllApplications(void); /** * Handle a widget action event. For CImage, this is a mouse button pre-release event. @@ -202,18 +258,15 @@ namespace NxWM * Add the application to the start window. The general sequence for * setting up the start window is: * - * 1. Call CTaskBar::openApplicationWindow to create a window for the start window, - * 2. Use the window to instantiate CStartWindow - * 3. Call CStartWindow::addApplication numerous times to install applications - * in the start window. - * 4. Call CTaskBar::startApplication (initially minimized) to start the start - * window application. + * 1. Call IAppicationFactory::create to a new instance of the application + * 2. Call CStartWindow::addApplication to add the application to the + * start window. * * @param app. The new application to add to the start window * @return true on success */ - bool addApplication(IApplication *app); + bool addApplication(IApplicationFactory *app); /** * Simulate a mouse click on the icon at index. This inline method is only diff --git a/NxWidgets/nxwm/include/cwindowcontrol.hxx b/NxWidgets/nxwm/include/cwindowcontrol.hxx index acec12727..91e430c5c 100644 --- a/NxWidgets/nxwm/include/cwindowcontrol.hxx +++ b/NxWidgets/nxwm/include/cwindowcontrol.hxx @@ -43,6 +43,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <mqueue.h> + #include <nuttx/nx/nxtk.h> #include <nuttx/nx/nxconsole.h> @@ -62,6 +64,12 @@ namespace NxWM { /** + * Forward references. + */ + + class IApplication; + + /** * The class CWindowControl integrates the widget control with some special * handling of mouse and keyboard inputs neesed by NxWM */ @@ -70,6 +78,9 @@ namespace NxWM private NXWidgets::CWindowEventHandler { private: + mqd_t m_mqd; /**< Message queue descriptor used to commincate with the + ** start window thread. */ + /** * Handle an NX window mouse input event. * @@ -105,6 +116,16 @@ namespace NxWM */ ~CWindowControl(void); + + /** + * Destroy the application window and everything in it. This is + * handled by CWindowControl (vs just calling the destructors) because + * in the case where an application destroys itself (because of pressing + * the stop button), then we need to unwind and get out of the application + * logic before destroying all of its objects. + */ + + void destroy(IApplication *app); }; } #endif // __cplusplus diff --git a/NxWidgets/nxwm/include/iapplication.hxx b/NxWidgets/nxwm/include/iapplication.hxx index 0d33db7bc..45067d900 100644 --- a/NxWidgets/nxwm/include/iapplication.hxx +++ b/NxWidgets/nxwm/include/iapplication.hxx @@ -44,6 +44,8 @@ #include "cnxstring.hxx" #include "ibitmap.hxx" + +#include "cwindowcontrol.hxx" #include "capplicationwindow.hxx" /**************************************************************************** @@ -65,15 +67,26 @@ namespace NxWM class IApplication { protected: - // These values (and the accessors that go with them) violate the "purity" - // of the base class. These are really part of the task bar implementation: - // Each application provides this state information needed by the taskbar. + /** + * These values (and the accessors that go with them) violate the "purity" + * of the base class. These are really part of the task bar implementation: + * Each application provides this state information needed by the taskbar. + */ bool m_minimized; /**< True if the application is minimized */ bool m_topapp; /**< True if this application is at the top in the hiearchy */ public: /** + * A virtual destructor is required in order to override the IApplication + * destructor. We do this because if we delete IApplication, we want the + * destructor of the class that inherits from IApplication to run, not this + * one. + */ + + virtual ~IApplication(void) { } + + /** * Each implementation of IApplication must provide a method to recover * the contained CApplicationWindow instance. */ @@ -81,6 +94,18 @@ namespace NxWM virtual IApplicationWindow *getWindow(void) const = 0; /** + * Get the window widget control. + * + * @return The widget control of the underlying window instance. + */ + + virtual inline CWindowControl *getWindowControl(void) const + { + IApplicationWindow *window = getWindow(); + return window->getWindowControl(); + } + + /** * Get the icon associated with the application * * @return An instance if IBitmap that may be used to rend the @@ -181,6 +206,31 @@ namespace NxWM virtual bool isFullScreen(void) const = 0; }; + + /** + * IApplicationFactory provides a mechanism for creating multiple instances + * of an application. + */ + + class IApplicationFactory + { + public: + /** + * Create a new instance of an application. + */ + + virtual IApplication *create(void) = 0; + + /** + * Get the icon associated with the application + * + * @return An instance if IBitmap that may be used to rend the + * application's icon. This is an new IBitmap instance that must + * be deleted by the caller when it is no long needed. + */ + + virtual NXWidgets::IBitmap *getIcon(void) = 0; + }; } #endif // __cplusplus diff --git a/NxWidgets/nxwm/include/iapplicationwindow.hxx b/NxWidgets/nxwm/include/iapplicationwindow.hxx index b00a03fa2..fe8830c2f 100644 --- a/NxWidgets/nxwm/include/iapplicationwindow.hxx +++ b/NxWidgets/nxwm/include/iapplicationwindow.hxx @@ -42,13 +42,10 @@ #include <nuttx/config.h> -#include "cnxtkwindow.hxx" -#include "cnxtoolbar.hxx" -#include "cwidgeteventargs.hxx" -#include "cwidgeteventhandler.hxx" -#include "cimage.hxx" -#include "clabel.hxx" -#include "crlepalettebitmap.hxx" +#include "inxwindow.hxx" +#include "cnxstring.hxx" + +#include "cwindowcontrol.hxx" /**************************************************************************** * Pre-Processor Definitions @@ -122,6 +119,14 @@ namespace NxWM virtual NXWidgets::INxWindow *getWindow(void) const = 0; /** + * Recover the contained window control + * + * @return. The window control used by this application + */ + + virtual CWindowControl *getWindowControl(void) const = 0; + + /** * Set the window label * * @param appname. The name of the application to place on the window diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx index 34721d777..3605f8c4f 100644 --- a/NxWidgets/nxwm/include/nxwmconfig.hxx +++ b/NxWidgets/nxwm/include/nxwmconfig.hxx @@ -263,6 +263,19 @@ * CONFIG_NXWM_STARTWINDOW_VSPACING - Vertical spacing. Default: 2 pixels * CONFIG_NXWM_STARTWINDOW_HSPACING - Horizontal spacing. Default: 2 rows * CONFIG_NXWM_STARTWINDOW_ICON - The glyph to use as the start window icon + * CONFIG_NXWM_STARTWINDOW_MQNAME - The well known name of the message queue + * Used to communicated from CWindowControl tothe start window thread. + * Default: "/dev/nxwm" + * CONFIG_NXWM_STARTWINDOW_MXMSGS - The maximum number of messages to queue + * before blocking. Defualt 32 + * CONFIG_NXWM_STARTWINDOW_MXMPRIO - The message priority. Default: 42. + * CONFIG_NXWM_STARTWINDOW_PRIO - Priority of the NxConsole task. Default: + * SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than + * CONFIG_NXWIDGETS_SERVERPRIO or else there may be data overrun errors. + * Such errors would most likely appear as duplicated rows of data on the + * display. + * CONFIG_NXWM_STARTWINDOW_STACKSIZE - The stack size to use when starting the + * NxConsole task. Default: 2048 bytes. */ #ifndef CONFIG_NXWM_STARTWINDOW_VSPACING @@ -281,6 +294,39 @@ # define CONFIG_NXWM_STARTWINDOW_ICON NxWM::g_playBitmap #endif +/** + * Start window task parameters + */ + +#ifndef CONFIG_NXWM_STARTWINDOW_MQNAME +# define CONFIG_NXWM_STARTWINDOW_MQNAME "/dev/nxwm" +#endif + +#ifndef CONFIG_NXWM_STARTWINDOW_MXMSGS +# ifdef CONFIG_NX_MXCLIENTMSGS +# define CONFIG_NXWM_STARTWINDOW_MXMSGS CONFIG_NX_MXCLIENTMSGS +# else +# define CONFIG_NXWM_STARTWINDOW_MXMSGS 32 +# endif +#endif + +#ifndef CONFIG_NXWM_STARTWINDOW_MXMPRIO +# define CONFIG_NXWM_STARTWINDOW_MXMPRIO 42 +#endif + +#ifndef CONFIG_NXWM_STARTWINDOW_PRIO +# define CONFIG_NXWM_STARTWINDOW_PRIO SCHED_PRIORITY_DEFAULT +#endif + +#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO +# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO" +# warning" -- This can result in data overrun errors" +#endif + +#ifndef CONFIG_NXWM_STARTWINDOW_STACKSIZE +# define CONFIG_NXWM_STARTWINDOW_STACKSIZE 2048 +#endif + /* NxConsole Window *********************************************************/ /** * NxConsole Window Configuration @@ -347,7 +393,7 @@ * CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO - Priority of the touchscreen listener * thread. Default: SCHED_PRIORITY_DEFAULT * CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK - Touchscreen listener thread stack - * size. Default 2048 + * size. Default 1024 */ #ifndef CONFIG_NXWM_TOUCHSCREEN_DEVNO @@ -367,7 +413,7 @@ #endif #ifndef CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK -# define CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK 2048 +# define CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK 1024 #endif /* Calibration display ******************************************************/ |