SWT is a good candidate for CSS styling since there is a strong correlation between SWT and HTML:
- SWT interfaces are hierarchical, with components nested within other components, just like HTML
- Components have classes which can be used as selectors, just like mark-up tags in HTML
- Based on ID and class, which can be defaults or specified programmatically
- Using compound selectors
- Child selectors (e.g., "all text widgets within a particular composite")
- Descendant selector
- Attributes (exact and partial value)
- Pseudo classes, such as dialogs or windows
A few utilities are available to help with the development of CSS for an application:
- CSS Spy, similar to Plug-in spy, can be used to test selectors, navigate all UI elements in a tree, see the effective CSS for a widget, and modify the styling of a widget on the fly
- CSS Scratch Pad is used for writing new CSS rules on the fly and seeing the result with a single click.
There is support for custom properties used in CSS, and extension points are available for further customisations. IDs can be set on widgets, then easily referred to within CSS without having to specify a complicated selector.
- Certain widgets do things differently, so different approaches to styling are necessary (e.g., background modes)
- Have to be careful when specifying selectors so that other parts of an application are not styled by accident
- No border style in CSS
- No variables or inheritance in CSS (though there are other utilities that can faciliate this)
- Label providers will need custom properties to be set for styling
- Only pixels right now
No comments:
Post a Comment