SWT.INHERIT_DEFAULT override individual control [message #1153294] |
Thu, 24 October 2013 14:08 |
|
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 #1154895 is a reply to message #1153470] |
Fri, 25 October 2013 14:39 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03282 seconds