use of org.eclipse.swt.events.PaintEvent 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.PaintEvent 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.PaintEvent 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.PaintEvent in project core by jcryptool.
the class AlgorithmView method createSearchArea.
/**
* Creates the search field. On Mac the text does contain a clear (reset) icon which resets
* the view filter. Since Windows does not support this an additional clear (reset) icon
* is shown next to the text.
*
* @param parent The parent composite
*/
private void createSearchArea(Composite parent) {
// search field
final Text search = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
if ((search.getStyle() & SWT.CANCEL) == 0) {
// reset search button for systems that do not support the cancel icon
Canvas canvas = new Canvas(parent, SWT.NONE);
GridData gridData = new GridData();
gridData.heightHint = 18;
gridData.widthHint = 18;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
// $NON-NLS-1$
e.gc.drawImage(ViewsPlugin.getImageDescriptor("icons/clear.gif").createImage(), 1, 1);
}
});
canvas.addMouseListener(new MouseAdapter() {
public void mouseUp(MouseEvent e) {
search.setText(Messages.AlgorithmView_search_message);
search.setForeground(COLOR_FILTER_INITIAL);
initialSearchState = true;
// $NON-NLS-1$
treeView.setFilter("");
// $NON-NLS-1$
paletteView.setFilter("");
}
});
}
search.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
search.setText(Messages.AlgorithmView_search_message);
search.setForeground(COLOR_FILTER_INITIAL);
search.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (initialSearchState) {
// $NON-NLS-1$
search.setText("");
search.setForeground(COLOR_FILTER_USER);
initialSearchState = false;
}
}
});
search.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
treeView.setFilter(search.getText());
paletteView.setFilter(search.getText());
}
});
search.addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
if (e.detail == SWT.CANCEL) {
search.setText(Messages.AlgorithmView_search_message);
search.setForeground(COLOR_FILTER_INITIAL);
initialSearchState = true;
// $NON-NLS-1$
treeView.setFilter("");
// $NON-NLS-1$
paletteView.setFilter("");
}
}
});
}
use of org.eclipse.swt.events.PaintEvent in project jbosstools-openshift by jbosstools.
the class AbstractProjectPage method onPageActivated.
@Override
protected void onPageActivated(final DataBindingContext dbc) {
loadResources(getPreviousPage() == null);
// fix GTK3 combo boxes too small
// https://issues.jboss.org/browse/JBIDE-16877,
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=431425
getControl().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (getControl().isVisible()) {
((Composite) getControl()).layout(true, true);
((Composite) getControl()).update();
getControl().removePaintListener(this);
}
}
});
}
Aggregations