summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-11-17 13:04:05 +0000
committerpeter1138 <peter1138@openttd.org>2009-11-17 13:04:05 +0000
commit14c6fd0e390df57db46a97373147b50f43ae2a75 (patch)
tree363b130f255b1aec4902a09c71edb76d54b0fec9 /src/widget.cpp
parentf14cd93ec860ad3b84fd6f1989328464b6a14a74 (diff)
downloadopenttd-14c6fd0e390df57db46a97373147b50f43ae2a75.tar.xz
(svn r18138) -Codechange: Add a new widgetpart to specify the height of a widget in text lines.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 9f7db9fd0..1d4f84059 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -757,6 +757,17 @@ void NWidgetResizeBase::SetMinimalSize(uint min_x, uint min_y)
}
/**
+ * Set minimal text lines for the widget.
+ * @param min_lines Number of text lines of the widget.
+ * @param spacing Extra spacing (eg WD_FRAMERECT_TOP + _BOTTOM) of the widget.
+ * @param size Font size of text.
+ */
+void NWidgetResizeBase::SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size)
+{
+ this->min_y = min_lines * GetCharacterHeight(size) + spacing;
+}
+
+/**
* Set the filling of the widget from initial size.
* @param fill_x Allow horizontal filling from initial size.
* @param fill_y Allow vertical filling from initial size.
@@ -2088,6 +2099,15 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
break;
}
+ case WPT_MINTEXTLINES: {
+ NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
+ if (nwrb != NULL) {
+ assert(parts->u.text_lines.size >= FS_BEGIN && parts->u.text_lines.size < FS_END);
+ nwrb->SetMinimalTextLines(parts->u.text_lines.lines, parts->u.text_lines.spacing, parts->u.text_lines.size);
+ }
+ break;
+ }
+
case WPT_FILL: {
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
if (nwrb != NULL) nwrb->SetFill(parts->u.xy.x != 0, parts->u.xy.y != 0);