comparison src/gui.c @ 811:d2c169a725c8

updated for version 7.0c01
author vimboss
date Mon, 27 Mar 2006 20:55:21 +0000
parents 9f345c48220b
children 23f82b5d2814
comparison
equal deleted inserted replaced
810:9f345c48220b 811:d2c169a725c8
519 gui.shell_created = TRUE; 519 gui.shell_created = TRUE;
520 520
521 #ifndef FEAT_GUI_GTK 521 #ifndef FEAT_GUI_GTK
522 /* Set the shell size, adjusted for the screen size. For GTK this only 522 /* Set the shell size, adjusted for the screen size. For GTK this only
523 * works after the shell has been opened, thus it is further down. */ 523 * works after the shell has been opened, thus it is further down. */
524 gui_set_shellsize(FALSE, TRUE); 524 gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
525 #endif 525 #endif
526 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) 526 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
527 /* Need to set the size of the menubar after all the menus have been 527 /* Need to set the size of the menubar after all the menus have been
528 * created. */ 528 * created. */
529 gui_mch_compute_menu_height((Widget)0); 529 gui_mch_compute_menu_height((Widget)0);
545 #endif 545 #endif
546 #if defined(FEAT_GUI_GTK) 546 #if defined(FEAT_GUI_GTK)
547 /* Give GTK+ a chance to put all widget's into place. */ 547 /* Give GTK+ a chance to put all widget's into place. */
548 gui_mch_update(); 548 gui_mch_update();
549 /* Now make sure the shell fits on the screen. */ 549 /* Now make sure the shell fits on the screen. */
550 gui_set_shellsize(FALSE, TRUE); 550 gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
551 #endif 551 #endif
552 /* When 'lines' was set while starting up the topframe may have to be 552 /* When 'lines' was set while starting up the topframe may have to be
553 * resized. */ 553 * resized. */
554 win_new_shellsize(); 554 win_new_shellsize();
555 555
739 #ifdef MSWIN 739 #ifdef MSWIN
740 TRUE 740 TRUE
741 #else 741 #else
742 FALSE 742 FALSE
743 #endif 743 #endif
744 ); 744 , RESIZE_BOTH);
745 } 745 }
746 746
747 return ret; 747 return ret;
748 } 748 }
749 749
1352 * If "fit_to_display" is TRUE then the size may be reduced to fit the window 1352 * If "fit_to_display" is TRUE then the size may be reduced to fit the window
1353 * on the screen. 1353 * on the screen.
1354 */ 1354 */
1355 /*ARGSUSED*/ 1355 /*ARGSUSED*/
1356 void 1356 void
1357 gui_set_shellsize(mustset, fit_to_display) 1357 gui_set_shellsize(mustset, fit_to_display, direction)
1358 int mustset; /* set by the user */ 1358 int mustset; /* set by the user */
1359 int fit_to_display; 1359 int fit_to_display;
1360 int direction; /* RESIZE_HOR, RESIZE_VER */
1360 { 1361 {
1361 int base_width; 1362 int base_width;
1362 int base_height; 1363 int base_height;
1363 int width; 1364 int width;
1364 int height; 1365 int height;
1397 } 1398 }
1398 1399
1399 if (fit_to_display) 1400 if (fit_to_display)
1400 { 1401 {
1401 gui_mch_get_screen_dimensions(&screen_w, &screen_h); 1402 gui_mch_get_screen_dimensions(&screen_w, &screen_h);
1402 if (width > screen_w) 1403 if ((direction & RESIZE_HOR) && width > screen_w)
1403 { 1404 {
1404 Columns = (screen_w - base_width) / gui.char_width; 1405 Columns = (screen_w - base_width) / gui.char_width;
1405 if (Columns < MIN_COLUMNS) 1406 if (Columns < MIN_COLUMNS)
1406 Columns = MIN_COLUMNS; 1407 Columns = MIN_COLUMNS;
1407 width = Columns * gui.char_width + base_width; 1408 width = Columns * gui.char_width + base_width;
1408 } 1409 }
1409 if (height > screen_h) 1410 if ((direction & RESIZE_VERT) && height > screen_h)
1410 { 1411 {
1411 Rows = (screen_h - base_height) / gui.char_height; 1412 Rows = (screen_h - base_height) / gui.char_height;
1412 check_shellsize(); 1413 check_shellsize();
1413 height = Rows * gui.char_height + base_height; 1414 height = Rows * gui.char_height + base_height;
1414 } 1415 }
1421 # ifdef FEAT_WINDOWS 1422 # ifdef FEAT_WINDOWS
1422 min_height += tabline_height() * gui.char_height; 1423 min_height += tabline_height() * gui.char_height;
1423 # endif 1424 # endif
1424 1425
1425 gui_mch_set_shellsize(width, height, min_width, min_height, 1426 gui_mch_set_shellsize(width, height, min_width, min_height,
1426 base_width, base_height); 1427 base_width, base_height, direction);
1427 if (fit_to_display) 1428 if (fit_to_display)
1428 { 1429 {
1429 int x, y; 1430 int x, y;
1430 1431
1431 /* Some window managers put the Vim window left of/above the screen. */ 1432 /* Some window managers put the Vim window left of/above the screen. */
3085 add_long_to_buf((long_u)menu, bytes); 3086 add_long_to_buf((long_u)menu, bytes);
3086 add_to_input_buf_csi(bytes, sizeof(long_u)); 3087 add_to_input_buf_csi(bytes, sizeof(long_u));
3087 } 3088 }
3088 #endif 3089 #endif
3089 3090
3090 #ifndef FEAT_WINDOWS 3091 static int prev_which_scrollbars[3];
3091 static int prev_which_scrollbars[3];
3092 #endif
3093 3092
3094 /* 3093 /*
3095 * Set which components are present. 3094 * Set which components are present.
3096 * If "oldval" is not NULL, "oldval" is the previous value, the new value is 3095 * If "oldval" is not NULL, "oldval" is the previous value, the new value is
3097 * in p_go. 3096 * in p_go.
3201 break; 3200 break;
3202 } 3201 }
3203 3202
3204 if (gui.in_use) 3203 if (gui.in_use)
3205 { 3204 {
3206 need_set_size = FALSE; 3205 need_set_size = 0;
3207 fix_size = FALSE; 3206 fix_size = FALSE;
3208 3207
3209 #ifdef FEAT_GUI_TABLINE 3208 #ifdef FEAT_GUI_TABLINE
3210 /* Update the GUI tab line, it may appear or disappear. This may 3209 /* Update the GUI tab line, it may appear or disappear. This may
3211 * cause the non-GUI tab line to disappear or appear. */ 3210 * cause the non-GUI tab line to disappear or appear. */
3215 /* We don't want a resize event change "Rows" here, save and 3214 /* We don't want a resize event change "Rows" here, save and
3216 * restore it. Resizing is handled below. */ 3215 * restore it. Resizing is handled below. */
3217 i = Rows; 3216 i = Rows;
3218 gui_update_tabline(); 3217 gui_update_tabline();
3219 Rows = i; 3218 Rows = i;
3220 need_set_size = TRUE; 3219 need_set_size = RESIZE_VERT;
3221 if (using_tabline) 3220 if (using_tabline)
3222 fix_size = TRUE; 3221 fix_size = TRUE;
3223 if (!gui_use_tabline()) 3222 if (!gui_use_tabline())
3224 redraw_tabline = TRUE; /* may draw non-GUI tab line */ 3223 redraw_tabline = TRUE; /* may draw non-GUI tab line */
3225 } 3224 }
3226 #endif 3225 #endif
3227 3226
3228 for (i = 0; i < 3; i++) 3227 for (i = 0; i < 3; i++)
3229 { 3228 {
3230 if (gui.which_scrollbars[i] != 3229 /* The scrollbar needs to be updated when it is shown/unshown and
3230 * when switching tab pages. But the size only changes when it's
3231 * shown/unshown. Thus we need two places to remember whether a
3232 * scrollbar is there or not. */
3233 if (gui.which_scrollbars[i] != prev_which_scrollbars[i]
3231 #ifdef FEAT_WINDOWS 3234 #ifdef FEAT_WINDOWS
3232 curtab->tp_prev_which_scrollbars[i] 3235 || gui.which_scrollbars[i]
3233 #else 3236 != curtab->tp_prev_which_scrollbars[i]
3234 prev_which_scrollbars[i]
3235 #endif 3237 #endif
3236 ) 3238 )
3237 { 3239 {
3238 if (i == SBAR_BOTTOM) 3240 if (i == SBAR_BOTTOM)
3239 gui_mch_enable_scrollbar(&gui.bottom_sbar, 3241 gui_mch_enable_scrollbar(&gui.bottom_sbar,
3243 FOR_ALL_WINDOWS(wp) 3245 FOR_ALL_WINDOWS(wp)
3244 { 3246 {
3245 gui_do_scrollbar(wp, i, gui.which_scrollbars[i]); 3247 gui_do_scrollbar(wp, i, gui.which_scrollbars[i]);
3246 } 3248 }
3247 } 3249 }
3248 need_set_size = TRUE; 3250 if (gui.which_scrollbars[i] != prev_which_scrollbars[i])
3249 if (gui.which_scrollbars[i]) 3251 {
3250 fix_size = TRUE; 3252 if (i == SBAR_BOTTOM)
3253 need_set_size = RESIZE_VERT;
3254 else
3255 need_set_size = RESIZE_HOR;
3256 if (gui.which_scrollbars[i])
3257 fix_size = TRUE;
3258 }
3251 } 3259 }
3252 #ifdef FEAT_WINDOWS 3260 #ifdef FEAT_WINDOWS
3253 curtab->tp_prev_which_scrollbars[i] 3261 curtab->tp_prev_which_scrollbars[i] = gui.which_scrollbars[i];
3254 #else 3262 #endif
3255 prev_which_scrollbars[i] 3263 prev_which_scrollbars[i] = gui.which_scrollbars[i];
3256 #endif
3257 = gui.which_scrollbars[i];
3258 } 3264 }
3259 3265
3260 #ifdef FEAT_MENU 3266 #ifdef FEAT_MENU
3261 if (gui.menu_is_active != prev_menu_is_active) 3267 if (gui.menu_is_active != prev_menu_is_active)
3262 { 3268 {
3264 * restore it. Resizing is handled below. */ 3270 * restore it. Resizing is handled below. */
3265 i = Rows; 3271 i = Rows;
3266 gui_mch_enable_menu(gui.menu_is_active); 3272 gui_mch_enable_menu(gui.menu_is_active);
3267 Rows = i; 3273 Rows = i;
3268 prev_menu_is_active = gui.menu_is_active; 3274 prev_menu_is_active = gui.menu_is_active;
3269 need_set_size = TRUE; 3275 need_set_size = RESIZE_VERT;
3270 if (gui.menu_is_active) 3276 if (gui.menu_is_active)
3271 fix_size = TRUE; 3277 fix_size = TRUE;
3272 } 3278 }
3273 #endif 3279 #endif
3274 3280
3275 #ifdef FEAT_TOOLBAR 3281 #ifdef FEAT_TOOLBAR
3276 if (using_toolbar != prev_toolbar) 3282 if (using_toolbar != prev_toolbar)
3277 { 3283 {
3278 gui_mch_show_toolbar(using_toolbar); 3284 gui_mch_show_toolbar(using_toolbar);
3279 prev_toolbar = using_toolbar; 3285 prev_toolbar = using_toolbar;
3280 need_set_size = TRUE; 3286 need_set_size = RESIZE_VERT;
3281 if (using_toolbar) 3287 if (using_toolbar)
3282 fix_size = TRUE; 3288 fix_size = TRUE;
3283 } 3289 }
3284 #endif 3290 #endif
3285 #ifdef FEAT_FOOTER 3291 #ifdef FEAT_FOOTER
3286 if (using_footer != prev_footer) 3292 if (using_footer != prev_footer)
3287 { 3293 {
3288 gui_mch_enable_footer(using_footer); 3294 gui_mch_enable_footer(using_footer);
3289 prev_footer = using_footer; 3295 prev_footer = using_footer;
3290 need_set_size = TRUE; 3296 need_set_size = RESIZE_VERT;
3291 if (using_footer) 3297 if (using_footer)
3292 fix_size = TRUE; 3298 fix_size = TRUE;
3293 } 3299 }
3294 #endif 3300 #endif
3295 #if defined(FEAT_MENU) && !defined(WIN16) && !(defined(WIN3264) && !defined(FEAT_TEAROFF)) 3301 #if defined(FEAT_MENU) && !defined(WIN16) && !(defined(WIN3264) && !defined(FEAT_TEAROFF))
3305 long c = Columns; 3311 long c = Columns;
3306 #endif 3312 #endif
3307 /* Adjust the size of the window to make the text area keep the 3313 /* Adjust the size of the window to make the text area keep the
3308 * same size and to avoid that part of our window is off-screen 3314 * same size and to avoid that part of our window is off-screen
3309 * and a scrollbar can't be used, for example. */ 3315 * and a scrollbar can't be used, for example. */
3310 gui_set_shellsize(FALSE, fix_size); 3316 gui_set_shellsize(FALSE, fix_size, need_set_size);
3311 3317
3312 #ifdef FEAT_GUI_GTK 3318 #ifdef FEAT_GUI_GTK
3313 /* GTK has the annoying habit of sending us resize events when 3319 /* GTK has the annoying habit of sending us resize events when
3314 * changing the window size ourselves. This mostly happens when 3320 * changing the window size ourselves. This mostly happens when
3315 * waiting for a character to arrive, quite unpredictably, and may 3321 * waiting for a character to arrive, quite unpredictably, and may
3377 gui_mch_update_tabline(); 3383 gui_mch_update_tabline();
3378 3384
3379 /* When the tabs change from hidden to shown or from shown to 3385 /* When the tabs change from hidden to shown or from shown to
3380 * hidden the size of the text area should remain the same. */ 3386 * hidden the size of the text area should remain the same. */
3381 if (!showit != !shown) 3387 if (!showit != !shown)
3382 gui_set_shellsize(FALSE, showit); 3388 gui_set_shellsize(FALSE, showit, RESIZE_VERT);
3383 } 3389 }
3384 } 3390 }
3385 3391
3386 /* 3392 /*
3387 * Get the label for tab page "tp" into NameBuff[]. 3393 * Get the label for tab page "tp" into NameBuff[].