public class FormColors extends Object
Modifier and Type | Field and Description |
---|---|
protected Color |
background |
protected Color |
border |
static String |
BORDER
Deprecated.
use
IFormColors.BORDER |
protected Map |
colorRegistry |
protected Display |
display |
protected Color |
foreground |
static String |
SEPARATOR
Deprecated.
use
IFormColors.SEPARATOR . |
static String |
TB_BG
Deprecated.
use
IFormColors.TB_BG |
static String |
TB_BORDER
Deprecated.
use
IFormColors.TB_BORDER . |
static String |
TB_FG
Deprecated.
use
IFormColors.TB_FG |
static String |
TB_GBG
Deprecated.
use
IFormColors.TB_GBG |
static String |
TB_TOGGLE
Deprecated.
use
IFormColors.TB_TOGGLE . |
static String |
TB_TOGGLE_HOVER
Deprecated.
use
IFormColors.TB_TOGGLE_HOVER . |
static String |
TITLE
Deprecated.
use
IFormColors.TITLE . |
Constructor and Description |
---|
FormColors(Display display)
Creates form colors using the provided display.
|
Modifier and Type | Method and Description |
---|---|
static RGB |
blend(RGB c1,
RGB c2,
int ratio)
Blends c1 and c2 based in the provided ratio.
|
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.
|
Color |
getInactiveBackground()
Creates a color that can be used for areas of the form that is inactive.
|
RGB |
getSystemColor(int code)
Returns the RGB value of the system color represented by the code
argument, as defined in
SWT class. |
protected void |
initialize()
Initializes the colors.
|
protected void |
initializeColorTable()
Allocates colors for the following keys: BORDER, SEPARATOR and
TITLE.
|
protected void |
initializeFormHeaderColors()
Allocates additional colors for the form header, namely background
gradients, bottom separator keylines and DND highlights.
|
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.
|
static boolean |
testAnyPrimaryColor(RGB rgb,
int from,
int to)
Tests the source RGB for range.
|
static boolean |
testTwoPrimaryColors(RGB rgb,
int from,
int to)
Tests the source RGB for range.
|
protected void |
updateBorderColor()
Computes the border color relative to the background.
|
public static final String TITLE
IFormColors.TITLE
.public static final String BORDER
IFormColors.BORDER
public static final String SEPARATOR
IFormColors.SEPARATOR
.public static final String TB_BG
IFormColors.TB_BG
public static final String TB_FG
IFormColors.TB_FG
public static final String TB_GBG
IFormColors.TB_GBG
public static final String TB_BORDER
IFormColors.TB_BORDER
.public static final String TB_TOGGLE
IFormColors.TB_TOGGLE
.public static final String TB_TOGGLE_HOVER
IFormColors.TB_TOGGLE_HOVER
.protected Map colorRegistry
protected Color background
protected Color foreground
protected Display display
protected Color border
public FormColors(Display display)
display
- the display to usepublic Display getDisplay()
protected void initialize()
initializeColorTable()
.initializeColorTable()
protected void initializeColorTable()
public void initializeSectionToolBarColors()
protected void initializeFormHeaderColors()
public RGB getSystemColor(int code)
SWT
class.code
- the system color constant as defined in SWT
class.public Color createColor(String key, RGB rgb)
key
- the unique color keyrgb
- the RGB objectpublic Color getInactiveBackground()
The color should not be disposed because it is managed by this class.
public Color createColor(String key, int r, int g, int b)
key
- the unique color keyr
- red valueg
- green valueb
- blue valueprotected void updateBorderColor()
public void setBackground(Color bg)
bg
- background colorpublic void setForeground(Color fg)
fg
- foreground colorpublic Color getBackground()
public Color getForeground()
public Color getBorderColor()
public boolean isWhiteBackground()
public Color getColor(String key)
key
- the color keypublic void dispose()
public void markShared()
public boolean isShared()
true
if shared, false
otherwise.public static RGB blend(RGB c1, RGB c2, int ratio)
c1
- first colorc2
- second colorratio
- percentage of the first color in the blend (0-100)public static boolean testAnyPrimaryColor(RGB rgb, int from, int to)
rgb
- the tested RGBfrom
- range start (excluding the value itself)to
- range end (excluding the value itself)true
if at least one of the primary colors in the
source RGB are within the provided range, false
otherwise.public static boolean testTwoPrimaryColors(RGB rgb, int from, int to)
rgb
- the tested RGBfrom
- range start (excluding the value itself)to
- tange end (excluding the value itself)true
if at least two of the primary colors in the
source RGB are within the provided range, false
otherwise.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.