[Scummvm-cvs-logs] CVS: scummvm/gui EditTextWidget.cpp,NONE,1.1 EditTextWidget.h,NONE,1.1 chooser.cpp,NONE,1.1 chooser.h,NONE,1.1 ListWidget.cpp,1.13,1.14 ListWidget.h,1.10,1.11 launcher.cpp,1.17,1.18 module.mk,1.1,1.2 newgui.cpp,1.29,1.30 newgui.h,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Thu Nov 21 04:49:08 CET 2002


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

Modified Files:
	ListWidget.cpp ListWidget.h launcher.cpp module.mk newgui.cpp 
	newgui.h 
Added Files:
	EditTextWidget.cpp EditTextWidget.h chooser.cpp chooser.h 
Log Message:
factored out ChooserDialog into it's own header/source file, and made the title adjustable; added a dummy file for EditFieldWidget (not implemented yet); some other cleanup

--- NEW FILE: EditTextWidget.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v 1.1 2002/11/21 12:48:50 fingolfin Exp $
 */

#include "stdafx.h"
#include "EditTextWidget.h"
#include "dialog.h"
#include "newgui.h"

--- NEW FILE: EditTextWidget.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/EditTextWidget.h,v 1.1 2002/11/21 12:48:50 fingolfin Exp $
 */

#ifndef EDITTEXTWIDGET_H
#define EDITTEXTWIDGET_H

#include "widget.h"
#include "common/str.h"
#include "common/list.h"

/* EditTextWidget */
class EditTextWidget : public StaticTextWidget {
	typedef ScummVM::StringList StringList;
	typedef ScummVM::String String;
protected:
	int				_currentKeyDown;
	String			_backupString;
	bool			_caretVisible;
	uint32			_caretTime;
public:
	EditTextWidget(Dialog *boss, int x, int y, int w, int h);
	virtual ~EditTextWidget();

	virtual void handleTickle();
	virtual void handleMouseDown(int x, int y, int button, int clickCount);
	virtual void handleMouseUp(int x, int y, int button, int clickCount);
	virtual bool handleKeyDown(char key, int modifiers);
	virtual bool handleKeyUp(char key, int modifiers);
	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);

	virtual bool wantsFocus() { return true; };

protected:
	void drawWidget(bool hilite);
	void drawCaret(bool erase);
	void lostFocusWidget();
};

#endif

--- NEW FILE: chooser.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/chooser.cpp,v 1.1 2002/11/21 12:48:50 fingolfin Exp $
 */

#include "chooser.h"
#include "newgui.h"
#include "ListWidget.h"

enum {
	kChooseCmd = 'Chos'
};

ChooserDialog::ChooserDialog(NewGui *gui, const String title, const StringList& list)
	: Dialog(gui, 40, 24, 320-2*40, 141)
{
	// Headline
	new StaticTextWidget(this, 10, 8, _w-2*10, kLineHeight, title, kTextAlignCenter);
	
	// Add choice list
	_list = new ListWidget(this, 10, 22, _w-2*10, _h-22-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->setEnabled(false);
	
	// Result = -1 -> no choice was made
	setResult(-1);
}

void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
{
	int item = _list->getSelected();
	switch (cmd) {
	case kChooseCmd:
	case kListItemDoubleClickedCmd:
		setResult(item);
		close();
		break;
	case kListSelectionChangedCmd:
		_chooseButton->setEnabled(item >= 0);
		_chooseButton->draw();
		break;
	default:
		Dialog::handleCommand(sender, cmd, data);
	}
}

--- NEW FILE: chooser.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/chooser.h,v 1.1 2002/11/21 12:48:50 fingolfin Exp $
 */

#ifndef CHOOSER_DIALOG_H
#define CHOOSER_DIALOG_H

#include "dialog.h"
#include "common/str.h"
#include "common/list.h"

class ButtonWidget;
class ListWidget;

/*
 * A dialog that allows the user to choose between a selection of items
 */

class ChooserDialog : public Dialog {
	typedef ScummVM::String String;
	typedef ScummVM::StringList StringList;
public:
	ChooserDialog(NewGui *gui, const String title, const StringList& list);

	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);

protected:
	ListWidget		*_list;
	ButtonWidget	*_chooseButton;
};

#endif

Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- ListWidget.cpp	15 Nov 2002 17:38:50 -0000	1.13
+++ ListWidget.cpp	21 Nov 2002 12:48:50 -0000	1.14
@@ -23,7 +23,6 @@
 #include "ScrollBarWidget.h"
 #include "dialog.h"
 #include "newgui.h"
-#include "common/engine.h"
 
 
 ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h)
