aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-06-12 19:06:37 +0000
committerVicent Marti2008-06-12 19:06:37 +0000
commit7a9a74691fef580467d93c713c03be613a6d289b (patch)
tree9badb25845ee23bcff69dc4d781b068cfa7ef877
parent5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5 (diff)
downloadscummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.tar.gz
scummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.tar.bz2
scummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.zip
Parser skeleton
Expanded drawing interface svn-id: r32678
-rw-r--r--dists/msvc9/scummvm.vcproj8
-rw-r--r--gui/InterfaceManager.cpp34
-rw-r--r--gui/InterfaceManager.h14
-rw-r--r--gui/ThemeParser.cpp111
-rw-r--r--gui/ThemeParser.h64
-rw-r--r--gui/module.mk1
6 files changed, 226 insertions, 6 deletions
diff --git a/dists/msvc9/scummvm.vcproj b/dists/msvc9/scummvm.vcproj
index 5667763fce..a0cc2c6e91 100644
--- a/dists/msvc9/scummvm.vcproj
+++ b/dists/msvc9/scummvm.vcproj
@@ -1205,6 +1205,14 @@
>
</File>
<File
+ RelativePath="..\..\gui\ThemeParser.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\gui\ThemeParser.h"
+ >
+ </File>
+ <File
RelativePath="..\..\gui\widget.cpp"
>
</File>
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp
index e64d292e16..a1eaa71c52 100644
--- a/gui/InterfaceManager.cpp
+++ b/gui/InterfaceManager.cpp
@@ -123,6 +123,40 @@ void InterfaceManager::drawLineSeparator(const Common::Rect &r, WidgetStateInfo
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();
diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h
index 05f95ee435..7ab3f4c9db 100644
--- a/gui/InterfaceManager.h
+++ b/gui/InterfaceManager.h
@@ -73,8 +73,10 @@ public:
kDDTab,
- kDDScrollBarBase,
- kDDScrollBarHandle,
+ kDDScrollbarBase,
+ kDDScrollbarButtonTop,
+ kDDScrollbarButtonBottom,
+ kDDScrollbarHandle,
kDDPopUp,
kDDCaret,
@@ -155,12 +157,12 @@ public:
/** 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);
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
new file mode 100644
index 0000000000..26745ac5a6
--- /dev/null
+++ b/gui/ThemeParser.cpp
@@ -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;
+}
+
+}
+
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
new file mode 100644
index 0000000000..c43088c36e
--- /dev/null
+++ b/gui/ThemeParser.h
@@ -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
diff --git a/gui/module.mk b/gui/module.mk
index be6e405b87..eecf9a093d 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS := \
theme.o \
ThemeClassic.o \
ThemeModern.o \
+ ThemeParser.o \
theme-config.o
# Include common rules