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:
parent
b5ae79b8f3
commit
f3b3d1fc72
@ -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,7 +119,7 @@ bool CNxTkWindow::open(void)
|
||||
|
||||
// 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));
|
||||
return m_hNxTkWindow != NULL;
|
||||
}
|
||||
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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,7 +109,7 @@ bool CNxWindow::open(void)
|
||||
|
||||
// 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));
|
||||
return m_hNxWindow != NULL;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <nuttx/version.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
|
||||
#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;
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
|
||||
#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;
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <mqueue.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
|
||||
#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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -146,10 +146,10 @@
|
||||
// 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
|
||||
#ifndef CONFIG_TWM4NX_FRAME_VSPACING
|
||||
# define CONFIG_TWM4NX_FRAME_VSPACING 2
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user