diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-12-08 21:25:08 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-12-08 21:25:08 +0000 |
commit | 057ab5a4dfb083878ee075a92ece949870aa7c56 (patch) | |
tree | b6cdd0dbf888a0096b90d6f24a8c1eda4ed49d83 /gtk/gtktextlayout.c | |
parent | 456ebcea28c2598882069d97381ff7e223fc4a99 (diff) | |
download | gtk+-057ab5a4dfb083878ee075a92ece949870aa7c56.tar.gz |
Fix #111031, reported by Padraig O'Briain:
2004-12-08 Matthias Clasen <mclasen@redhat.com>
Fix #111031, reported by Padraig O'Briain:
* gtk/gtktextlayout.h:
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position):
Add a variant of gtk_text_layout_get_iter_at_pixel() which
returns the character at the position, not the closest
cursor position.
* gtk/gtktextview.h:
* gtk/gtktextview.c (gtk_text_view_get_iter_at_position):
Add a variant of gtk_text_view_get_iter_at_location() which
returns the character at the position, not the closest
cursor position.
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r-- | gtk/gtktextlayout.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 56d100d0a0..3738a93e57 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -2277,11 +2277,25 @@ gtk_text_layout_get_line_at_y (GtkTextLayout *layout, void gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout, - GtkTextIter *target_iter, - gint x, gint y) + GtkTextIter *target_iter, + gint x, + gint y) +{ + gint trailing; + + gtk_text_layout_get_iter_at_position (layout, target_iter, &trailing, x, y); + + gtk_text_iter_forward_chars (target_iter, trailing); +} + +void gtk_text_layout_get_iter_at_position (GtkTextLayout *layout, + GtkTextIter *target_iter, + gint *trailing, + gint x, + gint y) { GtkTextLine *line; - gint byte_index, trailing; + gint byte_index; gint line_top; GtkTextLineDisplay *display; @@ -2301,7 +2315,7 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout, if (y > display->height - display->top_margin - display->bottom_margin) { byte_index = _gtk_text_line_byte_count (line); - trailing = 0; + *trailing = 0; } else { @@ -2310,14 +2324,15 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout, * x-direction. */ pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE, - &byte_index, &trailing); + &byte_index, trailing); } - line_display_index_to_iter (layout, display, target_iter, byte_index, trailing); + line_display_index_to_iter (layout, display, target_iter, byte_index, 0); gtk_text_layout_free_line_display (layout, display); } + /** * gtk_text_layout_get_cursor_locations: * @layout: a #GtkTextLayout |