From f3b3d1fc727a88cc2c14d71fde8ceded1f3f9316 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 4 May 2019 11:45:15 -0600 Subject: [PATCH] apps/graphics/NxWidgets: CNxTkWindow, CNxWindow, CNxServer: Add support to create RAM backed windows. apps/graphics/twm4nx: IconMgr window now comes up correctly. Need to revisit window width setup. All windows are no created as RAM backed windows. --- graphics/nxwidgets/src/cnxtkwindow.cxx | 13 ++++++------- graphics/nxwidgets/src/cnxwindow.cxx | 16 ++++++++++------ graphics/twm4nx/src/ciconmgr.cxx | 3 ++- graphics/twm4nx/src/cmenus.cxx | 3 ++- graphics/twm4nx/src/cresize.cxx | 4 +++- graphics/twm4nx/src/cwindow.cxx | 11 ++++++----- include/graphics/nxwidgets/cnxserver.hxx | 8 ++++---- include/graphics/nxwidgets/cnxtkwindow.hxx | 5 ++++- include/graphics/nxwidgets/cnxwindow.hxx | 9 ++++----- include/graphics/twm4nx/cwindow.hxx | 12 ++++++++++++ include/graphics/twm4nx/twm4nx_config.hxx | 8 ++++---- 11 files changed, 57 insertions(+), 35 deletions(-) diff --git a/graphics/nxwidgets/src/cnxtkwindow.cxx b/graphics/nxwidgets/src/cnxtkwindow.cxx index f9bf2fa0b..7edd324fc 100644 --- a/graphics/nxwidgets/src/cnxtkwindow.cxx +++ b/graphics/nxwidgets/src/cnxtkwindow.cxx @@ -49,10 +49,6 @@ #include "graphics/nxwidgets/cnxtoolbar.hxx" #include "graphics/nxwidgets/cbitmap.hxx" -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - /**************************************************************************** * Method Implementations ****************************************************************************/ @@ -64,15 +60,18 @@ using namespace NXWidgets; * * @param hNxServer Handle to the NX server. * @param widgetControl Controlling widget for this window. + * @param flags Window properties */ -CNxTkWindow::CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl) +CNxTkWindow::CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl, + uint8_t flags) : CCallback(widgetControl) { // Save construction values m_hNxServer = hNxServer; m_widgetControl = widgetControl; + m_flags = flags; // Nullify uninitilized pointers and values @@ -120,8 +119,8 @@ bool CNxTkWindow::open(void) // Create the window - m_hNxTkWindow = nxtk_openwindow(m_hNxServer, 0, vtable, - (FAR void *)static_cast(this)); + m_hNxTkWindow = nxtk_openwindow(m_hNxServer, m_flags, vtable, + (FAR void *)static_cast(this)); return m_hNxTkWindow != NULL; } diff --git a/graphics/nxwidgets/src/cnxwindow.cxx b/graphics/nxwidgets/src/cnxwindow.cxx index c88b6f1d8..423ea21f4 100644 --- a/graphics/nxwidgets/src/cnxwindow.cxx +++ b/graphics/nxwidgets/src/cnxwindow.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * apps/graphics/nxwidgets/src/cnxwindow.cxx * - * Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015-2016, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -57,14 +57,18 @@ using namespace NXWidgets; /** - * Constructor. + * Constructor. Creates an uninitialized instance of the CNxWindow + * object. The open() method must be called to initialize the instance. * * @param hNxServer Handle to the NX server. + * @param widgetControl Controlling widget for this window. + * @param flags Window properties */ -CNxWindow::CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl) +CNxWindow::CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl, + uint8_t flags) : CCallback(pWidgetControl), m_hNxServer(hNxServer), m_hNxWindow(0), - m_widgetControl(pWidgetControl) + m_widgetControl(pWidgetControl), m_flags(flags) { // Create the CGraphicsPort instance for this window @@ -105,8 +109,8 @@ bool CNxWindow::open(void) // Create the window - m_hNxWindow = nx_openwindow(m_hNxServer, 0, vtable, - (FAR void *)static_cast(this)); + m_hNxWindow = nx_openwindow(m_hNxServer, m_flags, vtable, + (FAR void *)static_cast(this)); return m_hNxWindow != NULL; } diff --git a/graphics/twm4nx/src/ciconmgr.cxx b/graphics/twm4nx/src/ciconmgr.cxx index 3fcfa619a..8fb9822dc 100644 --- a/graphics/twm4nx/src/ciconmgr.cxx +++ b/graphics/twm4nx/src/ciconmgr.cxx @@ -219,7 +219,7 @@ bool CIconMgr::add(FAR CWindow *cwin) else { windowSize.h = rowHeight * m_nWindows; - m_window->setWindowSize(&windowSize); + m_window->setWindowSize(&windowSize); // REVISIT: use resizeFrame() } // Increment the window count @@ -580,6 +580,7 @@ bool CIconMgr::createWindow(FAR const char *prefix) return false; } + m_window->synchronize(); return true; } diff --git a/graphics/twm4nx/src/cmenus.cxx b/graphics/twm4nx/src/cmenus.cxx index 5fb00728d..2b4b96586 100644 --- a/graphics/twm4nx/src/cmenus.cxx +++ b/graphics/twm4nx/src/cmenus.cxx @@ -54,6 +54,7 @@ #include #include +#include #include "graphics/nxwidgets/cnxfont.hxx" #include "graphics/nxwidgets/clistbox.hxx" @@ -487,7 +488,7 @@ bool CMenus::createMenuWindow(void) // 4. Create the menu window - m_menuWindow = m_twm4nx->createFramedWindow(control); + m_menuWindow = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED); if (m_menuWindow == (FAR NXWidgets::CNxTkWindow *)0) { delete control; diff --git a/graphics/twm4nx/src/cresize.cxx b/graphics/twm4nx/src/cresize.cxx index 605565456..c1a34fc90 100644 --- a/graphics/twm4nx/src/cresize.cxx +++ b/graphics/twm4nx/src/cresize.cxx @@ -46,6 +46,8 @@ #include +#include + #include "graphics/nxwidgets/cnxfont.hxx" #include "graphics/nxwidgets/clabel.hxx" @@ -959,7 +961,7 @@ bool CResize::createSizeWindow(void) // 4. Create the main window - m_sizeWindow = m_twm4nx->createFramedWindow(control); + m_sizeWindow = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED); if (m_sizeWindow == (FAR NXWidgets::CNxTkWindow *)0) { delete control; diff --git a/graphics/twm4nx/src/cwindow.cxx b/graphics/twm4nx/src/cwindow.cxx index 816788239..25bd3c66e 100644 --- a/graphics/twm4nx/src/cwindow.cxx +++ b/graphics/twm4nx/src/cwindow.cxx @@ -55,6 +55,7 @@ #include #include +#include #include "graphics/nxglyphs.hxx" @@ -618,7 +619,7 @@ bool CWindow::createMainWindow(FAR const nxgl_size_s *winsize, // 4. Create the window - m_nxWin = m_twm4nx->createFramedWindow(control); + m_nxWin = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED); if (m_nxWin == (FAR NXWidgets::CNxTkWindow *)0) { delete control; @@ -736,10 +737,10 @@ bool CWindow::createToolbar(void) } // Get the background color of the current widget system. - // REVISIT: No widgets yet, using the default widget background color + // REVISIT: No widgets yet, using the the non-shadowed border color port->drawFilledRect(0, 0, windowSize.w, windowSize.h, - CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR); + CONFIG_NXTK_BORDERCOLOR1); return true; } @@ -999,13 +1000,13 @@ bool CWindow::createToolbarTitle(FAR const char *name) struct nxgl_size_s titleSize; titleSize.h = m_tbHeight; - titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_FRAME_VSPACING + 1; + titleSize.w = m_tbRightX - m_tbLeftX - 2 * CONFIG_TWM4NX_TOOLBAR_HSPACING + 1; // Position the title. Packed to the left horizontally, positioned at the // top of the toolbar. struct nxgl_point_s titlePos; - titlePos.x = m_tbLeftX + CONFIG_TWM4NX_FRAME_VSPACING; + titlePos.x = m_tbLeftX + CONFIG_TWM4NX_TOOLBAR_HSPACING; titlePos.y = 0; // Get the Widget control instance from the toolbar window. This diff --git a/include/graphics/nxwidgets/cnxserver.hxx b/include/graphics/nxwidgets/cnxserver.hxx index 6ed3f3998..463e9c22c 100644 --- a/include/graphics/nxwidgets/cnxserver.hxx +++ b/include/graphics/nxwidgets/cnxserver.hxx @@ -160,18 +160,18 @@ namespace NXWidgets * Get an instance of a raw NX window. */ - inline CNxWindow *createRawWindow(CWidgetControl *widgetControl) + inline CNxWindow *createRawWindow(CWidgetControl *widgetControl, uint8_t flags = 0) { - return new CNxWindow(m_hNxServer, widgetControl); + return new CNxWindow(m_hNxServer, widgetControl, flags); } /** * Get an instance of the framed NX window. */ - inline CNxTkWindow *createFramedWindow(CWidgetControl *widgetControl) + inline CNxTkWindow *createFramedWindow(CWidgetControl *widgetControl, uint8_t flags = 0) { - return new CNxTkWindow(m_hNxServer, widgetControl); + return new CNxTkWindow(m_hNxServer, widgetControl, flags); } /** diff --git a/include/graphics/nxwidgets/cnxtkwindow.hxx b/include/graphics/nxwidgets/cnxtkwindow.hxx index f8f6a00f5..ac7ef9d66 100644 --- a/include/graphics/nxwidgets/cnxtkwindow.hxx +++ b/include/graphics/nxwidgets/cnxtkwindow.hxx @@ -89,6 +89,7 @@ namespace NXWidgets CWidgetControl *m_widgetControl; /**< Controlling widget for the window */ CNxToolbar *m_toolbar; /**< Child toolbar */ nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */ + uint8_t m_flags; /**< Window properties */ public: @@ -111,9 +112,11 @@ namespace NXWidgets * * @param hNxServer Handle to the NX server. * @param widgetControl Controlling widget for this window. + * @param flags Window properties */ - CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl); + CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl, + uint8_t flags); /** * Destructor. diff --git a/include/graphics/nxwidgets/cnxwindow.hxx b/include/graphics/nxwidgets/cnxwindow.hxx index d5e10638c..065521bca 100644 --- a/include/graphics/nxwidgets/cnxwindow.hxx +++ b/include/graphics/nxwidgets/cnxwindow.hxx @@ -52,10 +52,6 @@ #include "graphics/nxwidgets/ccallback.hxx" #include "graphics/nxwidgets/inxwindow.hxx" -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - /**************************************************************************** * Implementation Classes ****************************************************************************/ @@ -89,6 +85,7 @@ namespace NXWidgets NXHANDLE m_hNxServer; /**< Handle to the NX server. */ NXWINDOW m_hNxWindow; /**< Handle to the NX raw window */ CWidgetControl *m_widgetControl; /**< The controlling widget for the window */ + uint8_t m_flags; /**< Window properties */ public: @@ -111,9 +108,11 @@ namespace NXWidgets * * @param hNxServer Handle to the NX server. * @param widgetControl Controlling widget for this window. + * @param flags Window properties */ - CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl); + CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl, + uint8_t flags = 0); /** * Destructor. diff --git a/include/graphics/twm4nx/cwindow.hxx b/include/graphics/twm4nx/cwindow.hxx index 3c63ccb80..520b6d280 100644 --- a/include/graphics/twm4nx/cwindow.hxx +++ b/include/graphics/twm4nx/cwindow.hxx @@ -334,6 +334,18 @@ namespace Twm4Nx FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap, bool isIconMgr, FAR CIconMgr *iconMgr, bool noToolbar); + /** + * Synchronize the window with the NX server. This function will delay + * until the the NX server has caught up with all of the queued requests. + * When this function returns, the state of the NX server will be the + * same as the state of the application. + */ + + inline void synchronize(void) + { + m_nxWin->synchronize(); + } + /** * Get the widget control instance needed to support application drawing * into the window. diff --git a/include/graphics/twm4nx/twm4nx_config.hxx b/include/graphics/twm4nx/twm4nx_config.hxx index ab6b757c9..6dedf5bba 100644 --- a/include/graphics/twm4nx/twm4nx_config.hxx +++ b/include/graphics/twm4nx/twm4nx_config.hxx @@ -146,15 +146,15 @@ // Spacing. Defaults values good at 75 and 100 DPI #ifndef CONFIG_TWM4NX_TOOLBAR_HSPACING -# define CONFIG_TWM4NX_TOOLBAR_HSPACING 8 +# define CONFIG_TWM4NX_TOOLBAR_HSPACING 2 #endif -#ifndef CONFIG_TWM4NX_ICONMGR_VSPACING -# define CONFIG_TWM4NX_FRAME_VSPACING 2 +#ifndef CONFIG_TWM4NX_FRAME_VSPACING +# define CONFIG_TWM4NX_FRAME_VSPACING 2 #endif #ifndef CONFIG_TWM4NX_BUTTON_INDENT -# define CONFIG_TWM4NX_BUTTON_INDENT 1 +# define CONFIG_TWM4NX_BUTTON_INDENT 1 #endif #ifndef CONFIG_TWM4NX_ICONMGR_VSPACING