diff options
Diffstat (limited to 'src/window_gui.h')
-rw-r--r-- | src/window_gui.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/window_gui.h b/src/window_gui.h index 2d182ba8b..a78004f89 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -389,7 +389,9 @@ public: Window *z_back; ///< The window behind us in z-order. template <class NWID> - inline NWID *GetWidget(uint widnum) const; + inline const NWID *GetWidget(uint widnum) const; + template <class NWID> + inline NWID *GetWidget(uint widnum); void InitNested(const WindowDesc *desc, WindowNumber number = 0); @@ -847,7 +849,7 @@ public: * @return The requested widget if it is instantiated, \c NULL otherwise. */ template <class NWID> -inline NWID *Window::GetWidget(uint widnum) const +inline NWID *Window::GetWidget(uint widnum) { if (widnum >= this->nested_array_size || this->nested_array[widnum] == NULL) return NULL; NWID *nwid = dynamic_cast<NWID *>(this->nested_array[widnum]); @@ -857,12 +859,23 @@ inline NWID *Window::GetWidget(uint widnum) const /** Specialized case of #Window::GetWidget for the nested widget base class. */ template <> -inline NWidgetBase *Window::GetWidget<NWidgetBase>(uint widnum) const +inline const NWidgetBase *Window::GetWidget<NWidgetBase>(uint widnum) const { if (widnum >= this->nested_array_size) return NULL; return this->nested_array[widnum]; } +/** Get the nested widget with number \a widnum from the nested widget tree. + * @tparam NWID Type of the nested widget. + * @param widnum Widget number of the widget to retrieve. + * @return The requested widget if it is instantiated, \c NULL otherwise. + */ +template <class NWID> +inline const NWID *Window::GetWidget(uint widnum) const +{ + return const_cast<Window *>(this)->GetWidget<NWID>(widnum); +} + /** * Base class for windows opened from a toolbar. |