From c0f82d351894df16e23690b4361e66bed0fb6f84 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 12 Nov 2008 14:30:16 +0000 Subject: Renamed Graphics::TextAlignment -> Graphics::TextAlign and merged it with GUI::ThemeEngine::TextAlignVertical svn-id: r35023 --- engines/dialogs.cpp | 10 +++----- engines/parallaction/saveload.cpp | 6 ++--- engines/scumm/dialogs.cpp | 4 +-- graphics/VectorRenderer.h | 2 +- graphics/VectorRendererSpec.cpp | 4 +-- graphics/VectorRendererSpec.h | 2 +- graphics/font.cpp | 2 +- graphics/font.h | 12 ++++----- gui/EditTextWidget.cpp | 2 +- gui/ListWidget.cpp | 6 ++--- gui/PopUpWidget.cpp | 6 ++--- gui/ThemeData.h | 6 ++--- gui/ThemeEngine.cpp | 8 +++--- gui/ThemeEngine.h | 52 +++++---------------------------------- gui/ThemeParser.cpp | 8 +++--- gui/about.cpp | 10 ++++---- gui/launcher.cpp | 4 +-- gui/message.cpp | 2 +- gui/newgui.h | 6 ----- gui/saveload.cpp | 6 ++--- gui/widget.cpp | 10 ++++---- gui/widget.h | 10 +++----- 22 files changed, 64 insertions(+), 114 deletions(-) diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 0032006ca7..fb634bee97 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -49,8 +49,6 @@ using GUI::CommandSender; using GUI::StaticTextWidget; using GUI::kCloseCmd; -using GUI::kTextAlignCenter; -using GUI::kTextAlignLeft; using GUI::WIDGET_ENABLED; typedef GUI::OptionsDialog GUI_OptionsDialog; @@ -80,15 +78,15 @@ MainMenuDialog::MainMenuDialog(Engine *engine) _logo->setGfx(g_gui.theme()->getImageSurface(GUI::ThemeEngine::kImageLogoSmall)); } else { StaticTextWidget *title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM"); - title->setAlign(GUI::kTextAlignCenter); + title->setAlign(Graphics::kTextAlignCenter); } #else StaticTextWidget *title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM"); - title->setAlign(GUI::kTextAlignCenter); + title->setAlign(Graphics::kTextAlignCenter); #endif StaticTextWidget *version = new StaticTextWidget(this, "GlobalMenu.Version", gScummVMVersionDate); - version->setAlign(GUI::kTextAlignCenter); + version->setAlign(Graphics::kTextAlignCenter); new GUI::ButtonWidget(this, "GlobalMenu.Resume", "Resume", kPlayCmd, 'P'); @@ -223,7 +221,7 @@ void MainMenuDialog::reflowLayout() { GUI::StaticTextWidget *title = (StaticTextWidget *)findWidget("GlobalMenu.Title"); if (!title) { title = new StaticTextWidget(this, "GlobalMenu.Title", "ScummVM"); - title->setAlign(GUI::kTextAlignCenter); + title->setAlign(Graphics::kTextAlignCenter); } if (_logo) { diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index f012c1c76b..afa6b34499 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -259,9 +259,9 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); - _date = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No date saved", GUI::kTextAlignCenter); - _time = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No time saved", GUI::kTextAlignCenter); - _playtime = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", GUI::kTextAlignCenter); + _date = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No date saved", Graphics::kTextAlignCenter); + _time = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No time saved", Graphics::kTextAlignCenter); + _playtime = new GUI::StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", Graphics::kTextAlignCenter); // Buttons new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", GUI::kCloseCmd, 0); diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 1cb4e8a41d..42020dd4dc 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -62,8 +62,8 @@ using GUI::CommandSender; using GUI::StaticTextWidget; using GUI::kCloseCmd; -using GUI::kTextAlignCenter; -using GUI::kTextAlignLeft; +using Graphics::kTextAlignCenter; +using Graphics::kTextAlignLeft; using GUI::WIDGET_ENABLED; typedef GUI::OptionsDialog GUI_OptionsDialog; diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 4ccd6845b9..f0c319fe76 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -507,7 +507,7 @@ public: * method. */ virtual void drawString(const Graphics::Font *font, const Common::String &text, - const Common::Rect &area, GUI::ThemeEngine::TextAlign alignH, + const Common::Rect &area, Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool useEllipsis) = 0; /** diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 675acd7ad3..2924e2b1b7 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -449,7 +449,7 @@ colorFill(PixelType *first, PixelType *last, PixelType color) { template void VectorRendererSpec:: drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, - GUI::ThemeEngine::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool ellipsis) { + Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool ellipsis) { int offset = area.top; @@ -466,7 +466,7 @@ drawString(const Graphics::Font *font, const Common::String &text, const Common: } } - font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, (Graphics::TextAlignment)alignH, deltax, ellipsis); + font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, alignH, deltax, ellipsis); } /** LINES **/ diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h index 5b4ebf38e7..fdeb9f9989 100644 --- a/graphics/VectorRendererSpec.h +++ b/graphics/VectorRendererSpec.h @@ -68,7 +68,7 @@ public: drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled); } void drawString(const Graphics::Font *font, const Common::String &text, - const Common::Rect &area, GUI::ThemeEngine::TextAlign alignH, + const Common::Rect &area, Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool elipsis); void setFgColor(uint8 r, uint8 g, uint8 b) { _fgColor = RGBToColor(r, g, b); } diff --git a/graphics/font.cpp b/graphics/font.cpp index 3680ad2eb8..bc5353c9c6 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -772,7 +772,7 @@ int Font::getStringWidth(const Common::String &str) const { return space; } -void Font::drawString(Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis) const { +void Font::drawString(Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlign align, int deltax, bool useEllipsis) const { assert(dst != 0); const int leftX = x, rightX = x + w; uint i; diff --git a/graphics/font.h b/graphics/font.h index 3911e6d32c..5667fcd8f3 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -34,11 +34,11 @@ class SeekableReadStream; namespace Graphics { -// Text alignment modes for drawString() -enum TextAlignment { - kTextAlignLeft, - kTextAlignCenter, - kTextAlignRight +/** Text alignment modes */ +enum TextAlign { + kTextAlignLeft, //!< Text should be aligned to the left + kTextAlignCenter, //!< Text should be centered + kTextAlignRight //!< Text should be aligned to the right }; /** @@ -57,7 +57,7 @@ public: virtual int getCharWidth(byte chr) const = 0; virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const = 0; - void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; /** * Compute and return the width the string str has when rendered using this font. 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 _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 DialogStack; * GUI manager singleton. */ class NewGui : public Common::Singleton { - typedef Common::String String; friend class Dialog; friend class Common::Singleton; 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(); -- cgit v1.2.3