2 * Copyright (C) 2013 IBM Corporation
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.
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.
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
22 struct nc_widget_label;
23 struct nc_widget_checkbox;
24 struct nc_widget_textbox;
25 struct nc_widget_button;
27 struct nc_widget_label *widget_new_label(struct nc_widgetset *set,
28 int y, int x, char *str);
29 struct nc_widget_checkbox *widget_new_checkbox(struct nc_widgetset *set,
30 int y, int x, bool checked);
31 struct nc_widget_textbox *widget_new_textbox_hidden(struct nc_widgetset *set,
32 int y, int x, int len, char *str, bool hide_input);
33 struct nc_widget_textbox *widget_new_textbox(struct nc_widgetset *set,
34 int y, int x, int len, char *str);
35 struct nc_widget_subset *widget_new_subset(struct nc_widgetset *set,
36 int y, int x, int len, void *screen_cb);
37 struct nc_widget_select *widget_new_select(struct nc_widgetset *set,
38 int y, int x, int len);
39 struct nc_widget_button *widget_new_button(struct nc_widgetset *set,
40 int y, int x, int size, const char *str,
41 void (*click)(void *), void *arg);
43 void widget_textbox_set_fixed_size(struct nc_widget_textbox *textbox);
44 void widget_textbox_set_validator_integer(struct nc_widget_textbox *textbox,
46 void widget_textbox_set_validator_ip(struct nc_widget_textbox *textbox);
47 void widget_textbox_set_validator_ip_multi(struct nc_widget_textbox *textbox);
48 void widget_textbox_set_validator_url(struct nc_widget_textbox *textbox);
50 void widget_subset_add_option(struct nc_widget_subset *subset, const char *text);
51 void widget_subset_make_active(struct nc_widget_subset *subset, int idx);
53 void widget_subset_on_change(struct nc_widget_subset *subset,
54 void (*on_change)(void *arg, int value), void *arg);
56 void widget_select_add_option(struct nc_widget_select *select, int value,
57 const char *text, bool selected);
59 void widget_select_on_change(struct nc_widget_select *select,
60 void (*on_change)(void *arg, int value), void *arg);
62 char *widget_textbox_get_value(struct nc_widget_textbox *textbox);
63 bool widget_checkbox_get_value(struct nc_widget_checkbox *checkbox);
64 int widget_subset_get_order(void *ctx, unsigned int **order,
65 struct nc_widget_subset *subset);
66 void widget_subset_show_inactive(struct nc_widget_subset *subset,
67 struct nc_widget_select *select);
68 int widget_subset_n_inactive(struct nc_widget_subset *subset);
69 int widget_subset_height(struct nc_widget_subset *subset);
70 void widget_subset_drop_options(struct nc_widget_subset *subset);
71 void widget_subset_clear_active(struct nc_widget_subset *subset);
72 void widget_subset_callback(void *arg,
73 struct nc_widget_subset *subset, int idx);
74 int widget_select_get_value(struct nc_widget_select *select);
75 int widget_select_height(struct nc_widget_select *select);
76 void widget_select_drop_options(struct nc_widget_select *select);
78 /* generic widget API */
79 struct nc_widget *widget_textbox_base(struct nc_widget_textbox *textbox);
80 struct nc_widget *widget_checkbox_base(struct nc_widget_checkbox *checkbox);
81 struct nc_widget *widget_subset_base(struct nc_widget_subset *subset);
82 struct nc_widget *widget_select_base(struct nc_widget_select *select);
83 struct nc_widget *widget_label_base(struct nc_widget_label *label);
84 struct nc_widget *widget_button_base(struct nc_widget_button *button);
86 void widget_move(struct nc_widget *widget, int y, int x);
87 void widget_set_visible(struct nc_widget *widget, bool visible);
88 int widget_height(struct nc_widget *widget);
89 int widget_width(struct nc_widget *widget);
90 int widget_y(struct nc_widget *widget);
91 int widget_x(struct nc_widget *widget);
92 int widget_focus_y(struct nc_widget *widget);
95 typedef void (*widget_focus_cb)(struct nc_widget *widget, void *arg);
96 struct nc_widgetset *widgetset_create(void *ctx, WINDOW *main, WINDOW *sub);
97 void widgetset_set_widget_focus(struct nc_widgetset *set,
98 widget_focus_cb cb, void *arg);
99 void widgetset_set_windows(struct nc_widgetset *widgetset,
100 WINDOW *main, WINDOW *sub);
101 void widgetset_post(struct nc_widgetset *set);
102 void widgetset_unpost(struct nc_widgetset *set);
103 bool widgetset_process_key(struct nc_widgetset *set, int key);
105 #endif /* NC_WIDGETS_H */