Changeset - r8018:0bb6be7b55d7
[Not reviewed]
master
0 8 0
belugas - 16 years ago 2007-12-06 02:31:47
belugas@openttd.org
(svn r11578) -Codechange: Introduce the window default flag WDF_TEXTENTRY which specifies that the window holding it is actually one that enables an edit box.
Use this flag when dispatching a key event instead of using some hard coded window IDs.
This should ease a little bit the creation of new edit aware windows.
8 files changed with 14 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/console.cpp
Show inline comments
 
@@ -199,13 +199,13 @@ static const Widget _iconsole_window_wid
 
	{WIDGETS_END}
 
};
 

	
 
static const WindowDesc _iconsole_window_desc = {
 
	0, 0, 2, 2, 2, 2,
 
	WC_CONSOLE, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY,
 
	_iconsole_window_widgets,
 
	IConsoleWndProc,
 
};
 

	
 
void IConsoleInit()
 
{
src/genworld_gui.cpp
Show inline comments
 
@@ -509,21 +509,21 @@ static void GenerateLandscapeWndProc(Win
 
	}
 
}
 

	
 
static const WindowDesc _generate_landscape_desc = {
 
	WDP_CENTER, WDP_CENTER, 338, 268, 338, 268,
 
	WC_GENERATE_LANDSCAPE, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY,
 
	_generate_landscape_widgets,
 
	GenerateLandscapeWndProc,
 
};
 

	
 
static const WindowDesc _heightmap_load_desc = {
 
	WDP_CENTER, WDP_CENTER, 338, 236, 338, 236,
 
	WC_GENERATE_LANDSCAPE, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY,
 
	_heightmap_load_widgets,
 
	GenerateLandscapeWndProc,
 
};
 

	
 
static void _ShowGenerateLandscape(glwp_modes mode)
 
