Register paddings
Andreas Köhler
andi5.py at gmx.net
Wed Mar 22 13:17:12 EST 2006
Hi,
regarding
http://bugzilla.gnome.org/show_bug.cgi?id=334920
(register cell with very little cell padding)
I propose the following patch. Since it changes the look of what I
think is pretty characteristic for GnuCash, I want to hear your
thoughts and preferences :)
All the patch does is to add vertical padding at some places and
align text, editable text and cursor horizontally. Apply it locally
(or tell me to do it globally ;-)).
-- andi5
-------------- next part --------------
Index: src/register/register-gnome/gnucash-sheet.h
===================================================================
--- src/register/register-gnome/gnucash-sheet.h (revision 13680)
+++ src/register/register-gnome/gnucash-sheet.h (working copy)
@@ -28,7 +28,7 @@
#include "table-allgui.h"
#define CELL_VPADDING 3
-#define CELL_HPADDING 4
+#define CELL_HPADDING 5
#define GNUCASH_TYPE_REGISTER (gnucash_register_get_type ())
Index: src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- src/register/register-gnome/gnucash-item-edit.c (revision 13680)
+++ src/register/register-gnome/gnucash-item-edit.c (working copy)
@@ -263,7 +263,7 @@
// pango_layout_set_ellipsize(...) as of pango 1.6 may be useful for
// strings longer than the field width.
- pango_layout_get_cursor_pos (info->layout, cursor_byte_pos, &strong_pos, NULL);
+ pango_layout_get_cursor_pos (info->layout, cursor_byte_pos, &strong_pos, NULL);
info->cursor_rect.x = dx + PANGO_PIXELS (strong_pos.x);
info->cursor_rect.y = dy + PANGO_PIXELS (strong_pos.y);
@@ -323,19 +323,18 @@
gdk_gc_set_foreground (item_edit->gc, info.fg_color);
- gdk_draw_layout (drawable,
- item_edit->gc,
- info.text_rect.x + CELL_HPADDING +
- item_edit->x_offset,
- info.text_rect.y + 1,
- info.layout);
+ gdk_draw_layout (drawable,
+ item_edit->gc,
+ info.text_rect.x + CELL_HPADDING + item_edit->x_offset,
+ info.text_rect.y + CELL_VPADDING,
+ info.layout);
gdk_draw_line (drawable,
item_edit->gc,
info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
- info.cursor_rect.y,
+ info.cursor_rect.y + CELL_VPADDING,
info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
- info.cursor_rect.y + info.cursor_rect.height);
+ info.cursor_rect.y + CELL_VPADDING + info.cursor_rect.height);
gdk_gc_set_clip_rectangle (item_edit->gc, NULL);
Index: src/register/register-gnome/gnucash-grid.c
===================================================================
--- src/register/register-gnome/gnucash-grid.c (revision 13680)
+++ src/register/register-gnome/gnucash-grid.c (working copy)
@@ -527,7 +527,7 @@
gdk_draw_layout (drawable,
grid->gc,
x + CELL_HPADDING + x_offset,
- y + 1,
+ y + CELL_VPADDING + 1,
layout);
gdk_gc_set_clip_rectangle (grid->gc, NULL);
Index: src/register/register-gnome/gnucash-style.c
===================================================================
--- src/register/register-gnome/gnucash-style.c (revision 13680)
+++ src/register/register-gnome/gnucash-style.c (working copy)
@@ -152,8 +152,8 @@
/* GdkFont *font = GNUCASH_GRID(sheet->grid)->normal_font; */
CellDimensions *cd;
int row, col;
- gint default_height = 0, max_height = -1;
- PangoLayout *layout;
+ gint max_height = -1;
+ PangoLayout *layout;
/* g_return_if_fail (font != NULL); */
@@ -168,11 +168,6 @@
cd = g_table_index (dimensions->cell_dimensions,
row, col);
- /*cd->pixel_height = (font->ascent + font->descent +
- (2 * CELL_VPADDING));*/
- /* cd->pixel_height = (2 * CELL_VPADDING); */
-
-
cell = gnc_cellblock_get_cell (cursor, row, col);
if (!cell)
continue;
@@ -183,25 +178,19 @@
if (text)
{
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
- /* width = gdk_string_width (font, text); */
- cd->pixel_height = 0;
- pango_layout_get_pixel_size (layout, &width, &cd->pixel_height);
- g_object_unref (layout);
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
+ pango_layout_get_pixel_size (layout, &width, &cd->pixel_height);
+ g_object_unref (layout);
width += 2 * CELL_HPADDING;
+ cd->pixel_height += 2 * CELL_VPADDING;
}
else
- {
+ {
width = 0;
- cd->pixel_height = (2 * CELL_VPADDING);
- }
+ cd->pixel_height = (2 * CELL_VPADDING);
+ }
- if (default_height == 0)
- default_height = cd->pixel_height;
- if (max_height < 0)
- max_height = cd->pixel_height;
- else
- max_height = MAX(max_height, cd->pixel_height);
+ max_height = MAX(max_height, cd->pixel_height);
if (cd->pixel_width > 0)
continue;
@@ -223,9 +212,9 @@
{
cd = g_table_index (dimensions->cell_dimensions,
row, col);
- cd->pixel_height = max_height;
- }
- }
+ cd->pixel_height = max_height;
+ }
+ }
}
More information about the gnucash-devel
mailing list