Changeset - r13737:bf08d93c0845
[Not reviewed]
master
0 2 0
rubidium - 15 years ago 2009-11-24 16:54:52
rubidium@openttd.org
(svn r18272) -Codechange: make FindScrollbar a const function
2 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/widget.cpp
Show inline comments
 
@@ -848,7 +848,7 @@ NWidgetCore *NWidgetCore::GetWidgetFromP
 
}
 

	
 
/**
 
 * @fn Scrollbar *NWidgetCore::FindScrollbar(Window *w, bool allow_next = true)
 
 * @fn Scrollbar *NWidgetCore::FindScrollbar(Window *w, bool allow_next = true) const
 
 * Find the scrollbar of the widget through the Window::nested_array.
 
 * @param w          Window containing the widgets and the scrollbar,
 
 * @param allow_next Search may be extended to the next widget.
 
@@ -1587,10 +1587,10 @@ NWidgetCore *NWidgetBackground::GetWidge
 
	return nwid;
 
}
 

	
 
Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next)
 
Scrollbar *NWidgetBackground::FindScrollbar(Window *w, bool allow_next) const
 
{
 
	if (this->index > 0 && allow_next && this->child == NULL && (uint)(this->index) + 1 < w->nested_array_size) {
 
		NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1);
 
		const NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1);
 
		if (next_wid != NULL) return next_wid->FindScrollbar(w, false);
 
	}
 
	return NULL;
 
@@ -1637,7 +1637,7 @@ void NWidgetViewport::Draw(const Window 
 
	}
 
}
 

	
 
Scrollbar *NWidgetViewport::FindScrollbar(Window *w, bool allow_next)
 
Scrollbar *NWidgetViewport::FindScrollbar(Window *w, bool allow_next) const
 
{
 
	return NULL;
 
}
 
@@ -2053,13 +2053,13 @@ void NWidgetLeaf::Draw(const Window *w)
 
	}
 
}
 

	
 
Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next)
 
Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next) const
 
{
 
	if (this->type == WWT_SCROLLBAR) return &w->vscroll;
 
	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->GetWidget<NWidgetCore>(this->index + 1);
 
		const NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1);
 
		if (next_wid != NULL) return next_wid->FindScrollbar(w, false);
 
	}
 
	return NULL;
src/widget_type.h
Show inline comments
 
@@ -251,7 +251,7 @@ public:
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 

	
 
	virtual Scrollbar *FindScrollbar(Window *w, bool allow_next = true) = 0;
 
	virtual Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const = 0;
 

	
 
	NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget.
 
	Colours colour;            ///< Colour of this widget.
 
@@ -428,7 +428,7 @@ public:
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	/* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const;
 

	
 
private:
 
	NWidgetPIPContainer *child; ///< Child widget.
 
@@ -448,7 +448,7 @@ public:
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const;
 

	
 
	void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
 
	void UpdateViewportCoordinates(Window *w);
 
@@ -462,7 +462,7 @@ public:
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true);
 
	/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const;
 

	
 
	bool ButtonHit(const Point &pt);
 

	
0 comments (0 inline, 0 general)