diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-02 22:03:05 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-02 22:03:05 +0000 |
commit | 4b489525b44d49fa0f8cb95733dd0fdf4553c884 (patch) | |
tree | 8773aca5097c9c4fd1006bf1e35685c55619ce17 /NxWidgets/libnxwidgets | |
parent | 5ebf11ee63f1baaf070fd8484d99362810cd5bcc (diff) | |
download | px4-nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.gz px4-nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.bz2 px4-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')
-rw-r--r-- | NxWidgets/libnxwidgets/include/cnxtkwindow.hxx | 5 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cnxwidget.hxx | 35 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cnxtkwindow.cxx | 43 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cnxtoolbar.cxx | 6 |
4 files changed, 81 insertions, 8 deletions
diff --git a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx index b6915a6c1..32d634182 100644 --- a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx +++ b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx @@ -139,8 +139,9 @@ namespace NXWidgets CWidgetControl *getWidgetControl(void) const; /** - * Open a toolbar on the framed window. Toolbar creation is separate - * from object instantion so that errors can be reported + * 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. * * @return True if the toolbar was successfully created. */ diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx index eb1b18710..f46c2e73a 100644 --- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx @@ -695,6 +695,41 @@ namespace NXWidgets return m_rect.getHeight(); } + /** + * Get the size of the widget + * + * @return The widgets's size + */ + + inline void getSize(struct nxgl_size_s &size) const + { + size.h = m_rect.getHeight(); + size.w = m_rect.getWidth(); + } + + /** + * Get the position of the widget + * + * @return The widgets's position + */ + + inline void getPos(struct nxgl_point_s &pos) const + { + pos.x = m_rect.getX(); + pos.y = m_rect.getY(); + } + + /** + * Get the window bounding box in physical display coordinated. + * + * @return This function returns the window handle. + */ + + inline CRect getBoundingBox(void) + { + return CRect(m_rect); + } + /** * Get the dimensions of the border * 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; } diff --git a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx index 1c560deb1..b14a0b611 100644 --- a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx +++ b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx @@ -69,10 +69,16 @@ CNxToolbar::CNxToolbar(CNxTkWindow *pNxTkWindow, NXTKWINDOW hNxTkWindow, CWidgetControl *pWidgetControl, nxgl_coord_t height) : CCallback(pWidgetControl) { + // Initialize toolbar state data + m_nxTkWindow = pNxTkWindow; m_hNxTkWindow = hNxTkWindow; m_widgetControl = pWidgetControl; m_height = height; + + // Create the CGraphicsPort instance for this window + + m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this)); } /** |