diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-13 14:36:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-13 14:36:59 +0000 |
commit | 193f6fa1764c7d1d88efced8af88c785ebff891f (patch) | |
tree | ad7cd2e11ec8b196ca588de12508afb294a689c8 /NxWidgets/libnxwidgets | |
parent | dddc850bfc8afdd0fb6e02d1541636931abaa70a (diff) | |
download | nuttx-193f6fa1764c7d1d88efced8af88c785ebff891f.tar.gz nuttx-193f6fa1764c7d1d88efced8af88c785ebff891f.tar.bz2 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/libnxwidgets')
-rw-r--r-- | NxWidgets/libnxwidgets/include/cnxtkwindow.hxx | 9 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx | 13 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cnxtkwindow.cxx | 48 |
3 files changed, 57 insertions, 13 deletions
diff --git a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx index 32d634182..4c379754a 100644 --- a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx +++ b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx @@ -112,7 +112,7 @@ namespace NXWidgets * @param widgetControl Controlling widget for this window. */ - CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl); + CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl); /** * Destructor. @@ -143,10 +143,15 @@ namespace NXWidgets * the toolbar object AND calls the INxWindow::open() method to * create the toolbar. The toolbar is ready for use upon return. * + * @param height. The height in rows of the tool bar + * @param widgetControl. The controlling widget for this window. If + * none is provided, then a new, vanilla CWidgetControl will be created + * for the tool bar. * @return True if the toolbar was successfully created. */ - CNxToolbar *openToolbar(nxgl_coord_t height); + CNxToolbar *openToolbar(nxgl_coord_t height, + CWidgetControl *widgetControl = (CWidgetControl *)0); /** * Detach the toolbar. This should *ONLY* be called by the toolbar diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx index 4a54469d8..565e9cc36 100644 --- a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx @@ -526,7 +526,7 @@ namespace NXWidgets /** * Get the default widget style for this window. * - * @return Pointer to the clicked widget. + * @param style. The location to return the widget's style */ inline void getWidgetStyle(CWidgetStyle *style) @@ -535,6 +535,17 @@ namespace NXWidgets } /** + * Set the default widget style for this window. + * + * @param style. The new widget style to copy. + */ + + inline void setWidgetStyle(const CWidgetStyle *style) + { + copyWidgetStyle(&m_style, style); + } + + /** * These remaining methods are used by the CCallback instance to * provide notifications of certain events. */ diff --git a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx index 648cc368f..16eaad2c7 100644 --- a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx +++ b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx @@ -66,13 +66,13 @@ using namespace NXWidgets; * @param widgetControl Controlling widget for this window. */ -CNxTkWindow::CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl) - : CCallback(pWidgetControl) +CNxTkWindow::CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl) + : CCallback(widgetControl) { // Save construction values m_hNxServer = hNxServer; - m_widgetControl = pWidgetControl; + m_widgetControl = widgetControl; // Nullify uninitilized pointers @@ -138,14 +138,38 @@ CWidgetControl *CNxTkWindow::getWidgetControl(void) const * the toolbar object AND calls the INxWindow::open() method to * create the toolbar. The toolbar is ready for use upon return. * + * @param height. The height in rows of the tool bar + * @param widgetControl. The controlling widget for this window. If + * none is provided, then a new, vanilla CWidgetControl will be created + * for the tool bar. * @param height Height of the toolbar */ -CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height) +CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height, CWidgetControl *widgetControl) { if (m_hNxTkWindow && !m_toolbar) { - // Get current window style from the widget control + // Create a new widget control if none was provided + + CWidgetControl *allocControl = (CWidgetControl *)0; + if (!widgetControl) + { + // NOTE: This constructor would accept the toolbar "style" as a argument. + // However, we will explicitly set the style below to handle the case + // where the user has provided a custom widget control + + allocControl = new CWidgetControl(); + if (!allocControl) + { + return (CNxToolbar *)0; + } + + // Use the allocated widget control + + widgetControl = allocControl; + } + + // Get current window style from the NXTK window's widget control CWidgetStyle style; m_widgetControl->getWidgetStyle(&style); @@ -155,9 +179,7 @@ CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height) style.colors.background = CONFIG_NXTK_BORDERCOLOR1; style.colors.selectedBackground = CONFIG_NXTK_BORDERCOLOR1; - // Create a new controlling widget for the window using these colors - - CWidgetControl *widgetControl = new CWidgetControl(&style); + widgetControl->setWidgetStyle(&style); // And create the toolbar @@ -165,7 +187,10 @@ CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height) widgetControl, height); if (!m_toolbar) { - delete widgetControl; + if (allocControl) + { + delete allocControl; + } return (CNxToolbar *)0; } @@ -177,7 +202,10 @@ CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height) // Failed to create the toolbar. Clean-up and return NULL delete m_toolbar; - delete widgetControl; + if (allocControl) + { + delete allocControl; + } return (CNxToolbar *)0; } |