[Gnucash-changes] r11902 - gnucash/trunk - Scott Oonk's patch to
draw cursor at correct x, y offset from
David Hampton
hampton at cvs.gnucash.org
Wed Nov 9 23:35:32 EST 2005
Author: hampton
Date: 2005-11-09 23:35:31 -0500 (Wed, 09 Nov 2005)
New Revision: 11902
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
Log:
Scott Oonk's patch to draw cursor at correct x,y offset from
GdkDrawable.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2005-11-10 04:26:36 UTC (rev 11901)
+++ gnucash/trunk/ChangeLog 2005-11-10 04:35:31 UTC (rev 11902)
@@ -1,5 +1,9 @@
2005-11-09 Scott Oonk <scott.oonk at gmail.com>
+ * src/register/register-gnome/gnucash-item-edit.c: Draw cursor at
+ correct x,y offset from GdkDrawable. Will now correctly draw
+ cursor on initial entry into a cell.
+
* src/register/register-gnome/gnucash-item-edit.c: Fix some
alignment problems in the register.
Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c 2005-11-10 04:26:36 UTC (rev 11901)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c 2005-11-10 04:35:31 UTC (rev 11902)
@@ -71,6 +71,7 @@
GdkRectangle bg_rect;
GdkRectangle text_rect;
GdkRectangle hatch_rect;
+ GdkRectangle cursor_rect;
GdkColor *fg_color;
GdkColor *bg_color;
@@ -79,8 +80,6 @@
GdkColor *bg_color2;
gboolean hatching;
-
- PangoRectangle cursor;
};
@@ -226,8 +225,12 @@
}
pango_layout_get_cursor_pos (info->layout, cursor_byte_pos, &strong_pos, NULL);
- info->cursor = strong_pos;
+ info->cursor_rect.x = dx + PANGO_PIXELS (strong_pos.x);
+ info->cursor_rect.y = dy + PANGO_PIXELS (strong_pos.y);
+ info->cursor_rect.width = PANGO_PIXELS (strong_pos.width);
+ info->cursor_rect.height = PANGO_PIXELS (strong_pos.height);
+
if (info->hatching)
{
info->hatch_rect.x = dx;
@@ -249,15 +252,17 @@
static void
gnc_item_edit_update_scroll_offset(GncItemEdit *item_edit,
TextDrawInfo *info) {
- gint cursor_margin = CELL_HPADDING + 3;
- if (PANGO_PIXELS (info->cursor.x) + item_edit->x_offset
- > info->text_rect.width - cursor_margin) {
- item_edit->x_offset = info->text_rect.width
- - PANGO_PIXELS (info->cursor.x) - cursor_margin;
- } else if (PANGO_PIXELS (info->cursor.x) + item_edit->x_offset
- < 0) {
- item_edit->x_offset = - PANGO_PIXELS (info->cursor.x);
- }
+ if (info->cursor_rect.x + item_edit->x_offset >
+ info->text_rect.x + info->text_rect.width - CELL_HPADDING)
+ {
+ item_edit->x_offset =
+ (info->text_rect.x + info->text_rect.width - CELL_HPADDING)
+ - info->cursor_rect.x;
+ }
+ else if (info->cursor_rect.x + item_edit->x_offset < info->text_rect.x)
+ {
+ item_edit->x_offset = - info->cursor_rect.x;
+ }
}
static void
@@ -304,12 +309,10 @@
gdk_draw_line (drawable,
item_edit->gc,
- PANGO_PIXELS (info.cursor.x) + CELL_HPADDING
- + item_edit->x_offset,
- PANGO_PIXELS (info.cursor.y),
- PANGO_PIXELS (info.cursor.x) + CELL_HPADDING
- + item_edit->x_offset,
- PANGO_PIXELS (info.cursor.y + info.cursor.height));
+ info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
+ info.cursor_rect.y,
+ info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
+ info.cursor_rect.y + info.cursor_rect.height);
gdk_gc_set_clip_rectangle (item_edit->gc, NULL);
More information about the gnucash-changes
mailing list