Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » CSS & Layouts
CSS & Layouts [message #1384799] Mon, 02 June 2014 03:14 Go to next message
Eclipse UserFriend
How can I calculate some layout sizes based on the font size of the widgets, eg size columns in table widgets or the width and height of text widgets depending on the widgets fonts?

For example, consider this (old code):

Text text = new Text(parent, SWT.NONE);
text.setFont(textFont);
int averageCharWidth = textFont.getFontData()[0].getFontMetrics().getAverageCharWidth();
GridDataFactory.fillDefaults().hint(30 * averageCharWidth, SWT.DEFAULT).applyTo(text);


In e4, I will not set the font directly, it will be applied later by the css engine. How can I size the control?

Thanks,
Peter
Re: CSS & Layouts [message #1384816 is a reply to message #1384799] Mon, 02 June 2014 05:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I'm not 100% but could you try to register an SWT-Listener who listens
to SWT.Skin?

Tom

On 02.06.14 09:15, Peter Kullmann wrote:
> How can I calculate some layout sizes based on the font size of the
> widgets, eg size columns in table widgets or the width and height of
> text widgets depending on the widgets fonts?
> For example, consider this (old code):
>
> Text text = new Text(parent, SWT.NONE);
> text.setFont(textFont);
> int averageCharWidth =
> textFont.getFontData()[0].getFontMetrics().getAverageCharWidth();
> GridDataFactory.fillDefaults().hint(30 * averageCharWidth,
> SWT.DEFAULT).applyTo(text);
>
>
> In e4, I will not set the font directly, it will be applied later by the
> css engine. How can I size the control?
>
> Thanks, Peter
>
Re: CSS & Layouts [message #1384917 is a reply to message #1384816] Tue, 03 June 2014 03:03 Go to previous message
Eclipse UserFriend
Yes, thanks. That does work.
Peter
Previous Topic:how to share View in Multi Perspective
Next Topic:bug in PartRenderingEngine???
Goto Forum:
  


Current Time: Wed Jul 23 15:55:29 EDT 2025

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

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

Back to the top