1 /* Monolith form submit button 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_submit.c,v 1.4 2003/01/11 16:39:10 rich Exp $
23 #include <pthr_iolib.h>
26 #include "ml_widget.h"
27 #include "ml_smarttext.h"
28 #include "ml_form_submit.h"
30 static void repaint (void *, ml_session, const char *, io_handle);
31 static void clear_value (void *);
32 static void set_value (void *, const char *value);
33 static const char *get_value (void *);
35 struct ml_widget_operations form_submit_ops =
40 struct ml_form_input_operations form_submit_input_ops =
42 clear_value: clear_value,
49 struct ml_widget_operations *ops;
50 struct ml_form_input_operations *fops;
51 pool pool; /* Pool for allocations. */
52 const char *name; /* Name of the input field. */
53 const char *value; /* Value of the input field. */
57 new_ml_form_submit (pool pool, ml_form form, const char *value)
59 ml_form_submit w = pmalloc (pool, sizeof *w);
61 w->ops = &form_submit_ops;
62 w->fops = &form_submit_input_ops;
66 /* Register ourselves with the form. */
67 w->name = _ml_form_register_widget (form, w);
73 clear_value (void *vw)
75 ml_form_submit w = (ml_form_submit) vw;
81 set_value (void *vw, const char *value)
83 ml_form_submit w = (ml_form_submit) vw;
91 ml_form_submit w = (ml_form_submit) vw;
97 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
99 ml_form_submit w = (ml_form_submit) vw;
101 io_fprintf (io, "<input class=\"ml_form_submit\" "
102 "type=\"submit\" name=\"%s\" value=\"",
104 if (w->value) ml_plaintext_print (io, w->value);
105 io_fputs ("\" />", io);