forked from AuroraMiddleware/gtk
Take border width into account.
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.c (widget_to_buffer): Take border width into account. * gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont to compute wrap width ... GdkFont will pull in X11 core fonts.
This commit is contained in:
parent
a93987de00
commit
60c1630edc
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Feb 24 14:15:45 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktextview.c (widget_to_buffer): Take border
|
||||
width into account.
|
||||
|
||||
* gtk/gtklabel.c (get_label_wrap_width): Don't use GdkFont
|
||||
to compute wrap width ... GdkFont will pull in X11 core
|
||||
fonts.
|
||||
|
||||
Sun Feb 24 00:06:58 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Released 1.3.15.
|
||||
|
@ -1324,6 +1324,51 @@ gtk_label_clear_layout (GtkLabel *label)
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _LabelWrapWidth LabelWrapWidth;
|
||||
struct _LabelWrapWidth
|
||||
{
|
||||
gint width;
|
||||
PangoFontDescription *font_desc;
|
||||
};
|
||||
|
||||
static void
|
||||
label_wrap_width_free (gpointer data)
|
||||
{
|
||||
LabelWrapWidth *wrap_width = data;
|
||||
pango_font_description_free (wrap_width->font_desc);
|
||||
g_free (wrap_width);
|
||||
}
|
||||
|
||||
static gint
|
||||
get_label_wrap_width (GtkLabel *label)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
GtkStyle *style = GTK_WIDGET (label)->style;
|
||||
|
||||
LabelWrapWidth *wrap_width = g_object_get_data (G_OBJECT (style), "gtk-label-wrap-width");
|
||||
if (!wrap_width)
|
||||
{
|
||||
wrap_width = g_new0 (LabelWrapWidth, 1);
|
||||
g_object_set_data_full (G_OBJECT (style), "gtk-label-wrap-width",
|
||||
wrap_width, label_wrap_width_free);
|
||||
}
|
||||
|
||||
if (wrap_width->font_desc && pango_font_description_equal (wrap_width->font_desc, style->font_desc))
|
||||
return wrap_width->width;
|
||||
|
||||
if (wrap_width->font_desc)
|
||||
pango_font_description_free (wrap_width->font_desc);
|
||||
|
||||
wrap_width->font_desc = pango_font_description_copy (style->font_desc);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (label),
|
||||
"This long string gives a good enough length for any line to have.");
|
||||
pango_layout_get_size (layout, &wrap_width->width, NULL);
|
||||
g_object_unref (layout);
|
||||
|
||||
return wrap_width->width;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_ensure_layout (GtkLabel *label)
|
||||
{
|
||||
@ -1378,6 +1423,8 @@ gtk_label_ensure_layout (GtkLabel *label)
|
||||
pango_layout_set_width (label->layout, aux_info->width * PANGO_SCALE);
|
||||
else
|
||||
{
|
||||
gint wrap_width;
|
||||
|
||||
pango_layout_set_width (label->layout, -1);
|
||||
pango_layout_get_extents (label->layout, NULL, &logical_rect);
|
||||
|
||||
@ -1386,9 +1433,8 @@ gtk_label_ensure_layout (GtkLabel *label)
|
||||
/* Try to guess a reasonable maximum width */
|
||||
longest_paragraph = width;
|
||||
|
||||
width = MIN (width,
|
||||
PANGO_SCALE * gdk_string_width (gtk_style_get_font (GTK_WIDGET (label)->style),
|
||||
"This long string gives a good enough length for any line to have."));
|
||||
wrap_width = get_label_wrap_width (label);
|
||||
width = MIN (width, wrap_width);
|
||||
width = MIN (width,
|
||||
PANGO_SCALE * (gdk_screen_width () + 1) / 2);
|
||||
|
||||
|
@ -6848,6 +6848,7 @@ widget_to_buffer (GtkTextView *text_view,
|
||||
gint focus_edge_width;
|
||||
gboolean interior_focus;
|
||||
gint focus_width;
|
||||
gint border_width = GTK_CONTAINER (text_view)->border_width;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (text_view),
|
||||
"interior_focus", &interior_focus,
|
||||
@ -6861,14 +6862,14 @@ widget_to_buffer (GtkTextView *text_view,
|
||||
|
||||
if (buffer_x)
|
||||
{
|
||||
*buffer_x = widget_x - focus_edge_width + text_view->xoffset;
|
||||
*buffer_x = widget_x - focus_edge_width - border_width + text_view->xoffset;
|
||||
if (text_view->left_window)
|
||||
*buffer_x -= text_view->left_window->allocation.width;
|
||||
}
|
||||
|
||||
if (buffer_y)
|
||||
{
|
||||
*buffer_y = widget_y - focus_edge_width + text_view->yoffset;
|
||||
*buffer_y = widget_y - focus_edge_width - border_width + text_view->yoffset;
|
||||
if (text_view->top_window)
|
||||
*buffer_y -= text_view->top_window->allocation.height;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user