summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-10-25 13:33:56 +0000
committeralberth <alberth@openttd.org>2009-10-25 13:33:56 +0000
commit413f6b880f98375a85c36ffbf9359c8a2d2c052c (patch)
treef64d9d586c61c0e3bcd53e386ce553a78029cdff
parent699e5165ff0864d7600ae08015057fa6cb20049c (diff)
downloadopenttd-413f6b880f98375a85c36ffbf9359c8a2d2c052c.tar.xz
(svn r17865) -Codechange: Remove references to specific widgets and step-heights from BaseVehicleListWindow::DrawVehicleListItems().
-rw-r--r--src/group_gui.cpp4
-rw-r--r--src/vehicle_gui.cpp22
-rw-r--r--src/vehicle_gui_base.h2
3 files changed, 17 insertions, 11 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index f8810fc18..697c660b1 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -435,7 +435,9 @@ public:
this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
- this->DrawVehicleListItems(this->vehicle_sel);
+ Rect rect = {this->widget[GRP_WIDGET_LIST_VEHICLE].left, this->widget[GRP_WIDGET_LIST_VEHICLE].top,
+ this->widget[GRP_WIDGET_LIST_VEHICLE].right, this->widget[GRP_WIDGET_LIST_VEHICLE].bottom};
+ this->DrawVehicleListItems(this->vehicle_sel, this->resize.step_height, rect);
}
virtual void OnClick(Point pt, int widget)
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index b4a612889..b8c932136 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -803,13 +803,15 @@ static void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection
/**
* Draw all the vehicle list items.
- * @param selected_vehicle the vehicle that is to be selected
+ * @param selected_vehicle The vehicle that is to be highlighted.
+ * @param line_height Height of a single item line.
+ * @param r Rectangle with edge positions of the matrix widget.
*/
-void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
+void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r)
{
- int left = this->widget[VLW_WIDGET_LIST].left + WD_MATRIX_LEFT;
- int right = this->widget[VLW_WIDGET_LIST].right - WD_MATRIX_RIGHT;
- int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
+ int left = r.left + WD_MATRIX_LEFT;
+ int right = r.right - WD_MATRIX_RIGHT;
+ int y = r.top;
uint max = min(this->vscroll.GetPosition() + this->vscroll.GetCapacity(), this->vehicles.Length());
for (uint i = this->vscroll.GetPosition(); i < max; ++i) {
const Vehicle *v = this->vehicles[i];
@@ -819,7 +821,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
SetDParam(1, v->GetDisplayProfitLastYear());
DrawVehicleImage(v, left + 19, y + 5, selected_vehicle, right - left + 1 - 19, 0);
- DrawString(left + 19, right, y + this->resize.step_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
+ DrawString(left + 19, right, y + line_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
if (v->name != NULL) {
/* The vehicle got a name so we will print it */
@@ -831,7 +833,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
DrawString(left + 19, right, y, STR_TINY_GROUP, TC_BLACK);
}
- if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, left + 138, right, y);
+ if (line_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, left + 138, right, y);
if (v->IsInDepot()) {
str = STR_BLUE_COMMA;
@@ -844,7 +846,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
DrawVehicleProfitButton(v, left, y + 13);
- y += this->resize.step_height;
+ y += line_height;
}
}
@@ -1000,7 +1002,9 @@ struct VehicleListWindow : public BaseVehicleListWindow {
/* draw arrow pointing up/down for ascending/descending sorting */
this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
- this->DrawVehicleListItems(INVALID_VEHICLE);
+ Rect rect = {this->widget[VLW_WIDGET_LIST].left, this->widget[VLW_WIDGET_LIST].top,
+ this->widget[VLW_WIDGET_LIST].right, this->widget[VLW_WIDGET_LIST].bottom};
+ this->DrawVehicleListItems(INVALID_VEHICLE, this->resize.step_height, rect);
}
virtual void OnClick(Point pt, int widget)
diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h
index 1be573928..4b7eb8fb3 100644
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -37,7 +37,7 @@ struct BaseVehicleListWindow: public Window {
this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
}
- void DrawVehicleListItems(VehicleID selected_vehicle);
+ void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r);
void SortVehicleList();
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
};