Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » fix for cosmetic painting problem in PGroup
fix for cosmetic painting problem in PGroup [message #33926] Thu, 03 May 2007 13:46 Go to next message
Eclipse UserFriend
Originally posted by: slorenc.infogix.com

I ran into a painting problem with PGroup which has rounded corners. When
you set PGroups background to something other than the parent control's
background Pgroup's background bleeds outside the 4 rounded corners.



I fixed this problem by adding 2 lines of code in RectangleGroupStrategy's
paint method and would like to offer this fix to be incorporated into the
code.



First I set the background color to parent's color around line 136. See
Re: fix for cosmetic painting problem in PGroup [message #34001 is a reply to message #33926] Thu, 03 May 2007 16:18 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Hi Swavek,

PGroup is designed to correctly show the parent's background if you use
the SWT background mode features. If you call
setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
background color of the parent bleed through correctly.

Regards,
-Chris

Swavek Lorenc wrote:
> I ran into a painting problem with PGroup which has rounded corners. When
> you set PGroups background to something other than the parent control's
> background Pgroup's background bleeds outside the 4 rounded corners.
>
>
>
> I fixed this problem by adding 2 lines of code in RectangleGroupStrategy's
> paint method and would like to offer this fix to be incorporated into the
> code.
>
>
>
> First I set the background color to parent's color around line 136. See à
>
>
>
> Color back = getGroup().internalGetBackground();
>
> if (back != null)
>
> {
>
> // fill background with parent color so the areas outside the
> rounded edges have the same color as parent
>
> à gc.setBackground(getGroup().getParent().getBackground()); //
> added line
>
> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>
>
>
> The second place where this fix is made is in the code which paints the
> bottom rounded rectangle around line 404.
>
>
>
> gc.setClipping(reg);
>
> // fill the background constrained by the clipping region
>
> à gc.fillRectangle(0, titleHeight, getGroup().getSize().x - 1,
> getGroup().getSize().y - titleHeight); // added line
>
> // draw rounded bottom border
>
> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
> getGroup().getSize().x - 1,
>
> getGroup().getSize().y -
> titleHeight, null, false,
>
> true);
>
>
>
> reg.dispose();
>
>
>
> Swavek Lorenc
>
> slorenc@infogix.com
>
>
>
Re: fix for cosmetic painting problem in PGroup [message #44943 is a reply to message #34001] Tue, 18 December 2007 09:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Chris,

I don't know maybe I'm doing something wrong but code like this:


PGroup group_other = new PGroup(form, SWT.SMOOTH);
group_other.addControlListener(new Relayout());
group_other.setExpanded(false);
group_other.setBackgroundMode(SWT.INHERIT_DEFAULT);
group_other.setBackground(group_other.getDisplay().getSystem Color(SWT.COLOR_WHITE));

Leaves white edges at the bottom and top! Is there something I'm doing
wrong? Adding the 2 lines from this post fixes the problem reveals
another one because when putting Group-Widgets inside the PGroup their
border is not rendered any more.

I've tested with WinXP and Eclipse-3.3.

Tom

Chris Gross schrieb:
> Hi Swavek,
>
> PGroup is designed to correctly show the parent's background if you use
> the SWT background mode features. If you call
> setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
> background color of the parent bleed through correctly.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> I ran into a painting problem with PGroup which has rounded corners.
>> When you set PGroups background to something other than the parent
>> control's background Pgroup's background bleeds outside the 4 rounded
>> corners.
>>
>>
>>
>> I fixed this problem by adding 2 lines of code in
>> RectangleGroupStrategy's paint method and would like to offer this fix
>> to be incorporated into the code.
>>
>>
>>
>> First I set the background color to parent's color around line 136.
>> See à
>>
>>
>>
>> Color back = getGroup().internalGetBackground();
>>
>> if (back != null)
>>
>> {
>>
>> // fill background with parent color so the areas outside
>> the rounded edges have the same color as parent
>>
>> à gc.setBackground(getGroup().getParent().getBackground());
>> // added line
>>
>>
>> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>>
>>
>>
>> The second place where this fix is made is in the code which paints
>> the bottom rounded rectangle around line 404.
>>
>>
>>
>> gc.setClipping(reg);
>>
>> // fill the background constrained by the clipping region
>>
>> à gc.fillRectangle(0, titleHeight, getGroup().getSize().x
>> - 1, getGroup().getSize().y - titleHeight); // added line
>>
>> // draw rounded bottom border
>>
>> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
>> getGroup().getSize().x - 1,
>>
>> getGroup().getSize().y
>> - titleHeight, null, false,
>>
>> true);
>>
>>
>>
>> reg.dispose();
>>
>>
>>
>> Swavek Lorenc
>>
>> slorenc@infogix.com
>>
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: fix for cosmetic painting problem in PGroup [message #45335 is a reply to message #44943] Fri, 04 January 2008 21:21 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
You have to call setBackgroundMode on the parent of the PGroup. The
background mode API is (IMO) really confusing. I've added a new snippet
to show how to do correctly. Let me know if this helps:

http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.ecli pse.swt.nebula/org.eclipse.swt.nebula.snippets/src/org/eclip se/swt/nebula/snippets/pgroup/PGroupSnippet2.java?cvsroot=Te chnology_Project

-Chris

Tom Schindl wrote:
> Hi Chris,
>
> I don't know maybe I'm doing something wrong but code like this:
>
>
> PGroup group_other = new PGroup(form, SWT.SMOOTH);
> group_other.addControlListener(new Relayout());
> group_other.setExpanded(false);
> group_other.setBackgroundMode(SWT.INHERIT_DEFAULT);
> group_other.setBackground(group_other.getDisplay().getSystem Color(SWT.COLOR_WHITE));
>
>
> Leaves white edges at the bottom and top! Is there something I'm doing
> wrong? Adding the 2 lines from this post fixes the problem reveals
> another one because when putting Group-Widgets inside the PGroup their
> border is not rendered any more.
>
> I've tested with WinXP and Eclipse-3.3.
>
> Tom
>
> Chris Gross schrieb:
>> Hi Swavek,
>>
>> PGroup is designed to correctly show the parent's background if you
>> use the SWT background mode features. If you call
>> setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
>> background color of the parent bleed through correctly.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I ran into a painting problem with PGroup which has rounded corners.
>>> When you set PGroups background to something other than the parent
>>> control's background Pgroup's background bleeds outside the 4 rounded
>>> corners.
>>>
>>>
>>>
>>> I fixed this problem by adding 2 lines of code in
>>> RectangleGroupStrategy's paint method and would like to offer this
>>> fix to be incorporated into the code.
>>>
>>>
>>>
>>> First I set the background color to parent's color around line 136.
>>> See à
>>>
>>>
>>>
>>> Color back = getGroup().internalGetBackground();
>>>
>>> if (back != null)
>>>
>>> {
>>>
>>> // fill background with parent color so the areas outside
>>> the rounded edges have the same color as parent
>>>
>>> à gc.setBackground(getGroup().getParent().getBackground());
>>> // added line
>>>
>>>
>>> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>>>
>>>
>>>
>>> The second place where this fix is made is in the code which paints
>>> the bottom rounded rectangle around line 404.
>>>
>>>
>>>
>>> gc.setClipping(reg);
>>>
>>> // fill the background constrained by the clipping
>>> region
>>>
>>> à gc.fillRectangle(0, titleHeight,
>>> getGroup().getSize().x - 1, getGroup().getSize().y - titleHeight);
>>> // added line
>>>
>>> // draw rounded bottom border
>>>
>>> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
>>> getGroup().getSize().x - 1,
>>>
>>>
>>> getGroup().getSize().y - titleHeight, null, false,
>>>
>>> true);
>>>
>>>
>>>
>>> reg.dispose();
>>>
>>>
>>>
>>> Swavek Lorenc
>>>
>>> slorenc@infogix.com
>>>
>>>
>>>
>
>
Re: fix for cosmetic painting problem in PGroup [message #581717 is a reply to message #33926] Thu, 03 May 2007 16:18 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Hi Swavek,

PGroup is designed to correctly show the parent's background if you use
the SWT background mode features. If you call
setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
background color of the parent bleed through correctly.

Regards,
-Chris

Swavek Lorenc wrote:
> I ran into a painting problem with PGroup which has rounded corners. When
> you set PGroups background to something other than the parent control's
> background Pgroup's background bleeds outside the 4 rounded corners.
>
>
>
> I fixed this problem by adding 2 lines of code in RectangleGroupStrategy's
> paint method and would like to offer this fix to be incorporated into the
> code.
>
>
>
> First I set the background color to parent's color around line 136. See à
>
>
>
> Color back = getGroup().internalGetBackground();
>
> if (back != null)
>
> {
>
> // fill background with parent color so the areas outside the
> rounded edges have the same color as parent
>
> à gc.setBackground(getGroup().getParent().getBackground()); //
> added line
>
> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>
>
>
> The second place where this fix is made is in the code which paints the
> bottom rounded rectangle around line 404.
>
>
>
> gc.setClipping(reg);
>
> // fill the background constrained by the clipping region
>
> à gc.fillRectangle(0, titleHeight, getGroup().getSize().x - 1,
> getGroup().getSize().y - titleHeight); // added line
>
> // draw rounded bottom border
>
> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
> getGroup().getSize().x - 1,
>
> getGroup().getSize().y -
> titleHeight, null, false,
>
> true);
>
>
>
> reg.dispose();
>
>
>
> Swavek Lorenc
>
> slorenc@infogix.com
>
>
>
Re: fix for cosmetic painting problem in PGroup [message #587036 is a reply to message #34001] Tue, 18 December 2007 09:40 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Chris,

I don't know maybe I'm doing something wrong but code like this:


PGroup group_other = new PGroup(form, SWT.SMOOTH);
group_other.addControlListener(new Relayout());
group_other.setExpanded(false);
group_other.setBackgroundMode(SWT.INHERIT_DEFAULT);
group_other.setBackground(group_other.getDisplay().getSystem Color(SWT.COLOR_WHITE));

Leaves white edges at the bottom and top! Is there something I'm doing
wrong? Adding the 2 lines from this post fixes the problem reveals
another one because when putting Group-Widgets inside the PGroup their
border is not rendered any more.

I've tested with WinXP and Eclipse-3.3.

Tom

Chris Gross schrieb:
> Hi Swavek,
>
> PGroup is designed to correctly show the parent's background if you use
> the SWT background mode features. If you call
> setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
> background color of the parent bleed through correctly.
>
> Regards,
> -Chris
>
> Swavek Lorenc wrote:
>> I ran into a painting problem with PGroup which has rounded corners.
>> When you set PGroups background to something other than the parent
>> control's background Pgroup's background bleeds outside the 4 rounded
>> corners.
>>
>>
>>
>> I fixed this problem by adding 2 lines of code in
>> RectangleGroupStrategy's paint method and would like to offer this fix
>> to be incorporated into the code.
>>
>>
>>
>> First I set the background color to parent's color around line 136.
>> See à
>>
>>
>>
>> Color back = getGroup().internalGetBackground();
>>
>> if (back != null)
>>
>> {
>>
>> // fill background with parent color so the areas outside
>> the rounded edges have the same color as parent
>>
>> à gc.setBackground(getGroup().getParent().getBackground());
>> // added line
>>
>>
>> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>>
>>
>>
>> The second place where this fix is made is in the code which paints
>> the bottom rounded rectangle around line 404.
>>
>>
>>
>> gc.setClipping(reg);
>>
>> // fill the background constrained by the clipping region
>>
>> à gc.fillRectangle(0, titleHeight, getGroup().getSize().x
>> - 1, getGroup().getSize().y - titleHeight); // added line
>>
>> // draw rounded bottom border
>>
>> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
>> getGroup().getSize().x - 1,
>>
>> getGroup().getSize().y
>> - titleHeight, null, false,
>>
>> true);
>>
>>
>>
>> reg.dispose();
>>
>>
>>
>> Swavek Lorenc
>>
>> slorenc@infogix.com
>>
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: fix for cosmetic painting problem in PGroup [message #587152 is a reply to message #44943] Fri, 04 January 2008 21:21 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
You have to call setBackgroundMode on the parent of the PGroup. The
background mode API is (IMO) really confusing. I've added a new snippet
to show how to do correctly. Let me know if this helps:

http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.ecli pse.swt.nebula/org.eclipse.swt.nebula.snippets/src/org/eclip se/swt/nebula/snippets/pgroup/PGroupSnippet2.java?cvsroot=Te chnology_Project

-Chris

Tom Schindl wrote:
> Hi Chris,
>
> I don't know maybe I'm doing something wrong but code like this:
>
>
> PGroup group_other = new PGroup(form, SWT.SMOOTH);
> group_other.addControlListener(new Relayout());
> group_other.setExpanded(false);
> group_other.setBackgroundMode(SWT.INHERIT_DEFAULT);
> group_other.setBackground(group_other.getDisplay().getSystem Color(SWT.COLOR_WHITE));
>
>
> Leaves white edges at the bottom and top! Is there something I'm doing
> wrong? Adding the 2 lines from this post fixes the problem reveals
> another one because when putting Group-Widgets inside the PGroup their
> border is not rendered any more.
>
> I've tested with WinXP and Eclipse-3.3.
>
> Tom
>
> Chris Gross schrieb:
>> Hi Swavek,
>>
>> PGroup is designed to correctly show the parent's background if you
>> use the SWT background mode features. If you call
>> setBackgroundMode(SWT.INHERIT_DEFAULT) then you should see the
>> background color of the parent bleed through correctly.
>>
>> Regards,
>> -Chris
>>
>> Swavek Lorenc wrote:
>>> I ran into a painting problem with PGroup which has rounded corners.
>>> When you set PGroups background to something other than the parent
>>> control's background Pgroup's background bleeds outside the 4 rounded
>>> corners.
>>>
>>>
>>>
>>> I fixed this problem by adding 2 lines of code in
>>> RectangleGroupStrategy's paint method and would like to offer this
>>> fix to be incorporated into the code.
>>>
>>>
>>>
>>> First I set the background color to parent's color around line 136.
>>> See à
>>>
>>>
>>>
>>> Color back = getGroup().internalGetBackground();
>>>
>>> if (back != null)
>>>
>>> {
>>>
>>> // fill background with parent color so the areas outside
>>> the rounded edges have the same color as parent
>>>
>>> à gc.setBackground(getGroup().getParent().getBackground());
>>> // added line
>>>
>>>
>>> gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSi ze().y);
>>>
>>>
>>>
>>> The second place where this fix is made is in the code which paints
>>> the bottom rounded rectangle around line 404.
>>>
>>>
>>>
>>> gc.setClipping(reg);
>>>
>>> // fill the background constrained by the clipping
>>> region
>>>
>>> à gc.fillRectangle(0, titleHeight,
>>> getGroup().getSize().x - 1, getGroup().getSize().y - titleHeight);
>>> // added line
>>>
>>> // draw rounded bottom border
>>>
>>> GraphicUtils.drawRoundRectangle(gc, 0, titleHeight,
>>> getGroup().getSize().x - 1,
>>>
>>>
>>> getGroup().getSize().y - titleHeight, null, false,
>>>
>>> true);
>>>
>>>
>>>
>>> reg.dispose();
>>>
>>>
>>>
>>> Swavek Lorenc
>>>
>>> slorenc@infogix.com
>>>
>>>
>>>
>
>
Previous Topic:Pressing "Arrow Down" key right after focusing and selection of some cell in Grid programm
Next Topic:How to cancel keyboard event in the Grid?
Goto Forum:
  


Current Time: Thu Mar 28 18:00:00 GMT 2024

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

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

Back to the top