Java 类org.eclipse.swt.events.PaintEvent 实例源码

项目:convertigo-eclipse    文件:KTable.java   
protected void onPaint(PaintEvent event) {
  Rectangle rect = getClientArea();
  GC gc = event.gc;

  doCalculations();

  if (m_Model != null) {

    drawBottomSpace(gc);
    drawCells(gc, gc.getClipping(), 0, m_Model.getFixedColumnCount(),
        0, m_Model.getFixedRowCount());
    drawCells(gc, gc.getClipping(), m_LeftColumn, m_Model
        .getColumnCount(), 0, m_Model.getFixedRowCount());
    drawCells(gc, gc.getClipping(), 0, m_Model.getFixedColumnCount(),
        m_TopRow, m_TopRow + m_RowsVisible);
    drawCells(gc, gc.getClipping(), m_LeftColumn, m_Model
        .getColumnCount(), m_TopRow, m_TopRow + m_RowsVisible);
  } else {
    gc.fillRectangle(rect);
  }
}
项目:avoCADo    文件:MELabel.java   
@Override
void paintElement(PaintEvent e) {
    GC g = e.gc;
    g.setBackground(this.getBackground());
    int width  = this.getBounds().width;
    int height = this.getBounds().height;

    // clear entire canvas where button will be painted
    g.fillRectangle(0, 0, width, height);

    // draw text
    g.setForeground(this.meColorForeground);
    FontData fd = new FontData();
    fd.setHeight(8);
    if(textIsBold){
        fd.setStyle(SWT.BOLD);
    }else{
        fd.setStyle(SWT.NORMAL);
    }
    g.setFont(new Font(this.getDisplay(), fd));
    Point textPt = g.textExtent(this.meLabel);          
    g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
项目:avoCADo    文件:MESpacer.java   
@Override
void paintElement(PaintEvent e) {
    GC g = e.gc;
    g.setBackground(this.getBackground());
    int width  = this.getBounds().width;
    int height = this.getBounds().height;

    // clear entire canvas where button will be painted
    g.fillRectangle(0, 0, width, height);

    if(showImage && meIcon != null){
        Rectangle b = meIcon.getBounds();
        int imageX = Math.max((width-b.width)/2, 1);
        int imageY = Math.max((height-b.height)/2, 1);
        g.drawImage(meIcon, imageX, imageY);
    }
}
项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
    // FIXME - not i18n safe!!
    String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
    if (disk.getBitmapLabels().length == 2) {
        label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
    }
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<label.length(); i++) {
        if (i>0) buf.append("\n"); //$NON-NLS-1$
        buf.append(label.charAt(i));
    }
    label = buf.toString();
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();
    event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
    Point size = event.gc.textExtent(label);
    event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Paint a block map.
 */ 
private void paintBlockMap(PaintEvent event) {
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();

    double blocks = disk.getBitmapLength();
    double width = area.width;
    double height = area.height;
    double factor = Math.sqrt(blocks / (width * height));
    int xdim = (int) (width * factor + 0.5);
    int ydim = (int) (height * factor + 0.5);
    if (xdim * ydim < blocks) {
        xdim++;
    }
    if (xdim * ydim < blocks) {
        ydim++;
    }

    paintDiskMap(xdim, ydim, event);
}
项目:applecommander    文件:DiskMapTab.java   
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
    // FIXME - not i18n safe!!
    String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
    if (disk.getBitmapLabels().length == 2) {
        label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
    }
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<label.length(); i++) {
        if (i>0) buf.append("\n"); //$NON-NLS-1$
        buf.append(label.charAt(i));
    }
    label = buf.toString();
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();
    event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
    Point size = event.gc.textExtent(label);
    event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
项目:applecommander    文件:DiskMapTab.java   
/**
 * Paint a block map.
 */ 
