JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos (JNIEnv *env, jobject self, jint idx, jdoubleArray javaPos) { struct textlayout *tl; PangoRectangle pangoPos; jdouble *nativePos; gdk_threads_enter (); g_assert(self != NULL); g_assert(javaPos != NULL); tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, self); g_assert(tl != NULL); g_assert(tl->pango_layout != NULL); g_assert((*env)->GetArrayLength (env, javaPos) == 4); nativePos = (*env)->GetDoubleArrayElements (env, javaPos, NULL); pango_layout_index_to_pos (tl->pango_layout, idx, &pangoPos); nativePos[0] = (jdouble) pangoPos.x; nativePos[1] = (jdouble) pangoPos.y; nativePos[2] = (jdouble) pangoPos.width; nativePos[3] = (jdouble) pangoPos.height; (*env)->ReleaseDoubleArrayElements (env, javaPos, nativePos, 0); gdk_threads_leave (); }
/** * Find the position in a string where an x coordinate falls. * * \param[in] fstyle style for this text * \param[in] string UTF-8 string to measure * \param[in] length length of string, in bytes * \param[in] x coordinate to search for * \param[out] char_offset updated to offset in string of actual_x, [0..length] * \param[out] actual_x updated to x coordinate of character closest to x * \return NSERROR_OK and char_offset and actual_x updated or appropriate * error code on faliure */ static nserror nsfont_position_in_string(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { int index; PangoFontDescription *desc; PangoRectangle pos; nsfont_pango_check(); desc = nsfont_style_to_description(fstyle); pango_layout_set_font_description(nsfont_pango_layout, desc); pango_font_description_free(desc); pango_layout_set_text(nsfont_pango_layout, string, length); if (pango_layout_xy_to_index(nsfont_pango_layout, x * PANGO_SCALE, 0, &index, 0) == FALSE) { index = length; } pango_layout_index_to_pos(nsfont_pango_layout, index, &pos); *char_offset = index; *actual_x = PANGO_PIXELS(pos.x); return NSERROR_OK; }
static void gail_scale_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *widget; GtkScale *scale; PangoRectangle char_rect; PangoLayout *layout; gint index, x_layout, y_layout; const gchar *scale_text; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return; scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (scale); if (!layout) return; scale_text = pango_layout_get_text (layout); if (!scale_text) return; index = g_utf8_offset_to_pointer (scale_text, offset) - scale_text; gtk_scale_get_layout_offsets (scale, &x_layout, &y_layout); pango_layout_index_to_pos (layout, index, &char_rect); gail_misc_get_extents_from_pango_rectangle (widget, &char_rect, x_layout, y_layout, x, y, width, height, coords); }
static void gail_expander_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *widget; GtkWidget *label; PangoRectangle char_rect; gint index, x_layout, y_layout; const gchar *label_text; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return; label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (!GTK_IS_LABEL(label)) return; gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout); label_text = gtk_label_get_text (GTK_LABEL (label)); index = g_utf8_offset_to_pointer (label_text, offset) - label_text; pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect); gail_misc_get_extents_from_pango_rectangle (label, &char_rect, x_layout, y_layout, x, y, width, height, coords); }
int unicodeGetXRanges(char *utf8, int utf8Length, int *resultPtr, int resultLength) { int w, h, offsetX, offsetY; int count, ch, i, j; PangoRectangle rect; count = unicodeLength(utf8, utf8Length); if (resultLength < (2 * count)) return -1; if (cachedLayout == NULL) { cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1); cairo_t *cr = cairo_create(surface); cachedLayout = pango_cairo_create_layout(cr); } computeLayout(cachedLayout, utf8, utf8Length, &w, &h, &offsetX, &offsetY, NULL); i = j = 0; while ((i < utf8Length) && (j < (resultLength - 1))) { pango_layout_index_to_pos(cachedLayout, i, &rect); ch = utf8[i]; if ((ch & 0xE0) == 0xC0) i += 2; else if ((ch & 0xF0) == 0xE0) i += 3; else if ((ch & 0xF8) == 0xF0) i += 4; else i += 1; resultPtr[j] = PANGO_PIXELS(rect.x); resultPtr[j + 1] = PANGO_PIXELS(rect.x + rect.width); j += 2; } return count; }
static VALUE rg_index_to_pos(VALUE self, VALUE index) { PangoRectangle pos; pango_layout_index_to_pos(_SELF(self), NUM2INT(index), &pos); return BOXED2RVAL(&pos, PANGO_TYPE_RECTANGLE); }
static void gail_notebook_page_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *label; GailNotebookPage *notebook_page; PangoRectangle char_rect; gint index, x_layout, y_layout; const gchar *label_text; notebook_page = GAIL_NOTEBOOK_PAGE (text); label = get_label_from_notebook_page (notebook_page); if (!GTK_IS_LABEL(label)) return; gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout); label_text = gtk_label_get_text (GTK_LABEL (label)); index = g_utf8_offset_to_pointer (label_text, offset) - label_text; pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect); gail_misc_get_extents_from_pango_rectangle (label, &char_rect, x_layout, y_layout, x, y, width, height, coords); }
/* Given a paragraph and offset in that paragraph, find the * bounding rectangle for the character at the offset. */ void char_bounds (Paragraph *para, int index, int width, PangoRectangle *rect) { GList *para_list; int height = 0; para_list = paragraphs; while (para_list) { Paragraph *cur_para = para_list->data; if (cur_para == para) { PangoRectangle pos; pango_layout_index_to_pos (cur_para->layout, index, &pos); rect->x = PANGO_PIXELS (MIN (pos.x, pos.x + pos.width)); rect->width = PANGO_PIXELS (ABS (pos.width)); rect->y = height + PANGO_PIXELS (pos.y); rect->height = PANGO_PIXELS (pos.height); } height += cur_para->height; para_list = para_list->next; } }
static void gail_text_cell_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GailRendererCell *gail_renderer; GtkCellRendererText *gtk_renderer; GdkRectangle rendered_rect; GtkWidget *widget; AtkObject *parent; PangoRectangle char_rect; PangoLayout *layout; gint x_offset, y_offset, index, cell_height, cell_width; if (!GAIL_TEXT_CELL (text)->cell_text) { *x = *y = *height = *width = 0; return; } if (offset < 0 || offset >= GAIL_TEXT_CELL (text)->cell_length) { *x = *y = *height = *width = 0; return; } gail_renderer = GAIL_RENDERER_CELL (text); gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer); /* * Thus would be inconsistent with the cache */ gail_return_if_fail (gtk_renderer->text); parent = atk_object_get_parent (ATK_OBJECT (text)); if (GAIL_IS_CONTAINER_CELL (parent)) parent = atk_object_get_parent (parent); widget = GTK_ACCESSIBLE (parent)->widget; g_return_if_fail (GAIL_IS_CELL_PARENT (parent)); gail_cell_parent_get_cell_area (GAIL_CELL_PARENT (parent), GAIL_CELL (text), &rendered_rect); gtk_cell_renderer_get_size (GTK_CELL_RENDERER (gtk_renderer), widget, &rendered_rect, &x_offset, &y_offset, &cell_width, &cell_height); layout = create_pango_layout (gtk_renderer, widget); index = g_utf8_offset_to_pointer (gtk_renderer->text, offset) - gtk_renderer->text; pango_layout_index_to_pos (layout, index, &char_rect); gail_misc_get_extents_from_pango_rectangle (widget, &char_rect, x_offset + rendered_rect.x + gail_renderer->renderer->xpad, y_offset + rendered_rect.y + gail_renderer->renderer->ypad, x, y, width, height, coords); g_object_unref (layout); return; }
vector<XojPdfRectangle> TextView::findText(Text* t, string& search) { cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_t* cr = cairo_create(surface); PangoLayout* layout = initPango(cr, t); string str = t->getText(); pango_layout_set_text(layout, str.c_str(), str.length()); string text = t->getText(); string srch = StringUtils::toLowerCase(search); vector<XojPdfRectangle> list; int pos = -1; do { pos = StringUtils::toLowerCase(text).find(srch, pos + 1); if (pos != -1) { XojPdfRectangle mark; PangoRectangle rect = { 0 }; pango_layout_index_to_pos(layout, pos, &rect); mark.x1 = ((double) rect.x) / PANGO_SCALE + t->getX(); mark.y1 = ((double) rect.y) / PANGO_SCALE + t->getY(); pango_layout_index_to_pos(layout, pos + srch.length(), &rect); mark.x2 = ((double) rect.x + rect.width) / PANGO_SCALE + t->getX(); mark.y2 = ((double) rect.y + rect.height) / PANGO_SCALE + t->getY(); list.push_back(mark); } } while (pos != -1); g_object_unref(layout); cairo_surface_destroy(surface); cairo_destroy(cr); return list; }
GList * TextView::findText(Text * t, const char * search) { cairo_surface_t * surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_t * cr = cairo_create(surface); GList * list = NULL; PangoLayout * layout = initPango(cr, t); String str = t->getText(); pango_layout_set_text(layout, str.c_str(), str.size()); int pos = -1; String text = t->getText(); String srch = search; do { pos = text.indexOfCaseInsensitiv(srch, pos + 1); if (pos != -1) { XojPopplerRectangle * mark = new XojPopplerRectangle(); PangoRectangle rect = { 0 }; pango_layout_index_to_pos(layout, pos, &rect); mark->x1 = ((double) rect.x) / PANGO_SCALE + t->getX(); mark->y1 = ((double) rect.y) / PANGO_SCALE + t->getY(); pango_layout_index_to_pos(layout, pos + srch.length(), &rect); mark->x2 = ((double) rect.x + rect.width) / PANGO_SCALE + t->getX(); mark->y2 = ((double) rect.y + rect.height) / PANGO_SCALE + t->getY(); list = g_list_append(list, mark); } } while (pos != -1); g_object_unref(layout); cairo_surface_destroy(surface); cairo_destroy(cr); return list; }
static void gtk_label_accessible_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *widget; GtkLabel *label; PangoRectangle char_rect; const gchar *label_text; gint index, x_layout, y_layout; GdkWindow *window; gint x_window, y_window; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) return; label = GTK_LABEL (widget); gtk_label_get_layout_offsets (label, &x_layout, &y_layout); label_text = gtk_label_get_text (label); index = g_utf8_offset_to_pointer (label_text, offset) - label_text; pango_layout_index_to_pos (gtk_label_get_layout (label), index, &char_rect); pango_extents_to_pixels (&char_rect, NULL); window = gtk_widget_get_window (widget); gdk_window_get_origin (window, &x_window, &y_window); *x = x_window + x_layout + char_rect.x; *y = x_window + y_layout + char_rect.y; *width = char_rect.width; *height = char_rect.height; if (coords == ATK_XY_WINDOW) { window = gdk_window_get_toplevel (window); gdk_window_get_origin (window, &x_window, &y_window); *x -= x_window; *y -= y_window; } }
static void gtk_icon_view_item_accessible_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type) { GtkIconViewItemAccessible *item; #if 0 GtkIconView *icon_view; PangoRectangle char_rect; const gchar *item_text; gint index; #endif item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); if (!GTK_IS_ICON_VIEW (item->widget)) return; if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) return; #if 0 icon_view = GTK_ICON_VIEW (item->widget); /* FIXME we probably have to use GailTextCell to salvage this */ gtk_icon_view_update_item_text (icon_view, item->item); item_text = pango_layout_get_text (icon_view->priv->layout); index = g_utf8_offset_to_pointer (item_text, offset) - item_text; pango_layout_index_to_pos (icon_view->priv->layout, index, &char_rect); atk_component_get_position (ATK_COMPONENT (text), x, y, coord_type); *x += item->item->layout_x - item->item->x + char_rect.x / PANGO_SCALE; /* Look at gtk_icon_view_paint_item() to see where the text is. */ *x -= ((item->item->width - item->item->layout_width) / 2) + (MAX (item->item->pixbuf_width, icon_view->priv->item_width) - item->item->width) / 2, *y += item->item->layout_y - item->item->y + char_rect.y / PANGO_SCALE; *width = char_rect.width / PANGO_SCALE; *height = char_rect.height / PANGO_SCALE; #endif }
void gimp_text_tool_editor_get_cursor_rect (GimpTextTool *text_tool, gboolean overwrite, PangoRectangle *cursor_rect) { GtkTextBuffer *buffer = GTK_TEXT_BUFFER (text_tool->buffer); PangoLayout *layout; gint offset_x; gint offset_y; GtkTextIter cursor; gint cursor_index; g_return_if_fail (GIMP_IS_TEXT_TOOL (text_tool)); g_return_if_fail (cursor_rect != NULL); gtk_text_buffer_get_iter_at_mark (buffer, &cursor, gtk_text_buffer_get_insert (buffer)); cursor_index = gimp_text_buffer_get_iter_index (text_tool->buffer, &cursor, TRUE); gimp_text_tool_ensure_layout (text_tool); layout = gimp_text_layout_get_pango_layout (text_tool->layout); gimp_text_layout_get_offsets (text_tool->layout, &offset_x, &offset_y); if (overwrite) pango_layout_index_to_pos (layout, cursor_index, cursor_rect); else pango_layout_get_cursor_pos (layout, cursor_index, cursor_rect, NULL); gimp_text_layout_transform_rect (text_tool->layout, cursor_rect); cursor_rect->x = PANGO_PIXELS (cursor_rect->x) + offset_x; cursor_rect->y = PANGO_PIXELS (cursor_rect->y) + offset_y; cursor_rect->width = PANGO_PIXELS (cursor_rect->width); cursor_rect->height = PANGO_PIXELS (cursor_rect->height); }
GpStatus pango_MeasureCharacterRanges (GpGraphics *graphics, GDIPCONST WCHAR *stringUnicode, int length, GDIPCONST GpFont *font, GDIPCONST GpRectF *layoutRect, GDIPCONST GpStringFormat *format, int regionCount, GpRegion **regions) { PangoLayout *layout; GpStatus status = Ok; int i, j; GpRectF boundingBox; cairo_save (graphics->ct); layout = gdip_pango_setup_layout (graphics, stringUnicode, length, font, layoutRect, &boundingBox, format, NULL); if (!layout) { cairo_restore (graphics->ct); return OutOfMemory; } /* Create a region for every char range */ for (i = 0; i < format->charRangeCount; i++) { int start, end; CharacterRange range = format->charRanges [i]; GdipSetEmpty (regions [i]); if (range.Length > 0) start = range.First; else start = range.First + range.Length; end = start + range.Length; /* sanity check on charRange. negative lengths are allowed */ if (range.First < 0) { status = InvalidParameter; goto cleanup; } if ((start < 0) || (end > length)) { status = InvalidParameter; goto cleanup; } /* calculate the initial UTF-8 index */ int idxUtf8 = utf8_length_for_ucs2_string (stringUnicode, 0, start); /* calculate the regions */ for (j = start; j < end; j++) { PangoRectangle box; GpRectF charRect; pango_layout_index_to_pos (layout, idxUtf8, &box); charRect.X = (float)box.x / PANGO_SCALE; charRect.Y = (float)box.y / PANGO_SCALE; charRect.Width = (float)box.width / PANGO_SCALE; charRect.Height = (float)box.height / PANGO_SCALE; /* Normalize values (width/height can be negative) */ if (charRect.Width < 0) { charRect.Width = -charRect.Width; charRect.X -= charRect.Width; } if (charRect.Height < 0) { charRect.Height = -charRect.Height; charRect.Y -= charRect.Height; } // g_warning ("[%d] [%d : %d-%d] %c [x %g y %g w %g h %g]", i, j, start, end, (char)stringUnicode[j], charRect.X, charRect.Y, charRect.Width, charRect.Height); status = GdipCombineRegionRect (regions [i], &charRect, CombineModeUnion); if (status != Ok) break; // update the UTF-8 index idxUtf8 += utf8_length_for_ucs2_string (stringUnicode, j, 1); } if (status != Ok) break; } cleanup: cairo_restore (graphics->ct); return status; }
static void gtk_text_cell_accessible_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkRendererCellAccessible *gail_renderer; GtkRequisition min_size; GtkCellRendererText *gtk_renderer; GdkRectangle rendered_rect; GtkWidget *widget; AtkObject *parent; PangoRectangle char_rect; PangoLayout *layout; gchar *renderer_text; gfloat xalign, yalign; gint x_offset, y_offset, index; gint xpad, ypad; gint x_window, y_window, x_toplevel, y_toplevel; if (!GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text) { *x = *y = *height = *width = 0; return; } if (offset < 0 || offset >= GTK_TEXT_CELL_ACCESSIBLE (text)->cell_length) { *x = *y = *height = *width = 0; return; } gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text); gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer); g_object_get (gtk_renderer, "text", &renderer_text, NULL); if (text == NULL) { g_free (renderer_text); return; } parent = atk_object_get_parent (ATK_OBJECT (text)); if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent)) parent = atk_object_get_parent (parent); widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)); g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent)); _gtk_cell_accessible_parent_get_cell_area (GTK_CELL_ACCESSIBLE_PARENT (parent), GTK_CELL_ACCESSIBLE (text), &rendered_rect); gtk_cell_renderer_get_preferred_size (GTK_CELL_RENDERER (gtk_renderer), widget, &min_size, NULL); gtk_cell_renderer_get_alignment (GTK_CELL_RENDERER (gtk_renderer), &xalign, &yalign); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) xalign = 1.0 - xalign; x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width)); y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height)); layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text)); index = g_utf8_offset_to_pointer (renderer_text, offset) - renderer_text; pango_layout_index_to_pos (layout, index, &char_rect); gtk_cell_renderer_get_padding (gail_renderer->renderer, &xpad, &ypad); get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel); *x = (char_rect.x / PANGO_SCALE) + x_offset + rendered_rect.x + xpad + x_window; *y = (char_rect.y / PANGO_SCALE) + y_offset + rendered_rect.y + ypad + y_window; *height = char_rect.height / PANGO_SCALE; *width = char_rect.width / PANGO_SCALE; if (coords == ATK_XY_WINDOW) { *x -= x_toplevel; *y -= y_toplevel; } else if (coords != ATK_XY_SCREEN) { *x = 0; *y = 0; *height = 0; *width = 0; } g_free (renderer_text); g_object_unref (layout); }
/* Redraw the contents of the lcd display. * note: start BORDER pixels down and to the right. * TODO: we could be smart and only redraw what has changed. * This does this work correctly with varriable sized fonts. */ void drawStackLCD(){ int i; int curPos; int strt, stop; GdkGC *drawgc; #ifdef USE_PANGO PangoRectangle rect; int pango_pos; #endif /* draw the stack */ for(i=0; i<lcdHeight; i++){ /* draw the first unhighlighted section of the line */ strt = 0; if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ stop = hiX1; if(stop > lcdWidth) stop = lcdWidth; } else { stop = lcdWidth; } if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdGC, pango_pos + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_window_clear_area(lcdDA->window, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } /* draw the highlighted section of the line */ if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ strt = hiX1; if(strt > lcdWidth) strt = lcdWidth; stop = hiX2+1; if(stop > lcdWidth) stop = lcdWidth; if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE, pango_pos + BORDER + SHIFT, i*fontH + BORDER, fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdHighlightGC, strt*fontW + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdHighlightGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } } /* draw the last unhighlighted section of the line */ stop = lcdWidth; if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ strt = hiX2+1; if(strt > lcdWidth) strt = lcdWidth; } else { strt = lcdWidth; } if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdGC, pango_pos + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_window_clear_area(lcdDA->window, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } } /* draw the cursor */ if(isEditingEditor()){ curPos = cursorPosEditor(); if(curPos > lcdWidth){ curPos = lcdWidth; } if(dataSelected == DATA_SELECTED && curPos>=hiX1 && curPos<=hiX2 && lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2) { drawgc = lcdHighlightGC; } else { drawgc = lcdGC; } /* hack: draw a white line to erase any old cursor in position 0. XDrawImageString dosen't cover this up like it does with an old cursor in any other position */ if(!(dataSelected == DATA_SELECTED && 0==hiX1 && lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2)) { gdk_draw_line(lcdDA->window, lcdHighlightGC, BORDER + SHIFT, (lcdHeight-1) * fontH + BORDER, BORDER + SHIFT, lcdHeight * fontH - 1 + BORDER); } /* draw the cursor */ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, curPos, &rect); pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER; gdk_draw_line(lcdDA->window, drawgc, pango_pos, (lcdHeight-1) * fontH + BORDER, pango_pos, lcdHeight * fontH - 1 + BORDER); /* Flush GDK display, seems to be needed in certain environments */ gdk_flush(); } else { pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER; if (pango_pos > lcdDA->allocation.width - BORDER && lcdWidth > 6) { lcdWidth -= 1; clearLCDwindow(); calcStackLCD(); drawStackLCD(); } } #else gdk_draw_line(lcdDA->window, drawgc, fontW * curPos + SHIFT + BORDER, (lcdHeight-1) * fontH + BORDER, fontW * curPos + SHIFT + BORDER, lcdHeight * fontH - 1 + BORDER); }