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

tanoku at users.sourceforge.net tanoku at users.sourceforge.net
Thu Oct 9 13:49:35 CEST 2008


Revision: 34757
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34757&view=rev
Author:   tanoku
Date:     2008-10-09 11:49:35 +0000 (Thu, 09 Oct 2008)

Log Message:
-----------
Manual merge of the GSoC2008 GUI branch. (71 files)

Modified Paths:
--------------
    scummvm/trunk/common/module.mk
    scummvm/trunk/common/rect.h
    scummvm/trunk/dists/msvc9/scummvm.vcproj
    scummvm/trunk/engines/dialogs.cpp
    scummvm/trunk/engines/parallaction/saveload.cpp
    scummvm/trunk/engines/scumm/dialogs.cpp
    scummvm/trunk/graphics/font.cpp
    scummvm/trunk/graphics/module.mk
    scummvm/trunk/gui/EditTextWidget.cpp
    scummvm/trunk/gui/ListWidget.cpp
    scummvm/trunk/gui/PopUpWidget.cpp
    scummvm/trunk/gui/TabWidget.cpp
    scummvm/trunk/gui/TabWidget.h
    scummvm/trunk/gui/about.cpp
    scummvm/trunk/gui/browser.cpp
    scummvm/trunk/gui/console.cpp
    scummvm/trunk/gui/dialog.cpp
    scummvm/trunk/gui/dialog.h
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/module.mk
    scummvm/trunk/gui/newgui.cpp
    scummvm/trunk/gui/newgui.h
    scummvm/trunk/gui/options.cpp
    scummvm/trunk/gui/options.h
    scummvm/trunk/gui/theme.cpp
    scummvm/trunk/gui/theme.h
    scummvm/trunk/gui/themebrowser.cpp
    scummvm/trunk/gui/themebrowser.h
    scummvm/trunk/gui/widget.cpp
    scummvm/trunk/gui/widget.h

Added Paths:
-----------
    scummvm/trunk/common/xmlparser.cpp
    scummvm/trunk/common/xmlparser.h
    scummvm/trunk/graphics/VectorRenderer.cpp
    scummvm/trunk/graphics/VectorRenderer.h
    scummvm/trunk/graphics/VectorRendererSpec.cpp
    scummvm/trunk/graphics/VectorRendererSpec.h
    scummvm/trunk/gui/ThemeEngine.cpp
    scummvm/trunk/gui/ThemeEngine.h
    scummvm/trunk/gui/ThemeEval.cpp
    scummvm/trunk/gui/ThemeEval.h
    scummvm/trunk/gui/ThemeLayout.cpp
    scummvm/trunk/gui/ThemeLayout.h
    scummvm/trunk/gui/ThemeParser.cpp
    scummvm/trunk/gui/ThemeParser.h
    scummvm/trunk/gui/themes/default.inc
    scummvm/trunk/gui/themes/scummclassic/
    scummvm/trunk/gui/themes/scummclassic/THEMERC
    scummvm/trunk/gui/themes/scummclassic/classic_gfx.stx
    scummvm/trunk/gui/themes/scummclassic/classic_layout.stx
    scummvm/trunk/gui/themes/scummclassic/classic_layout_320.stx
    scummvm/trunk/gui/themes/scummclassic.zip
    scummvm/trunk/gui/themes/scummodern/
    scummvm/trunk/gui/themes/scummodern/THEMERC
    scummvm/trunk/gui/themes/scummodern/checkbox.bmp
    scummvm/trunk/gui/themes/scummodern/cursor.bmp
    scummvm/trunk/gui/themes/scummodern/cursor_small.bmp
    scummvm/trunk/gui/themes/scummodern/helvr12-l1.fcc
    scummvm/trunk/gui/themes/scummodern/logo.bmp
    scummvm/trunk/gui/themes/scummodern/logo_small.bmp
    scummvm/trunk/gui/themes/scummodern/scummodern_gfx.stx
    scummvm/trunk/gui/themes/scummodern/scummodern_layout.stx
    scummvm/trunk/gui/themes/scummodern/scummodern_layout_320.stx
    scummvm/trunk/gui/themes/scummodern.zip
    scummvm/trunk/gui/themes/scummtheme.py

Removed Paths:
-------------
    scummvm/trunk/gui/ThemeClassic.cpp
    scummvm/trunk/gui/ThemeClassic.h
    scummvm/trunk/gui/ThemeModern.cpp
    scummvm/trunk/gui/ThemeModern.h
    scummvm/trunk/gui/themes/classic080.ini
    scummvm/trunk/gui/themes/modern.ini
    scummvm/trunk/gui/themes/modern.zip

Modified: scummvm/trunk/common/module.mk
===================================================================
--- scummvm/trunk/common/module.mk	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/common/module.mk	2008-10-09 11:49:35 UTC (rev 34757)
@@ -17,6 +17,7 @@
 	system.o \
 	unarj.o \
 	unzip.o \
+	xmlparser.o \
 	zlib.o
 
 # Include common rules

Modified: scummvm/trunk/common/rect.h
===================================================================
--- scummvm/trunk/common/rect.h	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/common/rect.h	2008-10-09 11:49:35 UTC (rev 34757)
@@ -124,6 +124,16 @@
 		return contains(p.x, p.y);
 	}
 
