summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-24 14:53:55 +0000
committerrubidium <rubidium@openttd.org>2009-10-24 14:53:55 +0000
commitca0521f89fc53be22e18cb56f6d9c358555246af (patch)
tree709e00edcb606c69ea67ffbf1ba2a115c0bedb70 /src
parentc3992ab7b69461189f217be73136997cd097ee62 (diff)
downloadopenttd-ca0521f89fc53be22e18cb56f6d9c358555246af.tar.xz
(svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp6
-rw-r--r--src/autoreplace_gui.cpp2
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/depot_gui.cpp2
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/industry_gui.cpp6
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/network/network_content_gui.cpp2
-rw-r--r--src/network/network_gui.cpp2
-rw-r--r--src/newgrf_gui.cpp4
-rw-r--r--src/news_gui.cpp2
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/smallmap_gui.cpp2
-rw-r--r--src/station_gui.cpp6
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/toolbar_gui.cpp4
-rw-r--r--src/town_gui.cpp4
-rw-r--r--src/vehicle_gui.cpp8
-rw-r--r--src/viewport_gui.cpp2
-rw-r--r--src/window.cpp23
-rw-r--r--src/window_gui.h3
26 files changed, 41 insertions, 57 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index b37bcd17f..355cbbb00 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -203,7 +203,7 @@ struct AIListWindow : public Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST)->current_y / this->line_height);
this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
@@ -399,7 +399,7 @@ struct AISettingsWindow : public Window {
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(AIS_WIDGET_BACKGROUND)->current_y / this->line_height);
this->GetWidget<NWidgetCore>(AIS_WIDGET_BACKGROUND)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
@@ -876,7 +876,7 @@ struct AIDebugWindow : public Window {
if (data == -1 || ai_debug_company == data) this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(AID_WIDGET_LOG_PANEL)->current_y / this->resize.step_height);
}
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 8531a89cf..5aadee6fd 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -455,7 +455,7 @@ public:
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(RVW_WIDGET_LEFT_MATRIX)->current_y / this->resize.step_height);
this->vscroll2.SetCapacity(this->GetWidget<NWidgetBase>(RVW_WIDGET_RIGHT_MATRIX)->current_y / this->resize.step_height);
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 444d42848..259a7a843 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -282,7 +282,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(BBSW_BRIDGE_LIST)->current_y / this->resize.step_height);
this->GetWidget<NWidgetCore>(BBSW_BRIDGE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index de2cea4e9..131cd5de2 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1170,7 +1170,7 @@ struct BuildVehicleWindow : Window {
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (!this->listview_mode) ResizeButtons(this, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME);
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index d1d71c420..0617ab435 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -907,7 +907,7 @@ struct DepotWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_y / (int)this->resize.step_height);
this->hscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_x / (int)this->resize.step_width);
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 4ec91214e..f8810fc18 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -612,7 +612,7 @@ public:
this->group_rename = INVALID_GROUP;
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll2.SetCapacity((this->widget[GRP_WIDGET_LIST_GROUP].bottom - this->widget[GRP_WIDGET_LIST_GROUP].top + 1) / PLY_WND_PRC__SIZE_OF_ROW_TINY);
this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 1b64c652a..8f1ed09da 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -387,7 +387,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
/* Adjust the number of items in the matrix depending of the rezise */
this->vscroll.SetCapacity((this->widget[DPIW_MATRIX_WIDGET].bottom - this->widget[DPIW_MATRIX_WIDGET].top + 1) / this->resize.step_height);
@@ -706,7 +706,7 @@ public:
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT);
@@ -1091,7 +1091,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(IDW_INDUSTRY_LIST)->current_y / this->resize.step_height);
}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index e9152cda5..d85948aeb 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -380,7 +380,7 @@ struct MainWindow : Window
ZoomInOrOutToCursorWindow(wheel < 0, this);
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(MW_VIEWPORT);
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index e5cbb1975..0c113679f 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -2045,7 +2045,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(SLWW_DRIVES_DIRECTORIES_LIST)->current_y / this->resize.step_height);
}
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 43858d349..80631f17f 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -734,7 +734,7 @@ public:
this->InvalidateData();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(NCLWW_MATRIX)->current_y / this->resize.step_height);
this->GetWidget<NWidgetCore>(NCLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 85ee499b8..dc3fcef72 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -712,7 +712,7 @@ public:
if (!StrEmpty(str)) NetworkAddServer(str);
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->widget[NGWW_MATRIX].bottom - this->widget[NGWW_MATRIX].top + 1) / this->resize.step_height);
this->widget[NGWW_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index c486e36b5..2815599b1 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -279,7 +279,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ANGRFW_GRF_LIST)->current_y / this->resize.step_height);
}
@@ -608,7 +608,7 @@ struct NewGRFWindow : public Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->current_y / this->resize.step_height);
this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index ed78df793..ba27eef27 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -991,7 +991,7 @@ struct MessageHistoryWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(MHW_BACKGROUND)->current_y / this->line_height);
}
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index e985b4f21..071b1cbfb 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -1266,7 +1266,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
/* Update the scroll bar */
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST)->current_y / this->resize.step_height);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index fd352c3e3..283fa36e3 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1623,7 +1623,7 @@ struct GameSettingsWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->widget[SETTINGSEL_OPTIONSPANEL].bottom - this->widget[SETTINGSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT);
}
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 1ff7c928b..71dec9c40 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -155,7 +155,7 @@ struct SignListWindow : Window, SignList {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
}
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index d1f3a4a3a..9a92f2ec1 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1133,7 +1133,7 @@ public:
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->map_type == SMT_INDUSTRY) this->ResizeLegend();
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 28118103e..c077cdac1 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -564,7 +564,7 @@ public:
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->widget[SLW_LIST].bottom - this->widget[SLW_LIST].top + 1) / 10);
}
@@ -1049,7 +1049,7 @@ struct StationViewWindow : public Window {
DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), NULL, str);
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
ResizeButtons(this, SVW_LOCATION, SVW_RENAME);
this->vscroll.SetCapacity((this->widget[SVW_WAITING].bottom - this->widget[SVW_WAITING].top + 1) / this->resize.step_height);
@@ -1294,7 +1294,7 @@ struct SelectStationWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(JSW_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
}
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index ca8b38a34..ab6aac3d4 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -220,7 +220,7 @@ struct SubsidyListWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(SLW_PANEL)->current_y / this->resize.step_height);
}
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 65a2dd7b8..72efbf1f9 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -331,7 +331,7 @@ struct TimetableWindow : Window {
DoCommandP(0, p1, p2, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
/* Update the scroll bar */
this->vscroll.SetCapacity((this->widget[TTV_TIMETABLE_PANEL].bottom - this->widget[TTV_TIMETABLE_PANEL].top + 1) / this->resize.step_height);
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 88384bf76..5a7d05b88 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1127,7 +1127,7 @@ struct MainToolbarWindow : Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->width <= TBP_NORMAL_MAXBUTTON * TBP_BUTTONWIDTH) {
SplitToolbar(this);
@@ -1322,7 +1322,7 @@ public:
_place_proc(tile);
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
/* There are 16 buttons plus some spacings if the space allows it.
* Furthermore there are two panels of which one is non - essential
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 138cb81bb..a2e6abb69 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -466,7 +466,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(TVW_VIEWPORT);
@@ -801,7 +801,7 @@ public:
this->SetDirty();
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(TDW_CENTERTOWN)->current_y / this->resize.step_height);
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index c69dfc944..5420442dd 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -387,7 +387,7 @@ struct RefitWindow : public Window {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->widget[VRW_MATRIX].bottom - this->widget[VRW_MATRIX].top + 1) / this->resize.step_height);
this->widget[VRW_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
@@ -1103,7 +1103,7 @@ struct VehicleListWindow : public BaseVehicleListWindow {
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
this->vscroll.SetCapacity((this->widget[VLW_WIDGET_LIST].bottom - this->widget[VLW_WIDGET_LIST].top + 1) / this->resize.step_height);
this->widget[VLW_WIDGET_LIST].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
@@ -1496,7 +1496,7 @@ struct VehicleDetailsWindow : Window {
DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), NULL, str);
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
ResizeButtons(this, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TOTAL_CARGO);
@@ -1920,7 +1920,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(VVW_WIDGET_VIEWPORT);
diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp
index 2d9548363..9d118fad8 100644
--- a/src/viewport_gui.cpp
+++ b/src/viewport_gui.cpp
@@ -133,7 +133,7 @@ public:
}
}
- virtual void OnResize(Point delta)
+ virtual void OnResize()
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(EVW_VIEWPORT);
diff --git a/src/window.cpp b/src/window.cpp
index 957b5eba3..fc8e605eb 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -640,10 +640,7 @@ void Window::ReInit()
}
ResizeWindow(this, dx, dy); // Sets post-resize dirty blocks.
- Point diff;
- diff.x = dx;
- diff.y = dy;
- this->OnResize(diff); // Calls NWidgetViewport::UpdateViewportCoordinates()
+ this->OnResize(); // Calls NWidgetViewport::UpdateViewportCoordinates()
}
/** Find the Window whose parent pointer points to this window
@@ -1046,11 +1043,7 @@ void Window::FindWindowPlacementAndResize(int def_width, int def_height)
if (this->resize.step_height > 1) enlarge_y -= enlarge_y % (int)this->resize.step_height;
ResizeWindow(this, enlarge_x, enlarge_y);
-
- Point diff;
- diff.x = enlarge_x;
- diff.y = enlarge_y;
- this->OnResize(diff);
+ this->OnResize();
}
int nx = this->left;
@@ -1840,11 +1833,7 @@ static bool HandleWindowDragging()
/* ResizeWindow sets both pre- and after-size to dirty for redrawal */
ResizeWindow(w, x, y);
-
- Point diff;
- diff.x = x;
- diff.y = y;
- w->OnResize(diff);
+ w->OnResize();
return false;
}
}
@@ -2696,11 +2685,7 @@ void RelocateAllWindows(int neww, int newh)
case WC_MAIN_TOOLBAR:
if (neww - w->width != 0) {
ResizeWindow(w, min(neww, 640) - w->width, 0);
-
- Point delta;
- delta.x = neww - w->width;
- delta.y = 0;
- w->OnResize(delta);
+ w->OnResize();
}
top = w->top;
diff --git a/src/window_gui.h b/src/window_gui.h
index 4378b694a..2d182ba8b 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -771,9 +771,8 @@ public:
/**
* Called after the window got resized.
* For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
- * @param delta The amount of which the window size changed.
*/
- virtual void OnResize(Point delta) {}
+ virtual void OnResize() {}
/**
* A dropdown option associated to this window has been selected.