From c99eb9e4564b0c39356b469dfc2e1038c74da853 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 26 Jan 2008 20:55:04 +0000 Subject: (svn r11988) -Codechange: Add a generic way of changing a widget's size and adjust the widgets around it to suit. --- src/build_vehicle_gui.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/build_vehicle_gui.cpp') diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 50655df53..d524b0770 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -958,23 +958,6 @@ void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, u } } -static void ExpandPurchaseInfoWidget(Window *w, int expand_by) -{ - Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL]; - - SetWindowDirty(w); - wi->bottom += expand_by; - - for (uint i = BUILD_VEHICLE_WIDGET_BUILD; i < BUILD_VEHICLE_WIDGET_END; i++) { - wi = &w->widget[i]; - wi->top += expand_by; - wi->bottom += expand_by; - } - - w->height += expand_by; - SetWindowDirty(w); -} - static void DrawBuildVehicleWindow(Window *w) { const buildvehicle_d *bv = &WP(w, buildvehicle_d); @@ -996,7 +979,11 @@ static void DrawBuildVehicleWindow(Window *w) const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL]; int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine); - if (text_end > wi->bottom) ExpandPurchaseInfoWidget(w, text_end - wi->bottom); + if (text_end > wi->bottom) { + SetWindowDirty(w); + ResizeWindowForWidget(w, BUILD_VEHICLE_WIDGET_PANEL, 0, text_end - wi->bottom); + SetWindowDirty(w); + } } DrawSortButtonState(w, BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, bv->descending_sort_order ? SBS_DOWN : SBS_UP); -- cgit v1.2.3-54-g00ecf