Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 11:04 Go to next message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 123
Registered: July 2009
Senior Member
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 13:47 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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 20:45 Go to previous messageGo to next message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 123
Registered: July 2009
Senior Member
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 18:29 Go to previous message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 123
Registered: July 2009
Senior Member
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: Thu Apr 25 12:11:25 GMT 2024

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

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

Back to the top