Commit 8ddb92e4 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

change to pass in the cursor direction always, not just when we need an

2002-02-24  Havoc Pennington  <hp@pobox.com>

	* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
	the cursor direction always, not just when we need an arrow, so we
	can flip the cursor around its axis for RTL. Resolves #72372

	* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
	draw_insertion_cursor change

	* gtk/gtklabel.c (gtk_label_draw_cursor): ditto

	* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
parent 3e7279cf
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
2002-02-24 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (_gtk_draw_insertion_cursor): change to pass in
the cursor direction always, not just when we need an arrow, so we
can flip the cursor around its axis for RTL. Resolves #72372
* gtk/gtkentry.c (gtk_entry_draw_cursor): update for
draw_insertion_cursor change
* gtk/gtklabel.c (gtk_label_draw_cursor): ditto
* gtk/gtktextdisplay.c (gtk_text_layout_draw): ditto
2002-02-24 Alexander Larsson <alla@lysator.liu.se>
* gdk/x11/gdkwindow-x11.c (gdk_window_set_background):
......
......@@ -2701,6 +2701,8 @@ gtk_entry_draw_cursor (GtkEntry *entry,
"gtk-split-cursor", &split_cursor,
NULL);
dir1 = widget_direction;
if (split_cursor)
{
gc1 = entry->cursor_gc;
......@@ -2708,7 +2710,6 @@ gtk_entry_draw_cursor (GtkEntry *entry,
if (weak_x != strong_x)
{
dir1 = widget_direction;
dir2 = (widget_direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
gc2 = widget->style->text_gc[GTK_STATE_NORMAL];
......@@ -2731,13 +2732,15 @@ gtk_entry_draw_cursor (GtkEntry *entry,
cursor_location.height = text_area_height - 2 * INNER_BORDER ;
_gtk_draw_insertion_cursor (widget, entry->text_area, gc1,
&cursor_location, dir1);
&cursor_location, dir1,
dir2 != GTK_TEXT_DIR_NONE);
if (gc2)
if (dir2 != GTK_TEXT_DIR_NONE)
{
cursor_location.x = xoffset + x2;
_gtk_draw_insertion_cursor (widget, entry->text_area, gc2,
&cursor_location, dir2);
&cursor_location, dir2,
TRUE);
}
}
}
......
......@@ -1694,6 +1694,8 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
"gtk-split-cursor", &split_cursor,
NULL);
dir1 = widget_direction;
if (split_cursor)
{
gc1 = label->select_info->cursor_gc;
......@@ -1702,7 +1704,6 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
if (strong_pos.x != weak_pos.x ||
strong_pos.y != weak_pos.y)
{
dir1 = widget_direction;
dir2 = (widget_direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
gc2 = widget->style->black_gc;
......@@ -1725,9 +1726,10 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
cursor_location.height = PANGO_PIXELS (cursor1->height);
_gtk_draw_insertion_cursor (widget, widget->window, gc1,
&cursor_location, dir1);
&cursor_location, dir1,
dir2 != GTK_TEXT_DIR_NONE);
if (gc2)
if (dir2 != GTK_TEXT_DIR_NONE)
{
cursor_location.x = xoffset + PANGO_PIXELS (cursor2->x);
cursor_location.y = yoffset + PANGO_PIXELS (cursor2->y);
......@@ -1735,7 +1737,7 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
cursor_location.height = PANGO_PIXELS (cursor2->height);
_gtk_draw_insertion_cursor (widget, widget->window, gc2,
&cursor_location, dir2);
&cursor_location, dir2, TRUE);
}
}
}
......
......@@ -5668,9 +5668,10 @@ gtk_style_set_font (GtkStyle *style,
* @drawable: a #GdkDrawable
* @gc: a #GdkGC
* @location: location where to draw the cursor (@location->width is ignored)
* @dir: text direction for the cursor, used to decide whether to draw a
* directional arrow on the cursor and in what direction. Unless both
* strong and weak cursors are displayed, this should be %GTK_TEXT_DIR_NONE.
* @direction: whether the cursor is left-to-right or
* right-to-left. Should never be #GTK_TEXT_DIR_NONE
* @draw_arrow: %TRUE to draw a directional arrow on the
* cursor. Should be %FALSE unless the cursor is split.
*
* Draws a text caret on @drawable at @location. This is not a style function
* but merely a convenience function for drawing the standard cursor shape.
......@@ -5680,48 +5681,61 @@ _gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
GtkTextDirection dir)
GtkTextDirection direction,
gboolean draw_arrow)
{
gint stem_width;
gint arrow_width;
gint x, y;
gint i;
gfloat cursor_aspect_ratio;
gint offset;
g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
stem_width = location->height * cursor_aspect_ratio + 1;
arrow_width = stem_width + 1;
/* put (stem_width % 2) on the proper side of the cursor */
if (direction == GTK_TEXT_DIR_LTR)
offset = stem_width / 2;
else
offset = stem_width - stem_width / 2;
for (i = 0; i < stem_width; i++)
gdk_draw_line (drawable, gc,
location->x + i - stem_width / 2, location->y,
location->x + i - stem_width / 2, location->y + location->height - 1);
location->x + i - offset, location->y,
location->x + i - offset, location->y + location->height - 1);
if (dir == GTK_TEXT_DIR_RTL)
if (draw_arrow)
{
x = location->x - stem_width / 2 - 1;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
if (direction == GTK_TEXT_DIR_RTL)
{
x = location->x - offset - 1;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
for (i = 0; i < arrow_width; i++)
{
gdk_draw_line (drawable, gc,
x, y + i + 1,
x, y + 2 * arrow_width - i - 1);
x --;
}
}
else if (dir == GTK_TEXT_DIR_LTR)
{
x = location->x + stem_width - stem_width / 2;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
for (i = 0; i < arrow_width; i++)
{
gdk_draw_line (drawable, gc,
x, y + i + 1,
x, y + 2 * arrow_width - i - 1);
x --;
}
}
else if (direction == GTK_TEXT_DIR_LTR)
{
x = location->x + stem_width - offset;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
for (i = 0; i < arrow_width; i++)
{
gdk_draw_line (drawable, gc,
x, y + i + 1,
x, y + 2 * arrow_width - i - 1);
x++;
}
for (i = 0; i < arrow_width; i++)
{
gdk_draw_line (drawable, gc,
x, y + i + 1,
x, y + 2 * arrow_width - i - 1);
x++;
}
}
}
}
......@@ -883,7 +883,8 @@ void _gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
GtkTextDirection dir);
GtkTextDirection direction,
gboolean draw_arrow);
#ifdef __cplusplus
}
......
......@@ -842,16 +842,12 @@ gtk_text_layout_draw (GtkTextLayout *layout,
else
gc = widget->style->text_gc[GTK_STATE_NORMAL];
dir = line_display->direction;
if (have_strong && have_weak)
{
dir = line_display->direction;
if (!cursor->is_strong)
dir = (dir == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
}
else
{
dir = GTK_TEXT_DIR_NONE;
}
cursor_location.x = line_display->x_offset + cursor->x - x_offset;
cursor_location.y = current_y + line_display->top_margin + cursor->y;
......@@ -859,7 +855,8 @@ gtk_text_layout_draw (GtkTextLayout *layout,
cursor_location.height = cursor->height;
gdk_gc_set_clip_rectangle(gc, &clip);
_gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location, dir);
_gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location,
dir, have_strong && have_weak);
gdk_gc_set_clip_rectangle (gc, NULL);
cursor_list = cursor_list->next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment