[Scummvm-cvs-logs] CVS: scummvm/gui chooser.cpp,1.6,1.7 chooser.h,1.5,1.6

Max Horn fingolfin at users.sourceforge.net
Mon Nov 3 12:17:12 CET 2003


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv21942

Modified Files:
	chooser.cpp chooser.h 
Log Message:
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

Index: chooser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/chooser.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- chooser.cpp	2 Nov 2003 02:18:14 -0000	1.6
+++ chooser.cpp	3 Nov 2003 20:16:23 -0000	1.7
@@ -27,23 +27,20 @@
 	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) {
@@ -57,6 +54,10 @@
 	case kListSelectionChangedCmd:
 		_chooseButton->setEnabled(item >= 0);
 		_chooseButton->draw();
+		break;
+	case kCloseCmd:
+		setResult(-1);
+		close();
 		break;
 	default:
 		Dialog::handleCommand(sender, cmd, data);

Index: chooser.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/chooser.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- chooser.h	2 Nov 2003 02:18:14 -0000	1.5
+++ chooser.h	3 Nov 2003 20:16:23 -0000	1.6
@@ -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 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





More information about the Scummvm-git-logs mailing list