mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-07-18 04:08:57 +08:00
Various fixes for running the NxWM unit test on the STM3240G-EVAL
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4711 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
fb682a72fb
commit
b866254cde
@ -28,4 +28,10 @@
|
|||||||
* CNxWidget: Removed support for reference constants and close types.
|
* CNxWidget: Removed support for reference constants and close types.
|
||||||
The goal is to ge the base widget class as small as possible.
|
The goal is to ge the base widget class as small as possible.
|
||||||
* CNxTkWindow: Fix uninitialized pointer value.
|
* CNxTkWindow: Fix uninitialized pointer value.
|
||||||
|
* CNxToolbar: Need to "fake" the fix position callback to avoid
|
||||||
|
deadlock waits for the callback that won't happen.
|
||||||
|
* CNxTkWindow: Fix toolbar background color
|
||||||
|
* CWidgetControl: Don't declare the the geometry is good until a non-NULL
|
||||||
|
window size is received.
|
||||||
|
* CGraphicsPort and CWidgetControl: If the underlying graphics device
|
||||||
|
is write-only, then we have to render fonts a little differently.
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "nxconfig.hxx"
|
||||||
#include "inxwindow.hxx"
|
#include "inxwindow.hxx"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -106,15 +107,25 @@ namespace NXWidgets
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
INxWindow *m_pNxWnd; /**< NX window interface. */
|
INxWindow *m_pNxWnd; /**< NX window interface. */
|
||||||
|
#ifdef CONFIG_NX_WRITEONLY
|
||||||
|
nxgl_mxpixel_t m_backColor; /**< The background color to use */
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param pNxWnd An instance of the underlying window type.
|
* @param pNxWnd. An instance of the underlying window type.
|
||||||
|
* @param backColor. The background color is only needed if we
|
||||||
|
* cannot read from the graphics device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NX_WRITEONLY
|
||||||
|
CGraphicsPort(INxWindow *pNxWnd,
|
||||||
|
nxgl_mxpixel_t backColor = CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR);
|
||||||
|
#else
|
||||||
CGraphicsPort(INxWindow *pNxWnd);
|
CGraphicsPort(INxWindow *pNxWnd);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
|
@ -166,6 +166,8 @@ namespace NXWidgets
|
|||||||
TNxArray<CNxWidget*> m_widgets; /**< List of controlled
|
TNxArray<CNxWidget*> m_widgets; /**< List of controlled
|
||||||
widgets. */
|
widgets. */
|
||||||
bool m_modal; /**< True: in modal loop */
|
bool m_modal; /**< True: in modal loop */
|
||||||
|
bool m_haveGeometry; /**< True: indicates that we
|
||||||
|
have valid geometry data. */
|
||||||
sem_t m_modalSem; /**< Modal loops waits for
|
sem_t m_modalSem; /**< Modal loops waits for
|
||||||
events on this semaphore */
|
events on this semaphore */
|
||||||
/**
|
/**
|
||||||
@ -669,11 +671,7 @@ namespace NXWidgets
|
|||||||
* CGraphicsPort instance
|
* CGraphicsPort instance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool createGraphicsPort(INxWindow *window)
|
bool createGraphicsPort(INxWindow *window);
|
||||||
{
|
|
||||||
m_port = new CGraphicsPort(window);
|
|
||||||
return m_port != (CGraphicsPort *)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the CGraphicsPort instance for drawing on this window
|
* Get the CGraphicsPort instance for drawing on this window
|
||||||
|
@ -105,13 +105,23 @@ using namespace NXWidgets;
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param pNxWnd An instance of the underlying window type.
|
* @param pNxWnd. An instance of the underlying window type.
|
||||||
|
* @param backColor. The background color is only needed if we
|
||||||
|
* cannot read from the graphics device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NX_WRITEONLY
|
||||||
|
CGraphicsPort::CGraphicsPort(INxWindow *pNxWnd, nxgl_mxpixel_t backColor)
|
||||||
|
{
|
||||||
|
m_pNxWnd = pNxWnd;
|
||||||
|
m_backColor = backColor;
|
||||||
|
}
|
||||||
|
#else
|
||||||
CGraphicsPort::CGraphicsPort(INxWindow *pNxWnd)
|
CGraphicsPort::CGraphicsPort(INxWindow *pNxWnd)
|
||||||
{
|
{
|
||||||
m_pNxWnd = pNxWnd;
|
m_pNxWnd = pNxWnd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
@ -673,10 +683,6 @@ void CGraphicsPort::drawText(struct nxgl_point_s *pos, CRect *bound,
|
|||||||
|
|
||||||
// Loop setup
|
// Loop setup
|
||||||
|
|
||||||
#if 0
|
|
||||||
nxwidget_pixel_t backcolor = g_defaultWidgetStyle->colors.back;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct SBitmap bitmap;
|
struct SBitmap bitmap;
|
||||||
bitmap.bpp = CONFIG_NXWIDGETS_BPP;
|
bitmap.bpp = CONFIG_NXWIDGETS_BPP;
|
||||||
bitmap.fmt = CONFIG_NXWIDGETS_FMT;
|
bitmap.fmt = CONFIG_NXWIDGETS_FMT;
|
||||||
@ -736,14 +742,14 @@ void CGraphicsPort::drawText(struct nxgl_point_s *pos, CRect *bound,
|
|||||||
// Sometimes a solid background works, sometimes not. But reading
|
// Sometimes a solid background works, sometimes not. But reading
|
||||||
// from graphics memory always works.
|
// from graphics memory always works.
|
||||||
|
|
||||||
#if 0
|
#ifdef CONFIG_NX_WRITEONLY
|
||||||
// Set the glyph memory to the background color
|
// Set the glyph memory to the background color
|
||||||
|
|
||||||
nxwidget_pixel_t *bmPtr = (nxwidget_pixel_t *)bitmap.data;
|
nxwidget_pixel_t *bmPtr = (nxwidget_pixel_t *)bitmap.data;
|
||||||
unsigned int npixels = fontWidth * fontHeight;
|
unsigned int npixels = fontWidth * fontHeight;
|
||||||
for (unsigned int j = 0; j < npixels; j++)
|
for (unsigned int j = 0; j < npixels; j++)
|
||||||
{
|
{
|
||||||
*bmPtr++ = backcolor;
|
*bmPtr++ = m_backColor;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Read the current contents of the destination into the glyph memory
|
// Read the current contents of the destination into the glyph memory
|
||||||
|
@ -84,6 +84,7 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
|
|||||||
|
|
||||||
m_port = (CGraphicsPort *)NULL;
|
m_port = (CGraphicsPort *)NULL;
|
||||||
m_modal = false;
|
m_modal = false;
|
||||||
|
m_haveGeometry = false;
|
||||||
m_clickedWidget = (CNxWidget *)NULL;
|
m_clickedWidget = (CNxWidget *)NULL;
|
||||||
m_focusedWidget = (CNxWidget *)NULL;
|
m_focusedWidget = (CNxWidget *)NULL;
|
||||||
|
|
||||||
@ -440,14 +441,25 @@ void CWidgetControl::geometryEvent(NXHANDLE hWindow,
|
|||||||
|
|
||||||
m_hWindow = hWindow;
|
m_hWindow = hWindow;
|
||||||
nxgl_rectcopy(&m_bounds, bounds);
|
nxgl_rectcopy(&m_bounds, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the normal start up sequence, the window is created with zero size
|
||||||
|
// at position 0,0. The safe thing to do is to set the position (still
|
||||||
|
// with size 0, then then set the size. Assuming that is what is being
|
||||||
|
// done, we will not report that we have valid geometry until the size
|
||||||
|
// becomes nonzero.
|
||||||
|
|
||||||
|
if (!m_haveGeometry && size->h > 0 && size->w > 0)
|
||||||
|
{
|
||||||
// Wake up any threads waiting for initial position information.
|
// Wake up any threads waiting for initial position information.
|
||||||
// REVISIT: If the window is moved or repositioned, then the
|
// REVISIT: If the window is moved or repositioned, then the
|
||||||
// position and size data will be incorrect for a period of time.
|
// position and size data will be incorrect for a period of time.
|
||||||
// That case should be handled here as well.
|
// That case should be handled here as well.
|
||||||
|
|
||||||
|
m_haveGeometry = true;
|
||||||
giveGeoSem();
|
giveGeoSem();
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,6 +661,31 @@ void CWidgetControl::newCursorControlEvent(ECursorControl cursorControl)
|
|||||||
wakeupModalLoop();
|
wakeupModalLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The creation sequence is:
|
||||||
|
*
|
||||||
|
* 1) Create a dumb CWigetControl instance
|
||||||
|
* 2) Pass the dumb CWidgetControl instance to the window constructor
|
||||||
|
* that inherits from INxWindow.
|
||||||
|
* 3) The call this method with the static_cast to INxWindow to,
|
||||||
|
* finally, create the CGraphicsPort for this window.
|
||||||
|
* 4) After that, the fully smartend CWidgetControl instance can
|
||||||
|
* be used to generate additional widgets.
|
||||||
|
*
|
||||||
|
* @param window The instance of INxWindow needed to construct the
|
||||||
|
* CGraphicsPort instance
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool CWidgetControl::createGraphicsPort(INxWindow *window)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NX_WRITEONLY
|
||||||
|
m_port = new CGraphicsPort(window, m_style.colors.background);
|
||||||
|
#else
|
||||||
|
m_port = new CGraphicsPort(window);
|
||||||
|
#endif
|
||||||
|
return m_port != (CGraphicsPort *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a widget style
|
* Copy a widget style
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user