4 * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
9 * \brief Edit bool widget (implementation).
10 * This widget handles boolean editing.
11 * The boolean value will be displayed using two strings:
12 * one when the bool is false and one when it's true.
15 * \author Francesco Sacchi <batt@ðeveler.com>
20 *#* Revision 1.1 2005/11/04 18:26:38 bernie
21 *#* Import into DevLib.
23 *#* Revision 1.3 2005/06/08 17:32:33 batt
24 *#* Switch to new messaging system.
26 *#* Revision 1.2 2005/06/06 11:04:12 batt
27 *#* Add some comments.
29 *#* Revision 1.1 2005/05/31 11:11:37 batt
30 *#* Edit bool: first release.
34 #include <mware/editbool.h>
37 #include <drv/lcd_text.h>
42 void editbool_init(DEditBool *e, dpos_t pos, dpos_t size, dcontext_t *context, bool *value, const char *true_string, const char *false_string)
44 // Initialize superclass
45 widget_init(&e->widget, pos, size, context);
47 // Override superclass methods
48 e->widget.notifier.update = (update_func_ptr)editbool_update;
52 e->true_string = true_string;
53 e->false_string = false_string;
54 e->draw = editbool_draw;
58 * Handle the messages (edit the bool).
60 void editbool_update(DEditBool *e, dtag_t tag, dval_t _val)
67 *e->value = (bool)_val;
72 *e->value = !*e->value;
82 dnotify_targets(&e->widget.notifier, TAG_SETVALUE, (dval_t)*e->value);
87 * Draw the string on the context.
89 void editbool_draw(DEditBool *e)
91 lcd_printf((Layer *)e->widget.context, (lcdpos_t)e->widget.pos, LCD_NORMAL, "%*s", (int)e->widget.size , *e->value? e->true_string: e->false_string);