Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » SWT.INHERIT_DEFAULT override individual control(In RAP, how to override individual control to use its CSS)
SWT.INHERIT_DEFAULT override individual control [message #1153294] Thu, 24 October 2013 10:08 Go to next message
Eclipse UserFriend
Slightly tricky to describe what I'm after, so I'll try to be clear with examples...

Let's say I have a Composite (this is RAP 2.2 by the way), which gets its background colour from the theme css. Let's call it topComp, and we set its background mode to DEFAULT:

topComp.setBackgroundMode(SWT.INHERIT_DEFAULT);


with css for Composites like this:

Composite {
  padding: 0;
  opacity: 1;
  background-image: gradient(
    linear, left top, left bottom,
    from( #ffeedd ),
    to( #aaccff )
  );
  border: none;
  box-shadow: none;
  animation: none;
}


So all controls placed within topComp inherit the background from it, except for some exceptions such as lists, tables, text etc.

Now, let's imagine I place another composite inside topComp, let's call it littleComp, and we place a Label inside littleComp. By default, littleComp and Label both inherit the topComp's background. Good so far, and as expected.

Now, I use setData() to define a CUSTOM_VARIANT for littleComp and also Label like this:

littleComp.setData(RWT.CUSTOM_VARIANT, "prettyPink");
label.setData(RWT.CUSTOM_VARIANT, "prettyPink");


I also define css in the RAP theme being used:

Label.prettyPink {
  color: #ffddff;
  background-color: #ff66dd;
}

Composite.prettyPink {
  color: #ffddff;
  background-color: #ff66bb;
}


These CSS custom variants do not get picked up at runtime - because of the INHERIT_DEFAULT specified at the higher topComp, these appear to get ignored. I have to use INHERIT_NONE to pick up prettyPink, which is no use for me.

If I try the same experiment with a Text control, the CSS theme override works ok...

text.setData(RWT.CUSTOM_VARIANT, "prettyPink");

...

Text[SINGLE].prettyPink {
  color: #ffddff;
  background-color: #ff55cc;
}


Why doesn't this technique work for the label or the littleComp?
Perhaps there is a way to explicitly tell RAP/RWT that a specific control should ignore the INHERIT_DEFAULT and just use the default css theme for that control type?

What would be nice, would be something like this:

littleComp.setData(RWT.DO_NOT_INHERIT);
label.setData(RWT.DO_NOT_INHERIT);


...in which case those controls would simply use the style from the css. Remember they have the RWT.CUSTOM_VARIANT="prettyPink" setData already, so perhaps they ought to be using their own css styling anyway?

Not sure if this is a bug or not, or working as designed.

Any pointers or observations greatfully accepted!

Best regards, John
Re: SWT.INHERIT_DEFAULT override individual control [message #1153424 is a reply to message #1153294] Thu, 24 October 2013 11:54 Go to previous messageGo to next message
Eclipse UserFriend
perhaps my imagination, but perhaps Composites do not honour RWT.CUSTOM_VARIANT at all?
Re: SWT.INHERIT_DEFAULT override individual control [message #1153470 is a reply to message #1153424] Thu, 24 October 2013 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi John,
Composites support RWT.CUSTOM_VARIANT as all other widgets in RAP. The
background color set by the theming can't override the color inheritance
enforced by background mode. Nevertheless, you could set the background
color by code:
---
topComp.setBackgroundMode(SWT.INHERIT_DEFAULT);
littleComp.setBackground( SWT.COLOR_RED );
---
HTH,
Ivan

On 10/24/2013 6:54 PM, John Gymer wrote:
> perhaps my imagination, but perhaps Composites do not honour
> RWT.CUSTOM_VARIANT at all?
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: SWT.INHERIT_DEFAULT override individual control [message #1154895 is a reply to message #1153470] Fri, 25 October 2013 10:39 Go to previous message
Eclipse UserFriend
Thanks Ivan.
I was hoping to avoid INHERIT_NONE, but seems I cannot. No problem - I will adjust the default CSS to make assumptions that the Composites always use INHERIT_NONE. Luckily the CSS is flexible enough that each widget type can use "background-colour: inherit" where it is important!
Cheers, John
Previous Topic:How to attach the context menu to a custom widget
Next Topic:What to do about Eclipse RAP compatibility with Remote System Explorer?
Goto Forum:
  


Current Time: Wed Jul 23 02:27:14 EDT 2025

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

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

Back to the top