summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-28 18:48:11 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-28 18:48:11 +0000
commita63f8bb684d01a23bfe1ee85b1d7faf983b9d1ea (patch)
tree3f51cea039f16c0a9b0b8e05550fe9112d72d824 /NxWidgets/libnxwidgets/src
parentf1b1e3ba11994bcbb0a1ddad9f8e686a6a9ae475 (diff)
downloadnuttx-a63f8bb684d01a23bfe1ee85b1d7faf983b9d1ea.tar.gz
nuttx-a63f8bb684d01a23bfe1ee85b1d7faf983b9d1ea.tar.bz2
nuttx-a63f8bb684d01a23bfe1ee85b1d7faf983b9d1ea.zip
NxWidgets/NxWM updates from Petteri Aimonen (Patches 0007-0013)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5689 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets/src')
-rw-r--r--NxWidgets/libnxwidgets/src/cimage.cxx27
-rw-r--r--NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx4
-rw-r--r--NxWidgets/libnxwidgets/src/cnxtimer.cxx8
-rw-r--r--NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx46
4 files changed, 56 insertions, 29 deletions
diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx
index 30bf7e78b..9b3137129 100644
--- a/NxWidgets/libnxwidgets/src/cimage.cxx
+++ b/NxWidgets/libnxwidgets/src/cimage.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/include/cimage.cxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
-
+
/****************************************************************************
* Method Implementations
****************************************************************************/
@@ -163,6 +163,13 @@ void CImage::getPreferredDimensions(CRect &rect) const
void CImage::drawContents(CGraphicsPort *port)
{
+ if (!m_bitmap)
+ {
+ // No image to draw
+
+ return;
+ }
+
// Get the the drawable region
CRect rect;
@@ -187,11 +194,11 @@ void CImage::drawContents(CGraphicsPort *port)
m_bitmap->setSelected(isClicked() || m_highlighted);
// This is the number of rows that we can draw at the top of the display
-
+
nxgl_coord_t nTopRows = m_bitmap->getHeight() - m_origin.y;
if (nTopRows > rect.getHeight())
{
- nTopRows = rect.getHeight();
+ nTopRows = rect.getHeight();
}
else if (nTopRows < 0)
{
@@ -214,7 +221,7 @@ void CImage::drawContents(CGraphicsPort *port)
// the display
nxgl_coord_t nLeftPixels = m_bitmap->getWidth() - m_origin.x;
-
+
// This is the number of rows that we have to pad on the right if the display
// width is wider than the image width
@@ -257,7 +264,7 @@ void CImage::drawContents(CGraphicsPort *port)
// Replace any transparent pixels with the background color.
// Then we can use the faster opaque drawBitmap() function.
-
+
ptr = buffer;
for (int i = 0; i < nLeftPixels; i++, ptr++)
{
@@ -337,12 +344,12 @@ void CImage::drawBorder(CGraphicsPort *port)
{
return;
}
-
+
// Work out which colors to use
nxgl_coord_t color1;
nxgl_coord_t color2;
-
+
if (isClicked())
{
// Bevelled into the screen
@@ -357,7 +364,7 @@ void CImage::drawBorder(CGraphicsPort *port)
color1 = getShineEdgeColor();
color2 = getShadowEdgeColor();
}
-
+
port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2);
}
@@ -389,7 +396,7 @@ void CImage::onClick(nxgl_coord_t x, nxgl_coord_t y)
}
/**
- * Raises an action.
+ * Raises an action.
*
* @param x The x coordinate of the mouse.
* @param y The y coordinate of the mouse.
diff --git a/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx b/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
index 94caac5fd..df060f037 100644
--- a/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
+++ b/NxWidgets/libnxwidgets/src/cmultilinetextbox.cxx
@@ -1261,8 +1261,8 @@ void CMultiLineTextBox::drawRow(CGraphicsPort *port, int row)
uint8_t rowLength = m_text->getLineTrimmedLength(row);
struct nxgl_point_s pos;
- pos.x = getRowX(row) + m_canvasX;
- pos.y = getRowY(row) + m_canvasY;
+ pos.x = getRowX(row) + m_canvasX + rect.getX();
+ pos.y = getRowY(row) + m_canvasY + rect.getY();
// Determine the background and text color
diff --git a/NxWidgets/libnxwidgets/src/cnxtimer.cxx b/NxWidgets/libnxwidgets/src/cnxtimer.cxx
index d663df036..d67cee6e8 100644
--- a/NxWidgets/libnxwidgets/src/cnxtimer.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxtimer.cxx
@@ -193,16 +193,16 @@ void CNxTimer::workQueueCallback(FAR void *arg)
This->m_isRunning = false;
- // Raise the action event.
-
- This->m_widgetEventHandlers->raiseActionEvent();
-
// Restart the timer if this is a repeating timer
if (This->m_isRepeater)
{
This->start();
}
+
+ // Raise the action event.
+
+ This->m_widgetEventHandlers->raiseActionEvent();
}
diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
index 644abd714..2cb1a930d 100644
--- a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
+++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
@@ -1,7 +1,7 @@
/****************************************************************************
* NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -117,6 +117,7 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
sem_init(&m_waitSem, 0, 0);
#endif
#ifdef CONFIG_NX_MULTIUSER
+ sem_init(&m_boundsSem, 0, 0);
sem_init(&m_geoSem, 0, 0);
#endif
@@ -135,12 +136,11 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
copyWidgetStyle(&m_style, style);
}
}
-
/**
* Destructor.
*/
-
+
CWidgetControl::~CWidgetControl(void)
{
// Notify any external waiters... this should not happen because it
@@ -235,7 +235,7 @@ void CWidgetControl::postWindowEvent(void)
* all widgets in the window.
* @return True means some interesting event occurred
*/
-
+
bool CWidgetControl::pollEvents(CNxWidget *widget)
{
// Delete any queued widgets
@@ -299,7 +299,7 @@ void CWidgetControl::removeControlledWidget(CNxWidget *widget)
*
* @param widget The widget to add to the delete queue.
*/
-
+
void CWidgetControl::addToDeleteQueue(CNxWidget *widget)
{
// Add the widget to the delete queue
@@ -330,7 +330,7 @@ void CWidgetControl::setClickedWidget(CNxWidget *widget)
m_clickedWidget->release(m_clickedWidget->getX() - 10, 0);
}
-
+
// Update the pointer
m_clickedWidget = widget;
@@ -394,18 +394,19 @@ void CWidgetControl::geometryEvent(NXHANDLE hWindow,
if (!m_hWindow)
{
// Save one-time server specific information
-
+
m_hWindow = hWindow;
nxgl_rectcopy(&m_bounds, bounds);
+ giveBoundsSem();
}
// 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.
+ // becomes nonzero (or actually over 1).
- if (!m_haveGeometry && size->h > 0 && size->w > 0)
+ if (!m_haveGeometry && size->h > 1 && size->w > 1)
{
// Wake up any threads waiting for initial position information.
// REVISIT: If the window is moved or repositioned, then the
@@ -619,7 +620,7 @@ void CWidgetControl::newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr)
*
* @param cursorControl The cursor control code received.
*/
-
+
void CWidgetControl::newCursorControlEvent(ECursorControl cursorControl)
{
// Append the new cursor control
@@ -688,7 +689,7 @@ void CWidgetControl::copyWidgetStyle(CWidgetStyle *dest, const CWidgetStyle *src
* @param tp A time in the past from which to compute the elapsed time.
* @return The elapsed time since tp
*/
-
+
uint32_t CWidgetControl::elapsedTime(FAR const struct timespec *startTime)
{
struct timespec endTime;
@@ -701,7 +702,7 @@ uint32_t CWidgetControl::elapsedTime(FAR const struct timespec *startTime)
uint32_t seconds = endTime.tv_sec - startTime->tv_sec;
// Get the elapsed nanoseconds, borrowing from the seconds if necessary
-
+
int32_t endNanoSeconds = endTime.tv_nsec;
if (startTime->tv_nsec > endNanoSeconds)
{
@@ -767,7 +768,7 @@ void CWidgetControl::handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *
/**
* Delete any widgets in the deletion queue.
*/
-
+
void CWidgetControl::processDeleteQueue(void)
{
int i = 0;
@@ -917,6 +918,25 @@ void CWidgetControl::takeGeoSem(void)
#endif
/**
+ * Take the bounds semaphore (handling signal interruptions)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CWidgetControl::takeBoundsSem(void)
+{
+ // Take the bounds semaphore. Retry is an error occurs (only if
+ // the error is due to a signal interruption).
+
+ int ret;
+ do
+ {
+ ret = sem_wait(&m_boundsSem);
+ }
+ while (ret < 0 && errno == EINTR);
+}
+#endif
+
+/**
* Clear all mouse events
*/