diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/dialog.cpp | 16 | ||||
-rw-r--r-- | gui/dialog.h | 4 | ||||
-rw-r--r-- | gui/launcher.cpp | 6 | ||||
-rw-r--r-- | gui/message.cpp | 2 | ||||
-rw-r--r-- | gui/widget.cpp | 12 | ||||
-rw-r--r-- | gui/widget.h | 10 |
6 files changed, 39 insertions, 11 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 95df03f1db..31d980f8dd 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -38,6 +38,18 @@ * ... */ +Dialog::~Dialog() +{ + Widget *w = _firstWidget, *next; + while (w) { + next = w->_next; + w->_next = 0; + delete w; + w = next; + } + _firstWidget = 0; +} + void Dialog::open() { Widget *w = _firstWidget; @@ -243,8 +255,8 @@ Widget *Dialog::findWidget(int x, int y) return w; } -Widget *Dialog::addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey) +Widget *Dialog::addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey) { - return new ButtonWidget(this, x, y, w, h, label, cmd, hotkey); + return new ButtonWidget(this, x, y, 54, 16, label, cmd, hotkey); } diff --git a/gui/dialog.h b/gui/dialog.h index 0611b22ead..509ae6d385 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -48,7 +48,7 @@ public: : _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0), _mouseWidget(0), _focusedWidget(0), _visible(false) {} - virtual ~Dialog() {}; + virtual ~Dialog(); virtual void open(); virtual void close(); @@ -70,7 +70,7 @@ public: protected: Widget* findWidget(int x, int y); // Find the widget at pos x,y if any - Widget* addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey); + Widget* addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey); }; #endif diff --git a/gui/launcher.cpp b/gui/launcher.cpp index f602b1bb77..4238fbfc13 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -48,9 +48,9 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector) : Dialog(gui, 0, 0, 320, 200), _detector(detector) { // Add three buttons at the bottom - addButton(1*(_w - 54)/6, _h - 24, 54, 16, "Quit", kQuitCmd, 'Q'); - addButton(3*(_w - 54)/6, _h - 24, 54, 16, "Options", kOptionsCmd, 'O'); - _startButton = addButton(5*(_w - 54)/6, _h - 24, 54, 16, "Start", kStartCmd, 'S'); + addButton(1*(_w - 54)/6, _h - 24, "Quit", kQuitCmd, 'Q'); + addButton(3*(_w - 54)/6, _h - 24, "Options", kOptionsCmd, 'O'); + _startButton = addButton(5*(_w - 54)/6, _h - 24, "Start", kStartCmd, 'S'); _startButton->setEnabled(false); // Add list with game titles diff --git a/gui/message.cpp b/gui/message.cpp index a2b890785c..91c37763f9 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -69,5 +69,5 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message) } // FIXME - the vertical position has to be adjusted - addButton((_w - 54)/2, _h - 24, 54, 16, "OK", kCloseCmd, '\n'); // Confirm dialog + addButton((_w - kButtonWidth)/2, _h - 24, "OK", kCloseCmd, '\n'); // Confirm dialog } diff --git a/gui/widget.cpp b/gui/widget.cpp index 39c2a6b69b..463c0a7b3d 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -103,9 +103,7 @@ void StaticTextWidget::setValue(int value) void StaticTextWidget::drawWidget(bool hilite) { NewGui *gui = _boss->getGui(); - gui->drawString(_label.c_str(), _x, _y, _w, - !isEnabled() ? gui->_color : - hilite ? gui->_textcolorhi : gui->_textcolor, _align); + gui->drawString(_label.c_str(), _x, _y, _w, gui->_textcolor, _align); } @@ -125,6 +123,14 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) sendCommand(_cmd, 0); } +void ButtonWidget::drawWidget(bool hilite) +{ + NewGui *gui = _boss->getGui(); + gui->drawString(_label.c_str(), _x, _y, _w, + !isEnabled() ? gui->_color : + hilite ? gui->_textcolorhi : gui->_textcolor, _align); +} + #pragma mark - diff --git a/gui/widget.h b/gui/widget.h index 066252b0ec..718a50f444 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -47,6 +47,13 @@ enum { kScrollBarWidget = 'SCRB' }; +enum { + kButtonWidth = 54, + kButtonHeight = 16, +}; + + + class CommandReceiver; class CommandSender; @@ -155,6 +162,9 @@ public: void handleMouseUp(int x, int y, int button, int clickCount); void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + +protected: + void drawWidget(bool hilite); }; /* CheckboxWidget */ |