Mercurial > emacs
comparison src/gtkutil.c @ 51211:28ea05de2dc5
Make (many) trivial substitutions for renamed and
new macros in dispextern.h, frame.h and window.h.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sat, 24 May 2003 22:09:34 +0000 |
parents | f30e6f029d65 |
children | 8f1bed1dee3c |
comparison
equal
deleted
inserted
replaced
51210:491ca5acf5b3 | 51211:28ea05de2dc5 |
---|---|
32 #include "gtkutil.h" | 32 #include "gtkutil.h" |
33 #include "termhooks.h" | 33 #include "termhooks.h" |
34 #include <gdk/gdkkeysyms.h> | 34 #include <gdk/gdkkeysyms.h> |
35 | 35 |
36 #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ | 36 #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ |
37 (PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) | 37 (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) |
38 | 38 |
39 | 39 |
40 | 40 |
41 /*********************************************************************** | 41 /*********************************************************************** |
42 Utility functions | 42 Utility functions |
235 F is the frame we shall set geometry for. */ | 235 F is the frame we shall set geometry for. */ |
236 static void | 236 static void |
237 xg_set_geometry (f) | 237 xg_set_geometry (f) |
238 FRAME_PTR f; | 238 FRAME_PTR f; |
239 { | 239 { |
240 if (f->output_data.x->size_hint_flags & USPosition) | 240 if (f->size_hint_flags & USPosition) |
241 { | 241 { |
242 int left = f->output_data.x->left_pos; | 242 int left = f->left_pos; |
243 int xneg = f->output_data.x->size_hint_flags & XNegative; | 243 int xneg = f->size_hint_flags & XNegative; |
244 int top = f->output_data.x->top_pos; | 244 int top = f->top_pos; |
245 int yneg = f->output_data.x->size_hint_flags & YNegative; | 245 int yneg = f->size_hint_flags & YNegative; |
246 char geom_str[32]; | 246 char geom_str[32]; |
247 | 247 |
248 if (xneg) | 248 if (xneg) |
249 left = -left; | 249 left = -left; |
250 if (yneg) | 250 if (yneg) |
251 top = -top; | 251 top = -top; |
252 | 252 |
253 sprintf (geom_str, "=%dx%d%c%d%c%d", | 253 sprintf (geom_str, "=%dx%d%c%d%c%d", |
254 PIXEL_WIDTH (f), | 254 FRAME_PIXEL_WIDTH (f), |
255 FRAME_TOTAL_PIXEL_HEIGHT (f), | 255 FRAME_TOTAL_PIXEL_HEIGHT (f), |
256 (xneg ? '-' : '+'), left, | 256 (xneg ? '-' : '+'), left, |
257 (yneg ? '-' : '+'), top); | 257 (yneg ? '-' : '+'), top); |
258 | 258 |
259 if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 259 if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
271 FRAME_PTR f; | 271 FRAME_PTR f; |
272 int columns; | 272 int columns; |
273 int rows; | 273 int rows; |
274 { | 274 { |
275 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 275 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
276 PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f)); | 276 FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f)); |
277 | 277 |
278 /* base_height is now changed. */ | 278 /* base_height is now changed. */ |
279 x_wm_set_size_hint (f, 0, 0); | 279 x_wm_set_size_hint (f, 0, 0); |
280 | 280 |
281 /* If we are not mapped yet, set geometry once again, as window | 281 /* If we are not mapped yet, set geometry once again, as window |
315 FRAME_PTR f; | 315 FRAME_PTR f; |
316 int pixelwidth, pixelheight; | 316 int pixelwidth, pixelheight; |
317 { | 317 { |
318 int mbheight = FRAME_MENUBAR_HEIGHT (f); | 318 int mbheight = FRAME_MENUBAR_HEIGHT (f); |
319 int tbheight = FRAME_TOOLBAR_HEIGHT (f); | 319 int tbheight = FRAME_TOOLBAR_HEIGHT (f); |
320 int rows = PIXEL_TO_CHAR_HEIGHT (f, pixelheight - mbheight - tbheight); | 320 int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (pixelheight |
321 int columns = PIXEL_TO_CHAR_WIDTH (f, pixelwidth); | 321 - mbheight - tbheight)); |
322 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth); | |
322 | 323 |
323 if (FRAME_GTK_WIDGET (f) | 324 if (FRAME_GTK_WIDGET (f) |
324 && (columns != FRAME_WIDTH (f) || rows != FRAME_HEIGHT (f) | 325 && (columns != FRAME_COLS (f) || rows != FRAME_LINES (f) |
325 || pixelwidth != PIXEL_WIDTH (f) || pixelheight != PIXEL_HEIGHT (f))) | 326 || pixelwidth != FRAME_PIXEL_WIDTH (f) || pixelheight != FRAME_PIXEL_HEIGHT (f))) |
326 { | 327 { |
327 struct x_output *x = f->output_data.x; | 328 struct x_output *x = f->output_data.x; |
328 GtkAllocation all; | 329 GtkAllocation all; |
329 | 330 |
330 all.y = mbheight + tbheight; | 331 all.y = mbheight + tbheight; |
347 xg_frame_set_char_size (f, cols, rows) | 348 xg_frame_set_char_size (f, cols, rows) |
348 FRAME_PTR f; | 349 FRAME_PTR f; |
349 int cols; | 350 int cols; |
350 int rows; | 351 int rows; |
351 { | 352 { |
352 int pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows) | 353 int pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) |
353 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); | 354 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); |
354 int pixelwidth; | 355 int pixelwidth; |
355 | 356 |
356 /* Take into account the size of the scroll bar. Always use the | 357 /* Take into account the size of the scroll bar. Always use the |
357 number of columns occupied by the scroll bar here otherwise we | 358 number of columns occupied by the scroll bar here otherwise we |
358 might end up with a frame width that is not a multiple of the | 359 might end up with a frame width that is not a multiple of the |
359 frame's character width which is bad for vertically split | 360 frame's character width which is bad for vertically split |
360 windows. */ | 361 windows. */ |
361 f->output_data.x->vertical_scroll_bar_extra | 362 f->scroll_bar_actual_width |
362 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) | 363 = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); |
363 ? 0 | |
364 : (FRAME_SCROLL_BAR_COLS (f) | |
365 * FONT_WIDTH (f->output_data.x->font))); | |
366 | 364 |
367 compute_fringe_widths (f, 0); | 365 compute_fringe_widths (f, 0); |
368 | 366 |
369 /* CHAR_TO_PIXEL_WIDTH uses vertical_scroll_bar_extra, so call it | 367 /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it |
370 after calculating that value. */ | 368 after calculating that value. */ |
371 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols); | 369 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); |
372 | 370 |
373 /* Must resize our top level widget. Font size may have changed, | 371 /* Must resize our top level widget. Font size may have changed, |
374 but not rows/cols. */ | 372 but not rows/cols. */ |
375 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 373 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
376 pixelwidth, pixelheight); | 374 pixelwidth, pixelheight); |
509 FRAME_GTK_WIDGET (f) = wfixed; | 507 FRAME_GTK_WIDGET (f) = wfixed; |
510 f->output_data.x->vbox_widget = wvbox; | 508 f->output_data.x->vbox_widget = wvbox; |
511 | 509 |
512 gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE); | 510 gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE); |
513 | 511 |
514 gtk_widget_set_size_request (wfixed, | 512 gtk_widget_set_size_request (wfixed, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f)); |
515 PIXEL_WIDTH (f), | |
516 PIXEL_HEIGHT (f)); | |
517 | 513 |
518 gtk_container_add (GTK_CONTAINER (wtop), wvbox); | 514 gtk_container_add (GTK_CONTAINER (wtop), wvbox); |
519 gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0); | 515 gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0); |
520 | 516 |
521 if (FRAME_EXTERNAL_TOOL_BAR (f)) | 517 if (FRAME_EXTERNAL_TOOL_BAR (f)) |
592 /* Must use g_strdup because gtk_widget_modify_style does g_free. */ | 588 /* Must use g_strdup because gtk_widget_modify_style does g_free. */ |
593 style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>"); | 589 style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>"); |
594 gtk_widget_modify_style (wfixed, style); | 590 gtk_widget_modify_style (wfixed, style); |
595 | 591 |
596 /* GTK does not set any border, and they look bad with GTK. */ | 592 /* GTK does not set any border, and they look bad with GTK. */ |
597 f->output_data.x->border_width = 0; | 593 f->border_width = 0; |
598 f->output_data.x->internal_border_width = 0; | 594 f->internal_border_width = 0; |
599 | 595 |
600 UNBLOCK_INPUT; | 596 UNBLOCK_INPUT; |
601 | 597 |
602 return 1; | 598 return 1; |
603 } | 599 } |
619 to its own defaults. */ | 615 to its own defaults. */ |
620 GdkGeometry size_hints; | 616 GdkGeometry size_hints; |
621 gint hint_flags = 0; | 617 gint hint_flags = 0; |
622 int base_width, base_height; | 618 int base_width, base_height; |
623 int min_rows = 0, min_cols = 0; | 619 int min_rows = 0, min_cols = 0; |
624 int win_gravity = f->output_data.x->win_gravity; | 620 int win_gravity = f->win_gravity; |
625 | 621 |
626 if (flags) | 622 if (flags) |
627 { | 623 { |
628 memset (&size_hints, 0, sizeof (size_hints)); | 624 memset (&size_hints, 0, sizeof (size_hints)); |
629 f->output_data.x->size_hints = size_hints; | 625 f->output_data.x->size_hints = size_hints; |
630 f->output_data.x->hint_flags = hint_flags; | 626 f->output_data.x->hint_flags = hint_flags; |
631 } | 627 } |
632 else | 628 else |
633 flags = f->output_data.x->size_hint_flags; | 629 flags = f->size_hint_flags; |
634 | 630 |
635 size_hints = f->output_data.x->size_hints; | 631 size_hints = f->output_data.x->size_hints; |
636 hint_flags = f->output_data.x->hint_flags; | 632 hint_flags = f->output_data.x->hint_flags; |
637 | 633 |
638 hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE; | 634 hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE; |
639 size_hints.width_inc = FONT_WIDTH (f->output_data.x->font); | 635 size_hints.width_inc = FRAME_COLUMN_WIDTH (f); |
640 size_hints.height_inc = f->output_data.x->line_height; | 636 size_hints.height_inc = FRAME_LINE_HEIGHT (f); |
641 | 637 |
642 hint_flags |= GDK_HINT_BASE_SIZE; | 638 hint_flags |= GDK_HINT_BASE_SIZE; |
643 base_width = CHAR_TO_PIXEL_WIDTH (f, 0); | 639 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); |
644 base_height = CHAR_TO_PIXEL_HEIGHT (f, 0) | 640 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) |
645 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); | 641 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); |
646 | 642 |
647 check_frame_size (f, &min_rows, &min_cols); | 643 check_frame_size (f, &min_rows, &min_cols); |
648 | 644 |
649 size_hints.base_width = base_width; | 645 size_hints.base_width = base_width; |
2296 | 2292 |
2297 FRAME_MENUBAR_HEIGHT (f) = req.height; | 2293 FRAME_MENUBAR_HEIGHT (f) = req.height; |
2298 | 2294 |
2299 /* The height has changed, resize outer widget and set columns | 2295 /* The height has changed, resize outer widget and set columns |
2300 rows to what we had before adding the menu bar. */ | 2296 rows to what we had before adding the menu bar. */ |
2301 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 2297 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
2302 | 2298 |
2303 SET_FRAME_GARBAGED (f); | 2299 SET_FRAME_GARBAGED (f); |
2304 UNBLOCK_INPUT; | 2300 UNBLOCK_INPUT; |
2305 | 2301 |
2306 return 1; | 2302 return 1; |
2325 x->menubar_widget = 0; | 2321 x->menubar_widget = 0; |
2326 FRAME_MENUBAR_HEIGHT (f) = 0; | 2322 FRAME_MENUBAR_HEIGHT (f) = 0; |
2327 | 2323 |
2328 /* The height has changed, resize outer widget and set columns | 2324 /* The height has changed, resize outer widget and set columns |
2329 rows to what we had before removing the menu bar. */ | 2325 rows to what we had before removing the menu bar. */ |
2330 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 2326 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
2331 | 2327 |
2332 SET_FRAME_GARBAGED (f); | 2328 SET_FRAME_GARBAGED (f); |
2333 UNBLOCK_INPUT; | 2329 UNBLOCK_INPUT; |
2334 } | 2330 } |
2335 } | 2331 } |
2733 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll)); | 2729 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll)); |
2734 | 2730 |
2735 /* We do the same as for MOTIF in xterm.c, assume 30 chars per line | 2731 /* We do the same as for MOTIF in xterm.c, assume 30 chars per line |
2736 rather than the real portion value. This makes the thumb less likely | 2732 rather than the real portion value. This makes the thumb less likely |
2737 to resize and that looks better. */ | 2733 to resize and that looks better. */ |
2738 portion = XFASTINT (XWINDOW (bar->window)->height) * 30; | 2734 portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30; |
2739 /* When the thumb is at the bottom, position == whole. | 2735 /* When the thumb is at the bottom, position == whole. |
2740 So we need to increase `whole' to make space for the thumb. */ | 2736 So we need to increase `whole' to make space for the thumb. */ |
2741 whole += portion; | 2737 whole += portion; |
2742 | 2738 |
2743 if (whole <= 0) | 2739 if (whole <= 0) |
2755 value = top * XG_SB_RANGE; | 2751 value = top * XG_SB_RANGE; |
2756 value = min (value, XG_SB_MAX - size); | 2752 value = min (value, XG_SB_MAX - size); |
2757 value = max (value, XG_SB_MIN); | 2753 value = max (value, XG_SB_MIN); |
2758 | 2754 |
2759 /* Assume all lines are of equal size. */ | 2755 /* Assume all lines are of equal size. */ |
2760 new_step = size / max (1, FRAME_HEIGHT (f)); | 2756 new_step = size / max (1, FRAME_LINES (f)); |
2761 | 2757 |
2762 if ((int) adj->page_size != size | 2758 if ((int) adj->page_size != size |
2763 || (int) adj->step_increment != new_step) | 2759 || (int) adj->step_increment != new_step) |
2764 { | 2760 { |
2765 adj->page_size = size; | 2761 adj->page_size = size; |
2855 int bw = gtk_container_get_border_width (GTK_CONTAINER (wbox)); | 2851 int bw = gtk_container_get_border_width (GTK_CONTAINER (wbox)); |
2856 FRAME_TOOLBAR_HEIGHT (f) = 2; | 2852 FRAME_TOOLBAR_HEIGHT (f) = 2; |
2857 | 2853 |
2858 /* The height has changed, resize outer widget and set columns | 2854 /* The height has changed, resize outer widget and set columns |
2859 rows to what we had before detaching the tool bar. */ | 2855 rows to what we had before detaching the tool bar. */ |
2860 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 2856 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
2861 } | 2857 } |
2862 } | 2858 } |
2863 | 2859 |
2864 /* This callback is called when a tool bar is reattached. We must set | 2860 /* This callback is called when a tool bar is reattached. We must set |
2865 the height of the tool bar when this happens so frame sizes | 2861 the height of the tool bar when this happens so frame sizes |
2882 gtk_widget_size_request (w, &req); | 2878 gtk_widget_size_request (w, &req); |
2883 FRAME_TOOLBAR_HEIGHT (f) = req.height; | 2879 FRAME_TOOLBAR_HEIGHT (f) = req.height; |
2884 | 2880 |
2885 /* The height has changed, resize outer widget and set columns | 2881 /* The height has changed, resize outer widget and set columns |
2886 rows to what we had before detaching the tool bar. */ | 2882 rows to what we had before detaching the tool bar. */ |
2887 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 2883 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
2888 } | 2884 } |
2889 } | 2885 } |
2890 | 2886 |
2891 /* This callback is called when the mouse enters or leaves a tool bar item. | 2887 /* This callback is called when the mouse enters or leaves a tool bar item. |
2892 It is used for displaying and hiding the help text. | 2888 It is used for displaying and hiding the help text. |
3027 gtk_widget_size_request (x->toolbar_widget, &req); | 3023 gtk_widget_size_request (x->toolbar_widget, &req); |
3028 FRAME_TOOLBAR_HEIGHT (f) = req.height; | 3024 FRAME_TOOLBAR_HEIGHT (f) = req.height; |
3029 | 3025 |
3030 /* The height has changed, resize outer widget and set columns | 3026 /* The height has changed, resize outer widget and set columns |
3031 rows to what we had before adding the tool bar. */ | 3027 rows to what we had before adding the tool bar. */ |
3032 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 3028 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
3033 | 3029 |
3034 SET_FRAME_GARBAGED (f); | 3030 SET_FRAME_GARBAGED (f); |
3035 } | 3031 } |
3036 | 3032 |
3037 void | 3033 void |
3200 | 3196 |
3201 gtk_widget_size_request (x->toolbar_widget, &new_req); | 3197 gtk_widget_size_request (x->toolbar_widget, &new_req); |
3202 if (old_req.height != new_req.height) | 3198 if (old_req.height != new_req.height) |
3203 { | 3199 { |
3204 FRAME_TOOLBAR_HEIGHT (f) = new_req.height; | 3200 FRAME_TOOLBAR_HEIGHT (f) = new_req.height; |
3205 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 3201 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
3206 } | 3202 } |
3207 | 3203 |
3208 if (icon_list) g_list_free (icon_list); | 3204 if (icon_list) g_list_free (icon_list); |
3209 | 3205 |
3210 UNBLOCK_INPUT; | 3206 UNBLOCK_INPUT; |
3225 x->handlebox_widget = 0; | 3221 x->handlebox_widget = 0; |
3226 FRAME_TOOLBAR_HEIGHT (f) = 0; | 3222 FRAME_TOOLBAR_HEIGHT (f) = 0; |
3227 | 3223 |
3228 /* The height has changed, resize outer widget and set columns | 3224 /* The height has changed, resize outer widget and set columns |
3229 rows to what we had before removing the tool bar. */ | 3225 rows to what we had before removing the tool bar. */ |
3230 xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 3226 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
3231 | 3227 |
3232 SET_FRAME_GARBAGED (f); | 3228 SET_FRAME_GARBAGED (f); |
3233 UNBLOCK_INPUT; | 3229 UNBLOCK_INPUT; |
3234 } | 3230 } |
3235 } | 3231 } |