ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

ThemeEval.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_THEME_EVAL_H
00024 #define GUI_THEME_EVAL_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/hashmap.h"
00028 #include "common/hash-str.h"
00029 #include "common/stack.h"
00030 #include "common/str.h"
00031 #include "common/textconsole.h"
00032 #include "graphics/font.h"
00033 
00034 #include "gui/ThemeLayout.h"
00035 
00036 namespace GUI {
00037 
00038 class ThemeEval {
00039 
00040     typedef Common::HashMap<Common::String, int> VariablesMap;
00041     typedef Common::HashMap<Common::String, ThemeLayout *> LayoutsMap;
00042 
00043 public:
00044     ThemeEval() {
00045         buildBuiltinVars();
00046     }
00047 
00048     ~ThemeEval();
00049 
00050     void buildBuiltinVars();
00051 
00052     int getVar(const Common::String &s) {
00053         if (_vars.contains(s))
00054             return _vars[s];
00055 
00056         if (_builtin.contains(s))
00057             return _builtin[s];
00058 
00059         error("CRITICAL: Missing variable: '%s'", s.c_str());
00060         return -13375; //EVAL_UNDEF_VAR
00061     }
00062 
00063     int getVar(const Common::String &s, int def) {
00064         if (_vars.contains(s))
00065             return _vars[s];
00066 
00067         if (_builtin.contains(s))
00068             return _builtin[s];
00069 
00070         return def;
00071     }
00072 
00073     void setVar(const Common::String &name, int val) { _vars[name] = val; }
00074 
00075     bool hasVar(const Common::String &name) { return _vars.contains(name) || _builtin.contains(name); }
00076 
00077     ThemeEval &addDialog(const Common::String &name, const Common::String &overlays, int16 maxWidth = -1, int16 maxHeight = -1, int inset = 0);
00078     ThemeEval &addLayout(ThemeLayout::LayoutType type, int spacing = -1, ThemeLayout::ItemAlign itemAlign = ThemeLayout::kItemAlignStart);
00079     ThemeEval &addWidget(const Common::String &name, const Common::String &type, int w = -1, int h = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft);
00080     ThemeEval &addImportedLayout(const Common::String &name);
00081     ThemeEval &addSpace(int size = -1);
00082 
00083     ThemeEval &addPadding(int16 l, int16 r, int16 t, int16 b) { _curLayout.top()->setPadding(l, r, t, b); return *this; }
00084 
00085     ThemeEval &closeLayout() { _curLayout.pop(); return *this; }
00086     ThemeEval &closeDialog() { _curLayout.pop(); _curDialog.clear(); return *this; }
00087 
00088     bool hasDialog(const Common::String &name);
00089 
00090     void reflowDialogLayout(const Common::String &name, Widget *widgetChain);
00091     bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h);
00092 
00093     Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget);
00094 
00095 #ifdef LAYOUT_DEBUG_DIALOG
00096     void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
00097         _layouts[LAYOUT_DEBUG_DIALOG]->debugDraw(screen, font);
00098     }
00099 #endif
00100 
00101     void reset();
00102 
00103 private:
00104     VariablesMap _vars;
00105     VariablesMap _builtin;
00106 
00107     LayoutsMap _layouts;
00108     Common::Stack<ThemeLayout *> _curLayout;
00109     Common::String _curDialog;
00110 };
00111 
00112 } // End of namespace GUI
00113 
00114 #endif


Generated on Sat May 30 2020 05:01:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge