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.
This commit is contained in:
Gregory Nutt 2019-05-04 11:45:15 -06:00
parent b5ae79b8f3
commit f3b3d1fc72
11 changed files with 57 additions and 35 deletions

View File

@ -49,10 +49,6 @@
#include "graphics/nxwidgets/cnxtoolbar.hxx" #include "graphics/nxwidgets/cnxtoolbar.hxx"
#include "graphics/nxwidgets/cbitmap.hxx" #include "graphics/nxwidgets/cbitmap.hxx"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Method Implementations * Method Implementations
****************************************************************************/ ****************************************************************************/
@ -64,15 +60,18 @@ using namespace NXWidgets;
* *
* @param hNxServer Handle to the NX server. * @param hNxServer Handle to the NX server.
* @param widgetControl Controlling widget for this window. * @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) : CCallback(widgetControl)
{ {
// Save construction values // Save construction values
m_hNxServer = hNxServer; m_hNxServer = hNxServer;
m_widgetControl = widgetControl; m_widgetControl = widgetControl;
m_flags = flags;
// Nullify uninitilized pointers and values // Nullify uninitilized pointers and values
@ -120,8 +119,8 @@ bool CNxTkWindow::open(void)
// Create the window // Create the window
m_hNxTkWindow = nxtk_openwindow(m_hNxServer, 0, vtable, m_hNxTkWindow = nxtk_openwindow(m_hNxServer, m_flags, vtable,
(FAR void *)static_cast<CCallback*>(this)); (FAR void *)static_cast<CCallback*>(this));
return m_hNxTkWindow != NULL; return m_hNxTkWindow != NULL;
} }

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* apps/graphics/nxwidgets/src/cnxwindow.cxx * 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 <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -57,14 +57,18 @@
using namespace NXWidgets; 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 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), : CCallback(pWidgetControl), m_hNxServer(hNxServer), m_hNxWindow(0),
m_widgetControl(pWidgetControl) m_widgetControl(pWidgetControl), m_flags(flags)
{ {
// Create the CGraphicsPort instance for this window // Create the CGraphicsPort instance for this window
@ -105,8 +109,8 @@ bool CNxWindow::open(void)
// Create the window // Create the window
m_hNxWindow = nx_openwindow(m_hNxServer, 0, vtable, m_hNxWindow = nx_openwindow(m_hNxServer, m_flags, vtable,
(FAR void *)static_cast<CCallback*>(this)); (FAR void *)static_cast<CCallback*>(this));
return m_hNxWindow != NULL; return m_hNxWindow != NULL;
} }

View File

@ -219,7 +219,7 @@ bool CIconMgr::add(FAR CWindow *cwin)
else else
{ {
windowSize.h = rowHeight * m_nWindows; windowSize.h = rowHeight * m_nWindows;
m_window->setWindowSize(&windowSize); m_window->setWindowSize(&windowSize); // REVISIT: use resizeFrame()
} }
// Increment the window count // Increment the window count
@ -580,6 +580,7 @@ bool CIconMgr::createWindow(FAR const char *prefix)
return false; return false;
} }
m_window->synchronize();
return true; return true;
} }

View File

