use of org.eclipse.swt.widgets.Canvas in project archi by archimatetool.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
if (fEditPart == null) {
return;
}
// create canvas and lws
fCanvas = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(fCanvas);
fThumbnail = new ScrollableThumbnail((Viewport) fEditPart.getFigure());
fThumbnail.setUseScaledGraphics(false);
fThumbnail.setSource(fEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
fThumbnail.setBorder(new MarginBorder(3));
lws.setContents(fThumbnail);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fCanvas, HELP_ID);
}
use of org.eclipse.swt.widgets.Canvas in project archi by archimatetool.
the class BufferedGraphicsSource method flushGraphics.
/**
* @see org.eclipse.draw2d.GraphicsSource#flushGraphics(org.eclipse.draw2d.geometry.Rectangle)
*/
@Override
public void flushGraphics(Rectangle region) {
if (inUse.isEmpty())
return;
boolean restoreCaret = false;
Canvas canvas = null;
if (control instanceof Canvas) {
canvas = (Canvas) control;
Caret caret = canvas.getCaret();
if (caret != null)
restoreCaret = caret.isVisible();
if (restoreCaret && caret != null)
caret.setVisible(false);
}
/*
* The imageBuffer may be null if double-buffering was not successful.
*/
if (imageBuffer != null) {
imageGC.dispose();
controlGC.drawImage(getImage(), 0, 0, inUse.width, inUse.height, inUse.x, inUse.y, inUse.width, inUse.height);
imageBuffer.dispose();
imageBuffer = null;
imageGC = null;
}
controlGC.dispose();
controlGC = null;
if (restoreCaret && canvas != null)
canvas.getCaret().setVisible(true);
}
use of org.eclipse.swt.widgets.Canvas in project cogtool by cogtool.
the class Draw2DMouseState method dealWithEvent.
// Force subclasses to implement the "dealWith" versions
/**
* Returns true if subclass processing should continue, false
* if subclass processing should be terminated.
*/
protected boolean dealWithEvent(Event evt) {
if (evt.type == SWT.MenuDetect) {
// that each of our windows using Draw2D contains only one Canvas!
if (isMenuClick || (OSUtils.MACOSX && (evt.widget instanceof Canvas))) {
Canvas c = (Canvas) evt.widget;
Text focusedText = WindowUtil.getFocusedText();
if (focusedText != null) {
if (focusedText instanceof ManagedText) {
ManagedText txt = (ManagedText) focusedText;
if (!txt.confirm(ManagedText.LOSE_FOCUS)) {
return false;
}
}
c.forceFocus();
}
Combo focusedCombo = WindowUtil.getFocusedCombo();
if (focusedCombo != null) {
if (focusedCombo instanceof ManagedCombo) {
ManagedCombo combo = (ManagedCombo) focusedCombo;
if (!combo.confirm(ManagedCombo.LOSE_FOCUS)) {
return false;
}
}
c.forceFocus();
}
Point p = c.toControl(evt.x, evt.y);
menuUI.showContextMenu(p.x, p.y);
} else {
menuUI.showContextMenu();
}
}
return true;
}
use of org.eclipse.swt.widgets.Canvas in project translationstudio8 by heartsome.
the class CheckBoxCellEditor method activateCell.
/**
* As soon as the editor is activated, flip the current data value and commit it.<br/>
* The repaint will pick up the new value and flip the image.
*/
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
setCanonicalValue(originalCanonicalValue);
checked = !checked;
canvas = new Canvas(parent, SWT.NONE);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent paintEvent) {
Rectangle bounds = canvas.getBounds();
Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
}
});
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
checked = !checked;
canvas.redraw();
}
});
commit(MoveDirectionEnum.NONE, false);
return canvas;
}
use of org.eclipse.swt.widgets.Canvas in project dbeaver by serge-rider.
the class ProgressEditorPart method createProgressPane.
private void createProgressPane(final Composite parent) {
progressCanvas = new Canvas(parent, SWT.NONE);
progressCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.drawText("Connecting to datasource '" + getEditorInput().getDatabaseObject().getName() + "'...", 5, 5, true);
}
});
InitNodeService loadingService = new InitNodeService();
LoadingJob<IDatabaseEditorInput> loadJob = LoadingJob.createService(loadingService, new InitNodeVisualizer(loadingService));
loadJob.schedule();
}
Aggregations