4 #include "dialog.h" /* Widget */
6 /* Please note that the first element in all the widgets is a */
7 /* widget variable of type Widget. We abuse this fact everywhere */
10 typedef int (*bcback
) (int);
12 typedef struct WButton
{
14 int action
; /* what to do when pressed */
15 int selected
; /* button state */
17 #define HIDDEN_BUTTON 0
18 #define NARROW_BUTTON 1
19 #define NORMAL_BUTTON 2
20 #define DEFPUSH_BUTTON 3
21 unsigned int flags
; /* button flags */
22 char *text
; /* text of button */
23 int hotkey
; /* hot KEY */
24 int hotpos
; /* offset hot KEY char in text */
25 bcback callback
; /* Callback function */
28 typedef struct WRadio
{
30 unsigned int state
; /* radio button state */
32 int count
; /* number of members */
33 const char **texts
; /* texts of labels */
36 typedef struct WCheck
{
40 #define C_CHANGE 0x0002
41 unsigned int state
; /* check button state */
42 char *text
; /* text of check button */
43 int hotkey
; /* hot KEY */
44 int hotpos
; /* offset hot KEY char in text */
47 typedef struct WGauge
{
54 GList
*history_get (const char *input_name
);
55 void history_put (const char *input_name
, GList
*h
);
56 char *show_hist (GList
*history
, int widget_y
, int widget_x
);
60 int point
; /* cursor position in the input line */
61 int mark
; /* The mark position */
62 int first_shown
; /* Index of the first shown character */
63 int current_max_len
; /* Maximum length of input line */
64 int field_len
; /* Length of the editing field */
65 int color
; /* color used */
66 int first
; /* Is first keystroke? */
67 int disable_update
; /* Do we want to skip updates? */
68 int is_password
; /* Is this a password input line? */
69 char *buffer
; /* pointer to editing buffer */
70 GList
*history
; /* The history */
71 int need_push
; /* need to push the current Input on hist? */
72 char **completions
; /* Possible completions array */
73 int completion_flags
; /* INPUT_COMPLETE* bitwise flags(complete.h) */
74 char *history_name
; /* name of history for loading and saving */
77 /* For history load-save functions */
78 #define INPUT_LAST_TEXT ((char *) 2)
82 int auto_adjust_cols
; /* compute widget.cols from strlen(text)? */
84 int transparent
; /* Paint in the default color fg/bg */
87 typedef struct WLEntry
{
88 char *text
; /* Text to display */
90 void *data
; /* Client information */
96 typedef struct WListbox WListbox
;
97 typedef int (*lcback
) (WListbox
*);
99 /* Callback should return one of the following values */
101 LISTBOX_CONT
, /* continue */
102 LISTBOX_DONE
/* finish dialog */
107 WLEntry
*list
; /* Pointer to the circular double linked list. */
108 WLEntry
*top
; /* The first element displayed */
109 WLEntry
*current
; /* The current element displayed */
110 int pos
; /* Cur. pos, must be kept in sync with current */
111 int count
; /* Number of items in the listbox */
113 int height
; /* Size of the widget */
114 int allow_duplicates
; /* Do we allow duplicates on the list? */
115 int scrollbar
; /* Draw a scrollbar? */
116 lcback cback
; /* The callback function */
117 int cursor_x
, cursor_y
; /* Cache the values */
120 typedef struct WGroupbox
{
126 WButton
*button_new (int y
, int x
, int action
, int flags
, const char *text
,
128 WRadio
*radio_new (int y
, int x
, int count
, const char **text
);
129 WCheck
*check_new (int y
, int x
, int state
, const char *text
);
130 WInput
*input_new (int y
, int x
, int color
, int len
, const char *text
, const char *histname
);
131 WLabel
*label_new (int y
, int x
, const char *text
);
132 WGauge
*gauge_new (int y
, int x
, int shown
, int max
, int current
);
133 WListbox
*listbox_new (int x
, int y
, int width
, int height
, lcback callback
);
134 WGroupbox
*groupbox_new (int x
, int y
, int width
, int height
, const char *title
);
137 void winput_set_origin (WInput
*i
, int x
, int field_len
);
138 cb_ret_t
handle_char (WInput
*in
, int c_code
);
139 int is_in_input_map (WInput
*in
, int c_code
);
140 void update_input (WInput
*in
, int clear_first
);
141 void new_input (WInput
*in
);
142 int push_history (WInput
*in
, const char *text
);
143 void stuff (WInput
*in
, const char *text
, int insert_extra_space
);
144 void input_disable_update (WInput
*in
);
145 void input_set_prompt (WInput
*in
, int field_len
, const char *prompt
);
146 void input_enable_update (WInput
*in
);
147 void input_set_point (WInput
*in
, int pos
);
148 void input_show_cursor (WInput
*in
);
149 void assign_text (WInput
*in
, const char *text
);
150 cb_ret_t
input_callback (Widget
*, widget_msg_t msg
, int parm
);
153 void label_set_text (WLabel
*label
, const char *text
);
156 void gauge_set_value (WGauge
*g
, int max
, int current
);
157 void gauge_show (WGauge
*g
, int shown
);
160 const char *button_get_text (WButton
*b
);
161 void button_set_text (WButton
*b
, const char *text
);
163 /* Listbox manager */
164 WLEntry
*listbox_get_data (WListbox
*l
, int pos
);
166 /* search text int listbox entries */
167 WLEntry
*listbox_search_text (WListbox
*l
, const char *text
);
168 void listbox_select_entry (WListbox
*l
, WLEntry
*dest
);
169 void listbox_select_by_number (WListbox
*l
, int n
);
170 void listbox_select_last (WListbox
*l
, int set_top
);
171 void listbox_remove_current (WListbox
*l
, int force
);
172 void listbox_remove_list (WListbox
*l
);
173 void listbox_get_current (WListbox
*l
, char **string
, char **extra
);
176 LISTBOX_APPEND_AT_END
, /* append at the end */
177 LISTBOX_APPEND_BEFORE
, /* insert before current */
178 LISTBOX_APPEND_AFTER
, /* insert after current */
179 LISTBOX_APPEND_SORTED
/* insert alphabetically */
182 char *listbox_add_item (WListbox
*l
, enum append_pos pos
, int
183 hotkey
, const char *text
, void *data
);
185 /* Hintbar routines */
189 typedef void (*voidfn
)(void);
190 typedef void (*buttonbarfn
)(void *);
192 typedef struct WButtonBar WButtonBar
;
194 WButtonBar
*buttonbar_new (int visible
);
195 WButtonBar
*find_buttonbar (Dlg_head
*h
);
196 void buttonbar_clear_label (Dlg_head
*, int idx
);
197 void buttonbar_set_label (Dlg_head
*, int index
, const char *text
, voidfn
);
198 void buttonbar_set_label_data (Dlg_head
*h
, int idx
, const char *text
,
199 buttonbarfn cback
, void *data
);
200 void buttonbar_set_visible (WButtonBar
*, gboolean
);
201 void buttonbar_redraw (Dlg_head
*h
);