aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-07-08 22:11:47 +0000
committerMax Horn2002-07-08 22:11:47 +0000
commit0a9baabbdc173f772c4278b1f5c90f59121d4ee9 (patch)
treec09de90e88d5062603d71f59399192a71ff56e17 /gui/widget.cpp
parent5fa2ab9e006e041e78b966ec5baa42872e69114f (diff)
downloadscummvm-rg350-0a9baabbdc173f772c4278b1f5c90f59121d4ee9.tar.gz
scummvm-rg350-0a9baabbdc173f772c4278b1f5c90f59121d4ee9.tar.bz2
scummvm-rg350-0a9baabbdc173f772c4278b1f5c90f59121d4ee9.zip
replaced clearArea with the more general fillArea; added get/setValue methods to SliderWidget; changed look of SliderWidget a little bit; optimized drawing of SliderWidget
svn-id: r4500
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index dc65a1422a..510eb8428b 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -45,7 +45,7 @@ void Widget::draw()
// Clear background
if (_flags & WIDGET_CLEARBG)
- gui->clearArea(_x, _y, _w, _h);
+ gui->fillArea(_x, _y, _w, _h, gui->_bgcolor);
// Draw border
if (_flags & WIDGET_BORDER) {
@@ -148,15 +148,16 @@ void CheckboxWidget::drawWidget(bool hilite)
if (_state)
gui->drawBitmap(checked_img, _x + 3, _y + 3, gui->_textcolor);
else
- gui->clearArea(_x + 3, _y + 3, 8, 8);
+ gui->fillArea(_x + 3, _y + 3, 8, 8, gui->_bgcolor);
// 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)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _value(0), _old_value(1)
{
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
_type = kSliderWidget;
@@ -168,9 +169,15 @@ void SliderWidget::drawWidget(bool hilite)
// Draw the box
gui->box(_x, _y, _w, _h);
+
+ // Remove old 'bar' if necessary
+ if (_value != _old_value) {
+ gui->fillArea(_x + 2 + ((_w - 5) * _old_value / 100), _y + 2, 2, _h - 4, gui->_bgcolor);
+ _old_value = _value;
+ }
// 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);
+ gui->fillArea(_x + 2 + ((_w - 5) * _value / 100), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
}
void SliderWidget::handleMouseMoved(int x, int y, int state) {
@@ -179,7 +186,7 @@ void SliderWidget::handleMouseMoved(int x, int y, int state) {
if (newvalue != _value) {
_value = newvalue;
- setFlags(WIDGET_CLEARBG); draw(); clearFlags(WIDGET_CLEARBG);
+ draw();
}
}
-} \ No newline at end of file
+}