src/querystring_gui.h
author terom@frrb.lan
Fri, 19 Dec 2008 01:32:07 +0200
changeset 10438 51bff16a04c9
parent 10295 52982b3d0d84
permissions -rw-r--r--
initial mini-map stuff
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     1
/* $Id$ */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     2
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     3
/** @file querystring_gui.h Base for the GUIs that have an edit box in them. */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     4
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     5
#ifndef QUERYSTRING_GUI_H
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     6
#define QUERYSTRING_GUI_H
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     7
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     8
#include "textbuf_gui.h"
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
     9
#include "window_gui.h"
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    10
9897
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    11
/**
10295
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    12
 * Return values for HandleEditBoxKey
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    13
 */
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    14
enum HandleEditBoxResult
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    15
{
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    16
	HEBR_EDITING = 0, // Other key pressed.
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    17
	HEBR_CONFIRM,     // Return or enter key pressed.
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    18
	HEBR_CANCEL,      // Escape key pressed.
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    19
};
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    20
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    21
/**
9897
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    22
 * Data stored about a string that can be modified in the GUI
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    23
 */
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    24
struct QueryString {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    25
	StringID caption;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    26
	Textbuf text;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    27
	const char *orig;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    28
	CharSetFilter afilter;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    29
	bool handled;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    30
9897
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    31
	/**
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    32
	 * Make sure everything gets initialized properly.
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    33
	 */
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    34
	QueryString() : orig(NULL)
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    35
	{
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    36
	}
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    37
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    38
	/**
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    39
	 * Make sure everything gets freed.
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    40
	 */
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    41
	~QueryString()
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    42
	{
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    43
		free((void*)this->orig);
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    44
	}
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    45
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    46
	void DrawEditBox(Window *w, int wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    47
	void HandleEditBox(Window *w, int wid);
10295
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
    48
	HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    49
};
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    50
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    51
struct QueryStringBaseWindow : public Window, public QueryString {
9897
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    52
	char *edit_str_buf;
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    53
	char *orig_str_buf;
10276
b60b7e17db62 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents: 9916
diff changeset
    54
	const uint16 edit_str_size; ///< maximum length of string (in bytes), including terminating '\0'
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    55
9916
40b0040c754b (svn r14069) -Fix: silence MSVC 64-bits compile warnings.
rubidium
parents: 9897
diff changeset
    56
	QueryStringBaseWindow(uint16 size, const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number), edit_str_size(size)
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    57
	{
10276
b60b7e17db62 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents: 9916
diff changeset
    58
		assert(size != 0);
9897
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    59
		this->edit_str_buf = CallocT<char>(size);
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    60
	}
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    61
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    62
	~QueryStringBaseWindow()
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    63
	{
4d9a6ff6703e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium
parents: 9285
diff changeset
    64
		free(this->edit_str_buf);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    65
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    66
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    67
	void DrawEditBox(int wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    68
	void HandleEditBox(int wid);
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9203
diff changeset
    69
	int HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    70
};
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    71
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    72
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    73
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents:
diff changeset
    74
#endif /* QUERYSTRING_GUI_H */