@ -54,6 +54,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <nuttx/version.h> #include <nuttx/version.h>
#include <nuttx/nx/nxbe.h>
#include "graphics/nxwidgets/cnxfont.hxx" #include "graphics/nxwidgets/cnxfont.hxx"
#include "graphics/nxwidgets/clistbox.hxx" #include "graphics/nxwidgets/clistbox.hxx"
@ -487,7 +488,7 @@ bool CMenus::createMenuWindow(void)
// 4. Create the menu window // 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) if (m_menuWindow == (FAR NXWidgets::CNxTkWindow *)0)
{ {
delete control; delete control;

View File

@ -46,6 +46,8 @@
#include <stdio.h> #include <stdio.h>
#include <nuttx/nx/nxbe.h>
#include "graphics/nxwidgets/cnxfont.hxx" #include "graphics/nxwidgets/cnxfont.hxx"
#include "graphics/nxwidgets/clabel.hxx" #include "graphics/nxwidgets/clabel.hxx"
@ -959,7 +961,7 @@ bool CResize::createSizeWindow(void)
// 4. Create the main window // 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) if (m_sizeWindow == (FAR NXWidgets::CNxTkWindow *)0)
{ {
delete control; delete control;

View File

@ -55,6 +55,7 @@
#include <mqueue.h> #include <mqueue.h>
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxbe.h>
#include "graphics/nxglyphs.hxx" #include "graphics/nxglyphs.hxx"
@ -618,7 +619,7 @@ bool CWindow::createMainWindow(FAR const nxgl_size_s *winsize,
// 4. Create the window // 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) if (m_nxWin == (FAR NXWidgets::CNxTkWindow *)0)
{ {
delete control; delete control;
@ -736,10 +737,10 @@ bool CWindow::createToolbar(void)
} }
// Get the background color of the current widget system. // 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, port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR); CONFIG_NXTK_BORDERCOLOR1);
return true; return true;
} }
@ -999,13 +1000,13 @@ bool CWindow::createToolbarTitle(FAR const char *name)
struct nxgl_size_s titleSize; struct nxgl_size_s titleSize;
titleSize.h = m_tbHeight; 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 // Position the title. Packed to the left horizontally, positioned at the
// top of the toolbar. // top of the toolbar.
struct nxgl_point_s titlePos; struct nxgl_point_s titlePos;
titlePos.x = m_tbLeftX + CONFIG_TWM4NX_FRAME_VSPACING; titlePos.x = m_tbLeftX + CONFIG_TWM4NX_TOOLBAR_HSPACING;
titlePos.y = 0; titlePos.y = 0;
// Get the Widget control instance from the toolbar window. This // Get the Widget control instance from the toolbar window. This

View File

@ -160,18 +160,18 @@ namespace NXWidgets
* Get an instance of a raw NX window. * 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. * 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);
} }
/** /**

View File

@ -89,6 +89,7 @@ namespace NXWidgets
CWidgetControl *m_widgetControl; /**< Controlling widget for the window */ CWidgetControl *m_widgetControl; /**< Controlling widget for the window */
CNxToolbar *m_toolbar; /**< Child toolbar */ CNxToolbar *m_toolbar; /**< Child toolbar */
nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */ nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */
uint8_t m_flags; /**< Window properties */
public: public:
@ -111,9 +112,11 @@ namespace NXWidgets
* *
* @param hNxServer Handle to the NX server. * @param hNxServer Handle to the NX server.
* @param widgetControl Controlling widget for this window. * @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. * Destructor.

View File

@ -52,10 +52,6 @@
#include "graphics/nxwidgets/ccallback.hxx" #include "graphics/nxwidgets/ccallback.hxx"
#include "graphics/nxwidgets/inxwindow.hxx" #include "graphics/nxwidgets/inxwindow.hxx"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Implementation Classes * Implementation Classes
****************************************************************************/ ****************************************************************************/
@ -89,6 +85,7 @@ namespace NXWidgets
NXHANDLE m_hNxServer; /**< Handle to the NX server. */ NXHANDLE m_hNxServer; /**< Handle to the NX server. */
NXWINDOW m_hNxWindow; /**< Handle to the NX raw window */ NXWINDOW m_hNxWindow; /**< Handle to the NX raw window */
CWidgetControl *m_widgetControl; /**< The controlling widget for the window */ CWidgetControl *m_widgetControl; /**< The controlling widget for the window */
uint8_t m_flags; /**< Window properties */
public: public:
@ -111,9 +108,11 @@ namespace NXWidgets
* *
* @param hNxServer Handle to the NX server. * @param hNxServer Handle to the NX server.
* @param widgetControl Controlling widget for this window. * @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. * Destructor.

View File

@ -334,6 +334,18 @@ namespace Twm4Nx
FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap, FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap,
bool isIconMgr, FAR CIconMgr *iconMgr, bool noToolbar); 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 * Get the widget control instance needed to support application drawing
* into the window. * into the window.

View File

@ -146,15 +146,15 @@
// Spacing. Defaults values good at 75 and 100 DPI // Spacing. Defaults values good at 75 and 100 DPI
#ifndef CONFIG_TWM4NX_TOOLBAR_HSPACING #ifndef CONFIG_TWM4NX_TOOLBAR_HSPACING
# define CONFIG_TWM4NX_TOOLBAR_HSPACING 8 # define CONFIG_TWM4NX_TOOLBAR_HSPACING 2
#endif #endif
#ifndef CONFIG_TWM4NX_ICONMGR_VSPACING #ifndef CONFIG_TWM4NX_FRAME_VSPACING
# define CONFIG_TWM4NX_FRAME_VSPACING 2 # define CONFIG_TWM4NX_FRAME_VSPACING 2
#endif #endif
#ifndef CONFIG_TWM4NX_BUTTON_INDENT #ifndef CONFIG_TWM4NX_BUTTON_INDENT
# define CONFIG_TWM4NX_BUTTON_INDENT 1 # define CONFIG_TWM4NX_BUTTON_INDENT 1
#endif #endif
#ifndef CONFIG_TWM4NX_ICONMGR_VSPACING #ifndef CONFIG_TWM4NX_ICONMGR_VSPACING