本文整理了Java中org.eclipse.swt.widgets.Canvas.addListener()
方法的一些代码示例,展示了Canvas.addListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Canvas.addListener()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Canvas
类名称:Canvas
方法名:addListener
暂无
代码示例来源:origin: pentaho/pentaho-kettle
text = new Text( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
canvas = new Canvas( parent, SWT.BORDER );
canvas.addListener( SWT.Paint, new Listener() {
public void handleEvent( Event event ) {
paintCanvas( event );
代码示例来源:origin: org.eclipse/org.eclipse.help.ui
public void addListener(int e, Listener l) {
super.addListener(e, l);
//label.addListener(e, l);
}
代码示例来源:origin: BiglySoftware/BiglyBT
private void createPieceDistPanel() {
comp.setLayout(new FillLayout());
//pieceDistComposite = new Composite(parent, SWT.NONE);
pieceDistCanvas = new Canvas(comp,SWT.NO_BACKGROUND);
pieceDistCanvas.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
if ( pem==null || pem.isDestroyed()){
event.gc.fillRectangle(event.x, event.y, event.width, event.height);
}else{
if (imgToPaint != null && !imgToPaint.isDisposed()) {
event.gc.drawImage(imgToPaint, 0, 0);
}
}
}
});
}
代码示例来源:origin: BiglySoftware/BiglyBT
@Override
public void initialize(Canvas canvas) {
super.initialize(canvas);
drawCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (bufferImage != null && !bufferImage.isDisposed()) {
Rectangle bounds = bufferImage.getBounds();
if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {
e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y,
e.width, e.height);
}
}
}
});
drawCanvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
drawChart(true);
}
});
}
代码示例来源:origin: BiglySoftware/BiglyBT
canvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
代码示例来源:origin: diffplug/gradle-and-eclipse-rcp
public ColorPicker(Composite parent) {
super(new Canvas(parent, SWT.DOUBLE_BUFFERED));
setY(128);
wrapped.addListener(SWT.Paint, e -> {
Point size = wrapped.getSize();
Image img = getMapFor(e.display);
e.gc.drawImage(img, 0, 0, _256, _256, 0, 0, size.x, size.y);
});
mouseDown = SwtRx.addListener(wrapped, SWT.MouseDown).map(this::posToColor);
mouseMove = SwtRx.addListener(wrapped, SWT.MouseMove).map(this::posToColor);
}
代码示例来源:origin: BiglySoftware/BiglyBT
public void
initialize(
Canvas canvas,
boolean is_active )
{
super.initialize(canvas);
drawCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (bufferImage != null && !bufferImage.isDisposed()) {
Rectangle bounds = bufferImage.getBounds();
if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {
e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y, e.width, e.height);
}
}
}
});
drawCanvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
drawChart(true);
}
});
setActive( is_active );
}
代码示例来源:origin: com.diffplug.durian/durian-swt
public NoBorderBtn(Composite parent) {
super(new Canvas(parent, SWT.NONE));
wrapped.addListener(SWT.Paint, e -> {
Point size = wrapped.getSize();
// fill the background based on the "enabled" status
Color backgroundColor = wrapped.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
e.gc.setBackground(backgroundColor);
e.gc.fillRectangle(0, 0, size.x, size.y);
// draw the image
if (img != null) {
int deltaX = size.x - imgBounds.width;
int deltaY = size.y - imgBounds.height;
e.gc.drawImage(img, deltaX / 2, deltaY / 2);
}
});
// send a selection event on each click (if we aren't disabled)
wrapped.addListener(SWT.MouseDown, e -> {
if (enabled) {
selection.onNext(this);
}
});
// send a "completed" event when we finish
wrapped.addListener(SWT.Dispose, e -> {
selection.onComplete();
});
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver needs to be painted, by sending it
* one of the messages defined in the <code>PaintListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see PaintListener
* @see #removePaintListener
* @since 1.3
*/
public void addPaintListener( PaintListener listener ) {
checkWidget();
if( listener == null ) {
error( SWT.ERROR_NULL_ARGUMENT );
}
TypedListener typedListener = new TypedListener( listener );
addListener( SWT.Paint, typedListener );
}
代码示例来源:origin: BiglySoftware/BiglyBT
public AnimatedImage(Composite parent) {
canvas = new Canvas(parent,SWT.NO_BACKGROUND);
Color background = null;
Composite p = parent;
while(p != null && background == null) {
background = p.getBackground();
if(background != null) {
//System.out.println("background : " + background + ", composite : " + p);
break;
}
p = p.getParent();
}
canvas.setBackground(background);
canvas.addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(Event event) {
stop();
disposeImages();
}
});
}
代码示例来源:origin: BiglySoftware/BiglyBT
drawCanvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void headerShowToolTip (int x) {
String tooltip = headerGetToolTip (x);
if (tooltip == null || tooltip.length () == 0) return;
if (toolTipShell == null) {
toolTipShell = new Shell (getShell (), SWT.ON_TOP | SWT.TOOL);
toolTipLabel = new Label (toolTipShell, SWT.CENTER);
Display display = toolTipShell.getDisplay ();
toolTipLabel.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
toolTipLabel.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
for (int toolTipEvent : toolTipEvents) {
header.addListener (toolTipEvent, toolTipListener);
}
}
if (headerUpdateToolTip (x)) {
toolTipShell.setVisible (true);
} else {
headerHideToolTip ();
}
}
boolean headerUpdateToolTip (int x) {
代码示例来源:origin: org.xworker/xworker_swt
imageCanvas.addListener(SWT.MouseDown, this);
imageCanvas.addListener(SWT.MouseMove, this);
imageCanvas.addListener(SWT.MouseHover, this);
imageCanvas.addListener(SWT.MouseUp, this);
imageCanvas.addListener(SWT.KeyDown, this);
imageCanvas.addListener(SWT.KeyUp, this);
imageCanvas.addListener(SWT.MouseWheel, this);
imageCanvas.addPaintListener(this);
代码示例来源:origin: BiglySoftware/BiglyBT
cHeaderArea.addListener(SWT.MenuDetect, new Listener() {
@Override
public void handleEvent(Event event) {
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
protected void adjustItemNumber() {
if (fComposite == null)
return;
Control[] children= fComposite.getChildren();
int oldSize= children.length;
int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
Display display= fShell.getDisplay();
// add missing items
for (int i= oldSize; i < newSize; i++) {
Canvas canvas= new Canvas(fComposite, SWT.NONE);
Object gridData= fLayouter.getLayoutData();
canvas.setLayoutData(gridData);
canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
canvas.addPaintListener(fPaintListener);
canvas.addMouseTrackListener(fMouseTrackListener);
canvas.addMouseListener(fMouseListener);
canvas.addListener(SWT.MenuDetect, fMenuDetectListener);
canvas.addDisposeListener(fDisposeListener);
}
// dispose of exceeding resources
for (int i= oldSize; i > newSize; i--) {
Item item= (Item) children[i - 1].getData();
item.deselect();
children[i - 1].dispose();
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
protected void adjustItemNumber() {
if (fComposite == null)
return;
Control[] children= fComposite.getChildren();
int oldSize= children.length;
int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
Display display= fShell.getDisplay();
// add missing items
for (int i= oldSize; i < newSize; i++) {
Canvas canvas= new Canvas(fComposite, SWT.NONE);
Object gridData= fLayouter.getLayoutData();
canvas.setLayoutData(gridData);
canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
canvas.addPaintListener(fPaintListener);
canvas.addMouseTrackListener(fMouseTrackListener);
canvas.addMouseListener(fMouseListener);
canvas.addListener(SWT.MenuDetect, fMenuDetectListener);
canvas.addDisposeListener(fDisposeListener);
}
// dispose of exceeding resources
for (int i= oldSize; i > newSize; i--) {
Item item= (Item) children[i - 1].getData();
item.deselect();
children[i - 1].dispose();
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
protected void adjustItemNumber() {
if (fComposite == null)
return;
Control[] children= fComposite.getChildren();
int oldSize= children.length;
int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
Display display= fShell.getDisplay();
// add missing items
for (int i= oldSize; i < newSize; i++) {
Canvas canvas= new Canvas(fComposite, SWT.NONE);
Object gridData= fLayouter.getLayoutData();
canvas.setLayoutData(gridData);
canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
canvas.addPaintListener(fPaintListener);
canvas.addMouseTrackListener(fMouseTrackListener);
canvas.addMouseListener(fMouseListener);
canvas.addListener(SWT.MenuDetect, fMenuDetectListener);
canvas.addDisposeListener(fDisposeListener);
}
// dispose of exceeding resources
for (int i= oldSize; i > newSize; i--) {
Item item= (Item) children[i - 1].getData();
item.deselect();
children[i - 1].dispose();
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
canvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
代码示例来源:origin: BiglySoftware/BiglyBT
canvas.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void createCanvas(Composite parent) {
int style = SWT.NO_BACKGROUND;
if (dbItem.getSelection()) style |= SWT.DOUBLE_BUFFERED;
canvas = new Canvas(parent, style);
canvas.addListener(SWT.Paint, event -> {
GC gc = event.gc;
Rectangle rect = canvas.getClientArea();
Device device = gc.getDevice();
Pattern pattern = null;
if (background.getBgColor1() != null) {
if (background.getBgColor2() != null) { // gradient
pattern = new Pattern(device, 0, 0, rect.width,
rect.height,
background.getBgColor1(),
background.getBgColor2());
gc.setBackgroundPattern(pattern);
} else { // solid color
gc.setBackground(background.getBgColor1());
}
} else if (background.getBgImage() != null) { // image
pattern = new Pattern(device, background.getBgImage());
gc.setBackgroundPattern(pattern);
}
gc.fillRectangle(rect);
GraphicsTab tab = getTab();
if (tab != null) tab.paint(gc, rect.width, rect.height);
if (pattern != null) pattern.dispose();
});
}
内容来源于网络,如有侵权,请联系作者删除!