4 #include "dlg.h" /* Widget */
9 /* Please note that the first element in all the widgets is a */
10 /* widget variable of type Widget. We abuse this fact everywhere */
12 #define HIDDEN_BUTTON 0
13 #define NARROW_BUTTON 1
14 #define NORMAL_BUTTON 2
15 #define DEFPUSH_BUTTON 3
17 typedef struct WButton
{
19 int action
; /* what to do when pressed */
20 int selected
; /* button state */
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 int (*callback
)(int, void*); /* Callback function */
29 typedef struct WRadio
{
31 unsigned int state
; /* radio button state */
33 int count
; /* number of members */
34 char **texts
; /* texts of labels */
35 int upper_letter_is_hotkey
; /* If true, then the capital letter is a hk */
38 typedef struct WCheck
{
40 unsigned int state
; /* check button state */
41 char *text
; /* text of check button */
42 int hotkey
; /* hot KEY */
43 int hotpos
; /* offset hot KEY char in text */
46 typedef struct WGauge
{
53 GList
*history_get (char *input_name
);
54 void history_put (char *input_name
, GList
*h
);
55 char *show_hist (GList
*history
, int widget_y
, int widget_x
);
59 int point
; /* cursor position in the input line */
60 int mark
; /* The mark position */
61 int first_shown
; /* Index of the first shown character */
62 int current_max_len
; /* Maximum length of input line */
63 int field_len
; /* Length of the editing field */
64 int color
; /* color used */
65 int first
; /* Is first keystroke? */
66 int disable_update
; /* Do we want to skip updates? */
67 int is_password
; /* Is this a password input line? */
68 unsigned char *buffer
; /* pointer to editing buffer */
69 GList
*history
; /* The history */
70 int need_push
; /* need to push the current Input on hist? */
71 char **completions
; /* Possible completions array */
72 int completion_flags
; /* INPUT_COMPLETE* bitwise flags(complete.h) */
73 char *history_name
; /* name of history for loading and saving */
76 /* For history load-save functions */
77 #define INPUT_LAST_TEXT ((char *) 2)
78 #define HISTORY_FILE_NAME ".mc/history"
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 listbox_begin
, listbox_end
97 } /* listbox_insert */;
99 /* Listbox actions when selecting an option: */
102 listbox_finish
, /* finish dialog */
103 listbox_cback
/* call the callback routine */
104 } /* listbox_action */;
106 typedef int (*lcback
) (void *);
108 typedef struct WListbox
{
110 WLEntry
*list
; /* Pointer to the circular double linked list. */
111 WLEntry
*top
; /* The first element displayed */
112 WLEntry
*current
; /* The current element displayed */
113 int pos
; /* Cur. pos, must be kept in sync with current */
114 int count
; /* Number of items in the listbox */
116 int height
; /* Size of the widget */
117 int action
; /* Action type */
118 int allow_duplicates
; /* Do we allow duplicates on the list? */
119 int scrollbar
; /* Draw a scrollbar? */
120 lcback cback
; /* The callback function */
121 int cursor_x
, cursor_y
; /* Cache the values */
124 typedef void (*buttonbarfn
)(void *);
128 int visible
; /* Is it visible? */
131 buttonbarfn function
;
137 WButton
*button_new (int y
, int x
, int action
, int flags
, char *text
,
138 int (*callback
)(int, void *), void *extra
, char *tkname
);
139 WRadio
*radio_new (int y
, int x
, int count
, char **text
, int use_hotkey
, char *tkname
);
140 WCheck
*check_new (int y
, int x
, int state
, char *text
, char *tkname
);
141 WInput
*input_new (int y
, int x
, int color
, int len
, const char *text
, char *tkname
);
142 WLabel
*label_new (int y
, int x
, const char *text
, char *tkname
);
143 WGauge
*gauge_new (int y
, int x
, int shown
, int max
, int current
, char *tkname
);
144 WListbox
*listbox_new (int x
, int y
, int width
, int height
, int action
,
145 lcback
, char *tkname
);
148 void winput_set_origin (WInput
*i
, int x
, int field_len
);
149 int handle_char (WInput
*in
, int c_code
);
150 int is_in_input_map (WInput
*in
, int c_code
);
151 void update_input (WInput
*in
, int clear_first
);
152 void new_input (WInput
*in
);
153 int push_history (WInput
*in
, char *text
);
154 void stuff (WInput
*in
, char *text
, int insert_extra_space
);
155 void input_disable_update (WInput
*in
);
156 void input_set_prompt (WInput
*in
, int field_len
, char *prompt
);
157 void input_enable_update (WInput
*in
);
158 void input_set_point (WInput
*in
, int pos
);
159 void input_show_cursor (WInput
*in
);
160 void assign_text (WInput
*in
, char *text
);
161 int input_callback (WInput
*in
, int Msg
, int Par
);
164 void label_set_text (WLabel
*label
, char *text
);
167 void gauge_set_value (WGauge
*g
, int max
, int current
);
168 void gauge_show (WGauge
*g
, int shown
);
171 void button_set_text (WButton
*b
, char *text
);
173 /* Listbox manager */
174 WLEntry
*listbox_get_data (WListbox
*l
, int pos
);
176 /* search text int listbox entries */
177 WLEntry
*listbox_search_text (WListbox
*l
, char *text
);
178 void listbox_select_entry (WListbox
*l
, WLEntry
*dest
);
179 void listbox_select_by_number (WListbox
*l
, int n
);
180 void listbox_select_last (WListbox
*l
, int set_top
);
181 void listbox_remove_current (WListbox
*l
, int force
);
182 void listbox_remove_list (WListbox
*l
);
183 void listbox_get_current (WListbox
*l
, char **string
, char **extra
);
186 LISTBOX_APPEND_AT_END
, /* append at the end */
187 LISTBOX_APPEND_BEFORE
, /* insert before current */
188 LISTBOX_APPEND_AFTER
/* insert after current */
191 char *listbox_add_item (WListbox
*l
, enum append_pos pos
, int
192 hotkey
, char *text
, void *data
);
194 /* Hintbar routines */
196 /* Buttonbar routines */
197 WButtonBar
*buttonbar_new (int visible
);
198 WButtonBar
*find_buttonbar (Dlg_head
*h
);
199 typedef void (*voidfn
)(void);
200 void define_label (Dlg_head
*, int index
, char *text
, voidfn
);
201 void define_label_data (Dlg_head
*h
, int idx
, char *text
,
202 buttonbarfn cback
, void *data
);
203 void redraw_labels (Dlg_head
*h
);
204 void buttonbar_hint (WButtonBar
*bb
, char *s
);
206 #endif /* __WIDGET_H */