(svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method cpp_gui
authorKUDr
Tue, 13 Feb 2007 22:47:05 +0000
branchcpp_gui
changeset 6248 24583caadfee
parent 6247 67e881450cf3
child 6249 abafebc2fbce
(svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
src/depot_gui.cpp
src/graph_gui.cpp
src/main_gui.cpp
src/order_gui.cpp
src/rail_gui.cpp
src/road_gui.cpp
src/settings_gui.cpp
src/widget.cpp
src/window.cpp
src/window.h
--- a/src/depot_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/depot_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -914,14 +914,14 @@
 				} break;
 
 				case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
-					if (!IsWindowWidgetDisabled(w, DEPOT_WIDGET_SELL) &&
+					if (!w->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
 						WP(w, depot_d).sel != INVALID_VEHICLE) {
 						Vehicle *v;
 						uint command;
 						int sell_cmd;
 						bool is_engine;
 
-						if (IsWindowWidgetDisabled(w, e->we.click.widget)) return;
+						if (w->IsWidgetDisabled(e->we.click.widget)) return;
 						if (WP(w, depot_d).sel == INVALID_VEHICLE) return;
 
 						w->HandleButtonClick(e->we.click.widget);
--- a/src/graph_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/graph_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -953,7 +953,7 @@
 			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 				if (!GetPlayer(i)->is_active) {
 					// Check if we have the player as an active player
-					if (!IsWindowWidgetDisabled(w, i + 13)) {
+					if (!w->IsWidgetDisabled(i + 13)) {
 						// Bah, player gone :(
 						w->DisableWidget(i + 13);
 
@@ -964,7 +964,7 @@
 				}
 
 				// Check if we have the player marked as inactive
-				if (IsWindowWidgetDisabled(w, i + 13)) {
+				if (w->IsWidgetDisabled(i + 13)) {
 					// New player! Yippie :p
 					w->EnableWidget(i + 13);
 					// We need a repaint
@@ -1053,7 +1053,7 @@
 			// Check which button is clicked
 			if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) {
 				// Is it no on disable?
-				if (!IsWindowWidgetDisabled(w, e->we.click.widget)) {
+				if (!w->IsWidgetDisabled(e->we.click.widget)) {
 					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
 					_performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13);
 					LowerWindowWidget(w, _performance_rating_detail_player + 13);
--- a/src/main_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/main_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -108,7 +108,7 @@
  */
 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc)
 {
-	if (IsWindowWidgetDisabled(w, widget)) return false;
+	if (w->IsWidgetDisabled(widget)) return false;
 
 	SndPlayFx(SND_15_BEEP);
 	w->SetDirty();
@@ -1819,7 +1819,7 @@
 		break;
 
 	case WE_CLICK: {
-		if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget))
+		if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget))
 			_toolbar_button_procs[e->we.click.widget](w);
 	} break;
 
--- a/src/order_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/order_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -524,7 +524,7 @@
 			if (e->we.keypress.keycode == _order_keycodes[i]) {
 				e->we.keypress.cont = false;
 				//see if the button is disabled
-				if (!IsWindowWidgetDisabled(w, i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v);
+				if (!w->IsWidgetDisabled(i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v);
 				break;
 			}
 		}
--- a/src/rail_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/rail_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -319,7 +319,7 @@
 
 static void BuildRailClick_Remove(Window *w)
 {
-	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	w->SetDirty();
 	SndPlayFx(SND_15_BEEP);
 
--- a/src/road_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/road_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -169,7 +169,7 @@
 
 static void BuildRoadClick_Remove(Window *w)
 {
-	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
+	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	w->SetDirty();
 	SndPlayFx(SND_15_BEEP);
 	ToggleWidgetLoweredState(w, RTW_REMOVE);
--- a/src/settings_gui.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/settings_gui.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -98,7 +98,7 @@
 		StringID str = STR_02BE_DEFAULT;
 
 		w->SetWidgetDisabledState(21, !(_vehicle_design_names & 1));
-		if (!IsWindowWidgetDisabled(w, 21)) str = STR_02BF_CUSTOM;
+		if (!w->IsWidgetDisabled(21)) str = STR_02BF_CUSTOM;
 		SetDParam(0, str);
 		SetDParam(1, _currency_specs[_opt_ptr->currency].name);
 		SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
--- a/src/widget.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/widget.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -454,7 +454,7 @@
 
 			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top+2, wi->data, 0x84);
 draw_default:;
-			if (IsWindowWidgetDisabled(this, i)) {
+			if (IsWidgetDisabled(i)) {
 				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
 			}
 		}
--- a/src/window.cpp	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/window.cpp	Tue Feb 13 22:47:05 2007 +0000
@@ -606,7 +606,7 @@
 		if (e.we.click.widget < 0) return; /* exit if clicked outside of widgets */
 
 		/* don't allow any interaction if the button has been disabled */
-		if (IsWindowWidgetDisabled(this, e.we.click.widget)) return;
+		if (IsWidgetDisabled(e.we.click.widget)) return;
 
 		wi = &widget[e.we.click.widget];
 
--- a/src/window.h	Tue Feb 13 22:17:48 2007 +0000
+++ b/src/window.h	Tue Feb 13 22:47:05 2007 +0000
@@ -437,9 +437,10 @@
 	void ScrollbarClickHandler(const Widget *wi, int x, int y);
 public:
 
-	void SetWidgetDisabledState(byte widget_index, bool disab_stat);
-	void DisableWidget(byte widget_index);
-	void EnableWidget(byte widget_index);
+	/*inline*/ void SetWidgetDisabledState(byte widget_index, bool disab_stat);
+	/*inline*/ void DisableWidget(byte widget_index);
+	/*inline*/ void EnableWidget(byte widget_index);
+	/*inline*/ bool IsWidgetDisabled(byte widget_index) const;
 
 	//int32 AddRef()
 	//{
@@ -813,10 +814,10 @@
  * @param widget_index : index of this widget in the window
  * @return status of the widget ie: disabled = true, enabled = false
  */
-static inline bool IsWindowWidgetDisabled(const Window *w, byte widget_index)
+inline bool Window::IsWidgetDisabled(byte widget_index) const
 {
-	assert(widget_index < w->widget_count);
-	return HASBIT(w->widget[widget_index].display_flags, WIDG_DISABLED);
+	assert(widget_index < widget_count);
+	return HASBIT(widget[widget_index].display_flags, WIDG_DISABLED);
 }
 
 /**