summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:37:53 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:37:53 +0000
commit30867c487f17ca13744977c7873f4e1cf214fd33 (patch)
tree7b7c7bcf951dba613468a4431c0f7510be76180a /src/gfx.cpp
parente2ec0ddb030afd4e7bdf08d1a8f3cb9361388eae (diff)
downloadopenttd-30867c487f17ca13744977c7873f4e1cf214fd33.tar.xz
(svn r25691) -Add: [OSX] Support for mouse selection in the IME composition string.
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 0e72e23d7..4fed39194 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -722,6 +722,21 @@ Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsiz
}
/**
+ * Get the character from a string that is drawn at a specific position.
+ * @param str String to test.
+ * @param x Position relative to the start of the string.
+ * @param start_fontsize Font size to start the text with.
+ * @return Pointer to the character at the position or NULL if there is no character at the position.
+ */
+const char *GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
+{
+ if (x < 0) return NULL;
+
+ Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
+ return layout.GetCharAtPosition(x);
+}
+
+/**
* Draw single character horizontally centered around (x,y)
* @param c Character (glyph) to draw
* @param x X position to draw character