register cell text alignments

Andreas Köhler andi5.py at gmx.net
Fri Dec 9 04:13:32 EST 2005


Hi,

I do not know whether this is still the correct list, but
nevertheless here is a small patch that fixes the right alignment of
cells in the register. It uses logical extents instead of ink
extents, so now there should not be that many cutted dates and
amounts.

Prominent examples were imho dates in european style which quite
often contain leading spaces (another bug, I hope to send a patch
soon/some_time). So the trailing 5 in 2005 consisted of only two
line segments :)

-- andi5
-------------- next part --------------
Index: src/register/register-gnome/gnucash-grid.c
===================================================================
--- src/register/register-gnome/gnucash-grid.c	(Revision 12150)
+++ src/register/register-gnome/gnucash-grid.c	(Arbeitskopie)
@@ -366,7 +366,7 @@
 	PangoLayout *layout;
 	PangoContext *context;
 	PangoFontDescription *font;
-	PangoRectangle ink_rect;
+	PangoRectangle logical_rect;
         GdkColor *bg_color;
         GdkColor *fg_color;
 /*        gint x_offset, y_offset;*/
@@ -491,8 +491,8 @@
         y_offset++;*/
 
 	pango_layout_get_pixel_extents(layout,
-				       &ink_rect,
-				       NULL);
+				       NULL,
+				       &logical_rect);
 
         rect.x      = x + CELL_HPADDING;
         rect.y      = y + CELL_VPADDING;
@@ -510,15 +510,15 @@
                         break;
 
                 case CELL_ALIGN_RIGHT:
-			x_offset = width - 2 * CELL_HPADDING - ink_rect.width;
+			x_offset = width - 2 * CELL_HPADDING - logical_rect.width + 1;
                         break;
 
                 case CELL_ALIGN_CENTER:
-			if (ink_rect.width > width - 2 * CELL_HPADDING)
+			if (logical_rect.width > width - 2 * CELL_HPADDING)
 				x_offset = 0;
 			else
 				x_offset = (width - 2 * CELL_HPADDING - 
-					    ink_rect.width) / 2;
+					    logical_rect.width) / 2;
                         break;
 	}
 


More information about the gnucash-patches mailing list