diff --git a/graphics/twm4nx/src/ciconmgr.cxx b/graphics/twm4nx/src/ciconmgr.cxx index 997a59ca1..661fa9cf3 100644 --- a/graphics/twm4nx/src/ciconmgr.cxx +++ b/graphics/twm4nx/src/ciconmgr.cxx @@ -524,16 +524,6 @@ bool CIconMgr::createWindow(FAR const char *prefix) bool CIconMgr::createButtonArray(void) { - // Create a Widget control instance for the window using the default style - // for now. CWindowEvent derives from CWidgetControl. - // REVISIT: Create the style, using the selected colors. - - FAR CWindowEvent *control = new CWindowEvent(m_twm4nx); - if (control == (FAR CWindowEvent *)0) - { - return false; - } - // Get the width of the window struct nxgl_size_s windowSize; @@ -557,6 +547,17 @@ bool CIconMgr::createButtonArray(void) nxgl_coord_t buttonWidth = windowSize.w / m_maxColumns; nxgl_coord_t buttonHeight = windowSize.w / nrows; + // Get the Widget control instance from the Icon Manager window. This + // will force all widget drawing to go to the Icon Manager window. + + FAR NXWidgets:: CWidgetControl *control = m_window->getWidgetControl(); + if (control == (FAR NXWidgets:: CWidgetControl *)0) + { + // Should not fail + + return false; + } + // Now we have enough information to create the button array m_buttons = new NXWidgets::CButtonArray(control, @@ -566,7 +567,6 @@ bool CIconMgr::createButtonArray(void) if (m_buttons == (FAR NXWidgets::CButtonArray *)0) { gerr("ERROR: Failed to get window size\n"); - delete control; return false; } diff --git a/graphics/twm4nx/src/cmenus.cxx b/graphics/twm4nx/src/cmenus.cxx index d88023887..495c94ec7 100644 --- a/graphics/twm4nx/src/cmenus.cxx +++ b/graphics/twm4nx/src/cmenus.cxx @@ -628,17 +628,18 @@ bool CMenus::setMenuWindowPosition(FAR struct nxgl_point_s *framePos) bool CMenus::createMenuListBox(void) { + // Get the Widget control instance from the menu window. This + // will force all widget drawing to go to the Icon Manager window. + + FAR NXWidgets:: CWidgetControl *control = m_menuWindow->getWidgetControl(); + if (control == (FAR NXWidgets:: CWidgetControl *)0) + { + // Should not fail + + return false; + } + // Create the menu list box - // 1. Get the server instance. m_twm4nx inherits from NXWidgets::CNXServer - // so we all ready have the server instance. - // 2. Create the style, using the selected colors (REVISIT) - - // 3. Create a Widget control instance for the window using the default - // style for now. CWindowEvent derives from CWidgetControl. - - FAR CWindowEvent *control = new CWindowEvent(m_twm4nx); - - // 4. Create the menu list box struct nxgl_point_s pos; pos.x = 0; @@ -653,7 +654,6 @@ bool CMenus::createMenuListBox(void) if (m_menuListBox == (FAR NXWidgets::CListBox *)0) { gerr("ERROR: Failed to instantiate list box\n"); - delete control; return false; } diff --git a/graphics/twm4nx/src/cwindow.cxx b/graphics/twm4nx/src/cwindow.cxx index 5418c1a89..74bc6d2a3 100644 --- a/graphics/twm4nx/src/cwindow.cxx +++ b/graphics/twm4nx/src/cwindow.cxx @@ -843,7 +843,8 @@ bool CWindow::createToolbarButtons(void) nxgl_coord_t w = 1; nxgl_coord_t h = 1; - // Get the toolbar CWdigetControl instance + // Get the toolbar CWdigetControl instance. This will force all + // widget drawing to go to the toolbar. NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl(); @@ -962,13 +963,14 @@ bool CWindow::createToolbarTitle(FAR const char *name) titlePos.x = m_tbLeftX + CONFIG_TWM4NX_FRAME_VSPACING; titlePos.y = 0; - // Create a Widget control instance for the window using the default style - // for now. CWindowEvent derives from CWidgetControl. - // REVISIT: Create the style, using the selected colors. + // Get the Widget control instance from the toolbar window. This + // will force all widget drawing to go to the toolbar. - FAR CWindowEvent *control = new CWindowEvent(m_twm4nx); - if (control == (FAR CWindowEvent *)0) + FAR NXWidgets:: CWidgetControl *control = m_toolbar->getWidgetControl(); + if (control == (FAR NXWidgets:: CWidgetControl *)0) { + // Should not fail + return false; }