summaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Container.cc46
-rw-r--r--src/FbTk/Container.hh4
2 files changed, 29 insertions, 21 deletions
diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc
index 6a8f2a3..bcb6b01 100644
--- a/src/FbTk/Container.cc
+++ b/src/FbTk/Container.cc
@@ -33,13 +33,14 @@ namespace FbTk {
33 33
34typedef CompareEqual_base<FbWindow, Window> CompareWindow; 34typedef CompareEqual_base<FbWindow, Window> CompareWindow;
35 35
36Container::Container(const FbWindow &parent): 36Container::Container(const FbWindow &parent, bool auto_resize):
37 FbWindow(parent, 0, 0, 1, 1, ExposureMask), 37 FbWindow(parent, 0, 0, 1, 1, ExposureMask),
38 m_orientation(ROT0), 38 m_orientation(ROT0),
39 m_align(RELATIVE), 39 m_align(RELATIVE),
40 m_max_size_per_client(60), 40 m_max_size_per_client(60),
41 m_max_total_size(0), 41 m_max_total_size(0),
42 m_update_lock(false) { 42 m_update_lock(false),
43 m_auto_resize(auto_resize) {
43 EventManager::instance()->add(*this, *this); 44 EventManager::instance()->add(*this, *this);
44} 45}
45 46
@@ -328,7 +329,7 @@ void Container::repositionItems() {
328 } else 329 } else
329 max_width_per_client = 1; 330 max_width_per_client = 1;
330 } 331 }
331 if (total_width != cur_width) { 332 if (m_auto_resize && total_width != cur_width) {
332 // calling Container::resize here risks infinite loops 333 // calling Container::resize here risks infinite loops
333 unsigned int neww = total_width, newh = height; 334 unsigned int neww = total_width, newh = height;
334 translateSize(m_orientation, neww, newh); 335 translateSize(m_orientation, neww, newh);
@@ -410,24 +411,31 @@ void Container::repositionItems() {
410 411
411 412
412unsigned int Container::maxWidthPerClient() const { 413unsigned int Container::maxWidthPerClient() const {
413 unsigned int max_relative_size; 414 switch (alignment()) {
414 if (size() == 0) 415 case RIGHT:
415 max_relative_size = width(); 416 case CENTER:
416 else { 417 case LEFT:
417 unsigned int borderW = m_item_list.front()->borderWidth(); 418 return m_max_size_per_client;
418 // there're count-1 borders to fit in with the windows 419 break;
419 // -> 1 per window plus end 420 case RELATIVE:
420 unsigned int w = width(), h = height(); 421 if (size() == 0)
421 translateSize(m_orientation, w, h); 422 return width();
422 max_relative_size = w < (size()-1)*borderW ? 1 : 423 else {
423 (w - (size() - 1) * borderW) / size(); 424 unsigned int borderW = m_item_list.front()->borderWidth();
425 // there're count-1 borders to fit in with the windows
426 // -> 1 per window plus end
427 unsigned int w = width(), h = height();
428 translateSize(m_orientation, w, h);
429 if (w < (size()-1)*borderW)
430 return 1;
431 else
432 return (w - (size() - 1) * borderW) / size();
433 }
434 break;
424 } 435 }
425 436
426 if (alignment() == RELATIVE) 437 // this will never happen anyway
427 return max_relative_size; 438 return 1;
428
429 return (m_max_size_per_client < max_relative_size ?
430 m_max_size_per_client : max_relative_size);
431} 439}
432 440
433void Container::for_each(std::mem_fun_t<void, FbWindow> function) { 441void Container::for_each(std::mem_fun_t<void, FbWindow> function) {
diff --git a/src/FbTk/Container.hh b/src/FbTk/Container.hh
index 00f2c88..e2614a8 100644
--- a/src/FbTk/Container.hh
+++ b/src/FbTk/Container.hh
@@ -43,7 +43,7 @@ public:
43 typedef const Button * ConstItem; 43 typedef const Button * ConstItem;
44 typedef std::list<Item> ItemList; 44 typedef std::list<Item> ItemList;
45 45
46 explicit Container(const FbWindow &parent); 46 explicit Container(const FbWindow &parent, bool auto_resize = true);
47 virtual ~Container(); 47 virtual ~Container();
48 48
49 // manipulators 49 // manipulators
@@ -106,7 +106,7 @@ private:
106 unsigned int m_max_size_per_client; 106 unsigned int m_max_size_per_client;
107 unsigned int m_max_total_size; 107 unsigned int m_max_total_size;
108 ItemList m_item_list; 108 ItemList m_item_list;
109 bool m_update_lock; 109 bool m_update_lock, m_auto_resize;
110}; 110};
111 111
112} // end namespace FbTk 112} // end namespace FbTk