diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-17 12:12:02 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-17 12:12:02 -0600 |
commit | 1b928ea22fbe5e63c5fbfd9a9051eb40512a6665 (patch) | |
tree | bee9856ea642e60a428dca6d2cdf692370b49792 /NxWidgets/libnxwidgets/src | |
parent | 3898201b9416c1fc1a828270fe8ce12d7861cd71 (diff) | |
download | nuttx-1b928ea22fbe5e63c5fbfd9a9051eb40512a6665.tar.gz nuttx-1b928ea22fbe5e63c5fbfd9a9051eb40512a6665.tar.bz2 nuttx-1b928ea22fbe5e63c5fbfd9a9051eb40512a6665.zip |
NxWidgets::CGlyphSliderHorizontal: No longer uses a hard-coded slider height; the slider height is now provided as a parameter, replacing the widget height which is now calculated from the glip image height
Diffstat (limited to 'NxWidgets/libnxwidgets/src')
-rw-r--r-- | NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx | 48 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cnxwidget.cxx | 28 |
2 files changed, 49 insertions, 27 deletions
diff --git a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx index da7150ef7..0d6238a39 100644 --- a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx +++ b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx @@ -79,6 +79,7 @@ #include <cstdint> #include <cstdbool> +#include "ibitmap.hxx" #include "cwidgetcontrol.hxx" #include "cglyphsliderhorizontal.hxx" #include "cglyphsliderhorizontalgrip.hxx" @@ -98,20 +99,24 @@ using namespace NXWidgets; /** * Constructor. * - * @param pWidgetControl The controlling widget for the display + * @param control The widget control instance for the window. * @param x The x coordinate of the slider, relative to its parent. * @param y The y coordinate of the slider, relative to its parent. * @param width The width of the slider. - * @param height The height of the slider. + * @param thickness The thickness of the slider. + * @param gripBitmap The slider grip image + * @param fillColor The color to use when filling the grip + * @param fill True: The grip will be filled with fillColor */ -CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl, - nxgl_coord_t x, nxgl_coord_t y, - nxgl_coord_t width, nxgl_coord_t height, - IBitmap * pGripBitmap, - nxwidget_pixel_t fillColor, bool fill) -:CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE) +CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl *control, + nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, + nxgl_coord_t thickness, IBitmap *gripBitmap, + nxwidget_pixel_t fillColor, bool fill) +:CNxWidget(control, x, y, width, thickness, WIDGET_DRAGGABLE) { + // Initialize state data + m_minimumValue = 0; m_maximumValue = 0; m_contentSize = 0; @@ -120,22 +125,39 @@ CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl, m_pageSize = 1; m_fillColor = fillColor; m_fill = fill; - m_barThickness = 8; + m_barThickness = thickness; + + // Correct the height of the widget. The widget height was initially set + // to the thickness of the grip. But the grip image is normally a little + // taller than the slider is thick. + // + // Do use the resize method here; we are not ready for the resize events. + + nxgl_coord_t gripHeight = gripBitmap->getHeight() + 4; + if (gripHeight > thickness) + { + // Reset the widget height to the height of the grip image + + m_rect.setHeight(gripHeight); + } + + // Set widget attributes m_flags.permeable = false; m_flags.borderless = false; m_flags.doubleClickable = false; - // Create grip + // Set the "gutter" width CRect rect; getClientRect(rect); m_gutterWidth = rect.getWidth(); - // Create grip + // Create the grip - m_grip = new CGlyphSliderHorizontalGrip(pWidgetControl, x, y, - width, height, pGripBitmap); + m_grip = new CGlyphSliderHorizontalGrip(control, x, y, + gripBitmap->getWidth() + 4, + gripHeight, gripBitmap); m_grip->setBorderless(true); m_grip->addWidgetEventHandler(this); addWidget(m_grip); diff --git a/NxWidgets/libnxwidgets/src/cnxwidget.cxx b/NxWidgets/libnxwidgets/src/cnxwidget.cxx index c0c406dde..6d6ddb7b8 100644 --- a/NxWidgets/libnxwidgets/src/cnxwidget.cxx +++ b/NxWidgets/libnxwidgets/src/cnxwidget.cxx @@ -158,10 +158,10 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl, // Dragging values - m_grabPointX = 0; - m_grabPointY = 0; - m_newX = 0; - m_newY = 0; + m_grabPointX = 0; + m_grabPointY = 0; + m_newX = 0; + m_newY = 0; // Set initial flag values @@ -177,24 +177,24 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl, // Set hierarchy pointers - m_parent = (CNxWidget *)NULL; - m_focusedChild = (CNxWidget *)NULL; + m_parent = (CNxWidget *)NULL; + m_focusedChild = (CNxWidget *)NULL; // Double-click clock_gettime(CLOCK_REALTIME, &m_lastClickTime); - m_lastClickX = 0; - m_lastClickY = 0; - m_doubleClickBounds = DOUBLE_CLICK_BOUNDS; + m_lastClickX = 0; + m_lastClickY = 0; + m_doubleClickBounds = DOUBLE_CLICK_BOUNDS; // Set border size to 1 line - m_borderSize.top = 1; - m_borderSize.right = 1; - m_borderSize.bottom = 1; - m_borderSize.left = 1; + m_borderSize.top = 1; + m_borderSize.right = 1; + m_borderSize.bottom = 1; + m_borderSize.left = 1; - m_widgetEventHandlers = new CWidgetEventHandlerList(this); + m_widgetEventHandlers = new CWidgetEventHandlerList(this); } /** |