changeset 16825:1595576cd300 draft

(svn r21559) -Add: Disable the refit button until a refit option is selected.
author terkhen <terkhen@openttd.org>
date Tue, 21 Dec 2010 13:49:42 +0000
parents 9d47c26bc1f1
children 6d346c9c259d
files src/vehicle_gui.cpp
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -466,6 +466,7 @@
 
 	RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window()
 	{
+		this->sel = -1;
 		this->CreateNestedTree(desc);
 
 		this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
@@ -479,7 +480,7 @@
 		this->owner = v->owner;
 
 		this->order = order;
-		this->sel  = -1;
+		this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
 	}
 
 	virtual void OnInit()
@@ -505,6 +506,7 @@
 				}
 			}
 
+			this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
 			/* If the selected refit option was not found, scroll the window to the initial position. */
 			if (this->sel == -1) this->vscroll->ScrollTowards(0);
 		} else {
@@ -614,6 +616,8 @@
 		switch (widget) {
 			case VRW_MATRIX: { // listbox
 				this->sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, VRW_MATRIX);
+				if (this->sel == INT_MAX) this->sel = -1;
+				this->SetWidgetDisabledState(VRW_REFITBUTTON, this->sel == -1);
 				this->InvalidateData(1);
 
 				if (click_count == 1) break;