From 1b589beb813e64981a21508f1eb3a9710891dbee Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 7 Sep 2008 18:27:06 +0200 Subject: [PATCH] big dialogs: Refactoring. do not pass the term. --- src/bfu/button.c | 3 ++- src/bfu/button.h | 2 +- src/bfu/checkbox.c | 3 ++- src/bfu/checkbox.h | 2 +- src/bfu/dialog.c | 10 +++++----- src/bfu/group.c | 11 ++++++----- src/bfu/group.h | 2 +- src/bfu/inpfield.c | 5 +++-- src/bfu/inpfield.h | 2 +- src/bfu/listbox.c | 2 +- src/bfu/listbox.h | 2 +- src/dialogs/download.c | 4 ++-- 12 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/bfu/button.c b/src/bfu/button.c index 3616c9b7..0f3ccdfc 100644 --- a/src/bfu/button.c +++ b/src/bfu/button.c @@ -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) { diff --git a/src/bfu/button.h b/src/bfu/button.h index 3f00b264..d6ed7d2c 100644 --- a/src/bfu/button.h +++ b/src/bfu/button.h @@ -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 diff --git a/src/bfu/checkbox.c b/src/bfu/checkbox.c index 25107ecc..5dd58db2 100644 --- a/src/bfu/checkbox.c +++ b/src/bfu/checkbox.c @@ -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); diff --git a/src/bfu/checkbox.h b/src/bfu/checkbox.h index b4e65ce7..f18faeef 100644 --- a/src/bfu/checkbox.h +++ b/src/bfu/checkbox.h @@ -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); diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index 85afd0a6..c53949f1 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -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; } diff --git a/src/bfu/group.c b/src/bfu/group.c index 655df96b..4d404b9f 100644 --- a/src/bfu/group.c +++ b/src/bfu/group.c @@ -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); } diff --git a/src/bfu/group.h b/src/bfu/group.h index 9b92c2a0..bd284500 100644 --- a/src/bfu/group.h +++ b/src/bfu/group.h @@ -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); diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index 5e25c425..4a1bd43a 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -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); } diff --git a/src/bfu/inpfield.h b/src/bfu/inpfield.h index fb2270e9..eca314a3 100644 --- a/src/bfu/inpfield.h +++ b/src/bfu/inpfield.h @@ -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 *, diff --git a/src/bfu/listbox.c b/src/bfu/listbox.c index c4a4160d..851b2c11 100644 --- a/src/bfu/listbox.c +++ b/src/bfu/listbox.c @@ -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) diff --git a/src/bfu/listbox.h b/src/bfu/listbox.h index 63b8be44..ca1d06b5 100644 --- a/src/bfu/listbox.h +++ b/src/bfu/listbox.h @@ -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 *); diff --git a/src/dialogs/download.c b/src/dialogs/download.c index 3be1d57e..e1c81c3b 100644 --- a/src/dialogs/download.c +++ b/src/dialogs/download.c @@ -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); -- 2.11.4.GIT