/[emacs]/emacs/src/gtkutil.c
ViewVC logotype

Diff of /emacs/src/gtkutil.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by jhd, Fri May 2 12:20:16 2003 UTC revision 1.29 by kfstorm, Sat May 24 21:58:42 2003 UTC
# Line 34  Boston, MA 02111-1307, USA.  */ Line 34  Boston, MA 02111-1307, USA.  */
34  #include <gdk/gdkkeysyms.h>  #include <gdk/gdkkeysyms.h>
35    
36  #define FRAME_TOTAL_PIXEL_HEIGHT(f) \  #define FRAME_TOTAL_PIXEL_HEIGHT(f) \
37    (PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))    (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))
38    
39    
40    
# Line 237  static void Line 237  static void
237  xg_set_geometry (f)  xg_set_geometry (f)
238       FRAME_PTR f;       FRAME_PTR f;
239  {  {
240    if (f->output_data.x->size_hint_flags & USPosition)    if (f->size_hint_flags & USPosition)
241    {    {
242      int left = f->output_data.x->left_pos;      int left = f->left_pos;
243      int xneg = f->output_data.x->size_hint_flags & XNegative;      int xneg = f->size_hint_flags & XNegative;
244      int top = f->output_data.x->top_pos;      int top = f->top_pos;
245      int yneg = f->output_data.x->size_hint_flags & YNegative;      int yneg = f->size_hint_flags & YNegative;
246      char geom_str[32];      char geom_str[32];
247    
248      if (xneg)      if (xneg)
# Line 251  xg_set_geometry (f) Line 251  xg_set_geometry (f)
251        top = -top;        top = -top;
252    
253      sprintf (geom_str, "=%dx%d%c%d%c%d",      sprintf (geom_str, "=%dx%d%c%d%c%d",
254               PIXEL_WIDTH (f),               FRAME_PIXEL_WIDTH (f),
255               FRAME_TOTAL_PIXEL_HEIGHT (f),               FRAME_TOTAL_PIXEL_HEIGHT (f),
256               (xneg ? '-' : '+'), left,               (xneg ? '-' : '+'), left,
257               (yneg ? '-' : '+'), top);               (yneg ? '-' : '+'), top);
# Line 273  xg_resize_outer_widget (f, columns, rows Line 273  xg_resize_outer_widget (f, columns, rows
273       int rows;       int rows;
274  {  {
275    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
276                       PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f));                       FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f));
277    
278    /* base_height is now changed.  */    /* base_height is now changed.  */
279    x_wm_set_size_hint (f, 0, 0);    x_wm_set_size_hint (f, 0, 0);
# Line 317  xg_resize_widgets (f, pixelwidth, pixelh Line 317  xg_resize_widgets (f, pixelwidth, pixelh
317  {  {
318    int mbheight = FRAME_MENUBAR_HEIGHT (f);    int mbheight = FRAME_MENUBAR_HEIGHT (f);
319    int tbheight = FRAME_TOOLBAR_HEIGHT (f);    int tbheight = FRAME_TOOLBAR_HEIGHT (f);
320    int rows = PIXEL_TO_CHAR_HEIGHT (f, pixelheight - mbheight - tbheight);    int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (pixelheight
321    int columns = PIXEL_TO_CHAR_WIDTH (f, pixelwidth);                                                     - mbheight - tbheight));
322      int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth);
323    
324    if (FRAME_GTK_WIDGET (f)    if (FRAME_GTK_WIDGET (f)
325        && (columns != FRAME_WIDTH (f) || rows != FRAME_HEIGHT (f)        && (columns != FRAME_COLS (f) || rows != FRAME_LINES (f)
326            || pixelwidth != PIXEL_WIDTH (f) || pixelheight != PIXEL_HEIGHT (f)))            || pixelwidth != FRAME_PIXEL_WIDTH (f) || pixelheight != FRAME_PIXEL_HEIGHT (f)))
327      {      {
328        struct x_output *x = f->output_data.x;        struct x_output *x = f->output_data.x;
329        GtkAllocation all;        GtkAllocation all;
# Line 349  xg_frame_set_char_size (f, cols, rows) Line 350  xg_frame_set_char_size (f, cols, rows)
350       int cols;       int cols;
351       int rows;       int rows;
352  {  {
353    int pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows)    int pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows)
354      + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);      + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
355    int pixelwidth;    int pixelwidth;
356    
# Line 358  xg_frame_set_char_size (f, cols, rows) Line 359  xg_frame_set_char_size (f, cols, rows)
359       might end up with a frame width that is not a multiple of the       might end up with a frame width that is not a multiple of the
360       frame's character width which is bad for vertically split       frame's character width which is bad for vertically split
361       windows.  */       windows.  */
362    f->output_data.x->vertical_scroll_bar_extra    f->scroll_bar_actual_width
363      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)      = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
        ? 0  
        : (FRAME_SCROLL_BAR_COLS (f)  
           * FONT_WIDTH (f->output_data.x->font)));  
364    
365    compute_fringe_widths (f, 0);    compute_fringe_widths (f, 0);
366    
367    /* CHAR_TO_PIXEL_WIDTH uses vertical_scroll_bar_extra, so call it    /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it
368       after calculating that value.  */       after calculating that value.  */
369    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);    pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
370    
371    /* Must resize our top level widget.  Font size may have changed,    /* Must resize our top level widget.  Font size may have changed,
372       but not rows/cols.  */       but not rows/cols.  */
# Line 511  xg_create_frame_widgets (f) Line 509  xg_create_frame_widgets (f)
509    
510    gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE);    gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE);
511    
512    gtk_widget_set_size_request (wfixed,    gtk_widget_set_size_request (wfixed, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
                                PIXEL_WIDTH (f),  
                                PIXEL_HEIGHT (f));  
513    
514    gtk_container_add (GTK_CONTAINER (wtop), wvbox);    gtk_container_add (GTK_CONTAINER (wtop), wvbox);
515    gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0);    gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0);
# Line 594  xg_create_frame_widgets (f) Line 590  xg_create_frame_widgets (f)
590    gtk_widget_modify_style (wfixed, style);    gtk_widget_modify_style (wfixed, style);
591    
592    /* GTK does not set any border, and they look bad with GTK.  */    /* GTK does not set any border, and they look bad with GTK.  */
593    f->output_data.x->border_width = 0;    f->border_width = 0;
594    f->output_data.x->internal_border_width = 0;    f->internal_border_width = 0;
595    
596    UNBLOCK_INPUT;    UNBLOCK_INPUT;
597    
# Line 621  x_wm_set_size_hint (f, flags, user_posit Line 617  x_wm_set_size_hint (f, flags, user_posit
617      gint hint_flags = 0;      gint hint_flags = 0;
618      int base_width, base_height;      int base_width, base_height;
619      int min_rows = 0, min_cols = 0;      int min_rows = 0, min_cols = 0;
620      int win_gravity = f->output_data.x->win_gravity;      int win_gravity = f->win_gravity;
621    
622      if (flags)      if (flags)
623        {        {
# Line 630  x_wm_set_size_hint (f, flags, user_posit Line 626  x_wm_set_size_hint (f, flags, user_posit
626          f->output_data.x->hint_flags = hint_flags;          f->output_data.x->hint_flags = hint_flags;
627        }        }
628       else       else
629         flags = f->output_data.x->size_hint_flags;         flags = f->size_hint_flags;
630    
631      size_hints = f->output_data.x->size_hints;      size_hints = f->output_data.x->size_hints;
632      hint_flags = f->output_data.x->hint_flags;      hint_flags = f->output_data.x->hint_flags;
633    
634      hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;      hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
635      size_hints.width_inc = FONT_WIDTH (f->output_data.x->font);      size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
636      size_hints.height_inc = f->output_data.x->line_height;      size_hints.height_inc = FRAME_LINE_HEIGHT (f);
637    
638      hint_flags |= GDK_HINT_BASE_SIZE;      hint_flags |= GDK_HINT_BASE_SIZE;
639      base_width = CHAR_TO_PIXEL_WIDTH (f, 0);      base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
640      base_height = CHAR_TO_PIXEL_HEIGHT (f, 0)      base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0)
641        + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);        + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
642    
643      check_frame_size (f, &min_rows, &min_cols);      check_frame_size (f, &min_rows, &min_cols);
# Line 2298  xg_update_frame_menubar (f) Line 2294  xg_update_frame_menubar (f)
2294    
2295    /* The height has changed, resize outer widget and set columns    /* The height has changed, resize outer widget and set columns
2296       rows to what we had before adding the menu bar.  */       rows to what we had before adding the menu bar.  */
2297    xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));    xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
2298    
2299    SET_FRAME_GARBAGED (f);    SET_FRAME_GARBAGED (f);
2300    UNBLOCK_INPUT;    UNBLOCK_INPUT;
# Line 2327  free_frame_menubar (f) Line 2323  free_frame_menubar (f)
2323    
2324        /* The height has changed, resize outer widget and set columns        /* The height has changed, resize outer widget and set columns
2325           rows to what we had before removing the menu bar.  */           rows to what we had before removing the menu bar.  */
2326        xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));        xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
2327    
2328        SET_FRAME_GARBAGED (f);        SET_FRAME_GARBAGED (f);
2329        UNBLOCK_INPUT;        UNBLOCK_INPUT;
# Line 2735  xg_set_toolkit_scroll_bar_thumb (bar, po Line 2731  xg_set_toolkit_scroll_bar_thumb (bar, po
2731        /* We do the same as for MOTIF in xterm.c, assume 30 chars per line        /* We do the same as for MOTIF in xterm.c, assume 30 chars per line
2732           rather than the real portion value.  This makes the thumb less likely           rather than the real portion value.  This makes the thumb less likely
2733           to resize and that looks better.  */           to resize and that looks better.  */
2734        portion = XFASTINT (XWINDOW (bar->window)->height) * 30;        portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30;
2735        /* When the thumb is at the bottom, position == whole.        /* When the thumb is at the bottom, position == whole.
2736           So we need to increase `whole' to make space for the thumb.  */           So we need to increase `whole' to make space for the thumb.  */
2737        whole += portion;        whole += portion;
# Line 2757  xg_set_toolkit_scroll_bar_thumb (bar, po Line 2753  xg_set_toolkit_scroll_bar_thumb (bar, po
2753        value = max (value, XG_SB_MIN);        value = max (value, XG_SB_MIN);
2754    
2755        /* Assume all lines are of equal size.  */        /* Assume all lines are of equal size.  */
2756        new_step = size / max (1, FRAME_HEIGHT (f));        new_step = size / max (1, FRAME_LINES (f));
2757    
2758        if ((int) adj->page_size != size        if ((int) adj->page_size != size
2759            || (int) adj->step_increment != new_step)            || (int) adj->step_increment != new_step)
# Line 2857  xg_tool_bar_detach_callback (wbox, w, cl Line 2853  xg_tool_bar_detach_callback (wbox, w, cl
2853    
2854        /* The height has changed, resize outer widget and set columns        /* The height has changed, resize outer widget and set columns
2855           rows to what we had before detaching the tool bar.  */           rows to what we had before detaching the tool bar.  */
2856        xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));        xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
2857      }      }
2858  }  }
2859    
# Line 2884  xg_tool_bar_attach_callback (wbox, w, cl Line 2880  xg_tool_bar_attach_callback (wbox, w, cl
2880    
2881        /* The height has changed, resize outer widget and set columns        /* The height has changed, resize outer widget and set columns
2882           rows to what we had before detaching the tool bar.  */           rows to what we had before detaching the tool bar.  */
2883        xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));        xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
2884      }      }
2885  }  }
2886    
# Line 3029  xg_create_tool_bar (f) Line 3025  xg_create_tool_bar (f)
3025    
3026    /* The height has changed, resize outer widget and set columns    /* The height has changed, resize outer widget and set columns
3027       rows to what we had before adding the tool bar.  */       rows to what we had before adding the tool bar.  */
3028    xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));    xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
3029    
3030    SET_FRAME_GARBAGED (f);    SET_FRAME_GARBAGED (f);
3031  }  }
# Line 3202  update_frame_tool_bar (f) Line 3198  update_frame_tool_bar (f)
3198    if (old_req.height != new_req.height)    if (old_req.height != new_req.height)
3199      {      {
3200        FRAME_TOOLBAR_HEIGHT (f) = new_req.height;        FRAME_TOOLBAR_HEIGHT (f) = new_req.height;
3201        xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));        xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
3202      }      }
3203    
3204    if (icon_list) g_list_free (icon_list);    if (icon_list) g_list_free (icon_list);
# Line 3227  free_frame_tool_bar (f) Line 3223  free_frame_tool_bar (f)
3223    
3224        /* The height has changed, resize outer widget and set columns        /* The height has changed, resize outer widget and set columns
3225           rows to what we had before removing the tool bar.  */           rows to what we had before removing the tool bar.  */
3226        xg_resize_outer_widget (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));        xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
3227    
3228        SET_FRAME_GARBAGED (f);        SET_FRAME_GARBAGED (f);
3229        UNBLOCK_INPUT;        UNBLOCK_INPUT;

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26