@@ -91,7 +90,7 @@
 
 void ListWidget::handleTickle()
 {
-	uint32 time = g_system->get_msecs();
+	uint32 time = _boss->getGui()->get_time();
 	if (_editMode && _caretTime < time) {
 		_caretTime = time + 300;
 		if (_caretVisible) {

Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ListWidget.h	14 Nov 2002 14:42:39 -0000	1.10
+++ ListWidget.h	21 Nov 2002 12:48:50 -0000	1.11
@@ -22,7 +22,8 @@
 #define LISTWIDGET_H
 
 #include "widget.h"
-#include "util.h"
+#include "common/str.h"
+#include "common/list.h"
 
 class ScrollBarWidget;
 

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- launcher.cpp	21 Nov 2002 04:02:10 -0000	1.17
+++ launcher.cpp	21 Nov 2002 12:48:50 -0000	1.18
@@ -21,6 +21,7 @@
 #include "stdafx.h"
 #include "launcher.h"
 #include "browser.h"
+#include "chooser.h"
 #include "newgui.h"
 #include "ListWidget.h"
 
@@ -30,67 +31,6 @@
 #include "common/gameDetector.h"
 
 enum {
-	kChooseCmd = 'Chos'
-};
-
-/*
- * A dialog that allows the user to choose between a selection of items
- */
-
-class ChooserDialog : public Dialog {
-	typedef ScummVM::String String;
-	typedef ScummVM::StringList StringList;
-public:
-	ChooserDialog(NewGui *gui, const StringList& list);
-
-	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
-
-protected:
-	ListWidget		*_list;
-	ButtonWidget	*_chooseButton;
-};
-
-ChooserDialog::ChooserDialog(NewGui *gui, const StringList& list)
-	: Dialog(gui, 40, 30, 320-2*40, 200-2*30)
-{
-	// Headline
-	new StaticTextWidget(this, 10, 8, _w-2*10, kLineHeight,
-		"Pick the game:", kTextAlignCenter);
-	
-	// Add choice list
-	_list = new ListWidget(this, 10, 22, _w-2*10, _h-22-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->setEnabled(false);
-	
-	// Result = -1 -> no choice was made
-	setResult(-1);
-}
-
-void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
-{
-	int item = _list->getSelected();
-	switch (cmd) {
-	case kChooseCmd:
-	case kListItemDoubleClickedCmd:
-		setResult(item);
-		close();
-		break;
-	case kListSelectionChangedCmd:
-		_chooseButton->setEnabled(item >= 0);
-		_chooseButton->draw();
-		break;
-	default:
-		Dialog::handleCommand(sender, cmd, data);
-	}
-}
-
-
-enum {
 	kStartCmd = 'STRT',
 	kOptionsCmd = 'OPTN',
 	kAddGameCmd = 'ADDG',
@@ -279,7 +219,7 @@
 				for (i = 0; i < candidates.size(); i++)
 					list.push_back(candidates[i]->gamename);
 				
-				ChooserDialog dialog(_gui, list);
+				ChooserDialog dialog(_gui, "Pick the game:", list);
 				i = dialog.runModal();
 				if (0 <= i && i < candidates.size())
 					v = candidates[i];

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/module.mk,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- module.mk	21 Nov 2002 04:08:37 -0000	1.1
+++ module.mk	21 Nov 2002 12:48:50 -0000	1.2
@@ -2,7 +2,9 @@
 
 MODULE_OBJS = \
 	gui/browser.o \
+	gui/chooser.o \
 	gui/dialog.o \
+	gui/EditTextWidget.o \
 	gui/launcher.o \
 	gui/ListWidget.o \
 	gui/message.o \

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- newgui.cpp	10 Nov 2002 19:39:32 -0000	1.29
+++ newgui.cpp	21 Nov 2002 12:48:50 -0000	1.30
@@ -127,7 +127,7 @@
 		_system->update_screen();		
 
 		OSystem::Event event;
-		uint32 time = _system->get_msecs();
+		uint32 time = get_time();
 
 		while (_system->poll_event(&event)) {
 			switch(event.event_code) {
@@ -475,7 +475,7 @@
 //
 void NewGui::animateCursor()
 {
-	int time = _system->get_msecs(); 
+	int time = get_time(); 
 	if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
 		const byte colors[4] = { 15, 15, 7, 8 };
 		const byte color = colors[_cursorAnimateCounter];

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- newgui.h	5 Nov 2002 21:48:40 -0000	1.16
+++ newgui.h	21 Nov 2002 12:48:50 -0000	1.17
@@ -117,6 +117,9 @@
 	int16 _textcolor;
 	int16 _textcolorhi;
 
+	// Misc util
+	uint32 get_time() const { return _system->get_msecs(); }
+
 	// Drawing primitives
 	int16 *getBasePtr(int x, int y);
 	void box(int x, int y, int width, int height, bool inverted = false);





More information about the Scummvm-git-logs mailing list