use of org.eclipse.swt.events.PaintListener in project cubrid-manager by CUBRID.
the class InformationWindow method createContents.
protected Control createContents(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
infoText = new StyledText(composite, SWT.None);
infoText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
infoText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
infoText.setEditable(false);
infoText.setEnabled(false);
infoText.addMouseTrackListener(new MouseTrackListener() {
public void mouseHover(MouseEvent e) {
increaseAlpha();
}
public void mouseExit(MouseEvent e) {
reduceAlpha();
}
public void mouseEnter(MouseEvent e) {
increaseAlpha();
}
});
parentShell.addControlListener(new ControlListener() {
public void controlResized(ControlEvent e) {
updateLocation();
}
public void controlMoved(ControlEvent e) {
updateLocation();
}
});
if (Platform.getOS().equals(Platform.OS_WIN32)) {
parentShell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
updateLocation();
}
});
}
this.getShell().setAlpha(minAlpha);
updateLocation();
return parent;
}
use of org.eclipse.swt.events.PaintListener in project dbeaver by serge-rider.
the class ViewValuePanel method createContents.
@Override
public Control createContents(IResultSetPresentation presentation, Composite parent) {
this.presentation = presentation;
viewPlaceholder = new Composite(parent, SWT.NONE);
viewPlaceholder.setLayout(new FillLayout());
viewPlaceholder.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (viewPlaceholder.getChildren().length == 0) {
String hidePanelCmd = ActionUtils.findCommandDescription(ResultSetCommandHandler.CMD_TOGGLE_PANELS, ViewValuePanel.this.presentation.getController().getSite(), true);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Select a cell to view/edit value", 0);
UIUtils.drawMessageOverControl(viewPlaceholder, e, "Press " + hidePanelCmd + " to hide this panel", 20);
}
}
});
if (this.presentation instanceof ISelectionProvider) {
final ISelectionProvider selectionProvider = (ISelectionProvider) this.presentation;
final ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (ViewValuePanel.this.presentation.getController().getVisiblePanel() == ViewValuePanel.this) {
refreshValue(false);
}
}
};
selectionProvider.addSelectionChangedListener(selectionListener);
viewPlaceholder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
selectionProvider.removeSelectionChangedListener(selectionListener);
}
});
}
return viewPlaceholder;
}
use of org.eclipse.swt.events.PaintListener in project translationstudio8 by heartsome.
the class NatCombo method createTextControl.
private void createTextControl() {
text = new Text(this, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
text.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
text.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
text.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(gridData);
text.forceFocus();
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP) {
showDropdownControl();
int selectionIndex = dropdownList.getSelectionIndex();
selectionIndex += event.keyCode == SWT.ARROW_DOWN ? 1 : -1;
if (selectionIndex < 0) {
selectionIndex = 0;
}
dropdownList.select(selectionIndex);
text.setText(dropdownList.getSelection()[0]);
}
}
});
iconImage = GUIHelper.getImage("down_2");
final Canvas iconCanvas = new Canvas(this, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
Rectangle iconImageBounds = iconImage.getBounds();
return new Point(iconImageBounds.width + 2, iconImageBounds.height + 2);
}
};
gridData = new GridData(GridData.BEGINNING, SWT.FILL, false, true);
iconCanvas.setLayoutData(gridData);
iconCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
GC gc = event.gc;
Rectangle iconCanvasBounds = iconCanvas.getBounds();
Rectangle iconImageBounds = iconImage.getBounds();
int horizontalAlignmentPadding = CellStyleUtil.getHorizontalAlignmentPadding(HorizontalAlignmentEnum.CENTER, iconCanvasBounds, iconImageBounds.width);
int verticalAlignmentPadding = CellStyleUtil.getVerticalAlignmentPadding(VerticalAlignmentEnum.MIDDLE, iconCanvasBounds, iconImageBounds.height);
gc.drawImage(iconImage, horizontalAlignmentPadding, verticalAlignmentPadding);
Color originalFg = gc.getForeground();
gc.setForeground(GUIHelper.COLOR_WIDGET_BORDER);
gc.drawRectangle(0, 0, iconCanvasBounds.width - 1, iconCanvasBounds.height - 1);
gc.setForeground(originalFg);
}
});
iconCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
showDropdownControl();
}
});
}
use of org.eclipse.swt.events.PaintListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_addPaintListenerLorg_eclipse_swt_events_PaintListener.
@Test
public void test_addPaintListenerLorg_eclipse_swt_events_PaintListener() {
PaintListener listener = e -> eventOccurred = true;
control.addPaintListener(listener);
eventOccurred = false;
Event event = new Event();
GC gc = event.gc = new GC(control);
control.notifyListeners(SWT.Paint, event);
gc.dispose();
assertTrue(eventOccurred);
control.removePaintListener(listener);
}
use of org.eclipse.swt.events.PaintListener in project archi by archimatetool.
the class AboutDialog method createAboutTab.
private void createAboutTab() {
aboutTabItem = new TabItem(folder, SWT.NONE);
aboutTabItem.setText(Messages.AboutDialog_1);
Composite control = new Composite(folder, SWT.NONE);
control.setLayout(new GridLayout());
aboutTabItem.setControl(control);
Composite imageControl = new Composite(control, SWT.NO_BACKGROUND);
GridData gd = new GridData(GridData.CENTER, GridData.CENTER, true, true);
imageControl.setLayoutData(gd);
final int imageHeight;
// $NON-NLS-1$
final Image image = IArchiImages.ImageFactory.getImage("splash.bmp");
if (image != null) {
ImageData id = image.getImageData();
gd.widthHint = id.width;
gd.heightHint = id.height;
imageHeight = id.height;
} else {
gd.widthHint = 500;
gd.heightHint = 300;
imageHeight = 300;
}
final String version = Messages.AboutDialog_2 + System.getProperty(Application.APPLICATION_VERSIONID);
final String build = Messages.AboutDialog_3 + System.getProperty(Application.APPLICATION_BUILDID);
// $NON-NLS-1$
final String copyright = ArchiPlugin.INSTANCE.getResourceString("%aboutCopyright");
imageControl.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
int fontHeight = e.gc.getFontMetrics().getHeight() + 2;
e.gc.drawImage(image, 0, 0);
e.gc.drawString(version, 19, 166, true);
e.gc.drawString(build, 19, 166 + fontHeight, true);
e.gc.drawString(copyright, 12, imageHeight - fontHeight - 5, true);
}
});
}
Aggregations