summaryrefslogtreecommitdiff
path: root/src/network/network_content_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/network/network_content_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/network/network_content_gui.cpp')
-rw-r--r--src/network/network_content_gui.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 138cea9bd..adeddff15 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -239,6 +239,7 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
const ContentInfo *selected; ///< The selected content info
int list_pos; ///< Our position in the list
uint filesize_sum; ///< The sum of all selected file sizes
+ Scrollbar *vscroll;
/**
* (Re)build the network game list as its amount has changed because
@@ -260,7 +261,7 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
this->content.RebuildDone();
this->SortContentList();
- this->vscroll.SetCount(this->content.Length()); // Update the scrollbar
+ this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
this->ScrollToSelected();
}
@@ -338,7 +339,7 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
{
if (this->selected == NULL) return;
- this->vscroll.ScrollTowards(this->list_pos);
+ this->vscroll->ScrollTowards(this->list_pos);
}
public:
@@ -351,7 +352,9 @@ public:
selected(NULL),
list_pos(0)
{
- this->InitNested(desc, 1);
+ this->CreateNestedTree(desc);
+ this->vscroll = this->GetScrollbar(NCLWW_SCROLLBAR);
+ this->FinishInitNested(desc, 1);
this->GetWidget<NWidgetStacked>(NCLWW_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
@@ -448,7 +451,7 @@ public:
int sprite_y_offset = WD_MATRIX_TOP + (FONT_HEIGHT_NORMAL - 10) / 2;
uint y = r.top;
int cnt = 0;
- for (ConstContentIterator iter = this->content.Get(this->vscroll.GetPosition()); iter != this->content.End() && cnt < this->vscroll.GetCapacity(); iter++, cnt++) {
+ for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) {
const ContentInfo *ci = *iter;
if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, 10);
@@ -590,7 +593,7 @@ public:
{
switch (widget) {
case NCLWW_MATRIX: {
- uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, NCLWW_MATRIX);
+ uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, NCLWW_MATRIX);
if (id_v >= this->content.Length()) return; // click out of bounds
this->selected = *this->content.Get(id_v);
@@ -664,11 +667,11 @@ public:
break;
case WKC_PAGEUP:
/* scroll up a page */
- this->list_pos = (this->list_pos < this->vscroll.GetCapacity()) ? 0 : this->list_pos - this->vscroll.GetCapacity();
+ this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
break;
case WKC_PAGEDOWN:
/* scroll down a page */
- this->list_pos = min(this->list_pos + this->vscroll.GetCapacity(), (int)this->content.Length() - 1);
+ this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.Length() - 1);
break;
case WKC_HOME:
/* jump to beginning */
@@ -723,8 +726,8 @@ public:
virtual void OnResize()
{
- this->vscroll.SetCapacityFromWidget(this, NCLWW_MATRIX);
- this->GetWidget<NWidgetCore>(NCLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
+ this->vscroll->SetCapacityFromWidget(this, NCLWW_MATRIX);
+ this->GetWidget<NWidgetCore>(NCLWW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
virtual void OnReceiveContentInfo(const ContentInfo *rci)