+	/*! @brief check if the given rect is _fully_ contained inside this rectangle
+
+		@param r The rectangle to check
+
+		@retur true if the given rect is inside, false otherwise
+	*/
+	bool contains(const Rect &r) const {
+		return (left < r.left) && (right > r.right) && (top < r.top) && (bottom > r.bottom);
+	}
+
 	/*!	@brief check if given rectangle intersects with this rectangle
 
 		@param r the rectangle to check

Added: scummvm/trunk/common/xmlparser.cpp
===================================================================
--- scummvm/trunk/common/xmlparser.cpp	                        (rev 0)
+++ scummvm/trunk/common/xmlparser.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -0,0 +1,339 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $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"
+
+namespace Common {
+
+using namespace Graphics;
+
+bool XMLParser::parserError(const char *errorString, ...) {
+	_state = kParserError;
+
+	int original_pos = _stream->pos();
+	int pos = original_pos;
+	int lineCount = 1;
+	int lineStart = 0;
+
+	if (_fileName == "Memory Stream") {
+		lineStart = MAX(0, original_pos - 35);
+		lineCount = 0;
+	} else {
+		do {
+			if (_char == '\n' || _char == '\r') {
+				lineCount++;
+		
+				if (lineStart == 0)
+					lineStart = MAX(pos + 1, original_pos - 60);
+			}
+			
+			_stream->seek(-1, SEEK_CUR);
+
+		} while (_stream->pos() > 0);
+	}
+
+	char lineStr[70];
+	_stream->seek(original_pos - 35, SEEK_SET);
+	_stream->readLine_NEW(lineStr, 70);
+	
+	for (int i = 0; i < 70; ++i)
+		if (lineStr[i] == '\n')
+			lineStr[i] = ' ';
+
+	printf("\n  File <%s>, line %d:\n", _fileName.c_str(), lineCount);
+
+	bool startFull = lineStr[0] == '<';
+	bool endFull = lineStr[strlen(lineStr) - 1] == '>';
+
+	printf("%s%s%s\n", startFull ? "" : "...", lineStr, endFull ? "" : "...");
+
+	int cursor = 35;
+
+	if (!startFull)
+		cursor += 3;
+
+	while (cursor--)
+		printf(" ");
+
+	printf("^\n");
+	printf("Parser error: ");
+
+	va_list args;
+	va_start(args, errorString);
+	vprintf(errorString, args);
+	va_end(args);
+
+	printf("\n\n");
+
+	return false;
+}
+
+bool XMLParser::parseActiveKey(bool closed) {
+	bool ignore = false;
+	assert(_activeKey.empty() == false);
+
+	ParserNode *key = _activeKey.top();
+	XMLKeyLayout *layout = (_activeKey.size() == 1) ? _XMLkeys : getParentNode(key)->layout;
+	
+	if (layout->children.contains(key->name)) {
+		key->layout = layout->children[key->name];
+	
+		Common::StringMap localMap = key->values;
+		int keyCount = localMap.size();
+	
+		for (Common::List<XMLKeyLayout::XMLKeyProperty>::const_iterator i = key->layout->properties.begin(); i != key->layout->properties.end(); ++i) {
+			if (i->required && !localMap.contains(i->name))
+				return parserError("Missing required property '%s' inside key '%s'", i->name.c_str(), key->name.c_str());
+			else if (localMap.contains(i->name))
+				keyCount--;
+		}
+	
+		if (keyCount > 0)
+			return parserError("Unhandled property inside key '%s': '%s'", key->name.c_str(), localMap.begin()->_key.c_str());
+			
+	} else {
+		return parserError("Unexpected key in the active scope: '%s'.", key->name.c_str());
+	}
+
+	// check if any of the parents must be ignored.
+	// if a parent is ignored, all children are too.
+	for (int i = _activeKey.size() - 1; i >= 0; --i) {
+		if (_activeKey[i]->ignore)
+			ignore = true;
+	}
+
+	if (ignore == false && keyCallback(key) == false) {
+		// HACK:  People may be stupid and overlook the fact that
+		// when keyCallback() fails, a parserError() must be set.
+		// We set it manually in that case.
+		if (_state != kParserError)
+			parserError("Unhandled exception when parsing '%s' key.", key->name.c_str());
+			
+		return false;
+	}
+	
+	if (closed)
+		return closeKey();
+
+	return true;
+}
+
+bool XMLParser::parseKeyValue(Common::String keyName) {
+	assert(_activeKey.empty() == false);
+
+	if (_activeKey.top()->values.contains(keyName))
+		return false;
+
+	_token.clear();
+	char stringStart;
+
+	if (_char == '"' || _char == '\'') {
+		stringStart = _char;
+		_char = _stream->readByte();
+
+		while (_char && _char != stringStart) {
+			_token += _char;
+			_char = _stream->readByte();
+		}
+
+		if (_char == 0)
+			return false;
+
+		_char = _stream->readByte();
+
+	} else if (!parseToken()) {
+		return false;
+	}
+
+	_activeKey.top()->values[keyName] = _token;
+	return true;
+}
+
+bool XMLParser::closeKey() {
+	bool ignore = false;
+	bool result = true;
+	
+	for (int i = _activeKey.size() - 1; i >= 0; --i) {
+		if (_activeKey[i]->ignore)
+			ignore = true;
+	}
+	
+	if (ignore == false)
+		result = closedKeyCallback(_activeKey.top());
+		
+	freeNode(_activeKey.pop());
+	
+	return result;
+}
+
+bool XMLParser::parse() {
+
+	if (_stream == 0)
+		return parserError("XML stream not ready for reading.");
+		
+	if (_XMLkeys == 0)
+		buildLayout();
+
+	while (!_activeKey.empty())
+		freeNode(_activeKey.pop());
+
+	cleanup();
+
+	bool activeClosure = false;
+	bool selfClosure = false;
+
+	_state = kParserNeedKey;
+	_activeKey.clear();
+
+	_char = _stream->readByte();
+	
+	while (_char && _state != kParserError) {
+		if (skipSpaces())
+			continue;
+
+		if (skipComments())
+			continue;
+
+		switch (_state) {
+			case kParserNeedKey:
+				if (_char != '<') {
+					parserError("Parser expecting key start.");
+					break;
+				}
+
+				if ((_char = _stream->readByte()) == 0) {
+					parserError("Unexpected end of file.");
+					break;
+				}
+
+				if (_char == '/') { // FIXME: What if it's a comment start
+					_char = _stream->readByte();
+					activeClosure = true;
+				}
+
+				_state = kParserNeedKeyName;
+				break;
+
+			case kParserNeedKeyName:
+				if (!parseToken()) {
+					parserError("Invalid key name.");
+					break;
+				}
+
+				if (activeClosure) {
+					if (_activeKey.empty() || _token != _activeKey.top()->name) {
+						parserError("Unexpected closure.");
+						break;
+					}
+				} else {
+					ParserNode *node = allocNode(); //new ParserNode;
+					node->name = _token;
+					node->ignore = false;
+					node->depth = _activeKey.size();
+					node->layout = 0;
+					_activeKey.push(node);
+				}
+
+				_state = kParserNeedPropertyName;
+				break;
+
+			case kParserNeedPropertyName:
+				if (activeClosure) {
+					if (!closeKey()) {
+						parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str()); 
+						break;
+					}
+
+					activeClosure = false;
+
+					if (_char != '>')
+						parserError("Invalid syntax in key closure.");
+					else 
+						_state = kParserNeedKey;
+
+					_char = _stream->readByte();
+					break;
+				}
+
+				selfClosure = false;
+
+				if (_char == '/') { // FIXME: comment start?
+					selfClosure = true;
+					_char = _stream->readByte();
+				}
+
+				if (_char == '>') {
+					if (parseActiveKey(selfClosure)) {
+						_char = _stream->readByte();
+						_state = kParserNeedKey;
+					}
+					break;
+				}
+
+				if (!parseToken()) 
+					parserError("Error when parsing key value.");
+				else 
+					_state = kParserNeedPropertyOperator;
+
+				break;
+
+			case kParserNeedPropertyOperator:
+				if (_char != '=') 
+					parserError("Syntax error after key name.");
+				else  
+					_state = kParserNeedPropertyValue;
+
+				_char = _stream->readByte();
+				break;
+
+			case kParserNeedPropertyValue:
+				if (!parseKeyValue(_token)) 
+					parserError("Invalid key value.");
+				else 
+					_state = kParserNeedPropertyName;
+
+				break;
+
+			default:
+				break;
+		}
+	}
+
+	if (_state == kParserError)
+		return false;
+
+	if (_state != kParserNeedKey || !_activeKey.empty())
+		return parserError("Unexpected end of file.");
+
+	return true;
+}
+
+}
+


Property changes on: scummvm/trunk/common/xmlparser.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/common/xmlparser.h
===================================================================
--- scummvm/trunk/common/xmlparser.h	                        (rev 0)
+++ scummvm/trunk/common/xmlparser.h	2008-10-09 11:49:35 UTC (rev 34757)
@@ -0,0 +1,487 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef XML_PARSER_H
+#define XML_PARSER_H
+
+#include "common/scummsys.h"
+#include "graphics/surface.h"
+#include "common/system.h"
+#include "common/xmlparser.h"
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+#include "common/stack.h"
+
+namespace Common {
+	
+/*
+	XMLParser.cpp/h -- Generic XML Parser
+	=====================================
+
+	External documentation available at:
+		http://www.smartlikearoboc.com/scummvm_doc/xmlparser_doc.html
+*/
+
+#define MAX_XML_DEPTH 8
+			
+#define XML_KEY(keyName) {\
+		lay =  new CustomXMLKeyLayout;\
+		lay->callback = (&kLocalParserName::parserCallback_##keyName);\
+		layout.top()->children[#keyName] = lay;\
+		layout.push(lay); \
+		_layoutList.push_back(lay);\
+		for (Common::List<XMLKeyLayout::XMLKeyProperty>::const_iterator p = globalProps.begin(); p != globalProps.end(); ++p){\
+			layout.top()->properties.push_back(*p);}
+		
+#define XML_KEY_RECURSIVE(keyName) {\
+			layout.top()->children[#keyName] = layout.top();\
+			layout.push(layout.top());\
+		}
+
+#define KEY_END() layout.pop(); }
+
+#define XML_PROP(propName, req) {\
+		prop.name = #propName; \
+		prop.required = req; \
+		layout.top()->properties.push_back(prop); }
+		
+#define XML_GLOBAL_PROP(propName, req) {\
+		prop.name = #propName; \
+		prop.required = req;\
+		globalProps.push_back(prop); }
+		
+	
+#define CUSTOM_XML_PARSER(parserName) \
+	protected: \
+	typedef parserName kLocalParserName; \
+	bool keyCallback(ParserNode *node) {return node->layout->doCallback(this, node); }\
+	struct CustomXMLKeyLayout : public XMLKeyLayout {\
+		typedef bool (parserName::*ParserCallback)(ParserNode *node);\
+		ParserCallback callback;\
+		bool doCallback(XMLParser *parent, ParserNode *node) {return ((kLocalParserName*)parent->*callback)(node);} };\
+	virtual void buildLayout() { \
+		Common::Stack<XMLKeyLayout*> layout; \
+		CustomXMLKeyLayout *lay = 0; \
+		XMLKeyLayout::XMLKeyProperty prop; \
+		Common::List<XMLKeyLayout::XMLKeyProperty> globalProps; \
+		_XMLkeys = new CustomXMLKeyLayout; \
+		layout.push(_XMLkeys);
+	
+#define PARSER_END() layout.clear(); }
+
+/**
+ * The base XMLParser class implements generic functionality for parsing
+ * XML-like files.
+ *
+ * In order to use it, it must be inherited with a child class that implements
+ * the XMLParser::keyCallback() function.
+ *
+ * @see XMLParser::keyCallback()
+ */
+class XMLParser {
+
+public:
+	/**
+	 * Parser constructor.
+	 */
+	XMLParser() : _XMLkeys(0), _stream(0) {}
+
+	virtual ~XMLParser() {
+		while (!_activeKey.empty())
+			freeNode(_activeKey.pop());
+
+		delete _XMLkeys;
+		delete _stream;
+
+		for (Common::List<XMLKeyLayout*>::iterator i = _layoutList.begin();
+			i != _layoutList.end(); ++i)
+			delete *i;
+
+		_layoutList.clear();
+	}
+
+	/** Active state for the parser */
+	enum ParserState {
+		kParserNeedKey,
+		kParserNeedKeyName,
+
+		kParserNeedPropertyName,
+		kParserNeedPropertyOperator,
+		kParserNeedPropertyValue,
+
+		kParserError
+	};
+	
+	struct XMLKeyLayout;
+	struct ParserNode;
+	
+	typedef Common::HashMap<Common::String, XMLParser::XMLKeyLayout*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ChildMap;
+	
+	/** nested struct representing the layout of the XML file */
+	struct XMLKeyLayout {
+		struct XMLKeyProperty {
+			Common::String name;
+			bool required;
+		};
+		
+		Common::List<XMLKeyProperty> properties;
+		ChildMap children;
+		
+		virtual bool doCallback(XMLParser *parent, ParserNode *node) = 0;
+		
+		virtual ~XMLKeyLayout() {
+			properties.clear();
+		}
+	} *_XMLkeys;
+
+	/** Struct representing a parsed node */
+	struct ParserNode {
+		Common::String name;
+		Common::StringMap values;
+		bool ignore;
+		int depth;
+		XMLKeyLayout *layout;
+	};
+	
+	FixedSizeMemoryPool<sizeof(ParserNode), MAX_XML_DEPTH> _nodePool;
+
+	ParserNode *allocNode() {
+		void* mem = _nodePool.malloc();
+		return new (mem) ParserNode;
+	} 
+
+	void freeNode(ParserNode *node) {
+		node->~ParserNode();
+		_nodePool.free(node);
+	}
+
+	/**
+	 * Loads a file into the parser.
+	 * Used for the loading of Theme Description files
+	 * straight from the filesystem.
+	 *
+	 * @param filename Name of the file to load.
+	 */
+	bool loadFile(const Common::String &filename) {
+		Common::File *f = new Common::File;
+
+		if (!f->open(filename)) {
+			delete f;
+			return false;
+		}
+
+		_fileName = filename;
+		_stream = f;
+		return true;
+	}
+	
+	bool loadFile(const FSNode &node) {
+		Common::File *f = new Common::File;
+		
+		if (!f->open(node)) {
+			delete f;
+			return false;
+		}
+		
+		_fileName = node.getName();
+		_stream = f;
+		return true;
+	}
+
+	/**
+	 * Loads a memory buffer into the parser.
+	 * Used for loading the default theme fallback directly
+	 * from memory if no themes can be found.
+	 *
+	 * @param buffer Pointer to the buffer.
+	 * @param size Size of the buffer
+	 * @param disposable Sets if the XMLParser owns the buffer,
+	 *                   i.e. if it can be freed safely after it's
+	 *                   no longer needed by the parser.
+	 */
+	bool loadBuffer(const byte *buffer, uint32 size, bool disposable = false) {
+		_stream = new MemoryReadStream(buffer, size, disposable);
+		_fileName = "Memory Stream";
+		return true;
+	}
+	
+	bool loadStream(Common::SeekableReadStream *stream) {
+		_stream = stream;
+		_fileName = "File Stream";
+		return true;
+	}
+	
+	void close() {
+		if (_stream) {
+			delete _stream;
+			_stream = 0;
+		}
+	}
+
+	/**
+	 * The actual parsing function.
+	 * Parses the loaded data stream, returns true if successful.
+	 */
+	bool parse();
+
+	/**
+	 * Returns the active node being parsed (the one on top of
+	 * the node stack).
+	 */
+	ParserNode *getActiveNode() {
+		if (!_activeKey.empty())
+			return _activeKey.top();
+
+		return 0;
+	}
+
+	/**
+	 * Returns the parent of a given node in the stack.
+	 */
+	ParserNode *getParentNode(ParserNode *child) {
+		return child->depth > 0 ? _activeKey[child->depth - 1] : 0;
+	}
+
+protected:
+	
+	/**
+	 * The buildLayout function builds the layout for the parser to use
+	 * based on a series of helper macros. This function is automatically
+	 * generated by the CUSTOM_XML_PARSER() macro on custom parsers.
+	 *
+	 * See the documentation regarding XML layouts.
+	 */
+	virtual void buildLayout() = 0;
+	
+	/**
+	 * The keycallback function is automatically overloaded on custom parsers
+	 * when using the CUSTOM_XML_PARSER() macro. 
+	 *
+	 * Its job is to call the corresponding Callback function for the given node.
+	 * A function for each key type must be declared separately. See the custom
+	 * parser creation instructions.
+	 *
+	 * When parsing a key in such function, one may chose to skip it, e.g. because it's not needed
+	 * on the current configuration. In order to ignore a key, you must set
+	 * the "ignore" field of its KeyNode struct to "true": The key and all its children
+	 * will then be automatically ignored by the parser.
+	 *
+	 * The callback function must return true if the key was properly handled (this includes the case when the
+	 * key is being ignored). False otherwise. The return of keyCallback() is the same as
+	 * the callback function's.
+	 * See the sample implementation in GUI::ThemeParser.
+	 */
+	virtual bool keyCallback(ParserNode *node) = 0;
+
+	/**
+	 * The closed key callback function MAY be overloaded by inheriting classes to
+	 * implement parser-specific functions.
+	 *
+	 * The closedKeyCallback is issued once a key has been finished parsing, to let
+	 * the parser verify that all the required subkeys, etc, were included.
+	 *
+	 * Unlike the keyCallbacks(), there's just a closedKeyCallback() for all keys.
+	 * Use "node->name" to distinguish between each key type.
+	 *
+	 * Returns true if the key was properly closed, false otherwise.
+	 * By default, all keys are properly closed.
+	 */
+	virtual bool closedKeyCallback(ParserNode *node) {
+		return true;
+	}
+	
+	/**
+	 * Called when a node is closed. Manages its cleanup and calls the
+	 * closing callback function if needed.
+	 */
+	bool closeKey();
+
+	/**
+	 * Parses the value of a given key. There's no reason to overload this.
+	 */
+	bool parseKeyValue(Common::String keyName);
+
+	/**
+	 * Called once a key has been parsed. It handles the closing/cleanup of the
+	 * node stack and calls the keyCallback.
+	 */
+	bool parseActiveKey(bool closed);
+
+	/**
+	 * Prints an error message when parsing fails and stops the parser.
+	 * Parser error always returns "false" so we can pass the return value directly
+	 * and break down the parsing.
+	 */
+	bool parserError(const char *errorString, ...) GCC_PRINTF(2, 3);
+
+	/**
+	 * Skips spaces/whitelines etc. Returns true if any spaces were skipped.
+	 */
+	bool skipSpaces() {
+		if (!isspace(_char))
+			return false;
+
+		while (_char && isspace(_char))
+			_char = _stream->readByte();
+
+		return true;
+	}
+
+	/**
+	 * Skips comment blocks and comment lines.
+	 * Returns true if any comments were skipped.
+	 * Overload this if you want to disable comments on your XML syntax
+	 * or to change the commenting syntax.
+	 */
+	virtual bool skipComments() {
+		char endComment1 = 0, endComment2 = 0;
+
+		if (_char == '/') {
+			_char = _stream->readByte();
+
+			if (_char != '*') {
+				_stream->seek(-1, SEEK_CUR);
+				_char = '/';
+				return false;
+			}
+			
+			_char = _stream->readByte();
+
+			while (_char) {
+				endComment1 = endComment2;
+				endComment2 = _char;
+				_char = _stream->readByte();
+
+				if (endComment1 == '*' && endComment2 == '/')
+					break;
+
+				if (_char == 0)
+					return parserError("Comment has no closure.");
+			}
+			_char = _stream->readByte();
+			return true;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Check if a given character can be part of a KEY or VALUE name.
+	 * Overload this if you want to support keys with strange characters
+	 * in their name.
+	 */
+	virtual inline bool isValidNameChar(char c) {
+		return isalnum(c) || c == '_';
+	}
+
+	/**
+	 * Parses a the first textual token found.
+	 * There's no reason to overload this.
+	 */
+	bool parseToken() {
+		_token.clear();
+
+		while (isValidNameChar(_char)) {
+			_token += _char;
+			_char = _stream->readByte();
+		}
+
+		return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
+	}
+
+	/**
+	 * Parses the values inside an integer key.
+	 * The count parameter specifies the number of values inside
+	 * the key, which are expected to be separated with commas.
+	 *
+	 * Sample usage:
+	 * parseIntegerKey("255, 255, 255", 3, &red, &green, &blue);
+	 * [will parse each field into its own integer]
+	 *
+	 * parseIntegerKey("1234", 1, &number);
+	 * [will parse the single number into the variable]
+	 *
+	 * @param key String containing the integers to be parsed.
+	 * @param count Number of comma-separated ints in the string.
+	 * @param ... Integer variables to store the parsed ints, passed
+	 *            by reference.
+	 * @returns True if the parsing succeeded.
+	 */
+	bool parseIntegerKey(const char *key, int count, ...) {
+		char *parseEnd;
+		int *num_ptr;
+
+		va_list args;
+		va_start(args, count);
+
+		while (count--) {
+			while (isspace(*key))
+				key++;
+
+			num_ptr = va_arg(args, int*);
+			*num_ptr = strtol(key, &parseEnd, 10);
+
+			key = parseEnd;
+
+			while (isspace(*key))
+				key++;
+
+			if (count && *key++ != ',')
+				return false;
+		}
+
+		va_end(args);
+		return (*key == 0);
+	}
+
+	/**
+	 * Overload if your parser needs to support parsing the same file
+	 * several times, so you can clean up the internal state of the 
+	 * parser before each parse.
+	 */
+	virtual void cleanup() {}
+
+	Common::List<XMLKeyLayout*> _layoutList;
+
+private:
+	char _char;
+	SeekableReadStream *_stream;
+	Common::String _fileName;
+
+	ParserState _state; /** Internal state of the parser */
+
+	Common::String _error; /** Current error message */
+	Common::String _token; /** Current text token */
+
+	Common::Stack<ParserNode*> _activeKey; /** Node stack of the parsed keys */
+};
+
+}
+
+#endif


Property changes on: scummvm/trunk/common/xmlparser.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/dists/msvc9/scummvm.vcproj
===================================================================
--- scummvm/trunk/dists/msvc9/scummvm.vcproj	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/dists/msvc9/scummvm.vcproj	2008-10-09 11:49:35 UTC (rev 34757)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="scummvm"
 	ProjectGUID="{8434CB15-D08F-427D-9E6D-581AE5B28440}"
 	RootNamespace="scummvm"
@@ -103,9 +103,6 @@
 				Name="VCAppVerifierTool"
 			/>
 			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
@@ -200,9 +197,6 @@
 				Name="VCAppVerifierTool"
 			/>
 			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
@@ -470,6 +464,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\common\xmlparser.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\common\xmlparser.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\common\zlib.cpp"
 				>
 			</File>
@@ -1117,14 +1119,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\gui\eval.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\..\gui\eval.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\gui\Key.cpp"
 				>
 			</File>
@@ -1213,10 +1207,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\gui\theme-config.cpp"
-				>
-			</File>
-			<File
 				RelativePath="..\..\gui\theme.cpp"
 				>
 			</File>
@@ -1233,14 +1223,41 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\gui\ThemeClassic.cpp"
+				RelativePath="..\..\gui\ThemeEngine.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\..\gui\ThemeModern.cpp"
+				RelativePath="..\..\gui\ThemeEngine.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\gui\ThemeEval.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\gui\ThemeLayout.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\gui\ThemeLayout.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\gui\ThemeParser.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\gui\ThemeParser.h"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\gui\widget.cpp"
 				>
 			</File>
@@ -1345,6 +1362,22 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\graphics\VectorRenderer.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\graphics\VectorRenderer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\graphics\VectorRendererSpec.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\graphics\VectorRendererSpec.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\graphics\thumbnail.cpp"
 				>
 			</File>

Modified: scummvm/trunk/engines/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/dialogs.cpp	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/engines/dialogs.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -32,7 +32,6 @@
 #include "graphics/scaler.h"
 
 #include "gui/about.h"
-#include "gui/eval.h"
 #include "gui/newgui.h"
 #include "gui/ListWidget.h"
 #include "gui/theme.h"
@@ -59,9 +58,7 @@
 typedef GUI::OptionsDialog GUI_OptionsDialog;
 typedef GUI::Dialog GUI_Dialog;
 
-GlobalDialog::GlobalDialog(String name)
-	: GUI::Dialog(name) {
-_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;}
+GlobalDialog::GlobalDialog(String name) : GUI::Dialog(name) {}
 
 enum {
 	kSaveCmd = 'SAVE',
@@ -76,37 +73,41 @@
 };
 
 MainMenuDialog::MainMenuDialog(Engine *engine)
-	: GlobalDialog("globalmain"), _engine(engine) {
+	: GlobalDialog("GlobalMenu"), _engine(engine) {
+	_backgroundType = GUI::Theme::kDialogBackgroundSpecial;
 
 #ifndef DISABLE_FANCY_THEMES
 	_logo = 0;
-	if (g_gui.evaluator()->getVar("global_logo.visible") == 1 && g_gui.theme()->supportsImages()) {
-		_logo = new GUI::GraphicsWidget(this, "global_logo");
+	if (g_gui.xmlEval()->getVar("Globals.ShowGlobalMenuLogo", 0) == 1 && g_gui.theme()->supportsImages()) {
+		_logo = new GUI::GraphicsWidget(this, "GlobalMenu.Logo");
 		_logo->useThemeTransparency(true);
 		_logo->setGfx(g_gui.theme()->getImageSurface(GUI::Theme::kImageLogoSmall));
 	} else {
-		new StaticTextWidget(this, "global_title", "ScummVM");
+		StaticTextWidget *title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM");
+		title->setAlign(GUI::kTextAlignCenter);
 	}
 #else
-	new StaticTextWidget(this, "global_title", "ScummVM");
+	StaticTextWidget *title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM");
+	title->setAlign(GUI::kTextAlignCenter);
 #endif
 
-	new StaticTextWidget(this, "global_version", gScummVMVersionDate);
+	StaticTextWidget *version = new StaticTextWidget(this, "GlobalMenu.Version", gScummVMVersionDate);
+	version->setAlign(GUI::kTextAlignCenter);
 		
-	new GUI::ButtonWidget(this, "globalmain_resume", "Resume", kPlayCmd, 'P');
+	new GUI::ButtonWidget(this, "GlobalMenu.Resume", "Resume", kPlayCmd, 'P');
 
 //	new GUI::ButtonWidget(this, "globalmain_load", "Load", kLoadCmd, 'L');
 //	new GUI::ButtonWidget(this, "globalmain_save", "Save", kSaveCmd, 'S');
 
-	new GUI::ButtonWidget(this, "globalmain_options", "Options", kOptionsCmd, 'O');
+	new GUI::ButtonWidget(this, "GlobalMenu.Options", "Options", kOptionsCmd, 'O');
 
-	new GUI::ButtonWidget(this, "globalmain_about", "About", kAboutCmd, 'A');
+	new GUI::ButtonWidget(this, "GlobalMenu.About", "About", kAboutCmd, 'A');
 
-	_rtlButton = new GUI::ButtonWidget(this, "globalmain_rtl", "Return to Launcher", kRTLCmd, 'R');	
+	_rtlButton = new GUI::ButtonWidget(this, "GlobalMenu.RTL", "Return to Launcher", kRTLCmd, 'R');	
 	_rtlButton->setEnabled(_engine->hasFeature(Engine::kSupportsRTL));
 
 
-	new GUI::ButtonWidget(this, "globalmain_quit", "Quit", kQuitCmd, 'Q');
+	new GUI::ButtonWidget(this, "GlobalMenu.Quit", "Quit", kQuitCmd, 'Q');
 
 	_aboutDialog = new GUI::AboutDialog();
 	_optionsDialog = new ConfigDialog();
@@ -149,22 +150,24 @@
 
 void MainMenuDialog::reflowLayout() {
 #ifndef DISABLE_FANCY_THEMES
-	if (g_gui.evaluator()->getVar("global_logo.visible") == 1 && g_gui.theme()->supportsImages()) {
+	if (g_gui.xmlEval()->getVar("Globals.ShowGlobalMenuLogo", 0) == 1 && g_gui.theme()->supportsImages()) {
 		if (!_logo)
-			_logo = new GUI::GraphicsWidget(this, "global_logo");
+			_logo = new GUI::GraphicsWidget(this, "GlobalMenu.Logo");
 		_logo->useThemeTransparency(true);
 		_logo->setGfx(g_gui.theme()->getImageSurface(GUI::Theme::kImageLogoSmall));
 
-		GUI::StaticTextWidget *title = (StaticTextWidget *)findWidget("global_title");
+		GUI::StaticTextWidget *title = (StaticTextWidget *)findWidget("GlobalMenu.Title");
 		if (title) {
 			removeWidget(title);
 			title->setNext(0);
 			delete title;
 		}
 	} else {
-		GUI::StaticTextWidget *title = (StaticTextWidget *)findWidget("global_title");
-		if (!title)
-			new StaticTextWidget(this, "global_title", "ScummVM");
+		GUI::StaticTextWidget *title = (StaticTextWidget *)findWidget("GlobalMenu.Title");
+		if (!title) {
+			title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM");
+			title->setAlign(GUI::kTextAlignCenter);
+		}
 
 		if (_logo) {
 			removeWidget(_logo);
@@ -212,30 +215,30 @@
 //  "" as value for the domain, and in fact provide a somewhat better user
 // experience at the same time.
 ConfigDialog::ConfigDialog()
-	: GUI::OptionsDialog("", "scummconfig") {
+	: GUI::OptionsDialog("", "ScummConfig") {
 
 	//
 	// Sound controllers
 	//
 
-	addVolumeControls(this, "scummconfig_");
+	addVolumeControls(this, "ScummConfig.");
 
 	//
 	// Some misc options
 	//
 
 	// SCUMM has a talkspeed range of 0-9
-	addSubtitleControls(this, "scummconfig_", 9);
+	addSubtitleControls(this, "ScummConfig.", 9);
 
 	//
 	// Add the buttons
 	//
 
-	new GUI::ButtonWidget(this, "scummconfig_ok", "OK", GUI::OptionsDialog::kOKCmd, 'O');
-	new GUI::ButtonWidget(this, "scummconfig_cancel", "Cancel", kCloseCmd, 'C');
+	new GUI::ButtonWidget(this, "ScummConfig.Ok", "OK", GUI::OptionsDialog::kOKCmd, 'O');
+	new GUI::ButtonWidget(this, "ScummConfig.Cancel", "Cancel", kCloseCmd, 'C');
 
 #ifdef SMALL_SCREEN_DEVICE
-	new GUI::ButtonWidget(this, "scummconfig_keys", "Keys", kKeysCmd, 'K');
+	new GUI::ButtonWidget(this, "ScummConfig.Keys", "Keys", kKeysCmd, 'K');
 
 	//
 	// Create the sub dialog(s)

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -252,15 +252,17 @@
 };
 
 
+
 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
-	: Dialog("scummsaveload"), _list(0), _chooseButton(0), _gfxWidget(0) {
+	: Dialog("ScummSaveLoad"), _list(0), _chooseButton(0), _gfxWidget(0) {
 
 //	_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
+	_backgroundType = GUI::Theme::kDialogBackgroundSpecial;
 
-	new GUI::StaticTextWidget(this, "scummsaveload_title", title);
+	new GUI::StaticTextWidget(this, "ScummSaveLoad.Title", title);
 
 	// Add choice list
-	_list = new GUI::ListWidget(this, "scummsaveload_list");
+	_list = new GUI::ListWidget(this, "ScummSaveLoad.List");
 	_list->setEditable(true);
 	_list->setNumberingMode(GUI::kListNumberingOne);
 
@@ -271,12 +273,12 @@
 	_playtime = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", GUI::kTextAlignCenter);
 
 	// Buttons
-	new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", GUI::kCloseCmd, 0);
-	_chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0);
+	new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", GUI::kCloseCmd, 0);
+	_chooseButton = new GUI::ButtonWidget(this, "ScummSaveLoad.Choose", buttonLabel, kChooseCmd, 0);
 	_chooseButton->setEnabled(false);
 
 	_container = new GUI::ContainerWidget(this, 0, 0, 10, 10);
-	_container->setHints(GUI::THEME_HINT_USE_SHADOW);
+//	_container->setHints(GUI::THEME_HINT_USE_SHADOW);
 }
 
 SaveLoadChooser::~SaveLoadChooser() {

Modified: scummvm/trunk/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.cpp	2008-10-08 09:05:21 UTC (rev 34756)
+++ scummvm/trunk/engines/scumm/dialogs.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -36,9 +36,10 @@
 #endif
 
 #include "gui/about.h"
-#include "gui/eval.h"
+#include "gui/theme.h"
 #include "gui/newgui.h"
 #include "gui/ListWidget.h"
+#include "gui/ThemeEval.h"
 
 #include "scumm/dialogs.h"
 #include "scumm/sound.h"
@@ -212,9 +213,8 @@
 
 #pragma mark -
 
-ScummDialog::ScummDialog(String name)
-	: GUI::Dialog(name) {
-_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
+ScummDialog::ScummDialog(String name) : GUI::Dialog(name) {
+	_backgroundType = GUI::Theme::kDialogBackgroundSpecial;
 }
 
 #pragma mark -
@@ -233,17 +233,21 @@
 };
 
 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine)
-	: Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
+	: Dialog("ScummSaveLoad"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
+		
+	_backgroundType = GUI::Theme::kDialogBackgroundSpecial;
 
-	_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
+	new StaticTextWidget(this, "ScummSaveLoad.Title", title);
 
-	new StaticTextWidget(this, "scummsaveload_title", title);
-
 	// Add choice list
-	_list = new GUI::ListWidget(this, "scummsaveload_list");
+	_list = new GUI::ListWidget(this, "ScummSaveLoad.List");
 	_list->setEditable(saveMode);
 	_list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
 
+// Tanoku: SVNMerge removed this. Unconvinient. ///////////////
+//	_container = new GUI::ContainerWidget(this, 0, 0, 10, 10);
+///////////////////////////////////////////////////////////////
+
 	_gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10);
 
 	_date = new StaticTextWidget(this, 0, 0, 10, 10, "No date saved", kTextAlignCenter);
@@ -251,12 +255,12 @@
 	_playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter);
 
 	// Buttons
-	new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0);
-	_chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0);
+	new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", kCloseCmd, 0);
+	_chooseButton = new GUI::ButtonWidget(this, "ScummSaveLoad.Choose", buttonLabel, kChooseCmd, 0);
 	_chooseButton->setEnabled(false);
 
 	_container = new GUI::ContainerWidget(this, 0, 0, 10, 10);
-	_container->setHints(GUI::THEME_HINT_USE_SHADOW);
+//	_container->setHints(GUI::THEME_HINT_USE_SHADOW);
 }
 
 SaveLoadChooser::~SaveLoadChooser() {
@@ -317,18 +321,21 @@
 }
 
 void SaveLoadChooser::reflowLayout() {
-	if (g_gui.evaluator()->getVar("scummsaveload_extinfo.visible") == 1) {
-		int thumbX = g_gui.evaluator()->getVar("scummsaveload_thumbnail.x");
-		int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y");
-		int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad");
-		int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad");
+	if (g_gui.xmlEval()->getVar("Globals.ScummSaveLoad.ExtInfo.Visible") == 1) {
+		int16 x, y;
+		uint16 w, h;
+		
+		if (!g_gui.xmlEval()->getWidgetData("ScummSaveLoad.Thumbnail", x, y, w, h))
+			error("Error when loading position data for Save/Load Thumbnails.");
+			
+		int thumbW = kThumbnailWidth;	
 		int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1);
+		int thumbX = x + (w >> 1) - (thumbW >> 1);
+		int thumbY = y + kLineHeight;
+		
+		_container->resize(x, y, w, h);
+		_gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); 
 
-		_container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * 4);
-
-		// Add the thumbnail display
-		_gfxWidget->resize(thumbX, thumbY, kThumbnailWidth, thumbH);
-
 		int height = thumbY + thumbH + kLineHeight;
 
 		_date->resize(thumbX, height, kThumbnailWidth, kLineHeight);
@@ -347,9 +354,9 @@
 		_time->clearFlags(GUI::WIDGET_INVISIBLE);
 		_playtime->clearFlags(GUI::WIDGET_INVISIBLE);
 
-		_fillR = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR");
-		_fillG = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG");
-		_fillB = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB");
+		_fillR = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR");
+		_fillG = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG");
+		_fillB = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB");
 		updateInfos(false);
 	} else {
 		_container->setFlags(GUI::WIDGET_INVISIBLE);
@@ -431,20 +438,20 @@
 }
 
 ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm)
-	: ScummDialog("scummmain"), _vm(scumm) {
+	: ScummDialog("ScummMain"), _vm(scumm) {
 
-	new GUI::ButtonWidget(this, "scummmain_resume", "Resume", kPlayCmd, 'P');
+	new GUI::ButtonWidget(this, "ScummMain.Resume", "Resume", kPlayCmd, 'P');
 
-	new GUI::ButtonWidget(this, "scummmain_load", "Load", kLoadCmd, 'L');
-	new GUI::ButtonWidget(this, "scummmain_save", "Save", kSaveCmd, 'S');
+	new GUI::ButtonWidget(this, "ScummMain.Load", "Load", kLoadCmd, 'L');
+	new GUI::ButtonWidget(this, "ScummMain.Save", "Save", kSaveCmd, 'S');
 
-	new GUI::ButtonWidget(this, "scummmain_options", "Options", kOptionsCmd, 'O');
+	new GUI::ButtonWidget(this, "ScummMain.Options", "Options", kOptionsCmd, 'O');
 #ifndef DISABLE_HELP
-	new GUI::ButtonWidget(this, "scummmain_help", "Help", kHelpCmd, 'H');
+	new GUI::ButtonWidget(this, "ScummMain.Help", "Help", kHelpCmd, 'H');
 #endif
-	new GUI::ButtonWidget(this, "scummmain_about", "About", kAboutCmd, 'A');
+	new GUI::ButtonWidget(this, "ScummMain.About", "About", kAboutCmd, 'A');
 
-	new GUI::ButtonWidget(this, "scummmain_quit", "Quit", kQuitCmd, 'Q');
+	new GUI::ButtonWidget(this, "ScummMain.Quit", "Quit", kQuitCmd, 'Q');
 
 	//
 	// Create the sub dialog(s)
@@ -564,29 +571,29 @@
 //  "" as value for the domain, and in fact provide a somewhat better user
 // experience at the same time.
 ConfigDialog::ConfigDialog()
-	: GUI::OptionsDialog("", "scummconfig") {
+	: GUI::OptionsDialog("", "ScummConfig") {
 
 	//
 	// Sound controllers
 	//
 
-	addVolumeControls(this, "scummconfig_");
+	addVolumeControls(this, "ScummConfig.");
 
 	//
 	// Some misc options
 	//
 
 	// SCUMM has a talkspeed range of 0-9
-	addSubtitleControls(this, "scummconfig_", 9);
+	addSubtitleControls(this, "ScummConfig.", 9);
 
 	//
 	// Add the buttons
 	//
 
-	new GUI::ButtonWidget(this, "scummconfig_ok", "OK", GUI::OptionsDialog::kOKCmd, 'O');
-	new GUI::ButtonWidget(this, "scummconfig_cancel", "Cancel", kCloseCmd, 'C');
+	new GUI::ButtonWidget(this, "ScummConfig.Ok", "OK", GUI::OptionsDialog::kOKCmd, 'O');
+	new GUI::ButtonWidget(this, "ScummConfig.Cancel", "Cancel", kCloseCmd, 'C');
 #ifdef SMALL_SCREEN_DEVICE
-	new GUI::ButtonWidget(this, "scummconfig_keys", "Keys", kKeysCmd, 'K');
+	new GUI::ButtonWidget(this, "ScummConfig.Keys", "Keys", kKeysCmd, 'K');
 #endif
 
 #ifdef SMALL_SCREEN_DEVICE
@@ -626,22 +633,23 @@
 };
 
 HelpDialog::HelpDialog(const GameSettings &game)
-	: ScummDialog("scummhelp"), _game(game) {
-	_title = new StaticTextWidget(this, "scummhelp_title", "");
+	: ScummDialog("ScummHelp"), _game(game) {
+	_title = new StaticTextWidget(this, "ScummHelp.Title", "");
 
 	_page = 1;
+	_backgroundType = GUI::Theme::kDialogBackgroundDefault;
 
 	_numPages = ScummHelp::numPages(_game.id);
 
-	_prevButton = new GUI::ButtonWidget(this, "scummhelp_prev", "Previous", kPrevCmd, 'P');
-	_nextButton = new GUI::ButtonWidget(this, "scummhelp_next", "Next", kNextCmd, 'N');
-	new GUI::ButtonWidget(this, "scummhelp_close", "Close", kCloseCmd, 'C');
+	_prevButton = new GUI::ButtonWidget(this, "ScummHelp.Prev", "Previous", kPrevCmd, 'P');
+	_nextButton = new GUI::ButtonWidget(this, "ScummHelp.Next", "Next", kNextCmd, 'N');
+	new GUI::ButtonWidget(this, "ScummHelp.Close", "Close", kCloseCmd, 'C');
 	_prevButton->clearFlags(WIDGET_ENABLED);
 
 	// Dummy entries
 	for (int i = 0; i < HELP_NUM_LINES; i++) {
-		_key[i] = new StaticTextWidget(this, 0, 0, 10, 10, "", kTextAlignLeft);
-		_dsc[i] = new StaticTextWidget(this, 0, 0, 10, 10, "", kTextAlignLeft);
+		_key[i] = new StaticTextWidget(this, 0, 0, 10, 10, "", Graphics::kTextAlignRight);
+		_dsc[i] = new StaticTextWidget(this, 0, 0, 10, 10, "", Graphics::kTextAlignLeft);
 	}
 
 }
@@ -649,22 +657,21 @@
 void HelpDialog::reflowLayout() {
 	ScummDialog::reflowLayout();
 
-	_drawingHints &= ~GUI::THEME_HINT_SPECIAL_COLOR;
-
 	int lineHeight = g_gui.getFontHeight();
+	int16 x, y;
+	uint16 w, h;
+	
+	g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h);
+	
+	int keyW = w * 20 / 100;
+	int dscX = x + keyW + 32;
+	int dscW = w * 80 / 100;
+	
+	int xoff = (_w >> 1) - (w >> 1);
 
-	int keyX = g_gui.evaluator()->getVar("scummhelp_key.x");
-	int keyYoff = g_gui.evaluator()->getVar("scummhelp_key.yoffset");
-	int keyW = g_gui.evaluator()->getVar("scummhelp_key.w");
-	int keyH = g_gui.evaluator()->getVar("scummhelp_key.h");
-	int dscX = g_gui.evaluator()->getVar("scummhelp_dsc.x");
-	int dscYoff = g_gui.evaluator()->getVar("scummhelp_dsc.yoffset");
-	int dscW = g_gui.evaluator()->getVar("scummhelp_dsc.w");
-	int dscH = g_gui.evaluator()->getVar("scummhelp_dsc.h");
-
 	for (int i = 0; i < HELP_NUM_LINES; i++) {
-		_key[i]->resize(keyX, keyYoff + lineHeight * (i + 2), keyW, keyH);
-		_dsc[i]->resize(dscX, dscYoff + lineHeight * (i + 2), dscW, dscH);
+		_key[i]->resize(xoff + x, y + lineHeight * i, keyW, lineHeight + 2);
+		_dsc[i]->resize(xoff + dscX, y + lineHeight * i, dscW, lineHeight + 2);
 	}
 
 	displayKeyBindings();
@@ -836,7 +843,7 @@
 
 ValueDisplayDialog::ValueDisplayDialog(const Common::String& label, int minVal, int maxVal,
 		int val, uint16 incKey, uint16 decKey)
-	: GUI::Dialog("scummDummyDialog", false),
+	: GUI::Dialog("scummDummyDialog"),
 	_label(label), _min(minVal), _max(maxVal),
 	_value(val), _incKey(incKey), _decKey(decKey) {
 	assert(_min <= _value && _value <= _max);
@@ -844,8 +851,7 @@
 
 void ValueDisplayDialog::drawDialog() {
 	const int labelWidth = _w - 8 - _percentBarWidth;
-	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h),
-				GUI::THEME_HINT_SAVE_BACKGROUND | GUI::THEME_HINT_FIRST_DRAW);
+	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), GUI::Theme::kDialogBackgroundDefault);
 	g_gui.theme()->drawText(Common::Rect(_x+4, _y+4, _x+labelWidth+4,
 				_y+g_gui.theme()->getFontHeight()+4), _label);
 	g_gui.theme()->drawSlider(Common::Rect(_x+4+labelWidth, _y+4, _x+_w-4, _y+_h-4),
@@ -937,7 +943,10 @@
 	if (_value > 2)
 		_value = 0;
 
-	setInfoText(subtitleDesc[_value]);
+	if (_value == 1 && g_system->getOverlayWidth() <= 320)
+		setInfoText("Speech & Subs");
+	else
+		setInfoText(subtitleDesc[_value]);
 
 	_timer = getMillis() + 1500;
 }

Added: scummvm/trunk/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/trunk/graphics/VectorRenderer.cpp	                        (rev 0)
+++ scummvm/trunk/graphics/VectorRenderer.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -0,0 +1,159 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+#include "common/system.h"
+#include "common/events.h"
+
+#include "graphics/surface.h"
+#include "graphics/colormasks.h"
+
+#include "gui/ThemeEngine.h"
+#include "graphics/VectorRenderer.h"
+
+#define VECTOR_RENDERER_FAST_TRIANGLES
+
+namespace Graphics {
+
+const VectorRenderer::ConvolutionDataSet VectorRenderer::_convolutionData[VectorRenderer::kConvolutionMAX] = {
+	{ {{1, 1, 1}, {1, 8, 1}, {1, 1, 1}}, 16, 0 }, // soft blur matrix
+	{ {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, 18, 0 }, // hard blur matrix
+	{ {{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}, 16, 0 }, // gaussian blur matrix
+	{ {{2, 0, 0}, {0, -1, 0}, {0, 0, -1}}, 1, 127}, // emboss matrix
+	{ {{-1, -1, -1}, {-1, 9, -1}, {-1, -1, -1}}, 1, 0}, // sharpen matrix
+	{ {{1, 1, 1}, {1, -7, 1}, {1, 1, 1}}, 1, 0} // edge find matrix
+};
+
+/********************************************************************
+ * DRAWSTEP handling functions
+ ********************************************************************/
+void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra) {
+
+	if (step.bgColor.set)
+		setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
+
+	if (step.fgColor.set)
+		setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
+		
+	if (step.bevelColor.set)
+		setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
+
+	if (step.gradColor1.set && step.gradColor2.set)
+		setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b, 
+						  step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
+
+	setShadowOffset(_disableShadows ? 0 : step.shadow);
+	setBevel(step.bevel);
+	setGradientFactor(step.factor);
+	setStrokeWidth(step.stroke);
+	setFillMode((FillMode)step.fillMode);
+	
+	_dynamicData = extra;
+
+	(this->*(step.drawingCall))(area, step);
+}
+
+int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
+	int radius = 0;
+
+	if (step.radius == 0xFF)
+		radius = MIN(area.width(), area.height()) / 2;
+	else
+		radius = step.radius;
+
+	if (step.scale != (1 << 16) && step.scale != 0)
+		radius = (radius * step.scale) >> 16;
+
+	return radius;
+}
+
+void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
+	if (!step.autoWidth) {
+		in_w = step.w == -1 ? area.height() : step.w;
+		
+		switch(step.xAlign) {
+			case Graphics::DrawStep::kVectorAlignManual:
+				if (step.x >= 0) in_x = area.left + step.x;
+				else in_x = area.left + area.width() + step.x; // value relative to the opposite corner.
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignCenter:
+				in_x = area.left + (area.width() / 2) - (in_w / 2); 
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignLeft:
+				in_x = area.left;
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignRight:
+				in_x = area.left + area.width() - in_w;
+				break;
+				
+			default:
+				error("Vertical alignment in horizontal data.");
+		}
+	} else {
+		in_x = area.left;
+		in_w = area.width();
+	}
+	
+	if (!step.autoHeight) {
+		in_h = step.h == -1 ? area.width() : step.h;
+		
+		switch(step.yAlign) {
+			case Graphics::DrawStep::kVectorAlignManual:
+				if (step.y >= 0) in_y = area.top + step.y;
+				else in_y = area.top + area.height() + step.y; // relative
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignCenter:
+				in_y = area.top + (area.height() / 2) - (in_h / 2); 
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignTop:
+				in_y = area.top;
+				break;
+				
+			case Graphics::DrawStep::kVectorAlignBottom:
+				in_y = area.top + area.height() - in_h;
+				break;
+				
+			default:
+				error("Horizontal alignment in vertical data.");
+		}
+	} else {
+		in_y = area.top;
+		in_h = area.height();
+	}
+
+	if (step.scale != (1 << 16) && step.scale != 0) {
+		in_x = (in_x * step.scale) >> 16;
+		in_y = (in_y * step.scale) >> 16;
+		in_w = (in_w * step.scale) >> 16;
+		in_h = (in_h * step.scale) >> 16;
+	}
+}
+
+} // end of namespace Graphics


Property changes on: scummvm/trunk/graphics/VectorRenderer.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/graphics/VectorRenderer.h
===================================================================
--- scummvm/trunk/graphics/VectorRenderer.h	                        (rev 0)
+++ scummvm/trunk/graphics/VectorRenderer.h	2008-10-09 11:49:35 UTC (rev 34757)
@@ -0,0 +1,557 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef VECTOR_RENDERER_H
+#define VECTOR_RENDERER_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+
+#include "graphics/surface.h"
+#include "graphics/colormasks.h"
+
+#include "gui/ThemeEngine.h"
+
+namespace Graphics {
+class VectorRenderer;
+
+struct DrawStep {
+	struct { 
+		uint8 r, g, b;
+		bool set;
+	}	
+	fgColor, /** Foreground color */
+	bgColor, /** backgroudn color */
+	gradColor1, /** gradient start*/
+	gradColor2, /** gradient end */
+	bevelColor;
+
+	bool autoWidth, autoHeight;
+	int16 x, y, w, h; /** width, height and position, if not measured automatically.
+	 					  negative values mean counting from the opposite direction */
+	
+	enum VectorAlignment {
+		kVectorAlignManual,
+		kVectorAlignLeft,
+		kVectorAlignRight,
+		kVectorAlignBottom,
+		kVectorAlignTop,
+		kVectorAlignCenter
+	} xAlign, yAlign;
+
+	uint8 shadow, stroke, factor, radius, bevel; /** Misc options... */
+
+	uint8 fillMode; /** active fill mode */
+	uint32 extraData; /** Generic parameter for extra options (orientation/bevel) */
+
+	uint32 scale; /** scale of all the coordinates in FIXED POINT with 16 bits mantissa */
+
+	void (VectorRenderer::*drawingCall)(const Common::Rect &, const DrawStep &); /** Pointer to drawing function */
+	Graphics::Surface *blitSrc;
+};
+
+VectorRenderer *createRenderer(int mode);
+
+/**
+ * VectorRenderer: The core Vector Renderer Class
+ *
+ * This virtual class exposes the API with all the vectorial
+ * rendering functions that may be used to draw on a given Surface.
+ *
+ * This class must be instantiated as one of its children, which implement
+ * the actual rendering functionality for each Byte Depth / Byte Format
+ * combination, and may also contain platform specific code.
+ *
+ * TODO: Expand documentation.
+ *
+ * @see VectorRendererSpec
+ * @see VectorRendererAA
+ */
+class VectorRenderer {
+public:
+	VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled), 
+		_activeSurface(NULL), _strokeWidth(1), _gradientFactor(1), _disableShadows(false) {
+	
+	}
+
+	virtual ~VectorRenderer() {}
+
+	/** Specifies the way in which a shape is filled */
+	enum FillMode {
+		kFillDisabled = 0,
+		kFillForeground = 1,
+		kFillBackground = 2,
+		kFillGradient = 3
+	};
+
+	enum TriangleOrientation {
+		kTriangleAuto = 0,
+		kTriangleUp,
+		kTriangleDown,
+		kTriangleLeft,
+		kTriangleRight
+	};
+	
+	enum ConvolutionData {
+		kConvolutionSoftBlur,
+		kConvolutionHardBlur,
+		kConvolutionGaussianBlur,
+		kConvolutionEmboss,
+		kConvolutionSharpen,
+		kConvolutionEdgeDetect,
+		kConvolutionMAX
+	};
+	
+	struct ConvolutionDataSet {
+		int matrix[3][3];
+		int divisor;
+		int offset;
+	};
+
+	/**
+	 * Draws a line by considering the special cases for optimization.
+	 *
+	 * @param x1 Horizontal (X) coordinate for the line start
+	 * @param x2 Horizontal (X) coordinate for the line end
+	 * @param y1 Vertical (Y) coordinate for the line start
+	 * @param y2 Vertical (Y) coordinate for the line end
+	 */
+	virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
+
+	/**
+	 * Draws a circle centered at (x,y) with radius r.
+	 *
+	 * @param x Horizontal (X) coordinate for the center of the circle
+	 * @param y Vertical (Y) coordinate for the center of the circle
+	 * @param r Radius of the circle.
+	 */
+	virtual void drawCircle(int x, int y, int r) = 0;
+
+	/**
+	 * Draws a square starting at (x,y) with the given width and height.
+	 *
+	 * @param x Horizontal (X) coordinate for the center of the square
+	 * @param y Vertical (Y) coordinate for the center of the square
+	 * @param w Width of the square.
+	 * @param h Height of the square
+	 */
+	virtual void drawSquare(int x, int y, int w, int h) = 0;
+
+	/**
+	 * Draws a rounded square starting at (x,y) with the given width and height.
+	 * The corners of the square are rounded with the given radius.
+	 *
+	 * @param x Horizontal (X) coordinate for the center of the square
+	 * @param y Vertical (Y) coordinate for the center of the square
+	 * @param w Width of the square.
+	 * @param h Height of the square
+	 * @param r Radius of the corners.
+	 */
+	virtual void drawRoundedSquare(int x, int y, int r, int w, int h) = 0;
+
+	/**
+	 * Draws a triangle starting at (x,y) with the given base and height.
+	 * The triangle will always be isosceles, with the given base and height.
+	 * The orientation parameter controls the position of the base of the triangle.
+	 *
+	 * @param x Horizontal (X) coordinate for the top left corner of the triangle
+	 * @param y Vertical (Y) coordinate for the top left corner of the triangle
+	 * @param base Width of the base of the triangle
+	 * @param h Height of the triangle
+	 * @param orient Orientation of the triangle.
+	 */
+	virtual void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient) = 0;
+
+	/**
+	 * Draws a beveled square like the ones in the Classic GUI themes.
+	 * Beveled squares are always drawn with a transparent background. Draw them on top
+	 * of a standard square to fill it.
+	 *
+	 * @param x Horizontal (X) coordinate for the center of the square
+	 * @param y Vertical (Y) coordinate for the center of the square
+	 * @param w Width of the square.
+	 * @param h Height of the square
+	 * @param bevel Amount of bevel. Must be positive.
+	 */
+	virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0;
+	
+	/**
+	 * Draws a tab-like shape, specially thought for the Tab widget.
+	 * If a radius is given, the tab will have rounded corners. Otherwise,
+	 * the tab will be squared.
+	 *
+	 * @param x Horizontal (X) coordinate for the tab
+	 * @param y Vertical (Y) coordinate for the tab
+	 * @param w Width of the tab
+	 * @param h Height of the tab
+	 * @param r Radius of the corners of the tab (0 for squared tabs).
+	 */
+	virtual void drawTab(int x, int y, int r, int w, int h) = 0;
+	
+	
+	/**
+	 * Simple helper function to draw a cross.
+	 */
+	virtual void drawCross(int x, int y, int w, int h) {
+		drawLine(x, y, x + w, y + w);
+		drawLine(x + w, y, x, y + h);
+	}
+
+	/**
+	 * Gets the pixel pitch for the current drawing surface.
+	 * Note: This is a real pixel-pitch, not a byte-pitch.
+	 * That means it can be safely used in pointer arithmetics and
+	 * in pixel manipulation.
+	 *
+	 * @return integer with the active bytes per pixel
+	 */
+	virtual uint16 surfacePitch() {
+		return _activeSurface->pitch / _activeSurface->bytesPerPixel;
+	}
+
+	/**
+	 * Gets the BYTES (not bits) per Pixel we are working on,
+	 * based on the active drawing surface.
+	 *
+	 * @return integer byte with the active bytes per pixel value
+	 */
+	virtual uint8 bytesPerPixel() {
+		return _activeSurface->bytesPerPixel;
+	}
+
+	/**
+	 * Set the active foreground painting color for the renderer.
+	 * All the foreground drawing from then on will be done with that color, unless
+	 * specified otherwise.
+	 *
+	 * Foreground drawing means all outlines and basic shapes.
+	 *
+	 * @param r	value of the red color byte
+	 * @param g	value of the green color byte
+	 * @param b	value of the blue color byte
+	 */
+	virtual void setFgColor(uint8 r, uint8 g, uint8 b) = 0;
+
+	/**
+	 * Set the active background painting color for the renderer.
+	 * All the background drawing from then on will be done with that color, unless
+	 * specified otherwise.
+	 *
+	 * Background drawing means all the shape filling.
+	 *
+	 * @param r	value of the red color byte
+	 * @param g	value of the green color byte
+	 * @param b	value of the blue color byte
+	 */
+	virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0;
+	
+	virtual void setBevelColor(uint8 r, uint8 g, uint8 b) = 0;
+
+	/**
+	 * Set the active gradient color. All shapes drawn using kFillGradient
+	 * as their fill mode will use this VERTICAL gradient as their fill color.
+	 *
+	 * @param r1	value of the red color byte for the start color
+	 * @param g1	value of the green color byte for the start color
+	 * @param b1	value of the blue color byte for the start color
+	 * @param r2	value of the red color byte for the end color
+	 * @param g2	value of the green color byte for the end color
+	 * @param b2	value of the blue color byte for the end color
+	 */
+	virtual void setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2) = 0;
+
+	/**
+	 * Sets the active drawing surface. All drawing from this
+	 * point on will be done on that surface.
+	 *
+	 * @param surface Pointer to a Surface object.
+	 */
+	virtual void setSurface(Surface *surface) {
+		_activeSurface = surface;
+	}
+
+	/**
+	 * Fills the active surface with the specified fg/bg color or the active gradient.
+	 * Defaults to using the active Foreground color for filling.
+	 *
+	 * @param mode Fill mode (bg, fg or gradient) used to fill the surface
+	 */
+	virtual void fillSurface() = 0;
+
+	/**
+	 * Clears the active surface.
+	 */
+	virtual void clearSurface() {
+		byte *src = (byte *)_activeSurface->pixels;
+		memset(src, 0, _activeSurface->w * _activeSurface->h * _activeSurface->bytesPerPixel);
+	}
+
+	/**
+	 * Sets the active fill mode for all shapes.
+	 *
+	 * @see VectorRenderer::FillMode
+	 * @param mode Specified fill mode.
+	 */
+	virtual void setFillMode(FillMode mode) {
+		_fillMode = mode;
+	}
+
+	/**
+	 * Sets the stroke width. All shapes drawn with a stroke will
+	 * have that width. Pass 0 to disable shape stroking.
+	 *
+	 * @param width Witdh of the stroke in pixels.
+	 */
+	virtual void setStrokeWidth(int width) {
+		_strokeWidth = width;
+	}
+
+	/**
+	 * Enables adding shadows to all drawn primitives.
+	 * Shadows are drawn automatically under the shapes. The given offset
+	 * controls their intensity and size (the higher the offset, the
+	 * bigger the shadows). If the offset is 0, no shadows are drawn.
+	 *
+	 * @param offset Shadow offset.
+	 */
+	virtual void setShadowOffset(int offset) {
+		if (offset >= 0)
+			_shadowOffset = offset;
+	}
+	
+	virtual void setBevel(int amount) {
+		if (amount >= 0)
+			_bevel = amount;
+	}
+
+	/**
+	 * Sets the multiplication factor of the active gradient.
+	 *
+	 * @see _gradientFactor
+	 * @param factor Multiplication factor.
+	 */
+	virtual void setGradientFactor(int factor) {
+		if (factor > 0)
+			_gradientFactor = factor;
+	}
+
+	/**
+	 * Translates the position data inside a DrawStep into actual
+	 * screen drawing positions.
+	 */
+	void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h);
+
+	/**
+	 * Translates the radius data inside a drawstep into the real radius
+	 * for the shape. Used for automatic radius calculations.
+	 */
+	int stepGetRadius(const DrawStep &step, const Common::Rect &area);
+
+	/**
+	 * DrawStep callback functions for each drawing feature 
+	 */
+	void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h, radius;
+
+		radius = stepGetRadius(step, area);
+		stepGetPositions(step, area, x, y, w, h);
+
+		drawCircle(x + radius, y + radius, radius);
+	}
+
+	void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawSquare(x, y, w, h);
+	}
+
+	void drawCallback_LINE(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawLine(x, y, x + w, y + w);
+	}
+
+	void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawRoundedSquare(x, y, stepGetRadius(step, area), w, h);
+	}
+
+	void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) {
+		fillSurface();
+	}
+
+	void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawTriangle(x, y, w, h, (TriangleOrientation)step.extraData);
+	}
+
+	void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawBeveledSquare(x, y, w, h, _bevel);
+	}
+	
+	void drawCallback_TAB(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawTab(x, y, stepGetRadius(step, area), w, h);
+	}
+	
+	void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		blitAlphaBitmap(step.blitSrc, Common::Rect(x, y, x + w, y + h));
+	}
+	
+	void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step) {
+		uint16 x, y, w, h;
+		stepGetPositions(step, area, x, y, w, h);
+		drawCross(x, y, w, h);
+	}
+
+	void drawCallback_VOID(const Common::Rect &area, const DrawStep &step) {}
+
+	/**
+	 * Draws the specified draw step on the screen.
+	 * 
+	 * @see DrawStep
+	 * @param area Zone to paint on
+	 * @param step Pointer to a DrawStep struct.
+	 */
+	virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0);
+
+	/**
+	 * Copies the part of the current frame to the system overlay.
+	 *
+	 * @param sys Pointer to the global System class
+	 * @param r Zone of the surface to copy into the overlay.
+	 */
+	virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0;
+	
+	/**
+	 * Copies the current surface to the system overlay 
+	 *
+	 * @param sys Pointer to the global System class
+	 */
+	virtual void copyWholeFrame(OSystem *sys) = 0;
+
+	/**
+	 * Blits a given graphics surface on top of the current drawing surface.
+	 *
+	 * Note that the source surface and the active
+	 * surface are expected to be of the same size, hence the area delimited
+	 * by "r" in the source surface will be blitted into the area delimited by 
+	 * "r" on the current surface.
+	 *
+	 * If you wish to blit a smaller surface into the active drawing area, use
+	 * VectorRenderer::blitSubSurface().
+	 *
+	 * @param source Surface to blit into the drawing surface.
+	 * @param r Position in the active drawing surface to do the blitting.
+	 */
+	virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
+	
+	/**
+	 * Blits a given graphics surface into a small area of the current drawing surface.
+	 *
+	 * Note that the given surface is expected to be smaller than the
+	 * active drawing surface, hence the WHOLE source surface will be
+	 * blitted into the active surface, at the position specified by "r".
+	 */
+	virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
+	
+	virtual void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
+	
+	/**
+	 * Draws a string into the screen. Wrapper for the Graphics::Font string drawing
+	 * method.
+	 */
+	virtual void drawString(const Graphics::Font *font, const Common::String &text, 
+	                        const Common::Rect &area, GUI::Theme::TextAlign alignH, 
+	                        GUI::Theme::TextAlignVertical alignV, int deltax, bool useEllipsis) = 0;
+	
+	/**
+	 * Allows to temporarily enable/disable all shadows drawing.
+	 * i.e. for performance issues, blitting, etc
+	 */
+	virtual void disableShadows() { _disableShadows = true; }
+	virtual void enableShadows() { _disableShadows = false; }
+	
+	/**
+	 * Applies a convolution matrix on the given surface area.
+	 * Call applyConvolutionMatrix() instead if you want to use
+	 * the embeded matrixes (blur/sharpen masks, bevels, etc).
+	 *
+	 * @param area Area in which the convolution matrix will be applied.
+	 * @param filter Convolution matrix (3X3)
+	 * @param filterDiv Divisor for the convolution matrix.
+	 *					Make sure this equals the total sum of the elements
+	 *					of the matrix or brightness data will be distorted.
+	 * @param offset Offset on the convolution area.
+	 */
+	virtual void areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) = 0;
+	
+	/**
+	 * Applies one of the predefined convolution effects on the given area.
+	 *
+	 * WARNING: Because of performance issues, this is currently disabled on all renderers.
+	 *
+	 * @param id Id of the convolution data set (see VectorRenderer::ConvolutionData)
+	 * @param area Area in which the convolution effect will be applied.
+	 */
+	virtual void applyConvolutionMatrix(const ConvolutionData id, const Common::Rect &area) {
+		areaConvolution(area, _convolutionData[id].matrix, _convolutionData[id].divisor, _convolutionData[id].offset);
+	}
+	
+	/**
+	 * Applies a whole-screen shading effect, used before opening a new dialog.
+	 * Currently supports screen dimmings and luminance (b&w).
+	 */
+	virtual void applyScreenShading(GUI::Theme::ShadingStyle) = 0;
+
+protected:
+	Surface *_activeSurface; /** Pointer to the surface currently being drawn */
+
+	FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */
+	
+	int _shadowOffset; /** offset for drawn shadows */
+	int _bevel; /** amount of fake bevel */
+	bool _disableShadows; /** Disables temporarily shadow drawing for overlayed images. */
+	int _strokeWidth; /** Width of the stroke of all drawn shapes */
+	uint32 _dynamicData; /** Dynamic data from the GUI Theme that modifies the drawing of the current shape */
+
+	int _gradientFactor; /** Multiplication factor of the active gradient */
+	int _gradientBytes[3]; /** Color bytes of the active gradient, used to speed up calculation */
+	
+	static const ConvolutionDataSet _convolutionData[kConvolutionMAX];
+	
+	static const int _dimPercentValue = 256 * 50 / 100; /** default value for screen dimming (50%) */
+};
+
+} // end of namespace Graphics
+
+#endif


