Changeset - r14027:95f008e01843
[Not reviewed]
master
0 21 0
alberth - 15 years ago 2009-12-20 20:08:39
alberth@openttd.org
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
21 files changed with 53 insertions and 39 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -906,7 +906,7 @@ struct AIDebugWindow : public Window {
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(AID_WIDGET_LOG_PANEL)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, AID_WIDGET_LOG_PANEL);
 
	}
 
};
 

	
src/autoreplace_gui.cpp
Show inline comments
 
@@ -480,8 +480,8 @@ public:
 

	
 
	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);
 
		this->vscroll.SetCapacityFromWidget(this, RVW_WIDGET_LEFT_MATRIX);
 
		this->vscroll2.SetCapacityFromWidget(this, RVW_WIDGET_RIGHT_MATRIX);
 

	
 
		this->GetWidget<NWidgetCore>(RVW_WIDGET_LEFT_MATRIX)->widget_data =
 
				this->GetWidget<NWidgetCore>(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
src/bridge_gui.cpp
Show inline comments
 
@@ -280,7 +280,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(BBSW_BRIDGE_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, BBSW_BRIDGE_LIST);
 
		this->GetWidget<NWidgetCore>(BBSW_BRIDGE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		this->last_size = max(this->vscroll.GetCapacity(), this->last_size);
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1176,9 +1176,8 @@ struct BuildVehicleWindow : Window {
 

	
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(BUILD_VEHICLE_WIDGET_LIST);
 
		this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll.SetCapacityFromWidget(this, BUILD_VEHICLE_WIDGET_LIST);
 
		this->GetWidget<NWidgetCore>(BUILD_VEHICLE_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
src/depot_gui.cpp
Show inline comments
 
@@ -941,12 +941,12 @@ struct DepotWindow : Window {
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX);
 
		this->vscroll.SetCapacity(nwi->current_y / (int)this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, DEPOT_WIDGET_MATRIX);
 
		if (this->type == VEH_TRAIN) {
 
			this->hscroll.SetCapacity(nwi->current_x - this->header_width - this->count_width);
 
			nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		} else {
 
			this->hscroll.SetCapacity(nwi->current_x / (int)this->resize.step_width);
 
			this->hscroll.SetCapacityFromWidget(this, DEPOT_WIDGET_MATRIX);
 
			nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (this->hscroll.GetCapacity() << MAT_COL_START);
 
		}
 
	}
src/group_gui.cpp
Show inline comments
 
@@ -596,7 +596,7 @@ public:
 
		nwi->widget_data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 

	
 
		nwi = this->GetWidget<NWidgetCore>(GRP_WIDGET_LIST_VEHICLE);
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_VEHICLE)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, GRP_WIDGET_LIST_VEHICLE);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -445,7 +445,7 @@ public:
 
	virtual void OnResize()
 
	{
 
		/* Adjust the number of items in the matrix depending of the resize */
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(DPIW_MATRIX_WIDGET)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, DPIW_MATRIX_WIDGET);
 
		this->GetWidget<NWidgetCore>(DPIW_MATRIX_WIDGET)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
@@ -1138,7 +1138,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(IDW_INDUSTRY_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, IDW_INDUSTRY_LIST);
 
	}
 

	
 
	virtual void OnHundredthTick()
src/misc_gui.cpp
Show inline comments
 
@@ -2023,7 +2023,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(SLWW_DRIVES_DIRECTORIES_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
src/network/network_content_gui.cpp
Show inline comments
 
@@ -730,7 +730,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(NCLWW_MATRIX)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, NCLWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NCLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -895,9 +895,8 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(NGWW_MATRIX);
 
		this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll.SetCapacityFromWidget(this, NGWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NGWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
 
@@ -1673,9 +1672,8 @@ struct NetworkLobbyWindow : public Windo
 

	
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(NLWW_MATRIX);
 
		this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll.SetCapacityFromWidget(this, NLWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -297,7 +297,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ANGRFW_GRF_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, ANGRFW_GRF_LIST);
 
	}
 

	
 
	virtual void OnPaint()
 
@@ -621,9 +621,8 @@ struct NewGRFWindow : public Window {
 

	
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST);
 
		this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll.SetCapacityFromWidget(this, SNGRFS_FILE_LIST);
 
		this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
@@ -970,7 +969,7 @@ struct NewGRFWindow : public Window {
 

	
 
				for (c = this->list, i = 0; c != NULL; c = c->next, i++) {}
 

	
 
				this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SNGRFS_FILE_LIST)->current_y) / this->resize.step_height);
 
				this->vscroll.SetCapacityFromWidget(this, SNGRFS_FILE_LIST);
 
				this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
				this->vscroll.SetCount(i);
 
				break;
