code deduplication by using <algorithm> and FbTk/STLUtil.hh

This commit is contained in:
Mathias Gumz 2010-09-15 12:43:30 +02:00
parent 12e1ef7826
commit 0beda162d4

View file

@ -52,6 +52,7 @@
#include "FbTk/Shape.hh" #include "FbTk/Shape.hh"
#include "FbTk/SimpleObserver.hh" #include "FbTk/SimpleObserver.hh"
#include "FbTk/MemFun.hh" #include "FbTk/MemFun.hh"
#include "FbTk/STLUtil.hh"
// use GNU extensions // use GNU extensions
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -72,11 +73,14 @@
#endif #endif
#include <iterator> #include <iterator>
#include <typeinfo> #include <typeinfo>
#include <functional>
using std::string; using std::string;
using std::pair; using std::pair;
using std::list; using std::list;
using FbTk::STLUtil::forAll;
namespace FbTk { namespace FbTk {
template<> template<>
@ -518,18 +522,11 @@ void Toolbar::reconfigure() {
if (theme()->shape() && m_shape.get()) if (theme()->shape() && m_shape.get())
m_shape->update(); m_shape->update();
ItemList::iterator item_it = m_item_list.begin(); forAll(m_item_list, std::mem_fun(&ToolbarItem::updateSizing));
ItemList::iterator item_it_end = m_item_list.end();
for (; item_it != item_it_end; ++item_it) {
(*item_it)->updateSizing();
}
rearrangeItems(); rearrangeItems();
for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { forAll(m_item_list, std::bind2nd(std::mem_fun(&ToolbarItem::renderTheme), alpha()));
(*item_it)->renderTheme(alpha());
}
// we're done with all resizing and stuff now we can request a new // we're done with all resizing and stuff now we can request a new
// area to be reserved on screen // area to be reserved on screen
@ -794,10 +791,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) {
break; break;
} }
ItemList::iterator item_it = m_item_list.begin(); forAll(m_item_list, std::bind2nd(std::mem_fun(&ToolbarItem::setOrientation), orient));
ItemList::iterator item_it_end = m_item_list.end();
for (; item_it != item_it_end; ++item_it)
(*item_it)->setOrientation(orient);
} }
void Toolbar::updateVisibleState() { void Toolbar::updateVisibleState() {
@ -812,10 +806,7 @@ void Toolbar::toggleHidden() {
frame.window.move(frame.x_hidden, frame.y_hidden); frame.window.move(frame.x_hidden, frame.y_hidden);
else { else {
frame.window.move(frame.x, frame.y); frame.window.move(frame.x, frame.y);
ItemList::iterator item_it = m_item_list.begin(); forAll(m_item_list, std::mem_fun(&ToolbarItem::parentMoved));
ItemList::iterator item_it_end = m_item_list.end();
for ( ; item_it != item_it_end; ++item_it)
(*item_it)->parentMoved();
} }
} }