summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-07-26 13:08:48 +0000
committeralberth <alberth@openttd.org>2010-07-26 13:08:48 +0000
commit4203e641f8a507c017d10bf40f2c3882ce596da5 (patch)
tree883a2b182b8594de0b2048900956281c4efff861 /src/station_gui.cpp
parent97f85f7bfba286bf9a7c692b390eec8231cac9ae (diff)
downloadopenttd-4203e641f8a507c017d10bf40f2c3882ce596da5.tar.xz
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 4fe500f64..30034cc16 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -535,12 +535,7 @@ public:
{
switch (widget) {
case SLW_LIST: {
- uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(SLW_LIST)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
-
- if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds
-
- id_v += this->vscroll.GetPosition();
-
+ uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, SLW_LIST, 0, FONT_HEIGHT_NORMAL);
if (id_v >= this->stations.Length()) return; // click out of list bound
const Station *st = this->stations[id_v];
@@ -1152,7 +1147,7 @@ struct StationViewWindow : public Window {
{
switch (widget) {
case SVW_WAITING:
- this->HandleCargoWaitingClick((pt.y - this->GetWidget<NWidgetBase>(SVW_WAITING)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL + this->vscroll.GetPosition());
+ this->HandleCargoWaitingClick(this->vscroll.GetScrolledRowFromWidget(pt.y, this, SVW_WAITING, WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL));
break;
case SVW_LOCATION:
@@ -1416,7 +1411,7 @@ struct SelectStationWindow : Window {
{
if (widget != JSW_PANEL) return;
- uint32 st_index = (pt.y - this->GetWidget<NWidgetBase>(JSW_PANEL)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height + this->vscroll.GetPosition();
+ uint st_index = this->vscroll.GetScrolledRowFromWidget(pt.y, this, JSW_PANEL, WD_FRAMERECT_TOP);
bool distant_join = (st_index > 0);
if (distant_join) st_index--;