Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Custom widget problem
Custom widget problem [message #558008] Thu, 09 September 2010 19:01 Go to next message
No real name is currently offline No real nameFriend
Messages: 18
Registered: April 2010
Junior Member
Hello guys,

I have got problem and i hope someone can give me a hand. I want create custom widget so i extend Canvas, override computeSize and add paintListener to draw my widget. I create test application, create shell, set GridLayout with 10px margin and then create my widget. The problem is that my widget is not painted correctly. When i check getBounds its fine couse (10, 10, 62, 62) is what i expect but when i check getClipping on GC i got (0, 0, 62, 62). Why its like this? Even when i try change clipingArea it wont let me do that, cut my new are to fit (0,0,62,62) area space. How to draw it, couse GC let me draw only in are of (0, 0, 62, 62) no matter where Layout manager place my widget. I will be gratefull for any help and suggestions.

Tom
Re: Custom widget problem [message #558800 is a reply to message #558008] Tue, 14 September 2010 13:15 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Tom,

When GridLayout margins are set like this it indents where the child control
is placed. getBounds() returns (10, 10) for the x,y because this is your
Canvas' location relative to its parent (you're setting the GridLayout with
10px margins on the Canvas' parent, right?). So this is correct.

Your Canvas receives a Paint event with (0,0) for its x and y clipping
because this is relative to the _Canvas' origin_, not to its parent control.
The only time that a Paint's clipping x,y should be non-zero are if only a
portion of the Canvas has been damaged and requires redrawing. When
painting a Canvas' content the fact that it's indented by 10,10 relative to
its parent Control is not relevant.

If I've mis-understood your question then please follow up, thanks.

Grant


<kith1985@o2.pl> wrote in message news:i6baul$jat$1@build.eclipse.org...
> Hello guys,
>
> I have got problem and i hope someone can give me a hand. I want create
> custom widget so i extend Canvas, override computeSize and add
> paintListener to draw my widget. I create test application, create shell,
> set GridLayout with 10px margin and then create my widget. The problem is
> that my widget is not painted correctly. When i check getBounds its fine
> couse (10, 10, 62, 62) is what i expect but when i check getClipping on GC
> i got (0, 0, 62, 62). Why its like this? Even when i try change
> clipingArea it wont let me do that, cut my new are to fit (0,0,62,62) area
> space. How to draw it, couse GC let me draw only in are of (0, 0, 62, 62)
> no matter where Layout manager place my widget. I will be gratefull for
> any help and suggestions.
> Tom
Previous Topic:Basic Radio button text color question
Next Topic:Using Browser.evaluate and Browser.execute in non-top window contexts?
Goto Forum:
  


Current Time: Sat Apr 20 04:22:38 GMT 2024

Powered by FUDForum. Page generated in 0.03010 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top