diff options
author | Max Horn | 2003-11-03 20:16:23 +0000 |
---|---|---|
committer | Max Horn | 2003-11-03 20:16:23 +0000 |
commit | 3f1476788406b0dba63c5c1f315c87206b89a50a (patch) | |
tree | 6b0af625d6090a73e28f65007f04da87a0b8d407 /gui | |
parent | d2285e386fc555b0e2c02171e46eed8e4e120c0d (diff) | |
download | scummvm-rg350-3f1476788406b0dba63c5c1f315c87206b89a50a.tar.gz scummvm-rg350-3f1476788406b0dba63c5c1f315c87206b89a50a.tar.bz2 scummvm-rg350-3f1476788406b0dba63c5c1f315c87206b89a50a.zip |
Make ChooserDialog height & button label customizable; make its ListWidget available to the outside, to allow custom modifications (hack!); fixed bug where the cancel button didn't yield -1 as result
svn-id: r11110
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 |