(svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
--- a/src/graph_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/graph_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -928,7 +928,7 @@
if (_performance_rating_detail_player != INVALID_PLAYER) {
/* Raise and disable the widget for the previous selection. */
RaiseWindowWidget(w, _performance_rating_detail_player + 13);
- DisableWindowWidget(w, _performance_rating_detail_player + 13);
+ w->DisableWidget(_performance_rating_detail_player + 13);
w->SetDirty();
_performance_rating_detail_player = INVALID_PLAYER;
@@ -955,7 +955,7 @@
// Check if we have the player as an active player
if (!IsWindowWidgetDisabled(w, i + 13)) {
// Bah, player gone :(
- DisableWindowWidget(w, i + 13);
+ w->DisableWidget(i + 13);
// We need a repaint
w->SetDirty();
@@ -966,7 +966,7 @@
// Check if we have the player marked as inactive
if (IsWindowWidgetDisabled(w, i + 13)) {
// New player! Yippie :p
- EnableWindowWidget(w, i + 13);
+ w->EnableWidget(i + 13);
// We need a repaint
w->SetDirty();
}
--- a/src/newgrf_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/newgrf_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -254,8 +254,8 @@
if (!disable_all) {
/* All widgets are now enabled, so disable widgets we can't use */
- if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) DisableWindowWidget(w, SNGRFS_MOVE_UP);
- if (WP(w, newgrf_d).sel->next == NULL) DisableWindowWidget(w, SNGRFS_MOVE_DOWN);
+ if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) w->DisableWidget(SNGRFS_MOVE_UP);
+ if (WP(w, newgrf_d).sel->next == NULL) w->DisableWidget(SNGRFS_MOVE_DOWN);
}
}
--- a/src/order_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/order_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -106,7 +106,7 @@
w->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
HideWindowWidget(w, ORDER_WIDGET_REFIT); // Refit
} else {
- DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
+ w->DisableWidget(ORDER_WIDGET_TRANSFER);
}
ShowWindowWidget(w, ORDER_WIDGET_UNLOAD); // Unload
@@ -116,7 +116,7 @@
case OT_GOTO_STATION: break;
case OT_GOTO_DEPOT:
- DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
+ w->DisableWidget(ORDER_WIDGET_TRANSFER);
/* Remove unload and replace it with refit */
HideWindowWidget(w, ORDER_WIDGET_UNLOAD);
@@ -125,15 +125,15 @@
break;
case OT_GOTO_WAYPOINT:
- DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD);
- DisableWindowWidget(w, ORDER_WIDGET_UNLOAD);
- DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
+ w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
+ w->DisableWidget(ORDER_WIDGET_UNLOAD);
+ w->DisableWidget(ORDER_WIDGET_TRANSFER);
break;
default: // every other orders
- DisableWindowWidget(w, ORDER_WIDGET_NON_STOP);
- DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD);
- DisableWindowWidget(w, ORDER_WIDGET_UNLOAD);
+ w->DisableWidget(ORDER_WIDGET_NON_STOP);
+ w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
+ w->DisableWidget(ORDER_WIDGET_UNLOAD);
}
}
--- a/src/player_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/player_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -705,8 +705,8 @@
/* Spectators cannot do anything of course */
_local_player == PLAYER_SPECTATOR);
} else { // Shares are not allowed, disable buy/sell buttons
- DisableWindowWidget(w, PCW_WIDGET_BUY_SHARE);
- DisableWindowWidget(w, PCW_WIDGET_SELL_SHARE);
+ w->DisableWidget(PCW_WIDGET_BUY_SHARE);
+ w->DisableWidget(PCW_WIDGET_SELL_SHARE);
}
}
--- a/src/rail_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/rail_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -449,7 +449,7 @@
default:
/* When any other buttons than rail/signal/waypoint/station, raise and
* disable the removal button*/
- DisableWindowWidget(w, RTW_REMOVE);
+ w->DisableWidget(RTW_REMOVE);
RaiseWindowWidget(w, RTW_REMOVE);
break;
}
@@ -458,7 +458,7 @@
static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
- case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
+ case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
case WE_PAINT: w->DrawWidgets(); break;
@@ -525,7 +525,7 @@
case WE_ABORT_PLACE_OBJ:
w->RaiseButtons();
- DisableWindowWidget(w, RTW_REMOVE);
+ w->DisableWidget(RTW_REMOVE);
w->InvalidateWidget(RTW_REMOVE);
w = Window::FindById(WC_BUILD_STATION, 0);
--- a/src/road_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/road_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -192,11 +192,11 @@
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
- case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
+ case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
case WE_PAINT:
if (IsWindowWidgetLowered(w, RTW_ROAD_X) || IsWindowWidgetLowered(w, RTW_ROAD_Y)) {
- EnableWindowWidget(w, RTW_REMOVE);
+ w->EnableWidget(RTW_REMOVE);
}
w->DrawWidgets();
break;
@@ -229,7 +229,7 @@
case WE_ABORT_PLACE_OBJ:
w->RaiseButtons();
- DisableWindowWidget(w, RTW_REMOVE);
+ w->DisableWidget(RTW_REMOVE);
w->InvalidateWidget(RTW_REMOVE);
w = Window::FindById(WC_BUS_STATION, 0);
--- a/src/smallmap_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/smallmap_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -1012,7 +1012,7 @@
{
switch (e->event) {
case WE_CREATE: /* Disable zoom in button */
- DisableWindowWidget(w, 5);
+ w->DisableWidget(5);
break;
case WE_PAINT:
--- a/src/train_gui.cpp Tue Feb 13 22:09:37 2007 +0000
+++ b/src/train_gui.cpp Tue Feb 13 22:17:48 2007 +0000
@@ -152,14 +152,14 @@
w->SetWidgetDisabledState(13, !is_localplayer);
/* Disable cargo refit button, until we know we can enable it below. */
- DisableWindowWidget(w, 12);
+ w->DisableWidget(12);
if (is_localplayer) {
/* See if any vehicle can be refitted */
for (u = v; u != NULL; u = u->next) {
if (EngInfo(u->engine_type)->refit_mask != 0 ||
(RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON && v->cargo_cap != 0)) {
- EnableWindowWidget(w, 12);
+ w->EnableWidget(12);
/* We have a refittable carriage, bail out */
break;
}
@@ -405,7 +405,7 @@
SetVScrollCount(w, num);
- DisableWindowWidget(w, det_tab + 9);
+ w->DisableWidget(det_tab + 9);
w->SetWidgetDisabledState(2, v->owner != _local_player);
/* disable service-scroller when interval is set to disabled */
@@ -540,11 +540,11 @@
case 10: // Information
case 11: // Capacities
case 12: // Total cargo
- EnableWindowWidget(w, 9);
- EnableWindowWidget(w, 10);
- EnableWindowWidget(w, 11);
- EnableWindowWidget(w, 12);
- EnableWindowWidget(w, e->we.click.widget);
+ w->EnableWidget( 9);
+ w->EnableWidget(10);
+ w->EnableWidget(11);
+ w->EnableWidget(12);
+ w->EnableWidget(e->we.click.widget);
WP(w,traindetails_d).tab = e->we.click.widget - 9;
w->SetDirty();
break;
--- a/src/window.h Tue Feb 13 22:09:37 2007 +0000
+++ b/src/window.h Tue Feb 13 22:17:48 2007 +0000
@@ -438,6 +438,8 @@
public:
void SetWidgetDisabledState(byte widget_index, bool disab_stat);
+ void DisableWidget(byte widget_index);
+ void EnableWidget(byte widget_index);
//int32 AddRef()
//{
@@ -790,9 +792,9 @@
* @param w : Window on which the widget is located
* @param widget_index : index of this widget in the window
*/
-static inline void DisableWindowWidget(Window *w, byte widget_index)
+inline void Window::DisableWidget(byte widget_index)
{
- w->SetWidgetDisabledState(widget_index, true);
+ SetWidgetDisabledState(widget_index, true);
}
/**
@@ -800,9 +802,9 @@
* @param w : Window on which the widget is located
* @param widget_index : index of this widget in the window
*/
-static inline void EnableWindowWidget(Window *w, byte widget_index)
+inline void Window::EnableWidget(byte widget_index)
{
- w->SetWidgetDisabledState(widget_index, false);
+ SetWidgetDisabledState(widget_index, false);
}
/**