Search in sources :

Example 1 with Bullet

use of org.eclipse.swt.custom.Bullet in project eclipse.platform.swt by eclipse.

the class TextEditor method setBullet.

void setBullet(int type) {
    Point selection = styledText.getSelection();
    int lineStart = styledText.getLineAtOffset(selection.x);
    int lineEnd = styledText.getLineAtOffset(selection.y);
    StyleRange styleRange = new StyleRange();
    styleRange.metrics = new GlyphMetrics(0, 0, BULLET_WIDTH);
    Bullet bullet = new Bullet(type, styleRange);
    bullet.text = ".";
    for (int lineIndex = lineStart; lineIndex <= lineEnd; lineIndex++) {
        Bullet oldBullet = styledText.getLineBullet(lineIndex);
        styledText.setLineBullet(lineIndex, 1, oldBullet != null ? null : bullet);
    }
}
Also used : Bullet(org.eclipse.swt.custom.Bullet) GlyphMetrics(org.eclipse.swt.graphics.GlyphMetrics) StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

Bullet (org.eclipse.swt.custom.Bullet)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 GlyphMetrics (org.eclipse.swt.graphics.GlyphMetrics)1 Point (org.eclipse.swt.graphics.Point)1