summaryrefslogtreecommitdiff
path: root/src/querystring_gui.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-14 22:50:17 +0000
committerfrosch <frosch@openttd.org>2012-11-14 22:50:17 +0000
commitf6d4200f86e93828a4a58a957d6ae7d9d5497a86 (patch)
tree2d940ae42f1f273a19c2c33f2858feab9122d9c2 /src/querystring_gui.h
parent0ea21523556a345d38933ee2dd6dcdca0ec08514 (diff)
downloadopenttd-f6d4200f86e93828a4a58a957d6ae7d9d5497a86.tar.xz
(svn r24738) -Codechange: Remove Textbuf::Initialize in favour of a constructor.
Diffstat (limited to 'src/querystring_gui.h')
-rw-r--r--src/querystring_gui.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/querystring_gui.h b/src/querystring_gui.h
index 0eebd6206..1ce9b93f7 100644
--- a/src/querystring_gui.h
+++ b/src/querystring_gui.h
@@ -40,9 +40,11 @@ struct QueryString {
bool handled;
/**
- * Make sure everything gets initialized properly.
+ * Initialize string.
+ * @param size Maximum size in bytes.
+ * @param chars Maximum size in chars.
*/
- QueryString() : ok_button(-1), cancel_button(-1), orig(NULL)
+ QueryString(uint16 size, uint16 chars = UINT16_MAX) : ok_button(-1), cancel_button(-1), text(size, chars), orig(NULL)
{
}
@@ -67,16 +69,10 @@ struct QueryStringBaseWindow : public Window, public QueryString {
const uint16 edit_str_size; ///< Maximum length of string (in bytes), including terminating '\0'.
const uint16 max_chars; ///< Maximum length of string (in characters), including terminating '\0'.
- QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), edit_str_size(size), max_chars(chars == UINT16_MAX ? size : chars)
+ QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), QueryString(size, chars), edit_str_buf(text.buf), edit_str_size(text.max_bytes), max_chars(text.max_chars)
{
- assert(size != 0);
- this->edit_str_buf = CallocT<char>(size);
}
- ~QueryStringBaseWindow()
- {
- free(this->edit_str_buf);
- }
};
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button);