Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » FormLayout & spacing
FormLayout & spacing [message #437420] Fri, 04 June 2004 06:38 Go to next message
Eclipse UserFriend
Originally posted by: fayth.ut-mapdepot.com

Hi, I've exhausted just about everything I can try so it's time to refer to
the community.

I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create a new
"skinned" button as I absolutely could not get button to not display it's
edges when mouse enters the button area or presses on the button. I use a
CLabel widget to hold my new button image. I add some listeners to trap
mouse enter and a mouse left click and change the image to reflect a button
state. I subclassed Layout to handle the layout of each button I created. It
also enabled me to use FormLayout manager to arrange my GUI. This is where I
run into problems.

No matter how hard I try to get rid of it, I get a 3pixel border around each
widget that is placed in a composite. I absolutely need the buttons side by
side so the graphics line up.

public class PButton extends Composite {
Image image;
CLabel iLabel;
Vector pButtonPressListeners = new Vector();
Vector pButtonTrackListeners = new Vector();

public PButton(Composite parent, int style, Point pBSize) {
super(parent, style);
iLabel = new CLabel(this, 0);
setSize(pBSize); // <<<<<<======== I tried cheating here!

addDisposeListener(new DisposeListener() { ... });
iLabel.addMouseListener(new MouseAdapter() { ... });
iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });

setLayout(new PButtonLayout(pBSize));
}

public class PButtonLayout extends Layout {
Point iExtent; //the cached size

public PButtonLayout(Point iExtent) {
this.iExtent = iExtent; // <<<<===== I tried cheating here! Doesn't
affect the results whatsoever.
}

protected Point computeSize(Composite composite, int wHint, int hHint,
boolean changed) {
Control [] children = composite.getChildren();
if (changed || iExtent == null) {
iExtent = children[0].computeSize(wHint, hHint, false);
}
return new Point(iExtent.x, iExtent.y);
}

protected void layout(Composite composite, boolean changed) {
Control [] children = composite.getChildren();
if (changed || iExtent == null) {
iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
}
children[0].setBounds(0, 0, iExtent.x, iExtent.y);
}
}

I get the bounds of the image to be used (all states are equal size images)
and pass that size to the creation of each PButton.

PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
bounds.height));

The parent is a composite that sets FormLayout margins to 0 and spacing to
0. If I set the FormData() for my PButton like:
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
pButton1.setLayoutData(data);

data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(pButton1);
data.right = new FormAttachment(100, 0);
pButton2.setLayoutData(data);

I get a 3 pixel border around each widget that is actually added into the
calculation of getSize(). Now if I hardcode the size:
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.width = 186; data.height = 55;
pButton1.setLayoutData(data);

The listeners all work so the widgets are there, but nothing gets drawn. I
am at my wits end! I've spent the last 3 days (I'm out of work)trying
different ways to fix this but I end up with the same results. Oh, I've
tried the other form managers as well with the same results.

Please... I apologize for the size of this but wanted to save the "post the
code!" msgs going back and forth. If anybody has any idea what I'm doing
wrong could you please let me know? I would be very grateful. I am hoping
that the end product of this project will be a fully skinnable widget set.

