From 0beda162d466f8a925093c68b23302d8a79af977 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Wed, 15 Sep 2010 12:43:30 +0200 Subject: code deduplication by using and FbTk/STLUtil.hh --- src/Toolbar.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 4ed765a..8951923 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -52,6 +52,7 @@ #include "FbTk/Shape.hh" #include "FbTk/SimpleObserver.hh" #include "FbTk/MemFun.hh" +#include "FbTk/STLUtil.hh" // use GNU extensions #ifndef _GNU_SOURCE @@ -72,11 +73,14 @@ #endif #include #include +#include using std::string; using std::pair; using std::list; +using FbTk::STLUtil::forAll; + namespace FbTk { template<> @@ -518,18 +522,11 @@ void Toolbar::reconfigure() { if (theme()->shape() && m_shape.get()) m_shape->update(); - ItemList::iterator item_it = m_item_list.begin(); - ItemList::iterator item_it_end = m_item_list.end(); - for (; item_it != item_it_end; ++item_it) { - (*item_it)->updateSizing(); - } + forAll(m_item_list, std::mem_fun(&ToolbarItem::updateSizing)); rearrangeItems(); - for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { - (*item_it)->renderTheme(alpha()); - } - + forAll(m_item_list, std::bind2nd(std::mem_fun(&ToolbarItem::renderTheme), alpha())); // we're done with all resizing and stuff now we can request a new // area to be reserved on screen @@ -794,10 +791,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { break; } - ItemList::iterator item_it = m_item_list.begin(); - ItemList::iterator item_it_end = m_item_list.end(); - for (; item_it != item_it_end; ++item_it) - (*item_it)->setOrientation(orient); + forAll(m_item_list, std::bind2nd(std::mem_fun(&ToolbarItem::setOrientation), orient)); } void Toolbar::updateVisibleState() { @@ -812,10 +806,7 @@ void Toolbar::toggleHidden() { frame.window.move(frame.x_hidden, frame.y_hidden); else { frame.window.move(frame.x, frame.y); - ItemList::iterator item_it = m_item_list.begin(); - ItemList::iterator item_it_end = m_item_list.end(); - for ( ; item_it != item_it_end; ++item_it) - (*item_it)->parentMoved(); + forAll(m_item_list, std::mem_fun(&ToolbarItem::parentMoved)); } } -- cgit v0.11.2