1 /* Monolith form 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_form_layout.c,v 1.1 2002/11/13 20:46:37 rich Exp $
23 #include <pthr_iolib.h>
25 #include "ml_widget.h"
27 #include "ml_text_label.h"
28 #include "ml_multicol_layout.h"
29 #include "ml_form_layout.h"
31 static void repaint (void *, ml_session, const char *, io_handle);
32 static struct ml_widget_property properties[];
34 struct ml_widget_operations form_layout_ops =
37 properties: properties,
42 struct ml_widget_operations *ops;
43 pool pool; /* Pool for allocations. */
44 ml_multicol_layout tbl; /* We're really a multi-column layout. */
45 const char *clazz; /* Stylesheet class. */
48 static void update_table_class (void *vw);
50 static struct ml_widget_property properties[] =
53 offset: ml_offsetof (struct ml_form_layout, clazz),
55 on_set: update_table_class },
60 new_ml_form_layout (pool pool)
62 ml_form_layout w = pmalloc (pool, sizeof *w);
64 w->ops = &form_layout_ops;
66 w->tbl = new_ml_multicol_layout (pool, 2);
67 w->clazz = "ml_form_layout";
68 update_table_class (w);
74 update_table_class (void *vw)
76 ml_form_layout w = (ml_form_layout) vw;
78 ml_widget_set_property (w->tbl, "class", w->clazz);
82 ml_form_layout_pack (ml_form_layout w, const char *label, ml_widget input)
88 lbl = new_ml_text_label (w->pool, label);
90 ml_multicol_layout_set_header (w->tbl, 1);
91 ml_multicol_layout_pack (w->tbl, lbl);
95 ml_multicol_layout_set_header (w->tbl, 1);
96 ml_multicol_layout_pack (w->tbl, 0);
99 ml_multicol_layout_pack (w->tbl, input);
103 ml_form_layout_pack_help (ml_form_layout w, const char *help_text)
107 ml_multicol_layout_set_header (w->tbl, 1);
108 ml_multicol_layout_pack (w->tbl, 0);
110 lbl = new_ml_text_label (w->pool, help_text);
111 ml_widget_set_property (lbl, "font.size", "small");
112 ml_multicol_layout_pack (w->tbl, lbl);
116 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
118 ml_form_layout w = (ml_form_layout) vw;
120 ml_widget_repaint (w->tbl, session, windowid, io);