Changed drawdata names to a struct.

Fixed text drawing.

svn-id: r33112
This commit is contained in:
Vicent Marti 2008-07-19 15:49:08 +00:00
parent cf3832fcce
commit b5081a02ec
2 changed files with 40 additions and 31 deletions

View file

@ -39,41 +39,42 @@ namespace GUI {
using namespace Graphics;
const char *ThemeRenderer::kDrawDataStrings[] = {
"mainmenu_bg",
"special_bg",
"plain_bg",
"default_bg",
const ThemeRenderer::DrawDataInfo ThemeRenderer::kDrawData[] = {
{kDDMainDialogBackground, "mainmenu_bg", true},
{kDDSpecialColorBackground, "special_bg", true},
{kDDPlainColorBackground, "plain_bg", true},
{kDDDefaultBackground, "default_bg", true},
"widget_default",
"widget_small",
"widget_textedit",
"widget_slider",
{kDDWidgetBackgroundDefault, "widget_default", true},
{kDDWidgetBackgroundSmall, "widget_small", true},
{kDDWidgetBackgroundEditText, "widget_textedit", true},
{kDDWidgetBackgroundSlider, "widget_slider", true},
"button_idle",
"button_hover",
"button_disabled",
{kDDButtonIdle, "button_idle", true},
{kDDButtonHover, "button_hover", false},
{kDDButtonDisabled, "button_disabled", true},
"slider_full",
"slider_empty",
{kDDSliderFull,"slider_full", false},
{kDDSliderEmpty, "slider_empty", true},
"checkbox_enabled",
"checkbox_disabled",
{kDDCheckboxEnabled, "checkbox_enabled", false},
{kDDCheckboxDisabled, "checkbox_disabled", true},
"tab_active",
"tab_inactive",
{kDDTabActive, "tab_active", false},
{kDDTabInactive, "tab_inactive", true},
"scrollbar_base",
"scrollbar_handle",
{kDDScrollbarBase, "scrollbar_base", true},
{kDDScrollbarHandle, "scrollbar_handle", false},
"popup_idle",
"popup_hover",
{kDDPopUpIdle, "popup_idle", true},
{kDDPopUpHover, "popup_hover", false},
"caret",
"separator",
"default_text"
{kDDCaret, "caret", false},
{kDDSeparator, "separator", true},
{kDDDefaultText, "default_text", false}
};
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false),
@ -523,6 +524,7 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W
if (!_initOk)
return;
restoreBackground(r);
getFont(font)->drawString(_screen, str, r.left, r.top, r.width(), getTextColor(state), convertAligment(align), deltax, useEllipsis);
addDirtyRect(r);
}

View file

@ -40,6 +40,7 @@
namespace GUI {
struct WidgetDrawData;
struct DrawDataInfo;
struct WidgetDrawData {
/** List of all the steps needed to draw this widget */
@ -80,7 +81,6 @@ class ThemeRenderer : public Theme {
friend class GUI::GuiObject;
/** Strings representing each value in the DrawData enum */
static const char *kDrawDataStrings[];
/** Constant value to expand dirty rectangles, to make sure they are fully copied */
static const int kDirtyRectangleThreshold = 2;
@ -139,6 +139,13 @@ public:
kTextColorMAX
};
struct DrawDataInfo {
DrawData id;
const char *name;
bool buffer;
};
static const DrawDataInfo kDrawData[];
ThemeRenderer(Common::String themeName, GraphicsMode mode);
~ThemeRenderer() {
@ -195,8 +202,8 @@ public:
// custom stuff - tanoku
DrawData getDrawDataId(Common::String &name) {
for (int i = 0; i < kDrawDataMAX; ++i)
if (name.compareToIgnoreCase(kDrawDataStrings[i]) == 0)
return (DrawData)i;
if (name.compareToIgnoreCase(kDrawData[i].name) == 0)
return kDrawData[i].id;
return (DrawData)-1;
}