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"
19 #include <boost/shared_ptr.hpp>
31 typedef std::list<boost::shared_ptr<Box> > Container;
32 typedef Container::size_type size_type;
33 typedef Container::iterator iterator;
34 typedef Container::const_iterator const_iterator;
37 size_type size() const;
40 boost::shared_ptr<Box> push_back(Box const &);
45 const_iterator begin() const;
46 const_iterator end() const;
48 iterator erase(iterator where);
49 iterator erase(iterator begin, iterator end);
58 typedef unsigned int dimension_t;
60 /** \param min_w the minimum allowed width of the box.
61 * \param min_h the minimum allowed height of the box.
63 Box(dimension_t min_w, dimension_t min_h);
65 void setMinimumDimensions(dimension_t min_w, dimension_t min_h);
67 /** \name Child Orientation
68 * The enum prescribes whether children are aligned
69 * horizontally or vertically.
77 Orientation orientation() const;
78 void set(Orientation);
80 /// Initially set to Vertical
81 static Orientation defaultOrientation();
82 static void setDefault(Orientation);
86 * Do the children receive extra space when the parent grows?
94 Packing packing() const;
97 /// Initially set to Shrink
98 static Packing defaultPacking();
99 static void setDefault(Packing);
101 /** returns true if this Box or any of its children have
102 * packing() == Expand.
104 bool expandable() const;
107 /** \name Prefered Visibility
108 * If the parent container is visible, should this Box be
112 enum PreferedVisibility {
117 PreferedVisibility preferedVisibility() const;
118 /// If \pv == Invisible, also calls hide().
119 void set(PreferedVisibility pv);
122 /** \name Actual Visibility
125 bool visible() const;
126 /// Does nothing if preferedVisibility() == Invisible.
132 BoxList & children();
133 BoxList const & children() const;
135 dimension_t width() const;
136 dimension_t height() const;
137 dimension_t xorigin() const;
138 dimension_t yorigin() const;
140 void updateMetrics();
143 void shrinkMetrics();
144 void expandMetrics(dimension_t x, dimension_t y,
145 dimension_t w, dimension_t h);
146 void expandHbox(dimension_t x, dimension_t y,
147 dimension_t w, dimension_t h);
148 void expandVbox(dimension_t x, dimension_t y,
149 dimension_t w, dimension_t h);
151 static Orientation default_orientation_;
152 static Packing default_packing_;
162 Orientation orientation_;
164 PreferedVisibility prefered_visibility_;
170 typedef Box::dimension_t dimension_t;
172 /// \returns the just-added Box.
173 boost::shared_ptr<Box>
174 add(FL_OBJECT * widget, BoxList & container,
175 dimension_t min_w, dimension_t min_h);
176 void updateMetrics() const;
179 typedef std::map<FL_OBJECT *, boost::shared_ptr<Box> > DataMap;
184 /** Embed \c ob in \c container inside a border of width \c bw.
185 * Thereafter, hand control of its metrics to \c widgets.
186 * \returns the Box containing \c ob.
188 boost::shared_ptr<Box>
189 embed(FL_OBJECT * ob, BoxList & container, WidgetMap & widgets, int bw);
191 } // namespace frontend
194 #endif // NOT LAYOUT_ENGINE_H