mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Scott Oonk's patch to draw cursor at correct x,y offset from
GdkDrawable. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@11902 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
993cf80814
commit
1f8130828e
@ -1,5 +1,9 @@
|
|||||||
2005-11-09 Scott Oonk <scott.oonk@gmail.com>
|
2005-11-09 Scott Oonk <scott.oonk@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
|
* src/register/register-gnome/gnucash-item-edit.c: Fix some
|
||||||
alignment problems in the register.
|
alignment problems in the register.
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ struct _TextDrawInfo
|
|||||||
GdkRectangle bg_rect;
|
GdkRectangle bg_rect;
|
||||||
GdkRectangle text_rect;
|
GdkRectangle text_rect;
|
||||||
GdkRectangle hatch_rect;
|
GdkRectangle hatch_rect;
|
||||||
|
GdkRectangle cursor_rect;
|
||||||
|
|
||||||
GdkColor *fg_color;
|
GdkColor *fg_color;
|
||||||
GdkColor *bg_color;
|
GdkColor *bg_color;
|
||||||
@ -79,8 +80,6 @@ struct _TextDrawInfo
|
|||||||
GdkColor *bg_color2;
|
GdkColor *bg_color2;
|
||||||
|
|
||||||
gboolean hatching;
|
gboolean hatching;
|
||||||
|
|
||||||
PangoRectangle cursor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -226,7 +225,11 @@ gnc_item_edit_draw_info (GncItemEdit *item_edit, int x, int y, TextDrawInfo *inf
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 = 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)
|
if (info->hatching)
|
||||||
{
|
{
|
||||||
@ -249,14 +252,16 @@ gnc_item_edit_free_draw_info_members(TextDrawInfo *info)
|
|||||||
static void
|
static void
|
||||||
gnc_item_edit_update_scroll_offset(GncItemEdit *item_edit,
|
gnc_item_edit_update_scroll_offset(GncItemEdit *item_edit,
|
||||||
TextDrawInfo *info) {
|
TextDrawInfo *info) {
|
||||||
gint cursor_margin = CELL_HPADDING + 3;
|
if (info->cursor_rect.x + item_edit->x_offset >
|
||||||
if (PANGO_PIXELS (info->cursor.x) + item_edit->x_offset
|
info->text_rect.x + info->text_rect.width - CELL_HPADDING)
|
||||||
> info->text_rect.width - cursor_margin) {
|
{
|
||||||
item_edit->x_offset = info->text_rect.width
|
item_edit->x_offset =
|
||||||
- PANGO_PIXELS (info->cursor.x) - cursor_margin;
|
(info->text_rect.x + info->text_rect.width - CELL_HPADDING)
|
||||||
} else if (PANGO_PIXELS (info->cursor.x) + item_edit->x_offset
|
- info->cursor_rect.x;
|
||||||
< 0) {
|
}
|
||||||
item_edit->x_offset = - PANGO_PIXELS (info->cursor.x);
|
else if (info->cursor_rect.x + item_edit->x_offset < info->text_rect.x)
|
||||||
|
{
|
||||||
|
item_edit->x_offset = - info->cursor_rect.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,12 +309,10 @@ gnc_item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
|
|||||||
|
|
||||||
gdk_draw_line (drawable,
|
gdk_draw_line (drawable,
|
||||||
item_edit->gc,
|
item_edit->gc,
|
||||||
PANGO_PIXELS (info.cursor.x) + CELL_HPADDING
|
info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
|
||||||
+ item_edit->x_offset,
|
info.cursor_rect.y,
|
||||||
PANGO_PIXELS (info.cursor.y),
|
info.cursor_rect.x + CELL_HPADDING + item_edit->x_offset,
|
||||||
PANGO_PIXELS (info.cursor.x) + CELL_HPADDING
|
info.cursor_rect.y + info.cursor_rect.height);
|
||||||
+ item_edit->x_offset,
|
|
||||||
PANGO_PIXELS (info.cursor.y + info.cursor.height));
|
|
||||||
|
|
||||||
gdk_gc_set_clip_rectangle (item_edit->gc, NULL);
|
gdk_gc_set_clip_rectangle (item_edit->gc, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user