Cheers... Vic Hanson
Re: FormLayout & spacing [message #437507 is a reply to message #437420] Sun, 06 June 2004 19:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fayth.ut-mapdepot.com

Ok, well I guess I failed to generate any interest for this topic. I'm going
to consider this a bug in SWT, no matter what I tried in the layout managers
it would not allow me to have zero spacing between layed out widgets. My
widget size maintained the correct size right on up to the shell.pack()
function, which would add a 3 pixel border around the entire widget.

I was able to overcome this serious deficiency by not using the layout
managers at all.

Cheers, Fayth

"Fayth" <fayth@ut-mapdepot.com> wrote in message
news:c9p4t9$aq1$1@eclipse.org...
> Hi, I've exhausted just about everything I can try so it's time to refer
to
> the community.
>
> I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create a new
> "skinned" button as I absolutely could not get button to not display it's
> edges when mouse enters the button area or presses on the button. I use a
> CLabel widget to hold my new button image. I add some listeners to trap
> mouse enter and a mouse left click and change the image to reflect a
button
> state. I subclassed Layout to handle the layout of each button I created.
It
> also enabled me to use FormLayout manager to arrange my GUI. This is where
I
> run into problems.
>
> No matter how hard I try to get rid of it, I get a 3pixel border around
each
> widget that is placed in a composite. I absolutely need the buttons side
by
> side so the graphics line up.
>
> public class PButton extends Composite {
> Image image;
> CLabel iLabel;
> Vector pButtonPressListeners = new Vector();
> Vector pButtonTrackListeners = new Vector();
>
> public PButton(Composite parent, int style, Point pBSize) {
> super(parent, style);
> iLabel = new CLabel(this, 0);
> setSize(pBSize); // <<<<<<======== I tried cheating here!
>
> addDisposeListener(new DisposeListener() { ... });
> iLabel.addMouseListener(new MouseAdapter() { ... });
> iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
>
> setLayout(new PButtonLayout(pBSize));
> }
>
> public class PButtonLayout extends Layout {
> Point iExtent; //the cached size
>
> public PButtonLayout(Point iExtent) {
> this.iExtent = iExtent; // <<<<===== I tried cheating here! Doesn't
> affect the results whatsoever.
> }
>
> protected Point computeSize(Composite composite, int wHint, int hHint,
> boolean changed) {
> Control [] children = composite.getChildren();
> if (changed || iExtent == null) {
> iExtent = children[0].computeSize(wHint, hHint, false);
> }
> return new Point(iExtent.x, iExtent.y);
> }
>
> protected void layout(Composite composite, boolean changed) {
> Control [] children = composite.getChildren();
> if (changed || iExtent == null) {
> iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> }
> children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> }
> }
>
> I get the bounds of the image to be used (all states are equal size
images)
> and pass that size to the creation of each PButton.
>
> PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> bounds.height));
>
> The parent is a composite that sets FormLayout margins to 0 and spacing to
> 0. If I set the FormData() for my PButton like:
> FormData data = new FormData();
> data.top = new FormAttachment(0, 0);
> data.left = new FormAttachment(0, 0);
> pButton1.setLayoutData(data);
>
> data = new FormData();
> data.top = new FormAttachment(0, 0);
> data.left = new FormAttachment(pButton1);
> data.right = new FormAttachment(100, 0);
> pButton2.setLayoutData(data);
>
> I get a 3 pixel border around each widget that is actually added into the
> calculation of getSize(). Now if I hardcode the size:
> FormData data = new FormData();
> data.top = new FormAttachment(0, 0);
> data.left = new FormAttachment(0, 0);
> data.width = 186; data.height = 55;
> pButton1.setLayoutData(data);
>
> The listeners all work so the widgets are there, but nothing gets drawn. I
> am at my wits end! I've spent the last 3 days (I'm out of work)trying
> different ways to fix this but I end up with the same results. Oh, I've
> tried the other form managers as well with the same results.
>
> Please... I apologize for the size of this but wanted to save the "post
the
> code!" msgs going back and forth. If anybody has any idea what I'm doing
> wrong could you please let me know? I would be very grateful. I am hoping
> that the end product of this project will be a fully skinnable widget set.
>
> Cheers... Vic Hanson
>
>
Re: FormLayout & spacing [message #437547 is a reply to message #437507] Mon, 07 June 2004 14:31 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Fayth, we are in the middle of 3.0 hell so we don't get to the news groups
as much as we would like. Sorry, but please "post the code" (a complete
stand alone example) and I will look at it. Posting fragments is almost
useless. Thanks and hang in there, we are generally pretty responsive.

"Fayth" <fayth@ut-mapdepot.com> wrote in message
news:c9vpf6$kk5$1@eclipse.org...
> Ok, well I guess I failed to generate any interest for this topic. I'm
going
> to consider this a bug in SWT, no matter what I tried in the layout
managers
> it would not allow me to have zero spacing between layed out widgets. My
> widget size maintained the correct size right on up to the shell.pack()
> function, which would add a 3 pixel border around the entire widget.
>
> I was able to overcome this serious deficiency by not using the layout
> managers at all.
>
> Cheers, Fayth
>
> "Fayth" <fayth@ut-mapdepot.com> wrote in message
> news:c9p4t9$aq1$1@eclipse.org...
> > Hi, I've exhausted just about everything I can try so it's time to refer
> to
> > the community.
> >
> > I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create a
new
> > "skinned" button as I absolutely could not get button to not display
it's
> > edges when mouse enters the button area or presses on the button. I use
a
> > CLabel widget to hold my new button image. I add some listeners to trap
> > mouse enter and a mouse left click and change the image to reflect a
> button
> > state. I subclassed Layout to handle the layout of each button I
created.
> It
> > also enabled me to use FormLayout manager to arrange my GUI. This is
where
> I
> > run into problems.
> >
> > No matter how hard I try to get rid of it, I get a 3pixel border around
> each
> > widget that is placed in a composite. I absolutely need the buttons side
> by
> > side so the graphics line up.
> >
> > public class PButton extends Composite {
> > Image image;
> > CLabel iLabel;
> > Vector pButtonPressListeners = new Vector();
> > Vector pButtonTrackListeners = new Vector();
> >
> > public PButton(Composite parent, int style, Point pBSize) {
> > super(parent, style);
> > iLabel = new CLabel(this, 0);
> > setSize(pBSize); // <<<<<<======== I tried cheating here!
> >
> > addDisposeListener(new DisposeListener() { ... });
> > iLabel.addMouseListener(new MouseAdapter() { ... });
> > iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
> >
> > setLayout(new PButtonLayout(pBSize));
> > }
> >
> > public class PButtonLayout extends Layout {
> > Point iExtent; //the cached size
> >
> > public PButtonLayout(Point iExtent) {
> > this.iExtent = iExtent; // <<<<===== I tried cheating here! Doesn't
> > affect the results whatsoever.
> > }
> >
> > protected Point computeSize(Composite composite, int wHint, int hHint,
> > boolean changed) {
> > Control [] children = composite.getChildren();
> > if (changed || iExtent == null) {
> > iExtent = children[0].computeSize(wHint, hHint, false);
> > }
> > return new Point(iExtent.x, iExtent.y);
> > }
> >
> > protected void layout(Composite composite, boolean changed) {
> > Control [] children = composite.getChildren();
> > if (changed || iExtent == null) {
> > iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> > }
> > children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> > }
> > }
> >
> > I get the bounds of the image to be used (all states are equal size
> images)
> > and pass that size to the creation of each PButton.
> >
> > PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> > bounds.height));
> >
> > The parent is a composite that sets FormLayout margins to 0 and spacing
to
> > 0. If I set the FormData() for my PButton like:
> > FormData data = new FormData();
> > data.top = new FormAttachment(0, 0);
> > data.left = new FormAttachment(0, 0);
> > pButton1.setLayoutData(data);
> >
> > data = new FormData();
> > data.top = new FormAttachment(0, 0);
> > data.left = new FormAttachment(pButton1);
> > data.right = new FormAttachment(100, 0);
> > pButton2.setLayoutData(data);
> >
> > I get a 3 pixel border around each widget that is actually added into
the
> > calculation of getSize(). Now if I hardcode the size:
> > FormData data = new FormData();
> > data.top = new FormAttachment(0, 0);
> > data.left = new FormAttachment(0, 0);
> > data.width = 186; data.height = 55;
> > pButton1.setLayoutData(data);
> >
> > The listeners all work so the widgets are there, but nothing gets drawn.
I
> > am at my wits end! I've spent the last 3 days (I'm out of work)trying
> > different ways to fix this but I end up with the same results. Oh, I've
> > tried the other form managers as well with the same results.
> >
> > Please... I apologize for the size of this but wanted to save the "post
> the
> > code!" msgs going back and forth. If anybody has any idea what I'm doing
> > wrong could you please let me know? I would be very grateful. I am
hoping
> > that the end product of this project will be a fully skinnable widget
set.
> >
> > Cheers... Vic Hanson
> >
> >
>
>
Re: FormLayout & spacing [message #437609 is a reply to message #437547] Tue, 08 June 2004 19:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fayth.ut-mapdepot.com

Steve,
Forgive me for being a little impatient! I will have to recreate the
program from the snips I posted. I'll try to have it by the weekend. Thank
you so much for replying!

Fayth

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:ca1tpd$sfm$1@eclipse.org...
> Fayth, we are in the middle of 3.0 hell so we don't get to the news groups
> as much as we would like. Sorry, but please "post the code" (a complete
> stand alone example) and I will look at it. Posting fragments is almost
> useless. Thanks and hang in there, we are generally pretty responsive.
>
> "Fayth" <fayth@ut-mapdepot.com> wrote in message
> news:c9vpf6$kk5$1@eclipse.org...
> > Ok, well I guess I failed to generate any interest for this topic. I'm
> going
> > to consider this a bug in SWT, no matter what I tried in the layout
> managers
> > it would not allow me to have zero spacing between layed out widgets. My
> > widget size maintained the correct size right on up to the shell.pack()
> > function, which would add a 3 pixel border around the entire widget.
> >
> > I was able to overcome this serious deficiency by not using the layout
> > managers at all.
> >
> > Cheers, Fayth
> >
> > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > news:c9p4t9$aq1$1@eclipse.org...
> > > Hi, I've exhausted just about everything I can try so it's time to
refer
> > to
> > > the community.
> > >
> > > I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create a
> new
> > > "skinned" button as I absolutely could not get button to not display
> it's
> > > edges when mouse enters the button area or presses on the button. I
use
> a
> > > CLabel widget to hold my new button image. I add some listeners to
trap
> > > mouse enter and a mouse left click and change the image to reflect a
> > button
> > > state. I subclassed Layout to handle the layout of each button I
> created.
> > It
> > > also enabled me to use FormLayout manager to arrange my GUI. This is
> where
> > I
> > > run into problems.
> > >
> > > No matter how hard I try to get rid of it, I get a 3pixel border
around
> > each
> > > widget that is placed in a composite. I absolutely need the buttons
side
> > by
> > > side so the graphics line up.
> > >
> > > public class PButton extends Composite {
> > > Image image;
> > > CLabel iLabel;
> > > Vector pButtonPressListeners = new Vector();
> > > Vector pButtonTrackListeners = new Vector();
> > >
> > > public PButton(Composite parent, int style, Point pBSize) {
> > > super(parent, style);
> > > iLabel = new CLabel(this, 0);
> > > setSize(pBSize); // <<<<<<======== I tried cheating here!
> > >
> > > addDisposeListener(new DisposeListener() { ... });
> > > iLabel.addMouseListener(new MouseAdapter() { ... });
> > > iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
> > >
> > > setLayout(new PButtonLayout(pBSize));
> > > }
> > >
> > > public class PButtonLayout extends Layout {
> > > Point iExtent; //the cached size
> > >
> > > public PButtonLayout(Point iExtent) {
> > > this.iExtent = iExtent; // <<<<===== I tried cheating here! Doesn't
> > > affect the results whatsoever.
> > > }
> > >
> > > protected Point computeSize(Composite composite, int wHint, int
hHint,
> > > boolean changed) {
> > > Control [] children = composite.getChildren();
> > > if (changed || iExtent == null) {
> > > iExtent = children[0].computeSize(wHint, hHint, false);
> > > }
> > > return new Point(iExtent.x, iExtent.y);
> > > }
> > >
> > > protected void layout(Composite composite, boolean changed) {
> > > Control [] children = composite.getChildren();
> > > if (changed || iExtent == null) {
> > > iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> > > }
> > > children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> > > }
> > > }
> > >
> > > I get the bounds of the image to be used (all states are equal size
> > images)
> > > and pass that size to the creation of each PButton.
> > >
> > > PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> > > bounds.height));
> > >
> > > The parent is a composite that sets FormLayout margins to 0 and
spacing
> to
> > > 0. If I set the FormData() for my PButton like:
> > > FormData data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(0, 0);
> > > pButton1.setLayoutData(data);
> > >
> > > data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(pButton1);
> > > data.right = new FormAttachment(100, 0);
> > > pButton2.setLayoutData(data);
> > >
> > > I get a 3 pixel border around each widget that is actually added into
> the
> > > calculation of getSize(). Now if I hardcode the size:
> > > FormData data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(0, 0);
> > > data.width = 186; data.height = 55;
> > > pButton1.setLayoutData(data);
> > >
> > > The listeners all work so the widgets are there, but nothing gets
drawn.
> I
> > > am at my wits end! I've spent the last 3 days (I'm out of work)trying
> > > different ways to fix this but I end up with the same results. Oh,
I've
> > > tried the other form managers as well with the same results.
> > >
> > > Please... I apologize for the size of this but wanted to save the
"post
> > the
> > > code!" msgs going back and forth. If anybody has any idea what I'm
doing
> > > wrong could you please let me know? I would be very grateful. I am
> hoping
> > > that the end product of this project will be a fully skinnable widget
> set.
> > >
> > > Cheers... Vic Hanson
> > >
> > >
> >
> >
>
>
Re: FormLayout & spacing [message #437788 is a reply to message #437547] Thu, 10 June 2004 14:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fayth.ut-mapdepot.com

Hi Steve,
Ok I recreated the project. You will easily see that the two buttons
belong side by side. I'm using Eclipse 3.0 M9. Let me know if there is
anything else you need from me.

Fayth

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:ca1tpd$sfm$1@eclipse.org...
> Fayth, we are in the middle of 3.0 hell so we don't get to the news groups
> as much as we would like. Sorry, but please "post the code" (a complete
> stand alone example) and I will look at it. Posting fragments is almost
> useless. Thanks and hang in there, we are generally pretty responsive.
>
> "Fayth" <fayth@ut-mapdepot.com> wrote in message
> news:c9vpf6$kk5$1@eclipse.org...
> > Ok, well I guess I failed to generate any interest for this topic. I'm
> going
> > to consider this a bug in SWT, no matter what I tried in the layout
> managers
> > it would not allow me to have zero spacing between layed out widgets. My
> > widget size maintained the correct size right on up to the shell.pack()
> > function, which would add a 3 pixel border around the entire widget.
> >
> > I was able to overcome this serious deficiency by not using the layout
> > managers at all.
> >
> > Cheers, Fayth
> >
> > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > news:c9p4t9$aq1$1@eclipse.org...
> > > Hi, I've exhausted just about everything I can try so it's time to
refer
> > to
> > > the community.
> > >
> > > I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create a
> new
> > > "skinned" button as I absolutely could not get button to not display
> it's
> > > edges when mouse enters the button area or presses on the button. I
use
> a
> > > CLabel widget to hold my new button image. I add some listeners to
trap
> > > mouse enter and a mouse left click and change the image to reflect a
> > button
> > > state. I subclassed Layout to handle the layout of each button I
> created.
> > It
> > > also enabled me to use FormLayout manager to arrange my GUI. This is
> where
> > I
> > > run into problems.
> > >
> > > No matter how hard I try to get rid of it, I get a 3pixel border
around
> > each
> > > widget that is placed in a composite. I absolutely need the buttons
side
> > by
> > > side so the graphics line up.
> > >
> > > public class PButton extends Composite {
> > > Image image;
> > > CLabel iLabel;
> > > Vector pButtonPressListeners = new Vector();
> > > Vector pButtonTrackListeners = new Vector();
> > >
> > > public PButton(Composite parent, int style, Point pBSize) {
> > > super(parent, style);
> > > iLabel = new CLabel(this, 0);
> > > setSize(pBSize); // <<<<<<======== I tried cheating here!
> > >
> > > addDisposeListener(new DisposeListener() { ... });
> > > iLabel.addMouseListener(new MouseAdapter() { ... });
> > > iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
> > >
> > > setLayout(new PButtonLayout(pBSize));
> > > }
> > >
> > > public class PButtonLayout extends Layout {
> > > Point iExtent; //the cached size
> > >
> > > public PButtonLayout(Point iExtent) {
> > > this.iExtent = iExtent; // <<<<===== I tried cheating here! Doesn't
> > > affect the results whatsoever.
> > > }
> > >
> > > protected Point computeSize(Composite composite, int wHint, int
hHint,
> > > boolean changed) {
> > > Control [] children = composite.getChildren();
> > > if (changed || iExtent == null) {
> > > iExtent = children[0].computeSize(wHint, hHint, false);
> > > }
> > > return new Point(iExtent.x, iExtent.y);
> > > }
> > >
> > > protected void layout(Composite composite, boolean changed) {
> > > Control [] children = composite.getChildren();
> > > if (changed || iExtent == null) {
> > > iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> > > }
> > > children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> > > }
> > > }
> > >
> > > I get the bounds of the image to be used (all states are equal size
> > images)
> > > and pass that size to the creation of each PButton.
> > >
> > > PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> > > bounds.height));
> > >
> > > The parent is a composite that sets FormLayout margins to 0 and
spacing
> to
> > > 0. If I set the FormData() for my PButton like:
> > > FormData data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(0, 0);
> > > pButton1.setLayoutData(data);
> > >
> > > data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(pButton1);
> > > data.right = new FormAttachment(100, 0);
> > > pButton2.setLayoutData(data);
> > >
> > > I get a 3 pixel border around each widget that is actually added into
> the
> > > calculation of getSize(). Now if I hardcode the size:
> > > FormData data = new FormData();
> > > data.top = new FormAttachment(0, 0);
> > > data.left = new FormAttachment(0, 0);
> > > data.width = 186; data.height = 55;
> > > pButton1.setLayoutData(data);
> > >
> > > The listeners all work so the widgets are there, but nothing gets
drawn.
> I
> > > am at my wits end! I've spent the last 3 days (I'm out of work)trying
> > > different ways to fix this but I end up with the same results. Oh,
I've
> > > tried the other form managers as well with the same results.
> > >
> > > Please... I apologize for the size of this but wanted to save the
"post
> > the
> > > code!" msgs going back and forth. If anybody has any idea what I'm
doing
> > > wrong could you please let me know? I would be very grateful. I am
> hoping
> > > that the end product of this project will be a fully skinnable widget
> set.
> > >
> > > Cheers... Vic Hanson
> > >
> > >
> >
> >
>
>


  • Attachment: widgets.zip
    (Size: 44.57KB, Downloaded 71 times)
