From 11278c31a01b6fdfb09e2a3109a20d38ef793055 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 22 Apr 2013 08:01:43 -0600 Subject: [PATCH] Fixes to strchr, mkfats, and NxWidgets from Petteri Aimonen --- NxWidgets/ChangeLog.txt | 15 +++++++ NxWidgets/Kconfig | 6 +++ .../libnxwidgets/include/cglyphbutton.hxx | 17 ++++++-- NxWidgets/libnxwidgets/include/cnxtimer.hxx | 16 ++++--- NxWidgets/libnxwidgets/include/cnxwidget.hxx | 6 +-- .../libnxwidgets/include/cscrollbarpanel.hxx | 32 +++++++------- NxWidgets/libnxwidgets/src/cglyphbutton.cxx | 32 +++++++++----- .../libnxwidgets/src/cscrollbarpanel.cxx | 42 +++++++++---------- NxWidgets/nxwm/src/ctaskbar.cxx | 2 + NxWidgets/tools/bitmap_converter.py | 2 +- apps/NxWidgets/Kconfig | 6 +++ nuttx/ChangeLog | 5 +++ nuttx/fs/fat/fs_writefat.c | 2 +- nuttx/libc/string/lib_strchr.c | 7 +++- 14 files changed, 128 insertions(+), 62 deletions(-) diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index f5a5947b3..d1746a064 100644 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -329,3 +329,18 @@ From Petteri Aimonen. 1.7 2013-xx-xx Gregory Nutt + +* NxWidgets bitmap_converter.py: Fix bug when image width > 255. From + Petteri Aimonen (2013-4-22). +* NxWM::CScrollbarPanel: Fix spelling error in class name: CScollbarPanel + should be CScrollbarPanel. From Petteri Aimonen (2013-4-22). +* NxWidgets:: CGlyphButton: Generate action event, like CButton does. + From Petteri Aimonen (2013-4-22). +* NxWidgets:: CGlyphButton: Prevent drawing outside of the bitmap size. + From Petteri Aimonen (2013-4-22). +* NxWM::CTaskBar: Add option CONFIG_NXWM_TASKBAR_NO_BORDER to suppress + drawing of the border on the taskbar. From Petteri Aimonen (2013-4-22). +* NxWidgets::CNxTimer: Add function to check if CNxTimer is running. + From Petteri Aimonen (2013-4-22). +* NxWidgets::CNxWidgets: Allow overriding of the checkCollision() method. + From Petteri Aimonen (2013-4-22). diff --git a/NxWidgets/Kconfig b/NxWidgets/Kconfig index 6f5f3e924..efa56a06c 100644 --- a/NxWidgets/Kconfig +++ b/NxWidgets/Kconfig @@ -428,6 +428,12 @@ config NXWM_DISABLE_MINIMIZE windows. If the buttons are small, it's easy to hit minimize button accidentally when trying to close an application. +config NXWM_TASKBAR_NO_BORDER + bool "Suppress Taskbar border" + default n + ---help--- + Suppress drawing a the border around the taskbar. + comment "Tool Bar Configuration" config NXWM_CUSTOM_TOOLBAR_HEIGHT diff --git a/NxWidgets/libnxwidgets/include/cglyphbutton.hxx b/NxWidgets/libnxwidgets/include/cglyphbutton.hxx index aad348ca9..b4b1a5657 100644 --- a/NxWidgets/libnxwidgets/include/cglyphbutton.hxx +++ b/NxWidgets/libnxwidgets/include/cglyphbutton.hxx @@ -73,7 +73,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -87,11 +87,11 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ - + /**************************************************************************** * Implementation Classes ****************************************************************************/ - + #if defined(__cplusplus) namespace NXWidgets @@ -156,7 +156,16 @@ namespace NXWidgets virtual void onClick(nxgl_coord_t x, nxgl_coord_t y); /** - * Raises an action event and redraws the button. + * Raises an action event. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Raises a release event and redraws the button. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/include/cnxtimer.hxx b/NxWidgets/libnxwidgets/include/cnxtimer.hxx index d4715b378..ab3727de3 100644 --- a/NxWidgets/libnxwidgets/include/cnxtimer.hxx +++ b/NxWidgets/libnxwidgets/include/cnxtimer.hxx @@ -73,7 +73,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -87,11 +87,11 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ - + /**************************************************************************** * Implementation Classes ****************************************************************************/ - + #if defined(__cplusplus) namespace NXWidgets @@ -102,7 +102,7 @@ namespace NXWidgets * Timer widget. It can drive time-based events, animations, etc. * * Using the timer is simple: - * - Create an instance of the CNxTimer and add it as a child to a widget. + * - Create an instance of the CNxTimer and add it as a child to a widget. * - Call the instance's "start()" method. * - Catch the timer's action event and call any code that should run. */ @@ -169,6 +169,12 @@ namespace NXWidgets void stop(void); + /** + * Returns true if the timer is currently running. + */ + + inline bool isRunning() const { return m_isRunning; } + /** * Set the timeout of this timer. This timeout value will not * take effect until start() or reset() is called. @@ -181,7 +187,7 @@ namespace NXWidgets { m_timeout = timeout; } - + /** * Return the timeout of this timer. * diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx index a6982660b..f8c472e75 100644 --- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx @@ -1215,7 +1215,7 @@ namespace NXWidgets * @return True if a collision occurred. */ - bool checkCollision(nxgl_coord_t x, nxgl_coord_t y) const; + virtual bool checkCollision(nxgl_coord_t x, nxgl_coord_t y) const; /** * Checks if the supplied rectangle definition collides with this widget. @@ -1227,8 +1227,8 @@ namespace NXWidgets * @return True if a collision occurred. */ - bool checkCollision(nxgl_coord_t x, nxgl_coord_t y, - nxgl_coord_t width, nxgl_coord_t height) const; + virtual bool checkCollision(nxgl_coord_t x, nxgl_coord_t y, + nxgl_coord_t width, nxgl_coord_t height) const; /** * Checks if the supplied widget collides with this widget. diff --git a/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx b/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx index 08bdb721c..7f6bf1d32 100644 --- a/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx +++ b/NxWidgets/libnxwidgets/include/cscrollbarpanel.hxx @@ -73,7 +73,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -93,11 +93,11 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ - + /**************************************************************************** * Implementation Classes ****************************************************************************/ - + #if defined(__cplusplus) namespace NXWidgets @@ -105,8 +105,8 @@ namespace NXWidgets /** * Class containing a scrolling panel bordered by scrollbars. */ - class CScollbarPanel : public CNxWidget, public IScrollable, - public CWidgetEventHandler + class CScrollbarPanel : public CNxWidget, public IScrollable, + public CWidgetEventHandler { protected: CWidgetControl *m_widgetControl; /**< Widget control instance */ @@ -143,13 +143,13 @@ namespace NXWidgets * Destructor. */ - virtual ~CScollbarPanel(void) { } + virtual ~CScrollbarPanel(void) { } /** * Copy constructor is protected to prevent usage. */ - inline CScollbarPanel(const CScollbarPanel &scrollbarPanel) + inline CScrollbarPanel(const CScrollbarPanel &scrollbarPanel) : CNxWidget(scrollbarPanel) { } public: @@ -169,11 +169,11 @@ namespace NXWidgets * the style into its own internal style object. */ - CScollbarPanel(CWidgetControl *pWidgetControl, - nxgl_coord_t x, nxgl_coord_t y, - nxgl_coord_t width, nxgl_coord_t height, - uint32_t flags, - CWidgetStyle *style = (CWidgetStyle *)NULL); + CScrollbarPanel(CWidgetControl *pWidgetControl, + nxgl_coord_t x, nxgl_coord_t y, + nxgl_coord_t width, nxgl_coord_t height, + uint32_t flags, + CWidgetStyle *style = (CWidgetStyle *)NULL); /** * Scroll the panel by the specified amounts. @@ -183,7 +183,7 @@ namespace NXWidgets */ virtual void scroll(int32_t dx, int32_t dy); - + /** * Reposition the panel's scrolling region to the specified coordinates. * @@ -216,7 +216,7 @@ namespace NXWidgets */ virtual void setCanvasWidth(const int32_t width); - + /** * Sets the height of the virtual canvas. * @@ -248,7 +248,7 @@ namespace NXWidgets */ virtual const int32_t getCanvasX(void) const; - + /** * Gets the y coordinate of the virtual canvas. * @@ -264,7 +264,7 @@ namespace NXWidgets */ virtual const int32_t getCanvasWidth(void) const; - + /** * Gets the height of the virtual canvas. * diff --git a/NxWidgets/libnxwidgets/src/cglyphbutton.cxx b/NxWidgets/libnxwidgets/src/cglyphbutton.cxx index f24b5c943..6a2e521ed 100644 --- a/NxWidgets/libnxwidgets/src/cglyphbutton.cxx +++ b/NxWidgets/libnxwidgets/src/cglyphbutton.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -193,16 +193,16 @@ void CGlyphButton::drawContents(CGraphicsPort *port) if (isEnabled()) { - port->drawBitmap(rect.getX(), rect.getY(), - rect.getWidth(), rect.getHeight(), - bitmap, m_bitmapX, m_bitmapY, + port->drawBitmap(rect.getX() + m_bitmapX, rect.getY() + m_bitmapY, + bitmap->width, bitmap->height, + bitmap, 0, 0, CONFIG_NXWIDGETS_TRANSPARENT_COLOR); } else { - port->drawBitmapGreyScale(rect.getX(), rect.getY(), - rect.getWidth(), rect.getHeight(), - bitmap, m_bitmapX, m_bitmapY); + port->drawBitmapGreyScale(rect.getX() + m_bitmapX, rect.getY() + m_bitmapY, + bitmap->width, bitmap->height, + bitmap, 0, 0); } } @@ -237,7 +237,7 @@ void CGlyphButton::drawOutline(CGraphicsPort *port) nxgl_coord_t color1; nxgl_coord_t color2; - + if (isClicked()) { // Bevelled into the screen @@ -252,7 +252,7 @@ void CGlyphButton::drawOutline(CGraphicsPort *port) color1 = getShineEdgeColor(); color2 = getShadowEdgeColor(); } - + port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2); @@ -272,7 +272,19 @@ void CGlyphButton::onClick(nxgl_coord_t x, nxgl_coord_t y) } /** - * Raises an action event and redraws the button. + * Raises an action event. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CGlyphButton::onPreRelease(nxgl_coord_t x, nxgl_coord_t y) +{ + m_widgetEventHandlers->raiseActionEvent(); +} + +/** + * Raises a release event and redraws the button. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx b/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx index f21cd7766..4202ab749 100644 --- a/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx +++ b/NxWidgets/libnxwidgets/src/cscrollbarpanel.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -104,10 +104,10 @@ using namespace NXWidgets; * the style into its own internal style object. */ -CScollbarPanel::CScollbarPanel(CWidgetControl *pWidgetControl, - nxgl_coord_t x, nxgl_coord_t y, - nxgl_coord_t width, nxgl_coord_t height, - uint32_t flags, CWidgetStyle *style) +CScrollbarPanel::CScrollbarPanel(CWidgetControl *pWidgetControl, + nxgl_coord_t x, nxgl_coord_t y, + nxgl_coord_t width, nxgl_coord_t height, + uint32_t flags, CWidgetStyle *style) : CNxWidget(pWidgetControl, x, y, width, height, flags, style) { m_scrollbarWidth = 10; @@ -136,7 +136,7 @@ CScollbarPanel::CScollbarPanel(CWidgetControl *pWidgetControl, * @param dy The vertical distance to scroll. */ -void CScollbarPanel::scroll(int32_t dx, int32_t dy) +void CScrollbarPanel::scroll(int32_t dx, int32_t dy) { m_panel->scroll(dx, dy); } @@ -148,7 +148,7 @@ void CScollbarPanel::scroll(int32_t dx, int32_t dy) * @param y The new y coordinate of the scrolling region. */ -void CScollbarPanel::jump(int32_t x, int32_t y) +void CScrollbarPanel::jump(int32_t x, int32_t y) { m_panel->jump(x, y); } @@ -159,7 +159,7 @@ void CScollbarPanel::jump(int32_t x, int32_t y) * @param allow True to allow horizontal scrolling; false to deny it. */ -void CScollbarPanel::setAllowsVerticalScroll(bool allow) +void CScrollbarPanel::setAllowsVerticalScroll(bool allow) { m_panel->setAllowsVerticalScroll(allow); @@ -182,7 +182,7 @@ void CScollbarPanel::setAllowsVerticalScroll(bool allow) * @param allow True to allow horizontal scrolling; false to deny it. */ -void CScollbarPanel::setAllowsHorizontalScroll(bool allow) +void CScrollbarPanel::setAllowsHorizontalScroll(bool allow) { m_panel->setAllowsHorizontalScroll(allow); @@ -205,7 +205,7 @@ void CScollbarPanel::setAllowsHorizontalScroll(bool allow) * @param width The width of the virtual canvas. */ -void CScollbarPanel::setCanvasWidth(const int32_t width) +void CScrollbarPanel::setCanvasWidth(const int32_t width) { m_panel->setCanvasWidth(width); m_scrollbarHorizontal->setMaximumValue(width); @@ -217,7 +217,7 @@ void CScollbarPanel::setCanvasWidth(const int32_t width) * @param height The height of the virtual canvas. */ -void CScollbarPanel::setCanvasHeight(const int32_t height) +void CScrollbarPanel::setCanvasHeight(const int32_t height) { m_panel->setCanvasHeight(height); m_scrollbarVertical->setMaximumValue(height); @@ -229,7 +229,7 @@ void CScollbarPanel::setCanvasHeight(const int32_t height) * @return True if vertical scrolling is allowed. */ -bool CScollbarPanel::allowsVerticalScroll(void) const +bool CScrollbarPanel::allowsVerticalScroll(void) const { return m_panel->allowsVerticalScroll(); } @@ -240,7 +240,7 @@ bool CScollbarPanel::allowsVerticalScroll(void) const * @return True if horizontal scrolling is allowed. */ -bool CScollbarPanel::allowsHorizontalScroll(void) const +bool CScrollbarPanel::allowsHorizontalScroll(void) const { return m_panel->allowsHorizontalScroll(); } @@ -251,7 +251,7 @@ bool CScollbarPanel::allowsHorizontalScroll(void) const * @return The x coordinate of the virtual canvas. */ -const int32_t CScollbarPanel::getCanvasX(void) const +const int32_t CScrollbarPanel::getCanvasX(void) const { return m_panel->getCanvasX(); } @@ -262,7 +262,7 @@ const int32_t CScollbarPanel::getCanvasX(void) const * @return The y coordinate of the virtual canvas. */ -const int32_t CScollbarPanel::getCanvasY(void) const +const int32_t CScrollbarPanel::getCanvasY(void) const { return m_panel->getCanvasY(); } @@ -273,7 +273,7 @@ const int32_t CScollbarPanel::getCanvasY(void) const * @return The width of the virtual canvas. */ -const int32_t CScollbarPanel::getCanvasWidth(void) const +const int32_t CScrollbarPanel::getCanvasWidth(void) const { return m_panel->getCanvasWidth(); } @@ -284,7 +284,7 @@ const int32_t CScollbarPanel::getCanvasWidth(void) const * @return The height of the virtual canvas. */ -const int32_t CScollbarPanel::getCanvasHeight(void) const +const int32_t CScrollbarPanel::getCanvasHeight(void) const { return m_panel->getCanvasHeight(); } @@ -295,7 +295,7 @@ const int32_t CScollbarPanel::getCanvasHeight(void) const * @param e The event data. */ -void CScollbarPanel::handleScrollEvent(const CWidgetEventArgs &e) +void CScrollbarPanel::handleScrollEvent(const CWidgetEventArgs &e) { if (e.getSource() != NULL) { @@ -323,7 +323,7 @@ void CScollbarPanel::handleScrollEvent(const CWidgetEventArgs &e) * @param e The event data. */ -void CScollbarPanel::handleValueChangeEvent(const CWidgetEventArgs &e) +void CScrollbarPanel::handleValueChangeEvent(const CWidgetEventArgs &e) { if (e.getSource() != NULL) { @@ -352,7 +352,7 @@ void CScollbarPanel::handleValueChangeEvent(const CWidgetEventArgs &e) * Creates the child widgets. */ -void CScollbarPanel::buildUI(void) +void CScrollbarPanel::buildUI(void) { CRect rect; getClientRect(rect); @@ -432,7 +432,7 @@ void CScollbarPanel::buildUI(void) * @see redraw() */ -void CScollbarPanel::drawContents(CGraphicsPort *port) +void CScrollbarPanel::drawContents(CGraphicsPort *port) { port->drawFilledRect(0, 0, getWidth(), getHeight(), getBackgroundColor()); } diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index 93c38ed98..226ebe7bb 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -1112,11 +1112,13 @@ bool CTaskbar::redrawTaskbarWindow(void) port->drawFilledRect(0, 0, windowSize.w, windowSize.h, CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR); +#ifndef CONFIG_NXWM_TASKBAR_NO_BORDER // Add a border to the task bar to delineate it from the background window port->drawBevelledRect(0, 0, windowSize.w, windowSize.h, CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR, CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR); +#endif // Begin adding icons in the upper left corner diff --git a/NxWidgets/tools/bitmap_converter.py b/NxWidgets/tools/bitmap_converter.py index 1c5337741..714be3ae6 100755 --- a/NxWidgets/tools/bitmap_converter.py +++ b/NxWidgets/tools/bitmap_converter.py @@ -64,7 +64,7 @@ def encode_row(img, palette, y): for x in range(0, img.size[0]): c = quantize(img.getpixel((x, y)), palette) - if c == color: + if c == color and repeats < 255: repeats += 1 else: if color is not None: diff --git a/apps/NxWidgets/Kconfig b/apps/NxWidgets/Kconfig index 6f5f3e924..efa56a06c 100644 --- a/apps/NxWidgets/Kconfig +++ b/apps/NxWidgets/Kconfig @@ -428,6 +428,12 @@ config NXWM_DISABLE_MINIMIZE windows. If the buttons are small, it's easy to hit minimize button accidentally when trying to close an application. +config NXWM_TASKBAR_NO_BORDER + bool "Suppress Taskbar border" + default n + ---help--- + Suppress drawing a the border around the taskbar. + comment "Tool Bar Configuration" config NXWM_CUSTOM_TOOLBAR_HEIGHT diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0216356ea..ff18c5515 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -4581,3 +4581,8 @@ variables with auto-generated documentation. The initial checkin is an incomplete, poorly structured prototype that I hope to evolve into a useful tool (2014-4-20). + * libc/string/lib_strchr.c: strchr(str, '\0') should return a + pointer to the end of the string, not NULL. From Petteri + Aimonen (2014-4-22). + * fs/fat/fs_writefat.c: mkfatfs was writing the boot code to the + wrong location. From Petteri Aimonen (2014-4-22). diff --git a/nuttx/fs/fat/fs_writefat.c b/nuttx/fs/fat/fs_writefat.c index 564be5b50..1d58db5f2 100644 --- a/nuttx/fs/fat/fs_writefat.c +++ b/nuttx/fs/fat/fs_writefat.c @@ -212,7 +212,7 @@ static inline void mkfatfs_initmbr(FAR struct fat_format_s *fmt, /* Boot code may be placed in the remainder of the sector */ - memcpy(&var->fv_sect[BS16_BOOTCODE], var->fv_bootcode, var->fv_bootcodesize); + memcpy(&var->fv_sect[BS32_BOOTCODE], var->fv_bootcode, var->fv_bootcodesize); } /* The magic bytes at the end of the MBR are common to FAT12/16/32 */ diff --git a/nuttx/libc/string/lib_strchr.c b/nuttx/libc/string/lib_strchr.c index e6af56eee..7d7cf3757 100644 --- a/nuttx/libc/string/lib_strchr.c +++ b/nuttx/libc/string/lib_strchr.c @@ -64,12 +64,17 @@ FAR char *strchr(FAR const char *s, int c) { if (s) { - for (; *s; s++) + for (; ; s++) { if (*s == c) { return (FAR char *)s; } + + if (!*s) + { + break; + } } }