[Scummvm-cvs-logs] SF.net SVN: scummvm: [32678] scummvm/branches/gsoc2008-gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Thu Jun 12 21:06:37 CEST 2008


Revision: 32678
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32678&view=rev
Author:   Tanoku
Date:     2008-06-12 12:06:37 -0700 (Thu, 12 Jun 2008)

Log Message:
-----------
Parser skeleton
Expanded drawing interface

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/dists/msvc9/scummvm.vcproj
    scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
    scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
    scummvm/branches/gsoc2008-gui/gui/module.mk

Added Paths:
-----------
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.h

Modified: scummvm/branches/gsoc2008-gui/dists/msvc9/scummvm.vcproj
===================================================================
--- scummvm/branches/gsoc2008-gui/dists/msvc9/scummvm.vcproj	2008-06-12 18:52:43 UTC (rev 32677)
+++ scummvm/branches/gsoc2008-gui/dists/msvc9/scummvm.vcproj	2008-06-12 19:06:37 UTC (rev 32678)
@@ -1205,6 +1205,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\gui\ThemeParser.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\gui\ThemeParser.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\gui\widget.cpp"
 				>
 			</File>

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-12 18:52:43 UTC (rev 32677)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-12 19:06:37 UTC (rev 32678)
@@ -123,6 +123,40 @@
 	addDirtyRect(r);
 }
 
+void InterfaceManager::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
+	if (!_initOk)
+		return;
+
+	drawDD(checked ? kDDCheckboxEnabled : kDDCheckboxDisabled, r);
+
+	Common::Rect r2 = r;
+	r2.left += 16; // TODO: add variable for checkbox text offset.
+
+	// TODO: text drawing
+//	getFont()->drawString(&_screen, str, r2.left, r2.top, r2.width(), getColor(state), Graphics::kTextAlignLeft, 0, false);
+
+	addDirtyRect(r);
+}
+
+void InterfaceManager::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
+	if (!_initOk)
+		return;
+
+	drawDD(kDDSliderEmpty, r);
+
+	Common::Rect r2 = r;
+	r2.setWidth(MIN((int16)width, r.width()));
+
+	drawDD(kDDSliderFull, r2);
+
+	addDirtyRect(r);
+}
+
+void InterfaceManager::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState sb_state, WidgetStateInfo state) {
+	if (!_initOk)
+		return;
+}
+
 int InterfaceManager::runGUI() {
 	Common::EventManager *eventMan = _system->getEventManager();
 	_system->showOverlay();

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h	2008-06-12 18:52:43 UTC (rev 32677)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h	2008-06-12 19:06:37 UTC (rev 32678)
@@ -73,8 +73,10 @@
 
 		kDDTab,
 
-		kDDScrollBarBase,
-		kDDScrollBarHandle,
+		kDDScrollbarBase,
+		kDDScrollbarButtonTop,
+		kDDScrollbarButtonBottom,
+		kDDScrollbarHandle,
 
 		kDDPopUp,
 		kDDCaret,
@@ -155,12 +157,12 @@
 
 	/** Widget drawing */
 	void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) {}
-	void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0); // {}
+	void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
 	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) {}
-	void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled) {}
-	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled) {}
+	void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
+	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled);
 	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled) {}
-	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled) {}
+	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled);
 	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) {}
 	void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) {}
 	void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);

Added: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-06-12 19:06:37 UTC (rev 32678)
@@ -0,0 +1,111 @@
+/* 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 "gui/ThemeParser.h"
+
+/**
+
+<drawdata = "background_default" cache = true>
+	<draw func = "roundedsq" fill = "gradient" gradient_start = "255, 255, 128" gradient_end = "128, 128, 128" size = "auto">
+	<draw func = "roundedsq" fill = "none" color = "0, 0, 0" size = "auto">
+</drawdata>
+
+*/
+
+namespace GUI {
+
+inline bool isValidNameChar(char c) {
+	return !isspace(c) && c != '/' && c != '*' && c != '\\' && 
+		c != '|' && c != '"' && c != '\'' && c != ',' && 
+		c != '<' && c != '>' && c != '=';
+}
+
+void ThemeParser::parserError(const char *error_string) {
+	_state = kParserError;
+}
+
+bool ThemeParser::parseDrawData() {
+
+	_state = kParserNeedKey;
+	
+	while (_text[_pos++]) {
+
+		while (isspace(_text[_pos]))
+			_pos++;
+
+		// comment handling: skip everything between /* and */
+		if (_text[_pos] == '/') {
+			if (_text[++_pos] != '*') {
+				parserError("Malformed comment string.");
+				return false;
+			}
+			
+			_pos++;
+
+			while (_text[_pos] != '*' && _text[_pos + 1] != '/')
+				_pos++;
+		}
+
+		switch (_state) {
+			case kParserNeedKey:
+				if (_text[_pos] != '<') {
+					parserError("Expecting key start.");
+					return false;
+				}
+
+				_state = kParserKeyNeedName;
+				break;
+
+			case kParserKeyNeedName:
+				_token.clear();
+				while (isValidNameChar(_text[_pos]))
+					_token += _text[_pos++];
+
+				if (!isspace(_text[_pos])) {
+					parserError("Invalid character in token name.");
+					return false;
+				}
+
+				_state = kParserKeyNeedToken;
+				break;
+
+			case kParserKeyNeedToken:
+				_token.clear();
+				break;
+
+			default:
+				return false;
+		}
+	}
+
+	return true;
+}
+
+}
+


Property changes on: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	                        (rev 0)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-06-12 19:06:37 UTC (rev 32678)
@@ -0,0 +1,64 @@
+/* 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 THEME_PARSER_H
+#define THEME_PARSER_H
+
+#include "common/scummsys.h"
+#include "graphics/surface.h"
+#include "common/system.h"
+
+namespace GUI {
+
+class ThemeParser {
+
+	ThemeParser() {}
+	~ThemeParser() {}
+
+	enum ParserState {
+		kParserKeyNeedName,
+		kParserKeyNeedToken,
+		kParserKeyNeedSubkey,
+		kParserNeedKey,
+		kParserInComment,
+		kParserError
+	};
+
+	bool parseDrawData();
+	void parserError(const char *error_string);
+	
+protected:
+	int _pos;
+	char *_text;
+
+	ParserState _state;
+
+	Common::String _error;
+	Common::String _token;
+};
+
+}
+
+#endif
\ No newline at end of file


Property changes on: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2008-gui/gui/module.mk
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/module.mk	2008-06-12 18:52:43 UTC (rev 32677)
+++ scummvm/branches/gsoc2008-gui/gui/module.mk	2008-06-12 19:06:37 UTC (rev 32678)
@@ -26,6 +26,7 @@
 	theme.o \
 	ThemeClassic.o \
 	ThemeModern.o \
+	ThemeParser.o \
 	theme-config.o
 
 # Include common rules


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