private void paintBlockMap(PaintEvent event) {
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();

    double blocks = disk.getBitmapLength();
    double width = area.width;
    double height = area.height;
    double factor = Math.sqrt(blocks / (width * height));
    int xdim = (int) (width * factor + 0.5);
    int ydim = (int) (height * factor + 0.5);
    if (xdim * ydim < blocks) {
        xdim++;
    }
    if (xdim * ydim < blocks) {
        ydim++;
    }

    paintDiskMap(xdim, ydim, event);
}
项目:parabuild-ci    文件:SWTStrokeCanvas.java   
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
项目:BiglyBT    文件:SWTBGImagePainter.java   
public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell(display, SWT.DIALOG_TRIM);
    shell.setLayout(new FillLayout());

    Composite c = new Composite(shell, SWT.BORDER);
    c.setLayout(new FillLayout());
    c.addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            e.gc.drawLine(0, 0, 100, 50);
        }
    });

    Label lbl = new Label(c, SWT.NONE);
    lbl.setText("text");

    shell.open();

    while (!shell.isDisposed()) {
        if (display.readAndDispatch()) {
            display.sleep();
        }
    }
}
项目:BiglyBT    文件:SWTBGImagePainter2.java   
public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell(display, SWT.DIALOG_TRIM);
    shell.setLayout(new FillLayout());

    Composite c = new Composite(shell, SWT.BORDER);
    c.setLayout(new FillLayout());
    c.addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            e.gc.drawLine(0, 0, 100, 50);
        }
    });

    Label lbl = new Label(c, SWT.NONE);
    lbl.setText("text");

    shell.open();

    while (!shell.isDisposed()) {
        if (display.readAndDispatch()) {
            display.sleep();
        }
    }
}
项目:ccu-historian    文件:SWTStrokeCanvas.java   
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
项目:PhET    文件:SWTBenchTest.java   
/**
 * Create a new Piccolo2D SWT benchmarking test suite with the specified parent and style.
 *
 * @param parent parent
 * @param style style
 */
private SWTBenchTest(final Composite parent, final int style) {
    super(parent, style);

    testImageOpaque = loadImage(getDisplay(), "opaque.jpg");
    testImageBitmask = loadImage(getDisplay(), "bitmask.gif");
    testImageTranslucent = loadImage(getDisplay(), "translucent.png");
    testImageARGB = new Image(getDisplay(), 128, 128);

    final GC tmpGC = new GC(testImageARGB);
    tmpGC.drawImage(testImageTranslucent, 0, 0);
    tmpGC.dispose();

    addPaintListener(new PaintListener() {
        public void paintControl(final PaintEvent pe) {
            runAll(new SWTGraphics2D(pe.gc, getDisplay()));
        }
    });
}
项目:team-explorer-everywhere    文件:ImageButton.java   
@Override
public void paintControl(final PaintEvent e) {
    /*
     * We get a paint event when the shell containing this control loses
     * or gains focus. Unfortunately, we are not guaranteed to paint our
     * entire control, so we force a redraw to guarantee a full
     * painting.
     */
    if (hasPainted && shellFocusChanged()) {
        redraw();
        return;
    }

    final Image buttonImage = getImage();

    if (buttonImage != null && !e.gc.isDisposed()) {
        e.gc.drawImage(buttonImage, 0, 0);
    }

    hasPainted = true;
}
项目:aya-lang    文件:SWTStrokeCanvas.java   
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
项目:http4e    文件:CustomSeparator.java   
public CustomSeparator( Composite parent, int style) {
   super(parent, style = checkStyle(style));

   this.style = style;

   if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0)
      lineSize = 2;
   else
      lineSize = 1;

   addPaintListener(new PaintListener() {
      public void paintControl( PaintEvent event){
         onPaint(event);
      }
   });
}
项目:TuxGuitar-1.3.1-fork    文件:TGSplash.java   
public void init() {
    if(TuxGuitar.getInstance().getConfig().getBooleanValue(TGConfigKeys.SHOW_SPLASH)){
        final Image image = TuxGuitar.getInstance().getIconManager().getAppSplash();

        this.shell = new Shell(TuxGuitar.getInstance().getDisplay(), SWT.NO_TRIM | SWT.NO_BACKGROUND);
        this.shell.setLayout(new FillLayout());
        this.shell.setBounds(getBounds(image));
        this.shell.setImage(TuxGuitar.getInstance().getIconManager().getAppIcon());
        this.shell.setText(TuxGuitar.APPLICATION_NAME);
        this.shell.addPaintListener(new PaintListener() {
            public void paintControl(PaintEvent e) {
                TGPainter painter = new TGPainterImpl(e.gc);
                painter.drawImage(new TGImageImpl(image), 0, 0);
            }
        });
        this.shell.open();
        this.shell.redraw();
        this.shell.update();
    }
}
项目:TuxGuitar-1.3.1-fork    文件:TGTunerRoughWidget.java   
public void init() {
    this.setLayout(new GridLayout(1,true));
    this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    ((GridData)this.getLayoutData()).widthHint = 600;


    this.composite = new Composite(this,SWT.BORDER | SWT.DOUBLE_BUFFERED);
    this.composite.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    this.composite.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            TGPainterImpl painter = new TGPainterImpl(e.gc);
            TGTunerRoughWidget.this.paintWidget(painter);
        }

    });
    GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
    data.minimumHeight = MIN_HEIGHT;
    data.grabExcessHorizontalSpace = true;
    this.composite.setLayoutData(data);

}
项目:Black    文件:startInfo.java   
/**
 * Create contents of the shell.
 */
