Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:08 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
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


---
Just because you can doesn't mean you should
Re: SWT.INHERIT_DEFAULT override individual control [message #1153424 is a reply to message #1153294] Thu, 24 October 2013 15:54 Go to previous messageGo to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
perhaps my imagination, but perhaps Composites do not honour RWT.CUSTOM_VARIANT at all?


---
Just because you can doesn't mean you should
Re: SWT.INHERIT_DEFAULT override individual control [message #1153470 is a reply to message #1153424] Thu, 24 October 2013 16:34 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
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 14:39 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
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


---
Just because you can doesn't mean you should
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: Fri Apr 26 06:28:00 GMT 2024

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

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

Back to the top