use of org.eclipse.swt.events.PaintEvent 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.PaintEvent 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.PaintEvent 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.PaintEvent 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);
}
});
}
use of org.eclipse.swt.events.PaintEvent in project eclipse.platform.text by eclipse.
the class OverviewRuler method createControl.
@Override
public Control createControl(Composite parent, ITextViewer textViewer) {
fTextViewer = textViewer;
fHitDetectionCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
fHeader = new Canvas(parent, SWT.NONE);
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
fHeader.addMouseTrackListener(new MouseTrackAdapter() {
/*
* @see org.eclipse.swt.events.MouseTrackAdapter#mouseHover(org.eclipse.swt.events.MouseEvent)
* @since 3.3
*/
@Override
public void mouseEnter(MouseEvent e) {
updateHeaderToolTipText();
}
});
}
fCanvas = new Canvas(parent, SWT.NO_BACKGROUND);
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent event) {
if (fTextViewer != null)
doubleBufferPaint(event.gc);
}
});
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
handleDispose();
fTextViewer = null;
}
});
fCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
});
fCanvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
fCanvas.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
handleMouseScrolled(e);
}
});
if (fTextViewer != null) {
fTextViewer.addTextListener(fInternalListener);
// on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
fTextViewer.getTextWidget().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (fTextViewer == null) {
return;
}
StyledText textWidget = fTextViewer.getTextWidget();
if (textWidget != null && textWidget.getWordWrap()) {
redraw();
}
}
});
}
return fCanvas;
}
Aggregations