Styling MPartStack tab-height with relative height [message #1727602] |
Thu, 24 March 2016 07:04  |
Eclipse User |
|
|
|
I am styling the tab height of MPartStack via a custom CSS file in my e4 RCP application:
.MPartStack {
swt-tab-height: 25px;
}
However, this hard-coded 25px does not work an all platforms, in particular when the application is running in Windows 10 with a HiDPI screen. On HiDPI 25px is not enough, even smaller than the text. But then 25px works on OS X Retina.
Is there any why to set the height relative to the font height?
Or add padding above and/or below the text?
This SWT Mapping Wikipage seems to imply only fixed values are possible. So what are you doing then? Writing custom renderers?
|
|
|
|
|
Re: Styling MPartStack tab-height with relative height [message #1727802 is a reply to message #1727659] |
Sun, 27 March 2016 14:29  |
Eclipse User |
|
|
|
I now configured a custom renderer:
.MPartStack {
swt-tab-renderer: url('bundleclass://name.abuchen.portfolio.ui/name.abuchen.portfolio.ui.renderers.CTabRendering');
}
with a trivial implementation:
public class CTabRendering extends CTabFolderRenderer
{
public CTabRendering(CTabFolder parent)
{
super(parent);
}
@Override
protected Point computeSize(int part, int state, GC gc, int wHint, int hHint)
{
if (part != PART_HEADER)
return super.computeSize(part, state, gc, wHint, hHint);
int height = gc.textExtent("Default", SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC).y + 12; //$NON-NLS-1$
Rectangle trim = computeTrim(part, state, 0, 0, 0, height);
return new Point(trim.width, trim.height);
}
}
(Alternatively, one could / should iterate over the tabs and compute individual sizes. However, in my use case, I do not have icons and alternative fonts).
|
|
|
Powered by
FUDForum. Page generated in 0.03660 seconds