net.xoetrope.swt
Class XStyle

java.lang.Object
  extended by net.xoetrope.swt.XStyle
All Implemented Interfaces:
java.lang.Cloneable

public class XStyle
extends java.lang.Object
implements java.lang.Cloneable

A style for storing information about the look of a component. Information such as font (face, size, bold, italic), color (fore, back).

Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt $Revision: 2.5 $


Field Summary
static int COLOR_BACK
          The component back color style
static int COLOR_FORE
          The component fore color style
static int FONT_FACE
          The font face/family style
static int FONT_ITALIC
          The font italic style
static int FONT_SIZE
          The font size style
static int FONT_WEIGHT
          The font weight (bold) style
 
Constructor Summary
XStyle()
          Create a new style object
 
Method Summary
 java.lang.Object clone()
          Create a copy of this component
 int getNumStyles()
          Get the number of styles managed by this style object
 org.eclipse.swt.graphics.Color getStyleAsColor(int key)
          Retrieve a style element as a Color.
 int getStyleAsInt(int key)
          Retrieve a style element as an int.
 java.lang.String getStyleAsString(int key)
          Retrieve a style element as a String.
 void mergeStyle(XStyle newStyle)
          For applying a hierarchy of styles to a new XStyle.
 void setNumStyles(int num)
          Set the number of styles.
 void setStyle(int key, int value)
          Set a style element.
 void setStyle(int key, java.lang.Object value)
          Set a style element.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FONT_FACE

public static final int FONT_FACE
The font face/family style

See Also:
Constant Field Values

FONT_SIZE

public static final int FONT_SIZE
The font size style

See Also:
Constant Field Values

FONT_WEIGHT

public static final int FONT_WEIGHT
The font weight (bold) style

See Also:
Constant Field Values

FONT_ITALIC

public static final int FONT_ITALIC
The font italic style

See Also:
Constant Field Values

COLOR_BACK

public static final int COLOR_BACK
The component back color style

See Also:
Constant Field Values

COLOR_FORE

public static final int COLOR_FORE
The component fore color style

See Also:
Constant Field Values
Constructor Detail

XStyle

public XStyle()
Create a new style object

Method Detail

setNumStyles

public void setNumStyles(int num)
Set the number of styles. The current data is copied to the new style array. The number of styles can only be increased with this method so as to prevent any loss of data.

Parameters:
num - the number of new parameters

getNumStyles

public int getNumStyles()
Get the number of styles managed by this style object

Returns:
The number of styles being managed

clone

public java.lang.Object clone()
Create a copy of this component

Overrides:
clone in class java.lang.Object
Returns:
the copy

setStyle

public void setStyle(int key,
                     java.lang.Object value)
Set a style element.

Parameters:
key - The index of the element
value - The Object value of the element

setStyle

public void setStyle(int key,
                     int value)
Set a style element.

Parameters:
key - The index of the element
value - The int value of the element

getStyleAsInt

public int getStyleAsInt(int key)
Retrieve a style element as an int.

Parameters:
key - The index of the style required
Returns:
The style converted to an int

getStyleAsString

public java.lang.String getStyleAsString(int key)
Retrieve a style element as a String.

Parameters:
key - The index of the style required
Returns:
The style converted to a String

getStyleAsColor

public org.eclipse.swt.graphics.Color getStyleAsColor(int key)
Retrieve a style element as a Color.

Parameters:
key - The index of the style required
Returns:
The style converted to a Color

mergeStyle

public void mergeStyle(XStyle newStyle)
For applying a hierarchy of styles to a new XStyle. Only apply the style if it's found.

Parameters:
newStyle - the style to merge with the current object.