Hi all,
i am new here. Hope i got the right Mailing list.
I am trying to make my first custom widget.
I would like to make a Custom Group widget with eye-candy border and text over it (as the normal group widget does).
A little snipet with normal rectangle border.
class MyWidget extends Canvas {
public MyWidget(Composite parent, int style) {
super(parent, style);
addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
drawControl(e);
}
});
}
// draws the eye-candy borders and text over it
public void drawControl(PaintEvent e) {
GC gc = e.gc;
Rectangle rect = getClientArea();
gc.setLineWidth(2);
gc.setLineStyle(SWT.LINE_DASH);
// draw it a little inside of the total space that we take up
gc.drawRectangle(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10);
//Draw text here
}
}
Now my problem is to add text over the border as the Group class does.
Can you help in giving me the right way?
Shoul i use pheraps a GridLayout?
Thanks for any help you can give.
Andrea
È gratis!
SkyDrive: 5GB di spazio on line per tutti i tuoi files!