2008-05-11 12:26:20 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/** @file querystring_gui.h Base for the GUIs that have an edit box in them. */
|
|
|
|
|
|
|
|
#ifndef QUERYSTRING_GUI_H
|
|
|
|
#define QUERYSTRING_GUI_H
|
|
|
|
|
|
|
|
#include "textbuf_gui.h"
|
|
|
|
#include "window_gui.h"
|
|
|
|
|
2008-10-25 19:59:11 +00:00
|
|
|
/**
|
|
|
|
* Return values for HandleEditBoxKey
|
|
|
|
*/
|
|
|
|
enum HandleEditBoxResult
|
|
|
|
{
|
|
|
|
HEBR_EDITING = 0, // Other key pressed.
|
|
|
|
HEBR_CONFIRM, // Return or enter key pressed.
|
|
|
|
HEBR_CANCEL, // Escape key pressed.
|
|
|
|
};
|
|
|
|
|
2008-08-11 22:08:56 +00:00
|
|
|
/**
|
|
|
|
* Data stored about a string that can be modified in the GUI
|
|
|
|
*/
|
2008-05-11 12:26:20 +00:00
|
|
|
struct QueryString {
|
|
|
|
StringID caption;
|
|
|
|
Textbuf text;
|
|
|
|
const char *orig;
|
|
|
|
CharSetFilter afilter;
|
|
|
|
bool handled;
|
|
|
|
|
2008-08-11 22:08:56 +00:00
|
|
|
/**
|
|
|
|
* Make sure everything gets initialized properly.
|
|
|
|
*/
|
|
|
|
QueryString() : orig(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure everything gets freed.
|
|
|
|
*/
|
|
|
|
~QueryString()
|
|
|
|
{
|
|
|
|
free((void*)this->orig);
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
void DrawEditBox(Window *w, int wid);
|
|
|
|
void HandleEditBox(Window *w, int wid);
|
2008-10-25 19:59:11 +00:00
|
|
|
HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state);
|
2008-05-11 12:26:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QueryStringBaseWindow : public Window, public QueryString {
|
2008-08-11 22:08:56 +00:00
|
|
|
char *edit_str_buf;
|
|
|
|
char *orig_str_buf;
|
2008-10-22 19:12:10 +00:00
|
|
|
const uint16 edit_str_size; ///< maximum length of string (in bytes), including terminating '\0'
|
2008-08-11 22:08:56 +00:00
|
|
|
|
2008-08-13 14:52:54 +00:00
|
|
|
QueryStringBaseWindow(uint16 size, const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number), edit_str_size(size)
|
2008-08-11 22:08:56 +00:00
|
|
|
{
|
2008-10-22 19:12:10 +00:00
|
|
|
assert(size != 0);
|
2008-08-11 22:08:56 +00:00
|
|
|
this->edit_str_buf = CallocT<char>(size);
|
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2008-08-11 22:08:56 +00:00
|
|
|
~QueryStringBaseWindow()
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2008-08-11 22:08:56 +00:00
|
|
|
free(this->edit_str_buf);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawEditBox(int wid);
|
|
|
|
void HandleEditBox(int wid);
|
2009-01-03 23:40:29 +00:00
|
|
|
HandleEditBoxResult HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
|
2009-01-03 13:59:05 +00:00
|
|
|
virtual void OnOpenOSKWindow(int wid);
|
2008-05-11 12:26:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);
|
|
|
|
|
|
|
|
#endif /* QUERYSTRING_GUI_H */
|