Re: FormLayout & spacing [message #437870 is a reply to message #437788] Fri, 11 June 2004 16:27 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I hacked your code to use a Label instead of a CLabel and it works fine.
CLabel aways insets by 3 pixels. There is no API to stop it ...

"Fayth" <fayth@ut-mapdepot.com> wrote in message
news:ca9q8c$bs8$1@eclipse.org...
> Hi Steve,
> Ok I recreated the project. You will easily see that the two buttons
> belong side by side. I'm using Eclipse 3.0 M9. Let me know if there is
> anything else you need from me.
>
> Fayth
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:ca1tpd$sfm$1@eclipse.org...
> > Fayth, we are in the middle of 3.0 hell so we don't get to the news
groups
> > as much as we would like. Sorry, but please "post the code" (a complete
> > stand alone example) and I will look at it. Posting fragments is almost
> > useless. Thanks and hang in there, we are generally pretty responsive.
> >
> > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > news:c9vpf6$kk5$1@eclipse.org...
> > > Ok, well I guess I failed to generate any interest for this topic. I'm
> > going
> > > to consider this a bug in SWT, no matter what I tried in the layout
> > managers
> > > it would not allow me to have zero spacing between layed out widgets.
My
> > > widget size maintained the correct size right on up to the
shell.pack()
> > > function, which would add a 3 pixel border around the entire widget.
> > >
> > > I was able to overcome this serious deficiency by not using the layout
> > > managers at all.
> > >
> > > Cheers, Fayth
> > >
> > > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > > news:c9p4t9$aq1$1@eclipse.org...
> > > > Hi, I've exhausted just about everything I can try so it's time to
> refer
> > > to
> > > > the community.
> > > >
> > > > I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to create
a
> > new
> > > > "skinned" button as I absolutely could not get button to not display
> > it's
> > > > edges when mouse enters the button area or presses on the button. I
> use
> > a
> > > > CLabel widget to hold my new button image. I add some listeners to
> trap
> > > > mouse enter and a mouse left click and change the image to reflect a
> > > button
> > > > state. I subclassed Layout to handle the layout of each button I
> > created.
> > > It
> > > > also enabled me to use FormLayout manager to arrange my GUI. This is
> > where
> > > I
> > > > run into problems.
> > > >
> > > > No matter how hard I try to get rid of it, I get a 3pixel border
> around
> > > each
> > > > widget that is placed in a composite. I absolutely need the buttons
> side
> > > by
> > > > side so the graphics line up.
> > > >
> > > > public class PButton extends Composite {
> > > > Image image;
> > > > CLabel iLabel;
> > > > Vector pButtonPressListeners = new Vector();
> > > > Vector pButtonTrackListeners = new Vector();
> > > >
> > > > public PButton(Composite parent, int style, Point pBSize) {
> > > > super(parent, style);
> > > > iLabel = new CLabel(this, 0);
> > > > setSize(pBSize); // <<<<<<======== I tried cheating here!
> > > >
> > > > addDisposeListener(new DisposeListener() { ... });
> > > > iLabel.addMouseListener(new MouseAdapter() { ... });
> > > > iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
> > > >
> > > > setLayout(new PButtonLayout(pBSize));
> > > > }
> > > >
> > > > public class PButtonLayout extends Layout {
> > > > Point iExtent; //the cached size
> > > >
> > > > public PButtonLayout(Point iExtent) {
> > > > this.iExtent = iExtent; // <<<<===== I tried cheating here!
Doesn't
> > > > affect the results whatsoever.
> > > > }
> > > >
> > > > protected Point computeSize(Composite composite, int wHint, int
> hHint,
> > > > boolean changed) {
> > > > Control [] children = composite.getChildren();
> > > > if (changed || iExtent == null) {
> > > > iExtent = children[0].computeSize(wHint, hHint, false);
> > > > }
> > > > return new Point(iExtent.x, iExtent.y);
> > > > }
> > > >
> > > > protected void layout(Composite composite, boolean changed) {
> > > > Control [] children = composite.getChildren();
> > > > if (changed || iExtent == null) {
> > > > iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> > > > }
> > > > children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> > > > }
> > > > }
> > > >
> > > > I get the bounds of the image to be used (all states are equal size
> > > images)
> > > > and pass that size to the creation of each PButton.
> > > >
> > > > PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> > > > bounds.height));
> > > >
> > > > The parent is a composite that sets FormLayout margins to 0 and
> spacing
> > to
> > > > 0. If I set the FormData() for my PButton like:
> > > > FormData data = new FormData();
> > > > data.top = new FormAttachment(0, 0);
> > > > data.left = new FormAttachment(0, 0);
> > > > pButton1.setLayoutData(data);
> > > >
> > > > data = new FormData();
> > > > data.top = new FormAttachment(0, 0);
> > > > data.left = new FormAttachment(pButton1);
> > > > data.right = new FormAttachment(100, 0);
> > > > pButton2.setLayoutData(data);
> > > >
> > > > I get a 3 pixel border around each widget that is actually added
into
> > the
> > > > calculation of getSize(). Now if I hardcode the size:
> > > > FormData data = new FormData();
> > > > data.top = new FormAttachment(0, 0);
> > > > data.left = new FormAttachment(0, 0);
> > > > data.width = 186; data.height = 55;
> > > > pButton1.setLayoutData(data);
> > > >
> > > > The listeners all work so the widgets are there, but nothing gets
> drawn.
> > I
> > > > am at my wits end! I've spent the last 3 days (I'm out of
work)trying
> > > > different ways to fix this but I end up with the same results. Oh,
> I've
> > > > tried the other form managers as well with the same results.
> > > >
> > > > Please... I apologize for the size of this but wanted to save the
> "post
> > > the
> > > > code!" msgs going back and forth. If anybody has any idea what I'm
> doing
> > > > wrong could you please let me know? I would be very grateful. I am
> > hoping
> > > > that the end product of this project will be a fully skinnable
widget
> > set.
> > > >
> > > > Cheers... Vic Hanson
> > > >
> > > >
> > >
> > >
> >
> >
>
>
>
Re: FormLayout & spacing [message #437939 is a reply to message #437870] Mon, 14 June 2004 00:02 Go to previous message
Eclipse UserFriend
Originally posted by: fayth.ut-mapdepot.com

Right on, Steve! So I'm NOT crazy then! ROFL. Thank you very much for the
assistance. Would that be considered a bug? Or is that intended for a
reason? Somehow I always seem to walk that fine line and fall into the
cracks. It was fun figuring out an alternative, though, so it had its uses
for sure. Thanks again, man. Good luck climbing out of 3.0 hell!

Regards,
Fayth (Vic Hanson)

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:cacm1d$h98$1@eclipse.org...
> I hacked your code to use a Label instead of a CLabel and it works fine.
> CLabel aways insets by 3 pixels. There is no API to stop it ...
>
> "Fayth" <fayth@ut-mapdepot.com> wrote in message
> news:ca9q8c$bs8$1@eclipse.org...
> > Hi Steve,
> > Ok I recreated the project. You will easily see that the two buttons
> > belong side by side. I'm using Eclipse 3.0 M9. Let me know if there is
> > anything else you need from me.
> >
> > Fayth
> >
> > "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> > news:ca1tpd$sfm$1@eclipse.org...
> > > Fayth, we are in the middle of 3.0 hell so we don't get to the news
> groups
> > > as much as we would like. Sorry, but please "post the code" (a
complete
> > > stand alone example) and I will look at it. Posting fragments is
almost
> > > useless. Thanks and hang in there, we are generally pretty
responsive.
> > >
> > > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > > news:c9vpf6$kk5$1@eclipse.org...
> > > > Ok, well I guess I failed to generate any interest for this topic.
I'm
> > > going
> > > > to consider this a bug in SWT, no matter what I tried in the layout
> > > managers
> > > > it would not allow me to have zero spacing between layed out
widgets.
> My
> > > > widget size maintained the correct size right on up to the
> shell.pack()
> > > > function, which would add a 3 pixel border around the entire widget.
> > > >
> > > > I was able to overcome this serious deficiency by not using the
layout
> > > > managers at all.
> > > >
> > > > Cheers, Fayth
> > > >
> > > > "Fayth" <fayth@ut-mapdepot.com> wrote in message
> > > > news:c9p4t9$aq1$1@eclipse.org...
> > > > > Hi, I've exhausted just about everything I can try so it's time to
> > refer
> > > > to
> > > > > the community.
> > > > >
> > > > > I'm using Eclipse 3.0M9. Using SWT, I subclassed Composite to
create
> a
> > > new
> > > > > "skinned" button as I absolutely could not get button to not
display
> > > it's
> > > > > edges when mouse enters the button area or presses on the button.
I
> > use
> > > a
> > > > > CLabel widget to hold my new button image. I add some listeners to
> > trap
> > > > > mouse enter and a mouse left click and change the image to reflect
a
> > > > button
> > > > > state. I subclassed Layout to handle the layout of each button I
> > > created.
> > > > It
> > > > > also enabled me to use FormLayout manager to arrange my GUI. This
is
> > > where
> > > > I
> > > > > run into problems.
> > > > >
> > > > > No matter how hard I try to get rid of it, I get a 3pixel border
> > around
> > > > each
> > > > > widget that is placed in a composite. I absolutely need the
buttons
> > side
> > > > by
> > > > > side so the graphics line up.
> > > > >
> > > > > public class PButton extends Composite {
> > > > > Image image;
> > > > > CLabel iLabel;
> > > > > Vector pButtonPressListeners = new Vector();
> > > > > Vector pButtonTrackListeners = new Vector();
> > > > >
> > > > > public PButton(Composite parent, int style, Point pBSize) {
> > > > > super(parent, style);
> > > > > iLabel = new CLabel(this, 0);
> > > > > setSize(pBSize); // <<<<<<======== I tried cheating here!
> > > > >
> > > > > addDisposeListener(new DisposeListener() { ... });
> > > > > iLabel.addMouseListener(new MouseAdapter() { ... });
> > > > > iLabel.addMouseTrackListener(new MouseTrackAdapter() { ... });
> > > > >
> > > > > setLayout(new PButtonLayout(pBSize));
> > > > > }
> > > > >
> > > > > public class PButtonLayout extends Layout {
> > > > > Point iExtent; //the cached size
> > > > >
> > > > > public PButtonLayout(Point iExtent) {
> > > > > this.iExtent = iExtent; // <<<<===== I tried cheating here!
> Doesn't
> > > > > affect the results whatsoever.
> > > > > }
> > > > >
> > > > > protected Point computeSize(Composite composite, int wHint, int
> > hHint,
> > > > > boolean changed) {
> > > > > Control [] children = composite.getChildren();
> > > > > if (changed || iExtent == null) {
> > > > > iExtent = children[0].computeSize(wHint, hHint, false);
> > > > > }
> > > > > return new Point(iExtent.x, iExtent.y);
> > > > > }
> > > > >
> > > > > protected void layout(Composite composite, boolean changed) {
> > > > > Control [] children = composite.getChildren();
> > > > > if (changed || iExtent == null) {
> > > > > iExtent = children[0].computeSize(iExtent.x, iExtent.y, false);
> > > > > }
> > > > > children[0].setBounds(0, 0, iExtent.x, iExtent.y);
> > > > > }
> > > > > }
> > > > >
> > > > > I get the bounds of the image to be used (all states are equal
size
> > > > images)
> > > > > and pass that size to the creation of each PButton.
> > > > >
> > > > > PButton pButton1 = new PButton(parent, 0, new Point(bounds.width,
> > > > > bounds.height));
> > > > >
> > > > > The parent is a composite that sets FormLayout margins to 0 and
> > spacing
> > > to
> > > > > 0. If I set the FormData() for my PButton like:
> > > > > FormData data = new FormData();
> > > > > data.top = new FormAttachment(0, 0);
> > > > > data.left = new FormAttachment(0, 0);
> > > > > pButton1.setLayoutData(data);
> > > > >
> > > > > data = new FormData();
> > > > > data.top = new FormAttachment(0, 0);
> > > > > data.left = new FormAttachment(pButton1);
> > > > > data.right = new FormAttachment(100, 0);
> > > > > pButton2.setLayoutData(data);
> > > > >
> > > > > I get a 3 pixel border around each widget that is actually added
> into
> > > the
> > > > > calculation of getSize(). Now if I hardcode the size:
> > > > > FormData data = new FormData();
> > > > > data.top = new FormAttachment(0, 0);
> > > > > data.left = new FormAttachment(0, 0);
> > > > > data.width = 186; data.height = 55;
> > > > > pButton1.setLayoutData(data);
> > > > >
> > > > > The listeners all work so the widgets are there, but nothing gets
> > drawn.
> > > I
> > > > > am at my wits end! I've spent the last 3 days (I'm out of
> work)trying
> > > > > different ways to fix this but I end up with the same results. Oh,
> > I've
> > > > > tried the other form managers as well with the same results.
> > > > >
> > > > > Please... I apologize for the size of this but wanted to save the
> > "post
> > > > the
> > > > > code!" msgs going back and forth. If anybody has any idea what I'm
> > doing
> > > > > wrong could you please let me know? I would be very grateful. I am
> > > hoping
> > > > > that the end product of this project will be a fully skinnable
> widget
> > > set.
> > > > >
> > > > > Cheers... Vic Hanson
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>
Previous Topic:Install Problem.Won't Run.MissingResourceException
Next Topic:Text color in a toolitem
Goto Forum:
  


Current Time: Thu Mar 28 12:52:54 GMT 2024

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

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

Back to the top