fd.right = new FormAttachment(100, -14);
textWidget.setLayoutData(fd);
cBubble.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
Rectangle clientArea = cBubble.getClientArea();
e.gc.setBackground(textWidget.getBackground());
e.gc.setAdvanced(true);
e.gc.setAntialias(SWT.ON);
e.gc.fillRoundRectangle(clientArea.x, clientArea.y,
clientArea.width - 1, clientArea.height - 1, clientArea.height,
clientArea.height);
e.gc.setAlpha(127);
e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
clientArea.width - 1, clientArea.height - 1, clientArea.height,
clientArea.height);
e.gc.setLineCap(SWT.CAP_ROUND);
int iconHeight = clientArea.height - 9;
if (iconHeight > 13) {
iconHeight = 13;
}
int iconY = clientArea.y + ((clientArea.height - iconHeight + 1) / 2);
e.gc.setAlpha(120);
e.gc.setLineWidth(2);
e.gc.drawOval(clientArea.x + 6, iconY, 7, 6);
e.gc.drawPolyline(new int[] {
clientArea.x + 12,
iconY + 6,
clientArea.x + 15,
iconY + iconHeight,
});
boolean textIsBlank = text.length() == 0;
if (!textIsBlank) {
//e.gc.setLineWidth(1);
e.gc.setAlpha(80);
Rectangle rXArea = new Rectangle(clientArea.x + clientArea.width
- 16, clientArea.y + 1, 11, clientArea.height - 2);
cBubble.setData("XArea", rXArea);
e.gc.drawPolyline(new int[] {
clientArea.x + clientArea.width - 7,
clientArea.y + 7,
clientArea.x + clientArea.width - (7 + 5),
clientArea.y + clientArea.height - 7,
});
e.gc.drawPolyline(new int[] {
clientArea.x + clientArea.width - 7,
clientArea.y + clientArea.height - 7,
clientArea.x + clientArea.width - (7 + 5),
clientArea.y + 7,
});
}
}
});
cBubble.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
Rectangle r = (Rectangle) event.widget.getData("XArea");
if (r != null && r.contains(event.x, event.y)) {
textWidget.setText("");
}
}
});
}