/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount () { checkLayout(); computeRuns(null); return runs.length; }
/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount() { checkLayout (); computeRuns(); return OS.pango_layout_get_line_count(layout); }
/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount() { checkLayout (); computeRuns(); return OS.pango_layout_get_line_count(layout); }
/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount() { checkLayout (); computeRuns(); return OS.pango_layout_get_line_count(layout); }
/** * Returns the line offsets. Each value in the array is the * offset for the first character in a line except for the last * value, which contains the length of the text. * * @return the line offsets * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int[] getLineOffsets () { checkLayout(); computeRuns(null); int[] offsets = new int[lineOffset.length]; for (int i = 0; i < offsets.length; i++) { offsets[i] = untranslateOffset(lineOffset[i]); } return offsets; }
/** * Returns the index of the line that contains the specified * character offset. * * @param offset the character offset * @return the line index * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li> * </ul> * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineIndex (int offset) { checkLayout(); computeRuns(null); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); offset = translateOffset(offset); for (int line=0; line<runs.length; line++) { if (lineOffset[line + 1] > offset) { return line; } } return runs.length - 1; }
Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(null); if (!(0 <= lineIndex && lineIndex < runs.length)) SWT.error(SWT.ERROR_INVALID_RANGE); int x = getLineIndent(lineIndex); int y = DPIUtil.autoScaleUp(lineY[lineIndex]); int width = lineWidth[lineIndex]; int height = DPIUtil.autoScaleUp(lineY[lineIndex + 1] - lineY[lineIndex] - lineSpacingInPoints); return new Rectangle (x, y, width, height); }
Point getLocationInPixels(int offset, boolean trailing) { computeRuns(); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); offset = translateOffset(offset); long /*int*/ ptr = OS.pango_layout_get_text(layout); int byteOffset = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, offset) - ptr); int strlen = OS.strlen(ptr); byteOffset = Math.min(byteOffset, strlen); PangoRectangle pos = new PangoRectangle(); OS.pango_layout_index_to_pos(layout, byteOffset, pos); int x = trailing ? pos.x + pos.width : pos.x; int y = pos.y; x = OS.PANGO_PIXELS(x); if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x; } x += Math.min (indent, wrapIndent); return new Point(x, OS.PANGO_PIXELS(y)); }
Point getLocationInPixels(int offset, boolean trailing) { computeRuns(); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); offset = translateOffset(offset); int /*long*/ ptr = OS.pango_layout_get_text(layout); int byteOffset = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, offset) - ptr); int strlen = OS.strlen(ptr); byteOffset = Math.min(byteOffset, strlen); PangoRectangle pos = new PangoRectangle(); OS.pango_layout_index_to_pos(layout, byteOffset, pos); int x = trailing ? pos.x + pos.width : pos.x; int y = pos.y; x = OS.PANGO_PIXELS(x); if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x; } x += Math.min (indent, wrapIndent); return new Point(x, OS.PANGO_PIXELS(y)); }
Point getLocationInPixels(int offset, boolean trailing) { computeRuns(); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); offset = translateOffset(offset); int /*long*/ ptr = OS.pango_layout_get_text(layout); int byteOffset = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, offset) - ptr); int strlen = OS.strlen(ptr); byteOffset = Math.min(byteOffset, strlen); PangoRectangle pos = new PangoRectangle(); OS.pango_layout_index_to_pos(layout, byteOffset, pos); int x = trailing ? pos.x + pos.width : pos.x; int y = pos.y; x = OS.PANGO_PIXELS(x); if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x; } x += Math.min (indent, wrapIndent); return new Point(x, OS.PANGO_PIXELS(y)); }
/** * Returns the line offsets. Each value in the array is the * offset for the first character in a line except for the last * value, which contains the length of the text. * * @return the line offsets * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int[] getLineOffsets() { checkLayout(); computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); int[] offsets = new int [lineCount + 1]; long /*int*/ ptr = OS.pango_layout_get_text(layout); PangoLayoutLine line = new PangoLayoutLine(); for (int i = 0; i < lineCount; i++) { long /*int*/ linePtr = OS.pango_layout_get_line(layout, i); OS.memmove(line, linePtr, PangoLayoutLine.sizeof); int pos = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + line.start_index); offsets[i] = untranslateOffset(pos); } offsets[lineCount] = text.length(); return offsets; }
/** * Returns the line offsets. Each value in the array is the * offset for the first character in a line except for the last * value, which contains the length of the text. * * @return the line offsets * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int[] getLineOffsets() { checkLayout(); computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); int[] offsets = new int [lineCount + 1]; int /*long*/ ptr = OS.pango_layout_get_text(layout); PangoLayoutLine line = new PangoLayoutLine(); for (int i = 0; i < lineCount; i++) { int /*long*/ linePtr = OS.pango_layout_get_line(layout, i); OS.memmove(line, linePtr, PangoLayoutLine.sizeof); int pos = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + line.start_index); offsets[i] = untranslateOffset(pos); } offsets[lineCount] = text.length(); return offsets; }
/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount() { checkLayout (); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { computeRuns(); return lineOffsets.length - 1; } finally { if (pool != null) pool.release(); } }
Rectangle getBoundsInPixels() { checkLayout(); computeRuns(); int[] w = new int[1], h = new int[1]; OS.pango_layout_get_size(layout, w, h); int wrapWidth = OS.pango_layout_get_width(layout); w[0] = wrapWidth != -1 ? wrapWidth : w[0] + OS.pango_layout_get_indent(layout); int width = OS.PANGO_PIXELS(w[0]); int height = OS.PANGO_PIXELS(h[0]); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } height += OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout)); return new Rectangle(0, 0, width, height); }
Rectangle getBoundsInPixels() { checkLayout(); computeRuns(); int[] w = new int[1], h = new int[1]; OS.pango_layout_get_size(layout, w, h); int wrapWidth = OS.pango_layout_get_width(layout); w[0] = wrapWidth != -1 ? wrapWidth : w[0] + OS.pango_layout_get_indent(layout); int width = OS.PANGO_PIXELS(w[0]); int height = OS.PANGO_PIXELS(h[0]); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } height += OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout)); return new Rectangle(0, 0, width, height); }
Rectangle getBoundsInPixels() { checkLayout(); computeRuns(); int[] w = new int[1], h = new int[1]; OS.pango_layout_get_size(layout, w, h); int wrapWidth = OS.pango_layout_get_width(layout); w[0] = wrapWidth != -1 ? wrapWidth : w[0] + OS.pango_layout_get_indent(layout); int width = OS.PANGO_PIXELS(w[0]); int height = OS.PANGO_PIXELS(h[0]); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } height += OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout)); return new Rectangle(0, 0, width, height); }
/** * Returns the line offsets. Each value in the array is the * offset for the first character in a line except for the last * value, which contains the length of the text. * * @return the line offsets * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int[] getLineOffsets() { checkLayout (); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { computeRuns(); int[] offsets = new int[lineOffsets.length]; for (int i = 0; i < offsets.length; i++) { offsets[i] = untranslateOffset(lineOffsets[i]); } return offsets; } finally { if (pool != null) pool.release(); } }
Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE); long /*int*/ iter = OS.pango_layout_get_iter(layout); if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); for (int i = 0; i < lineIndex; i++) OS.pango_layout_iter_next_line(iter); PangoRectangle rect = new PangoRectangle(); OS.pango_layout_iter_get_line_extents(iter, null, rect); OS.pango_layout_iter_free(iter); int x = OS.PANGO_PIXELS(rect.x); int y = OS.PANGO_PIXELS(rect.y); int width = OS.PANGO_PIXELS(rect.width); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x - width; } x += Math.min (indent, wrapIndent); return new Rectangle(x, y, width, height); }
Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE); int /*long*/ iter = OS.pango_layout_get_iter(layout); if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); for (int i = 0; i < lineIndex; i++) OS.pango_layout_iter_next_line(iter); PangoRectangle rect = new PangoRectangle(); OS.pango_layout_iter_get_line_extents(iter, null, rect); OS.pango_layout_iter_free(iter); int x = OS.PANGO_PIXELS(rect.x); int y = OS.PANGO_PIXELS(rect.y); int width = OS.PANGO_PIXELS(rect.width); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x - width; } x += Math.min (indent, wrapIndent); return new Rectangle(x, y, width, height); }
Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE); int /*long*/ iter = OS.pango_layout_get_iter(layout); if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); for (int i = 0; i < lineIndex; i++) OS.pango_layout_iter_next_line(iter); PangoRectangle rect = new PangoRectangle(); OS.pango_layout_iter_get_line_extents(iter, null, rect); OS.pango_layout_iter_free(iter); int x = OS.PANGO_PIXELS(rect.x); int y = OS.PANGO_PIXELS(rect.y); int width = OS.PANGO_PIXELS(rect.width); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); } if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) { x = width() - x - width; } x += Math.min (indent, wrapIndent); return new Rectangle(x, y, width, height); }