diff options
author | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
commit | 4203e641f8a507c017d10bf40f2c3882ce596da5 (patch) | |
tree | 883a2b182b8594de0b2048900956281c4efff861 /src/industry_gui.cpp | |
parent | 97f85f7bfba286bf9a7c692b390eec8231cac9ae (diff) | |
download | openttd-4203e641f8a507c017d10bf40f2c3882ce596da5.tar.xz |
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
Diffstat (limited to 'src/industry_gui.cpp')
-rw-r--r-- | src/industry_gui.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 50e6b8be4..13cb0b92f 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -459,9 +459,8 @@ public: switch (widget) { case DPIW_MATRIX_WIDGET: { const IndustrySpec *indsp; - int y = (pt.y - this->GetWidget<NWidgetBase>(DPIW_MATRIX_WIDGET)->pos_y) / this->resize.step_height + this->vscroll.GetPosition(); - - if (y >= 0 && y < count) { // Is it within the boundaries of available data? + int y = this->vscroll.GetScrolledRowFromWidget(pt.y, this, DPIW_MATRIX_WIDGET); + if (y < this->count) { // Is it within the boundaries of available data? this->selected_index = y; this->selected_type = this->index[y]; indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type); @@ -1194,11 +1193,7 @@ public: break; case IDW_INDUSTRY_LIST: { - int y = (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height; - uint16 p; - - if (!IsInsideMM(y, 0, this->vscroll.GetCapacity())) return; - p = y + this->vscroll.GetPosition(); + uint p = this->vscroll.GetScrolledRowFromWidget(pt.y, this, IDW_INDUSTRY_LIST, WD_FRAMERECT_TOP); if (p < this->industries.Length()) { if (_ctrl_pressed) { ShowExtraViewPortWindow(this->industries[p]->location.tile); |