]> git.ozlabs.org Git - petitboot/blob - ui/ncurses/nc-widgets.h
discover,ui: fix checks for debug option
[petitboot] / ui / ncurses / nc-widgets.h
1 /*
2  *  Copyright (C) 2013 IBM Corporation
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17
18 #ifndef NC_WIDGETS_H
19
20 struct nc_widgetset;
21 struct nc_widget_label;
22 struct nc_widget_checkbox;
23 struct nc_widget_textbox;
24 struct nc_widget_button;
25
26 struct nc_widget_label *widget_new_label(struct nc_widgetset *set,
27                 int y, int x, char *str);
28 struct nc_widget_checkbox *widget_new_checkbox(struct nc_widgetset *set,
29                 int y, int x, bool checked);
30 struct nc_widget_textbox *widget_new_textbox(struct nc_widgetset *set,
31                 int y, int x, int len, char *str);
32 struct nc_widget_select *widget_new_select(struct nc_widgetset *set,
33                 int y, int x, int len);
34 struct nc_widget_button *widget_new_button(struct nc_widgetset *set,
35                 int y, int x, int size, const char *str,
36                 void (*click)(void *), void *arg);
37
38 void widget_textbox_set_fixed_size(struct nc_widget_textbox *textbox);
39 void widget_textbox_set_validator_integer(struct nc_widget_textbox *textbox,
40                 long min, long max);
41 void widget_textbox_set_validator_ipv4(struct nc_widget_textbox *textbox);
42 void widget_textbox_set_validator_ipv4_multi(struct nc_widget_textbox *textbox);
43
44 void widget_select_add_option(struct nc_widget_select *select, int value,
45                 const char *text, bool selected);
46
47 void widget_select_on_change(struct nc_widget_select *select,
48                 void (*on_change)(void *arg, int value), void *arg);
49
50 char *widget_textbox_get_value(struct nc_widget_textbox *textbox);
51 bool widget_checkbox_get_value(struct nc_widget_checkbox *checkbox);
52 int widget_select_get_value(struct nc_widget_select *select);
53 int widget_select_height(struct nc_widget_select *select);
54 void widget_select_drop_options(struct nc_widget_select *select);
55
56 /* generic widget API */
57 struct nc_widget *widget_textbox_base(struct nc_widget_textbox *textbox);
58 struct nc_widget *widget_checkbox_base(struct nc_widget_checkbox *checkbox);
59 struct nc_widget *widget_select_base(struct nc_widget_select *select);
60 struct nc_widget *widget_label_base(struct nc_widget_label *label);
61 struct nc_widget *widget_button_base(struct nc_widget_button *button);
62
63 void widget_move(struct nc_widget *widget, int y, int x);
64 void widget_set_visible(struct nc_widget *widget, bool visible);
65 int widget_height(struct nc_widget *widget);
66 int widget_width(struct nc_widget *widget);
67 int widget_y(struct nc_widget *widget);
68 int widget_x(struct nc_widget *widget);
69 int widget_focus_y(struct nc_widget *widget);
70
71 /* widgetset API */
72 typedef void (*widget_focus_cb)(struct nc_widget *widget, void *arg);
73 struct nc_widgetset *widgetset_create(void *ctx, WINDOW *main, WINDOW *sub);
74 void widgetset_set_widget_focus(struct nc_widgetset *set,
75                 widget_focus_cb cb, void *arg);
76 void widgetset_set_windows(struct nc_widgetset *widgetset,
77                 WINDOW *main, WINDOW *sub);
78 void widgetset_post(struct nc_widgetset *set);
79 void widgetset_unpost(struct nc_widgetset *set);
80 bool widgetset_process_key(struct nc_widgetset *set, int key);
81
82 #endif /* NC_WIDGETS_H */
83