[Scummvm-cvs-logs] SF.net SVN: scummvm:[35545] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Dec 26 01:26:34 CET 2008


Revision: 35545
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35545&view=rev
Author:   fingolfin
Date:     2008-12-26 00:26:34 +0000 (Fri, 26 Dec 2008)

Log Message:
-----------
Some 'cleanup' of Gui::ThemeLayout

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeLayout.cpp
    scummvm/trunk/gui/ThemeLayout.h

Modified: scummvm/trunk/gui/ThemeLayout.cpp
===================================================================
--- scummvm/trunk/gui/ThemeLayout.cpp	2008-12-25 23:55:36 UTC (rev 35544)
+++ scummvm/trunk/gui/ThemeLayout.cpp	2008-12-26 00:26:34 UTC (rev 35545)
@@ -22,17 +22,20 @@
  * $Id$
  *
  */
+
 #include "common/util.h"
 #include "common/system.h"
 #include "common/events.h"
-#include "common/hashmap.h"
-#include "common/hash-str.h"
 #include "common/xmlparser.h"
-#include "graphics/scaler.h"
 
 #include "gui/ThemeEval.h"
 #include "gui/ThemeLayout.h"
 
+#ifdef LAYOUT_DEBUG_DIALOG
+#include "graphics/font.h"
+#include "graphics/surface.h"
+#endif
+
 namespace GUI {
 
 void ThemeLayout::importLayout(ThemeLayout *layout) {
@@ -92,7 +95,21 @@
 	return p->getHeight() - height;
 }
 
+#ifdef LAYOUT_DEBUG_DIALOG
+void ThemeLayout::debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
+	uint16 color = 0xFFFF;
+	font->drawString(screen, getName(), _x, _y, _w, color, Graphics::kTextAlignRight, 0, true);
+	screen->hLine(_x, _y, _x + _w, color);
+	screen->hLine(_x, _y + _h, _x + _w , color);
+	screen->vLine(_x, _y, _y + _h, color);
+	screen->vLine(_x + _w, _y, _y + _h, color);
 
+	for (uint i = 0; i < _children.size(); ++i)
+		_children[i]->debugDraw(screen, font);
+}
+#endif
+
+
 bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) {
 	if (name == _name) {
 		x = _x; y = _y;

Modified: scummvm/trunk/gui/ThemeLayout.h
===================================================================
--- scummvm/trunk/gui/ThemeLayout.h	2008-12-25 23:55:36 UTC (rev 35544)
+++ scummvm/trunk/gui/ThemeLayout.h	2008-12-26 00:26:34 UTC (rev 35545)
@@ -26,10 +26,20 @@
 #ifndef THEME_LAYOUT_H
 #define THEME_LAYOUT_H
 
+#ifdef LAYOUT_DEBUG_DIALOG
+namespace Graphics {
+	class Font;
+	class Surface;
+}
+#endif
+
 namespace GUI {
 
 class ThemeLayout {
-
+	friend class ThemeLayoutMain;
+	friend class ThemeLayoutVertical;
+	friend class ThemeLayoutHorizontal;
+	friend class ThemeLayoutSpacing;
 public:
 	enum LayoutType {
 		kLayoutMain,
@@ -38,8 +48,8 @@
 		kLayoutWidget
 	};
 
-	ThemeLayout(ThemeLayout *p, const Common::String &name) :
-		_parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1),
+	ThemeLayout(ThemeLayout *p) :
+		_parent(p), _x(0), _y(0), _w(-1), _h(-1),
 		_paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0),
 		_centered(false), _defaultW(-1), _defaultH(-1) { }
 
@@ -65,12 +75,9 @@
 		_spacing = spacing;
 	}
 
-	int16 getParentX() { return _parent ? _parent->_x : 0; }
-	int16 getParentY() { return _parent ? _parent->_y : 0; }
+protected:
 	int16 getParentW();
 	int16 getParentH();
-	int16 getX() { return _x; }
-	int16 getY() { return _y; }
 	int16 getWidth() { return _w; }
 	int16 getHeight() { return _h; }
 
@@ -89,23 +96,11 @@
 	void setWidth(int16 width) { _w = width; }
 	void setHeight(int16 height) { _h = height; }
 
-#ifdef LAYOUT_DEBUG_DIALOG
-	void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
-		uint16 color = 0xFFFF;
-		font->drawString(screen, getName(), _x, _y, _w, color, Graphics::kTextAlignRight, 0, true);
-		screen->hLine(_x, _y, _x + _w, color);
-		screen->hLine(_x, _y + _h, _x + _w , color);
-		screen->vLine(_x, _y, _y + _h, color);
-		screen->vLine(_x + _w, _y, _y + _h, color);
+	virtual LayoutType getLayoutType() = 0;
 
-		for (uint i = 0; i < _children.size(); ++i)
-			_children[i]->debugDraw(screen, font);
-	}
-#endif
+	virtual ThemeLayout *makeClone() = 0;
 
