Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Styling MPartStack tab-height with relative height
Styling MPartStack tab-height with relative height [message #1727602] Thu, 24 March 2016 07:04 Go to next message
Eclipse UserFriend
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 #1727622 is a reply to message #1727602] Thu, 24 March 2016 09:47 Go to previous messageGo to next message
Eclipse UserFriend
Have you tried to use em instead of px? Haven't tried it myself yet, but in CSS this should do the trick IIRC.
Re: Styling MPartStack tab-height with relative height [message #1727659 is a reply to message #1727622] Thu, 24 March 2016 16:45 Go to previous messageGo to next message
Eclipse UserFriend
I just tried "25em" instead. That has no styling effect whatsoever.
Re: Styling MPartStack tab-height with relative height [message #1727802 is a reply to message #1727659] Sun, 27 March 2016 14:29 Go to previous message
Eclipse UserFriend
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).
Previous Topic:E4 Preferences Dialog
Next Topic:Hello World
Goto Forum:
  


Current Time: Wed Jul 23 14:40:46 EDT 2025

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

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

Back to the top