diff options
author | frosch <frosch@openttd.org> | 2010-08-12 08:37:01 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-08-12 08:37:01 +0000 |
commit | 71ca58c2bb1b72a088acec5b70423a43512ec195 (patch) | |
tree | b0e875a8626ce26d7fed7597328409f2cb937dbe /src/widgets | |
parent | 10339c60c0e53ccc90f0cc379763be6582d87bf2 (diff) | |
download | openttd-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/widgets')
-rw-r--r-- | src/widgets/dropdown.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 1297ae4ca..5239928c2 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -99,6 +99,7 @@ struct DropdownWindow : Window { bool instant_close; ///< Close the window when the mouse button is raised. int scrolling; ///< If non-zero, auto-scroll the item list (one time). Point position; ///< Position of the topleft corner of the window. + Scrollbar *vscroll; /** * Create a dropdown menu. @@ -119,6 +120,8 @@ struct DropdownWindow : Window { this->CreateNestedTree(&_dropdown_desc); + this->vscroll = this->GetScrollbar(DDM_SCROLL); + uint items_width = size.width - (scroll ? WD_VSCROLLBAR_WIDTH : 0); NWidgetCore *nwi = this->GetWidget<NWidgetCore>(DDM_ITEMS); nwi->SetMinimalSize(items_width, size.height + 4); @@ -142,8 +145,8 @@ struct DropdownWindow : Window { } /* Capacity is the average number of items visible */ - this->vscroll.SetCapacity(size.height * (uint16)list->size() / list_height); - this->vscroll.SetCount((uint16)list->size()); + this->vscroll->SetCapacity(size.height * (uint16)list->size() / list_height); + this->vscroll->SetCount((uint16)list->size()); this->parent_wnd_class = parent->window_class; this->parent_wnd_num = parent->window_number; @@ -192,7 +195,7 @@ struct DropdownWindow : Window { NWidgetBase *nwi = this->GetWidget<NWidgetBase>(DDM_ITEMS); int y = _cursor.pos.y - this->top - nwi->pos_y - 2; int width = nwi->current_x - 4; - int pos = this->vscroll.GetPosition(); + int pos = this->vscroll->GetPosition(); const DropDownList *list = this->list; @@ -227,7 +230,7 @@ struct DropdownWindow : Window { TextColour colour = (TextColour)this->GetWidget<NWidgetCore>(widget)->colour; int y = r.top + 2; - int pos = this->vscroll.GetPosition(); + int pos = this->vscroll->GetPosition(); for (DropDownList::const_iterator it = this->list->begin(); it != this->list->end(); ++it) { const DropDownListItem *item = *it; int item_height = item->Height(r.right - r.left + 1); @@ -263,12 +266,12 @@ struct DropdownWindow : Window { virtual void OnTick() { if (this->scrolling != 0) { - int pos = this->vscroll.GetPosition(); + int pos = this->vscroll->GetPosition(); - this->vscroll.UpdatePosition(this->scrolling); + this->vscroll->UpdatePosition(this->scrolling); this->scrolling = 0; - if (pos != this->vscroll.GetPosition()) { + if (pos != this->vscroll->GetPosition()) { this->SetDirty(); } } |