aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Container.cc')
-rw-r--r--src/FbTk/Container.cc70
1 files changed, 23 insertions, 47 deletions
diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc
index ce143ef..e1d2e07 100644
--- a/src/FbTk/Container.cc
+++ b/src/FbTk/Container.cc
@@ -26,6 +26,7 @@
26#include "TextUtils.hh" 26#include "TextUtils.hh"
27#include "EventManager.hh" 27#include "EventManager.hh"
28#include "CompareEqual.hh" 28#include "CompareEqual.hh"
29#include "STLUtil.hh"
29 30
30#include <algorithm> 31#include <algorithm>
31 32
@@ -78,7 +79,7 @@ void Container::insertItem(Item item, int pos) {
78 } else if (pos == 0) { 79 } else if (pos == 0) {
79 m_item_list.push_front(item); 80 m_item_list.push_front(item);
80 } else { 81 } else {
81 ItemList::iterator it = m_item_list.begin(); 82 ItemList::iterator it = begin();
82 for (; pos != 0; ++it, --pos) 83 for (; pos != 0; ++it, --pos)
83 continue; 84 continue;
84 85
@@ -104,12 +105,10 @@ void Container::moveItem(Item item, int movement) {
104 if (newindex < 0) // neg wrap 105 if (newindex < 0) // neg wrap
105 newindex += size; 106 newindex += size;
106 107
107 ItemList::iterator it = std::find(m_item_list.begin(), 108 ItemList::iterator it = std::find(begin(), end(), item);
108 m_item_list.end(),
109 item);
110 m_item_list.erase(it); 109 m_item_list.erase(it);
111 110
112 for (it = m_item_list.begin(); newindex >= 0; ++it, --newindex) { 111 for (it = begin(); newindex >= 0; ++it, --newindex) {
113 if (newindex == 0) { 112 if (newindex == 0) {
114 break; 113 break;
115 } 114 }
@@ -143,12 +142,11 @@ bool Container::moveItemTo(Item item, int x, int y) {
143 &itemwin)) 142 &itemwin))
144 return false; 143 return false;
145 144
146 ItemList::iterator it = find_if(m_item_list.begin(), 145 ItemList::iterator it = find_if(begin(), end(),
147 m_item_list.end(),
148 CompareWindow(&FbWindow::window, 146 CompareWindow(&FbWindow::window,
149 itemwin)); 147 itemwin));
150 // not found :( 148 // not found :(
151 if (it == m_item_list.end()) 149 if (it == end())
152 return false; 150 return false;
153 151
154 Window child_return = 0; 152 Window child_return = 0;
@@ -162,8 +160,8 @@ bool Container::moveItemTo(Item item, int x, int y) {
162} 160}
163 161
164bool Container::removeItem(Item item) { 162bool Container::removeItem(Item item) {
165 ItemList::iterator it = m_item_list.begin(); 163 ItemList::iterator it = begin();
166 ItemList::iterator it_end = m_item_list.end(); 164 ItemList::iterator it_end = end();
167 for (; it != it_end && (*it) != item; ++it); 165 for (; it != it_end && (*it) != item; ++it);
168 166
169 if (it == it_end) 167 if (it == it_end)
@@ -178,7 +176,7 @@ bool Container::removeItem(int index) {
178 if (index < 0 || index > size()) 176 if (index < 0 || index > size())
179 return false; 177 return false;
180 178
181 ItemList::iterator it = m_item_list.begin(); 179 ItemList::iterator it = begin();
182 for (; index != 0; ++it, --index) 180 for (; index != 0; ++it, --index)
183 continue; 181 continue;
184 182
@@ -247,12 +245,11 @@ bool Container::tryExposeEvent(XExposeEvent &event) {
247 return true; 245 return true;
248 } 246 }
249 247
250 ItemList::iterator it = find_if(m_item_list.begin(), 248 ItemList::iterator it = find_if(begin(), end(),
251 m_item_list.end(),
252 CompareWindow(&FbWindow::window, 249 CompareWindow(&FbWindow::window,
253 event.window)); 250 event.window));
254 // not found :( 251 // not found :(
255 if (it == m_item_list.end()) 252 if (it == end())
256 return false; 253 return false;
257 254
258 (*it)->exposeEvent(event); 255 (*it)->exposeEvent(event);
@@ -265,12 +262,11 @@ bool Container::tryButtonPressEvent(XButtonEvent &event) {
265 return true; 262 return true;
266 } 263 }
267 264
268 ItemList::iterator it = find_if(m_item_list.begin(), 265 ItemList::iterator it = find_if(begin(), end(),
269 m_item_list.end(),
270 CompareWindow(&FbWindow::window, 266 CompareWindow(&FbWindow::window,
271 event.window)); 267 event.window));
272 // not found :( 268 // not found :(
273 if (it == m_item_list.end()) 269 if (it == end())
274 return false; 270 return false;
275 271
276 (*it)->buttonPressEvent(event); 272 (*it)->buttonPressEvent(event);
@@ -283,12 +279,11 @@ bool Container::tryButtonReleaseEvent(XButtonEvent &event) {
283 return true; 279 return true;
284 } 280 }
285 281
286 ItemList::iterator it = find_if(m_item_list.begin(), 282 ItemList::iterator it = find_if(begin(), end(),
287 m_item_list.end(),
288 CompareWindow(&FbWindow::window, 283 CompareWindow(&FbWindow::window,
289 event.window)); 284 event.window));
290 // not found :( 285 // not found :(
291 if (it == m_item_list.end()) 286 if (it == end())
292 return false; 287 return false;
293 288
294 (*it)->buttonReleaseEvent(event); 289 (*it)->buttonReleaseEvent(event);
@@ -360,8 +355,8 @@ void Container::repositionItems() {
360 } 355 }
361 356
362 357
363 ItemList::iterator it = m_item_list.begin(); 358 ItemList::iterator it = begin();
364 const ItemList::iterator it_end = m_item_list.end(); 359 const ItemList::iterator it_end = end();
365 360
366 int rounding_error = 0; 361 int rounding_error = 0;
367 362
@@ -442,41 +437,26 @@ unsigned int Container::maxWidthPerClient() const {
442} 437}
443 438
444void Container::for_each(std::mem_fun_t<void, FbWindow> function) { 439void Container::for_each(std::mem_fun_t<void, FbWindow> function) {
445 std::for_each(m_item_list.begin(), 440 std::for_each(begin(), end(), function);
446 m_item_list.end(),
447 function);
448} 441}
449 442
450void Container::setAlpha(unsigned char alpha) { 443void Container::setAlpha(unsigned char alpha) {
451 FbWindow::setAlpha(alpha); 444 FbWindow::setAlpha(alpha);
452 ItemList::iterator it = m_item_list.begin(); 445 STLUtil::forAll(m_item_list, std::bind2nd(std::mem_fun(&Button::setAlpha), alpha));
453 ItemList::iterator it_end = m_item_list.end();
454 for (; it != it_end; ++it)
455 (*it)->setAlpha(alpha);
456} 446}
457 447
458void Container::parentMoved() { 448void Container::parentMoved() {
459 FbWindow::parentMoved(); 449 FbWindow::parentMoved();
460 ItemList::iterator it = m_item_list.begin(); 450 STLUtil::forAll(m_item_list, std::mem_fun(&Button::parentMoved));
461 ItemList::iterator it_end = m_item_list.end();
462 for (; it != it_end; ++it)
463 (*it)->parentMoved();
464} 451}
465 452
466void Container::invalidateBackground() { 453void Container::invalidateBackground() {
467 FbWindow::invalidateBackground(); 454 FbWindow::invalidateBackground();
468 ItemList::iterator it = m_item_list.begin(); 455 STLUtil::forAll(m_item_list, std::mem_fun(&Button::invalidateBackground));
469 ItemList::iterator it_end = m_item_list.end();
470 for (; it != it_end; ++it)
471 (*it)->invalidateBackground();
472} 456}
473 457
474void Container::clear() { 458void Container::clear() {
475 ItemList::iterator it = m_item_list.begin(); 459 STLUtil::forAll(m_item_list, std::mem_fun(&Button::clear));
476 ItemList::iterator it_end = m_item_list.end();
477 for (; it != it_end; ++it)
478 (*it)->clear();
479
480} 460}
481 461
482void Container::setOrientation(Orientation orient) { 462void Container::setOrientation(Orientation orient) {
@@ -484,11 +464,7 @@ void Container::setOrientation(Orientation orient) {
484 return; 464 return;
485 465
486 FbWindow::invalidateBackground(); 466 FbWindow::invalidateBackground();
487 467 STLUtil::forAll(m_item_list, std::bind2nd(std::mem_fun(&Button::setOrientation), orient));
488 ItemList::iterator it = m_item_list.begin();
489 ItemList::iterator it_end = m_item_list.end();
490 for (; it != it_end; ++it)
491 (*it)->setOrientation(orient);
492 468
493 if (((m_orientation == ROT0 || m_orientation == ROT180) && 469 if (((m_orientation == ROT0 || m_orientation == ROT180) &&
494 (orient == ROT90 || orient == ROT270)) || 470 (orient == ROT90 || orient == ROT270)) ||