1 /* Monolith flow layout class.
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: ml_flow_layout.c,v 1.1 2002/08/28 19:50:28 rich Exp $
23 #include <pthr_iolib.h>
25 #include "ml_widget.h"
27 #include "ml_flow_layout.h"
29 static void repaint (void *, ml_session, const char *, io_handle);
31 struct ml_widget_operations flow_layout_ops =
38 struct ml_widget_operations *ops;
39 pool pool; /* Pool for allocations. */
40 vector v; /* Vector of widgets. */
44 new_ml_flow_layout (pool pool)
46 ml_flow_layout w = pmalloc (pool, sizeof *w);
48 w->ops = &flow_layout_ops;
50 w->v = new_vector (pool, ml_widget);
56 ml_flow_layout_push_back (ml_flow_layout w, ml_widget _w)
58 vector_push_back (w->v, _w);
62 ml_flow_layout_pack (ml_flow_layout w, ml_widget _w)
64 vector_push_back (w->v, _w);
68 ml_flow_layout_pop_back (ml_flow_layout w)
72 vector_pop_back (w->v, _w);
77 ml_flow_layout_push_front (ml_flow_layout w, ml_widget _w)
79 vector_push_front (w->v, _w);
83 ml_flow_layout_pop_front (ml_flow_layout w)
87 vector_pop_front (w->v, _w);
92 ml_flow_layout_get (ml_flow_layout w, int i)
96 vector_get (w->v, i, _w);
101 ml_flow_layout_insert (ml_flow_layout w, int i, ml_widget _w)
103 vector_insert (w->v, i, _w);
107 ml_flow_layout_replace (ml_flow_layout w, int i, ml_widget _w)
109 vector_replace (w->v, i, _w);
113 ml_flow_layout_erase (ml_flow_layout w, int i)
115 vector_erase (w->v, i);
119 ml_flow_layout_clear (ml_flow_layout w)
125 ml_flow_layout_size (ml_flow_layout w)
127 return vector_size (w->v);
131 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
133 ml_flow_layout w = (ml_flow_layout) vw;
136 for (i = 0; i < vector_size (w->v); ++i)
140 vector_get (w->v, i, _w);
141 ml_widget_repaint (_w, session, windowid, io);