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);
}
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;
}
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;
}
Aggregations