diff options
author | Max Horn | 2002-10-19 01:22:41 +0000 |
---|---|---|
committer | Max Horn | 2002-10-19 01:22:41 +0000 |
commit | 7198181b093732592d678fc95c64698fe0470715 (patch) | |
tree | de94c24039a14ae90c575440fb47824ff887fd56 /gui/widget.cpp | |
parent | ee13e1638980f8503e8ea04cd676acf1f41197fc (diff) | |
download | scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.tar.gz scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.tar.bz2 scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.zip |
reworked the way the save/load dialog works. yup, still not perfect, but we're hopefully getting closer. Feedback welcome
svn-id: r5189
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r-- | gui/widget.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp index 463c0a7b3d..1451dce773 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -26,9 +26,7 @@ #ifdef _MSC_VER - # pragma warning( disable : 4068 ) // unknown pragma - #endif @@ -59,7 +57,7 @@ void Widget::draw() // Draw border if (_flags & WIDGET_BORDER) { - gui->box(_x, _y, _w, _h); + gui->box(_x, _y, _w, _h, (_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER); _x += 4; _y += 4; _w -= 8; @@ -111,9 +109,10 @@ void StaticTextWidget::drawWidget(bool hilite) ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey) - : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) + : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss), + _cmd(cmd), _hotkey(hotkey) { - _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ; + _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG; _type = kButtonWidget; } @@ -131,6 +130,27 @@ void ButtonWidget::drawWidget(bool hilite) hilite ? gui->_textcolorhi : gui->_textcolor, _align); } + +#pragma mark - + + +PushButtonWidget::PushButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey) + : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) +{ + _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG; + _type = kButtonWidget; +} + +void PushButtonWidget::setState(bool state) +{ + if (_state != state) { + _state = state; + _flags ^= WIDGET_INV_BORDER; + draw(); + } +} + + #pragma mark - @@ -147,17 +167,16 @@ static uint32 checked_img[8] = { }; CheckboxWidget::CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey) - : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) + : PushButtonWidget(boss, x, y, w, h, label, cmd, hotkey) { _flags = WIDGET_ENABLED; _type = kCheckboxWidget; } -void CheckboxWidget::handleMouseDown(int x, int y, int button, int clickCount) +void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) { - if (isEnabled()) { - _state = !_state; - draw(); + if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { + toggleState(); sendCommand(_cmd, 0); } } |