7 /* Please note that the first element in all the widgets is a */
8 /* widget variable of type Widget. We abuse this fact everywhere */
11 #define HIDDEN_BUTTON 0
12 #define NARROW_BUTTON 1
13 #define NORMAL_BUTTON 2
14 #define DEFPUSH_BUTTON 3
16 typedef struct WButton
{
18 int action
; /* what to do when pressed */
19 int selected
; /* button state */
20 unsigned int flags
; /* button flags */
21 char *text
; /* text of button */
22 int hotkey
; /* hot KEY */
23 int hotpos
; /* offset hot KEY char in text */
24 int (*callback
)(int, void*); /* Callback function */
28 typedef struct WRadio
{
30 unsigned int state
; /* radio button state */
32 int count
; /* number of members */
33 char **texts
; /* texts of labels */
34 int upper_letter_is_hotkey
; /* If true, then the capital letter is a hk */
37 typedef struct WCheck
{
39 unsigned int state
; /* check button state */
40 char *text
; /* text of check button */
41 int hotkey
; /* hot KEY */
42 int hotpos
; /* offset hot KEY char in text */
45 typedef struct WGauge
{
50 int pixels
; /* Only used for Tk:
51 * We keep the pixel size in the C code
52 * so that we can compute quickly compute
53 * the size of the rectangle in the Tk
54 * canvas. Using Tcl would be too slow.
58 typedef struct hist_entry
{
59 struct hist_entry
*prev
;
60 struct hist_entry
*next
;
64 Hist
*history_get (char *input_name
);
65 void history_put (char *input_name
, Hist
*h
);
66 char *show_hist (Hist
*history
, int widget_y
, int widget_x
);
70 int point
; /* cursor position in the input line */
71 int mark
; /* The mark position */
72 int first_shown
; /* Index of the first shown character */
73 int current_max_len
; /* Maximum length of input line */
74 int field_len
; /* Length of the editing field */
75 int color
; /* color used */
76 int first
; /* Is first keystroke? */
77 int disable_update
; /* Do we want to skip updates? */
78 int is_password
; /* Is this a password input line? */
79 unsigned char *buffer
; /* pointer to editing buffer */
80 Hist
*history
; /* The history */
81 int need_push
; /* need to push the current Input on hist? */
82 char **completions
; /* Possible completions array */
83 int completion_flags
; /* INPUT_COMPLETE* bitwise flags(complete.h) */
84 int inserted_one
; /* TK: just one char inserted, nothing fancy */
85 char *history_name
; /* name of history for loading and saving */
88 /* For history load-save functions */
89 #define INPUT_LAST_TEXT ((char *) 2)
90 #define HISTORY_FILE_NAME ".mc/history"
94 int auto_adjust_cols
; /* compute widget.cols from strlen(text)? */
96 int transparent
; /* Paint in the default color fg/bg */
99 typedef struct WLEntry
{
100 char *text
; /* Text to display */
102 void *data
; /* Client information */
103 struct WLEntry
*next
;
104 struct WLEntry
*prev
;
108 listbox_begin
, listbox_end
109 } /* listbox_insert */;
111 /* Listbox actions when selecting an option: */
114 listbox_finish
, /* finish dialog */
115 listbox_cback
/* call the callback routine */
116 } /* listbox_action */;
118 typedef int (*lcback
) (void *);
122 WLEntry
*list
; /* Pointer to the circular double linked list. */
123 WLEntry
*top
; /* The first element displayed */
124 WLEntry
*current
; /* The current element displayed */
125 int pos
; /* Cur. pos, must be kept in sync with current */
126 int count
; /* Number of items in the listbox */
128 int height
; /* Size of the widget */
129 int action
; /* Action type */
130 int allow_duplicates
; /* Do we allow duplicates on the list? */
131 int scrollbar
; /* Draw a scrollbar? */
132 lcback cback
; /* The callback function */
133 int cursor_x
, cursor_y
; /* Cache the values */
136 typedef void (*buttonbarfn
)(void *);
140 int visible
; /* Is it visible? */
143 buttonbarfn function
;
149 WButton
*button_new (int y
, int x
, int action
, int flags
, char *text
,
150 int (*callback
)(int, void *), void *extra
, char *tkname
);
151 WRadio
*radio_new (int y
, int x
, int count
, char **text
, int use_hotkey
, char *tkname
);
152 WCheck
*check_new (int y
, int x
, int state
, char *text
, char *tkname
);
153 WInput
*input_new (int y
, int x
, int color
, int len
, const char *text
, char *tkname
);
154 WLabel
*label_new (int y
, int x
, const char *text
, char *tkname
);
155 WGauge
*gauge_new (int y
, int x
, int shown
, int max
, int current
, char *tkname
);
156 WListbox
*listbox_new (int x
, int y
, int width
, int height
, int action
,
157 lcback
, char *tkname
);
160 void winput_set_origin (WInput
*i
, int x
, int field_len
);
161 int handle_char (WInput
*in
, int c_code
);
162 int is_in_input_map (WInput
*in
, int c_code
);
163 void update_input (WInput
*in
, int clear_first
);
164 void new_input (WInput
*in
);
165 int push_history (WInput
*in
, char *text
);
166 void stuff (WInput
*in
, char *text
, int insert_extra_space
);
167 void input_disable_update (WInput
*in
);
168 void input_set_prompt (WInput
*in
, int field_len
, char *prompt
);
169 void input_enable_update (WInput
*in
);
170 void input_set_point (WInput
*in
, int pos
);
171 void input_show_cursor (WInput
*in
);
172 void assign_text (WInput
*in
, char *text
);
175 void label_set_text (WLabel
*label
, char *text
);
178 void gauge_set_value (WGauge
*g
, int max
, int current
);
179 void gauge_show (WGauge
*g
, int shown
);
182 void button_set_text (WButton
*b
, char *text
);
184 /* Listbox manager */
185 WLEntry
*listbox_get_data (WListbox
*l
, int pos
);
187 /* search text int listbox entries */
188 WLEntry
*listbox_search_text (WListbox
*l
, char *text
);
189 void listbox_select_entry (WListbox
*l
, WLEntry
*dest
);
190 void listbox_select_by_number (WListbox
*l
, int n
);
191 void listbox_select_last (WListbox
*l
, int set_top
);
192 void listbox_remove_current (WListbox
*l
, int force
);
193 void listbox_remove_list (WListbox
*l
);
194 void listbox_get_current (WListbox
*l
, char **string
, char **extra
);
197 LISTBOX_APPEND_AT_END
, /* append at the end */
198 LISTBOX_APPEND_BEFORE
, /* insert before current */
199 LISTBOX_APPEND_AFTER
/* insert after current */
202 char *listbox_add_item (WListbox
*l
, enum append_pos pos
, int
203 hotkey
, char *text
, void *data
);
205 /* Hintbar routines */
207 /* Buttonbar routines */
208 WButtonBar
*buttonbar_new (int visible
);
209 typedef void (*voidfn
)(void);
210 void define_label (Dlg_head
*, Widget
*paneletc
, int index
, char *text
, voidfn
);
211 void define_label_data (Dlg_head
*h
, Widget
*paneletc
, int idx
, char *text
,
212 buttonbarfn cback
, void *data
);
213 void redraw_labels (Dlg_head
*h
, Widget
*paneletc
);
214 void buttonbar_hint (WButtonBar
*bb
, char *s
);
216 #endif /* __WIDGET_H */