/* GDK - The GIMP Drawing Kit
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
i = 0;
while (i < n_ranges)
- {
+ {
int *pixel_ranges = NULL;
int n_pixel_ranges = 0;
int j;
/* Note that get_x_ranges returns layout coordinates
*/
- if (index_ranges[i*2+1] >= line->start_index &&
- index_ranges[i*2] < line->start_index + line->length)
+ if (index_ranges[i*2+1] >= pango_layout_line_get_start_index (line) &&
+ index_ranges[i*2] < pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line))
pango_layout_line_get_x_ranges (line,
index_ranges[i*2],
index_ranges[i*2+1],
&pixel_ranges, &n_pixel_ranges);
-
+
for (j = 0; j < n_pixel_ranges; j++)
{
GdkRectangle rect;
int x_off, y_off;
-
+
x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x);
y_off = PANGO_PIXELS (baseline - logical_rect.y);
{
cairo_region_t *clip_region;
PangoLayoutIter *iter;
-
+
g_return_val_if_fail (line != NULL, NULL);
g_return_val_if_fail (index_ranges != NULL, NULL);
-
+
iter = pango_layout_get_iter (line->layout);
while (pango_layout_iter_get_line_readonly (iter) != line)
pango_layout_iter_next_line (iter);
-
+
clip_region = layout_iter_get_line_clip_region(iter, x_origin, y_origin, index_ranges, n_ranges);
pango_layout_iter_free (iter);
const int *index_ranges,
int n_ranges)
{
- PangoLayoutIter *iter;
+ PangoLayoutIter *iter;
cairo_region_t *clip_region;
-
+
g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL);
g_return_val_if_fail (index_ranges != NULL, NULL);
-
+
clip_region = cairo_region_create ();
-
+
iter = pango_layout_get_iter (layout);
-
+
do
{
PangoRectangle logical_rect;
cairo_region_t *line_region;
int baseline;
-
+
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
- baseline = pango_layout_iter_get_baseline (iter);
+ baseline = pango_layout_iter_get_baseline (iter);
- line_region = layout_iter_get_line_clip_region(iter,
+ line_region = layout_iter_get_line_clip_region(iter,
x_origin + PANGO_PIXELS (logical_rect.x),
y_origin + PANGO_PIXELS (baseline),
index_ranges,
}
}
+static const char *
+pango_align_to_string (PangoAlignment align)
+{
+ switch (align)
+ {
+ case PANGO_ALIGN_LEFT:
+ return "left";
+ case PANGO_ALIGN_CENTER:
+ return "center";
+ case PANGO_ALIGN_RIGHT:
+ return "right";
+ default:
+ g_assert_not_reached ();
+ }
+}
+
void
gtk_pango_get_font_attributes (PangoFontDescription *font,
GVariantBuilder *builder)
GVariantBuilder *builder)
{
PangoContext *context;
- const char *val;
- PangoAlignment align;
- PangoWrapMode mode;
context = pango_layout_get_context (layout);
if (context)
if (font)
gtk_pango_get_font_attributes (font, builder);
}
- if (pango_layout_get_justify (layout))
- {
- val = "fill";
- }
- else
- {
- align = pango_layout_get_alignment (layout);
- if (align == PANGO_ALIGN_LEFT)
- val = "left";
- else if (align == PANGO_ALIGN_CENTER)
- val = "center";
- else
- val = "right";
- }
- g_variant_builder_add (builder, "{ss}", "justification", val);
- mode = pango_layout_get_wrap (layout);
- g_variant_builder_add (builder, "{ss}", "wrap-mode",
- pango_wrap_mode_to_string (mode));
+ g_variant_builder_add (builder, "{ss}", "justification",
+ pango_align_to_string (pango_layout_get_alignment (layout)));
+ g_variant_builder_add (builder, "{ss}", "wrap-mode",
+ pango_wrap_mode_to_string (pango_layout_get_wrap (layout)));
g_variant_builder_add (builder, "{ss}", "strikethrough", "false");
g_variant_builder_add (builder, "{ss}", "underline", "false");
g_variant_builder_add (builder, "{ss}", "rise", "0");
{
PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL, *prev_prev_line = NULL;
- int index, start_index, end_index;
+ int index, start_index, length, end_index;
+ int prev_start_index, prev_length;
+ int prev_prev_start_index, prev_prev_length;
const char *text;
gboolean found = FALSE;
do
{
line = pango_layout_iter_get_line (iter);
- start_index = line->start_index;
- end_index = start_index + line->length;
+ start_index = pango_layout_line_get_start_index (line);
+ length = pango_layout_line_get_length (line);
+ end_index = start_index + length;
if (index >= start_index && index <= end_index)
{
{
case ATSPI_TEXT_BOUNDARY_LINE_START:
end_index = start_index;
- start_index = prev_line->start_index;
+ start_index = prev_start_index;
break;
case ATSPI_TEXT_BOUNDARY_LINE_END:
if (prev_prev_line)
- start_index = prev_prev_line->start_index + prev_prev_line->length;
+ start_index = prev_prev_start_index + prev_prev_length;
else
start_index = 0;
- end_index = prev_line->start_index + prev_line->length;
+ end_index = prev_start_index + prev_length;
break;
case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START:
}
prev_prev_line = prev_line;
+ prev_prev_start_index = prev_start_index;
+ prev_prev_length = prev_length;
prev_line = line;
+ prev_start_index = start_index;
+ prev_length = length;
}
while (pango_layout_iter_next_line (iter));
if (!found)
{
- start_index = prev_line->start_index + prev_line->length;
+ start_index = prev_start_index + prev_length;
end_index = start_index;
}
pango_layout_iter_free (iter);
{
PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL;
- int index, start_index, end_index;
+ int index, start_index, length, end_index;
const char *text;
gboolean found = FALSE;
do
{
line = pango_layout_iter_get_line (iter);
- start_index = line->start_index;
- end_index = start_index + line->length;
+ start_index = pango_layout_line_get_start_index (line);
+ length = pango_layout_line_get_length (line);
+ end_index = start_index + length;
if (index >= start_index && index <= end_index)
{
{
case ATSPI_TEXT_BOUNDARY_LINE_START:
if (pango_layout_iter_next_line (iter))
- end_index = pango_layout_iter_get_line (iter)->start_index;
+ end_index = pango_layout_line_get_start_index (pango_layout_iter_get_line (iter));
break;
case ATSPI_TEXT_BOUNDARY_LINE_END:
if (prev_line)
- start_index = prev_line->start_index + prev_line->length;
+ start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
break;
case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START:
if (!found)
{
- start_index = prev_line->start_index + prev_line->length;
+ start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
end_index = start_index;
}
pango_layout_iter_free (iter);
{
PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL;
- int index, start_index, end_index;
+ int index, start_index, length, end_index;
const char *text;
gboolean found = FALSE;
do
{
line = pango_layout_iter_get_line (iter);
- start_index = line->start_index;
- end_index = start_index + line->length;
+ start_index = pango_layout_line_get_start_index (line);
+ length = pango_layout_line_get_length (line);
+ end_index = start_index + length;
if (index >= start_index && index <= end_index)
{
switch (boundary_type)
{
case ATSPI_TEXT_BOUNDARY_LINE_START:
- start_index = line->start_index;
+ start_index = pango_layout_line_get_start_index (line);
if (pango_layout_iter_next_line (iter))
- end_index = pango_layout_iter_get_line (iter)->start_index;
+ end_index = pango_layout_line_get_start_index (pango_layout_iter_get_line (iter));
else
- end_index = start_index + line->length;
+ end_index = start_index + pango_layout_line_get_length (line);
break;
case ATSPI_TEXT_BOUNDARY_LINE_END:
start_index = end_index;
- end_index = line->start_index + line->length;
+ end_index = pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line);
break;
case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START:
if (!found)
{
- start_index = prev_line->start_index + prev_line->length;
+ start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
end_index = start_index;
}
pango_layout_iter_free (iter);
int first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
- found_byte = layout_line->start_index;
+ found_byte = pango_layout_line_get_start_index (layout_line);
if (line_top >= y)
{
int first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
- found_byte = layout_line->start_index;
+ found_byte = pango_layout_line_get_start_index (layout_line);
pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
if (update_byte)
{
- line_byte = layout_line->start_index + layout_line->length;
+ line_byte = pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line);
}
- if (line_byte < layout_line->length || !tmp_list->next) /* first line of paragraph */
+ if (line_byte < pango_layout_line_get_length (layout_line) || !tmp_list->next) /* first line of paragraph */
{
GtkTextLine *prev_line;
layout_line = tmp_list->data;
line_display_index_to_iter (layout, display, iter,
- layout_line->start_index + layout_line->length, 0);
+ pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line), 0);
break;
}
}
else
{
- int prev_offset = layout_line->start_index;
+ int prev_offset = pango_layout_line_get_start_index (layout_line);
tmp_list = tmp_list->next;
while (tmp_list)
{
layout_line = tmp_list->data;
- if (line_byte < layout_line->start_index + layout_line->length ||
+ if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
!tmp_list->next)
{
line_display_index_to_iter (layout, display, iter, prev_offset, 0);
break;
}
- prev_offset = layout_line->start_index;
+ prev_offset = pango_layout_line_get_start_index (layout_line);
tmp_list = tmp_list->next;
}
}
if (found)
{
line_display_index_to_iter (layout, display, iter,
- layout_line->start_index, 0);
+ pango_layout_line_get_start_index (layout_line), 0);
found_after = TRUE;
}
- else if (line_byte < layout_line->start_index + layout_line->length || !tmp_list->next)
+ else if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) || !tmp_list->next)
found = TRUE;
tmp_list = tmp_list->next;
{
PangoLayoutLine *layout_line = tmp_list->data;
- if (line_byte < layout_line->start_index + layout_line->length || !tmp_list->next)
+ if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) || !tmp_list->next)
{
line_display_index_to_iter (layout, display, iter,
- direction < 0 ? layout_line->start_index : layout_line->start_index + layout_line->length,
+ direction < 0 ? pango_layout_line_get_start_index (layout_line) : pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line),
0);
/* FIXME: As a bad hack, we move back one position when we
* are inside a paragraph to avoid going to next line on a
* forced break not at whitespace. Real fix is to keep track
* of whether marks are at leading or trailing edge? */
- if (direction > 0 && layout_line->length > 0 &&
+ if (direction > 0 && pango_layout_line_get_length (layout_line) > 0 &&
!gtk_text_iter_ends_line (iter) &&
!_gtk_text_btree_char_is_invisible (iter))
gtk_text_iter_backward_char (iter);
{
PangoLayoutLine *layout_line = tmp_list->data;
- if (line_byte < layout_line->start_index + layout_line->length ||
+ if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
!tmp_list->next)
{
/* We're located on this line or the para delimiters before
*/
gtk_text_line_display_unref (display);
- if (line_byte == layout_line->start_index)
+ if (line_byte == pango_layout_line_get_start_index (layout_line))
return TRUE;
else
return FALSE;
{
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
- if (line_byte < layout_line->start_index + layout_line->length ||
+ if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
pango_layout_iter_at_last_line (layout_iter))
{
PangoRectangle logical_rect;
* only do it if the selection is opaque.
*/
if (selection_start_index < byte_offset &&
- selection_end_index > line->length + byte_offset &&
+ selection_end_index > pango_layout_line_get_length (line) + byte_offset &&
selection->alpha >= 1)
{
gtk_snapshot_append_color (crenderer->snapshot,
baseline);
/* Check if some part of the line is selected; the newline
- * that is after line->length for the last line of the
+ * that is after pango_layout_line_get_length (line) for the last line of the
* paragraph counts as part of the line for this
*/
- if ((selection_start_index < byte_offset + line->length ||
- (selection_start_index == byte_offset + line->length && pango_layout_iter_at_last_line (iter))) &&
+ if ((selection_start_index < byte_offset + pango_layout_line_get_length (line) ||
+ (selection_start_index == byte_offset + pango_layout_line_get_length (line) && pango_layout_iter_at_last_line (iter))) &&
selection_end_index > byte_offset)
{
int *ranges = NULL;
/* Paint in the ends of the line */
if (line_rect.x > line_display->left_margin * PANGO_SCALE &&
((line_display->direction == GTK_TEXT_DIR_LTR && selection_start_index < byte_offset) ||
- (line_display->direction == GTK_TEXT_DIR_RTL && selection_end_index > byte_offset + line->length)))
+ (line_display->direction == GTK_TEXT_DIR_RTL && selection_end_index > byte_offset + pango_layout_line_get_length (line))))
gtk_snapshot_append_color (crenderer->snapshot,
selection,
&GRAPHENE_RECT_INIT (line_display->left_margin,
if (line_rect.x + line_rect.width <
(screen_width + line_display->left_margin) * PANGO_SCALE &&
- ((line_display->direction == GTK_TEXT_DIR_LTR && selection_end_index > byte_offset + line->length) ||
+ ((line_display->direction == GTK_TEXT_DIR_LTR && selection_end_index > byte_offset + pango_layout_line_get_length (line)) ||
(line_display->direction == GTK_TEXT_DIR_RTL && selection_start_index < byte_offset)))
{
int nonlayout_width = line_display->left_margin
gtk_widget_has_focus (crenderer->widget) &&
cursor_alpha > 0 &&
byte_offset <= line_display->insert_index &&
- (line_display->insert_index < byte_offset + line->length ||
- (at_last_line && line_display->insert_index == byte_offset + line->length)))
+ (line_display->insert_index < byte_offset + pango_layout_line_get_length (line) ||
+ (at_last_line && line_display->insert_index == byte_offset + pango_layout_line_get_length (line))))
{
GtkStyleContext *context;
GdkRGBA cursor_color;
}
}
- byte_offset += line->length;
+ byte_offset += pango_layout_line_get_length (line);
}
while (pango_layout_iter_next_line (iter));
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
int n_lines;
n_lines = pango_layout_get_line_count (layout);
-
+
if (n_lines >= DRAG_ICON_MAX_LINES)
{
text = pango_layout_get_text (layout);
text = pango_layout_get_text (layout);
- if (index < layout_line->start_index + layout_line->length)
+ if (index < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
{
/* this may be a zero-width character in the middle of the line,
* or it could be a character where line is wrapped, we do want
* block cursor in latter case */
if (g_utf8_next_char (text + index) - text !=
- layout_line->start_index + layout_line->length)
+ pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
{
/* zero-width character in the middle of the line, do not
* bother with block cursor */
/* In case when index points to the end of line, pos->x is always most right
* pixel of the layout line, so we need to correct it for RTL text. */
- if (layout_line->length)
+ if (pango_layout_line_get_length (layout_line))
{
- if (layout_line->resolved_dir == PANGO_DIRECTION_RTL)
+ if (pango_layout_line_get_resolved_direction (layout_line) == PANGO_DIRECTION_RTL)
{
PangoLayoutIter *iter;
PangoRectangle line_rect;