Add to git.
[monolith.git] / src / ml_box.c
1 /* Monolith box class.
2  * - by Richard W.M. Jones <rich@annexia.org>
3  *
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.
8  *
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.
13  *
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.
17  *
18  * $Id: ml_box.c,v 1.2 2002/09/14 14:35:58 rich Exp $
19  */
20
21 #include "config.h"
22
23 #include <pthr_iolib.h>
24
25 #include "ml_widget.h"
26 #include "monolith.h"
27 #include "ml_box.h"
28
29 static void repaint (void *, ml_session, const char *, io_handle);
30
31 struct ml_widget_operations box_ops =
32   {
33     repaint: repaint
34   };
35
36 struct ml_box
37 {
38   struct ml_widget_operations *ops;
39   pool pool;                    /* Pool for allocations. */
40   ml_widget w;                  /* Widget packed inside the box. */
41 };
42
43 ml_box
44 new_ml_box (pool pool)
45 {
46   ml_box w = pmalloc (pool, sizeof *w);
47
48   w->ops = &box_ops;
49   w->pool = pool;
50   w->w = 0;
51
52   return w;
53 }
54
55 void
56 ml_box_pack (ml_box w, ml_widget _w)
57 {
58   w->w = _w;
59 }
60
61 static void
62 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
63 {
64   ml_box w = (ml_box) vw;
65
66   io_fprintf (io, "<span class=\"ml_box\">");
67
68   if (w->w)
69     ml_widget_repaint (w->w, session, windowid, io);
70
71   io_fprintf (io, "</span>");
72 }