[Scummvm-cvs-logs] CVS: scummvm/gui widget.cpp,1.16,1.17 widget.h,1.14,1.15

Max Horn fingolfin at users.sourceforge.net
Mon Jul 15 06:00:05 CEST 2002


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

Modified Files:
	widget.cpp widget.h 
Log Message:
allow static text/button widgets in NewGUI to be drawn centred

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- widget.cpp	13 Jul 2002 22:41:29 -0000	1.16
+++ widget.cpp	15 Jul 2002 12:59:56 -0000	1.17
@@ -52,6 +52,7 @@
 		gui->box(_x, _y, _w, _h);
 		_x += 4;
 		_y += 4;
+		_w -= 8;
 	}
 	
 	// Now perform the actual widget draw
@@ -64,6 +65,7 @@
 	if (_flags & WIDGET_BORDER) {
 		_x -= 4;
 		_y -= 4;
+		_w += 8;
 	}
 	_x -= _boss->_x;
 	_y -= _boss->_y;
@@ -74,7 +76,7 @@
 
 
 StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text)
-	: Widget (boss, x, y, w, h), _label(0)
+	: Widget (boss, x, y, w, h), _label(0), _centred(false)
 {
 	_type = kStaticTextWidget;
 	setLabel(text);
@@ -104,7 +106,7 @@
 void StaticTextWidget::drawWidget(bool hilite)
 {
 	NewGui *gui = _boss->getGui();
-	gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor);
+	gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor, _centred);
 }
 
 
@@ -117,6 +119,8 @@
 	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.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- widget.h	13 Jul 2002 22:41:29 -0000	1.14
+++ widget.h	15 Jul 2002 12:59:56 -0000	1.15
@@ -112,11 +112,14 @@
 class StaticTextWidget : public Widget {
 protected:
 	char	*_label;
+	bool	_centred;
 public:
 	StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text);
 	~StaticTextWidget();
 	void setLabel(const char *label);
 	const char *getLabel() const	{ return _label; }
+	void setCentred(bool centred)	{ _centred = centred; }
+	bool isCentred() const			{ return _centred; }
 
 protected:
 	void drawWidget(bool hilite);





More information about the Scummvm-git-logs mailing list