use of org.eclipse.swt.graphics.Region in project xtext-eclipse by eclipse.
the class RenameRefactoringPopup method packPopup.
protected void packPopup() {
popupLayout.marginTop = HAH;
popupLayout.marginBottom = 0;
popup.pack();
Region oldRegion = region;
region = new Region();
region.add(getPolygon(false));
popup.setRegion(region);
Rectangle bounds = region.getBounds();
popup.setSize(bounds.width, bounds.height + 2);
if (oldRegion != null) {
oldRegion.dispose();
}
}
use of org.eclipse.swt.graphics.Region in project pmd-eclipse-plugin by pmd.
the class Util method backgroundBuilderFor.
public static CellPainterBuilder backgroundBuilderFor(final int systemColourIndex) {
return new CellPainterBuilder() {
public void addPainterFor(final Tree tree, final int columnIndex, final RuleFieldAccessor getter, Map<Integer, List<Listener>> paintListeners) {
final Display display = tree.getDisplay();
tree.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
if (event.index != columnIndex) {
return;
}
event.detail &= ~SWT.HOT;
if ((event.detail & SWT.SELECTED) != 0) {
GC gc = event.gc;
Rectangle area = tree.getClientArea();
/*
* If you wish to paint the selection beyond the end of last column, you must change the
* clipping region.
*/
int columnCount = tree.getColumnCount();
if (event.index == columnCount - 1 || columnCount == 0) {
int width = area.x + area.width - event.x;
if (width > 0) {
Region region = new Region();
gc.getClipping(region);
region.add(event.x, event.y, width, event.height);
gc.setClipping(region);
region.dispose();
}
}
gc.setAdvanced(true);
if (gc.getAdvanced()) {
gc.setAlpha(127);
}
Rectangle rect = event.getBounds();
Color foreground = gc.getForeground();
Color background = gc.getBackground();
gc.setForeground(display.getSystemColor(systemColourIndex));
gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
gc.fillGradientRectangle(event.x, rect.y, 500, rect.height, false);
gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
gc.drawLine(event.x, rect.y, event.x + 20, rect.y + 20);
// restore colors for subsequent drawing
gc.setForeground(foreground);
gc.setBackground(background);
event.detail &= ~SWT.SELECTED;
}
}
});
}
};
}
Aggregations