protected void createContents() {
    setText("SWT Application");
    setSize(673, 173);
    windowLocation.showWindowOnScreenCenter(this);
    addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            // TODO Auto-generated method stub
            e.gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
            e.gc.drawString(infotext, 20, getSize().y-20,true);

        }
    });

}
项目:statecharts    文件:StatechartDiagramEditor.java   
public RotatedLabel(Composite parent, int style) {
    super(parent, style);

    this.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            paint(e);
        }
    });
    this.addListener(SWT.MouseDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (switchListener != null && !isDefinitionSectionExpanded)
                switchListener.handleSelection();
        }
    });
}
项目:raptor-chess-interface    文件:ResultDecorator.java   
/**
 * Draws the result text centered in the specified component.
 * 
 * @param e
 *            The paint event to draw in.
 * @param text
 *            The text to draw.
 */
protected void drawResultText(PaintEvent e, String text) {
    if (text != null) {
        e.gc.setForeground(Raptor.getInstance().getPreferences().getColor(
                PreferenceKeys.RESULTS_COLOR));

        e.gc.setFont(getResultFont(e.height));

        Point extent = e.gc.stringExtent(text);

        if (frame != -1) {
            e.gc.setAdvanced(true);
            e.gc.setAlpha((int)(255.0/ANIMATION_STAGES * frame));
            e.gc.drawString(text, e.width / 2 - extent.x / 2, e.height / 2
                    - extent.y / 2, true);
            e.gc.setAlpha(255);
        } else {
            e.gc.drawString(text, e.width / 2 - extent.x / 2, e.height / 2
                    - extent.y / 2, true);
        }
    }
}
项目:scouter    文件:ActiveSpeedCommonView.java   
public void createPartControl(Composite parent) {
    setTitleImage(Images.TYPE_ACTSPEED);
    canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED);
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            try {
                area = canvas.getClientArea();
                drawCanvasImage(e.gc);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    });

    window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
项目:piccolo2d.java    文件:SWTBenchTest.java   
/**
 * Create a new Piccolo2D SWT benchmarking test suite with the specified parent and style.
 *
 * @param parent parent
 * @param style style
 */
