aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorJames Brown2002-07-08 13:52:50 +0000
committerJames Brown2002-07-08 13:52:50 +0000
commit7be66a5f0531a6bf183ee53a6d5b575d3815261e (patch)
treecd9685d9514ca567b9d0d8db0e8b4d01feddebbe /gui/widget.cpp
parent0ea6fac17425829dedb940597d0d461407dbb6ad (diff)
downloadscummvm-rg350-7be66a5f0531a6bf183ee53a6d5b575d3815261e.tar.gz
scummvm-rg350-7be66a5f0531a6bf183ee53a6d5b575d3815261e.tar.bz2
scummvm-rg350-7be66a5f0531a6bf183ee53a6d5b575d3815261e.zip
Add slider widget
svn-id: r4496
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index cb3fce0ed5..dc65a1422a 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -153,3 +153,33 @@ void CheckboxWidget::drawWidget(bool hilite)
// Finally draw the label
gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor);
}
+
+#pragma mark -
+SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey)
+{
+ _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
+ _type = kSliderWidget;
+}
+
+void SliderWidget::drawWidget(bool hilite)
+{
+ NewGui *gui = _boss->getGui();
+
+ // Draw the box
+ gui->box(_x, _y, _w, _h);
+
+ // Draw the 'bar'
+ gui->line(_x + 2 + ((_w - 5)* _value / 100), _y + 2, _x + 2 + ((_w - 5)* _value / 100), _y + _h - 3, hilite ? gui->_textcolorhi : gui->_textcolor);
+}
+
+void SliderWidget::handleMouseMoved(int x, int y, int state) {
+ if (state == 1) {
+ int newvalue = x * 100 / _w;
+
+ if (newvalue != _value) {
+ _value = newvalue;
+ setFlags(WIDGET_CLEARBG); draw(); clearFlags(WIDGET_CLEARBG);
+ }
+ }
+} \ No newline at end of file