summaryrefslogtreecommitdiff
path: root/src/signs_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/signs_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/signs_gui.cpp')
-rw-r--r--src/signs_gui.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 4e28bd15f..e8bd685a7 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -90,17 +90,20 @@ enum SignListWidgets {
struct SignListWindow : Window, SignList {
int text_offset; // Offset of the sign text relative to the left edge of the SLW_LIST widget.
+ Scrollbar *vscroll;
SignListWindow(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);
/* Create initial list. */
this->signs.ForceRebuild();
this->signs.ForceResort();
this->BuildSignsList();
this->SortSignsList();
- this->vscroll.SetCount(this->signs.Length());
+ this->vscroll->SetCount(this->signs.Length());
}
virtual void OnPaint()
@@ -114,7 +117,7 @@ struct SignListWindow : Window, SignList {
case SLW_LIST: {
uint y = r.top + WD_FRAMERECT_TOP; // Offset from top of widget.
/* No signs? */
- if (this->vscroll.GetCount() == 0) {
+ if (this->vscroll->GetCount() == 0) {
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right, y, STR_STATION_LIST_NONE);
return;
}
@@ -126,7 +129,7 @@ struct SignListWindow : Window, SignList {
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
/* At least one sign available. */
- for (uint16 i = this->vscroll.GetPosition(); this->vscroll.IsVisible(i) && i < this->vscroll.GetCount(); i++) {
+ for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
const Sign *si = this->signs[i];
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
@@ -142,13 +145,13 @@ struct SignListWindow : Window, SignList {
virtual void SetStringParameters(int widget) const
{
- if (widget == SLW_CAPTION) SetDParam(0, this->vscroll.GetCount());
+ if (widget == SLW_CAPTION) SetDParam(0, this->vscroll->GetCount());
}
virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == SLW_LIST) {
- uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, SLW_LIST, WD_FRAMERECT_TOP);
+ uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, SLW_LIST, WD_FRAMERECT_TOP);
if (id_v == INT_MAX) return;
const Sign *si = this->signs[id_v];
@@ -158,7 +161,7 @@ struct SignListWindow : Window, SignList {
virtual void OnResize()
{
- this->vscroll.SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
+ this->vscroll->SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
@@ -188,7 +191,7 @@ struct SignListWindow : Window, SignList {
this->signs.ForceRebuild();
this->BuildSignsList();
this->SetWidgetDirty(SLW_CAPTION);
- this->vscroll.SetCount(this->signs.Length());
+ this->vscroll->SetCount(this->signs.Length());
} else { // Change of sign contents.
this->signs.ForceResort();
}