{
 
@@ -742,13 +742,13 @@ static const Widget _create_scenario_wid
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _create_scenario_desc = {
 
	WDP_CENTER, WDP_CENTER, 338, 170, 338, 170,
 
	WC_GENERATE_LANDSCAPE, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_TEXTENTRY,
 
	_create_scenario_widgets,
 
	CreateScenarioWndProc,
 
};
 

	
 
void ShowCreateScenario()
 
{
src/misc_gui.cpp
Show inline comments
 
@@ -1177,13 +1177,13 @@ static const Widget _query_string_widget
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _query_string_desc = {
 
	190, 219, 260, 42, 260, 42,
 
	WC_QUERY_STRING, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_TEXTENTRY,
 
	_query_string_widgets,
 
	QueryStringWndProc
 
};
 

	
 
static char _edit_str_buf[64];
 

	
 
@@ -1645,21 +1645,21 @@ static void SaveLoadDlgWndProc(Window *w
 
	}
 
}
 

	
 
static const WindowDesc _load_dialog_desc = {
 
	WDP_CENTER, WDP_CENTER, 257, 154, 257, 294,
 
	WC_SAVELOAD, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY,
 
	_load_dialog_widgets,
 
	SaveLoadDlgWndProc,
 
};
 

	
 
static const WindowDesc _save_dialog_desc = {
 
	WDP_CENTER, WDP_CENTER, 257, 180, 257, 320,
 
	WC_SAVELOAD, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY,
 
	_save_dialog_widgets,
 
	SaveLoadDlgWndProc,
 
};
 

	
 
void ShowSaveLoadDialog(int mode)
 
{
src/network/network_gui.cpp
Show inline comments
 
@@ -1849,13 +1849,13 @@ static const Widget _chat_window_widgets
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _chat_window_desc = {
 
	WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height
 
	WC_SEND_NETWORK_MSG, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_TEXTENTRY,
 
	_chat_window_widgets,
 
	ChatWindowWndProc
 
};
 

	
 
void ShowNetworkChatQueryWindow(DestType type, int dest)
 
{
 
@@ -1948,13 +1948,13 @@ static const Widget _ncp_window_widgets[
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _ncp_window_desc = {
 
	WDP_AUTO, WDP_AUTO, 300, 63, 300, 63,
 
	WC_COMPANY_PASSWORD_WINDOW, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_TEXTENTRY,
 
	_ncp_window_widgets,
 
	NetworkCompanyPasswordWindowWndProc
 
};
 

	
 
void ShowNetworkCompanyPasswordWindow()
 
{
src/newgrf_gui.cpp
Show inline comments
 
@@ -232,13 +232,13 @@ static const Widget _newgrf_add_dlg_widg
 
};
 

	
 

	
 
static const WindowDesc _newgrf_add_dlg_desc = {
 
	WDP_CENTER, WDP_CENTER, 307, 237, 307, 337,
 
	WC_SAVELOAD, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_TEXTENTRY,
 
	_newgrf_add_dlg_widgets,
 
	NewGRFAddDlgWndProc,
 
};
 

	
 

	
 
/* 'NewGRF Settings' dialogue */
src/signs_gui.cpp
Show inline comments
 
@@ -295,13 +295,13 @@ static const Widget _query_sign_edit_wid
 
{ WIDGETS_END },
 
};
 

	
 
static const WindowDesc _query_sign_edit_desc = {
 
	190, 170, 260, 42, 260, 42,
 
	WC_QUERY_STRING, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_TEXTENTRY,
 
	_query_sign_edit_widgets,
 
	QuerySignEditWndProc
 
};
 

	
 
void ShowRenameSignWindow(const Sign *si)
 
{
src/window.cpp
Show inline comments
 
@@ -1673,16 +1673,12 @@ void SendWindowMessageClass(WindowClass 
 
 * @param key Lower 8 bits contain the ASCII character, the higher
 
 * 16 bits the keycode */
 
void HandleKeypress(uint32 key)
 
{
 
	Window* const *wz;
 
	WindowEvent e;
 
	/* Stores if a window with a textfield for typing is open
 
	 * If this is the case, keypress events are only passed to windows with text fields and
 
	 * to thein this main toolbar. */
 
	bool query_open = false;
 

	
 
	/*
 
	* During the generation of the world, there might be
 
	* another thread that is currently building for example
 
	* a road. To not interfere with those tasks, we should
 
	* NOT change the _current_player here.
 
@@ -1695,34 +1691,18 @@ void HandleKeypress(uint32 key)
 
	/* Setup event */
 
	e.event = WE_KEYPRESS;
 
	e.we.keypress.key     = GB(key,  0, 16);
 
	e.we.keypress.keycode = GB(key, 16, 16);
 
	e.we.keypress.cont = true;
 

	
 
	/* check if we have a query string window open before allowing hotkeys */
 
	if (FindWindowById(WC_QUERY_STRING,            0) != NULL ||
 
			FindWindowById(WC_SEND_NETWORK_MSG,        0) != NULL ||
 
			FindWindowById(WC_GENERATE_LANDSCAPE,      0) != NULL ||
 
			FindWindowById(WC_CONSOLE,                 0) != NULL ||
 
			FindWindowById(WC_SAVELOAD,                0) != NULL ||
 
			FindWindowById(WC_COMPANY_PASSWORD_WINDOW, 0) != NULL) {
 
		query_open = true;
 
	}
 

	
 
	/* Call the event, start with the uppermost window. */
 
	for (wz = _last_z_window; wz != _z_windows;) {
 
		Window *w = *--wz;
 

	
 
		/* if a query window is open, only call the event for certain window types */
 
		if (query_open &&
 
				w->window_class != WC_QUERY_STRING &&
 
				w->window_class != WC_SEND_NETWORK_MSG &&
 
				w->window_class != WC_GENERATE_LANDSCAPE &&
 
				w->window_class != WC_CONSOLE &&
 
				w->window_class != WC_SAVELOAD &&
 
				w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
 
		/* Only call the event for the windows declared as been text entry enabled */
 
		if (!(w->desc_flags & WDF_TEXTENTRY)) {
 
			continue;
 
		}
 
		w->wndproc(w, &e);
 
		if (!e.we.keypress.cont) break;
 
	}
 

	
src/window.h
Show inline comments
 
@@ -205,13 +205,13 @@ struct WindowDesc {
 
};
 

	
 
enum WindowDefaultFlag {
 
	WDF_STD_TOOLTIPS    =   1 << 0, ///< use standard routine when displaying tooltips
 
	WDF_DEF_WIDGET      =   1 << 1, ///< default widget control for some widgets in the on click event
 
	WDF_STD_BTN         =   1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1)
 

	
 
	WDF_TEXTENTRY       =   1 << 3, ///< This window is authorized to receive keyboard events
 
	WDF_UNCLICK_BUTTONS =   1 << 4, ///< Unclick buttons when the window event times out */
 
	WDF_STICKY_BUTTON   =   1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
 
	WDF_RESIZABLE       =   1 << 6, ///< A window can be resized
 
	WDF_MODAL           =   1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
 
};
 

	
0 comments (0 inline, 0 general)