diff options
-rw-r--r-- | gui/ThemeModern.cpp | 2 | ||||
-rw-r--r-- | gui/theme.cpp | 8 | ||||
-rw-r--r-- | gui/theme.h | 52 | ||||
-rw-r--r-- | gui/widget.cpp | 22 | ||||
-rw-r--r-- | gui/widget.h | 19 |
5 files changed, 49 insertions, 54 deletions
diff --git a/gui/ThemeModern.cpp b/gui/ThemeModern.cpp index f245ccf778..ef457e94c7 100644 --- a/gui/ThemeModern.cpp +++ b/gui/ThemeModern.cpp @@ -1280,7 +1280,7 @@ void ThemeModern::deleteFonts() { FontMan.removeFontName(FONT_NAME_ITALIC); } -void ThemeModern::setupFont(const String &key, const String &name, FontStyle style) { +void ThemeModern::setupFont(const Common::String &key, const Common::String &name, FontStyle style) { if (_evaluator->getVar(key) == EVAL_STRING_VAR) { _fonts[style] = FontMan.getFontByName(name); diff --git a/gui/theme.cpp b/gui/theme.cpp index 4e9e295763..a3f0cee510 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -37,7 +37,7 @@ Theme::~Theme() { delete _evaluator; } -void Theme::getColorFromConfig(const String &value, OverlayColor &color) { +void Theme::getColorFromConfig(const Common::String &value, OverlayColor &color) { const char *postfixes[] = {".r", ".g", ".b"}; int rgb[3]; @@ -47,7 +47,7 @@ void Theme::getColorFromConfig(const String &value, OverlayColor &color) { color = g_system->RGBToColor(rgb[0], rgb[1], rgb[2]); } -void Theme::getColorFromConfig(const String &value, uint8 &r, uint8 &g, uint8 &b) { +void Theme::getColorFromConfig(const Common::String &value, uint8 &r, uint8 &g, uint8 &b) { r = _evaluator->getVar(value + ".r", 0); g = _evaluator->getVar(value + ".g", 0); b = _evaluator->getVar(value + ".b", 0); @@ -143,7 +143,7 @@ Common::String Theme::genCacheFilename(const char *filename) { return ""; } -bool Theme::loadConfigFile(const String &stylefile) { +bool Theme::loadConfigFile(const Common::String &stylefile) { if (ConfMan.hasKey("themepath")) Common::File::addDefaultDirectory(ConfMan.get("themepath")); @@ -187,7 +187,7 @@ bool Theme::loadConfigFile(const String &stylefile) { return true; } -bool Theme::themeConfigUseable(const String &stylefile, const String &style, String *cStyle, Common::ConfigFile *cfg) { +bool Theme::themeConfigUseable(const Common::String &stylefile, const Common::String &style, Common::String *cStyle, Common::ConfigFile *cfg) { if (ConfMan.hasKey("themepath")) Common::File::addDefaultDirectory(ConfMan.get("themepath")); diff --git a/gui/theme.h b/gui/theme.h index a20fea335d..ee1814e96e 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -72,7 +72,6 @@ enum { class Theme { - typedef Common::String String; public: Theme(); @@ -204,9 +203,9 @@ public: return kTextAlignCenter; } - void processResSection(Common::ConfigFile &config, const String &name, bool skipDefs = false, const String &prefix = ""); - void processSingleLine(const String §ion, const String &prefix, const String &name, const String &str); - void setSpecialAlias(const String &alias, const String &name); + void processResSection(Common::ConfigFile &config, const Common::String &name, bool skipDefs = false, const Common::String &prefix = ""); + void processSingleLine(const Common::String §ion, const Common::String &prefix, const Common::String &name, const Common::String &str); + void setSpecialAlias(const Common::String &alias, const Common::String &name); bool isThemeLoadingRequired(); bool sectionIsSkipped(Common::ConfigFile &config, const char *name, int w, int h); @@ -214,10 +213,10 @@ public: Eval *_evaluator; - static bool themeConfigUseable(const String &file, const String &style="", String *cStyle=0, Common::ConfigFile *cfg=0); + static bool themeConfigUseable(const Common::String &file, const Common::String &style="", Common::String *cStyle=0, Common::ConfigFile *cfg=0); - const String &getStylefileName() const { return _stylefile; } - const String &getThemeName() const { return _stylename; } + const Common::String &getStylefileName() const { return _stylefile; } + const Common::String &getThemeName() const { return _stylename; } virtual bool supportsImages() const { return false; } @@ -227,14 +226,14 @@ public: virtual const Graphics::Surface *getImageSurface(const kThemeImages n) const { return 0; } protected: - bool loadConfigFile(const String &file); - void getColorFromConfig(const String &name, OverlayColor &col); - void getColorFromConfig(const String &value, uint8 &r, uint8 &g, uint8 &b); + bool loadConfigFile(const Common::String &file); + void getColorFromConfig(const Common::String &name, OverlayColor &col); + void getColorFromConfig(const Common::String &value, uint8 &r, uint8 &g, uint8 &b); const Graphics::Font *loadFont(const char *filename); Common::String genCacheFilename(const char *filename); - String _stylefile, _stylename; + Common::String _stylefile, _stylename; Common::Rect _drawArea; Common::ConfigFile _configFile; @@ -273,23 +272,21 @@ public: void resetDrawArea(); - typedef Common::String String; - const Graphics::Font *getFont(FontStyle font) const { return _font; } int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; } - int getStringWidth(const String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } + int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); - void drawText(const Common::Rect &r, const String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); + void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); - void drawButton(const Common::Rect &r, const String &str, State state, uint16 hints); + void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); void drawSlider(const Common::Rect &r, int width, State state); - void drawCheckbox(const Common::Rect &r, const String &str, bool checked, State state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, int titleVPad, State state); + void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state); void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); void drawCaret(const Common::Rect &r, bool erase, State state); @@ -322,7 +319,7 @@ private: bool _initOk; bool _enabled; - String _fontName; + Common::String _fontName; const Graphics::Font *_font; OverlayColor _color, _shadowcolor; OverlayColor _bgcolor; @@ -346,9 +343,8 @@ private: #ifndef DISABLE_FANCY_THEMES class ThemeModern : public Theme { - typedef Common::String String; public: - ThemeModern(OSystem *system, const String &stylefile, const Common::ConfigFile *cfg = 0); + ThemeModern(OSystem *system, const Common::String &stylefile, const Common::ConfigFile *cfg = 0); virtual ~ThemeModern(); bool init(); @@ -372,19 +368,19 @@ public: const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const { return _fonts[font]; } int getFontHeight(FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getFontHeight(); return 0; } - int getStringWidth(const String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; } + int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; } int getCharWidth(byte c, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getCharWidth(c); return 0; } void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); - void drawText(const Common::Rect &r, const String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); + void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); - void drawButton(const Common::Rect &r, const String &str, State state, uint16 hints); + void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); void drawSlider(const Common::Rect &r, int width, State state); - void drawCheckbox(const Common::Rect &r, const String &str, bool checked, State state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, int titleVPad, State state); + void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state); void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); void drawCaret(const Common::Rect &r, bool erase, State state); @@ -449,7 +445,7 @@ private: void setupFonts(); void deleteFonts(); - void setupFont(const String &key, const String &name, FontStyle style); + void setupFont(const Common::String &key, const Common::String &name, FontStyle style); const Graphics::Font *_fonts[kFontStyleMax]; @@ -544,7 +540,7 @@ private: byte _cursorPal[4*MAX_CURS_COLORS]; private: - const String *_imageHandles; + const Common::String *_imageHandles; const Graphics::Surface **_images; enum ColorHandles { diff --git a/gui/widget.cpp b/gui/widget.cpp index 5079a6f31a..a7bc7cc48b 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -35,7 +35,7 @@ Widget::Widget(GuiObject *boss, int x, int y, int w, int h) init(); } -Widget::Widget(GuiObject *boss, const String &name) +Widget::Widget(GuiObject *boss, const Common::String &name) : GuiObject(name), _type(0), _boss(boss), _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), _hasFocus(false) { init(); @@ -141,14 +141,14 @@ bool Widget::isVisible() const { #pragma mark - -StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align) +StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, TextAlignment align) : Widget(boss, x, y, w, h), _align(align) { _flags = WIDGET_ENABLED; _type = kStaticTextWidget; _label = text; } -StaticTextWidget::StaticTextWidget(GuiObject *boss, const String &name, const String &text) +StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text) : Widget(boss, name) { _flags = WIDGET_ENABLED; _type = kStaticTextWidget; @@ -166,7 +166,7 @@ void StaticTextWidget::setValue(int value) { _label = buf; } -void StaticTextWidget::setLabel(const String &label) { +void StaticTextWidget::setLabel(const Common::String &label) { _label = label; // TODO: We should automatically redraw when the label is changed. // The following doesn't quite work when we are using tabs, plus it @@ -190,14 +190,14 @@ void StaticTextWidget::drawWidget(bool hilite) { #pragma mark - -ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey) +ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd, uint8 hotkey) : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { _flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG; _type = kButtonWidget; } -ButtonWidget::ButtonWidget(GuiObject *boss, const String &name, const String &label, uint32 cmd, uint8 hotkey) +ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd, uint8 hotkey) : StaticTextWidget(boss, name, label), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { _flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG; @@ -216,13 +216,13 @@ void ButtonWidget::drawWidget(bool hilite) { #pragma mark - -CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey) +CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) { _flags = WIDGET_ENABLED; _type = kCheckboxWidget; } -CheckboxWidget::CheckboxWidget(GuiObject *boss, const String &name, const String &label, uint32 cmd, uint8 hotkey) +CheckboxWidget::CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, name, label, cmd, hotkey), _state(false) { _flags = WIDGET_ENABLED; _type = kCheckboxWidget; @@ -257,7 +257,7 @@ SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 c _type = kSliderWidget; } -SliderWidget::SliderWidget(GuiObject *boss, const String &name, uint32 cmd) +SliderWidget::SliderWidget(GuiObject *boss, const Common::String &name, uint32 cmd) : Widget(boss, name), CommandSender(boss), _cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) { _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG; @@ -319,7 +319,7 @@ GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h) _hints &= ~THEME_HINT_SAVE_BACKGROUND; } -GraphicsWidget::GraphicsWidget(GuiObject *boss, const String &name) +GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name) : Widget(boss, name), _gfx(), _alpha(256), _transparency(false) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG; _type = kGraphicsWidget; @@ -376,7 +376,7 @@ ContainerWidget::ContainerWidget(GuiObject *boss, int x, int y, int w, int h) : _type = kContainerWidget; } -ContainerWidget::ContainerWidget(GuiObject *boss, const String &name) : Widget(boss, name) { +ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : Widget(boss, name) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG; _type = kContainerWidget; } diff --git a/gui/widget.h b/gui/widget.h index 99759a777b..4ff8ad5409 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -164,17 +164,16 @@ protected: /* StaticTextWidget */ class StaticTextWidget : public Widget { protected: - typedef Common::String String; typedef Graphics::TextAlignment TextAlignment; - String _label; + Common::String _label; TextAlignment _align; public: - StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align); - StaticTextWidget(GuiObject *boss, const String &name, const String &text); + StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, TextAlignment align); + StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text); void setValue(int value); - void setLabel(const String &label); - const String &getLabel() const { return _label; } + void setLabel(const Common::String &label); + const Common::String &getLabel() const { return _label; } void setAlign(TextAlignment align); TextAlignment getAlign() const { return _align; } @@ -189,8 +188,8 @@ protected: uint32 _cmd; uint8 _hotkey; public: - ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0); - ButtonWidget(GuiObject *boss, const String &name, const String &label, uint32 cmd = 0, uint8 hotkey = 0); + ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); + ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); void setCmd(uint32 cmd) { _cmd = cmd; } uint32 getCmd() const { return _cmd; } @@ -208,8 +207,8 @@ class CheckboxWidget : public ButtonWidget { protected: bool _state; public: - CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0); - CheckboxWidget(GuiObject *boss, const String &name, const String &label, uint32 cmd = 0, uint8 hotkey = 0); + CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); + CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd = 0, uint8 hotkey = 0); void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } |