public class FormColors
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.swt.graphics.Color |
background |
protected org.eclipse.swt.graphics.Color |
border |
static java.lang.String |
BORDER
Deprecated.
use
IFormColors.BORDER |
protected java.util.Map |
colorRegistry |
protected org.eclipse.swt.widgets.Display |
display |
protected org.eclipse.swt.graphics.Color |
foreground |
static java.lang.String |
SEPARATOR
Deprecated.
use
IFormColors.SEPARATOR . |
static java.lang.String |
TB_BG
Deprecated.
use
IFormColors.TB_BG |
static java.lang.String |
TB_BORDER
Deprecated.
use
IFormColors.TB_BORDER . |
static java.lang.String |
TB_FG
Deprecated.
use
IFormColors.TB_FG |
static java.lang.String |
TB_GBG
Deprecated.
use
IFormColors.TB_GBG |
static java.lang.String |
TB_TOGGLE
Deprecated.
use
IFormColors.TB_TOGGLE . |
static java.lang.String |
TB_TOGGLE_HOVER
Deprecated.
use
IFormColors.TB_TOGGLE_HOVER . |
static java.lang.String |
TITLE
Deprecated.
use
IFormColors.TITLE . |
Constructor and Description |
---|
FormColors(org.eclipse.swt.widgets.Display display)
Creates form colors using the provided display.
|
Modifier and Type | Method and Description |
---|---|
static org.eclipse.swt.graphics.RGB |
blend(org.eclipse.swt.graphics.RGB c1,
org.eclipse.swt.graphics.RGB c2,
int ratio)
Blends c1 and c2 based in the provided ratio.
|
org.eclipse.swt.graphics.Color |
createColor(java.lang.String key,
int r,
int g,
int b)
Creates the color for the specified key using the provided RGB values.
|
org.eclipse.swt.graphics.Color |
createColor(java.lang.String key,
org.eclipse.swt.graphics.RGB rgb)
Creates the color for the specified key using the provided RGB object.
|
void |
dispose()
Disposes all the colors in the registry.
|
org.eclipse.swt.graphics.Color |
getBackground()
Returns the current background color.
|
org.eclipse.swt.graphics.Color |
getBorderColor()
Returns the computed border color.
|
org.eclipse.swt.graphics.Color |
getColor(java.lang.String key)
Returns the color object for the provided key or null if
not in the registry.
|
org.eclipse.swt.widgets.Display |
getDisplay()
Returns the display used to create colors.
|
org.eclipse.swt.graphics.Color |
getForeground()
Returns the current foreground color.
|
org.eclipse.swt.graphics.Color |
getInactiveBackground()
Creates a color that can be used for areas of the form that is inactive.
|
org.eclipse.swt.graphics.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(org.eclipse.swt.graphics.Color bg)
Sets the background color.
|
void |
setForeground(org.eclipse.swt.graphics.Color fg)
Sets the foreground color.
|
static boolean |
testAnyPrimaryColor(org.eclipse.swt.graphics.RGB rgb,
int from,
int to)
Tests the source RGB for range.
|
static boolean |
testTwoPrimaryColors(org.eclipse.swt.graphics.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 java.lang.String TITLE
IFormColors.TITLE
.public static final java.lang.String BORDER
IFormColors.BORDER
public static final java.lang.String SEPARATOR
IFormColors.SEPARATOR
.public static final java.lang.String TB_BG
IFormColors.TB_BG
public static final java.lang.String TB_FG
IFormColors.TB_FG
public static final java.lang.String TB_GBG
IFormColors.TB_GBG
public static final java.lang.String TB_BORDER
IFormColors.TB_BORDER
.public static final java.lang.String TB_TOGGLE
IFormColors.TB_TOGGLE
.public static final java.lang.String TB_TOGGLE_HOVER
IFormColors.TB_TOGGLE_HOVER
.protected java.util.Map colorRegistry
protected org.eclipse.swt.graphics.Color background
protected org.eclipse.swt.graphics.Color foreground
protected org.eclipse.swt.widgets.Display display
protected org.eclipse.swt.graphics.Color border
public FormColors(org.eclipse.swt.widgets.Display display)
display
- the display to usepublic org.eclipse.swt.widgets.Display getDisplay()
protected void initialize()
initializeColorTable()
.initializeColorTable()
protected void initializeColorTable()
public void initializeSectionToolBarColors()
protected void initializeFormHeaderColors()
public org.eclipse.swt.graphics.RGB getSystemColor(int code)
SWT
class.code
- the system color constant as defined in SWT
class.public org.eclipse.swt.graphics.Color createColor(java.lang.String key, org.eclipse.swt.graphics.RGB rgb)
key
- the unique color keyrgb
- the RGB objectpublic org.eclipse.swt.graphics.Color getInactiveBackground()
The color should not be disposed because it is managed by this class.
public org.eclipse.swt.graphics.Color createColor(java.lang.String key, int r, int g, int b)
key
- the unique color keyr
- red valueg
- green valueb
- blue valueprotected void updateBorderColor()
public void setBackground(org.eclipse.swt.graphics.Color bg)
bg
- background colorpublic void setForeground(org.eclipse.swt.graphics.Color fg)
fg
- foreground colorpublic org.eclipse.swt.graphics.Color getBackground()
public org.eclipse.swt.graphics.Color getForeground()
public org.eclipse.swt.graphics.Color getBorderColor()
public boolean isWhiteBackground()
public org.eclipse.swt.graphics.Color getColor(java.lang.String key)
key
- the color keypublic void dispose()
public void markShared()
public boolean isShared()
true
if shared, false
otherwise.public static org.eclipse.swt.graphics.RGB blend(org.eclipse.swt.graphics.RGB c1, org.eclipse.swt.graphics.RGB c2, int ratio)
c1
- first colorc2
- second colorratio
- percentage of the first color in the blend (0-100)public static boolean testAnyPrimaryColor(org.eclipse.swt.graphics.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(org.eclipse.swt.graphics.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 © 2007–2020. All rights reserved.