apps/graphics/twm4nx: Exploit the new feature to create hidden windows. This cleans up some brief window startup anomalies. Also fixes an initialization error in CMenus.
This commit is contained in:
parent
b512ec0235
commit
b0d39372fb
@ -527,11 +527,13 @@ bool CIconMgr::createIconManagerWindow(FAR const char *prefix)
|
|||||||
// WFLAGS_NO_RESIZE_BUTTON: The user cannot control the Icon Manager
|
// WFLAGS_NO_RESIZE_BUTTON: The user cannot control the Icon Manager
|
||||||
// window size
|
// window size
|
||||||
// WFLAGS_IS_ICONMGR: Yes, this is the Icon Manager window
|
// WFLAGS_IS_ICONMGR: Yes, this is the Icon Manager window
|
||||||
|
// WFLAGS_HIDDEN_WINDOW: The window is created in the hidden state
|
||||||
|
|
||||||
CWindowFactory *factory = m_twm4nx->getWindowFactory();
|
CWindowFactory *factory = m_twm4nx->getWindowFactory();
|
||||||
|
|
||||||
uint8_t wflags = (WFLAGS_NO_MENU_BUTTON | WFLAGS_NO_DELETE_BUTTON |
|
uint8_t wflags = (WFLAGS_NO_MENU_BUTTON | WFLAGS_NO_DELETE_BUTTON |
|
||||||
WFLAGS_NO_RESIZE_BUTTON | WFLAGS_IS_ICONMGR);
|
WFLAGS_NO_RESIZE_BUTTON | WFLAGS_IS_ICONMGR |
|
||||||
|
WFLAGS_HIDDEN_WINDOW);
|
||||||
|
|
||||||
m_window = factory->createWindow(name, &CONFIG_TWM4NX_ICONMGR_IMAGE,
|
m_window = factory->createWindow(name, &CONFIG_TWM4NX_ICONMGR_IMAGE,
|
||||||
this, wflags);
|
this, wflags);
|
||||||
@ -542,10 +544,6 @@ bool CIconMgr::createIconManagerWindow(FAR const char *prefix)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide the window until we complete the configuration
|
|
||||||
|
|
||||||
m_window->hideWindow();
|
|
||||||
|
|
||||||
// Free any temporary name strings
|
// Free any temporary name strings
|
||||||
|
|
||||||
if (allocName != (FAR char *)0)
|
if (allocName != (FAR char *)0)
|
||||||
|
@ -94,6 +94,8 @@ CMenus::CMenus(CTwm4Nx *twm4nx)
|
|||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
|
|
||||||
|
m_menuHead = (FAR struct SMenuItem *)0; // No menu items
|
||||||
|
m_menuTail = (FAR struct SMenuItem *)0; // No menu items
|
||||||
m_popUpMenu = (FAR CMenus *)0; // No pop-up menu
|
m_popUpMenu = (FAR CMenus *)0; // No pop-up menu
|
||||||
m_activeItem = (FAR struct SMenuItem *)0; // No active menu item
|
m_activeItem = (FAR struct SMenuItem *)0; // No active menu item
|
||||||
m_nMenuItems = 0; // No menu items yet
|
m_nMenuItems = 0; // No menu items yet
|
||||||
@ -461,7 +463,8 @@ void CMenus::identify(FAR CWindow *cwin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the menu window
|
* Create the menu window. Menu windows are always created in the hidden
|
||||||
|
* state. When the menu is selected, then it should be shown.
|
||||||
*
|
*
|
||||||
* @result True is returned on success
|
* @result True is returned on success
|
||||||
*/
|
*/
|
||||||
@ -478,9 +481,11 @@ bool CMenus::createMenuWindow(void)
|
|||||||
|
|
||||||
FAR CWindowEvent *control = new CWindowEvent(m_twm4nx, (FAR void *)this);
|
FAR CWindowEvent *control = new CWindowEvent(m_twm4nx, (FAR void *)this);
|
||||||
|
|
||||||
// 4. Create the menu window
|
// 4. Create the menu window. Menu windows are always created in the
|
||||||
|
// hidden state. When the menu is selected, then it should be shown.
|
||||||
|
|
||||||
m_menuWindow = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED);
|
uint8_t cflags = (NXBE_WINDOW_RAMBACKED | NXBE_WINDOW_HIDDEN);
|
||||||
|
m_menuWindow = m_twm4nx->createFramedWindow(control, cflags);
|
||||||
if (m_menuWindow == (FAR NXWidgets::CNxTkWindow *)0)
|
if (m_menuWindow == (FAR NXWidgets::CNxTkWindow *)0)
|
||||||
{
|
{
|
||||||
delete control;
|
delete control;
|
||||||
@ -537,9 +542,12 @@ bool CMenus::setMenuWindowSize(void)
|
|||||||
|
|
||||||
m_entryHeight = menuFont->getHeight() + 4;
|
m_entryHeight = menuFont->getHeight() + 4;
|
||||||
|
|
||||||
// Get the length of the longest item string in in the menu
|
// Get the length of the title
|
||||||
|
|
||||||
|
nxgl_coord_t maxstring = menuFont->getStringWidth(m_menuName);
|
||||||
|
|
||||||
|
// Compare that to the length of the longest item string in in the menu
|
||||||
|
|
||||||
nxgl_coord_t maxstring = 0;
|
|
||||||
for (FAR struct SMenuItem *curr = m_menuHead;
|
for (FAR struct SMenuItem *curr = m_menuHead;
|
||||||
curr != NULL;
|
curr != NULL;
|
||||||
curr = curr->flink)
|
curr = curr->flink)
|
||||||
|
@ -249,7 +249,7 @@ bool CWindow::initialize(FAR const char *name,
|
|||||||
|
|
||||||
// Create the main window
|
// Create the main window
|
||||||
|
|
||||||
if (!createMainWindow(&winsize, pos))
|
if (!createMainWindow(&winsize, pos, flags))
|
||||||
{
|
{
|
||||||
twmerr("ERROR: createMainWindow() failed\n");
|
twmerr("ERROR: createMainWindow() failed\n");
|
||||||
cleanup();
|
cleanup();
|
||||||
@ -662,10 +662,12 @@ bool CWindow::event(FAR struct SEventMsg *eventmsg)
|
|||||||
*
|
*
|
||||||
* @param winsize The initial window size
|
* @param winsize The initial window size
|
||||||
* @param winpos The initial window position
|
* @param winpos The initial window position
|
||||||
|
* @param flags Toolbar customizations see WFLAGS_NO_* definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool CWindow::createMainWindow(FAR const nxgl_size_s *winsize,
|
bool CWindow::createMainWindow(FAR const nxgl_size_s *winsize,
|
||||||
FAR const nxgl_point_s *winpos)
|
FAR const nxgl_point_s *winpos,
|
||||||
|
uint8_t flags)
|
||||||
{
|
{
|
||||||
// 1. Get the server instance. m_twm4nx inherits from NXWidgets::CNXServer
|
// 1. Get the server instance. m_twm4nx inherits from NXWidgets::CNXServer
|
||||||
// so we all ready have the server instance.
|
// so we all ready have the server instance.
|
||||||
@ -678,7 +680,13 @@ bool CWindow::createMainWindow(FAR const nxgl_size_s *winsize,
|
|||||||
|
|
||||||
// 4. Create the window
|
// 4. Create the window
|
||||||
|
|
||||||
m_nxWin = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED);
|
uint8_t cflags = NXBE_WINDOW_RAMBACKED;
|
||||||
|
if (WFLAGS_IS_HIDDEN_WINDOW(flags))
|
||||||
|
{
|
||||||
|
cflags |= NXBE_WINDOW_HIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_nxWin = m_twm4nx->createFramedWindow(control, cflags);
|
||||||
if (m_nxWin == (FAR NXWidgets::CNxTkWindow *)0)
|
if (m_nxWin == (FAR NXWidgets::CNxTkWindow *)0)
|
||||||
{
|
{
|
||||||
delete control;
|
delete control;
|
||||||
|
@ -176,7 +176,8 @@ namespace Twm4Nx
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the menu window
|
* Create the menu window. Menu windows are always created in the
|
||||||
|
* hidden state. When the menu is selected, then it should be shown.
|
||||||
*
|
*
|
||||||
* @result True is returned on success
|
* @result True is returned on success
|
||||||
*/
|
*/
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
|
|
||||||
#define NO_TOOLBAR (NTOOLBAR_BUTTONS + 0)
|
#define NO_TOOLBAR (NTOOLBAR_BUTTONS + 0)
|
||||||
#define ICONMGR_WINDOW (NTOOLBAR_BUTTONS + 1)
|
#define ICONMGR_WINDOW (NTOOLBAR_BUTTONS + 1)
|
||||||
|
#define HIDDEN_WINDOW (NTOOLBAR_BUTTONS + 2)
|
||||||
|
|
||||||
#define WFLAGS_NO_MENU_BUTTON (1 << MENU_BUTTON)
|
#define WFLAGS_NO_MENU_BUTTON (1 << MENU_BUTTON)
|
||||||
#define WFLAGS_NO_DELETE_BUTTON (1 << DELETE_BUTTON)
|
#define WFLAGS_NO_DELETE_BUTTON (1 << DELETE_BUTTON)
|
||||||
@ -94,6 +95,7 @@
|
|||||||
#define WFLAGS_NO_MINIMIZE_BUTTON (1 << MINIMIZE_BUTTON)
|
#define WFLAGS_NO_MINIMIZE_BUTTON (1 << MINIMIZE_BUTTON)
|
||||||
#define WFLAGS_NO_TOOLBAR (1 << NO_TOOLBAR)
|
#define WFLAGS_NO_TOOLBAR (1 << NO_TOOLBAR)
|
||||||
#define WFLAGS_IS_ICONMGR (1 << ICONMGR_WINDOW)
|
#define WFLAGS_IS_ICONMGR (1 << ICONMGR_WINDOW)
|
||||||
|
#define WFLAGS_HIDDEN_WINDOW (1 << HIDDEN_WINDOW)
|
||||||
|
|
||||||
#define WFLAGS_HAVE_MENU_BUTTON(f) (((f) & WFLAGS_NO_MENU_BUTTON) == 0)
|
#define WFLAGS_HAVE_MENU_BUTTON(f) (((f) & WFLAGS_NO_MENU_BUTTON) == 0)
|
||||||
#define WFLAGS_HAVE_DELETE_BUTTON(f) (((f) & WFLAGS_NO_DELETE_BUTTON) == 0)
|
#define WFLAGS_HAVE_DELETE_BUTTON(f) (((f) & WFLAGS_NO_DELETE_BUTTON) == 0)
|
||||||
@ -101,6 +103,7 @@
|
|||||||
#define WFLAGS_HAVE_MINIMIZE_BUTTON(f) (((f) & WFLAGS_NO_MINIMIZE_BUTTON) == 0)
|
#define WFLAGS_HAVE_MINIMIZE_BUTTON(f) (((f) & WFLAGS_NO_MINIMIZE_BUTTON) == 0)
|
||||||
#define WFLAGS_HAVE_TOOLBAR(f) (((f) & WFLAGS_NO_TOOLBAR) == 0)
|
#define WFLAGS_HAVE_TOOLBAR(f) (((f) & WFLAGS_NO_TOOLBAR) == 0)
|
||||||
#define WFLAGS_IS_ICONMGR_WINDOW(f) (((f) & WFLAGS_IS_ICONMGR) != 0)
|
#define WFLAGS_IS_ICONMGR_WINDOW(f) (((f) & WFLAGS_IS_ICONMGR) != 0)
|
||||||
|
#define WFLAGS_IS_HIDDEN_WINDOW(f) (((f) & WFLAGS_HIDDEN_WINDOW) != 0)
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation Classes
|
// Implementation Classes
|
||||||
@ -172,10 +175,12 @@ namespace Twm4Nx
|
|||||||
*
|
*
|
||||||
* @param winsize The initial window size
|
* @param winsize The initial window size
|
||||||
* @param winpos The initial window position
|
* @param winpos The initial window position
|
||||||
|
* @param flags Toolbar customizations see WFLAGS_NO_* definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool createMainWindow(FAR const nxgl_size_s *winsize,
|
bool createMainWindow(FAR const nxgl_size_s *winsize,
|
||||||
FAR const nxgl_point_s *winpos);
|
FAR const nxgl_point_s *winpos,
|
||||||
|
uint8_t flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the height of the tool bar
|
* Calculate the height of the tool bar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user