Changeset - r15506:26ede26dbbe9
[Not reviewed]
master
0 3 0
frosch - 14 years ago 2010-07-17 14:47:54
frosch@openttd.org
(svn r20170) -Codechange: Add BaseVehicleListWindow::GetActionDropdownSize().
3 files changed with 23 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/group_gui.cpp
Show inline comments
 
@@ -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);
src/vehicle_gui.cpp
Show inline comments
 
@@ -126,6 +126,27 @@ void BaseVehicleListWindow::BuildVehicle
 
}
 

	
 
/**
 
 * 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
src/vehicle_gui_base.h
Show inline comments
 
@@ -43,6 +43,7 @@ struct BaseVehicleListWindow : public Wi
 
	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);
 
};
 

	
0 comments (0 inline, 0 general)