1 /* Monolith iframe 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_iframe.c,v 1.1 2002/11/08 23:19:14 rich Exp $
25 #include <pthr_iolib.h>
28 #include "ml_widget.h"
29 #include "ml_iframe.h"
31 static void repaint (void *, ml_session, const char *, io_handle);
32 static struct ml_widget_property properties[];
34 struct ml_widget_operations iframe_ops =
37 properties: properties,
42 struct ml_widget_operations *ops;
43 pool pool; /* Pool for allocations. */
44 const char *action_id; /* Action. */
45 ml_widget non_frame_widget; /* Alternative for non-frames browsers. */
46 int width, height; /* Width, height. */
47 const char *clazz; /* Class. */
48 const char *scrolling; /* "yes", "no" or "auto". */
51 static struct ml_widget_property properties[] =
54 offset: ml_offsetof (struct ml_iframe, width),
57 offset: ml_offsetof (struct ml_iframe, height),
60 offset: ml_offsetof (struct ml_iframe, clazz),
61 type: ML_PROP_STRING },
63 offset: ml_offsetof (struct ml_iframe, scrolling),
64 type: ML_PROP_STRING },
69 new_ml_iframe (pool pool, void (*fn) (ml_session, void *),
70 ml_session session, void *data,
71 ml_widget non_frame_widget)
73 ml_iframe w = pmalloc (pool, sizeof *w);
79 w->width = w->height = 0;
80 w->non_frame_widget = non_frame_widget;
82 /* Register the callback. */
83 w->action_id = ml_register_action (session, fn, data);
89 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
91 ml_iframe w = (ml_iframe) vw;
93 io_fprintf (io, "<iframe src=\"%s?ml_action=%s&ml_window=%s\"",
94 ml_session_script_name (session), w->action_id, windowid);
97 io_fprintf (io, " class=\"%s\"", w->clazz);
99 io_fprintf (io, " width=\"%d\"", w->width);
101 io_fprintf (io, " height=\"%d\"", w->height);
103 io_fprintf (io, " scrolling=\"%s\"", w->scrolling);
106 if (w->non_frame_widget)
107 ml_widget_repaint (w->non_frame_widget, session, windowid, io);
109 io_fputs ("Your browser does not support frames.", io);
111 io_fputs ("</iframe>", io);