Java Code Examples for org.eclipse.swt.widgets.Control#addPaintListener()
The following examples show how to use
org.eclipse.swt.widgets.Control#addPaintListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMouseProvider.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Method to register the provider to chart viewer. */ protected void register() { IPlotArea plotArea = getChart().getPlotArea(); Control control = plotArea.getControl(); if (this instanceof MouseListener) { control.addMouseListener((MouseListener) this); } if (this instanceof MouseMoveListener) { control.addMouseMoveListener((MouseMoveListener) this); } if (this instanceof MouseWheelListener) { control.addMouseWheelListener((MouseWheelListener) this); } if (this instanceof MouseTrackListener) { control.addMouseTrackListener((MouseTrackListener) this); } if (this instanceof ICustomPaintListener) { plotArea.addCustomPaintListener((ICustomPaintListener) this); } else if (this instanceof PaintListener) { control.addPaintListener((PaintListener) this); } TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler(); if(tooltipHandler != null) { tooltipHandler.activateHoverHelp(control); } }
Example 2
Source File: AnimatedGIFRunner.java From http4e with Apache License 2.0 | 5 votes |
AnimatedGIFRunner( Control control, ImageLoader imageLoaderGIF, final Image backgroundImage){ this.control = control; controlGC = new GC(control); shellBackground = control.getBackground(); this.imageLoader = imageLoaderGIF; this.imageDataArray = imageLoader.data; if(imageDataArray == null || imageDataArray.length < 2){ throw new RuntimeException("Illegal ImageLoader."); } isStopped = false; this.backgroundImage = backgroundImage; Rectangle ctrR = control.getBounds(); positionX = (ctrR.width - CoreConstants.IMAGES_HEIGHT)/2; positionY = (ctrR.height - CoreConstants.IMAGES_HEIGHT)/2; control.addPaintListener(new PaintListener() { public void paintControl( PaintEvent e){ GC graphics = e.gc; if(!graphics.isDisposed()) { graphics.drawImage(backgroundImage, positionX, positionY); graphics.dispose(); } } }); }
Example 3
Source File: TmfBaseProvider.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Method to register the provider to chart viewer. */ protected void register() { IPlotArea plotArea = getChart().getPlotArea(); Control control = plotArea.getControl(); if (this instanceof MouseListener) { control.addMouseListener((MouseListener) this); } if (this instanceof MouseMoveListener) { control.addMouseMoveListener((MouseMoveListener) this); } if (this instanceof MouseWheelListener) { control.addMouseWheelListener((MouseWheelListener) this); } if (this instanceof MouseTrackListener) { control.addMouseTrackListener((MouseTrackListener) this); } if (this instanceof ICustomPaintListener) { plotArea.addCustomPaintListener((ICustomPaintListener) this); } else if (this instanceof PaintListener) { control.addPaintListener((PaintListener) this); } TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler(); if(tooltipHandler != null) { tooltipHandler.activateHoverHelp(control); } }
Example 4
Source File: WSO2UIToolkit.java From developer-studio with Apache License 2.0 | 5 votes |
private static void propagateEnability(final Control watchControl, final Control... controls) { watchControl.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { for (Control control : controls) { control.setEnabled(watchControl.getEnabled()); } } }); }
Example 5
Source File: PropsUi.java From hop with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GuiResource gui = GuiResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( paintEvent -> { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } ); } font = null; // GuiResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GuiResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GuiResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GuiResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 6
Source File: IDEUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 4 votes |
public static void paintBackgroundToMatch(Control control, Control parent) { control.addPaintListener(event -> { control.setBackground(parent.getBackground()); control.setForeground(parent.getForeground()); }); }
Example 7
Source File: PropsUI.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GUIResource gui = GUIResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( new PaintListener() { @Override public void paintControl( PaintEvent paintEvent ) { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } } ); } font = null; // GUIResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GUIResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GUIResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GUIResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 8
Source File: AbstractTimeGraphView.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Add a paint listener to the view * * @param listener * The paint listener * @since 4.0 */ public void addPaintListener(PaintListener listener) { Control tgControl = getTimeGraphViewer().getTimeGraphControl(); tgControl.addPaintListener(listener); }