summaryrefslogtreecommitdiff
path: root/NxWidgets/nxwm
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-13 14:36:59 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-13 14:36:59 +0000
commit193f6fa1764c7d1d88efced8af88c785ebff891f (patch)
treead7cd2e11ec8b196ca588de12508afb294a689c8 /NxWidgets/nxwm
parentdddc850bfc8afdd0fb6e02d1541636931abaa70a (diff)
downloadpx4-nuttx-193f6fa1764c7d1d88efced8af88c785ebff891f.tar.gz
px4-nuttx-193f6fa1764c7d1d88efced8af88c785ebff891f.tar.bz2
px4-nuttx-193f6fa1764c7d1d88efced8af88c785ebff891f.zip
NxWM: Fix detection of touch events in the tool bar; Start window should not have a stop icon
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4729 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/nxwm')
-rw-r--r--NxWidgets/nxwm/include/capplicationwindow.hxx26
-rw-r--r--NxWidgets/nxwm/include/ctaskbar.hxx4
-rw-r--r--NxWidgets/nxwm/src/capplicationwindow.cxx160
-rw-r--r--NxWidgets/nxwm/src/ctaskbar.cxx6
4 files changed, 127 insertions, 69 deletions
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx
index 7736a3081..807f268a6 100644
--- a/NxWidgets/nxwm/include/capplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/capplicationwindow.hxx
@@ -73,6 +73,16 @@ namespace NxWM
class CApplicationWindow : public IApplicationWindow,
private NXWidgets::CWidgetEventHandler
{
+ public:
+ /**
+ * Enumeration describing the bit settings for each window flag
+ */
+
+ enum EWindowFlags
+ {
+ WINDOW_PERSISTENT = 0x01 /**< Persistent windows have no stop button */
+ };
+
protected:
NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
NXWidgets::CNxToolbar *m_toolbar; /**< The toolbar */
@@ -83,6 +93,7 @@ namespace NxWM
NXWidgets::CRlePaletteBitmap *m_stopBitmap; /**< The stop icon bitmap */
NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
IApplicationCallback *m_callback; /**< Toolbar action callbacks */
+ uint8_t m_flags; /**< Window flags */
/**
* Handle a mouse button click event.
@@ -98,9 +109,10 @@ namespace NxWM
* CApplicationWindow Constructor
*
* @param window. The window to be used by this application.
+ * @param flags. Optional flags to control the window configuration (See EWindowFlags).
*/
- CApplicationWindow(NXWidgets::CNxTkWindow *window);
+ CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags = 0);
/**
* CApplicationWindow Destructor
@@ -153,6 +165,18 @@ namespace NxWM
void registerCallbacks(IApplicationCallback *callback);
/**
+ * Check if this window is configured for a persistent application (i.e.,
+ * an application that has no STOP icon
+ *
+ * @return True if the window is configured for a persistent application.
+ */
+
+ inline bool isPersistent(void) const
+ {
+ return (m_flags & WINDOW_PERSISTENT) != 0;
+ }
+
+ /**
* Simulate a mouse click on the minimize icon. This inline method is only
* used during automated testing of NxWM.
*/
diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx
index 431c2be48..35a291aef 100644
--- a/NxWidgets/nxwm/include/ctaskbar.hxx
+++ b/NxWidgets/nxwm/include/ctaskbar.hxx
@@ -301,9 +301,11 @@ namespace NxWM
*
* 4. Call CTaskBar::startApplication start the application and bring its window to
* the top.
+ *
+ * @param flags. CApplicationWindow flugs for window customization.
*/
- CApplicationWindow *openApplicationWindow(void);
+ CApplicationWindow *openApplicationWindow(uint8_t flags = 0);
/**
* Create a full screen application window. Creating a new full screen application
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx
index f57c04297..d2190cd24 100644
--- a/NxWidgets/nxwm/src/capplicationwindow.cxx
+++ b/NxWidgets/nxwm/src/capplicationwindow.cxx
@@ -47,6 +47,7 @@
#include "nxwmconfig.hxx"
#include "nxwmglyphs.hxx"
+#include "cwindowcontrol.hxx"
#include "capplicationwindow.hxx"
/********************************************************************************************
@@ -63,13 +64,15 @@
* CApplicationWindow Constructor
*
* @param taskbar. A pointer to the parent task bar instance.
+ * @param flags. Optional flags to control the window configuration (See EWindowFlags).
*/
-CApplicationWindow::CApplicationWindow(NXWidgets::CNxTkWindow *window)
+CApplicationWindow::CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags)
{
- // Save the window for later use
+ // Save the window and window flags for later use
m_window = window;
+ m_flags = flags;
// These will be created with the open method is called
@@ -150,9 +153,17 @@ CApplicationWindow::~CApplicationWindow(void)
bool CApplicationWindow::open(void)
{
+ // Create one of our special window controls for the tool bar
+
+ CWindowControl *control = new CWindowControl();
+ if (!control)
+ {
+ return false;
+ }
+
// Open the toolbar
- m_toolbar = m_window->openToolbar(CONFIG_NXWM_TOOLBAR_HEIGHT);
+ m_toolbar = m_window->openToolbar(CONFIG_NXWM_TOOLBAR_HEIGHT, control);
if (!m_toolbar)
{
// We failed to open the toolbar
@@ -168,67 +179,67 @@ bool CApplicationWindow::open(void)
return false;
}
- // Get the CWidgetControl associated with the toolbar
+ // Start positioning icons from the right side of the tool bar
- NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
- if (!control)
- {
- return false;
- }
+ struct nxgl_point_s iconPos;
+ struct nxgl_size_s iconSize;
- // Create STOP bitmap container
+ iconPos.x = windowSize.w;
- m_stopBitmap = new NXWidgets::CRlePaletteBitmap(&g_stopBitmap);
- if (!m_stopBitmap)
- {
- return false;
- }
+ // Create the STOP icon only if this is a non-persistent application
- // Create the STOP application icon at the right of the toolbar
+ if (!isPersistent())
+ {
+ // Create STOP bitmap container
- struct nxgl_point_s iconPos;
- struct nxgl_size_s iconSize;
+ m_stopBitmap = new NXWidgets::CRlePaletteBitmap(&g_stopBitmap);
+ if (!m_stopBitmap)
+ {
+ return false;
+ }
- // Get the height and width of the stop bitmap
+ // Create the STOP application icon at the right of the toolbar
+ // Get the height and width of the stop bitmap
- iconSize.w = m_stopBitmap->getWidth();
- iconSize.h = m_stopBitmap->getHeight();
+ iconSize.w = m_stopBitmap->getWidth();
+ iconSize.h = m_stopBitmap->getHeight();
- // The default CImage has borders enabled with thickness of the border
- // width. Add twice the thickness of the border to the width and height.
- // (We could let CImage do this for us by calling
- // CImage::getPreferredDimensions())
+ // The default CImage has borders enabled with thickness of the border
+ // width. Add twice the thickness of the border to the width and height.
+ // (We could let CImage do this for us by calling
+ // CImage::getPreferredDimensions())
- iconSize.w += 2 * 1;
- iconSize.h += 2 * 1;
+ iconSize.w += 2 * 1;
+ iconSize.h += 2 * 1;
- // Pick an X/Y position such that the image will position at the right of
- // the toolbar and centered vertically.
+ // Pick an X/Y position such that the image will position at the right of
+ // the toolbar and centered vertically.
- iconPos.x = windowSize.w - iconSize.w;
+ iconPos.x -= iconSize.w;
- if (iconSize.h >= windowSize.h)
- {
- iconPos.y = 0;
- }
- else
- {
- iconPos.y = (windowSize.h - iconSize.h) >> 1;
- }
+ if (iconSize.h >= windowSize.h)
+ {
+ iconPos.y = 0;
+ }
+ else
+ {
+ iconPos.y = (windowSize.h - iconSize.h) >> 1;
+ }
- // Now we have enough information to create the image
+ // Now we have enough information to create the image
- m_stopImage = new NXWidgets::CImage(control, iconPos.x, iconPos.y, iconSize.w,
- iconSize.h, m_stopBitmap);
- if (!m_stopImage)
- {
- return false;
- }
+ m_stopImage = new NXWidgets::CImage(control, iconPos.x, iconPos.y, iconSize.w,
+ iconSize.h, m_stopBitmap);
+ if (!m_stopImage)
+ {
+ return false;
+ }
- // Configure 'this' to receive mouse click inputs from the image
+ // Configure 'this' to receive mouse click inputs from the image
- m_stopImage->setBorderless(true);
- m_stopImage->addWidgetEventHandler(this);
+ m_stopImage->setBorderless(true);
+ m_stopImage->addWidgetEventHandler(this);
+ }
// Create MINIMIZE application bitmap container
@@ -343,17 +354,23 @@ void CApplicationWindow::redraw(void)
port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
CONFIG_NXTK_BORDERCOLOR1);
- // Then draw the images
+ // Then draw the stop image (which may not be present if this is a
+ // "persistent" application)
- m_stopImage->enableDrawing();
- m_stopImage->redraw();
- m_stopImage->setRaisesEvents(true);
+ if (m_stopImage)
+ {
+ m_stopImage->enableDrawing();
+ m_stopImage->redraw();
+ m_stopImage->setRaisesEvents(true);
+ }
+
+ // Draw the minimize image
m_minimizeImage->enableDrawing();
m_minimizeImage->redraw();
m_minimizeImage->setRaisesEvents(true);
- // And draw the window label
+ // And finally draw the window label
m_windowLabel->enableDrawing();
m_windowLabel->redraw();
@@ -366,10 +383,16 @@ void CApplicationWindow::redraw(void)
void CApplicationWindow::hide(void)
{
- // Disable the images
+ // Disable the stop image (which may not be present if this is a
+ // "persistent" application)
+
+ if (m_stopImage)
+ {
+ m_stopImage->disableDrawing();
+ m_stopImage->setRaisesEvents(false);
+ }
- m_stopImage->disableDrawing();
- m_stopImage->setRaisesEvents(false);
+ // Disable the minimize image
m_minimizeImage->disableDrawing();
m_minimizeImage->setRaisesEvents(false);
@@ -428,7 +451,8 @@ void CApplicationWindow::clickMinimizeIcon(int index)
// And click the image at its center
- m_minimizeImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
+ m_minimizeImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
}
#endif
@@ -440,17 +464,23 @@ void CApplicationWindow::clickMinimizeIcon(int index)
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CApplicationWindow::clickStopIcon(int index)
{
- // Get the size and position of the widget
+ // The stop icon will not be available for "persistent" applications
- struct nxgl_size_s imageSize;
- m_stopImage->getSize(imageSize);
+ if (m_stopImage)
+ {
+ // Get the size and position of the widget
- struct nxgl_point_s imagePos;
- m_stopImage->getPos(imagePos);
+ struct nxgl_size_s imageSize;
+ m_stopImage->getSize(imageSize);
- // And click the image at its center
+ struct nxgl_point_s imagePos;
+ m_stopImage->getPos(imagePos);
- m_stopImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
+ // And click the image at its center
+
+ m_stopImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
}
#endif
@@ -468,7 +498,7 @@ void CApplicationWindow::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
{
// Check the stop application image
- if (m_stopImage->isClicked())
+ if (m_stopImage && m_stopImage->isClicked())
{
// Notify the controlling logic that the application should be stopped
diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx
index 9558e47a8..c6e1b574b 100644
--- a/NxWidgets/nxwm/src/ctaskbar.cxx
+++ b/NxWidgets/nxwm/src/ctaskbar.cxx
@@ -264,9 +264,11 @@ bool CTaskbar::startWindowManager(void)
*
* 4. Call CTaskBar::startApplication start the application and bring its window to
* the top.
+ *
+ * @param flags. CApplicationWindow flugs for window customization.
*/
-CApplicationWindow *CTaskbar::openApplicationWindow(void)
+CApplicationWindow *CTaskbar::openApplicationWindow(uint8_t flags)
{
// Get a framed window for the application
@@ -282,7 +284,7 @@ CApplicationWindow *CTaskbar::openApplicationWindow(void)
// Use this window to instantiate the application window
- CApplicationWindow *appWindow = new CApplicationWindow(window);
+ CApplicationWindow *appWindow = new CApplicationWindow(window, flags);
if (!appWindow)
{
delete window;