(svn r15784) -Fix (r15779): TextAlignment and TA_* already exist on windows

This commit is contained in:
glx 2009-03-21 20:06:00 +00:00
parent 93fe44a3c5
commit 9fcff01850
8 changed files with 35 additions and 35 deletions

View File

@ -411,7 +411,7 @@ int DrawString(int x, int y, StringID str, TextColour colour)
* @return In case of left or center alignment the right most pixel we have drawn to. * @return In case of left or center alignment the right most pixel we have drawn to.
* In case of right alignment the left most pixel we have drawn to. * In case of right alignment the left most pixel we have drawn to.
*/ */
static int DrawString(int left, int right, int top, char *str, const char *last, TextColour colour, TextAlignment align, bool underline = false) static int DrawString(int left, int right, int top, char *str, const char *last, TextColour colour, StringAlignment align, bool underline = false)
{ {
TruncateString(str, right - left); TruncateString(str, right - left);
HandleBiDiAndArabicShapes(str, last); HandleBiDiAndArabicShapes(str, last);
@ -419,16 +419,16 @@ static int DrawString(int left, int right, int top, char *str, const char *last,
int w = GetStringBoundingBox(str).width; int w = GetStringBoundingBox(str).width;
switch (align) { switch (align) {
case TA_LEFT: case SA_LEFT:
right = left + w; right = left + w;
break; break;
case TA_CENTER: case SA_CENTER:
left += (right - left - w) / 2; left += (right - left - w) / 2;
right = left + w; right = left + w;
break; break;
case TA_RIGHT: case SA_RIGHT:
left = right - w; left = right - w;
break; break;
@ -440,7 +440,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last,
GfxFillRect(left, top + 10, right, top + 10, _string_colourremap[1]); GfxFillRect(left, top + 10, right, top + 10, _string_colourremap[1]);
} }
return align == TA_RIGHT ? left : right; return align == SA_RIGHT ? left : right;
} }
/** /**
@ -456,7 +456,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last,
* will be drawn in the right direction. * will be drawn in the right direction.
* @param underline Whether to underline what has been drawn or not. * @param underline Whether to underline what has been drawn or not.
*/ */
int DrawString(int left, int right, int top, const char *str, TextColour colour, TextAlignment align, bool underline) int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline)
{ {
char buffer[DRAW_STRING_BUFFER]; char buffer[DRAW_STRING_BUFFER];
strecpy(buffer, str, lastof(buffer)); strecpy(buffer, str, lastof(buffer));
@ -476,7 +476,7 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
* will be drawn in the right direction. * will be drawn in the right direction.
* @param underline Whether to underline what has been drawn or not. * @param underline Whether to underline what has been drawn or not.
*/ */
int DrawString(int left, int right, int top, StringID str, TextColour colour, TextAlignment align, bool underline) int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align, bool underline)
{ {
char buffer[DRAW_STRING_BUFFER]; char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
@ -494,7 +494,7 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour, Te
*/ */
int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw) int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw)
{ {
return DrawString(x, x + maxw, y, str, colour, TA_LEFT, false); return DrawString(x, x + maxw, y, str, colour, SA_LEFT, false);
} }
/** /**
@ -507,7 +507,7 @@ int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw
*/ */
int DrawStringRightAligned(int x, int y, StringID str, TextColour colour) int DrawStringRightAligned(int x, int y, StringID str, TextColour colour)
{ {
return DrawString(0, x, y, str, colour, TA_RIGHT, false); return DrawString(0, x, y, str, colour, SA_RIGHT, false);
} }
/** /**
@ -521,7 +521,7 @@ int DrawStringRightAligned(int x, int y, StringID str, TextColour colour)
*/ */
int DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colour, uint maxw) int DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colour, uint maxw)
{ {
return DrawString(x - maxw, x, y, str, colour, TA_RIGHT, false); return DrawString(x - maxw, x, y, str, colour, SA_RIGHT, false);
} }
/** /**
@ -534,7 +534,7 @@ int DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colou
*/ */
int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour) int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour)
{ {
return DrawString(0, x, y, str, colour, TA_RIGHT, true); return DrawString(0, x, y, str, colour, SA_RIGHT, true);
} }
/** /**
@ -550,7 +550,7 @@ int DrawStringCentered(int x, int y, StringID str, TextColour colour)
char buffer[DRAW_STRING_BUFFER]; char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
int w = GetStringBoundingBox(buffer).width; int w = GetStringBoundingBox(buffer).width;
return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, TA_CENTER); return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, SA_CENTER);
} }
/** /**
@ -566,7 +566,7 @@ int DrawStringCentered(int x, int y, StringID str, TextColour colour)
*/ */
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, TextColour colour) int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, TextColour colour)
{ {
return DrawString(xl, xr, y, str, colour, TA_CENTER, false); return DrawString(xl, xr, y, str, colour, SA_CENTER, false);
} }
/** /**
@ -583,7 +583,7 @@ int DoDrawStringCentered(int x, int y, const char *str, TextColour colour)
strecpy(buffer, str, lastof(buffer)); strecpy(buffer, str, lastof(buffer));
int w = GetStringBoundingBox(buffer).width; int w = GetStringBoundingBox(buffer).width;
return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, TA_CENTER); return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, SA_CENTER);
} }
/** /**
@ -599,7 +599,7 @@ int DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour)
char buffer[DRAW_STRING_BUFFER]; char buffer[DRAW_STRING_BUFFER];
GetString(buffer, str, lastof(buffer)); GetString(buffer, str, lastof(buffer));
int w = GetStringBoundingBox(buffer).width; int w = GetStringBoundingBox(buffer).width;
return DrawString(x - w, y + w, y, buffer, lastof(buffer), colour, TA_CENTER, true); return DrawString(x - w, y + w, y, buffer, lastof(buffer), colour, SA_CENTER, true);
} }
/** /**
@ -613,7 +613,7 @@ int DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour)
*/ */
int DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, TextColour colour) int DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, TextColour colour)
{ {
return DrawString(xl, xr, y, str, colour, TA_CENTER, true); return DrawString(xl, xr, y, str, colour, SA_CENTER, true);
} }
/** /**

View File

@ -86,14 +86,14 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo);
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL); void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
/** How to align the to-be drawn text. */ /** How to align the to-be drawn text. */
enum TextAlignment { enum StringAlignment {
TA_LEFT, ///< Left align the text SA_LEFT, ///< Left align the text
TA_CENTER, ///< Center the text SA_CENTER, ///< Center the text
TA_RIGHT, ///< Right align the text SA_RIGHT, ///< Right align the text
}; };
int DrawString(int left, int right, int top, const char *str, TextColour colour, TextAlignment align = TA_LEFT, bool underline = false); int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false);
int DrawString(int left, int right, int top, StringID str, TextColour colour, TextAlignment align = TA_LEFT, bool underline = false); int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false);
int DrawStringCentered(int x, int y, StringID str, TextColour colour); int DrawStringCentered(int x, int y, StringID str, TextColour colour);
int DoDrawStringCentered(int x, int y, const char *str, TextColour colour); int DoDrawStringCentered(int x, int y, const char *str, TextColour colour);

