tron@2186: /* $Id$ */ tron@2186: rubidium@8107: /** @file textbuf_gui.h Stuff related to the text buffer GUI. */ truelight@0: rubidium@8107: #ifndef TEXTBUF_GUI_H rubidium@8107: #define TEXTBUF_GUI_H Darkvater@1632: rubidium@8107: #include "window_type.h" rubidium@8214: #include "string_type.h" rubidium@8737: #include "strings_type.h" smatz@10145: #include "core/enum_type.hpp" maedhros@6670: rubidium@8107: struct Textbuf { smatz@10276: char *buf; ///< buffer in which text is saved smatz@10276: uint16 maxsize, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxsize is in bytes (including terminating '\0') smatz@10276: uint16 size, width; ///< the current size of the string. Width specifies screensize in pixels, size is in bytes smatz@10276: bool caret; ///< is the caret ("_") visible or not smatz@10276: uint16 caretpos; ///< the current position of the caret in the buffer, in bytes smatz@10276: uint16 caretxoffs; ///< the current position of the caret in pixels Darkvater@1632: }; truelight@0: Darkvater@1390: bool HandleCaret(Textbuf *tb); Darkvater@1390: Darkvater@1879: void DeleteTextBufferAll(Textbuf *tb); Darkvater@1390: bool DeleteTextBufferChar(Textbuf *tb, int delmode); peter1138@5108: bool InsertTextBufferChar(Textbuf *tb, uint32 key); Darkvater@1390: bool InsertTextBufferClipboard(Textbuf *tb); Darkvater@1390: bool MoveTextBufferPos(Textbuf *tb, int navmode); smatz@10276: void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth); Darkvater@1390: void UpdateTextBufferSize(Textbuf *tb); truelight@0: smatz@10145: /** Flags used in ShowQueryString() call */ smatz@10145: enum QueryStringFlags { smatz@10148: QSF_NONE = 0, smatz@10145: QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change smatz@10148: QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned) smatz@10145: }; smatz@10145: smatz@10145: DECLARE_ENUM_AS_BIT_SET(QueryStringFlags) smatz@10145: smatz@10145: smatz@9319: typedef void QueryCallbackProc(Window*, bool); smatz@9319: smatz@10145: void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags); smatz@9319: void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback); truelight@0: rubidium@8737: /** The number of 'characters' on the on-screen keyboard. */ rubidium@8737: static const uint OSK_KEYBOARD_ENTRIES = 50; rubidium@8737: rubidium@8737: /** rubidium@8737: * The number of characters has to be OSK_KEYBOARD_ENTRIES. However, these rubidium@8737: * have to be UTF-8 encoded, which means up to 4 bytes per character. rubidium@8737: * Furthermore the string needs to be '\0'-terminated. rubidium@8737: */ rubidium@8737: extern char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1]; rubidium@8737: rubidium@8107: #endif /* TEXTBUF_GUI_H */