1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

big dialogs: Refactoring. do not pass the term.

This commit is contained in:
Witold Filipczyk 2008-09-07 18:27:06 +02:00 committed by Witold Filipczyk
parent ca073bf5ca
commit 1b589beb81
12 changed files with 26 additions and 22 deletions

View File

@ -115,10 +115,11 @@ buttons_width(struct widget_data *widget_data, int n,
}
void
dlg_format_buttons(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_buttons(struct dialog_data *dlg_data,
struct widget_data *widget_data, int n,
int x, int *y, int w, int *rw, enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
int i1 = 0;
while (i1 < n) {

View File

@ -49,6 +49,6 @@ void add_dlg_button_do(struct dialog *dlg, unsigned char *text, int flags, widge
#endif
extern const struct widget_ops button_ops;
void dlg_format_buttons(struct terminal *, struct dialog_data *, struct widget_data *, int, int, int *, int, int *, enum format_align, int);
void dlg_format_buttons(struct dialog_data *, struct widget_data *, int, int, int *, int, int *, enum format_align, int);
#endif

View File

@ -36,11 +36,12 @@ add_dlg_radio_do(struct dialog *dlg, unsigned char *text,
}
void
dlg_format_checkbox(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_checkbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw,
enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
unsigned char *text = widget_data->widget->text;
set_box(&widget_data->box, x, *y, CHECKBOX_LEN, CHECKBOX_HEIGHT);

View File

@ -31,7 +31,7 @@ void add_dlg_radio_do(struct dialog *dlg, unsigned char *text, int groupid, int
extern const struct widget_ops checkbox_ops;
void
dlg_format_checkbox(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_checkbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw,
enum format_align align, int format_only);

View File

@ -581,12 +581,12 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
switch (wdata->widget->type) {
case WIDGET_FIELD_PASS:
case WIDGET_FIELD:
dlg_format_field(term, dlg_data, wdata, x, y, w, rw, ALIGN_LEFT,
dlg_format_field(dlg_data, wdata, x, y, w, rw, ALIGN_LEFT,
format_only);
break;
case WIDGET_LISTBOX:
dlg_format_listbox(term, dlg_data, wdata, x, y, w, h, rw,
dlg_format_listbox(dlg_data, wdata, x, y, w, h, rw,
ALIGN_LEFT, format_only);
break;
@ -610,7 +610,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
break;
}
dlg_format_group(term, dlg_data, wdata, size, x, y, w, rw,
dlg_format_group(dlg_data, wdata, size, x, y, w, rw,
format_only);
wdata += size - 1;
@ -618,7 +618,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
/* No horizontal space between checkboxes belonging to
* the same group. */
dlg_format_checkbox(term, dlg_data, wdata, x, y, w, rw,
dlg_format_checkbox(dlg_data, wdata, x, y, w, rw,
ALIGN_LEFT, format_only);
if (widgets > 1
&& group == widget_has_group(&wdata[1]))
@ -630,7 +630,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
/* We assume that the buttons are all stuffed at the very end
* of the dialog. */
case WIDGET_BUTTON:
dlg_format_buttons(term, dlg_data, wdata, widgets,
dlg_format_buttons(dlg_data, wdata, widgets,
x, y, w, rw, ALIGN_CENTER, format_only);
return;
}

View File

@ -20,10 +20,11 @@
#define CHECKBOX_LEN 3 /* "[X]" or "(X)" */
void
dlg_format_group(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_group(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int n, int x, int *y, int w, int *rw, int format_only)
{
struct terminal *term = dlg_data->win->term;
int space_between_widgets = 1;
int line_width = 0;
int xpos;
@ -155,11 +156,11 @@ group_layouter(struct dialog_data *dlg_data)
#endif /* CONFIG_UTF8 */
rw = int_min(w, strlen(dlg_data->dlg->title));
dlg_format_group(term, dlg_data, dlg_data->widgets_data, n,
dlg_format_group(dlg_data, dlg_data->widgets_data, n,
0, &y, w, &rw, 1);
y++;
dlg_format_buttons(term, dlg_data, dlg_data->widgets_data + n, 2, 0, &y, w,
dlg_format_buttons(dlg_data, dlg_data->widgets_data + n, 2, 0, &y, w,
&rw, ALIGN_CENTER, 1);
w = rw;
@ -167,10 +168,10 @@ group_layouter(struct dialog_data *dlg_data)
draw_dialog(dlg_data, w, y);
y = dlg_data->box.y + DIALOG_TB + 1;
dlg_format_group(term, dlg_data, dlg_data->widgets_data, n,
dlg_format_group(dlg_data, dlg_data->widgets_data, n,
dlg_data->box.x + DIALOG_LB, &y, w, NULL, 0);
y++;
dlg_format_buttons(term, dlg_data, dlg_data->widgets_data + n, 2,
dlg_format_buttons(dlg_data, dlg_data->widgets_data + n, 2,
dlg_data->box.x + DIALOG_LB, &y, w, &rw, ALIGN_CENTER, 0);
}

View File

@ -5,7 +5,7 @@ struct dialog_data;
struct terminal;
struct widget_data;
void dlg_format_group(struct terminal *term, struct dialog_data *dlg_data,
void dlg_format_group(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int n, int x, int *y, int w, int *rw, int format_only);

View File

@ -103,10 +103,11 @@ check_nonempty(struct dialog_data *dlg_data, struct widget_data *widget_data)
}
void
dlg_format_field(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_field(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw, enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
static int max_label_width;
static int *prev_y; /* Assert the uniqueness of y */ /* TODO: get rid of this !! --Zas */
unsigned char *label = widget_data->widget->text;
@ -765,7 +766,7 @@ input_line_layouter(struct dialog_data *dlg_data)
- ses->status.show_status_bar
- ses->status.show_tabs_bar;
dlg_format_field(win->term, dlg_data, dlg_data->widgets_data, 0,
dlg_format_field(dlg_data, dlg_data->widgets_data, 0,
&y, win->term->width, NULL, ALIGN_LEFT, 0);
}

View File

@ -62,7 +62,7 @@ extern const struct widget_ops field_pass_ops;
widget_handler_status_T check_number(struct dialog_data *, struct widget_data *);
widget_handler_status_T check_nonempty(struct dialog_data *, struct widget_data *);
void dlg_format_field(struct terminal *, struct dialog_data *, struct widget_data *, int, int *, int, int *, enum format_align, int format_only);
void dlg_format_field(struct dialog_data *, struct widget_data *, int, int *, int, int *, enum format_align, int format_only);
void input_field(struct terminal *, struct memory_list *, int, unsigned char *,
unsigned char *, unsigned char *, unsigned char *, void *,

View File

@ -41,7 +41,7 @@ get_listbox_widget_data(struct widget_data *widget_data)
/* Layout for generic boxes */
void
dlg_format_listbox(struct terminal *term, struct dialog_data *dlg_data,
dlg_format_listbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int max_height, int *rw,
enum format_align align, int format_only)

View File

@ -133,7 +133,7 @@ struct listbox_item {
extern const struct widget_ops listbox_ops;
void dlg_format_listbox(struct terminal *, struct dialog_data *, struct widget_data *, int, int *, int, int, int *, enum format_align, int format_only);
void dlg_format_listbox(struct dialog_data *, struct widget_data *, int, int *, int, int, int *, enum format_align, int format_only);
struct listbox_item *traverse_listbox_items_list(struct listbox_item *, struct listbox_data *, int, int, int (*)(struct listbox_item *, void *, int *), void *);

View File

@ -170,7 +170,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
dialog_text_color, ALIGN_LEFT, 1);
y++;
dlg_format_buttons(term, dlg_data, dlg_data->widgets_data,
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
dlg_data->number_of_widgets, 0, &y, w,
&rw, ALIGN_CENTER, 1);
@ -211,7 +211,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
dialog_text_color, ALIGN_LEFT, 0);
y++;
dlg_format_buttons(term, dlg_data, dlg_data->widgets_data,
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
dlg_data->number_of_widgets, x, &y, w,
NULL, ALIGN_CENTER, 0);