Ticket #1414: ScalableUI.patch
File ScalableUI.patch, 20.7 KB (added by E.L.K., 15 years ago) |
---|
-
src/dialog.c
diff --git a/src/dialog.c b/src/dialog.c index 4fd409c..06336ce 100644
a b common_dialog_repaint (struct Dlg_head *h) 183 183 } 184 184 } 185 185 186 /* this function allows to set dialog position */ 187 void 188 dialog_set_position(Dlg_head *h, int y1, int x1, int y2, int x2) 189 { 190 /* save old positions, will be used to reposition childs */ 191 int ox = h->x; 192 int oy = h->y; 193 int oc = h->cols; 194 int ol = h->lines; 195 196 h->x = x1; 197 h->y = y1; 198 h->lines = y2 - y1; 199 h->cols = x2 - x1; 200 201 /* values by which controls should be moved */ 202 int shift_x = h->x - ox; 203 int shift_y = h->y - oy; 204 int scale_x = h->cols - oc; 205 int scale_y = h->lines - ol; 206 207 if ((shift_x != 0) 208 || (shift_y != 0) 209 || (scale_x != 0) 210 || (scale_y != 0)){ 211 212 Widget *c = h->current; 213 214 do { 215 216 /* there are, mainly, 2 generally possible 217 situations: 218 219 1. control sticks to one side - it 220 should be moved 221 222 2. control sticks to two sides of 223 one direction - it should be sized */ 224 225 int x = c->x; 226 int y = c->y; 227 int cols = c->cols; 228 int lines = c->lines; 229 230 if ((c->pos_flags & WPOS_KEEP_LEFT) && (c->pos_flags & WPOS_KEEP_RIGHT)) { 231 x += shift_x; 232 cols += scale_x; 233 } else if (c->pos_flags & WPOS_KEEP_LEFT){ 234 x += shift_x; 235 } else if (c->pos_flags & WPOS_KEEP_RIGHT){ 236 x += shift_x + scale_x; 237 } 238 239 if ((c->pos_flags & WPOS_KEEP_TOP) && (c->pos_flags & WPOS_KEEP_BOTTOM)) { 240 y += shift_y; 241 lines += scale_y; 242 } else if (c->pos_flags & WPOS_KEEP_TOP){ 243 y += shift_y; 244 } else if (c->pos_flags & WPOS_KEEP_BOTTOM){ 245 y += shift_y + scale_y; 246 } 247 248 widget_set_size(c, y, x, lines, cols); 249 /* widget_set_size(c, c->y + wpos_top, c->x + wpos_left, c->lines, c->cols); widget_set_size(c, c->y + wpos_top, c->x + wpos_left, c->lines, c->cols); */ 250 251 c = c->next; 252 } while (h->current != c); 253 } 254 } 255 256 /* this function sets only size, leaving positioning to automatic methods */ 257 void 258 dialog_set_size(Dlg_head *h, int lines, int cols){ 259 260 int x = h->x; 261 int y = h->y; 262 263 if (h->flags & DLG_CENTER) { 264 y = (LINES - lines) / 2; 265 x = (COLS - cols) / 2; 266 } 267 268 if ((h->flags & DLG_TRYUP) && (y > 3)) 269 y -= 2; 270 271 dialog_set_position(h, y, x, y + lines, x + cols); 272 273 } 274 186 275 /* Default dialog callback */ 187 276 cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm) 188 277 { … … cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm) 192 281 common_dialog_repaint (h); 193 282 return MSG_HANDLED; 194 283 } 284 195 285 if (msg == DLG_IDLE){ 196 286 dlg_broadcast_msg_to (h, WIDGET_IDLE, 0, W_WANT_IDLE); 197 287 return MSG_HANDLED; 198 288 } 289 290 /* this is default resizing mechanism */ 291 if (msg == DLG_RESIZE){ 292 /* the main idea of this code is to resize dialog 293 according to flags (if any of flags require automatic 294 resizing, like DLG_CENTER, end after that reposition 295 controls in dialog according to flags of widget) */ 296 297 dialog_set_size(h, h->lines, h->cols); 298 299 return MSG_HANDLED; 300 } 301 199 302 return MSG_NOT_HANDLED; 200 303 } 201 304 … … create_dlg (int y1, int x1, int lines, int cols, const int *color_set, 223 326 new_d->cols = cols; 224 327 new_d->lines = lines; 225 328 new_d->flags = flags; 329 new_d->dlg_data = NULL; 226 330 227 331 /* Strip existing spaces, add one space before and after the title */ 228 332 if (title) { … … set_idle_proc (Dlg_head *d, int enable) 244 348 d->flags &= ~DLG_WANT_IDLE; 245 349 } 246 350 351 /* wrapper to simply add lefttop positioned controls */ 352 int 353 add_widget (Dlg_head *h, void *w){ 354 add_widget_autopos(h, w, WPOS_KEEP_LEFT | WPOS_KEEP_TOP); 355 } 356 247 357 /* 248 358 * Insert widget to dialog before current widget. For dialogs populated 249 359 * from the bottom, make the widget current. Return widget number. 250 360 */ 251 361 int 252 add_widget (Dlg_head *h, void *w)362 add_widget_autopos (Dlg_head *h, void *w, int pos_flags) 253 363 { 254 364 Widget *widget = (Widget *) w; 255 365 … … add_widget (Dlg_head *h, void *w) 257 367 if (!widget || h->running) 258 368 abort (); 259 369 370 widget->pos_flags = pos_flags; 260 371 widget->x += h->x; 261 372 widget->y += h->y; 262 373 widget->parent = h; -
src/dialog.h
diff --git a/src/dialog.h b/src/dialog.h index 919e866..cab7e19 100644
a b typedef struct Dlg_head { 115 115 dlg_cb_fn callback; 116 116 struct Dlg_head *parent; /* Parent dialog */ 117 117 118 void *dlg_data; /* data can be passed to dialog */ 119 118 120 } Dlg_head; 119 121 120 122 … … struct Widget { 139 141 callback_fn callback; 140 142 mouse_h mouse; 141 143 struct Dlg_head *parent; 144 int pos_flags; /* repositioning flags */ 142 145 }; 143 146 144 147 /* draw box in window */ … … void draw_double_box (Dlg_head *h, int y, int x, int ys, int xs); 156 159 #define DLG_CENTER (1 << 0) /* Center the dialog */ 157 160 #define DLG_NONE (000000) /* No options */ 158 161 162 163 /* Flags for widget repositioning on dialog resize */ 164 #define WPOS_KEEP_LEFT (1 << 0) /* keep widget distance to left border of dialog */ 165 #define WPOS_KEEP_RIGHT (1 << 1) /* keep widget distance to right border of dialog */ 166 #define WPOS_KEEP_TOP (1 << 2) /* keep widget distance to top border of dialog */ 167 #define WPOS_KEEP_BOTTOM (1 << 3) /* keep widget distance to bottom border of dialog */ 168 #define WPOS_KEEP_ALL WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT | WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM 169 #define WPOS_KEEP_HORZ WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT 170 #define WPOS_KEEP_VERT WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM 171 172 173 /* sets size of dialog, leaving positioning to automatic mehtods 174 according to dialog flags */ 175 void dialog_set_size(Dlg_head *h, int lines, int cols); 176 177 /* this function allows to set dialog position */ 178 void dialog_set_position(Dlg_head *h, int y1, int x1, int y2, int x2); 179 159 180 /* Creates a dialog head */ 160 181 Dlg_head *create_dlg (int y1, int x1, int lines, int cols, 161 182 const int *color_set, dlg_cb_fn callback, 162 183 const char *help_ctx, const char *title, int flags); 163 int add_widget (Dlg_head *dest, void *Widget); 184 185 int add_widget_autopos (Dlg_head *dest, void *Widget, int pos_flags); 186 int add_widget (Dlg_head *dest, void *Widget); /* temp wrapper w/o last arg */ 164 187 165 188 /* Runs dialog d */ 166 189 int run_dlg (Dlg_head *d); -
src/hotlist.c
diff --git a/src/hotlist.c b/src/hotlist.c index dd8dd04..b4133dd 100644
a b static struct _hotlist_but { 121 121 int ret_cmd, flags, y, x; 122 122 const char *text; 123 123 int type; 124 int pos_flags; 124 125 } hotlist_but[] = { 125 { B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST },126 { B_REMOVE, NORMAL_BUTTON, 1, 30, N_("&Remove"), LIST_HOTLIST },127 { B_APPEND, NORMAL_BUTTON, 1, 15, N_("&Append"), LIST_MOVELIST },128 { B_INSERT, NORMAL_BUTTON, 1, 0, N_("&Insert"), LIST_MOVELIST },129 { B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &Entry"), LIST_HOTLIST },130 { B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &Group"), LIST_HOTLIST },131 { B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST },132 { B_UP_GROUP, NORMAL_BUTTON, 0, 42, N_("&Up"), LIST_HOTLIST|LIST_MOVELIST },133 { B_ADD_CURRENT, NORMAL_BUTTON, 0, 20, N_("&Add current"), LIST_HOTLIST },126 { B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 127 { B_REMOVE, NORMAL_BUTTON, 1, 30, N_("&Remove"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 128 { B_APPEND, NORMAL_BUTTON, 1, 15, N_("&Append"), LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 129 { B_INSERT, NORMAL_BUTTON, 1, 0, N_("&Insert"), LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 130 { B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &Entry"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 131 { B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &Group"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 132 { B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST, WPOS_KEEP_RIGHT | WPOS_KEEP_BOTTOM }, 133 { B_UP_GROUP, NORMAL_BUTTON, 0, 42, N_("&Up"), LIST_HOTLIST|LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 134 { B_ADD_CURRENT, NORMAL_BUTTON, 0, 20, N_("&Add current"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 134 135 #ifdef USE_VFS 135 { B_REFRESH_VFS, NORMAL_BUTTON, 0, 43, N_("&Refresh"), LIST_VFSLIST },136 { B_FREE_ALL_VFS, NORMAL_BUTTON, 0, 20, N_("Fr&ee VFSs now"), LIST_VFSLIST },136 { B_REFRESH_VFS, NORMAL_BUTTON, 0, 43, N_("&Refresh"), LIST_VFSLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 137 { B_FREE_ALL_VFS, NORMAL_BUTTON, 0, 20, N_("Fr&ee VFSs now"), LIST_VFSLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 137 138 #endif 138 { B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST },139 { B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, 139 140 }; 140 141 141 142 /* Directory hotlist */ … … hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm) 473 474 } 474 475 return MSG_NOT_HANDLED; 475 476 477 case DLG_RESIZE: 478 /* simply call dialog_set_size with new size */ 479 dialog_set_size(h, LINES - 2, COLS - 6); 480 return MSG_HANDLED; 481 476 482 case DLG_POST_KEY: 477 483 if (hotlist_state.moving) 478 484 dlg_select_widget (l_movelist); … … hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm) 481 487 /* always stay on hotlist */ 482 488 /* fall through */ 483 489 490 484 491 case DLG_INIT: 485 492 attrset (MENU_ENTRY_COLOR); 486 493 update_path_name (); … … init_hotlist (int list_type) 629 636 630 637 for (i = 0; i < BUTTONS; i++) { 631 638 if (hotlist_but[i].type & list_type) 632 add_widget (hotlist_dlg, 633 button_new (BY + hotlist_but[i].y, 634 BX + hotlist_but[i].x, 635 hotlist_but[i].ret_cmd, 636 hotlist_but[i].flags, 637 hotlist_but[i].text, 638 hotlist_button_callback)); 639 add_widget_autopos (hotlist_dlg, 640 button_new (BY + hotlist_but[i].y, 641 BX + hotlist_but[i].x, 642 hotlist_but[i].ret_cmd, 643 hotlist_but[i].flags, 644 hotlist_but[i].text, 645 hotlist_button_callback), 646 hotlist_but[i].pos_flags); 639 647 } 640 648 641 649 /* We add the labels. … … init_hotlist (int list_type) 643 651 * pname_group will hold name of current group 644 652 */ 645 653 pname = label_new (UY - 11 + LINES, UX + 2, ""); 646 add_widget (hotlist_dlg, pname);654 add_widget_autopos (hotlist_dlg, pname, WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT); 647 655 if (!hotlist_state.moving) { 648 add_widget (hotlist_dlg, 649 label_new (UY - 12 + LINES, UX + 1, 650 _(" Directory path "))); 656 add_widget_autopos (hotlist_dlg, 657 label_new (UY - 12 + LINES, UX + 1, 658 _(" Directory path ")), 659 WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT); 651 660 652 661 /* This one holds the displayed pathname */ 653 662 pname_group = label_new (UY, UX + 1, _(" Directory label ")); 654 add_widget (hotlist_dlg, pname_group); 663 add_widget_autopos (hotlist_dlg, pname_group, 664 WPOS_KEEP_TOP | WPOS_KEEP_LEFT); 655 665 } 656 666 /* get new listbox */ 657 667 l_hotlist = … … init_hotlist (int list_type) 667 677 #endif /* !USE_VFS */ 668 678 fill_listbox (); 669 679 670 add_widget (hotlist_dlg, l_hotlist);680 add_widget_autopos (hotlist_dlg, l_hotlist, WPOS_KEEP_ALL); 671 681 /* add listbox to the dialogs */ 672 682 } 673 683 -
src/layout.c
diff --git a/src/layout.c b/src/layout.c index e801a99..6c3a4b7 100644
a b change_screen_size (void) 796 796 #endif 797 797 setup_panels (); 798 798 799 /* Inform currently running dialog */ 800 (*current_dlg->callback) (current_dlg, DLG_RESIZE, 0); 799 800 /* Inform all running dialogs */ 801 Dlg_head *d = current_dlg; 802 while (d != 0) { 803 (*d->callback) (d, DLG_RESIZE, 0); 804 d = d->parent; 805 } 806 801 807 802 808 #ifdef RESIZABLE_MENUBAR 803 809 menubar_arrange (the_menubar); -
src/main.c
diff --git a/src/main.c b/src/main.c index e9c0830..b0c5cb2 100644
a b directory_history_list (WPanel *panel) 701 701 if (!panel->dir_history) 702 702 return; 703 703 704 s = show_hist (panel->dir_history, panel->widget.x, panel->widget.y);704 s = show_hist (panel->dir_history, &panel->widget); 705 705 706 706 if (!s) 707 707 return; -
src/slint.c
diff --git a/src/slint.c b/src/slint.c index 1ab4631..9e4624c 100644
a b 48 48 #include "setup.h" 49 49 #include "background.h" /* we_are_background */ 50 50 51 #include "layout.h" /* for winch_flag */ 52 51 53 #ifdef HAVE_SLANG 52 54 53 55 /* Taken from S-Lang's slutty.c */ … … getch (void) 480 482 } 481 483 #endif /* HAVE_SLANG */ 482 484 485 486 static void 487 perform_refresh() 488 { 489 if (winch_flag != 0) { 490 /* if winch was caugth, we should do not only redraw screen, but 491 reposition/resize all */ 492 change_screen_size(); 493 } else { 494 refresh(); 495 } 496 } 497 483 498 void 484 499 mc_refresh (void) 485 500 { 486 501 #ifdef WITH_BACKGROUND 487 if (!we_are_background) 502 if (!we_are_background) 488 503 #endif /* WITH_BACKGROUND */ 489 refresh ();504 perform_refresh (); 490 505 } -
src/widget.c
diff --git a/src/widget.c b/src/widget.c index bc2fda6..af89410 100644
a b listbox_fwd (WListbox *l) 1011 1011 return MSG_NOT_HANDLED; 1012 1012 } 1013 1013 1014 struct dlg_hist_data{ 1015 Widget *panel_widget; 1016 int count; 1017 size_t maxlen; 1018 }; 1019 1020 static cb_ret_t 1021 dlg_hist_reposition(Dlg_head *dlg_head) 1022 { 1023 /* guard checks */ 1024 if (!dlg_head) 1025 return MSG_NOT_HANDLED; 1026 1027 if (!dlg_head->dlg_data) 1028 return MSG_NOT_HANDLED; 1029 1030 struct dlg_hist_data *data = (struct dlg_hist_data *)dlg_head->dlg_data; 1031 1032 int x, y, he, wi; 1033 y = data->panel_widget->y; 1034 he = data->count + 2; 1035 1036 if (he <= y || y > (LINES - 6)) { 1037 he = min (he, y - 1); 1038 y -= he; 1039 } else { 1040 y++; 1041 he = min (he, LINES - y); 1042 } 1043 1044 if (data->panel_widget->x > 2) 1045 x = data->panel_widget->x - 2; 1046 else 1047 x = 0; 1048 1049 wi = data->maxlen + 4; 1050 if ((wi + x) > COLS) { 1051 wi = min (wi, COLS); 1052 x = COLS - wi; 1053 } 1054 1055 dialog_set_position(dlg_head, y, x, y + he, x + wi); 1056 } 1057 1058 static cb_ret_t 1059 dlg_hist_callback (Dlg_head *h, dlg_msg_t msg, int parm) 1060 { 1061 switch (msg) { 1062 1063 case DLG_RESIZE: 1064 return dlg_hist_reposition(h); 1065 1066 default: 1067 return default_dlg_callback (h, msg, parm); 1068 } 1069 } 1070 1071 1014 1072 char * 1015 show_hist (GList *history, int widget_x, int widget_y)1073 show_hist (GList *history, Widget *panel_widget) 1016 1074 { 1017 1075 GList *hi, *z; 1018 1076 size_t maxlen = str_term_width1 (i18n_htitle ()), i, count = 0; … … show_hist (GList *history, int widget_x, int widget_y) 1034 1092 hi = g_list_next (hi); 1035 1093 } 1036 1094 1037 y = widget_y; 1038 h = count + 2; 1039 if (h <= y || y > LINES - 6) { 1040 h = min (h, y - 1); 1041 y -= h; 1042 } else { 1043 y++; 1044 h = min (h, LINES - y); 1045 } 1046 1047 if (widget_x > 2) 1048 x = widget_x - 2; 1049 else 1050 x = 0; 1051 if ((w = maxlen + 4) + x > COLS) { 1052 w = min (w, COLS); 1053 x = COLS - w; 1054 } 1095 struct dlg_hist_data hist_data; 1096 hist_data.maxlen = maxlen; 1097 hist_data.panel_widget = panel_widget; 1098 hist_data.count = count; 1055 1099 1056 1100 query_dlg = 1057 create_dlg (y, x, h, w, dialog_colors, NULL, "[History-query]", 1058 i18n_htitle (), DLG_COMPACT); 1059 query_list = listbox_new (1, 1, h - 2, w - 2, NULL); 1060 add_widget (query_dlg, query_list); 1101 create_dlg (0, 0, 4, 4, dialog_colors, dlg_hist_callback, 1102 "[History-query]", i18n_htitle (), DLG_COMPACT); 1103 1104 query_dlg->dlg_data = &hist_data; 1105 1106 query_list = listbox_new (1, 1, 2, 2, 0); 1107 1108 /* this call makes list stick to all sides of dialog, effectively make 1109 it be resized with dialog */ 1110 add_widget_autopos (query_dlg, query_list, WPOS_KEEP_ALL); 1111 1112 /* to avoid diplicating of (calculating sizes in two places) 1113 code, call dlg_hist_callback function here, to set dialog and 1114 controls positions. 1115 1116 The main idea - create 4x4 dialog and add 2x2 list in 1117 center of it, and let dialog function resize it to needed 1118 size. */ 1119 1120 dlg_hist_callback(query_dlg, DLG_RESIZE, 0); 1121 1061 1122 hi = z; 1062 if ( y < widget_y) {1123 if (query_dlg->y < panel_widget->y) { 1063 1124 /* traverse */ 1064 1125 while (hi) { 1065 1126 listbox_add_item (query_list, 0, 0, (char *) hi->data, NULL); … … show_hist (GList *history, int widget_x, int widget_y) 1088 1149 static void do_show_hist (WInput * in) 1089 1150 { 1090 1151 char *r; 1091 r = show_hist (in->history, in->widget.x, in->widget.y);1152 r = show_hist (in->history, &in->widget); 1092 1153 if (r) { 1093 1154 assign_text (in, r); 1094 1155 g_free (r); … … listbox_callback (Widget *w, widget_msg_t msg, int parm) 2196 2257 (*h->callback) (h, DLG_ACTION, l->pos); 2197 2258 return MSG_HANDLED; 2198 2259 2260 case WIDGET_RESIZED: 2261 l->width = w->cols; 2262 l->height = w->lines; 2263 return MSG_HANDLED; 2264 2199 2265 case WIDGET_FOCUS: 2200 2266 case WIDGET_UNFOCUS: 2201 2267 case WIDGET_DRAW: -
src/widget.h
diff --git a/src/widget.h b/src/widget.h index d986f9f..e016469 100644
a b typedef struct WGauge { 92 92 93 93 GList *history_get (const char *input_name); 94 94 void history_put (const char *input_name, GList *h); 95 char *show_hist (GList *history, int widget_y, int widget_x); 95 96 // for repositioning of history dialog we should pass panel widget to this 97 // function, as position of history dialog depends on panel widget's 98 // position 99 char *show_hist (GList *history, Widget *panel_widget); 96 100 97 101 typedef struct { 98 102 Widget widget; -
src/wtools.c
diff --git a/src/wtools.c b/src/wtools.c index 4a2c95d..d59384d 100644
a b int run_listbox (Listbox *l) 100 100 return val; 101 101 } 102 102 103 /* default query callback, used to reposition query */ 104 cb_ret_t default_query_callback (Dlg_head *h, dlg_msg_t msg, int parm) 105 { 106 if (msg == DLG_RESIZE) { 107 108 int xpos = COLS / 2 - h->cols / 2; 109 int ypos = LINES / 3 - (h->lines - 3) / 2; 110 111 /* set position */ 112 dialog_set_position(h, ypos, xpos, ypos + h->lines, xpos + h->cols); 113 return MSG_HANDLED; 114 } 115 return default_dlg_callback(h, msg, parm); 116 } 103 117 104 118 static Dlg_head *last_query_dlg; 105 119 … … query_dialog (const char *header, const char *text, int flags, int count, ...) 116 130 int win_len = 0; 117 131 int i; 118 132 int result = -1; 119 int xpos, ypos;120 133 int cols, lines; 121 134 char *cur_name; 122 135 static const int *query_colors; … … query_dialog (const char *header, const char *text, int flags, int count, ...) 145 158 str_msg_term_size (text, &lines, &cols); 146 159 cols = 6 + max (win_len, max (str_term_width1 (header), cols)); 147 160 lines += 4 + (count > 0 ? 2 : 0); 148 xpos = COLS / 2 - cols / 2;149 ypos = LINES / 3 - (lines - 3) / 2;150 161 151 162 /* prepare dialog */ 152 163 query_dlg = 153 create_dlg ( ypos, xpos, lines, cols, query_colors, NULL,164 create_dlg (0, 0, lines, cols, query_colors, default_query_callback, 154 165 "[QueryBox]", header, DLG_NONE); 155 166 156 167 if (count > 0) { … … query_dialog (const char *header, const char *text, int flags, int count, ...) 158 169 va_start (ap, count); 159 170 for (i = 0; i < count; i++) { 160 171 cur_name = va_arg (ap, char *); 161 xpos = str_term_width1 (cur_name) + 6;172 int xpos = str_term_width1 (cur_name) + 6; 162 173 if (strchr (cur_name, '&') != NULL) 163 174 xpos--; 164 175 … … query_dialog (const char *header, const char *text, int flags, int count, ...) 174 185 175 186 add_widget (query_dlg, label_new (2, 3, text)); 176 187 188 /* do resize before running and selecting any widget*/ 189 default_query_callback(query_dlg, DLG_RESIZE, 0); 190 177 191 if (defbutton) 178 192 dlg_select_widget (defbutton); 179 193 … … do_create_message (int flags, const char *title, const char *text) 215 229 p = g_strconcat ("\n", text, "\n", (char *) NULL); 216 230 query_dialog (title, p, flags, 0); 217 231 d = last_query_dlg; 232 233 /* do resize before initing and running*/ 234 default_query_callback(d, DLG_RESIZE, 0); 235 218 236 init_dlg (d); 219 237 g_free (p); 220 238