diff options
| author | Max Horn | 2002-11-21 12:48:50 +0000 | 
|---|---|---|
| committer | Max Horn | 2002-11-21 12:48:50 +0000 | 
| commit | dec234c6a563fbc0bec4d604dea45189739e2ee2 (patch) | |
| tree | 6b138affb87fdf3936af1999785112f98becf8c8 /gui | |
| parent | cb160cfbf369c8a66d7ad9e6bfdecfaacc826ef2 (diff) | |
| download | scummvm-rg350-dec234c6a563fbc0bec4d604dea45189739e2ee2.tar.gz scummvm-rg350-dec234c6a563fbc0bec4d604dea45189739e2ee2.tar.bz2 scummvm-rg350-dec234c6a563fbc0bec4d604dea45189739e2ee2.zip  | |
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
svn-id: r5658
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/EditTextWidget.cpp | 24 | ||||
| -rw-r--r-- | gui/EditTextWidget.h | 56 | ||||
| -rw-r--r-- | gui/ListWidget.cpp | 3 | ||||
| -rw-r--r-- | gui/ListWidget.h | 3 | ||||
| -rw-r--r-- | gui/chooser.cpp | 65 | ||||
| -rw-r--r-- | gui/chooser.h | 48 | ||||
| -rw-r--r-- | gui/launcher.cpp | 64 | ||||
| -rw-r--r-- | gui/module.mk | 2 | ||||
| -rw-r--r-- | gui/newgui.cpp | 4 | ||||
| -rw-r--r-- | gui/newgui.h | 3 | 
10 files changed, 205 insertions, 67 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp new file mode 100644 index 0000000000..41fca2a0e8 --- /dev/null +++ b/gui/EditTextWidget.cpp @@ -0,0 +1,24 @@ +/* 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$ + */ + +#include "stdafx.h" +#include "EditTextWidget.h" +#include "dialog.h" +#include "newgui.h" diff --git a/gui/EditTextWidget.h b/gui/EditTextWidget.h new file mode 100644 index 0000000000..f955e22921 --- /dev/null +++ b/gui/EditTextWidget.h @@ -0,0 +1,56 @@ +/* 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$ + */ + +#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 diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 995d434f6e..751b31f037 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -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::scrollBarRecalc()  void ListWidget::handleTickle()  { -	uint32 time = g_system->get_msecs(); +	uint32 time = _boss->getGui()->get_time();  	if (_editMode && _caretTime < time) {  		_caretTime = time + 300;  		if (_caretVisible) { diff --git a/gui/ListWidget.h b/gui/ListWidget.h index aca1d3eabf..a378414958 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -22,7 +22,8 @@  #define LISTWIDGET_H  #include "widget.h" -#include "util.h" +#include "common/str.h" +#include "common/list.h"  class ScrollBarWidget; diff --git a/gui/chooser.cpp b/gui/chooser.cpp new file mode 100644 index 0000000000..e7d924297f --- /dev/null +++ b/gui/chooser.cpp @@ -0,0 +1,65 @@ +/* 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$ + */ + +#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); +	} +} diff --git a/gui/chooser.h b/gui/chooser.h new file mode 100644 index 0000000000..b01c27718d --- /dev/null +++ b/gui/chooser.h @@ -0,0 +1,48 @@ +/* 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$ + */ + +#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 diff --git a/gui/launcher.cpp b/gui/launcher.cpp index bf0087835a..88efae7860 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -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 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat  				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]; diff --git a/gui/module.mk b/gui/module.mk index ec96344ebf..bb024d180a 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -2,7 +2,9 @@ MODULE := gui  MODULE_OBJS = \  	gui/browser.o \ +	gui/chooser.o \  	gui/dialog.o \ +	gui/EditTextWidget.o \  	gui/launcher.o \  	gui/ListWidget.o \  	gui/message.o \ diff --git a/gui/newgui.cpp b/gui/newgui.cpp index e7b492dc9e..3b30f410bc 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -127,7 +127,7 @@ void NewGui::runLoop()  		_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::drawBitmap(uint32 bitmap[8], int x, int y, int16 color)  //  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]; diff --git a/gui/newgui.h b/gui/newgui.h index 078d3984e0..1bd68ff0a3 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -117,6 +117,9 @@ public:  	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);  | 
