Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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;
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 void addDialog(const Common::String &name, const Common::String &overlays, bool enabled = true, int inset = 0);
00078 void addLayout(ThemeLayout::LayoutType type, int spacing, bool center = false);
00079 void addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled = true, Graphics::TextAlign align = Graphics::kTextAlignLeft);
00080 bool addImportedLayout(const Common::String &name);
00081 void addSpace(int size);
00082
00083 void addPadding(int16 l, int16 r, int16 t, int16 b) { _curLayout.top()->setPadding(l, r, t, b); }
00084
00085 void closeLayout() { _curLayout.pop(); }
00086 void closeDialog() { _curLayout.pop()->reflowLayout(); _curDialog.clear(); }
00087
00088 bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h);
00089
00090 Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget);
00091
00092 #ifdef LAYOUT_DEBUG_DIALOG
00093 void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
00094 _layouts[LAYOUT_DEBUG_DIALOG]->debugDraw(screen, font);
00095 }
00096 #endif
00097
00098 void reset();
00099
00100 private:
00101 VariablesMap _vars;
00102 VariablesMap _builtin;
00103
00104 LayoutsMap _layouts;
00105 Common::Stack<ThemeLayout *> _curLayout;
00106 Common::String _curDialog;
00107 };
00108
00109 }
00110
00111 #endif