Files @ r10525:898f08b99221
Branch filter:

Location: cpp/openttd-patchpack/source/src/querystring_gui.h

translators
(svn r14782) -Update: WebTranslator2 update to 2009-01-02 18:38:20
arabic_egypt - 7 fixed by khaloofah (7)
brazilian_portuguese - 14 fixed, 5 changed by tucalipe (19)
catalan - 14 fixed by arnaullv (14)
finnish - 14 fixed by jpx_ (14)
hungarian - 14 fixed by alyr (14)
indonesian - 6 changed by fanioz (6)
korean - 13 fixed by dlunch (13)
malay - 8 fixed by tombakemas (8)
serbian - 29 fixed, 2 changed by nummer (31)
thai - 2 fixed by chat9780 (2)
ukrainian - 13 fixed by mad (1), znikoz (12)
urdu - 20 fixed by yasirniazkhan (20)
/* $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"

/**
 * Return values for HandleEditBoxKey
 */
enum HandleEditBoxResult
{
	HEBR_EDITING = 0, // Other key pressed.
	HEBR_CONFIRM,     // Return or enter key pressed.
	HEBR_CANCEL,      // Escape key pressed.
};

/**
 * Data stored about a string that can be modified in the GUI
 */
struct QueryString {
	StringID caption;
	Textbuf text;
	const char *orig;
	CharSetFilter afilter;
	bool handled;

	/**
	 * Make sure everything gets initialized properly.
	 */
	QueryString() : orig(NULL)
	{
	}

	/**
	 * Make sure everything gets freed.
	 */
	~QueryString()
	{
		free((void*)this->orig);
	}

	void DrawEditBox(Window *w, int wid);
	void HandleEditBox(Window *w, int wid);
	HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state);
};

struct QueryStringBaseWindow : public Window, public QueryString {
	char *edit_str_buf;
	char *orig_str_buf;
	const uint16 edit_str_size; ///< maximum length of string (in bytes), including terminating '\0'

	QueryStringBaseWindow(uint16 size, const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number), edit_str_size(size)
	{
		assert(size != 0);
		this->edit_str_buf = CallocT<char>(size);
	}

	~QueryStringBaseWindow()
	{
		free(this->edit_str_buf);
	}

	void DrawEditBox(int wid);
	void HandleEditBox(int wid);
	int HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
};

void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);

#endif /* QUERYSTRING_GUI_H */