From 1b928ea22fbe5e63c5fbfd9a9051eb40512a6665 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 17 Jul 2014 12:12:02 -0600 Subject: 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 --- .../include/cglyphsliderhorizontal.hxx | 11 +++-- NxWidgets/libnxwidgets/include/cnxwidget.hxx | 2 +- .../libnxwidgets/src/cglyphsliderhorizontal.cxx | 48 ++++++++++++++++------ NxWidgets/libnxwidgets/src/cnxwidget.cxx | 28 ++++++------- 4 files changed, 57 insertions(+), 32 deletions(-) (limited to 'NxWidgets/libnxwidgets') diff --git a/NxWidgets/libnxwidgets/include/cglyphsliderhorizontal.hxx b/NxWidgets/libnxwidgets/include/cglyphsliderhorizontal.hxx index 354a097ac..6d23237b7 100644 --- a/NxWidgets/libnxwidgets/include/cglyphsliderhorizontal.hxx +++ b/NxWidgets/libnxwidgets/include/cglyphsliderhorizontal.hxx @@ -174,16 +174,19 @@ namespace NXWidgets /** * Constructor. * - * @param pWidgetControl The widget control instance for the window. + * @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(CWidgetControl *pWidgetControl, + CGlyphSliderHorizontal(CWidgetControl *control, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, - nxgl_coord_t height, IBitmap *pGripBitmap, + nxgl_coord_t thickness, IBitmap *gripBitmap, nxwidget_pixel_t fillColor, bool fill = true); /** diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx index 543c0b24b..a67938d48 100644 --- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx @@ -170,7 +170,7 @@ namespace NXWidgets protected: CWidgetControl *m_widgetControl; /**< The controlling widget for the display */ - CRect m_rect; /**< Rectange bounding the widget. */ + CRect m_rect; /**< Rectangle bounding the widget. */ // Dragging variables 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 #include +#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); } /** -- cgit v1.2.3