summaryrefslogtreecommitdiff
path: root/src/querystring_gui.h
diff options
context:
space:
mode:
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);