diff options
author | Max Horn | 2002-07-07 23:37:47 +0000 |
---|---|---|
committer | Max Horn | 2002-07-07 23:37:47 +0000 |
commit | c3b606cd9b0b0445b0360f9a95225186252ae1c1 (patch) | |
tree | 00b31845f07a89afb6f2bb425d3e2e7a478554e1 /gui/widget.cpp | |
parent | 10d86be56456b57392cca05d5a2135408289223c (diff) | |
download | scummvm-rg350-c3b606cd9b0b0445b0360f9a95225186252ae1c1.tar.gz scummvm-rg350-c3b606cd9b0b0445b0360f9a95225186252ae1c1.tar.bz2 scummvm-rg350-c3b606cd9b0b0445b0360f9a95225186252ae1c1.zip |
added CheckboxWidget; added NewGui::drawBitmap
svn-id: r4486
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r-- | gui/widget.cpp | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp index 0fbcfd20ba..38033a2d06 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -78,7 +78,7 @@ StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, con void StaticTextWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->_gui; + NewGui *gui = _boss->getGui(); gui->drawString(_text, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor); } @@ -94,6 +94,55 @@ ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char void ButtonWidget::handleClick(int button) { - if (_flags & WIDGET_ENABLED) + if (_flags & WIDGET_ENABLED && _cmd) _boss->handleCommand(_cmd); } + + +#pragma mark - + + +/* 8x8 checkbox bitmap */ +static uint32 checked_img[8] = { + 0x00000000, + 0x01000010, + 0x00100100, + 0x00011000, + 0x00011000, + 0x00100100, + 0x01000010, + 0x00000000, +}; + +CheckboxWidget::CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd) + : ButtonWidget(boss, x, y, w, h, label, cmd), _state(false) +{ + _flags = WIDGET_ENABLED; +} + +void CheckboxWidget::handleClick(int button) +{ + if (_flags & WIDGET_ENABLED) { + _state = !_state; + draw(); + if (_cmd) + _boss->handleCommand(_cmd); + } +} + +void CheckboxWidget::drawWidget(bool hilite) +{ + NewGui *gui = _boss->getGui(); + + // Draw the box + gui->box(_x, _y, 14, 14); + + // If checked, draw cross inside the box + if (_state) + gui->drawBitmap(checked_img, _x + 3, _y + 3, gui->_textcolor); + else + gui->clearArea(_x + 3, _y + 3, 8, 8); + + // Finally draw the label + gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor); +} |