[Scummvm-cvs-logs] CVS: scummvm/gui widget.cpp,1.47,1.48 widget.h,1.41,1.42

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Wed May 18 00:24:14 CEST 2005


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5420

Modified Files:
	widget.cpp widget.h 
Log Message:
Big version of the checkbox widget.


Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- widget.cpp	15 May 2005 18:22:17 -0000	1.47
+++ widget.cpp	18 May 2005 07:23:21 -0000	1.48
@@ -177,20 +177,8 @@
 
 #pragma mark -
 
-/* 8x8 checkbox bitmap */
-static uint32 checked_img[8] = {
-	0x00000000,
-	0x01000010,
-	0x00100100,
-	0x00011000,
-	0x00011000,
-	0x00100100,
-	0x01000010,
-	0x00000000,
-};
-
 CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws)
-	: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws), _state(false) {
+	: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws), _state(false), _ws(ws) {
 	_flags = WIDGET_ENABLED;
 	_type = kCheckboxWidget;
 }
@@ -212,17 +200,38 @@
 
 void CheckboxWidget::drawWidget(bool hilite) {
 	NewGui *gui = &g_gui;
+	int fontHeight = _font->getFontHeight();
 
 	// Draw the box
-	gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor);
-	gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
+	gui->box(_x, _y, fontHeight + 4, fontHeight + 4, gui->_color, gui->_shadowcolor);
+	gui->fillRect(_x + 2, _y + 2, fontHeight, fontHeight, gui->_bgcolor);
 
 	// If checked, draw cross inside the box
-	if (_state)
-		gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
+	if (_state) {
+		Graphics::Surface &surf = gui->getScreen();
+		Common::Point p0, p1, p2, p3;
+		OverlayColor color = isEnabled() ? gui->_textcolor : gui->_color;
+
+		p0 = Common::Point(_x + 4, _y + 4);
+		p1 = Common::Point(_x + fontHeight - 1, _y + 4);
+		p2 = Common::Point(_x + 4, _y + fontHeight - 1);
+		p3 = Common::Point(_x + fontHeight - 1, _y + fontHeight - 1);
+
+		if (_ws == kBigWidgetSize) {
+			surf.drawLine(p0.x + 1, p0.y, p3.x, p3.y - 1, color);
+			surf.drawLine(p0.x, p0.y + 1, p3.x - 1, p3.y, color);
+			surf.drawLine(p0.x + 1, p0.y + 1, p3.x - 1, p3.y - 1, color);
+			surf.drawLine(p2.x + 1, p2.y - 1, p1.x - 1, p1.y + 1, color);
+			surf.drawLine(p2.x + 1, p2.y, p1.x, p1.y + 1, color);
+			surf.drawLine(p2.x, p2.y - 1, p1.x - 1, p1.y, color);
+		} else {
+			surf.drawLine(p0.x, p0.y, p3.x, p3.y, color);
+			surf.drawLine(p2.x, p2.y, p1.x, p1.y, color);
+		}
+	}
 
 	// Finally draw the label
-	gui->drawString(_font, _label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
+	gui->drawString(_font, _label, _x + fontHeight + 10, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
 }
 
 #pragma mark -

Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- widget.h	11 May 2005 19:30:28 -0000	1.41
+++ widget.h	18 May 2005 07:23:21 -0000	1.42
@@ -187,6 +187,7 @@
 class CheckboxWidget : public ButtonWidget {
 protected:
 	bool	_state;
+	const	WidgetSize _ws;
 public:
 	CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize);
 





More information about the Scummvm-git-logs mailing list