1 #include "arrangement.h"
8 Arrangement::Arrangement(Layout &l):
10 parent(layout.get_arrangement())
12 layout.push_arrangement(*this);
15 Arrangement::~Arrangement()
17 layout.pop_arrangement(*this);
20 void Arrangement::arrange(Widget &wdg)
22 for(unsigned i=0; i<4; ++i)
23 process_widget(wdg, static_cast<Side>(i), true);
28 void Arrangement::arrange(Arrangement &arr)
30 for(unsigned i=0; i<4; ++i)
32 Side side = static_cast<Side>(i);
33 const Edge &edge = arr.get_edge(side);
34 for(list<Widget *>::const_iterator j=edge.widgets.begin(); j!=edge.widgets.end(); ++j)
35 process_widget(**j, side, edge.aligned);
40 void Arrangement::add_constraint(Widget &wdg, Layout::ConstraintType type, Side side)
42 add_constraint(wdg, type, edges[side]);
45 void Arrangement::add_constraint(Widget &wdg, Layout::ConstraintType type, const Edge &edge)
47 for(list<Widget *>::const_iterator i=edge.widgets.begin(); i!=edge.widgets.end(); ++i)
49 layout.add_constraint(wdg, type, **i);
52 Layout::ConstraintType Arrangement::get_order_constraint(Side s, bool slack)
56 case TOP: return (slack ? Layout::FAR_ABOVE : Layout::ABOVE);
57 case RIGHT: return (slack ? Layout::FAR_RIGHT_OF : Layout::RIGHT_OF);
58 case BOTTOM: return (slack ? Layout::FAR_BELOW : Layout::BELOW);
59 case LEFT: return (slack ? Layout::FAR_LEFT_OF : Layout::LEFT_OF);
60 default: throw invalid_argument("Arrangement::get_align_constraint");
64 Layout::ConstraintType Arrangement::get_align_constraint(Side s)
68 case TOP: return Layout::ALIGN_TOP;
69 case RIGHT: return Layout::ALIGN_RIGHT;
70 case BOTTOM: return Layout::ALIGN_BOTTOM;
71 case LEFT: return Layout::ALIGN_LEFT;
72 default: throw invalid_argument("Arrangement::get_align_constraint");
77 Arrangement::Edge::Edge():
81 void Arrangement::Edge::clear()
87 void Arrangement::Edge::add(Widget &wdg, bool algn)
95 widgets.push_back(&wdg);
99 void Arrangement::Edge::align()
101 if(aligned || widgets.empty())
104 list<Widget *>::iterator second = widgets.begin();
107 widgets.erase(second, widgets.end());