changeset 11506:a952351a6319 draft

(svn r15867) -Codechange: remove the assumption that the first widgets are the close box/title bar. Most work already done by r15756.
author yexo <yexo@openttd.org>
date Sat, 28 Mar 2009 02:46:10 +0000
parents fba50a5a947b
children 034f89d22bc0
files src/window.cpp src/window_gui.h
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -285,7 +285,7 @@
 		/* If clicked on a window that previously did dot have focus */
 		if (_focused_window != w &&
 				(w->desc_flags & WDF_NO_FOCUS) == 0 &&           // Don't lose focus to toolbars
-				!(w->desc_flags & WDF_STD_BTN && widget == 0)) { // Don't change focused window if 'X' (close button) was clicked
+				!(w->desc_flags & WDF_STD_BTN && w->widget[widget].type == WWT_CLOSEBOX)) { // Don't change focused window if 'X' (close button) was clicked
 			focused_widget_changed = true;
 			if (_focused_window != NULL) {
 				_focused_window->OnFocusLost();
@@ -348,12 +348,12 @@
 		if (HideDropDownMenu(w) == widget) return;
 
 		if (w->desc_flags & WDF_STD_BTN) {
-			if (widget == 0) { // 'X'
+			if (w->widget[widget].type == WWT_CLOSEBOX) { // 'X'
 				delete w;
 				return;
 			}
 
-			if (widget == 1) { // 'Title bar'
+			if (w->widget[widget].type == WWT_CAPTION) { // 'Title bar'
 				StartWindowDrag(w);
 				return;
 			}
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -69,11 +69,11 @@
 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, @see DispatchLeftClickEvent()
-	WDF_STD_BTN         =   1 << 2, ///< Default handling for close and titlebar widgets (widget no 0 and 1)
+	WDF_STD_BTN         =   1 << 2, ///< Default handling for close and titlebar widgets (the widgets with type WWT_CLOSEBOX and WWT_CAPTION).
 	WDF_CONSTRUCTION    =   1 << 3, ///< This window is used for construction; close it whenever changing company.
 
 	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_STICKY_BUTTON   =   1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget with type WWT_STICKYBOX).
 	WDF_RESIZABLE       =   1 << 6, ///< Window can be resized
 	WDF_MODAL           =   1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'