private SWTBenchTest(final Composite parent, final int style) {
    super(parent, style);

    testImageOpaque = loadImage(getDisplay(), "opaque.jpg");
    testImageBitmask = loadImage(getDisplay(), "bitmask.gif");
    testImageTranslucent = loadImage(getDisplay(), "translucent.png");
    testImageARGB = new Image(getDisplay(), 128, 128);

    final GC tmpGC = new GC(testImageARGB);
    tmpGC.drawImage(testImageTranslucent, 0, 0);
    tmpGC.dispose();

    addPaintListener(new PaintListener() {
        public void paintControl(final PaintEvent pe) {
            runAll(new SWTGraphics2D(pe.gc, getDisplay()));
        }
    });
}
项目:skin4eclipse    文件:VSViewStackPresentation.java   
public void paintControl(PaintEvent e) {
    if (PresentationPlugin.DEBUG_PAINT) {
        System.out.println(getDebugPartName() + ": paint");
    }

    GC gc = e.gc;
    Rectangle clientArea = presentationControl.getClientArea();
    gc.setClipping(clientArea);
    if (borderSize > 0) {
        gc.setLineWidth(borderSize);
    }
    if (activeFocus) {
        gc.setForeground(colorBorderFocus);
    } else {
        gc.setForeground(colorBorderNoFocus);
    }
    gc.setBackground(systemColorNormalShadow);
    gc.fillRectangle(clientArea);

    if (borderSize > 0) {
        gc.drawRectangle(clientArea.x + borderSize / 2,
                clientArea.y + borderSize / 2, clientArea.width - borderSize,
                clientArea.height - borderSize);
    }
    gc.setClipping((Rectangle) null);
}
项目:skin4eclipse    文件:UIUtils.java   
public static void drawRestoreIcon(PaintEvent e, int gap,
        Rectangle clientArea) {
    int width4 = (clientArea.width ) / 4;
    int width3 = 2 * width4 / 3;
    int height4 = (clientArea.height - 2) / 4;
    int height3 = 2 * height4 / 3;
    GC gc = e.gc;
    gc.fillRectangle(clientArea.x + width4 + width3 + 1 + gap,
            clientArea.y + height4 + 1 + gap, 2 * width3, 2);
    gc.drawRectangle(clientArea.x + width4 + width3 + 1 + gap,
            clientArea.y + height4 + 1 + gap, 2 * width3, 2 * height3);

    gc.fillRectangle(clientArea.x + width4 + gap, clientArea.y + height4
            + 2 * height3 + gap, 2 * width3, 2);
    gc.drawRectangle(clientArea.x + width4 + gap, clientArea.y + height4
            + 2 * height3 + gap, 2 * width3, 2 * height3);
}
项目:skin4eclipse    文件:CloseButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    GC gc = e.gc;

    if (active) {
        gc.setForeground(colorTextFocus);
    } else {
        gc.setForeground(colorTextNoFocus);
    }

    // Draw X
    int width = clientArea.width / 4;
    int height = clientArea.height / 4 - 1;
    int limit = (2 * width) - 1;
    for (int i = 0, j = 0; i < limit; i++, j++) {
        int xStart = clientArea.x + width + i + 1 + gap;
        int xEnd = clientArea.x + width + i + 2 + gap;
        int yLevel1 = clientArea.y + height + j + gap + 3;
        int yLevel2 = clientArea.y + 3 * height - j + gap + 3;

        gc.drawLine(xStart, yLevel1, xEnd, yLevel1);
        gc.drawLine(xStart, yLevel2, xEnd, yLevel2);
    }
}
项目:skin4eclipse    文件:NavigatorButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    // Draw arrow
    GC gc = e.gc;
    int xPad = (clientArea.width - width) / 2;
    int yPad = (clientArea.height - height) / 2;
    if(xPad < 0){
        xPad = 0;
    }
    if(yPad < 0){
        yPad = 0;
    }
    if(selectable) {
        gc.drawImage(image, clientArea.x + xPad, clientArea.y + yPad);
    } else {
        gc.drawImage(imageDisabled, clientArea.x + xPad, clientArea.y + yPad);
    }
}
项目:skin4eclipse    文件:MinimizeButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    GC gc = e.gc;
    Color color;
    if (active) {
        color = colorTextFocus;
    } else {
        color = colorTextNoFocus;
    }
    // both foreground and background the same
    gc.setBackground(color);
    if (site.getState() != IStackPresentationSite.STATE_MINIMIZED) {
        // Draw minimize icon
        int width = clientArea.width / 4;
        int height = clientArea.height / 4;
        gc.fillRectangle(clientArea.x + width + 1 + gap, clientArea.y
                + clientArea.height - height - 2 + gap, width * 2, 2);

    } else {
        // Draw restore icon
        gc.setForeground(color);
        UIUtils.drawRestoreIcon(e, gap, clientArea);
    }
}
项目:skin4eclipse    文件:MaximizeButton.java   
protected void paintControl(PaintEvent e, int gap, Rectangle clientArea) {
    GC gc = e.gc;
    Color color;
    if (active) {
        color = colorTextFocus;
    } else {
        color = colorTextNoFocus;
    }
    // both foreground and background the same
    gc.setBackground(color);
    gc.setForeground(color);

    if (site.getState() != IStackPresentationSite.STATE_MAXIMIZED) {
        // Draw maximize icon
        int width = clientArea.width / 4;
        int height = clientArea.height / 4;
        int xCoord = clientArea.x + width + 1 + gap;
        int yCoord = clientArea.y + height + 1 + gap;
        gc.fillRectangle(xCoord, yCoord, width * 2, 2);
        gc.drawRectangle(xCoord, yCoord, width * 2, height * 2);
    } else {
        // Draw restore icon
        UIUtils.drawRestoreIcon(e, gap, clientArea);
    }
}
项目:PDFReporter-Studio    文件:TabbedPropertySearch.java   
/**
 * @param e
 */
