Search in sources :

Example 11 with GlyphMetrics

use of org.eclipse.swt.graphics.GlyphMetrics in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_custom_StyledText method test_caretSizeAndPositionVariableGlyphMetrics.

@Test
public void test_caretSizeAndPositionVariableGlyphMetrics() {
    text.setText("abcd");
    // keep leftMargin as it affects behavior
    text.setMargins(2, 0, 0, 0);
    text.setLineSpacing(0);
    StyleRange range = new StyleRange(2, 1, null, null);
    range.metrics = new GlyphMetrics(100, 0, 10);
    text.setStyleRange(range);
    text.setCaretOffset(0);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    // +5: caret takes 5 more pixels
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(1);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(2);
    assertEquals(text.getLineHeight(0), text.getCaret().getSize().y);
    assertEquals(0, text.getCaret().getBounds().y);
    text.setCaretOffset(3);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(4);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(3);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(2);
    assertEquals(text.getLineHeight(0), text.getCaret().getSize().y);
    assertEquals(0, text.getCaret().getBounds().y);
    text.setCaretOffset(1);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
    text.setCaretOffset(0);
    assertEquals(text.getLineHeight(), text.getCaret().getSize().y);
    assertEquals(text.getLineHeight(0) - text.getCaret().getSize().y, text.getCaret().getBounds().y);
}
Also used : GlyphMetrics(org.eclipse.swt.graphics.GlyphMetrics) StyleRange(org.eclipse.swt.custom.StyleRange) Test(org.junit.Test)

Example 12 with GlyphMetrics

use of org.eclipse.swt.graphics.GlyphMetrics in project netxms by netxms.

the class AnsiIOConsoleViewer method addRange.

/**
 * @param ranges
 * @param start
 * @param length
 * @param foreground
 * @param isCode
 */
private void addRange(List<StyleRange> ranges, int start, int length, Color foreground, boolean isCode) {
    StyleRange range = new StyleRange(start, length, foreground, null);
    AnsiConsoleAttributes.updateRangeStyle(range, lastAttributes);
    if (isCode) {
        range.metrics = new GlyphMetrics(0, 0, 0);
    }
    ranges.add(range);
    lastRangeEnd = lastRangeEnd + range.length;
}
Also used : GlyphMetrics(org.eclipse.swt.graphics.GlyphMetrics) StyleRange(org.eclipse.swt.custom.StyleRange)

Example 13 with GlyphMetrics

use of org.eclipse.swt.graphics.GlyphMetrics in project egit by eclipse.

the class SourceBranchFailureDialog method createBullet.

private Bullet createBullet(Composite main) {
    StyleRange style = new StyleRange();
    style.metrics = new GlyphMetrics(0, 0, 40);
    style.foreground = main.getDisplay().getSystemColor(SWT.COLOR_BLACK);
    Bullet bullet = new Bullet(style);
    return bullet;
}
Also used : Bullet(org.eclipse.swt.custom.Bullet) GlyphMetrics(org.eclipse.swt.graphics.GlyphMetrics) StyleRange(org.eclipse.swt.custom.StyleRange)

Aggregations

GlyphMetrics (org.eclipse.swt.graphics.GlyphMetrics)13 StyleRange (org.eclipse.swt.custom.StyleRange)10 Point (org.eclipse.swt.graphics.Point)8 Rectangle (org.eclipse.swt.graphics.Rectangle)3 TextStyle (org.eclipse.swt.graphics.TextStyle)3 InnerTagBean (net.heartsome.cat.common.innertag.InnerTagBean)2 Position (org.eclipse.jface.text.Position)2 Bullet (org.eclipse.swt.custom.Bullet)2 InnerTag (net.heartsome.cat.common.ui.innertag.InnerTag)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 TextLayout (org.eclipse.swt.graphics.TextLayout)1 Test (org.junit.Test)1