summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:22 +0300
commit8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf (patch)
tree2c95704e2de3418227faf7a52357a6fe03d5b735 /src/gui/widgets
parente73f7da4d65e7dc61a952894cc6f0843c4da3170 (diff)
downloadmanaplus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.gz
manaplus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.bz2
manaplus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.xz
manaplus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.zip
Improve iterators part 1.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/browserbox.cpp16
-rw-r--r--src/gui/widgets/browserbox.h2
-rw-r--r--src/gui/widgets/container.cpp4
-rw-r--r--src/gui/widgets/itemcontainer.cpp4
-rw-r--r--src/gui/widgets/setuptabscroll.cpp12
-rw-r--r--src/gui/widgets/tabbedarea.cpp8
-rw-r--r--src/gui/widgets/tabstrip.cpp4
-rw-r--r--src/gui/widgets/widgetgroup.cpp3
-rw-r--r--src/gui/widgets/window.cpp5
-rw-r--r--src/gui/widgets/windowcontainer.cpp3
10 files changed, 31 insertions, 30 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 8cbeec78c..30a5e72b6 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -219,7 +219,8 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
int hyphenWidth = font->getWidth(hyphen);
unsigned x = 0;
- for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i)
+ for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end();
+ i != i_end; ++ i)
{
std::string tempRow = *i;
for (unsigned int j = 0; j < tempRow.size(); j++)
@@ -374,9 +375,8 @@ void BrowserBox::draw(gcn::Graphics *graphics)
gcn::Font *font = getFont();
- for (LinePartIterator i = mLineParts.begin();
- i != mLineParts.end();
- ++i)
+ for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end();
+ i != i_end; ++i)
{
const LinePart &part = *i;
if (part.mY + 50 < mYStart)
@@ -425,7 +425,8 @@ int BrowserBox::calcHeight()
mLineParts.clear();
- for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i)
+ for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end();
+ i != i_end; ++ i)
{
const std::string row = *(i);
bool wrapped = false;
@@ -670,9 +671,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y)
int lastY = 0;
- for (LinePartIterator i = mLineParts.begin();
- i != mLineParts.end();
- ++i)
+ for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end();
+ i != i_end; ++i)
{
const LinePart &part = *i;
if (part.mY + 50 < mYStart)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 55bea8dad..edea47ddf 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -206,11 +206,13 @@ class BrowserBox : public gcn::Widget,
int calcHeight();
typedef TextRows::iterator TextRowIterator;
+ typedef TextRows::const_iterator TextRowCIter;
TextRows mTextRows;
std::list<int> mTextRowLinksCount;
typedef std::vector<LinePart> LinePartList;
typedef LinePartList::iterator LinePartIterator;
+ typedef LinePartList::const_iterator LinePartCIter;
LinePartList mLineParts;
typedef std::vector<BROWSER_LINK> Links;
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index 106112956..e085d609f 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -37,8 +37,8 @@ Container::~Container()
bool Container::safeRemove(gcn::Widget* widget)
{
- WidgetListConstIterator iter;
- for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
+ for (WidgetListConstIterator iter = mWidgets.begin();
+ iter != mWidgets.end(); ++iter)
{
if (*iter == widget)
{
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 0aabcd297..e52cc0e0c 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -529,8 +529,8 @@ void ItemContainer::updateMatrix()
break;
}
- std::vector<ItemIdPair*>::const_iterator iter;
- for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter)
+ for (std::vector<ItemIdPair*>::const_iterator iter = sortedItems.begin(),
+ iter_end = sortedItems.end(); iter != sortedItems.end(); ++ iter)
{
if (j >= mGridRows)
break;
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index f3f8b1526..13c2668f5 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -87,8 +87,8 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event)
void SetupTabScroll::apply()
{
- std::map<std::string, SetupItem*>::const_iterator iter;
- for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ for (std::map<std::string, SetupItem*>::const_iterator
+ iter = mItems.begin(); iter != mItems.end(); ++ iter)
{
if ((*iter).second)
(*iter).second->apply((*iter).first);
@@ -97,8 +97,8 @@ void SetupTabScroll::apply()
void SetupTabScroll::cancel()
{
- std::map<std::string, SetupItem*>::const_iterator iter;
- for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ for (std::map<std::string, SetupItem*>::const_iterator
+ iter = mItems.begin(); iter != mItems.end(); ++ iter)
{
if ((*iter).second)
(*iter).second->cancel((*iter).first);
@@ -107,8 +107,8 @@ void SetupTabScroll::cancel()
void SetupTabScroll::externalUpdated()
{
- std::map<std::string, SetupItem*>::const_iterator iter;
- for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ for (std::map<std::string, SetupItem*>::const_iterator
+ iter = mItems.begin(); iter != mItems.end(); ++ iter)
{
SetupItem *widget = (*iter).second;
if (widget && !widget->isMainConfig())
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 5896af304..96e81b534 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -167,8 +167,8 @@ void TabbedArea::removeTab(gcn::Tab *tab)
tabIndexToBeSelected = index - 1;
}
- TabContainer::iterator iter;
- for (iter = mTabs.begin(); iter != mTabs.end(); ++iter)
+ for (TabContainer::iterator iter = mTabs.begin();
+ iter != mTabs.end(); ++iter)
{
if (iter->first == tab)
{
@@ -178,8 +178,8 @@ void TabbedArea::removeTab(gcn::Tab *tab)
}
}
- std::vector<gcn::Tab*>::iterator iter2;
- for (iter2 = mTabsToDelete.begin(); iter2 != mTabsToDelete.end(); ++iter2)
+ for (std::vector<gcn::Tab*>::iterator iter2 = mTabsToDelete.begin();
+ iter2 != mTabsToDelete.end(); ++iter2)
{
if (*iter2 == tab)
{
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 6b3f42fe9..758b69846 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -56,8 +56,8 @@ void TabStrip::action(const gcn::ActionEvent &event)
gcn::Widget *widget = event.getSource();
if (static_cast<Button*>(widget)->isPressed2())
{
- WidgetListConstIterator iter;
- for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter)
+ for (WidgetListConstIterator iter = mWidgets.begin();
+ iter != mWidgets.end(); ++ iter)
{
if (*iter != widget)
{
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index b2b513850..076cf059c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -55,8 +55,7 @@ void WidgetGroup::addButton(std::string text, std::string tag)
void WidgetGroup::action(const gcn::ActionEvent &event)
{
- ActionListenerIterator iter;
- for (iter = mActionListeners.begin();
+ for (ActionListenerIterator iter = mActionListeners.begin();
iter != mActionListeners.end(); ++iter)
{
(*iter)->action(event);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 6e6918694..d956e9adf 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -382,12 +382,11 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED)
if (gui)
gui->setCursorType(Gui::CURSOR_POINTER);
- WidgetListConstIterator it;
-
if (!mFocusHandler)
return;
- for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
+ for (WidgetListConstIterator it = mWidgets.begin();
+ it != mWidgets.end(); ++ it)
{
if (mFocusHandler->isFocused(*it))
mFocusHandler->focusNone();
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 9e698ffa6..2e40d88d2 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -47,7 +47,8 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget)
void WindowContainer::adjustAfterResize(int oldScreenWidth,
int oldScreenHeight)
{
- for (WidgetListIterator i = mWidgets.begin(); i != mWidgets.end(); ++i)
+ for (WidgetListIterator i = mWidgets.begin(), i_end = mWidgets.end();
+ i != i_end; ++i)
{
if (Window *window = dynamic_cast<Window*>(*i))
window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight);