mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Scot Oonk's patch to fix some alignment problems in the register.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@11901 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
dff3bc9682
commit
993cf80814
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2005-11-09 Scott Oonk <scott.oonk@gmail.com>
|
||||
|
||||
* src/register/register-gnome/gnucash-item-edit.c: Fix some
|
||||
alignment problems in the register.
|
||||
|
||||
It removes the pango_layout_set_alignment code. Since we are
|
||||
rendering a single line of text, the layout is only as wide as the
|
||||
text. Because of this, the alignment within the layout doesn't
|
||||
have any effect.
|
||||
|
||||
Use the same x_offset logic regardless of how we enter the cell.
|
||||
|
||||
Make sure x_offset gets reset when changing cells via the keyboard.
|
||||
|
||||
2005-11-09 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome-utils/gnc-tree-view-account.[ch]: Add a function that
|
||||
|
@ -218,21 +218,12 @@ gnc_item_edit_draw_info (GncItemEdit *item_edit, int x, int y, TextDrawInfo *inf
|
||||
// pango_layout_set_ellipsize(...) as of pango 1.6 may be useful for
|
||||
// strings longer than the field width.
|
||||
|
||||
switch (gnc_table_get_align (table, item_edit->virt_loc))
|
||||
// Default x_offset based on cell alignment
|
||||
if (item_edit->reset_pos)
|
||||
{
|
||||
default:
|
||||
case CELL_ALIGN_LEFT:
|
||||
pango_layout_set_alignment (info->layout, PANGO_ALIGN_LEFT);
|
||||
break;
|
||||
|
||||
case CELL_ALIGN_RIGHT:
|
||||
pango_layout_set_alignment (info->layout, PANGO_ALIGN_RIGHT);
|
||||
break;
|
||||
|
||||
case CELL_ALIGN_CENTER:
|
||||
pango_layout_set_alignment (info->layout, PANGO_ALIGN_CENTER);
|
||||
break;
|
||||
}
|
||||
gnc_item_edit_reset_offset (item_edit);
|
||||
item_edit->reset_pos = FALSE;
|
||||
}
|
||||
|
||||
pango_layout_get_cursor_pos (info->layout, cursor_byte_pos, &strong_pos, NULL);
|
||||
info->cursor = strong_pos;
|
||||
@ -284,8 +275,6 @@ gnc_item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
|
||||
/* Get the measurements for drawing */
|
||||
gnc_item_edit_draw_info (item_edit, x, y, &info);
|
||||
|
||||
item_edit->reset_pos = FALSE;
|
||||
|
||||
/* Draw the background */
|
||||
gdk_gc_set_foreground (item_edit->gc, info.bg_color);
|
||||
gdk_draw_rectangle (drawable, item_edit->gc, TRUE,
|
||||
@ -575,10 +564,41 @@ gnc_item_edit_focus_out (GncItemEdit *item_edit)
|
||||
void
|
||||
gnc_item_edit_reset_offset (GncItemEdit *item_edit)
|
||||
{
|
||||
Table *table;
|
||||
PangoRectangle ink_rect;
|
||||
PangoLayout *layout;
|
||||
gint x, y, width, height;
|
||||
|
||||
g_return_if_fail (item_edit != NULL);
|
||||
g_return_if_fail (GNC_IS_ITEM_EDIT(item_edit));
|
||||
|
||||
item_edit->reset_pos = TRUE;
|
||||
table = item_edit->sheet->table;
|
||||
layout = gtk_entry_get_layout (GTK_ENTRY(item_edit->editor));
|
||||
pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
|
||||
gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &width, &height);
|
||||
|
||||
switch (gnc_table_get_align (table, item_edit->virt_loc))
|
||||
{
|
||||
default:
|
||||
case CELL_ALIGN_LEFT:
|
||||
item_edit->x_offset = 0;
|
||||
break;
|
||||
|
||||
case CELL_ALIGN_RIGHT:
|
||||
item_edit->x_offset = width
|
||||
- 2 * CELL_HPADDING
|
||||
- ink_rect.width;
|
||||
break;
|
||||
|
||||
case CELL_ALIGN_CENTER:
|
||||
if (ink_rect.width > width - 2 * CELL_HPADDING)
|
||||
item_edit->x_offset = 0;
|
||||
else
|
||||
item_edit->x_offset = (width
|
||||
- 2 * CELL_HPADDING
|
||||
- ink_rect.width) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -725,35 +745,7 @@ gnc_item_edit_set_cursor_pos (GncItemEdit *item_edit,
|
||||
editable = GTK_EDITABLE (item_edit->editor);
|
||||
|
||||
if (changed_cells)
|
||||
{
|
||||
CellAlignment align;
|
||||
|
||||
align = gnc_table_get_align (table, item_edit->virt_loc);
|
||||
|
||||
if (align == CELL_ALIGN_RIGHT) {
|
||||
PangoRectangle ink_rect;
|
||||
PangoLayout *layout;
|
||||
|
||||
gtk_editable_set_position(editable, -1);
|
||||
|
||||
layout = gtk_entry_get_layout( GTK_ENTRY(item_edit->
|
||||
editor) );
|
||||
pango_layout_get_pixel_extents(layout,
|
||||
&ink_rect,
|
||||
NULL);
|
||||
|
||||
item_edit->x_offset =
|
||||
cd->pixel_width - ink_rect.width -
|
||||
2* CELL_HPADDING;
|
||||
}
|
||||
else {
|
||||
gtk_editable_set_position(editable, 0);
|
||||
item_edit->x_offset = 0;
|
||||
}
|
||||
|
||||
if (item_edit->is_popup)
|
||||
x -= item_edit->popup_toggle.toggle_offset;
|
||||
}
|
||||
gnc_item_edit_reset_offset (item_edit);
|
||||
|
||||
o_x = cd->origin_x + item_edit->x_offset;
|
||||
o_y = cd->origin_y;
|
||||
|
Loading…
Reference in New Issue
Block a user