Author: mordante
Date: Fri May 22 12:46:28 2009
New Revision: 35815
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35815&view=rev
Log:
Also add a private header for scrollbar_container.
Added:
trunk/src/gui/widgets/scrollbar_container_private.hpp (with props)
Modified:
trunk/src/gui/widgets/scrollbar_container.cpp
trunk/src/gui/widgets/scrollbar_container.hpp
Modified: trunk/src/gui/widgets/scrollbar_container.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.cpp?rev=35815&r1=35814&r2=35815&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.cpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.cpp Fri May 22 12:46:28 2009
@@ -14,7 +14,7 @@
#define GETTEXT_DOMAIN "wesnoth-lib"
-#include "gui/widgets/scrollbar_container.hpp"
+#include "gui/widgets/scrollbar_container_private.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/log.hpp"
@@ -404,31 +404,15 @@
twidget* tscrollbar_container::find_widget(
const tpoint& coordinate, const bool must_be_active)
{
- assert(content_ && content_grid_);
-
- twidget* result = tcontainer_::find_widget(coordinate, must_be_active);
- if(result != content_) {
- return result;
- } else if(result == content_) {
- return content_grid_->find_widget(coordinate, must_be_active);
- }
- return NULL;
+ return tscrollbar_container_implementation
+ ::find_widget<twidget>(*this, coordinate,
must_be_active);
}
const twidget* tscrollbar_container::find_widget(const tpoint& coordinate,
const bool must_be_active) const
{
- assert(content_ && content_grid_);
-
- const twidget* result =
- tcontainer_::find_widget(coordinate, must_be_active);
-
- if(result != content_) {
- return result;
- } else if(result == content_) {
- return content_grid_->find_widget(coordinate, must_be_active);
- }
- return NULL;
+ return tscrollbar_container_implementation
+ ::find_widget<const twidget>(*this, coordinate,
must_be_active);
}
bool tscrollbar_container::does_block_easy_close() const
Modified: trunk/src/gui/widgets/scrollbar_container.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.hpp?rev=35815&r1=35814&r2=35815&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.hpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.hpp Fri May 22 12:46:28 2009
@@ -37,6 +37,7 @@
friend struct tbuilder_scroll_label;
friend class tlistbox;
+ friend struct tscrollbar_container_implementation;
public:
Added: trunk/src/gui/widgets/scrollbar_container_private.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container_private.hpp?rev=35815&view=auto
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container_private.hpp (added)
+++ trunk/src/gui/widgets/scrollbar_container_private.hpp Fri May 22 12:46:28
2009
@@ -1,0 +1,77 @@
+/* $Id$ */
+/*
+ Copyright (C) 2009 by Mark de Wever <[email protected]>
+ Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ or at your option any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY.
+
+ See the COPYING file for more details.
+*/
+
+#ifndef GUI_WIDGETS_SCROLLBAR_CONTAINER_PRIVATE_HPP_INCLUDED
+#define GUI_WIDGETS_SCROLLBAR_CONTAINER_PRIVATE_HPP_INCLUDED
+
+#include "gui/widgets/scrollbar_container.hpp"
+
+/**
+ * @file gui/widgets/scrollbar_containe_private.hpp
+ * Helper for header for the scrollbar_container.
+ *
+ * @note This file should only be included by scrollbar_container.cpp.
+ *
+ * This file is being used for a small experiment in which some private
+ * functions of tscrollbar_container are no longer in tscrollbar_container
+ * but moved in a friend class with static functions. The goal is to have
+ * less header recompilations, when there's a need to add or remove a private
+ * function. Also non-trivial functions like 'const foo& bar() const' and
+ * 'foo& bar()' are wrapped in a template to avoid code duplication (for
+ * typing not for the binary) to make maintenance easier.
+ */
+
+namespace gui2 {
+
+/**
+ * Helper to implement private functions without modifing the header.
+ *
+ * The class is a helper to avoid recompilation and only has static
+ * functions.
+ */
+struct tscrollbar_container_implementation
+{
+ /**
+ * Implementation for the wrappers for
+ * [const] twidget* tscrollbar_container::find_widget(
+ * const tpoint&, const bool) [const].
+ *
+ * @param W twidget or const twidget.
+ */
+ template<class W>
+ static W* find_widget(
+ typename tconst_duplicator<W,
tscrollbar_container>::type&
+ scrollbar_container,
+ const tpoint& coordinate, const bool must_be_active)
+ {
+
+ assert(scrollbar_container.content_
+ && scrollbar_container.content_grid_);
+
+ W* result = scrollbar_container.tcontainer_
+ ::find_widget(coordinate, must_be_active);
+
+ if(result == scrollbar_container.content_) {
+ return scrollbar_container.content_grid_->
+ find_widget(coordinate, must_be_active);
+ }
+
+ return result;
+ }
+};
+
+} // namespace gui2
+
+#endif
+
Propchange: trunk/src/gui/widgets/scrollbar_container_private.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/src/gui/widgets/scrollbar_container_private.hpp
------------------------------------------------------------------------------
svn:keywords = 'Author Date Id Revision'
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits