Java 类org.eclipse.swt.custom.PaintObjectEvent 实例源码

项目:relations    文件:Styles.java   
/**
 * Convenience method
 * 
 * @param inWidget
 *            {@link StyledText}
 * @return {@link PaintObjectListener}
 */
public static PaintObjectListener getPaintObjectListener(
        final StyledText inWidget) {
    return new PaintObjectListener() {
        @Override
        public void paintObject(final PaintObjectEvent inEvent) {
            final Display lDisplay = inEvent.display;
            final StyleRange lStyle = inEvent.style;
            final int lPosition = inEvent.x + lStyle.metrics.width
                    - BULLET_WIDTH + 2;
            Font lFont = lStyle.font;
            if (lFont == null)
                lFont = inWidget.getFont();
            final TextLayout lLayout = new TextLayout(lDisplay);
            lLayout.setAscent(inEvent.ascent);
            lLayout.setDescent(inEvent.descent);
            lLayout.setFont(lFont);
            lLayout.setText(String.format("%s.", inEvent.bulletIndex + 1)); //$NON-NLS-1$
            lLayout.draw(inEvent.gc, lPosition, inEvent.y);
            lLayout.dispose();
        }
    };
}
项目:elexis-3-base    文件:Page.java   
public void paintObject(final PaintObjectEvent event){
    StyleRange style = event.style;
    int start = style.start;
    int index = 0;
    for (Iterator<Integer> it = offsets.iterator(); it.hasNext(); index++) {
        int offset = it.next();
        if (start == offset) {
            Control control = controls.get(index);
            Point pt = control.getSize();
            int x = event.x + MARGIN;
            int y = event.y + event.ascent - 2 * pt.y / 3;
            control.setLocation(x, y);
            break;
        }
    }
}
项目:SPELL    文件:CustomStyledText.java   
@Override
/**************************************************************************
 * Callback from PaintObjectListener interface for the styled text widget.
 * Used to set images.
 *************************************************************************/
public synchronized void paintObject(PaintObjectEvent event)
{
    if (m_view.isVisible())
    {
        // Get the line model
        // NOT COMPATIBLE WITH ECLIPSE 3.3 --BEGIN
        // TextViewLine line = (TextViewLine) event.style.data;
        // NOT COMPATIBLE WITH ECLIPSE 3.3 --END

        // Solution for backwards compatibility with ECLIPSE 3.3
        int lineIndex = m_view.getLineAtOffset(event.style.start);
        TextViewLine line = (TextViewLine) m_model.getLineObject(lineIndex);
        int height = m_view.getLineHeight() + m_view.getLineSpacing();

        // If there is an icon defined, draw it.

        Image icon = m_labelProvider.getImage(line.getType());
        if (icon != null)
        {
            event.gc.drawImage(icon, 0, 0, TextParagraph.ICON_SIZE, TextParagraph.ICON_SIZE, event.x, event.y,
                    height, height);
        }
    }
}