diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/chooser.cpp | 17 | ||||
-rw-r--r-- | gui/chooser.h | 13 |
2 files changed, 16 insertions, 14 deletions
diff --git a/gui/chooser.cpp b/gui/chooser.cpp index b62dabdd70..dbcde18441 100644 --- a/gui/chooser.cpp +++ b/gui/chooser.cpp @@ -27,23 +27,20 @@ enum { kChooseCmd = 'Chos' }; -ChooserDialog::ChooserDialog(const String title, const StringList& list) - : Dialog(8, 24, 320 -2 * 8, 141) { +ChooserDialog::ChooserDialog(const String &title, const StringList& list, const String &buttonLabel, int height) + : Dialog(8, (200 - height) / 2, 320 -2 * 8, height) { // Headline - new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter); + new StaticTextWidget(this, 10, 6, _w - 2 * 10, kLineHeight, title, kTextAlignCenter); // Add choice list - _list = new ListWidget(this, 10, 22, _w - 2 * 10, _h - 22 - 24 - 10); + _list = new ListWidget(this, 10, 18, _w - 2 * 10, _h - 14 - 24 - 10); _list->setNumberingMode(kListNumberingOff); _list->setList(list); // Buttons addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0); - _chooseButton = addButton(_w-(kButtonWidth + 10), _h - 24, "Choose", kChooseCmd, 0); + _chooseButton = addButton(_w-(kButtonWidth + 10), _h - 24, buttonLabel, kChooseCmd, 0); _chooseButton->setEnabled(false); - - // Result = -1 -> no choice was made - setResult(-1); } void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { @@ -58,6 +55,10 @@ void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data _chooseButton->setEnabled(item >= 0); _chooseButton->draw(); break; + case kCloseCmd: + setResult(-1); + close(); + break; default: Dialog::handleCommand(sender, cmd, data); } diff --git a/gui/chooser.h b/gui/chooser.h index 3ba83b5cd4..25b0c703e4 100644 --- a/gui/chooser.h +++ b/gui/chooser.h @@ -21,9 +21,9 @@ #ifndef CHOOSER_DIALOG_H #define CHOOSER_DIALOG_H -#include "dialog.h" #include "common/str.h" #include "common/list.h" +#include "gui/dialog.h" class ButtonWidget; class ListWidget; @@ -35,14 +35,15 @@ class ListWidget; class ChooserDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; -public: - ChooserDialog(const String title, const StringList &list); - - virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); - protected: ListWidget *_list; ButtonWidget *_chooseButton; + +public: + ChooserDialog(const String &title, const StringList &list, const String &buttonLabel = "Choose", int height = 140); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + ListWidget *getListWidget() { return _list; } // HACK }; #endif |