Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.ui.forms
Class FormColors

    java.lang.Object
      org.eclipse.ui.forms.FormColors

public class FormColors
extends Object

Manages colors that will be applied to forms and form widgets. The colors are chosen to make the widgets look correct in the editor area. If a different set of colors is needed, subclass this class and override 'initialize' and/or 'initializeColors'.

Since:
  3.0

Field Summary
`protected Color` | `background`
`protected Color` | `border`
`static String` | `BORDER` Key for the tree/table border color.
`protected Map` | `colorRegistry`
`protected Display` | `display`
`protected Color` | `foreground`
`static String` | `SEPARATOR` Key for the section separator color.
`static String` | `TB_BG`
`static String` | `TB_BORDER`
`static String` | `TB_FG`
`static String` | `TB_GBG`
`static String` | `TB_TOGGLE`
`static String` | `TITLE` Key for the form title foreground color.

Constructor Summary
`FormColors(Display display)` Creates form colors using the provided display.

Method Summary
`Color` | `createColor(String key, int r, int g, int b)` Creates the color for the specified key using the provided RGB values.
`Color` | `createColor(String key, RGB rgb)` Creates the color for the specified key using the provided RGB object.
`void` | `dispose()` Disposes all the colors in the registry.
`Color` | `getBackground()` Returns the current background color.
`Color` | `getBorderColor()` Returns the computed border color.
`Color` | `getColor(String key)` Returns the color object for the provided key or `null` if not in the registry.
`Display` | `getDisplay()` Returns the display used to create colors.
`Color` | `getForeground()` Returns the current foreground color.
`RGB` | `getSystemColor(int code)`
`protected void` | `initialize()` Initializes the colors.
`protected void` | `initializeColorTable()` Allocates colors for the following keys: BORDER, COMPOSITE_SEPARATOR and DEFAULT_HEADER.
`void` | `initializeSectionToolBarColors()` Allocates colors for the section tool bar (all the keys that start with TB).
`boolean` | `isShared()` Tests if the colors are shared.
`boolean` | `isWhiteBackground()` Tests if the background is white.
`void` | `markShared()` Marks the colors shared.
`void` | `setBackground(Color bg)` Sets the background color.
`void` | `setForeground(Color fg)` Sets the foreground color.
`protected void` | `updateBorderColor()` Computes the border color relative to the background.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TITLE

    public static final String TITLE

  Key for the form title foreground color.

  See Also:
    Constant Field Values

### BORDER

    public static final String BORDER

  Key for the tree/table border color.

  See Also:
    Constant Field Values

### SEPARATOR

    public static final String SEPARATOR

  Key for the section separator color.

  See Also:
    Constant Field Values

### TB_BG

    public static final String TB_BG

See Also:
  Constant Field Values

### TB_FG

    public static final String TB_FG

See Also:
  Constant Field Values

### TB_GBG

    public static final String TB_GBG

See Also:
  Constant Field Values

### TB_BORDER

    public static final String TB_BORDER

See Also:
  Constant Field Values

### TB_TOGGLE

    public static final String TB_TOGGLE

See Also:
  Constant Field Values

### colorRegistry

    protected Map colorRegistry

### background

    protected Color background

### foreground

    protected Color foreground

### display

    protected Display display

### border

    protected Color border

Constructor Detail

### FormColors

    public FormColors(Display display)

  Creates form colors using the provided display.

Parameters:
  `display` - the display to use

Method Detail

### getDisplay

    public Display getDisplay()

  Returns the display used to create colors.

  Returns:
    the display

### initialize

    protected void initialize()

  Initializes the colors. Subclasses can override this method to change the way colors are created. Alternatively, only the color table can be modified by overriding `initializeColorTable()`.

  See Also:
    `initializeColorTable()`

### initializeColorTable

    protected void initializeColorTable()

  Allocates colors for the following keys: BORDER, COMPOSITE_SEPARATOR and DEFAULT_HEADER. Subclasses can override to allocate this colors differently.

### initializeSectionToolBarColors

    public void initializeSectionToolBarColors()

  Allocates colors for the section tool bar (all the keys that start with TB). Since these colors are only needed when TITLE_BAR style is used with the Section widget, they are not needed all the time and are allocated on demand. Consequently, this method will do nothing if the colors have been already initialized. Call this method prior to using colors with the TB keys to ensure they are available.

### getSystemColor

    public RGB getSystemColor(int code)

### createColor

    public Color createColor(String key,
                             RGB rgb)

  Creates the color for the specified key using the provided RGB object. The color object will be returned and also put into the registry. When the class is disposed, the color will be disposed with it.

  Parameters:
    `key` - the unique color key
    `rgb` - the RGB object
  Returns:
    the allocated color object

### createColor

    public Color createColor(String key,
                             int r,
                             int g,
                             int b)

  Creates the color for the specified key using the provided RGB values. The color object will be returned and also put into the registry. When the class is disposed, the color will be disposed with it.

  Parameters:
    `key` - the unique color key
    `r` - red value
    `g` - green value
    `b` - blue value
  Returns:
    the allocated color object

### updateBorderColor

    protected void updateBorderColor()

  Computes the border color relative to the background. Allocated border color is designed to work well with white. Otherwise, stanard widget background color will be used.

### setBackground

    public void setBackground(Color bg)

  Sets the background color. All the toolkits that use this class will share the same background.

  Parameters:
    `bg` - background color

### setForeground

    public void setForeground(Color fg)

  Sets the foreground color. All the toolkits that use this class will share the same foreground.

  Parameters:
    `fg` - foreground color

### getBackground

    public Color getBackground()

  Returns the current background color.

  Returns:
    the background color

### getForeground

    public Color getForeground()

  Returns the current foreground color.

  Returns:
    the foreground color

### getBorderColor

    public Color getBorderColor()

  Returns the computed border color. Border color depends on the background and is recomputed whenever the background changes.

  Returns:
    the current border color

### isWhiteBackground

    public boolean isWhiteBackground()

  Tests if the background is white. White background has RGB value 255,255,255.

  Returns:
    `true` if background is white, `false` otherwise.

### getColor

    public Color getColor(String key)

  Returns the color object for the provided key or `null` if not in the registry.

  Parameters:
    `key` - the color key
  Returns:
    color object if found, or `null` if not.

### dispose

    public void dispose()

  Disposes all the colors in the registry.

### markShared

    public void markShared()

  Marks the colors shared. This prevents toolkits that share this object from disposing it.

### isShared

    public boolean isShared()

  Tests if the colors are shared.

  Returns:
    `true` if shared, `false` otherwise.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.