summaryrefslogtreecommitdiff
path: root/src/subsidy_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-08-12 08:37:01 +0000
committerfrosch <frosch@openttd.org>2010-08-12 08:37:01 +0000
commit71ca58c2bb1b72a088acec5b70423a43512ec195 (patch)
treeb0e875a8626ce26d7fed7597328409f2cb937dbe /src/subsidy_gui.cpp
parent10339c60c0e53ccc90f0cc379763be6582d87bf2 (diff)
downloadopenttd-71ca58c2bb1b72a088acec5b70423a43512ec195.tar.xz
(svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
Note: All windows get individual members with the same names, which are initialised via Window::GetScrollbar(). This caching is not required at all, but simplifies conversion.
Diffstat (limited to 'src/subsidy_gui.cpp')
-rw-r--r--src/subsidy_gui.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 930b11714..a7f05157c 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -31,9 +31,13 @@ enum SubsidyListWidgets {
};
struct SubsidyListWindow : Window {
+ Scrollbar *vscroll;
+
SubsidyListWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
- this->InitNested(desc, window_number);
+ this->CreateNestedTree(desc);
+ this->vscroll = this->GetScrollbar(SLW_SCROLLBAR);
+ this->FinishInitNested(desc, window_number);
this->OnInvalidateData(0);
}
@@ -41,7 +45,7 @@ struct SubsidyListWindow : Window {
{
if (widget != SLW_PANEL) return;
- int y = this->vscroll.GetScrolledRowFromWidget(pt.y, this, SLW_PANEL, WD_FRAMERECT_TOP);
+ int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, SLW_PANEL, WD_FRAMERECT_TOP);
int num = 0;
const Subsidy *s;
FOR_ALL_SUBSIDIES(s) {
@@ -157,8 +161,8 @@ struct SubsidyListWindow : Window {
int y = r.top + WD_FRAMERECT_TOP;
int x = r.left + WD_FRAMERECT_LEFT;
- int pos = -this->vscroll.GetPosition();
- const int cap = this->vscroll.GetCapacity();
+ int pos = -this->vscroll->GetPosition();
+ const int cap = this->vscroll->GetCapacity();
/* Section for drawing the offered subisidies */
if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_TITLE);
@@ -213,12 +217,12 @@ struct SubsidyListWindow : Window {
virtual void OnResize()
{
- this->vscroll.SetCapacityFromWidget(this, SLW_PANEL);
+ this->vscroll->SetCapacityFromWidget(this, SLW_PANEL);
}
virtual void OnInvalidateData(int data)
{
- this->vscroll.SetCount(this->CountLines());
+ this->vscroll->SetCount(this->CountLines());
}
};