Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Custom Group widget

Hi,

what's wrong with:

gc.drawText("MyWidget's Text", rect.x + 10, rect.y);

This should draw the text at the specified position. Some font formatting and better positioning assumed.

Cheers
Jan

On Tue, Aug 26, 2008 at 12:51 PM, Andrea Paternesi <patton73@xxxxxxxxxx> wrote:
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!

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top