use of org.eclipse.swt.events.PaintListener in project hale by halestudio.
the class HaleSplash method init.
@Override
public void init(Shell splash) {
IProduct product = Platform.getProduct();
if (product != null) {
/*
* Using a custom property for the foreground color, because when
* using the one defined in IProductConstants, it is overriden when
* recreating a run configuration from the product.
*/
String foregroundColorString = product.getProperty(PRODUCT_PROP_SPLASH_FONT_COLOR);
int foregroundColorInteger;
try {
foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
} catch (Exception ex) {
// off white
foregroundColorInteger = 0xD2D7FF;
}
/*
* Foreground color will be overriden in super.init(...), that's why
* we have to set it in getContent() - store it here for later
* access.
*/
customFontColor = new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8, foregroundColorInteger & 0xFF);
}
super.init(splash);
if (product != null) {
// get application version
Version haleVersion = Version.parseVersion(Display.getAppVersion());
// classified as development version if a qualifier other than
// RELEASE is given
boolean developmentVersion = haleVersion.getQualifier() != null && !haleVersion.getQualifier().isEmpty() && !haleVersion.getQualifier().equalsIgnoreCase("RELEASE");
if (!developmentVersion) {
// strip qualifier for RELEASE
haleVersion = new Version(haleVersion.getMajor(), haleVersion.getMinor(), haleVersion.getMicro());
}
StringBuilder versionStringBuilder = new StringBuilder();
versionStringBuilder.append(haleVersion.toString());
if (developmentVersion) {
// add revision information
String revisionString = product.getProperty(PRODUCT_PROP_REVISION);
if (revisionString != null && !revisionString.isEmpty()) {
versionStringBuilder.insert(0, '\n');
versionStringBuilder.insert(0, revisionString);
versionStringBuilder.insert(0, "Revision ");
}
}
// add version tag
String versionTagString = product.getProperty(PRODUCT_PROP_VERSION_TAG);
if (versionTagString != null && !versionTagString.isEmpty()) {
versionStringBuilder.append('-');
versionStringBuilder.append(versionTagString);
}
// add copyright notice
String copyrightString = product.getProperty(PRODUCT_PROP_COPYRIGHT);
if (copyrightString != null && !copyrightString.isEmpty()) {
versionStringBuilder.append(' ');
versionStringBuilder.append(copyrightString);
}
final String versionString = versionStringBuilder.toString();
getContent().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
// computed version string location
Point extent = e.gc.textExtent(versionString);
if (versionStringFont == null) {
// find fitting font
Font customFont = null;
while (extent.x >= e.width || extent.y > MAX_HEIGHT) {
FontData[] orgFont = e.gc.getFont().getFontData();
// minimum font size
if (orgFont[0].getHeight() <= MIN_SIZE) {
break;
}
FontData fd = new FontData(orgFont[0].toString());
fd.setHeight(orgFont[0].getHeight() - 1);
if (customFont != null) {
// dispose previous custom font
customFont.dispose();
}
customFont = new Font(e.display, fd);
e.gc.setFont(customFont);
extent = e.gc.textExtent(versionString);
}
if (customFont != null) {
versionStringFont = customFont;
}
}
e.gc.setForeground(getForeground());
e.gc.drawText(versionString, (e.width - extent.x) / 2, e.height - extent.y - BOTTOM_MARGIN, true);
}
});
}
}
use of org.eclipse.swt.events.PaintListener in project ecf by eclipse.
the class ScribbleView method createPartControl.
public void createPartControl(Composite parent) {
Composite backgroundComposite = new Composite(parent, SWT.NONE);
GridLayout backgroundGridLayout = new GridLayout(3, false);
backgroundGridLayout.marginHeight = 0;
backgroundGridLayout.marginBottom = 0;
backgroundGridLayout.marginLeft = 0;
backgroundGridLayout.marginRight = 0;
backgroundGridLayout.marginWidth = 0;
backgroundGridLayout.horizontalSpacing = 0;
backgroundComposite.setLayout(backgroundGridLayout);
backgroundComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite paletteComposite = new Composite(backgroundComposite, SWT.NONE);
backgroundGridLayout = new GridLayout();
backgroundGridLayout.marginHeight = 0;
backgroundGridLayout.marginBottom = 0;
backgroundGridLayout.marginLeft = 0;
backgroundGridLayout.marginRight = 0;
backgroundGridLayout.marginWidth = 0;
backgroundGridLayout.horizontalSpacing = 0;
paletteComposite.setLayout(backgroundGridLayout);
GridData toolboxGridData = new GridData(GridData.FILL_VERTICAL);
toolboxGridData.widthHint = 60;
paletteComposite.setLayoutData(toolboxGridData);
final TableViewer toolbox = new TableViewer(paletteComposite, SWT.FLAT | SWT.FULL_SELECTION);
toolboxGridData = new GridData(GridData.FILL_BOTH);
toolbox.getTable().setLayoutData(toolboxGridData);
toolbox.setLabelProvider(new ToolboxLabelProvider());
toolbox.setContentProvider(new ListContentProvider());
toolbox.setInput(createTools());
toolbox.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
currentTool = (AbstractTool) ((StructuredSelection) toolbox.getSelection()).getFirstElement();
// Apply the drawSettings to the currently selected tool.
currentTool.setDrawSettings(drawSettings);
}
});
// Create the UI widgets to modify the DrawSettings instance.
createSettings(paletteComposite);
Label separator = new Label(backgroundComposite, SWT.SEPARATOR | SWT.VERTICAL);
separator.setLayoutData(new GridData(GridData.FILL_VERTICAL));
canvas = new Canvas(backgroundComposite, SWT.NONE);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
display = parent.getDisplay();
canvas.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
for (Iterator i = tools.iterator(); i.hasNext(); ) {
AbstractTool at = (AbstractTool) i.next();
at.draw(canvas);
}
}
});
Listener listener = new Listener() {
public void handleEvent(Event event) {
if (currentTool != null) {
// Have the tool interpret the mouse events.
currentTool.handleUIEvent(event, canvas);
// other clients for rendering.
if (currentTool.isComplete()) {
tools.add(currentTool);
sendTool(currentTool);
// Only do this once per Tool.
currentTool.setComplete(false);
}
/*else {
if (currentTool instanceof Pencil) {
tools.add(currentTool);
}
}*/
}
}
};
canvas.addListener(SWT.MouseDown, listener);
canvas.addListener(SWT.MouseMove, listener);
canvas.addListener(SWT.MouseUp, listener);
}
use of org.eclipse.swt.events.PaintListener in project statecharts by Yakindu.
the class DiagramPartitioningBreadcrumbViewer method createDropDownTreeViewer.
protected TreeViewer createDropDownTreeViewer(final Composite composite, TreePath paramPath, final IBreadcrumbDropDownSite site) {
Diagram diagram = (Diagram) paramPath.getParentPath().getLastSegment();
TreeViewer viewer = null;
if (diagram != null)
viewer = createDiagramViewer(composite, diagram);
else
viewer = createProjectStatechartViewer(composite, (Diagram) paramPath.getLastSegment());
viewer.getControl().addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
getDropDownShell().pack(true);
}
});
return viewer;
}
use of org.eclipse.swt.events.PaintListener in project ecf by eclipse.
the class ScreenCaptureConfirmationDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(width, height));
composite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(image, 0, 0);
}
});
return composite;
}
use of org.eclipse.swt.events.PaintListener in project pentaho-kettle by pentaho.
the class StarModelDialog method addModelTab.
private void addModelTab() {
wModelTab = new CTabItem(wTabFolder, SWT.NONE);
wModelTab.setText(BaseMessages.getString(PKG, "StarModelDialog.ModelTab.Label"));
Composite wModelComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wModelComp);
FormLayout transLayout = new FormLayout();
transLayout.marginWidth = Const.MARGIN;
transLayout.marginHeight = Const.MARGIN;
wModelComp.setLayout(transLayout);
// Model name:
//
Label wlModelName = new Label(wModelComp, SWT.RIGHT);
wlModelName.setText(BaseMessages.getString(PKG, "StarModelDialog.ModelName.Label"));
props.setLook(wlModelName);
FormData fdlJobname = new FormData();
fdlJobname.left = new FormAttachment(0, 0);
fdlJobname.right = new FormAttachment(middle, -margin);
fdlJobname.top = new FormAttachment(0, margin);
wlModelName.setLayoutData(fdlJobname);
wModelName = new Text(wModelComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wModelName);
FormData fdJobname = new FormData();
fdJobname.left = new FormAttachment(middle, 0);
fdJobname.top = new FormAttachment(0, margin);
fdJobname.right = new FormAttachment(100, 0);
wModelName.setLayoutData(fdJobname);
Control lastControl = wModelName;
// Model description
//
Label wlModelDescription = new Label(wModelComp, SWT.RIGHT);
wlModelDescription.setText(BaseMessages.getString(PKG, "StarModelDialog.ModelDescription.Label"));
props.setLook(wlModelDescription);
FormData fdlJobFilename = new FormData();
fdlJobFilename.left = new FormAttachment(0, 0);
fdlJobFilename.right = new FormAttachment(middle, -margin);
fdlJobFilename.top = new FormAttachment(lastControl, margin);
wlModelDescription.setLayoutData(fdlJobFilename);
wModelDescription = new Text(wModelComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wModelDescription);
FormData fdJobFilename = new FormData();
fdJobFilename.left = new FormAttachment(middle, 0);
fdJobFilename.top = new FormAttachment(lastControl, margin);
fdJobFilename.right = new FormAttachment(100, 0);
wModelDescription.setLayoutData(fdJobFilename);
lastControl = wModelDescription;
canvas = new Canvas(wModelComp, SWT.BORDER);
FormData fdCanvas = new FormData();
fdCanvas.left = new FormAttachment(0, 0);
fdCanvas.right = new FormAttachment(100, 0);
fdCanvas.top = new FormAttachment(lastControl, 3 * margin);
fdCanvas.bottom = new FormAttachment(100, -margin);
canvas.setLayoutData(fdCanvas);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent paintEvent) {
drawLogicalModel(logicalModel, canvas, paintEvent);
}
});
FormData fdModelComp = new FormData();
fdModelComp.left = new FormAttachment(0, 0);
fdModelComp.top = new FormAttachment(0, 0);
fdModelComp.right = new FormAttachment(100, 0);
fdModelComp.bottom = new FormAttachment(100, 0);
wModelComp.setLayoutData(fdModelComp);
wModelTab.setControl(wModelComp);
}
Aggregations