comparison src/widget.cpp @ 13747:1bc53910de7f draft

(svn r18272) -Codechange: make FindScrollbar a const function
author rubidium <rubidium@openttd.org>
date Tue, 24 Nov 2009 16:54:52 +0000
parents a0aa80f5d2d2
children 4f41c01242a8
comparison
equal deleted inserted replaced
13746:5fc6cdbd8404 13747:1bc53910de7f
846 { 846 {
847 return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : NULL; 847 return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : NULL;
848 } 848 }
849 849
850 /** 850 /**
851 * @fn Scrollbar *NWidgetCore::FindScrollbar(Window *w, bool allow_next = true) 851 * @fn Scrollbar *NWidgetCore::FindScrollbar(Window *w, bool allow_next = true) const
852 * Find the scrollbar of the widget through the Window::nested_array. 852 * Find the scrollbar of the widget through the Window::nested_array.
853 * @param w Window containing the widgets and the scrollbar, 853 * @param w Window containing the widgets and the scrollbar,
854 * @param allow_next Search may be extended to the next widget. 854 * @param allow_next Search may be extended to the next widget.
855 * 855 *
856 * @todo This implementation uses the constraint that a scrollbar must be the next item in the #Window::nested_array, and the scrollbar 856 * @todo This implementation uses the constraint that a scrollbar must be the next item in the #Window::nested_array, and the scrollbar
1585 if (nwid == NULL) nwid = this; 1585 if (nwid == NULL) nwid = this;
1586 } 1586 }
1587 return nwid; 1587 return nwid;
1588 } 1588 }
1589 1589
1590 Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next) 1590 Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next) const
1591 { 1591 {
1592 if (this->index > 0 && allow_next && this->child == NULL && (uint)(this->index) + 1 < w->nested_array_size) { 1592 if (this->index > 0 && allow_next && this->child == NULL && (uint)(this->index) + 1 < w->nested_array_size) {
1593 NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1); 1593 const NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1);
1594 if (next_wid != NULL) return next_wid->FindScrollbar(w, false); 1594 if (next_wid != NULL) return next_wid->FindScrollbar(w, false);
1595 } 1595 }
1596 return NULL; 1596 return NULL;
1597 } 1597 }
1598 1598
1635 GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, 1635 GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1,
1636 (this->disp_flags & ND_SHADE_DIMMED) ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOUR); 1636 (this->disp_flags & ND_SHADE_DIMMED) ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOUR);
1637 } 1637 }
1638 } 1638 }
1639 1639
1640 Scrollbar *NWidgetViewport::FindScrollbar(Window *w, bool allow_next) 1640 Scrollbar *NWidgetViewport::FindScrollbar(Window *w, bool allow_next) const
1641 { 1641 {
1642 return NULL; 1642 return NULL;
1643 } 1643 }
1644 1644
1645 /** 1645 /**
2051 if (this->IsDisabled()) { 2051 if (this->IsDisabled()) {
2052 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER); 2052 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
2053 } 2053 }
2054 } 2054 }
2055 2055
2056 Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next) 2056 Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next) const
2057 { 2057 {
2058 if (this->type == WWT_SCROLLBAR) return &w->vscroll; 2058 if (this->type == WWT_SCROLLBAR) return &w->vscroll;
2059 if (this->type == WWT_SCROLL2BAR) return &w->vscroll2; 2059 if (this->type == WWT_SCROLL2BAR) return &w->vscroll2;
2060 2060
2061 if (this->index > 0 && allow_next && (uint)(this->index) + 1 < w->nested_array_size) { 2061 if (this->index > 0 && allow_next && (uint)(this->index) + 1 < w->nested_array_size) {
2062 NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1); 2062 const NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1);
2063 if (next_wid != NULL) return next_wid->FindScrollbar(w, false); 2063 if (next_wid != NULL) return next_wid->FindScrollbar(w, false);
2064 } 2064 }
2065 return NULL; 2065 return NULL;
2066 } 2066 }
2067 2067