View File

@ -421,7 +421,7 @@ public:
DrawSprite(sprite, pal, this->widget[NCLWW_CHECKBOX].left + (pal == PAL_NONE ? 3 : 4), y + (pal == PAL_NONE ? 1 : 0)); DrawSprite(sprite, pal, this->widget[NCLWW_CHECKBOX].left + (pal == PAL_NONE ? 3 : 4), y + (pal == PAL_NONE ? 1 : 0));
StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS; StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS;
DrawString(this->widget[NCLWW_TYPE].left, this->widget[NCLWW_TYPE].right, y, str, TC_BLACK, TA_CENTER); DrawString(this->widget[NCLWW_TYPE].left, this->widget[NCLWW_TYPE].right, y, str, TC_BLACK, SA_CENTER);
SetDParamStr(0, ci->name); SetDParamStr(0, ci->name);
DrawStringTruncated(this->widget[NCLWW_NAME].left + 5, y, STR_JUST_RAW_STRING, TC_BLACK, this->widget[NCLWW_NAME].right - this->widget[NCLWW_NAME].left - 5); DrawStringTruncated(this->widget[NCLWW_NAME].left + 5, y, STR_JUST_RAW_STRING, TC_BLACK, this->widget[NCLWW_NAME].right - this->widget[NCLWW_NAME].left - 5);

View File

@ -408,10 +408,10 @@ public:
SetDParamStr(0, sel->info.server_name); SetDParamStr(0, sel->info.server_name);
DrawString(this->widget[NGWW_DETAILS].left, this->widget[NGWW_DETAILS].right, 62, STR_JUST_RAW_STRING, TC_ORANGE, TA_CENTER); // game name DrawString(this->widget[NGWW_DETAILS].left, this->widget[NGWW_DETAILS].right, 62, STR_JUST_RAW_STRING, TC_ORANGE, SA_CENTER); // game name
SetDParamStr(0, sel->info.map_name); SetDParamStr(0, sel->info.map_name);
DrawString(this->widget[NGWW_DETAILS].left, this->widget[NGWW_DETAILS].right, 74, STR_JUST_RAW_STRING, TC_BLACK, TA_CENTER); // map name DrawString(this->widget[NGWW_DETAILS].left, this->widget[NGWW_DETAILS].right, 74, STR_JUST_RAW_STRING, TC_BLACK, SA_CENTER); // map name
SetDParam(0, sel->info.clients_on); SetDParam(0, sel->info.clients_on);
SetDParam(1, sel->info.clients_max); SetDParam(1, sel->info.clients_max);

