summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-22 14:40:25 +0000
committerrubidium <rubidium@openttd.org>2009-11-22 14:40:25 +0000
commit5ad4a5e3e2bd5955be21e61a1ae53fa1c363450a (patch)
treee173c05c1aab8696185d9caa05f6e3126649de25 /src
parenta9e09df92375d66bb59750e35e1dc665ba6a1f31 (diff)
downloadopenttd-5ad4a5e3e2bd5955be21e61a1ae53fa1c363450a.tar.xz
(svn r18222) -Codechange: make the sign list window big font aware
Diffstat (limited to 'src')
-rw-r--r--src/signs_gui.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 6df461754..30f436d2e 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -120,6 +120,7 @@ struct SignListWindow : Window, SignList {
}
bool rtl = _dynlang.text_dir == TD_RTL;
+ int sprite_offset_y = (FONT_HEIGHT_NORMAL - 10) / 2 + 1;
uint icon_left = 4 + (rtl ? r.right - this->text_offset : r.left);
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
@@ -128,7 +129,7 @@ struct SignListWindow : Window, SignList {
for (uint16 i = this->vscroll.GetPosition(); this->vscroll.IsVisible(i) && i < this->vscroll.GetCount(); i++) {
const Sign *si = this->signs[i];
- if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + 1);
+ if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
SetDParam(0, si->index);
DrawString(text_left, text_right, y, STR_SIGN_NAME, TC_YELLOW);
@@ -165,12 +166,21 @@ struct SignListWindow : Window, SignList {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
{
- if (widget == SLW_LIST) {
- Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
- this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
- resize->height = max<uint>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_COMPANY_ICON).height);
- Dimension d = {this->text_offset + MAX_LENGTH_SIGN_NAME_PIXELS + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
- *size = maxdim(*size, d);
+ switch (widget) {
+ case SLW_LIST: {
+ Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
+ this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
+ resize->height = max<uint>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_COMPANY_ICON).height);
+ Dimension d = {this->text_offset + MAX_LENGTH_SIGN_NAME_PIXELS + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
+ *size = maxdim(*size, d);
+ } break;
+
+ case SLW_CAPTION:
+ SetDParam(0, max<uint>(1000, Sign::GetPoolSize()));
+ *size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION);
+ size->height += padding.height;
+ size->width += padding.width;
+ break;
}
}