summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-05-13 21:11:38 +0000
committerpeter1138 <peter1138@openttd.org>2008-05-13 21:11:38 +0000
commit2c02810b3a2913be6300a1d8acb33d90595e0f64 (patch)
treec8ffea0b2a6dd64f1f1198ca523c15df8c62b86b /src/widgets
parent839070028e8c5101de770b03bb9f327479e02817 (diff)
downloadopenttd-2c02810b3a2913be6300a1d8acb33d90595e0f64.tar.xz
(svn r13075) -Codechange: Allow any value for a dropdown item instead of just positive.
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dropdown.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 0a361a0f5..bab184da7 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -87,9 +87,9 @@ struct DropdownWindow : Window {
DeleteDropDownList(this->list);
}
- int GetDropDownItem()
+ bool GetDropDownItem(int &value)
{
- if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) < 0) return -1;
+ if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) < 0) return false;
int y = _cursor.pos.y - this->top - 2;
int width = this->widget[0].right - 3;
@@ -105,14 +105,15 @@ struct DropdownWindow : Window {
int item_height = item->Height(width);
if (y < item_height) {
- if (item->masked || item->String() == STR_NULL) return -1;
- return item->result;
+ if (item->masked || item->String() == STR_NULL) return false;
+ value = item->result;
+ return true;
}
y -= item_height;
}
- return -1;
+ return false;
}
virtual void OnPaint()
@@ -162,8 +163,8 @@ struct DropdownWindow : Window {
virtual void OnClick(Point pt, int widget)
{
if (widget != 0) return;
- int item = GetDropDownItem();
- if (item >= 0) {
+ int item;
+ if (this->GetDropDownItem(item)) {
this->click_delay = 4;
this->selected_index = item;
this->SetDirty();
@@ -197,11 +198,11 @@ struct DropdownWindow : Window {
}
if (this->drag_mode) {
- int item = GetDropDownItem();
+ int item;
if (!_left_button_clicked) {
this->drag_mode = false;
- if (item < 0) return;
+ if (!this->GetDropDownItem(item)) return;
this->click_delay = 2;
} else {
if (_cursor.pos.y <= this->top + 2) {
@@ -214,7 +215,7 @@ struct DropdownWindow : Window {
return;
}
- if (item < 0) return;
+ if (!this->GetDropDownItem(item)) return;
}
this->selected_index = item;