From c4f279f48009b2176eff5f981b728766d82f10da Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 23 Apr 2001 20:18:35 +0000 Subject: Make pixbuf columns show their title if there is space. 2001-04-23 Christopher James Lahey * e-table-header-utils.c (e_table_header_draw_button): Make pixbuf columns show their title if there is space. svn path=/trunk/; revision=9517 --- widgets/table/e-table-header-utils.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'widgets') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 6d73d1f763..0933359206 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* ETable widget - utilities for drawing table header buttons * * Copyright (C) 2000 Ximian, Inc. @@ -288,6 +289,7 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, if (ecol->is_pixbuf) { int pwidth, pheight; int clip_width, clip_height; + int xpos; GdkPixmap *pixmap; g_assert (ecol->pixbuf != NULL); @@ -298,15 +300,34 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, clip_width = MIN (pwidth, inner_width); clip_height = MIN (pheight, inner_height); + xpos = inner_x; + + if (inner_width - pwidth > 11) { + int rbearing; + int width; + int ypos; + + gdk_string_extents (font, ecol->text, NULL, &rbearing, &width, NULL, NULL); + if (rbearing < inner_width - (pwidth + 1)) { + xpos = inner_x + (inner_width - width - (pwidth + 1)) / 2; + } + + ypos = inner_y + (inner_height - font->ascent - font->descent) / 2 + font->ascent; + + e_table_draw_elided_string (drawable, font, gc, + xpos + pwidth + 1, ypos, + ecol->text, inner_width - (xpos - inner_x), FALSE); + } + pixmap = make_composite_pixmap (drawable, gc, ecol->pixbuf, &style->bg[state], clip_width, clip_height, - inner_x, + xpos, inner_y + (inner_height - clip_height) / 2); if (pixmap) { gdk_draw_pixmap (drawable, gc, pixmap, 0, 0, - inner_x, + xpos, inner_y + (inner_height - clip_height) / 2, clip_width, clip_height); gdk_pixmap_unref (pixmap); -- cgit v1.2.3