[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.27,1.28 widget.cpp,1.24,1.25 widget.h,1.22,1.23

Max Horn fingolfin at users.sourceforge.net
Fri Jul 26 17:37:01 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv6843/gui

Modified Files:
	dialog.cpp widget.cpp widget.h 
Log Message:
added support for right aligned text; made use of that in the sound dialog; less redrawing in the sound dialog

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dialog.cpp	27 Jul 2002 00:05:45 -0000	1.27
+++ dialog.cpp	27 Jul 2002 00:36:09 -0000	1.28
@@ -244,7 +244,7 @@
 	const char *str = _gui->queryResString(resID);
 	if (!str)
 		str = "Dummy!";
-	new StaticTextWidget(this, x, y, w, h, str);
+	new StaticTextWidget(this, x, y, w, h, str, kTextAlignLeft);
 }
 
 void Dialog::addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey)
@@ -385,11 +385,11 @@
 	: Dialog (gui, 30, 10, 260, 134)
 {
 	addButton(110, 110, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
-	new StaticTextWidget(this, 10, 17, 240, 16, "Build " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", true);
-	new StaticTextWidget(this, 10, 37, 240, 16, "ScummVM http://scummvm.sourceforge.net", true);
-	new StaticTextWidget(this, 10, 67, 240, 16, "All games (c) LucasArts", true);
-	new StaticTextWidget(this, 10, 84, 240, 16, "Except", true);
-	new StaticTextWidget(this, 10, 97, 240, 16, "Simon the Sorcerer (c) Adventuresoft", true);
+	new StaticTextWidget(this, 10, 17, 240, 16, "Build " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", kTextAlignCenter);
+	new StaticTextWidget(this, 10, 37, 240, 16, "ScummVM http://scummvm.sourceforge.net", kTextAlignCenter);
+	new StaticTextWidget(this, 10, 67, 240, 16, "All games (c) LucasArts", kTextAlignCenter);
+	new StaticTextWidget(this, 10, 84, 240, 16, "Except", kTextAlignCenter);
+	new StaticTextWidget(this, 10, 97, 240, 16, "Simon the Sorcerer (c) Adventuresoft", kTextAlignCenter);
 }
 
 PauseDialog::PauseDialog(NewGui *gui)
@@ -405,21 +405,25 @@
 	// set up dialog
 	addButton(70, 90, 54, 16, "OK", kOKCmd, 'O');	// Confirm dialog
 	addButton(136, 90, 54, 16, "Cancel", kCancelCmd, 'C');	// Abort dialog
-	new StaticTextWidget(this, 10, 17, 140, 16, "Master volume:", false);
-	new StaticTextWidget(this, 10, 37, 140, 16, "Music volume:", false);
-	new StaticTextWidget(this, 10, 57, 140, 16, "SFX volume:", false);
+	new StaticTextWidget(this, 20, 17, 85, 16, "Master volume:", kTextAlignRight);
+	new StaticTextWidget(this, 20, 37, 85, 16, "Music volume:", kTextAlignRight);
+	new StaticTextWidget(this, 20, 57, 85, 16, "SFX volume:", kTextAlignRight);
 
-	masterVolumeSlider = new SliderWidget(this, 100, 13, 80, 16, "Volume1", kMasterVolumeChanged);
-	musicVolumeSlider = new SliderWidget(this, 100, 33, 80, 16, "Volume2", kMusicVolumeChanged);
-	sfxVolumeSlider = new SliderWidget(this, 100, 53, 80, 16, "Volume3", kSfxVolumeChanged);
+	masterVolumeSlider = new SliderWidget(this, 110, 13, 80, 16, "Volume1", kMasterVolumeChanged);
+	musicVolumeSlider = new SliderWidget(this, 110, 33, 80, 16, "Volume2", kMusicVolumeChanged);
+	sfxVolumeSlider = new SliderWidget(this, 110, 53, 80, 16, "Volume3", kSfxVolumeChanged);
 
 	masterVolumeSlider->setMinValue(0);	masterVolumeSlider->setMaxValue(255);
 	musicVolumeSlider->setMinValue(0);	musicVolumeSlider->setMaxValue(255);
 	sfxVolumeSlider->setMinValue(0);	sfxVolumeSlider->setMaxValue(255);
 
-	masterVolumeLabel = new StaticTextWidget(this, 190, 16, 60, 16, "Volume1");
-	musicVolumeLabel = new StaticTextWidget(this, 190, 36, 60, 16, "Volume2");
-	sfxVolumeLabel = new StaticTextWidget(this, 190, 56, 60, 16, "Volume3");
+	masterVolumeLabel = new StaticTextWidget(this, 195, 17, 60, 16, "Volume1", kTextAlignLeft);
+	musicVolumeLabel = new StaticTextWidget(this, 195, 37, 60, 16, "Volume2", kTextAlignLeft);
+	sfxVolumeLabel = new StaticTextWidget(this, 195, 57, 60, 16, "Volume3", kTextAlignLeft);
+	
+	masterVolumeLabel->setFlags(WIDGET_CLEARBG);
+	musicVolumeLabel->setFlags(WIDGET_CLEARBG);
+	sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
 }
 
 void SoundDialog::open()
@@ -449,14 +453,17 @@
 	case kMasterVolumeChanged:
 		_soundVolumeMaster = masterVolumeSlider->getValue();
 		masterVolumeLabel->setValue(_soundVolumeMaster);
+		masterVolumeLabel->draw();
 		break;
 	case kMusicVolumeChanged:
 		_soundVolumeMusic = musicVolumeSlider->getValue();
 		musicVolumeLabel->setValue(_soundVolumeMusic);
+		musicVolumeLabel->draw();
 		break;
 	case kSfxVolumeChanged:
 		_soundVolumeSfx = sfxVolumeSlider->getValue();
 		sfxVolumeLabel->setValue(_soundVolumeSfx);
+		sfxVolumeLabel->draw();
 		break;
 	case kOKCmd: {
 		Scumm	*scumm = _gui->getScumm();
@@ -482,7 +489,4 @@
 	default:
 		Dialog::handleCommand(sender, cmd, data);
 	}
-
-	draw();
-
 }

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- widget.cpp	27 Jul 2002 00:05:46 -0000	1.24
+++ widget.cpp	27 Jul 2002 00:36:09 -0000	1.25
@@ -76,8 +76,8 @@
 #pragma mark -
 
 
-StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text, bool centred)
-	: Widget (boss, x, y, w, h), _label(0), _centred(centred)
+StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text, int align)
+	: Widget (boss, x, y, w, h), _label(0), _align(align)
 {
 	_type = kStaticTextWidget;
 	setLabel(text);
@@ -117,7 +117,7 @@
 void StaticTextWidget::drawWidget(bool hilite)
 {
 	NewGui *gui = _boss->getGui();
-	gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor, _centred);
+	gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor, _align);
 }
 
 
@@ -125,13 +125,11 @@
 
 
 ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
-	: StaticTextWidget(boss, x, y, w, h, label), CommandSender(boss), _cmd(cmd), _hotkey(hotkey)
+	: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey)
 {
 	assert(label);
 	_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ;
 	_type = kButtonWidget;
-	
-	setCentred(true);
 }
 
 ButtonWidget::~ButtonWidget()

Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- widget.h	27 Jul 2002 00:05:46 -0000	1.22
+++ widget.h	27 Jul 2002 00:36:09 -0000	1.23
@@ -118,15 +118,15 @@
 class StaticTextWidget : public Widget {
 protected:
 	char	*_label;
-	bool	_centred;
+	int		_align;
 public:
-	StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text, bool centred = false);
+	StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text, int align);
 	~StaticTextWidget();
 	void setValue(int value);
 	void setLabel(const char *label);
 	const char *getLabel() const	{ return _label; }
-	void setCentred(bool centred)	{ _centred = centred; }
-	bool isCentred() const			{ return _centred; }
+	void setAlign(int align)		{ _align = align; }
+	int getAlign() const			{ return _align; }
 
 protected:
 	void drawWidget(bool hilite);





More information about the Scummvm-git-logs mailing list