querystring_gui.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef QUERYSTRING_GUI_H
00013 #define QUERYSTRING_GUI_H
00014
00015 #include "textbuf_gui.h"
00016 #include "window_gui.h"
00017
00021 enum HandleEditBoxResult
00022 {
00023 HEBR_EDITING = 0,
00024 HEBR_CONFIRM,
00025 HEBR_CANCEL,
00026 HEBR_NOT_FOCUSED,
00027 };
00028
00032 struct QueryString {
00033 StringID caption;
00034 Textbuf text;
00035 const char *orig;
00036 CharSetFilter afilter;
00037 bool handled;
00038
00042 QueryString() : orig(NULL)
00043 {
00044 }
00045
00049 ~QueryString()
00050 {
00051 free((void*)this->orig);
00052 }
00053
00054 private:
00055 bool HasEditBoxFocus(const Window *w, int wid) const;
00056 public:
00057 void DrawEditBox(Window *w, int wid);
00058 void HandleEditBox(Window *w, int wid);
00059 HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, EventState &state);
00060 };
00061
00062 struct QueryStringBaseWindow : public Window, public QueryString {
00063 char *edit_str_buf;
00064 const uint16 edit_str_size;
00065 const uint16 max_chars;
00066
00067 QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), edit_str_size(size), max_chars(chars == UINT16_MAX ? size : chars)
00068 {
00069 assert(size != 0);
00070 this->edit_str_buf = CallocT<char>(size);
00071 }
00072
00073 ~QueryStringBaseWindow()
00074 {
00075 free(this->edit_str_buf);
00076 }
00077
00078 void DrawEditBox(int wid);
00079 void HandleEditBox(int wid);
00080 HandleEditBoxResult HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
00081 virtual void OnOpenOSKWindow(int wid);
00082 virtual void OnOSKInput(int wid) {}
00083 };
00084
00085 void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);
00086 void UpdateOSKOriginalText(const QueryStringBaseWindow *parent, int button);
00087
00088 #endif