aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-07-12 16:24:11 +0000
committerMax Horn2002-07-12 16:24:11 +0000
commite34571dca90689bd7367697c842927994a38d62d (patch)
tree017bb4761fc65a9b517c2f08a45d17a20bd6a813 /gui/widget.cpp
parentc99d9a57c0e6d3d24c3f6c51c50612a228f17158 (diff)
downloadscummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.gz
scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.tar.bz2
scummvm-rg350-e34571dca90689bd7367697c842927994a38d62d.zip
Countless changes to the New GUI; some hightligths: new ScrollBarWidget class; ListWidget is usable (demo shows it off); added custom String/StringList classes
svn-id: r4521
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 82e98f7989..f170ddadc2 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -44,7 +44,7 @@ void Widget::draw()
_y += _boss->_y;
// Clear background (unless alpha blending is enabled)
- if (_flags & WIDGET_CLEARBG && !_boss->_screenBuf)
+ if (_flags & WIDGET_CLEARBG)
gui->fillRect(_x, _y, _w, _h, gui->_bgcolor);
// Draw border
@@ -74,37 +74,37 @@ void Widget::draw()
StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text)
- : Widget (boss, x, y, w, h), _text(0)
+ : Widget (boss, x, y, w, h), _label(0)
{
_type = kStaticTextWidget;
- setText(text);
+ setLabel(text);
}
StaticTextWidget::~StaticTextWidget()
{
- if (_text) {
- free(_text);
- _text = 0;
+ if (_label) {
+ free(_label);
+ _label = 0;
}
}
-void StaticTextWidget::setText(const char *text)
+void StaticTextWidget::setLabel(const char *label)
{
- // Free old text if any
- if (_text)
- free(_text);
+ // Free old label if any
+ if (_label)
+ free(_label);
- // Duplicate new text
- if (text)
- _text = strdup(text);
+ // Duplicate new label
+ if (label)
+ _label = strdup(label);
else
- _text = 0;
+ _label = 0;
}
void StaticTextWidget::drawWidget(bool hilite)
{
NewGui *gui = _boss->getGui();
- gui->drawString(_text, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor);
}
@@ -112,18 +112,26 @@ void StaticTextWidget::drawWidget(bool hilite)
ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
- : StaticTextWidget(boss, x, y, w, h, label), _cmd(cmd), _hotkey(hotkey)
+ : StaticTextWidget(boss, x, y, w, h, label), CommandSender(boss), _cmd(cmd), _hotkey(hotkey)
{
+ assert(label);
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ;
_type = kButtonWidget;
}
-void ButtonWidget::handleClick(int button)
+ButtonWidget::~ButtonWidget()
{
- if (_flags & WIDGET_ENABLED && _cmd)
- _boss->handleCommand(_cmd);
+ if (_label) {
+ free(_label);
+ _label = 0;
+ }
}
+void ButtonWidget::handleClick(int x, int y, int button)
+{
+ if (_flags & WIDGET_ENABLED)
+ sendCommand(_cmd, 0);
+}
#pragma mark -
@@ -147,13 +155,12 @@ CheckboxWidget::CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const c
_type = kCheckboxWidget;
}
-void CheckboxWidget::handleClick(int button)
+void CheckboxWidget::handleClick(int x, int y, int button)
{
if (_flags & WIDGET_ENABLED) {
_state = !_state;
draw();
- if (_cmd)
- _boss->handleCommand(_cmd);
+ sendCommand(_cmd, 0);
}
}
@@ -171,7 +178,7 @@ void CheckboxWidget::drawWidget(bool hilite)
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
// Finally draw the label
- gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor);
+ gui->drawString(_label, _x + 20, _y + 3, _w, gui->_textcolor);
}
#pragma mark -