From 116c77c342d0f628235a7f5dbacfbb5bc3fb0829 Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 19 Sep 2009 11:31:12 +0000 Subject: (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array. --- src/widget.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/widget.cpp') diff --git a/src/widget.cpp b/src/widget.cpp index 6719a2506..7b29791a5 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -834,8 +834,9 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const top = this->widget[widget].top; } else { assert(this->nested_array != NULL); - base = offset + this->nested_array[widget]->pos_x + (_dynlang.text_dir == TD_LTR ? this->nested_array[widget]->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0); - top = this->nested_array[widget]->pos_y; + NWidgetBase *nwid = this->GetWidget(widget); + base = offset + nwid->pos_x + (_dynlang.text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0); + top = nwid->pos_y; } DrawString(base, base + WD_SORTBUTTON_ARROW_WIDTH, top + 1 + offset, state == SBS_DOWN ? DOWNARROW : UPARROW, TC_BLACK, SA_CENTER); } @@ -937,7 +938,7 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ /** - * @fn void FillNestedArray(NWidgetCore **array, uint length) + * @fn void FillNestedArray(NWidgetBase **array, uint length) * Fill the Window::nested_array array with pointers to nested widgets in the tree. * @param array Base pointer of the array. * @param length Length of the array. @@ -1104,7 +1105,7 @@ void NWidgetCore::SetDataTip(uint16 widget_data, StringID tool_tip) this->tool_tip = tool_tip; } -void NWidgetCore::FillNestedArray(NWidgetCore **array, uint length) +void NWidgetCore::FillNestedArray(NWidgetBase **array, uint length) { if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; } @@ -1211,7 +1212,7 @@ void NWidgetContainer::Add(NWidgetBase *wid) } } -void NWidgetContainer::FillNestedArray(NWidgetCore **array, uint length) +void NWidgetContainer::FillNestedArray(NWidgetBase **array, uint length) { for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) { child_wid->FillNestedArray(array, length); @@ -1640,7 +1641,7 @@ void NWidgetSpacer::SetupSmallestSize(Window *w, bool init_array) this->smallest_y = this->min_y; } -void NWidgetSpacer::FillNestedArray(NWidgetCore **array, uint length) +void NWidgetSpacer::FillNestedArray(NWidgetBase **array, uint length) { } @@ -1772,7 +1773,7 @@ void NWidgetBackground::StoreWidgets(Widget *widgets, int length, bool left_movi if (this->child != NULL) this->child->StoreWidgets(widgets, length, left_moving, top_moving, rtl); } -void NWidgetBackground::FillNestedArray(NWidgetCore **array, uint length) +void NWidgetBackground::FillNestedArray(NWidgetBase **array, uint length) { if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; if (this->child != NULL) this->child->FillNestedArray(array, length); @@ -1832,7 +1833,7 @@ NWidgetCore *NWidgetBackground::GetWidgetFromPos(int x, int y) Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next) { if (this->index > 0 && allow_next && this->child == NULL && (uint)(this->index) + 1 < w->nested_array_size) { - NWidgetCore *next_wid = w->nested_array[this->index + 1]; + NWidgetCore *next_wid = w->GetWidget(this->index + 1); if (next_wid != NULL) return next_wid->FindScrollbar(w, false); } return NULL; @@ -2278,7 +2279,7 @@ Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next) if (this->type == WWT_SCROLL2BAR) return &w->vscroll2; if (this->index > 0 && allow_next && (uint)(this->index) + 1 < w->nested_array_size) { - NWidgetCore *next_wid = w->nested_array[this->index + 1]; + NWidgetCore *next_wid = w->GetWidget(this->index + 1); if (next_wid != NULL) return next_wid->FindScrollbar(w, false); } return NULL; -- cgit v1.2.3-70-g09d2