protected void drawTitleBackground(PaintEvent e) {
    if (factory.getColors() == null) return;
    Rectangle bounds = getClientArea();
    Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
    Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
    GC gc = e.gc;
    gc.setForeground(bg);
    gc.setBackground(gbg);
    gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width,
            bounds.height, true);
    // background bottom separator
    gc.setForeground(factory.getColors().getColor(
            IFormColors.H_BOTTOM_KEYLINE1));
    gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1,
            bounds.height - 2);
    gc.setForeground(factory.getColors().getColor(
            IFormColors.H_BOTTOM_KEYLINE2));
    gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1,
            bounds.height - 1);
}
项目:PDFReporter-Studio    文件:TabbedPropertyTitle.java   
/**
 * @param e
 */
protected void drawTitleBackground(PaintEvent e) {
    if (factory.getColors() == null) return;
    Rectangle bounds = getClientArea();
    label.setBackground(new Color[] {
            factory.getColors().getColor(IFormColors.H_GRADIENT_END),
            factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
            new int[] { 100 }, true);
    Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
    Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
    GC gc = e.gc;
    gc.setForeground(bg);
    gc.setBackground(gbg);
    gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width,
            bounds.height, true);
    // background bottom separator
    gc.setForeground(factory.getColors().getColor(
            IFormColors.H_BOTTOM_KEYLINE1));
    gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1,
            bounds.height - 2);
    gc.setForeground(factory.getColors().getColor(
            IFormColors.H_BOTTOM_KEYLINE2));
    gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1,
            bounds.height - 1);
}
项目:gama    文件:BoxDecoratorImpl.java   
@Override
public void paintControl(final PaintEvent e) {
    if (paintMode) {
        return;
    }
    paintMode = true;
    try {
        // check charCount as workaround for no event when
        // StyledText.setContent()
        if (boxes == null || charCount != boxText.getCharCount()) {
            buildBoxes();
            updateCaret();
            drawBackgroundBoxes();
        } else if (offsetMoved()) {
            updateCaret();
            drawBackgroundBoxes();
        } else {
            redrawIfClientAreaChanged();
        }
    } catch (final Throwable t) {
        // EditBox.logError(this, "Box paint error", t);
    } finally {
        paintMode = false;
    }
}
项目:slr-toolkit    文件:ChartPreview.java   
public void paintControl(PaintEvent pe) {
    GC gc = pe.gc;
    if (dataPresent) {
        if (buffer != null) {
            gc.drawImage(buffer, 0, 0);
        }
    } else {
        // Get the width of the canvas
        int canvasWidth = preview.getSize().x;
        int canvasHeight = preview.getSize().y;

        // Plot centred by subtracting half the width of the string from
        // the centre of the Canvas width
        gc.drawText(textToShow, canvasWidth / 2, canvasHeight / 2);
    }

}
项目:mytourbook    文件:ValuePointToolTipUI.java   
private void onPaintShellContainer(final PaintEvent event) {

        final GC gc = event.gc;
        final Point shellSize = _shellContainer.getSize();

        // draw border
        gc.setForeground(_fgBorder);
        gc.drawRectangle(0, 0, shellSize.x - 1, shellSize.y - 1);

// this is not working correctly because a new paint needs to be done
//      gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
//      switch (pinnedLocation) {
//      case TopLeft:
//          gc.drawPoint(0, 0);
//          break;
//      case TopRight:
//          gc.drawPoint(shellSize.x - 1, 0);
//          break;
//      case BottomLeft:
//          gc.drawPoint(0, shellSize.y - 1);
//          break;
//      case BottomRight:
//          gc.drawPoint(shellSize.x - 1, shellSize.y - 1);
//          break;
//      }
    }
项目:mytourbook    文件:AbstractRRShell.java   
private Composite createUI_20_PageShellImage(final Composite parent) {

        final Canvas resizeCanvas = new Canvas(//
                parent,
//              SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE//
                SWT.NONE //
        );

        resizeCanvas.setLayout(new FillLayout());

//      resizeCanvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));

        resizeCanvas.addPaintListener(new PaintListener() {
            @Override
            public void paintControl(final PaintEvent e) {
                onPaintShellImage(e);
            }
        });

        return resizeCanvas;
    }
