diff options
author | Max Horn | 2008-11-12 14:30:16 +0000 |
---|---|---|
committer | Max Horn | 2008-11-12 14:30:16 +0000 |
commit | c0f82d351894df16e23690b4361e66bed0fb6f84 (patch) | |
tree | f6ddb6d08e8dbe0637a5e5dcfb13d4a4fa5c21c0 /gui | |
parent | 144be21bed1001c4a72739ef7656908cbf71e909 (diff) | |
download | scummvm-rg350-c0f82d351894df16e23690b4361e66bed0fb6f84.tar.gz scummvm-rg350-c0f82d351894df16e23690b4361e66bed0fb6f84.tar.bz2 scummvm-rg350-c0f82d351894df16e23690b4361e66bed0fb6f84.zip |
Renamed Graphics::TextAlignment -> Graphics::TextAlign and merged it with GUI::ThemeEngine::TextAlignVertical
svn-id: r35023
Diffstat (limited to 'gui')
-rw-r--r-- | gui/EditTextWidget.cpp | 2 | ||||
-rw-r--r-- | gui/ListWidget.cpp | 6 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 6 | ||||
-rw-r--r-- | gui/ThemeData.h | 6 | ||||
-rw-r--r-- | gui/ThemeEngine.cpp | 8 | ||||
-rw-r--r-- | gui/ThemeEngine.h | 52 | ||||
-rw-r--r-- | gui/ThemeParser.cpp | 8 | ||||
-rw-r--r-- | gui/about.cpp | 10 | ||||
-rw-r--r-- | gui/launcher.cpp | 4 | ||||
-rw-r--r-- | gui/message.cpp | 2 | ||||
-rw-r--r-- | gui/newgui.h | 6 | ||||
-rw-r--r-- | gui/saveload.cpp | 6 | ||||
-rw-r--r-- | gui/widget.cpp | 10 | ||||
-rw-r--r-- | gui/widget.h | 10 |
14 files changed, 44 insertions, 92 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index 5fc8ca6d94..873c578638 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -86,7 +86,7 @@ void EditTextWidget::drawWidget() { // Draw the text adjustOffset(); - g_gui.theme()->drawText(Common::Rect(_x+2+ _leftPadding,_y+2, _x+_leftPadding+getEditRect().width()+2, _y+_h-2), _editString, _state, ThemeEngine::kTextAlignLeft, false, -_editScrollOffset, false, _font); + g_gui.theme()->drawText(Common::Rect(_x+2+ _leftPadding,_y+2, _x+_leftPadding+getEditRect().width()+2, _y+_h-2), _editString, _state, Graphics::kTextAlignLeft, false, -_editScrollOffset, false, _font); } Common::Rect EditTextWidget::getEditRect() const { diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 5e7f417704..37cbd668ce 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -387,7 +387,7 @@ void ListWidget::drawWidget() { sprintf(temp, "%2d. ", (pos + _numberingMode)); buffer = temp; g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), - buffer, _state, ThemeEngine::kTextAlignLeft, inverted, _leftPadding); + buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding); pad = 0; } @@ -398,7 +398,7 @@ void ListWidget::drawWidget() { adjustOffset(); width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW; g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight-2), - buffer, _state, ThemeEngine::kTextAlignLeft, inverted, pad); + buffer, _state, Graphics::kTextAlignLeft, inverted, pad); } else { int maxWidth = _textWidth[i]; buffer = _list[pos]; @@ -411,7 +411,7 @@ void ListWidget::drawWidget() { if (width > maxWidth) maxWidth = width; g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight-2), - buffer, _state, ThemeEngine::kTextAlignLeft, inverted, pad); + buffer, _state, Graphics::kTextAlignLeft, inverted, pad); } _textWidth[i] = width; diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 15b536f760..74c441e916 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -345,7 +345,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x+w, y+kLineHeight)); } else { g_gui.theme()->drawText(Common::Rect(x+1, y+2, x+w, y+2+kLineHeight), name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled, - ThemeEngine::kTextAlignLeft, false, _leftPadding); + Graphics::kTextAlignLeft, false, _leftPadding); } } @@ -425,12 +425,12 @@ void PopUpWidget::drawWidget() { // Draw the label, if any if (_labelWidth > 0) - g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label, _state, ThemeEngine::kTextAlignRight); + g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label, _state, Graphics::kTextAlignRight); Common::String sel; if (_selectedItem >= 0) sel = _entries[_selectedItem].name; - g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, _state, g_gui.theme()->convertAligment(kTextAlignLeft)); + g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, _state, Graphics::kTextAlignLeft); } } // End of namespace GUI diff --git a/gui/ThemeData.h b/gui/ThemeData.h index d2995e44a4..d6423c16f2 100644 --- a/gui/ThemeData.h +++ b/gui/ThemeData.h @@ -42,7 +42,7 @@ struct WidgetDrawData { Common::List<Graphics::DrawStep> _steps; int _textDataId; - GUI::ThemeEngine::TextAlign _textAlignH; + Graphics::TextAlign _textAlignH; GUI::ThemeEngine::TextAlignVertical _textAlignV; /** Extra space that the widget occupies when it's drawn. @@ -96,7 +96,7 @@ protected: class ThemeItemTextData : public ThemeItem { public: ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const Common::Rect &area, const Common::String &text, - GUI::ThemeEngine::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, + Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, bool ellipsis, bool restoreBg, int deltaX) : ThemeItem(engine, area), _data(data), _text(text), _alignH(alignH), _alignV(alignV), _ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX) {} @@ -106,7 +106,7 @@ public: protected: const TextDrawData *_data; Common::String _text; - GUI::ThemeEngine::TextAlign _alignH; + Graphics::TextAlign _alignH; GUI::ThemeEngine::TextAlignVertical _alignV; bool _ellipsis; bool _restoreBg; diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index aaba8910f6..d87feb3273 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -350,7 +350,7 @@ void ThemeEngine::addDrawStep(const Common::String &drawDataId, const Graphics:: _widgets[id]->_steps.push_back(step); } -bool ThemeEngine::addTextData(const Common::String &drawDataId, const Common::String &textDataId, TextAlign alignH, TextAlignVertical alignV) { +bool ThemeEngine::addTextData(const Common::String &drawDataId, const Common::String &textDataId, Graphics::TextAlign alignH, TextAlignVertical alignV) { DrawData id = getDrawDataId(drawDataId); TextData textId = getTextDataId(textDataId); @@ -601,7 +601,7 @@ void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) } void ThemeEngine::queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg, - bool ellipsis, TextAlign alignH, TextAlignVertical alignV, int deltax) { + bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax) { if (_texts[type] == 0) return; @@ -771,7 +771,7 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo s queueDD(kDDCaret, r); } -void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) { +void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) { if (!ready()) return; @@ -842,7 +842,7 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co } } -void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) { +void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) { if (!ready()) return; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index b812d7a2b2..57efa04f8a 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -35,8 +35,8 @@ #define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.3" namespace Graphics { -struct DrawStep; -class VectorRenderer; + struct DrawStep; + class VectorRenderer; } namespace GUI { @@ -138,13 +138,6 @@ protected: } kTextDataDefaults[]; public: - //! Defined the align of the text - enum TextAlign { - kTextAlignLeft, //!< Text should be aligned to the left - kTextAlignCenter, //!< Text should be centered - kTextAlignRight //!< Text should be aligned to the right - }; - //! Vertical alignment of the text. enum TextAlignVertical { kTextAlignVBottom, @@ -336,7 +329,7 @@ public: ScrollbarState, WidgetStateInfo state = kStateEnabled); void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, - int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft); + int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft); void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled); @@ -345,7 +338,7 @@ public: void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state = kStateEnabled); - void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold); + void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold); void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled); @@ -436,7 +429,7 @@ public: * Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the * new Font API is in place. */ - bool addTextData(const Common::String &drawDataId, const Common::String &textDataId, TextAlign alignH, TextAlignVertical alignV); + bool addTextData(const Common::String &drawDataId, const Common::String &textDataId, Graphics::TextAlign alignH, TextAlignVertical alignV); /** * Returns if the Theme is ready to draw stuff on screen. @@ -615,7 +608,7 @@ protected: */ void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0); void queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg, - bool elipsis, TextAlign alignH = kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0); + bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0); void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha); /** @@ -638,39 +631,6 @@ public: const Graphics::Font *loadFontFromArchive(const Common::String &filename); Common::String genCacheFilename(const char *filename); - Graphics::TextAlignment convertAligment(TextAlign align) const { - switch (align) { - case kTextAlignLeft: - return Graphics::kTextAlignLeft; - break; - - case kTextAlignRight: - return Graphics::kTextAlignRight; - break; - - default: - break; - }; - return Graphics::kTextAlignCenter; - } - - TextAlign convertAligment(Graphics::TextAlignment align) const { - switch (align) { - case Graphics::kTextAlignLeft: - return kTextAlignLeft; - break; - - case Graphics::kTextAlignRight: - return kTextAlignRight; - break; - - default: - break; - } - return kTextAlignCenter; - } - - bool isThemeLoadingRequired(); static bool themeConfigUseable(const Common::FSNode &node, Common::String &themeName); diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 1663efc404..bbcfc6302e 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -177,15 +177,15 @@ bool ThemeParser::parserCallback_bitmap(ParserNode *node) { } bool ThemeParser::parserCallback_text(ParserNode *node) { - GUI::ThemeEngine::TextAlign alignH; + Graphics::TextAlign alignH; GUI::ThemeEngine::TextAlignVertical alignV; if (node->values["horizontal_align"] == "left") - alignH = GUI::ThemeEngine::kTextAlignLeft; + alignH = Graphics::kTextAlignLeft; else if (node->values["horizontal_align"] == "right") - alignH = GUI::ThemeEngine::kTextAlignRight; + alignH = Graphics::kTextAlignRight; else if (node->values["horizontal_align"] == "center") - alignH = GUI::ThemeEngine::kTextAlignCenter; + alignH = Graphics::kTextAlignCenter; else return parserError("Invalid value for text alignment."); if (node->values["vertical_align"] == "top") diff --git a/gui/about.cpp b/gui/about.cpp index 7749533925..ffcd92d1d6 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -218,18 +218,18 @@ void AboutDialog::drawDialog() { for (int line = firstLine; line < lastLine; line++) { const char *str = _lines[line].c_str(); - ThemeEngine::TextAlign align = ThemeEngine::kTextAlignCenter; + Graphics::TextAlign align = Graphics::kTextAlignCenter; ThemeEngine::WidgetStateInfo state = ThemeEngine::kStateEnabled; while (str[0] == '\\') { switch (str[1]) { case 'C': - align = ThemeEngine::kTextAlignCenter; + align = Graphics::kTextAlignCenter; break; case 'L': - align = ThemeEngine::kTextAlignLeft; + align = Graphics::kTextAlignLeft; break; case 'R': - align = ThemeEngine::kTextAlignRight; + align = Graphics::kTextAlignRight; break; case 'c': switch (str[2]) { @@ -262,7 +262,7 @@ void AboutDialog::drawDialog() { str += 2; } // Trim leading whitespaces if center mode is on - if (align == ThemeEngine::kTextAlignCenter) + if (align == Graphics::kTextAlignCenter) while (*str && *str == ' ') str++; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 6f199208b4..a484638338 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -930,7 +930,7 @@ void LauncherDialog::reflowLayout() { if (g_gui.xmlEval()->getVar("Globals.ShowLauncherLogo") == 1 && g_gui.theme()->supportsImages()) { StaticTextWidget *ver = (StaticTextWidget*)findWidget("Launcher.Version"); if (ver) { - ver->setAlign((Graphics::TextAlignment)g_gui.xmlEval()->getVar("Launcher.Version.Align", Graphics::kTextAlignCenter)); + ver->setAlign((Graphics::TextAlign)g_gui.xmlEval()->getVar("Launcher.Version.Align", Graphics::kTextAlignCenter)); ver->setLabel(gScummVMVersionDate); } @@ -941,7 +941,7 @@ void LauncherDialog::reflowLayout() { } else { StaticTextWidget *ver = (StaticTextWidget*)findWidget("Launcher.Version"); if (ver) { - ver->setAlign((Graphics::TextAlignment)g_gui.xmlEval()->getVar("Launcher.Version.Align", Graphics::kTextAlignCenter)); + ver->setAlign((Graphics::TextAlign)g_gui.xmlEval()->getVar("Launcher.Version.Align", Graphics::kTextAlignCenter)); ver->setLabel(gScummVMFullVersion); } diff --git a/gui/message.cpp b/gui/message.cpp index 1d71224d13..4d63a96c56 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -78,7 +78,7 @@ MessageDialog::MessageDialog(const Common::String &message, const char *defaultB // Each line is represented by one static text item. for (int i = 0; i < lineCount; i++) { new StaticTextWidget(this, 10, 10 + i * kLineHeight, maxlineWidth, kLineHeight, - lines[i], kTextAlignCenter); + lines[i], Graphics::kTextAlignCenter); } if (defaultButton && altButton) { diff --git a/gui/newgui.h b/gui/newgui.h index e7ee19769e..29eb58638e 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -50,11 +50,6 @@ class ThemeEval; #define kLineHeight (g_gui.getFontHeight() + 2) -using Graphics::TextAlignment; -using Graphics::kTextAlignCenter; -using Graphics::kTextAlignLeft; -using Graphics::kTextAlignRight; - // Simple dialog stack class // Anybody nesting dialogs deeper than 4 is mad anyway @@ -65,7 +60,6 @@ typedef Common::FixedStack<Dialog *> DialogStack; * GUI manager singleton. */ class NewGui : public Common::Singleton<NewGui> { - typedef Common::String String; friend class Dialog; friend class Common::Singleton<SingletonBaseType>; NewGui(); diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 1d4f2030dc..bce0df3583 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -56,9 +56,9 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); - _date = new StaticTextWidget(this, 0, 0, 10, 10, "No date saved", kTextAlignCenter); - _time = new StaticTextWidget(this, 0, 0, 10, 10, "No time saved", kTextAlignCenter); - _playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter); + _date = new StaticTextWidget(this, 0, 0, 10, 10, "No date saved", Graphics::kTextAlignCenter); + _time = new StaticTextWidget(this, 0, 0, 10, 10, "No time saved", Graphics::kTextAlignCenter); + _playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", Graphics::kTextAlignCenter); // Buttons new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", kCloseCmd, 0); diff --git a/gui/widget.cpp b/gui/widget.cpp index 433c58dd58..f8af13ccbc 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -163,7 +163,7 @@ bool Widget::isVisible() const { #pragma mark - -StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, TextAlignment align) +StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align) : Widget(boss, x, y, w, h), _align(align) { setFlags(WIDGET_ENABLED); _type = kStaticTextWidget; @@ -176,7 +176,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, _type = kStaticTextWidget; _label = text; - _align = (Graphics::TextAlignment)g_gui.xmlEval()->getVar(name + ".Align", kTextAlignLeft); + _align = (Graphics::TextAlign)g_gui.xmlEval()->getVar(name + ".Align", Graphics::kTextAlignLeft); } void StaticTextWidget::setValue(int value) { @@ -194,7 +194,7 @@ void StaticTextWidget::setLabel(const Common::String &label) { //_boss->draw(); } -void StaticTextWidget::setAlign(TextAlignment align) { +void StaticTextWidget::setAlign(Graphics::TextAlign align) { _align = align; // TODO: We should automatically redraw when the alignment is changed. // See setLabel() for more insights. @@ -202,13 +202,13 @@ void StaticTextWidget::setAlign(TextAlignment align) { void StaticTextWidget::drawWidget() { - g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, g_gui.theme()->convertAligment(_align)); + g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, _align); } #pragma mark - 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), + : StaticTextWidget(boss, x, y, w, h, label, Graphics::kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; diff --git a/gui/widget.h b/gui/widget.h index 3174d4416a..a37ef5c7f4 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -145,18 +145,16 @@ protected: /* StaticTextWidget */ class StaticTextWidget : public Widget { protected: - typedef Graphics::TextAlignment TextAlignment; - Common::String _label; - TextAlignment _align; + Graphics::TextAlign _align; public: - StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, TextAlignment align); + StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align); StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text); void setValue(int value); void setLabel(const Common::String &label); const Common::String &getLabel() const { return _label; } - void setAlign(TextAlignment align); - TextAlignment getAlign() const { return _align; } + void setAlign(Graphics::TextAlign align); + Graphics::TextAlign getAlign() const { return _align; } protected: void drawWidget(); |