Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » CSS & Layouts
CSS & Layouts [message #1384799] Mon, 02 June 2014 07:14 Go to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 202
Registered: July 2009
Senior Member
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 09:50 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5721
Registered: July 2009
Senior Member
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 07:03 Go to previous message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 202
Registered: July 2009
Senior Member
Yes, thanks. That does work.
Peter
Previous Topic:how to share View in Multi Perspective
Next Topic:bug in PartRenderingEngine???
Goto Forum:
  


Current Time: Sat May 23 07:21:37 GMT 2015

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

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