4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
11 * A generic layout engine that draws heavily on GTK+.
14 #ifndef LAYOUT_ENGINE_H
15 #define LAYOUT_ENGINE_H
17 #include "forms_fwd.h"
28 typedef std::list<Box> Container;
29 typedef Container::size_type size_type;
30 typedef Container::iterator iterator;
31 typedef Container::const_iterator const_iterator;
34 size_type size() const;
37 Box & push_back(Box const &);
42 const_iterator begin() const;
43 const_iterator end() const;
45 iterator erase(iterator where);
46 iterator erase(iterator begin, iterator end);
55 typedef unsigned int dimension_t;
57 /** \param min_w the minimum allowed width of the box.
58 * \param min_h the minimum allowed height of the box.
60 Box(dimension_t min_w, dimension_t min_h);
62 void setMinimumDimensions(dimension_t min_w, dimension_t min_h);
64 /** \name Child Orientation
65 * The enum prescribes whether children are aligned
66 * horizontally or vertically.
74 Orientation orientation() const;
75 void set(Orientation);
77 /// Initially set to Vertical
78 static Orientation defaultOrientation();
79 static void setDefault(Orientation);
83 * Do the children receive extra space when the parent grows?
91 Packing packing() const;
94 /// Initially set to Shrink
95 static Packing defaultPacking();
96 static void setDefault(Packing);
98 /** returns true if this Box or any of its children have
99 * packing() == Expand.
101 bool expandable() const;
104 /** \name Prefered Visibility
105 * If the parent container is visible, should this Box be
109 enum PreferedVisibility {
114 PreferedVisibility preferedVisibility() const;
115 /// If \pv == Invisible, also calls hide().
116 void set(PreferedVisibility pv);
119 /** \name Actual Visibility
122 bool visible() const;
123 /// Does nothing if preferedVisibility() == Invisible.
129 BoxList & children();
130 BoxList const & children() const;
132 dimension_t width() const;
133 dimension_t height() const;
134 dimension_t xorigin() const;
135 dimension_t yorigin() const;
137 void updateMetrics();
140 void shrinkMetrics();
141 void expandMetrics(dimension_t x, dimension_t y,
142 dimension_t w, dimension_t h);
143 void expandHbox(dimension_t x, dimension_t y,
144 dimension_t w, dimension_t h);
145 void expandVbox(dimension_t x, dimension_t y,
146 dimension_t w, dimension_t h);
148 static Orientation default_orientation_;
149 static Packing default_packing_;
159 Orientation orientation_;
161 PreferedVisibility prefered_visibility_;
167 typedef Box::dimension_t dimension_t;
169 /// \returns the just-added Box.
170 Box & add(FL_OBJECT * widget, BoxList & container,
171 dimension_t min_w, dimension_t min_h);
172 void updateMetrics() const;
175 typedef std::map<FL_OBJECT *, Box *> DataMap;
180 /** Embed \c ob in \c container inside a border of width \c bw.
181 * Thereafter, hand control of its metrics to \c widgets.
182 * \returns the Box containing \c ob.
184 Box & embed(FL_OBJECT * ob, BoxList & container, WidgetMap & widgets, int bw);
186 } // namespace frontend
189 #endif // NOT LAYOUT_ENGINE_H