1 /* Monolith multi-column 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_multicol_layout.c,v 1.3 2002/11/13 20:46:37 rich Exp $
23 #include <pthr_iolib.h>
25 #include "ml_widget.h"
27 #include "ml_table_layout.h"
28 #include "ml_multicol_layout.h"
30 static void repaint (void *, ml_session, const char *, io_handle);
31 static struct ml_widget_property properties[];
33 struct ml_widget_operations multicol_layout_ops =
36 properties: properties,
39 struct ml_multicol_layout
41 struct ml_widget_operations *ops;
42 pool pool; /* Pool for allocations. */
43 ml_table_layout tbl; /* We're really just a table layout. */
44 int cols; /* Fixed number of columns. */
45 int rows; /* Current number of rows in the table. */
46 int r, c; /* Next row, column. */
47 const char *clazz; /* Stylesheet class. */
50 static void update_table_class (void *vw);
52 static struct ml_widget_property properties[] =
55 offset: ml_offsetof (struct ml_multicol_layout, clazz),
57 on_set: update_table_class },
61 static void make_cell (ml_multicol_layout w);
64 new_ml_multicol_layout (pool pool, int nr_cols)
66 ml_multicol_layout w = pmalloc (pool, sizeof *w);
68 w->ops = &multicol_layout_ops;
70 w->tbl = new_ml_table_layout (pool, 0, nr_cols);
80 update_table_class (void *vw)
82 ml_multicol_layout w = (ml_multicol_layout) vw;
84 ml_widget_set_property (w->tbl, "class", w->clazz);
88 ml_multicol_layout_set_align (ml_multicol_layout w, const char *align)
91 ml_table_layout_set_align (w->tbl, w->r, w->c, align);
95 ml_multicol_layout_set_valign (ml_multicol_layout w, const char *valign)
98 ml_table_layout_set_valign (w->tbl, w->r, w->c, valign);
102 ml_multicol_layout_set_class (ml_multicol_layout w, const char *clazz)
105 ml_table_layout_set_class (w->tbl, w->r, w->c, clazz);
109 ml_multicol_layout_set_header (ml_multicol_layout w, int is_header)
112 ml_table_layout_set_header (w->tbl, w->r, w->c, is_header);
116 ml_multicol_layout_pack (ml_multicol_layout w, ml_widget _w)
120 /* Insert the widget. */
121 if (_w) ml_table_layout_pack (w->tbl, _w, w->r, w->c);
123 /* Move to the next position. */
133 make_cell (ml_multicol_layout w)
135 /* Create a new row in the underlying table? */
138 ml_table_layout_add_row (w->tbl);
144 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
146 ml_multicol_layout w = (ml_multicol_layout) vw;
148 ml_widget_repaint (w->tbl, session, windowid, io);