Patches from Petteri Aimonen + stdbool and rand() changes for Freddie Chopin

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5415 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-12-07 16:00:56 +00:00
parent e9d2baa274
commit 0dbe3858ea
4 changed files with 47 additions and 11 deletions

View File

@ -213,4 +213,8 @@
Submitted by Petteri Aimonen.
* NxWidgets:CText and NxWidgets:CNumericEdite: Fix some memory freeing bugs
(from Petteri Aimonen).
* NxWidgets::CScrollingPanel: Usability improvements. It is borderless for now,
because there was no easy way to redraw only the required part of the border.
Contributed by Petteri Aimonen.
* NxWidgets::CNxWidgets and NxWM::CStartWindow: Small changes to make sub-
classing easier (from Petteri Aimonen).

View File

@ -1058,7 +1058,7 @@ namespace NXWidgets
* @return True if the click was successful.
*/
bool click(nxgl_coord_t x, nxgl_coord_t y);
virtual bool click(nxgl_coord_t x, nxgl_coord_t y);
/**
* Check if the click is a double-click.

View File

@ -70,11 +70,12 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include "cwidgetcontrol.hxx"
#include "cscrollingpanel.hxx"
@ -113,6 +114,13 @@ CScrollingPanel::CScrollingPanel(CWidgetControl *pWidgetControl,
: CNxWidget(pWidgetControl, x, y, width, height, flags, style)
{
m_widgetControl = pWidgetControl;
// NOTE: CScrollingPanel is temporarily borderless because there was no
// easy way to redraw only the required part of the border.
m_flags.permeable = true;
m_flags.borderless = true;
CRect rect;
getClientRect(rect);
@ -120,12 +128,10 @@ CScrollingPanel::CScrollingPanel(CWidgetControl *pWidgetControl,
m_canvasHeight = rect.getHeight();
m_canvasX = 0;
m_canvasY = 0;
setAllowsVerticalScroll(true);
setAllowsHorizontalScroll(true);
setContentScrolled(true);
m_flags.permeable = true;
}
/**
@ -186,6 +192,24 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy)
CGraphicsPort *port = m_widgetControl->getGraphicsPort();
port->move(getX(), getY(), dx, dy, rect.getWidth(), rect.getHeight());
if (dx > 0)
{
revealedRects.push_back(CRect(getX(), getY(), dx, rect.getHeight()));
}
else if (dx < 0)
{
revealedRects.push_back(CRect(getX() + rect.getWidth() + dx, getY(), -dx, rect.getHeight()));
}
if (dy > 0)
{
revealedRects.push_back(CRect(getX(), getY(), rect.getWidth(), dy));
}
else if (dy < 0)
{
revealedRects.push_back(CRect(getX(), getY() + rect.getHeight() + dy, rect.getWidth(), -dy));
}
// Adjust the scroll values
m_canvasY += dy;
@ -193,12 +217,20 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy)
if (revealedRects.size() > 0)
{
// Draw revealed sections
// Draw background to revealed sections
// Children will redraw themselves in moveTo.
for (int i = 0; i < revealedRects.size(); ++i)
{
drawBorder(port);
drawContents(port);
CRect &rrect = revealedRects[i];
gvdbg("Redrawing %d,%d,%d,%d after scroll\n",
rrect.getX(), rrect.getY(),
rrect.getWidth(), rrect.getHeight());
port->drawFilledRect(rrect.getX(), rrect.getY(),
rrect.getWidth(), rrect.getHeight(),
getBackgroundColor());
}
}
}

View File

@ -97,8 +97,8 @@ namespace NxWM
*/
class CStartWindow : public IApplication,
private IApplicationCallback,
private NXWidgets::CWidgetEventHandler
protected IApplicationCallback,
protected NXWidgets::CWidgetEventHandler
{
protected:
/**