public class CascadingStylesheet extends Object implements Stylesheet
This stylesheet contains:
The style of a widget is determined following these steps:
getSelectorStyle(Selector)
),Widget.getParent()
),getDefaultStyle()
).Style
).
The result style is complete at the end of the resolution.
The implementation assumes that the style of the parent is resolved prior to the resolution of its children. It
simplifies the cascading resolution because it avoids recursive resolution upward. In other words, that means that
the resolution of the styles in a hierarchy must be done from top to bottom. That is the case for the widgets since
Widget.updateStyle()
is recursive (see Container.updateStyle()
).
Constructor and Description |
---|
CascadingStylesheet()
Creates a new cascading stylesheet.
|
Modifier and Type | Method and Description |
---|---|
EditableStyle |
getDefaultStyle()
Gets the default style.
|
EditableStyle |
getSelectorStyle(Selector selector)
Gets the style for a selector.
|
Style |
getStyle(Widget widget)
Gets the style for a widget.
|
void |
reset()
Resets the stylesheet to its initial state.
|
void |
resetDefaultStyle()
Resets the default style attributes to their initial value.
|
void |
resetSelectorStyle(Selector selector)
Resets the style attributes for a selector.
|
public CascadingStylesheet()
public EditableStyle getDefaultStyle()
This style is used as the root style of the cascading resolution. Its initial attributes are equal to the values
defined in DefaultStyle
.
public EditableStyle getSelectorStyle(Selector selector)
This style is applied to the widgets matching the selector.
selector
- the selector.public Style getStyle(Widget widget)
Stylesheet
getStyle
in interface Stylesheet
widget
- the widget to get the style for.public void reset()
public void resetDefaultStyle()
public void resetSelectorStyle(Selector selector)
selector
- the selector.