Bartek Szczypien
Bartek Szczypien

Reputation: 343

Change the color of TabFolder in Eclipse RCP 3.x

I need to change the very bright (almost white) color visible on the attached image and the color of the font on those TabItems being a part of white TabFolder. I use CSS and also tried setBackground function called on Composite and TabFolder but without success. The best solution for me would be to change it via CSS if possible

enter image description here

Upvotes: 1

Views: 828

Answers (1)

greg-449
greg-449

Reputation: 111217

There is no specific code for TabFolder or TabItem in the Eclipse CSS support so they just get the CSS common to all controls such as background-color and color.

color does seem to change the color of the tab folder tab text, background-color does not change the tab background (it changes the background of the rest of the control).

The Eclipse CSS support works by calling normal SWT methods in the controls, since TabFolder does not have methods to set the tab background there is no way this can be done.

CTabFolder is much more flexible and allows new tab renderers to be used which can extend the CSS. Also note that on some platforms CTabFolder looks substantially different from TabFolder (macOS in particular).

You can use CSS classes and ids to restrict your CSS to just your folders. For example in your code use:

CSSUtil.setCSSClass(folder, "my-folder-class");

to set the CSS class of a folder and in the CSS use the class:

CTabFolder.my-folder-class
{
  swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
  swt-shadow-visible: false;
  swt-simple: false;
  swt-tab-height: 22px;
  swt-unselected-tabs-color:  black;
  swt-selected-tab-fill: black;
  swt-outer-keyline-color: black;
  swt-tab-outline: black;
  swt-shadow-color: black;
  swt-unselected-hot-tab-color-background: #2F2F2F;
  swt-selected-tabs-background: black black 100%;
  color: rgb(128, 128, 128);
}

This CSS also shows the use of the standard Eclipse custom tab folder renderer. This is just an example taken from a dark theme for one of my own RCPs.

Upvotes: 3

Related Questions