|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jmex.bui.BStyleSheet
public class BStyleSheet
Defines a stylesheet which is used to configure the style (font family, font size, foreground and background color, etc.) of components in the BUI library. The BUI stylesheets syntax is a subset of the Cascading Style Sheet sytnax and follows its semantic conventions as well where possible.
A basic stylesheet enumerating most usable values is as follows:
style_class {
// foreground and background properties
color: 0 0 0;
background: solid #00000088; // note the 50% alpha
background: image monkey.png XX; // XX = centerx|centery|centerxy|
// scalex|scaley|scalexy|
// tilex|tiley|tilexy|
// framex|framey|framexy
background: image monkey.png framexy top right bottom left;
cursor: name;
// text properties
font: Helvetica XX 12; // XX = normal|bold|italic|bolditalic
text-align: XX; // XX = left|center|right
vertical-align: XX; // XX = top|center|bottom
text-effect: XX; // XX = none|outline|shadow|glow
line-spacing: -2; // XX = amount of space to add/remove between lines
// box properties
padding: top; // right=top, bottom=top, left=top
padding: top, right; // bottom=top, left=right
padding: top, right, bottom, left;
border: 1 solid #FFCC99;
border: 1 blank;
size: 250 100; // overrrides component preferred size
// explicit inheritance
parent: other_class; // other_class must be defined *before* this one
tooltip: other_class; // used to define the style class for the tool_tip
}
Each component is identified by its default stylesheet class, which are derived from the
component's Java class name: window, label, textfield, component, popupmenu, etc.
The component's stylesheet class can be overridden with a call to BComponent.setStyleClass(java.lang.String).
A component's style is resolved in the following manner:
color, font, text-align, vertical-align.
root stylesheet class is checked (for all properties, not just
those for which we climb the interface hierarchy).
This resolution process is followed at the time the component is added to the interface hierarchy and the result is used to configure the component. We tradeoff the relative expense of doing the lookup every time the component is rendered (every frame) with the memory expense of storing the style of every component in memory.
| Nested Class Summary | |
|---|---|
protected static class |
BStyleSheet.BackgroundProperty
|
protected static class |
BStyleSheet.CursorProperty
|
static class |
BStyleSheet.DefaultResourceProvider
A default implementation of the stylesheet resource provider. |
protected static class |
BStyleSheet.FontProperty
|
protected static class |
BStyleSheet.IconProperty
|
protected static class |
BStyleSheet.Property
|
static interface |
BStyleSheet.ResourceProvider
An interface used by the stylesheet to obtain font and image resources. |
protected static class |
BStyleSheet.Rule
|
| Field Summary | |
|---|---|
protected static HashMap<String,Integer> |
_ibconsts
|
protected BStyleSheet.ResourceProvider |
_rsrcprov
|
protected HashMap<String,BStyleSheet.Rule> |
_rules
|
protected static HashMap<String,Integer> |
_taconsts
|
protected static HashMap<String,Integer> |
_teconsts
|
protected static HashMap<String,Integer> |
_vaconsts
|
static String |
BOLD
A font style constant. |
static String |
BOLD_ITALIC
A font style constant. |
static String |
ITALIC
A font style constant. |
static String |
PLAIN
A font style constant. |
| Constructor Summary | |
|---|---|
BStyleSheet(Reader reader,
BStyleSheet.ResourceProvider rsrcprov)
Creates a stylesheet from the specified textual source. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PLAIN
public static final String BOLD
public static final String ITALIC
public static final String BOLD_ITALIC
protected BStyleSheet.ResourceProvider _rsrcprov
protected HashMap<String,BStyleSheet.Rule> _rules
protected static HashMap<String,Integer> _taconsts
protected static HashMap<String,Integer> _vaconsts
protected static HashMap<String,Integer> _teconsts
protected static HashMap<String,Integer> _ibconsts
| Constructor Detail |
|---|
public BStyleSheet(Reader reader,
BStyleSheet.ResourceProvider rsrcprov)
throws IOException
IOException| Method Detail |
|---|
public static void main(String[] args)
public ColorRGBA getColor(BComponent component,
String pseudoClass)
public BBackground getBackground(BComponent component,
String pseudoClass)
public BIcon getIcon(BComponent component,
String pseudoClass)
public BCursor getCursor(BComponent component,
String pseudoClass)
public BTextFactory getTextFactory(BComponent component,
String pseudoClass)
public int getTextAlignment(BComponent component,
String pseudoClass)
public int getVerticalAlignment(BComponent component,
String pseudoClass)
public int getTextEffect(BComponent component,
String pseudoClass)
public int getLineSpacing(BComponent component,
String pseudoClass)
public int getEffectSize(BComponent component,
String pseudoClass)
public ColorRGBA getEffectColor(BComponent component,
String pseudoClass)
public Insets getInsets(BComponent component,
String pseudoClass)
public BBorder getBorder(BComponent component,
String pseudoClass)
public Dimension getSize(BComponent component,
String pseudoClass)
public String getTooltipStyle(BComponent component,
String pseudoClass)
public BKeyMap getKeyMap(BComponent component,
String pseudoClass)
protected Object findProperty(BComponent component,
String pseudoClass,
String property,
boolean climb)
protected Object getProperty(String fqClass,
String property)
protected void parse(StreamTokenizer tok)
throws IOException
IOException
protected BStyleSheet.Rule startRule(StreamTokenizer tok)
throws IOException
IOException
protected boolean parseProperty(StreamTokenizer tok,
BStyleSheet.Rule rule)
throws IOException
IOException
protected Object createProperty(String name,
ArrayList args)
protected void fail(StreamTokenizer tok,
String expected)
throws IOException
IOExceptionprotected ColorRGBA parseColor(String hex)
protected int parseInt(Object arg)
protected static String makeFQClass(String styleClass,
String pseudoClass)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||