项目:mytourbook    文件:ImageSizeIndicator.java   
private void onPaint(final PaintEvent paintEvent) {

        final GC gc = paintEvent.gc;

        final Rectangle bounds = getBounds();

        final int vMargin = 1;
        final int vMargin2 = 2 * vMargin;
        final int width = bounds.width;
        final int height = bounds.height;

        // debug box
//      gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
//      gc.fillRectangle(0, 0, bounds.width, bounds.height);

        if (_isHqImage) {
            gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED));
        } else {
            gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GREEN));
        }
        gc.fillRectangle(0, vMargin, width, height - vMargin2);
    }
项目:mytourbook    文件:TimeChooserPanel.java   
/**
 * The paint method.
 * 
 * @param event the pain tevent
 */
private void onPaint(PaintEvent event) {
    // do preparing calculations
    updateInternals();

    GC gc = event.gc;

    drawMarks(gc);

    for (int i = 0; i < 12; i++) {
        int y = i * _rowHeight;
        drawAMPM(gc, y, i);
        drawHour(gc, y, i);
        drawMinute(gc, y, i);
    }
    // int x = 0;
    // gc.drawLine(x, 0, x, getClientArea().height);
    // x += _columnWidth;
    // gc.drawLine(x, 0, x, getClientArea().height);
    // x += _columnWidth;
    // gc.drawLine(x, 0, x, getClientArea().height);
    // x += _columnWidth;
    // gc.drawLine(x, 0, x, getClientArea().height);
    // x += _columnWidth;
}
项目:jo-widgets    文件:CanvasImpl.java   
public CanvasImpl(
    final IGenericWidgetFactory factory,
    final Object parentUiReference,
    final ICanvasSetupSpi setup,
    final SwtImageRegistry imageRegistry) {
    super(factory, new Canvas((Composite) parentUiReference, getStyle(setup)), imageRegistry);
    getUiReference().setBackgroundMode(SWT.INHERIT_DEFAULT);
    this.paintObservable = new PaintObservable();

    getUiReference().addPaintListener(new PaintListener() {
        @Override
        public void paintControl(final PaintEvent e) {
            final Dimension size = getSize();
            final Rectangle bounds = new Rectangle(0, 0, size.getWidth(), size.getHeight());
            final Rectangle clipBounds = new Rectangle(e.x, e.y, e.width, e.height);
            final GraphicContextSpiImpl graphicContext = new GraphicContextSpiImpl(e.gc, bounds, imageRegistry);
            paintObservable.firePaint(new PaintEventSpiImpl(graphicContext, clipBounds));
        }
    });
}
项目:p2-installer    文件:SpinnerProgress.java   
/**
    * Constructor
    * 
    * @param parent Parent
    * @param style Style flags
    */
public SpinnerProgress(Composite parent, int style) {
    super(parent, style);

    // Add paint listener
    addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            onPaint(e);
        }
    });
    // Set font
    setFont(parent.getFont());
    // Create spoke colors
    createColors(getDisplay());
    // Compute spoke angles
    computeSpokeAngles();
}
项目:p2-installer    文件:AnimateControl.java   
/**
 * Constructor
 * 
 * @param parent Parent
 * @param image Image to display
 */
public AnimateControl(Composite parent, int style, Image[] images) {
    super(parent, style);

    // Image attributes
    this.images = images;
    imageWidth = images[0].getImageData().width;
    imageHeight = images[0].getImageData().height;

    // Add paint listener
    addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            onPaint(e);
        }
    });
}
项目:p2-installer    文件:AnimateControl.java   
/**
 * Called to paint the control.
 * 
 * @param event Paint event
 */
private void onPaint(PaintEvent event) {
    GC gc = event.gc;

    gc.setFont(getFont());

    // Get the client area
    Rectangle clientArea = getClientArea();
    Point textSize = gc.textExtent(getText(), TEXT_FLAGS);
    int offset = clientArea.height / 2 - textSize.y / 2;

    // Draw image
    gc.drawImage(getImages()[currentImage], 0, 0);
    gc.setForeground(getForeground());
    // Draw text
    gc.drawText(getText(), imageWidth + TEXT_MARGIN, offset, TEXT_FLAGS);
}