changeset 12899:85086de37f39 draft

(svn r17391) -Codechange: Add string box calculation routine for multi-line strings.
author alberth <alberth@openttd.org>
date Wed, 02 Sep 2009 20:40:56 +0000
parents 8b5b1dcdf299
children f4f237bdc0da
files src/gfx.cpp src/gfx_func.h
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -729,6 +729,16 @@
 	return GetMultilineStringHeight(buffer, GB(tmp, 0, 16));
 }
 
+/** Calculate string bounding box for multi-line strings.
+ * @param str        String to check.
+ * @param suggestion Suggested bounding box.
+ * @return Bounding box for the multi-line string, may be bigger than \a suggestion.
+ */
+Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
+{
+	Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)};
+	return box;
+}
 
 /**
  * Draw string, possibly over multiple lines.
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -117,6 +117,7 @@
 Dimension GetStringBoundingBox(StringID strid);
 uint32 FormatStringLinebreaks(char *str, int maxw);
 int GetStringHeight(StringID str, int maxw);
+Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
 void LoadStringWidthTable();
 
 /**