1 /* Monolith heading 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_heading.c,v 1.2 2002/11/23 17:31:01 rich Exp $
27 #include <pthr_iolib.h>
30 #include "ml_widget.h"
31 #include "ml_smarttext.h"
32 #include "ml_heading.h"
34 static void repaint (void *, ml_session, const char *, io_handle);
35 static struct ml_widget_property properties[];
37 struct ml_widget_operations heading_ops =
40 properties: properties,
45 struct ml_widget_operations *ops;
46 pool pool; /* Pool for allocations. */
47 int level; /* Heading level (1 - 6). */
48 const char *text; /* Text to be displayed. */
51 static struct ml_widget_property properties[] =
54 offset: ml_offsetof (struct ml_heading, text),
55 type: ML_PROP_STRING },
56 { name: "heading.level",
57 offset: ml_offsetof (struct ml_heading, level),
63 new_ml_heading (pool pool, int level, const char *text)
65 ml_heading w = pmalloc (pool, sizeof *w);
67 w->ops = &heading_ops;
76 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
78 ml_heading w = (ml_heading) vw;
82 io_fprintf (io, "<h%d class=\"ml_heading\">", w->level);
83 ml_plaintext_print (io, w->text);
84 io_fprintf (io, "</h%d>", w->level);