String platform= SWT.getPlatform();
final boolean isWin= platform.equals("win32"); //$NON-NLS-1$
if (!isWin && !platform.equals("gtk")) //$NON-NLS-1$
return;
final Canvas resizer= new Canvas(bars, SWT.NONE);
int size= getResizeHandleSize(bars);
GridData data= new GridData(SWT.END, SWT.END, false, true);
data.widthHint= size;
data.heightHint= size;
resizer.setLayoutData(data);
resizer.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
Point s= resizer.getSize();
int x= s.x - 2;
int y= s.y - 2;
int min= Math.min(x, y);
if (isWin) {
// draw dots
e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
int end= min - 1;
for (int i= 0; i <= 2; i++)
for (int j= 0; j <= 2 - i; j++)
e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
end--;
e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
for (int i= 0; i <= 2; i++)
for (int j= 0; j <= 2 - i; j++)
e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
} else {
// draw diagonal lines
e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
for (int i= 1; i < min; i+= 4) {
e.gc.drawLine(i, y, x, i);
}
e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
for (int i= 2; i < min; i+= 4) {
e.gc.drawLine(i, y, x, i);
}
}
}
});
resizer.setCursor(new Cursor(resizer.getDisplay(), SWT.CURSOR_SIZESE));
MouseAdapter resizeSupport= new MouseAdapter() {
private MouseMoveListener fResizeListener;
public void mouseDown(MouseEvent e) {
Point shellSize= fShell.getSize();
final int shellX= shellSize.x;
final int shellY= shellSize.y;
Point mouseLoc= resizer.toDisplay(e.x, e.y);
final int mouseX= mouseLoc.x;
final int mouseY= mouseLoc.y;
fResizeListener= new MouseMoveListener() {
public void mouseMove(MouseEvent e2) {
Point mouseLoc2= resizer.toDisplay(e2.x, e2.y);
int dx= mouseLoc2.x - mouseX;
int dy= mouseLoc2.y - mouseY;
setSize(shellX + dx, shellY + dy);
}
};
resizer.addMouseMoveListener(fResizeListener);
}
public void mouseUp(MouseEvent e) {
resizer.removeMouseMoveListener(fResizeListener);
fResizeListener= null;
}
};
resizer.addMouseListener(resizeSupport);
}