summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-07-17 14:47:54 +0000
committerfrosch <frosch@openttd.org>2010-07-17 14:47:54 +0000
commitce480fb4b5adce00719a45f374108833c31748f9 (patch)
tree00852b3355785c1a313d86e4f506abae10c32347 /src
parentc79d4f46a35fe1029f1017f243fbf367bb363e45 (diff)
downloadopenttd-ce480fb4b5adce00719a45f374108833c31748f9.tar.xz
(svn r20170) -Codechange: Add BaseVehicleListWindow::GetActionDropdownSize().
Diffstat (limited to 'src')
-rw-r--r--src/group_gui.cpp6
-rw-r--r--src/vehicle_gui.cpp21
-rw-r--r--src/vehicle_gui_base.h1
3 files changed, 23 insertions, 5 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index f2c8d77f2..29728cadb 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -236,11 +236,7 @@ public:
break;
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
- static const StringID _dropdown_text[] = {STR_VEHICLE_LIST_REPLACE_VEHICLES, STR_VEHICLE_LIST_SEND_FOR_SERVICING, STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT, STR_GROUP_ADD_SHARED_VEHICLE, STR_GROUP_REMOVE_ALL_VEHICLES};
- Dimension d = {0, 0};
- for (const StringID *sid = _dropdown_text; sid != endof(_dropdown_text); sid++) {
- d = maxdim(d, GetStringBoundingBox(*sid));
- }
+ Dimension d = this->GetActionDropdownSize(true);
d.height += padding.height;
d.width += padding.width;
*size = maxdim(*size, d);
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 3cfbfc911..f53019578 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -126,6 +126,27 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w
}
/**
+ * Compute the size for the Action dropdown.
+ * @param show_group If true include group-related stuff.
+ * @return Required size.
+ */
+Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_group)
+{
+ Dimension d = {0, 0};
+
+ d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES));
+ d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_FOR_SERVICING));
+ d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT));
+
+ if (show_group) {
+ d = maxdim(d, GetStringBoundingBox(STR_GROUP_ADD_SHARED_VEHICLE));
+ d = maxdim(d, GetStringBoundingBox(STR_GROUP_REMOVE_ALL_VEHICLES));
+ }
+
+ return d;
+}
+
+/**
* Display the Action dropdown window.
* @param show_group If true include group-related stuff.
* @return Itemlist for dropdown
diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h
index eec4661a9..aded315d5 100644
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -43,6 +43,7 @@ struct BaseVehicleListWindow : public Window {
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
void SortVehicleList();
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
+ Dimension GetActionDropdownSize(bool show_group);
DropDownList *BuildActionDropdownList(bool show_group);
};