apps/graphics/twm4nx: In order for widgets too draw the correct window or toolbar, it is necessary to get the CWidgetControl instance from the window we want to use, not to create a new instance.
This commit is contained in:
parent
fe0954cd62
commit
ba58654955
@ -524,16 +524,6 @@ bool CIconMgr::createWindow(FAR const char *prefix)
|
|||||||
|
|
||||||
bool CIconMgr::createButtonArray(void)
|
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
|
// Get the width of the window
|
||||||
|
|
||||||
struct nxgl_size_s windowSize;
|
struct nxgl_size_s windowSize;
|
||||||
@ -557,6 +547,17 @@ bool CIconMgr::createButtonArray(void)
|
|||||||
nxgl_coord_t buttonWidth = windowSize.w / m_maxColumns;
|
nxgl_coord_t buttonWidth = windowSize.w / m_maxColumns;
|
||||||
nxgl_coord_t buttonHeight = windowSize.w / nrows;
|
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
|
// Now we have enough information to create the button array
|
||||||
|
|
||||||
m_buttons = new NXWidgets::CButtonArray(control,
|
m_buttons = new NXWidgets::CButtonArray(control,
|
||||||
@ -566,7 +567,6 @@ bool CIconMgr::createButtonArray(void)
|
|||||||
if (m_buttons == (FAR NXWidgets::CButtonArray *)0)
|
if (m_buttons == (FAR NXWidgets::CButtonArray *)0)
|
||||||
{
|
{
|
||||||
gerr("ERROR: Failed to get window size\n");
|
gerr("ERROR: Failed to get window size\n");
|
||||||
delete control;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,17 +628,18 @@ bool CMenus::setMenuWindowPosition(FAR struct nxgl_point_s *framePos)
|
|||||||
|
|
||||||
bool CMenus::createMenuListBox(void)
|
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
|
// 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;
|
struct nxgl_point_s pos;
|
||||||
pos.x = 0;
|
pos.x = 0;
|
||||||
@ -653,7 +654,6 @@ bool CMenus::createMenuListBox(void)
|
|||||||
if (m_menuListBox == (FAR NXWidgets::CListBox *)0)
|
if (m_menuListBox == (FAR NXWidgets::CListBox *)0)
|
||||||
{
|
{
|
||||||
gerr("ERROR: Failed to instantiate list box\n");
|
gerr("ERROR: Failed to instantiate list box\n");
|
||||||
delete control;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +843,8 @@ bool CWindow::createToolbarButtons(void)
|
|||||||
nxgl_coord_t w = 1;
|
nxgl_coord_t w = 1;
|
||||||
nxgl_coord_t h = 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();
|
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.x = m_tbLeftX + CONFIG_TWM4NX_FRAME_VSPACING;
|
||||||
titlePos.y = 0;
|
titlePos.y = 0;
|
||||||
|
|
||||||
// Create a Widget control instance for the window using the default style
|
// Get the Widget control instance from the toolbar window. This
|
||||||
// for now. CWindowEvent derives from CWidgetControl.
|
// will force all widget drawing to go to the toolbar.
|
||||||
// REVISIT: Create the style, using the selected colors.
|
|
||||||
|
|
||||||
FAR CWindowEvent *control = new CWindowEvent(m_twm4nx);
|
FAR NXWidgets:: CWidgetControl *control = m_toolbar->getWidgetControl();
|
||||||
if (control == (FAR CWindowEvent *)0)
|
if (control == (FAR NXWidgets:: CWidgetControl *)0)
|
||||||
{
|
{
|
||||||
|
// Should not fail
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user