src/order_gui.cpp
Show inline comments
 
@@ -1289,7 +1289,7 @@ public:
 
	virtual void OnResize()
 
	{
 
		/* Update the scroll bar */
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, ORDER_WIDGET_ORDER_LIST);
 
	}
 

	
 
	virtual void OnTimeout()
src/settings_gui.cpp
Show inline comments
 
@@ -1625,7 +1625,7 @@ struct GameSettingsWindow : Window {
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SETTINGSEL_OPTIONSPANEL)->current_y - SETTINGTREE_TOP_OFFSET - SETTINGTREE_BOTTOM_OFFSET) / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, SETTINGSEL_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET);
 
	}
 
};
 

	
src/signs_gui.cpp
Show inline comments
 
@@ -158,7 +158,7 @@ struct SignListWindow : Window, SignList
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
src/station_gui.cpp
Show inline comments
 
@@ -604,7 +604,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL);
 
		this->vscroll.SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
@@ -1118,7 +1118,7 @@ struct StationViewWindow : public Window
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SVW_WAITING)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, SVW_WAITING, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 
};
 

	
 
@@ -1359,7 +1359,7 @@ struct SelectStationWindow : Window {
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(JSW_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, JSW_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
src/subsidy_gui.cpp
Show inline comments
 
@@ -217,7 +217,7 @@ struct SubsidyListWindow : Window {
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(SLW_PANEL)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, SLW_PANEL);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
src/timetable_gui.cpp
Show inline comments
 
@@ -585,7 +585,7 @@ struct TimetableWindow : Window {
 
	virtual void OnResize()
 
	{
 
		/* Update the scroll bar */
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(TTV_TIMETABLE_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, TTV_TIMETABLE_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 

	
 
	/**
src/town_gui.cpp
Show inline comments
 
@@ -845,7 +845,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(TDW_CENTERTOWN)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, TDW_CENTERTOWN);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
src/vehicle_gui.cpp
Show inline comments
 
@@ -494,9 +494,8 @@ struct RefitWindow : public Window {
 

	
 
	virtual void OnResize()
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(VRW_MATRIX);
 
		this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
		nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll.SetCapacityFromWidget(this, VRW_MATRIX);
 
		this->GetWidget<NWidgetCore>(VRW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
 
@@ -1243,7 +1242,7 @@ public:
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(VLW_WIDGET_LIST)->current_y / this->resize.step_height);
 
		this->vscroll.SetCapacityFromWidget(this, VLW_WIDGET_LIST);
 
		this->GetWidget<NWidgetCore>(VLW_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
@@ -1683,7 +1682,7 @@ struct VehicleDetailsWindow : Window {
 
	{
 
		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(VLD_WIDGET_MATRIX);
 
		if (nwi != NULL) {
 
			this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height);
 
			this->vscroll.SetCapacityFromWidget(this, VLD_WIDGET_MATRIX);
 
			nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		}
 
	}
src/window.cpp
Show inline comments
 
@@ -79,6 +79,23 @@ WindowDesc::~WindowDesc()
 
}
 

	
 
/**
 
 * Set capacity of visible elements from the size and resize properties of a widget.
 
 * @param w       Window.
 
 * @param widget  Widget with size and resize properties.
 
 * @param padding Padding to subtract from the size.
 
 * @note Updates the position if needed.
 
 */
 
void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding)
 
{
 
	NWidgetBase *nwid = w->GetWidget<NWidgetBase>(widget);
 
	if (this->is_vertical) {
 
		this->SetCapacity(((int)nwid->current_y - padding) / (int)nwid->resize_y);
 
	} else {
 
		this->SetCapacity(((int)nwid->current_x - padding) / (int)nwid->resize_x);
 
	}
 
}
 

	
 
/**
 
 * Set the window that has the focus
 
 * @param w The window to set the focus on
 
 */
src/window_gui.h
Show inline comments
 
@@ -247,6 +247,8 @@ public:
 
		if (this->cap + this->pos > this->count) this->pos = max(0, this->count - this->cap);
 
	}
 

	
 
	void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
 

	
 
	/**
 
	 * Sets the position of the first visible element
 
	 * @param position the position of the element
0 comments (0 inline, 0 general)