summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-02 22:03:05 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-02 22:03:05 +0000
commit4b489525b44d49fa0f8cb95733dd0fdf4553c884 (patch)
tree8773aca5097c9c4fd1006bf1e35685c55619ce17 /NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
parent5ebf11ee63f1baaf070fd8484d99362810cd5bcc (diff)
downloadnuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.gz
nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.bz2
nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.zip
NxWM updates (with some NX and NxWidget fixes too)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4689 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets/src/cnxtkwindow.cxx')
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtkwindow.cxx43
1 files changed, 37 insertions, 6 deletions
diff --git a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
index bae9cb815..520896fa2 100644
--- a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx
@@ -124,7 +124,9 @@ CWidgetControl *CNxTkWindow::getWidgetControl(void) const
}
/**
- * Open a toolbar on the framed window
+ * Open a toolbar on the framed window. This method both instantiates
+ * the toolbar object AND calls the INxWindow::open() method to
+ * create the toolbar. The toolbar is ready for use upon return.
*
* @param height Height of the toolbar
*/
@@ -133,13 +135,42 @@ CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height)
{
if (m_hNxTkWindow && !m_toolbar)
{
- // Create the toolbar. Note that we use the SAME underlying
- // widget control. That is because the tool bar really resides
- // in the same "physical" window.
-
+ // Get current window style from the widget control
+
+ CWidgetStyle style;
+ m_widgetControl->getWidgetStyle(&style);
+
+ // Set the background color to the color of the toolbar
+
+ style.colors.background = CONFIG_NXTK_BORDERCOLOR1;
+
+ // Create a new controlling widget for the window
+
+ CWidgetControl *widgetControl = new CWidgetControl(&style);
+
+ // And create the toolbar
+
m_toolbar = new CNxToolbar(this, m_hNxTkWindow,
- m_widgetControl, height);
+ widgetControl, height);
+ if (!m_toolbar)
+ {
+ delete widgetControl;
+ return (CNxToolbar *)0;
+ }
+
+ // Create the new toolbar. Toolbar creation is separate from
+ // object instantiation so that failures can be reported.
+
+ if (!m_toolbar->open())
+ {
+ // Failed to create the toolbar. Clean-up and return NULL
+
+ delete m_toolbar;
+ delete widgetControl;
+ return (CNxToolbar *)0;
+ }
}
+
return m_toolbar;
}