-	virtual LayoutType getLayoutType() = 0;
-	virtual const char *getName() { return _name.c_str(); }
-
+public:
 	virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
 
 	virtual bool getDialogData(int16 &x, int16 &y, uint16 &w, uint16 &h) {
@@ -115,23 +110,27 @@
 		return true;
 	}
 
-	virtual ThemeLayout *makeClone() = 0;
 	void importLayout(ThemeLayout *layout);
 
+#ifdef LAYOUT_DEBUG_DIALOG
+	void debugDraw(Graphics::Surface *screen, const Graphics::Font *font);
+
+	virtual const char *getName() const = 0;
+#endif
+
 protected:
 	ThemeLayout *_parent;
-	Common::String _name;
 	int16 _x, _y, _w, _h;
 	int8 _paddingLeft, _paddingRight, _paddingTop, _paddingBottom;
 	int8 _spacing;
-	Common::Array<ThemeLayout*> _children;
+	Common::Array<ThemeLayout *> _children;
 	bool _centered;
 	int16 _defaultW, _defaultH;
 };
 
 class ThemeLayoutMain : public ThemeLayout {
 public:
-	ThemeLayoutMain(int16 x, int16 y, int16 w, int16 h) : ThemeLayout(0, "") {
+	ThemeLayoutMain(int16 x, int16 y, int16 w, int16 h) : ThemeLayout(0) {
 		_w = _defaultW = w;
 		_h = _defaultH = h;
 		_x = _defaultX = x;
@@ -145,7 +144,9 @@
 		_y = _defaultY;
 	}
 
-	const char *getName() { return "Global Layout"; }
+#ifdef LAYOUT_DEBUG_DIALOG
+	const char *getName() const { return "Global Layout"; }
+#endif
 	LayoutType getLayoutType() { return kLayoutMain; }
 
 	ThemeLayout *makeClone() { assert(!"Do not copy Main Layouts!"); return 0; }
@@ -158,13 +159,15 @@
 class ThemeLayoutVertical : public ThemeLayout {
 public:
 	ThemeLayoutVertical(ThemeLayout *p, int spacing, bool center) :
-		ThemeLayout(p, "") {
+		ThemeLayout(p) {
 		_spacing = spacing;
 		_centered = center;
 	}
 
 	void reflowLayout();
-	const char *getName() { return "Vertical Layout"; }
+#ifdef LAYOUT_DEBUG_DIALOG
+	const char *getName() const { return "Vertical Layout"; }
+#endif
 	LayoutType getLayoutType() { return kLayoutVertical; }
 
 
@@ -181,13 +184,15 @@
 class ThemeLayoutHorizontal : public ThemeLayout {
 public:
 	ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool center) :
-		ThemeLayout(p, "") {
+		ThemeLayout(p) {
 		_spacing = spacing;
 		_centered = center;
 	}
 
 	void reflowLayout();
-	const char *getName() { return "Horizontal Layout"; }
+#ifdef LAYOUT_DEBUG_DIALOG
+	const char *getName() const { return "Horizontal Layout"; }
+#endif
 	LayoutType getLayoutType() { return kLayoutHorizontal; }
 
 	ThemeLayout *makeClone() {
@@ -202,21 +207,27 @@
 
 class ThemeLayoutWidget : public ThemeLayout {
 public:
-	ThemeLayoutWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h) : ThemeLayout(p, name) {
+	ThemeLayoutWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h) : ThemeLayout(p), _name(name) {
 		_w = _defaultW = w;
 		_h = _defaultH = h;
 	}
 
 	bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
 	void reflowLayout() {}
+#ifdef LAYOUT_DEBUG_DIALOG
+	virtual const char *getName() const { return _name.c_str(); }
+#endif
 	LayoutType getLayoutType() { return kLayoutWidget; }
 
 	ThemeLayout *makeClone() { return new ThemeLayoutWidget(*this); }
+
+protected:
+	Common::String _name;
 };
 
 class ThemeLayoutSpacing : public ThemeLayout {
 public:
-	ThemeLayoutSpacing(ThemeLayout *p, int size) : ThemeLayout(p, "") {
+	ThemeLayoutSpacing(ThemeLayout *p, int size) : ThemeLayout(p) {
 		if (p->getLayoutType() == kLayoutHorizontal) {
 			_w = _defaultW = size;
 			_h = _defaultH = 1;
@@ -229,7 +240,9 @@
 	bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; }
 	void reflowLayout() {}
 	LayoutType getLayoutType() { return kLayoutWidget; }
-	const char *getName() { return "SPACE"; }
+#ifdef LAYOUT_DEBUG_DIALOG
+	const char *getName() const { return "SPACE"; }
+#endif
 
 	ThemeLayout *makeClone() { return new ThemeLayoutSpacing(*this); }
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list