From 45a9bbd34cda3c784b935860a4cc616a0314a57c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 2 Sep 2011 20:06:58 +0300 Subject: Replace guichan iterators to const_iterator if need. --- src/gui/widgets/container.cpp | 2 +- src/gui/widgets/container.h | 4 ++++ src/gui/widgets/window.cpp | 2 +- src/guichan/basiccontainer.cpp | 22 +++++++++++----------- src/guichan/include/guichan/basiccontainer.hpp | 10 ++++++++++ src/guichan/widgets/window.cpp | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 96cea7119..558257507 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -37,7 +37,7 @@ Container::~Container() bool Container::safeRemove(gcn::Widget* widget) { - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) { if (*iter == widget) diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 1d8872477..c011b8925 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -26,6 +26,10 @@ #include #include +#if !defined USE_INTERNALGUICHAN +typedef std::list::const_iterator WidgetListConstIterator; +#endif + /** * A widget container. * diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 0a3779307..4435496a7 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -368,7 +368,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (gui) gui->setCursorType(Gui::CURSOR_POINTER); - WidgetListIterator it; + WidgetListConstIterator it; if (!mFocusHandler) return; diff --git a/src/guichan/basiccontainer.cpp b/src/guichan/basiccontainer.cpp index d51968eb6..439535c9a 100644 --- a/src/guichan/basiccontainer.cpp +++ b/src/guichan/basiccontainer.cpp @@ -110,7 +110,7 @@ namespace gcn void BasicContainer::focusNext() { - WidgetListIterator it; + WidgetListConstIterator it; for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { @@ -118,7 +118,7 @@ namespace gcn break; } - WidgetListIterator end = it; + WidgetListConstIterator end = it; if (it == mWidgets.end()) it = mWidgets.begin(); @@ -140,7 +140,7 @@ namespace gcn void BasicContainer::focusPrevious() { - WidgetListReverseIterator it; + WidgetListCReverseIterator it; for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it) { @@ -148,7 +148,7 @@ namespace gcn break; } - WidgetListReverseIterator end = it; + WidgetListCReverseIterator end = it; ++ it; @@ -178,7 +178,7 @@ namespace gcn x -= r.x; y -= r.y; - WidgetListReverseIterator it; + WidgetListCReverseIterator it; for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it) { if ((*it)->isVisible() && (*it)->getDimension() @@ -203,7 +203,7 @@ namespace gcn if (mInternalFocusHandler != NULL) return; - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { (*iter)->_setFocusHandler(focusHandler); @@ -243,7 +243,7 @@ namespace gcn void BasicContainer::clear() { - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { @@ -259,7 +259,7 @@ namespace gcn { graphics->pushClipArea(getChildrenArea()); - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { if ((*iter)->isVisible()) @@ -289,7 +289,7 @@ namespace gcn void BasicContainer::logicChildren() { - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) (*iter)->logic(); } @@ -324,7 +324,7 @@ namespace gcn { Widget::setInternalFocusHandler(focusHandler); - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { if (mInternalFocusHandler == NULL) @@ -336,7 +336,7 @@ namespace gcn Widget* BasicContainer::findWidgetById(const std::string& id) { - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) { if ((*iter)->getId() == id) diff --git a/src/guichan/include/guichan/basiccontainer.hpp b/src/guichan/include/guichan/basiccontainer.hpp index 998e1f601..6163b6535 100644 --- a/src/guichan/include/guichan/basiccontainer.hpp +++ b/src/guichan/include/guichan/basiccontainer.hpp @@ -167,11 +167,21 @@ namespace gcn */ typedef WidgetList::iterator WidgetListIterator; + /** + * Typedef. + */ + typedef WidgetList::const_iterator WidgetListConstIterator; + /** * Typedef. */ typedef WidgetList::reverse_iterator WidgetListReverseIterator; + /** + * Typedef. + */ + typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator; + /** * Holds all widgets of the basic container. */ diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index 4779fb0ce..7b04981c2 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -279,7 +279,7 @@ namespace gcn void Window::resizeToContent() { - WidgetListIterator it; + WidgetListConstIterator it; int w = 0, h = 0; for (it = mWidgets.begin(); it != mWidgets.end(); it++) -- cgit v1.2.3-70-g09d2