View File

@ -107,11 +107,11 @@ struct StatusBarWindow : Window {
/* Draw status bar */ /* Draw status bar */
if (this->saving) { // true when saving is active if (this->saving) { // true when saving is active
DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING, SA_CENTER);
} else if (_do_autosave) { } else if (_do_autosave) {
DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING, SA_CENTER);
} else if (_pause_game) { } else if (_pause_game) {
DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING, SA_CENTER);
} else if (this->ticker_scroll > TICKER_STOP && FindWindowById(WC_NEWS_WINDOW, 0) == NULL && _statusbar_news_item.string_id != 0) { } else if (this->ticker_scroll > TICKER_STOP && FindWindowById(WC_NEWS_WINDOW, 0) == NULL && _statusbar_news_item.string_id != 0) {
/* Draw the scrolling news text */ /* Draw the scrolling news text */
if (!DrawScrollingStatusText(&_statusbar_news_item, this->ticker_scroll, this->widget[SBW_MIDDLE].right - this->widget[SBW_MIDDLE].left - 2)) { if (!DrawScrollingStatusText(&_statusbar_news_item, this->ticker_scroll, this->widget[SBW_MIDDLE].right - this->widget[SBW_MIDDLE].left - 2)) {
@ -119,14 +119,14 @@ struct StatusBarWindow : Window {
if (c != NULL) { if (c != NULL) {
/* This is the default text */ /* This is the default text */
SetDParam(0, c->index); SetDParam(0, c->index);
DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_02BA, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_02BA, TC_FROMSTRING, SA_CENTER);
} }
} }
} else { } else {
if (c != NULL) { if (c != NULL) {
/* This is the default text */ /* This is the default text */
SetDParam(0, c->index); SetDParam(0, c->index);
DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_02BA, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_02BA, TC_FROMSTRING, SA_CENTER);
} }
} }

View File

@ -1243,13 +1243,13 @@ public:
this->DrawWidgets(); this->DrawWidgets();
SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
DrawString(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING, SA_CENTER);
/* We hide this panel when the toolbar space gets too small */ /* We hide this panel when the toolbar space gets too small */
const Widget *panel = &this->widget[TBSE_SPACERPANEL]; const Widget *panel = &this->widget[TBSE_SPACERPANEL];
if (panel->left != panel->right) { if (panel->left != panel->right) {
DrawString(panel->left + 1, panel->right - 1, 1, STR_0221_OPENTTD, TC_FROMSTRING, TA_CENTER); DrawString(panel->left + 1, panel->right - 1, 1, STR_0221_OPENTTD, TC_FROMSTRING, SA_CENTER);
DrawString(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING, TA_CENTER); DrawString(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING, SA_CENTER);
} }
} }

View File

@ -1938,7 +1938,7 @@ struct VehicleViewWindow : Window {
/* draw the flag plus orders */ /* draw the flag plus orders */
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, this->widget[VVW_WIDGET_START_STOP_VEH].top + 1); DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, this->widget[VVW_WIDGET_START_STOP_VEH].top + 1);
DrawString(this->widget[VVW_WIDGET_START_STOP_VEH].left + 8, this->widget[VVW_WIDGET_START_STOP_VEH].right, this->widget[VVW_WIDGET_START_STOP_VEH].top + 1, str, TC_FROMSTRING, TA_CENTER); DrawString(this->widget[VVW_WIDGET_START_STOP_VEH].left + 8, this->widget[VVW_WIDGET_START_STOP_VEH].right, this->widget[VVW_WIDGET_START_STOP_VEH].top + 1, str, TC_FROMSTRING, SA_CENTER);
this->DrawViewport(); this->DrawViewport();
} }

View File

@ -478,7 +478,7 @@ void Window::DrawWidgets() const
GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->owner]][4]); GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->owner]][4]);
} }
DrawString(r.left + 2, r.right - 2, r.top + 2, wi->data, TC_FROMSTRING, TA_CENTER); DrawString(r.left + 2, r.right - 2, r.top + 2, wi->data, TC_FROMSTRING, SA_CENTER);
break; break;
case WWT_DROPDOWN: { case WWT_DROPDOWN: {