Property changes on: scummvm/trunk/graphics/VectorRenderer.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/graphics/VectorRendererSpec.cpp
===================================================================
--- scummvm/trunk/graphics/VectorRendererSpec.cpp	                        (rev 0)
+++ scummvm/trunk/graphics/VectorRendererSpec.cpp	2008-10-09 11:49:35 UTC (rev 34757)
@@ -0,0 +1,1591 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+ 
+#include "common/util.h"
+#include "common/system.h"
+#include "common/events.h"
+
+#include "graphics/surface.h"
+#include "graphics/colormasks.h"
+
+#include "gui/ThemeEngine.h"
+#include "graphics/VectorRenderer.h"
+#include "graphics/VectorRendererSpec.h"
+
+#define VECTOR_RENDERER_FAST_TRIANGLES
+
+/** Fixed point SQUARE ROOT **/
+inline uint32 fp_sqroot(uint32 x) {
+	register uint32 root, remHI, remLO, testDIV, count;
+
+	root = 0;
+	remHI = 0;
+	remLO = x;
+	count = 23;
+
+	do {
+		remHI = (remHI << 2) | (remLO >> 30);
+		remLO <<= 2;
+		root <<= 1;
+		testDIV = (root << 1) + 1;
+
+		if (remHI >= testDIV) {
+			remHI -= testDIV;
+			root++;
+		}
+	} while (count--);
+
+	return root;
+}
+
+/*
+	HELPER MACROS for Bresenham's circle drawing algorithm 
+	Note the proper spelling on this header.
+*/
+#define __BE_ALGORITHM() { \
+	if (f >= 0) { \
+		y--; \
+		ddF_y += 2; \
+		f += ddF_y; \
+		py -= pitch; \
+	} \
+	px += pitch; \
+	ddF_x += 2; \
+	f += ddF_x + 1; \
+}
+
+#define __BE_DRAWCIRCLE(ptr1,ptr2,ptr3,ptr4,x,y,px,py) { \
+	*(ptr1 + (y) - (px)) = color; \
+	*(ptr1 + (x) - (py)) = color; \
+	*(ptr2 - (x) - (py)) = color; \
+	*(ptr2 - (y) - (px)) = color; \
+	*(ptr3 - (y) + (px)) = color; \
+	*(ptr3 - (x) + (py)) = color; \
+	*(ptr4 + (x) + (py)) = color; \
+	*(ptr4 + (y) + (px)) = color; \
+}
+
+#define __BE_DRAWCIRCLE_XCOLOR(ptr1,ptr2,ptr3,ptr4,x,y,px,py) { \
+	*(ptr1 + (y) - (px)) = color1; \
+	*(ptr1 + (x) - (py)) = color2; \
+	*(ptr2 - (x) - (py)) = color2; \
+	*(ptr2 - (y) - (px)) = color1; \
+	*(ptr3 - (y) + (px)) = color3; \
+	*(ptr3 - (x) + (py)) = color4; \
+	*(ptr4 + (x) + (py)) = color4; \
+	*(ptr4 + (y) + (px)) = color3; \
+}
+
+#define __BE_RESET() { \
+	f = 1 - r; \
+	ddF_x = 0; ddF_y = -2 * r; \
+	x = 0; y = r; px = 0; py = pitch * r; \
+}
+
+#define __TRIANGLE_MAINX() \
+		if (error_term >= 0) { \
+			ptr_right += pitch; \
+			ptr_left += pitch; \
+			error_term += dysub; \
+		} else { \
+			error_term += ddy; \
+		} \
+		ptr_right++; \
+		ptr_left--;
+
+#define __TRIANGLE_MAINY() \
+		if (error_term >= 0) { \
+			ptr_right++; \
+			ptr_left--; \
+			error_term += dxsub; \
+		} else { \
+			error_term += ddx; \
+		} \
+		ptr_right += pitch; \
+		ptr_left += pitch;
+		
+/** HELPER MACROS for WU's circle drawing algorithm **/
+#define __WU_DRAWCIRCLE(ptr1,ptr2,ptr3,ptr4,x,y,px,py,a) { \
+	blendPixelPtr(ptr1 + (y) - (px), color, a); \
+	blendPixelPtr(ptr1 + (x) - (py), color, a); \
+	blendPixelPtr(ptr2 - (x) - (py), color, a); \
+	blendPixelPtr(ptr2 - (y) - (px), color, a); \
+	blendPixelPtr(ptr3 - (y) + (px), color, a); \
+	blendPixelPtr(ptr3 - (x) + (py), color, a); \
+	blendPixelPtr(ptr4 + (x) + (py), color, a); \
+	blendPixelPtr(ptr4 + (y) + (px), color, a); \
+}
+
+// optimized Wu's algorithm
+#define __WU_ALGORITHM() { \
+	oldT = T; \
+	T = fp_sqroot(rsq - ((y * y) << 16)) ^ 0xFFFF; \
+	py += p; \
+	if (T < oldT) { \
+		x--; px -= p; \
+	} \
+	a2 = (T >> 8); \
+	a1 = ~a2; \
+}
+
+
+
+namespace Graphics {
+    
+VectorRenderer *createRenderer(int mode) {
+	switch (mode) {
+	case GUI::ThemeEngine::kGfxStandard16bit:
+		return new VectorRendererSpec<uint16, ColorMasks<565> >;
+
+	case GUI::ThemeEngine::kGfxAntialias16bit:
+		return new VectorRendererAA<uint16, ColorMasks<565> >;
+
+	default:
+		return 0;
+	}
+}
+     
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) {
+	PixelType *ptr = 0;
+	int newR, newG, newB;
+	uint8 r, g, b;
+	int yVal;
+	
+	for (int y = area.top; y < area.bottom; ++y) {
+		for (int x = area.left; x < area.right; ++x) {
+			newR = newG = newB = 0;
+
+			for (int j = 0; j < 3; ++j) {
+				yVal = MIN(MAX(y - 1 + j, 0), area.bottom - 1);
+				
+				for (int i = 0; i < 3; ++i) {
+					ptr = (PixelType *)Base::_activeSurface->getBasePtr(MIN(MAX(x - 1 + j, 0), area.right - 1), yVal);
+					colorToRGB<PixelFormat>((uint32)*ptr, r, g, b);
+					
+					newR += r * filter[j][i];
+					newG += g * filter[j][i];
+					newB += b * filter[j][i];
+				}
+			}
+			
+			newR = (newR / filterDiv) + offset;
+			newG = (newG / filterDiv) + offset;
+			newB = (newB / filterDiv) + offset;
+			
+			ptr = (PixelType *)Base::_activeSurface->getBasePtr(x, y);
+			*ptr = RGBToColor<PixelFormat>(CLIP(newR, 0, 255), CLIP(newG, 0, 255), CLIP(newB, 0, 255));
+		}		
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2) {
+	_gradientEnd = RGBToColor<PixelFormat>(r2, g2, b2);
+	_gradientStart = RGBToColor<PixelFormat>(r1, g1, b1);
+
+	Base::_gradientBytes[0] = (_gradientEnd & PixelFormat::kRedMask) - (_gradientStart & PixelFormat::kRedMask);
+	Base::_gradientBytes[1] = (_gradientEnd & PixelFormat::kGreenMask) - (_gradientStart & PixelFormat::kGreenMask);
+	Base::_gradientBytes[2] = (_gradientEnd & PixelFormat::kBlueMask) - (_gradientStart & PixelFormat::kBlueMask);
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+fillSurface() {
+	PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0);
+
+	int w = _activeSurface->w;
+	int h = _activeSurface->h ;
+	int pitch = surfacePitch();
+
+	if (Base::_fillMode == kFillBackground)
+		colorFill(ptr, ptr + w * h, _bgColor);
+	else if (Base::_fillMode == kFillForeground)
+		colorFill(ptr, ptr + w * h, _fgColor);
+	else if (Base::_fillMode == kFillGradient) {
+		int i = h;
+		while (i--) {
+			colorFill(ptr, ptr + w, calcGradient(h - i, h));
+			ptr += pitch;
+		}
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+copyFrame(OSystem *sys, const Common::Rect &r) {
+
+	sys->copyRectToOverlay(
+
+#ifdef OVERLAY_MULTIPLE_DEPTHS
+    (const PixelType*)
+#else
+	(const OverlayColor*)
+#endif
+
+	    _activeSurface->getBasePtr(r.left, r.top), _activeSurface->w, 
+	    r.left, r.top, r.width(), r.height()
+	);
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+blitSurface(const Graphics::Surface *source, const Common::Rect &r) {
+	assert(source->w == _activeSurface->w && source->h == _activeSurface->h);
+	
+	PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top);
+	PixelType *src_ptr = (PixelType *)source->getBasePtr(r.left, r.top);
+
+	int dst_pitch = surfacePitch();
+	int src_pitch = source->pitch / source->bytesPerPixel;
+
+	int h = r.height(), w = r.width();
+
+	while (h--) {
+		memcpy(dst_ptr, src_ptr, w * sizeof(PixelType));
+		dst_ptr += dst_pitch;
+		src_ptr += src_pitch;
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) {
+	PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top);
+	PixelType *src_ptr = (PixelType *)source->getBasePtr(0, 0);
+	
+	int dst_pitch = surfacePitch();
+	int src_pitch = source->pitch / source->bytesPerPixel;
+	
+	int h = r.height(), w = r.width();
+	
+	while (h--) {
+		memcpy(dst_ptr, src_ptr, w * sizeof(PixelType));
+		dst_ptr += dst_pitch;
+		src_ptr += src_pitch;
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) {
+	int16 x = r.left;
+	int16 y = r.top;
+	
+	if (r.width() > source->w)
+		x = x + (r.width() >> 1) - (source->w >> 1);
+		
+	if (r.height() > source->h)
+		y = y + (r.height() >> 1) - (source->h >> 1);
+		
+	PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
+	PixelType *src_ptr = (PixelType *)source->getBasePtr(0, 0);
+	
+	int dst_pitch = surfacePitch();
+	int src_pitch = source->pitch / source->bytesPerPixel;
+	
+	int w, h = source->h;
+	
+	while (h--) {
+		w = source->w;
+		
+		while (w--) {
+			if (*src_ptr != _bitmapAlphaColor)
+				*dst_ptr = *src_ptr;
+				
+			dst_ptr++;
+			src_ptr++;
+		}
+		
+		dst_ptr = dst_ptr - source->w + dst_pitch;
+		src_ptr = src_ptr - source->w + src_pitch;
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+applyScreenShading(GUI::Theme::ShadingStyle shadingStyle) {
+	int pixels = _activeSurface->w * _activeSurface->h;
+	PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0);
+	uint8 r, g, b;
+	uint lum;
+
+	const uint32 shiftMask = (uint32)~(
+		(1 << PixelFormat::kGreenShift) | 
+		(1 << PixelFormat::kRedShift) | 
+		(1 << PixelFormat::kBlueShift)) >> 1;
+	
+	if (shadingStyle == GUI::Theme::kShadingDim) {
+
+		int n = (pixels + 7) >> 3;
+		switch (pixels % 8) {
+		case 0: do { 
+					*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 7:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 6:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 5:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 4:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 3:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 2:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+		case 1:		*ptr = (*ptr >> 1) & shiftMask; ++ptr;
+				} while (--n > 0);
+		}
+
+	} else if (shadingStyle == GUI::Theme::kShadingLuminance) {
+		while (pixels--) {
+			colorToRGB<PixelFormat>(*ptr, r, g, b);
+			lum = (r >> 2) + (g >> 1) + (b >> 3);
+			*ptr++ = RGBToColor<PixelFormat>(lum, lum, lum);
+		}
+	}
+}
+
+template <typename PixelType, typename PixelFormat>
+inline void VectorRendererSpec<PixelType, PixelFormat>::
+blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha)	{
+	register int idst = *ptr;
+	register int isrc = color;
+
+	*ptr = (PixelType)(
+		(PixelFormat::kRedMask & ((idst & PixelFormat::kRedMask) +
+		((int)(((int)(isrc & PixelFormat::kRedMask) -
+		(int)(idst & PixelFormat::kRedMask)) * alpha) >> 8))) |
+		(PixelFormat::kGreenMask & ((idst & PixelFormat::kGreenMask) +
+		((int)(((int)(isrc & PixelFormat::kGreenMask) -
+		(int)(idst & PixelFormat::kGreenMask)) * alpha) >> 8))) |
+		(PixelFormat::kBlueMask & ((idst & PixelFormat::kBlueMask) +
+		((int)(((int)(isrc & PixelFormat::kBlueMask) -
+		(int)(idst & PixelFormat::kBlueMask)) * alpha) >> 8))) );
+}
+
+template <typename PixelType, typename PixelFormat>
+inline PixelType VectorRendererSpec<PixelType, PixelFormat>::
+calcGradient(uint32 pos, uint32 max) {
+	PixelType output = 0;
+	pos = (MIN(pos * Base::_gradientFactor, max) << 12) / max;
+	
+	output |= (_gradientStart + ((Base::_gradientBytes[0] * pos) >> 12)) & PixelFormat::kRedMask;
+	output |= (_gradientStart + ((Base::_gradientBytes[1] * pos) >> 12)) & PixelFormat::kGreenMask;
+	output |= (_gradientStart + ((Base::_gradientBytes[2] * pos) >> 12)) & PixelFormat::kBlueMask;
+	output |= ~(PixelFormat::kRedMask | PixelFormat::kGreenMask | PixelFormat::kBlueMask);
+
+	return output;
+}
+
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+colorFill(PixelType *first, PixelType *last, PixelType color) {
+	register int count = (last - first);
+	register int n = (count + 7) >> 3;
+	switch (count % 8) {
+	case 0: do { 
+				*first++ = color;
+	case 7:		*first++ = color;
+	case 6:		*first++ = color;
+	case 5:		*first++ = color;
+	case 4:		*first++ = color;
+	case 3:		*first++ = color;
+	case 2:		*first++ = color;
+	case 1:		*first++ = color;
+			} while (--n > 0);
+	}
+}
+
+/********************************************************************
+ ********************************************************************
+ * Primitive shapes drawing - Public API calls - VectorRendererSpec *
+ ********************************************************************
+ ********************************************************************/
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, 
+			GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax, bool ellipsis) {
+
+	int offset = area.top;
+	
+	if (font->getFontHeight() < area.height()) {
+		switch (alignV) {
+			case GUI::Theme::kTextAlignVCenter:
+				offset = area.top + ((area.height() - font->getFontHeight()) >> 1);
+				break;
+			case GUI::Theme::kTextAlignVBottom:
+				offset = area.bottom - font->getFontHeight();
+				break;
+			default:
+				break;
+		}
+	}
+	
+	font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, (Graphics::TextAlignment)alignH, deltax, ellipsis);
+}
+
+/** LINES **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawLine(int x1, int y1, int x2, int y2) {
+	x1 = CLIP(x1, 0, (int)Base::_activeSurface->w);
+	x2 = CLIP(x2, 0, (int)Base::_activeSurface->w);
+	y1 = CLIP(y1, 0, (int)Base::_activeSurface->h);
+	y2 = CLIP(y2, 0, (int)Base::_activeSurface->h);
+
+	// we draw from top to bottom
+	if (y2 < y1) {
+		SWAP(x1, x2);
+		SWAP(y1, y2);
+	}
+
+	int dx = ABS(x2 - x1);
+	int dy = ABS(y2 - y1);
+
+	// this is a point, not a line. stoopid.
+	if (dy == 0 && dx == 0) 
+		return;
+
+	if (Base::_strokeWidth == 0)
+		return;
+
+	PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
+	int pitch = Base::surfacePitch();
+	int st = Base::_strokeWidth >> 1;
+
+	if (dy == 0) { // horizontal lines
+		// these can be filled really fast with a single memset.
+		colorFill(ptr, ptr + dx + 1, (PixelType)_fgColor);
+		
+		for (int i = 0, p = pitch; i < st; ++i, p += pitch) {
+			colorFill(ptr + p, ptr + dx + 1 + p, (PixelType)_fgColor);
+			colorFill(ptr - p, ptr + dx + 1 - p, (PixelType)_fgColor);
+		}
+
+	} else if (dx == 0) { // vertical lines
+		// these ones use a static pitch increase.
+		while (y1++ <= y2) {
+			colorFill(ptr - st, ptr + st, (PixelType)_fgColor);
+			ptr += pitch;
+		}
+
+	} else if (ABS(dx) == ABS(dy)) { // diagonal lines
+		// these ones also use a fixed pitch increase
+		pitch += (x2 > x1) ? 1 : -1;
+
+		while (dy--) {
+			colorFill(ptr - st, ptr + st, (PixelType)_fgColor);
+			ptr += pitch;
+		}
+
+	} else { // generic lines, use the standard algorithm...
+		drawLineAlg(x1, y1, x2, y2, dx, dy, (PixelType)_fgColor);
+	}
+}
+
+/** CIRCLES **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawCircle(int x, int y, int r) {
+	if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h ||
+		x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
+		return;
+
+	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset 
+		&& x + r + Base::_shadowOffset < Base::_activeSurface->w
+		&& y + r + Base::_shadowOffset < Base::_activeSurface->h) {
+		drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillForeground);
+	}
+
+	switch (Base::_fillMode) {
+	case kFillDisabled:
+		if (Base::_strokeWidth)
+			drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
+		break;
+
+	case kFillForeground:
+		drawCircleAlg(x, y, r, _fgColor, kFillForeground);
+		break;
+
+	case kFillBackground:
+		if (Base::_strokeWidth > 1) {
+			drawCircleAlg(x, y, r, _fgColor, kFillForeground);
+			drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillBackground);
+		} else {
+			drawCircleAlg(x, y, r, _bgColor, kFillBackground);
+			drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
+		}
+		break;
+
+	case kFillGradient:
+		break;
+	}
+}
+
+/** SQUARES **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawSquare(int x, int y, int w, int h) {
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+		w <= 0 || h <= 0 || x < 0 || y < 0)
+		return;
+
+	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
+		&& x + w + Base::_shadowOffset < Base::_activeSurface->w
+		&& y + h + Base::_shadowOffset < Base::_activeSurface->h) {
+		drawSquareShadow(x, y, w, h, Base::_shadowOffset);
+	}
+
+	switch (Base::_fillMode) {
+	case kFillDisabled:
+		if (Base::_strokeWidth)
+			drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
+		break;
+
+	case kFillForeground:
+		drawSquareAlg(x, y, w, h, _fgColor, kFillForeground);
+		break;
+
+	case kFillBackground:
+		drawSquareAlg(x, y, w, h, _bgColor, kFillBackground);
+		drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
+		break;
+
+	case kFillGradient:
+		VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillGradient);
+		if (Base::_strokeWidth)
+			drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
+		break;
+	}
+}
+
+/** ROUNDED SQUARES **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawRoundedSquare(int x, int y, int r, int w, int h) {
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+		w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0)
+		return;
+		
+	if ((r << 1) > w || (r << 1) > h)
+		r = MIN(w >> 1, h >> 1);
+
+	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
+		&& x + w + Base::_shadowOffset < Base::_activeSurface->w
+		&& y + h + Base::_shadowOffset < Base::_activeSurface->h) {
+		drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset);
+	}
+
+	switch (Base::_fillMode) {
+	case kFillDisabled:
+		if (Base::_strokeWidth)
+			drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
+		break;
+
+	case kFillForeground:
+		drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillForeground);
+		break;
+
+	case kFillBackground:
+		VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kFillBackground);
+		drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
+		break;
+
+	case kFillGradient:
+		if (Base::_strokeWidth > 1) {
+			drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillForeground);
+			VectorRendererSpec::drawRoundedSquareAlg(x + Base::_strokeWidth/2, y + Base::_strokeWidth/2, 
+				r - Base::_strokeWidth/2, w - Base::_strokeWidth, h - Base::_strokeWidth, 0, kFillGradient);
+		} else {
+			VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kFillGradient);
+			if (Base::_strokeWidth)
+				drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
+		}
+		break;
+	}
+	
+	if (Base::_bevel)
+		drawRoundedSquareFakeBevel(x, y, r, w, h, Base::_bevel);
+}
+
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawTab(int x, int y, int r, int w, int h) {
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+		w <= 0 || h <= 0 || x < 0 || y < 0 || r > w || r > h)
+		return;
+		
+	if (r == 0 && Base::_bevel > 0) {
+		drawBevelTabAlg(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
+		return;
+	}
+	
+	if (r == 0) return;
+	
+	switch (Base::_fillMode) {
+		case kFillDisabled:
+			return;
+		
+		case kFillGradient:
+		case kFillBackground:
+			drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
+			if (Base::_strokeWidth)
+				drawTabAlg(x, y, w, h, r, _fgColor, kFillDisabled, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
+			break;
+			
+		case kFillForeground:
+			drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
+			break;
+	}
+}
+
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
+	
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
+		return;
+
+	PixelType color = 0;
+
+	if (Base::_strokeWidth <= 1) {
+		if (Base::_fillMode == kFillForeground)
+			color = _fgColor;
+		else if (Base::_fillMode == kFillBackground)
+			color = _bgColor;
+	} else {
+		if (Base::_fillMode == kFillDisabled)
+			return;
+		color = _fgColor;
+	}
+	
+	if (Base::_dynamicData != 0)
+		orient = (TriangleOrientation)Base::_dynamicData;
+		
+	int newW = w / 2;
+	if (newW % 2) newW++;
+
+	switch(orient) {
+		case kTriangleUp:
+		case kTriangleDown:
+			drawTriangleFast(x + (newW / 2), y + (h / 2) - (newW / 2), newW, (orient == kTriangleDown), color, Base::_fillMode);
+			break;
+
+		case kTriangleLeft:
+		case kTriangleRight:
+		case kTriangleAuto:
+			break;
+	}
+
+	if (Base::_strokeWidth > 0)
+		if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillGradient) {
+			drawTriangleFast(x + (newW / 2), y + (h / 2) - (newW / 2), newW, (orient == kTriangleDown), _fgColor, kFillDisabled);
+		}
+}
+
+
+
+
+
+/********************************************************************
+ ********************************************************************
+ * Aliased Primitive drawing ALGORITHMS - VectorRendererSpec
+ ********************************************************************
+ ********************************************************************/
+/** TAB ALGORITHM - NON AA */
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight) {
+	int f, ddF_x, ddF_y;
+	int x, y, px, py;
+	int pitch = Base::surfacePitch();
+	int sw  = 0, sp = 0, hp = 0;
+	
+	PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
+	PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
+	PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+
+	int real_radius = r;
+	int short_h = h - r + 2;
+	int long_h = h;
+
+	if (fill_m == kFillDisabled) {
+		while (sw++ < Base::_strokeWidth) {
+			colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
+			colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
+			sp += pitch;
+
+			__BE_RESET();
+			r--;
+			
+			while (x++ < y) {
+				__BE_ALGORITHM();
+				*(ptr_tr + (y) - (px)) = color;
+				*(ptr_tr + (x) - (py)) = color;
+				*(ptr_tl - (x) - (py)) = color;
+				*(ptr_tl - (y) - (px)) = color;
+
+				if (Base::_strokeWidth > 1) {
+					*(ptr_tr + (y) - (px - pitch)) = color;
+					*(ptr_tr + (x) - (py)) = color;
+					*(ptr_tl - (x) - (py)) = color;
+					*(ptr_tl - (y) - (px - pitch)) = color;
+				}
+			} 
+		}
+
+		ptr_fill += pitch * real_radius;
+		while (short_h--) {
+			colorFill(ptr_fill, ptr_fill + Base::_strokeWidth - 1, color);
+			colorFill(ptr_fill + w - Base::_strokeWidth + 2, ptr_fill + w, color);
+			ptr_fill += pitch;
+		}
+		
+		if (baseLeft) {
+			sw = 0;
+			ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1 + h);
+			while (sw++ < Base::_strokeWidth) {
+				colorFill(ptr_fill - baseLeft, ptr_fill, color);
+				ptr_fill += pitch;
+			}
+		}
+		
+		if (baseRight) {
+			sw = 0;
+			ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w, y1 + h);
+			while (sw++ < Base::_strokeWidth) {
+				colorFill(ptr_fill, ptr_fill + baseRight, color);
+				ptr_fill += pitch;
+			}
+		}
+	} else {
+		__BE_RESET();
+
+		PixelType color1, color2;
+		color1 = color2 = color;
+		
+		while (x++ < y) {
+			__BE_ALGORITHM();
+	
+			if (fill_m == kFillGradient) {
+				color1 = calcGradient(real_radius - x, long_h);
+				color2 = calcGradient(real_radius - y, long_h);
+			}
+	
+			colorFill(ptr_tl - x - py, ptr_tr + x - py, color2);
+			colorFill(ptr_tl - y - px, ptr_tr + y - px, color1);
+	
+			*(ptr_tr + (y) - (px)) = color1;
+			*(ptr_tr + (x) - (py)) = color2;
+			*(ptr_tl - (x) - (py)) = color2;
+			*(ptr_tl - (y) - (px)) = color1;
+		}
+	
+		ptr_fill += pitch * r;
+		while (short_h--) {
+			if (fill_m == kFillGradient)
+				color = calcGradient(real_radius++, long_h);
+			colorFill(ptr_fill, ptr_fill + w + 1, color);
+			ptr_fill += pitch;
+		}
+	}
+}
+
+
+/** BEVELED TABS FOR CLASSIC THEME **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawBevelTabAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, int baseLeft, int baseRight) {
+	int pitch = Base::surfacePitch();
+	int i, j;
+	
+	PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y);
+	
+	i = bevel;
+	while (i--) {
+		colorFill(ptr_left, ptr_left + w, top_color);
+		ptr_left += pitch;
+	}
+
+	if (baseLeft > 0) {
+		i = h - bevel;
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y);
+		while (i--) {
+			colorFill(ptr_left, ptr_left + bevel, top_color);
+			ptr_left += pitch;
+		}
+	}
+
+	i = h - bevel;
+	j = bevel;
+	ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y);
+	while (i--) {
+		colorFill(ptr_left + j, ptr_left + bevel, bottom_color);
+		if (j > 0) j--;
+		ptr_left += pitch;
+	}
+	
+	i = bevel;
+	ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y + h - bevel);
+	while (i--) {
+		colorFill(ptr_left, ptr_left + baseRight + bevel, bottom_color);
+		
+		if (baseLeft)
+			colorFill(ptr_left - w - baseLeft + bevel, ptr_left - w + bevel + bevel, top_color);
+		ptr_left += pitch;
+	}
+}
+
+/** SQUARE ALGORITHM **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
+	PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
+	int pitch = Base::surfacePitch();
+	int max_h = h;
+	
+	if (fill_m != kFillDisabled) {
+		while (h--) {
+			if (fill_m == kFillGradient)
+				color = calcGradient(max_h - h, max_h);
+
+			colorFill(ptr, ptr + w, color);
+			ptr += pitch;
+		}
+	} else {
+		int sw = Base::_strokeWidth, sp = 0, hp = pitch * (h - 1);
+
+		while (sw--) {
+			colorFill(ptr + sp, ptr + w + sp, color);
+			colorFill(ptr + hp - sp, ptr + w + hp - sp, color);
+			sp += pitch;
+		}
+
+		while (h--) {
+			colorFill(ptr, ptr + Base::_strokeWidth, color);
+			colorFill(ptr + w - Base::_strokeWidth, ptr + w, color);
+			ptr += pitch;
+		}
+	}
+}
+
+/** SQUARE ALGORITHM **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) {
+	int pitch = Base::surfacePitch();
+	
+	int height = h;
+	PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y);
+	
+	if (fill) {
+		while (height--) {
+			blendFill(ptr_fill, ptr_fill + w, _bgColor, 200);
+			ptr_fill += pitch;
+		}
+	}
+	
+	int i, j;
+	x = MAX(x - bevel, 0);
+	y = MAX(y - bevel, 0);
+	h += bevel << 1;
+	w += bevel << 1;
+	
+	PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y);
+	
+	i = bevel;
+	while (i--) {
+		colorFill(ptr_left, ptr_left + w, top_color);
+		ptr_left += pitch;
+	}
+
+	i = h - bevel;
+	ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + bevel);
+	while (i--) {
+		colorFill(ptr_left, ptr_left + bevel, top_color);
+		ptr_left += pitch;
+	}
+
+	i = bevel;
+	ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + h - bevel);
+	while (i--) {
+		colorFill(ptr_left + i, ptr_left + w, bottom_color);
+		ptr_left += pitch;
+	}
+
+	i = h - bevel;
+	j = bevel - 1;
+	ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y);
+	while (i--) {
+		colorFill(ptr_left + j, ptr_left + bevel, bottom_color);
+		if (j > 0) j--;
+		ptr_left += pitch;
+	}
+}
+
+/** GENERIC LINE ALGORITHM **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType,PixelFormat>::
+drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
+	PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
+	int pitch = Base::surfacePitch();
+	int xdir = (x2 > x1) ? 1 : -1;
+
+	*ptr = (PixelType)color;
+
+	if (dx > dy) {
+		int ddy = dy * 2;
+		int dysub = ddy - (dx * 2);
+		int error_term = ddy - dx;
+
+		while (dx--) {
+			if (error_term >= 0) {
+				ptr += pitch;
+				error_term += dysub;
+			} else {
+				error_term += ddy;
+			}
+
+			ptr += xdir;
+			*ptr = (PixelType)color;
+		}
+	} else {
+		int ddx = dx * 2;
+		int dxsub = ddx - (dy * 2);
+		int error_term = ddx - dy;
+
+		while (dy--) {
+			if (error_term >= 0) {
+				ptr += xdir;
+				error_term += dxsub;
+			} else {
+				error_term += ddx;
+			}
+
+			ptr += pitch;
+			*ptr = (PixelType)color;
+		}
+	}
+
+	ptr = (PixelType *)_activeSurface->getBasePtr(x2, y2);
+	*ptr = (PixelType)color;
+}
+
+/** VERTICAL TRIANGLE DRAWING ALGORITHM **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType,PixelFormat>::
+drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
+	int dx = w >> 1, dy = h, gradient_h = 0;
+	int pitch = Base::surfacePitch();
+	PixelType *ptr_right = 0, *ptr_left = 0;
+
+	if (inverted) {
+		ptr_right = (PixelType *)_activeSurface->getBasePtr(x1, y1);
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x1 + w, y1);
+	} else {
+		ptr_right = ptr_left = (PixelType *)_activeSurface->getBasePtr(x1 + dx, y1);
+	}
+
+	if (dx > dy) {
+		int ddy = dy * 2;
+		int dysub = ddy - (dx * 2);
+		int error_term = ddy - dx;
+
+		switch(fill_m) {
+		case kFillDisabled:
+			while (dx--) {
+				__TRIANGLE_MAINX();
+				*ptr_right = color;
+				*ptr_left = color;
+			}
+			colorFill(ptr_left, ptr_right, color);
+			break;
+
+		case kFillForeground:
+		case kFillBackground:
+			while (dx--) {
+				__TRIANGLE_MAINX();
+				if (inverted) colorFill(ptr_right, ptr_left, color);
+				else colorFill(ptr_left, ptr_right, color);
+			}
+			break;
+
+		case kFillGradient:
+			while (dx--) {
+				__TRIANGLE_MAINX();
+				if (inverted) colorFill(ptr_right, ptr_left, calcGradient(gradient_h++, h));
+				else colorFill(ptr_left, ptr_right, calcGradient(gradient_h++, h));
+			}
+			break;
+		}
+	} else {
+		int ddx = dx * 2;
+		int dxsub = ddx - (dy * 2);
+		int error_term = ddx - dy;
+
+		switch(fill_m) {
+		case kFillDisabled:
+			while (dy--) {
+				__TRIANGLE_MAINY();
+				*ptr_right = color;
+				*ptr_left = color;
+			}
+			colorFill(ptr_left, ptr_right, color);
+			break;
+
+		case kFillForeground:
+		case kFillBackground:
+			while (dy--) {
+				__TRIANGLE_MAINY();
+				if (inverted) colorFill(ptr_right, ptr_left, color);
+				else colorFill(ptr_left, ptr_right, color);
+			}
+			break;
+		case kFillGradient:
+			while (dy--) {
+				__TRIANGLE_MAINY();
+				if (inverted) colorFill(ptr_right, ptr_left, calcGradient(gradient_h++, h));
+				else colorFill(ptr_left, ptr_right, calcGradient(gradient_h++, h));
+			}
+			break;
+		}
+	}
+}
+
+
+/** VERTICAL TRIANGLE DRAWING - FAST VERSION FOR SQUARED TRIANGLES */
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType,PixelFormat>::
+drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
+	int pitch = Base::surfacePitch();
+	int hstep = 0, dy = size;
+	bool grad = (fill_m == kFillGradient);
+	
+	PixelType *ptr_right = 0, *ptr_left = 0;
+	
+	if (inverted) {
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x1, y1);
+		ptr_right = (PixelType *)_activeSurface->getBasePtr(x1 + size, y1);
+	} else {
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x1, y1 + size);
+		ptr_right = (PixelType *)_activeSurface->getBasePtr(x1 + size, y1 + size);
+		pitch = -pitch;
+	}
+	
+	if (fill_m == kFillDisabled) {
+		while (ptr_left < ptr_right) {
+			*ptr_left = color;
+			*ptr_right = color;
+			ptr_left += pitch;
+			ptr_right += pitch;
+			if (hstep++ % 2) {
+				ptr_left++;
+				ptr_right--;
+			}
+		}
+	} else {
+		while (ptr_left < ptr_right) {
+			colorFill(ptr_left, ptr_right, grad ? calcGradient(dy--, size) : color);
+			ptr_left += pitch;
+			ptr_right += pitch;
+			if (hstep++ % 2) {
+				ptr_left++;
+				ptr_right--;
+			}	
+		}
+	}
+}
+
+/** ROUNDED SQUARE ALGORITHM **/
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
+	int f, ddF_x, ddF_y;
+	int x, y, px, py;
+	int pitch = Base::surfacePitch();
+	int sw = 0, sp = 0, hp = h * pitch;
+	
+	PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
+	PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
+	PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - r);
+	PixelType *ptr_br = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + h - r);
+	PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+
+	int real_radius = r;
+	int short_h = h - (2 * r) + 2;
+	int long_h = h;
+
+	if (fill_m == kFillDisabled) {
+		while (sw++ < Base::_strokeWidth) {

@@ Diff output truncated at 100000 characters. @@

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