Class: Wx::ColourDatabase
- Inherits:
-
Object
- Object
- Wx::ColourDatabase
- Defined in:
- lib/wx/doc/gen/gdi_common.rb
Overview
This class is untracked and should not be derived from nor instances extended!
wxWidgets maintains a database of standard RGB colours for a predefined set of named colours.
The application may add to this set if desired by using #add_colour and may use it to look up colours by names using #find or find the names for the standard colour using #find_name. It is also possible to switch between the colour values defined in the CSS standard (see www.w3.org/TR/css-color-4/#named-colors) and the traditional colour values which were used by wxWidgets versions earlier than 3.3.0, which may be useful to preserve the appearance of the existing code: if you need to do this, please call #use_scheme with Traditional argument, but the use of new, standard colours is recommended. There is one predefined, global instance of this class called TheColourDatabase. The standard database contains at least the following colours:
AQUAMARINE
BLACK
BLUE
BLUE VIOLET
BROWN
CADET BLUE
CORAL
CORNFLOWER BLUE
CYAN
DARK GREY
DARK GREEN
DARK OLIVE GREEN
DARK ORCHID
DARK SLATE BLUE
DARK SLATE GREY
DARK TURQUOISE
DIM GREY FIREBRICK
FOREST GREEN
GOLD
GOLDENROD
GREY
GREEN
GREEN YELLOW
INDIAN RED
KHAKI
LIGHT BLUE
LIGHT GREY
LIGHT STEEL BLUE
LIME GREEN
MAGENTA
MAROON
MEDIUM AQUAMARINE
MEDIUM BLUE MEDIUM FOREST GREEN
MEDIUM GOLDENROD
MEDIUM ORCHID
MEDIUM SEA GREEN
MEDIUM SLATE BLUE
MEDIUM SPRING GREEN
MEDIUM TURQUOISE
MEDIUM VIOLET RED
MIDNIGHT BLUE
NAVY
ORANGE
ORANGE RED
ORCHID
PALE GREEN
PINK
PLUM
PURPLE RED
SALMON
SEA GREEN
SIENNA
SKY BLUE
SLATE BLUE
SPRING GREEN
STEEL BLUE
TAN
THISTLE
TURQUOISE
VIOLET
VIOLET RED
WHEAT
WHITE
YELLOW
YELLOW GREEN
See the “Database colours” page of the Drawing Sample to see how all these colours look like.
Category: Graphics Device Interface (GDI)
Defined Under Namespace
Classes: Scheme
Instance Method Summary collapse
-
#add_colour(colourName, colour) ⇒ void
Adds a colour to the database.
-
#find(colourName) ⇒ Wx::Colour
Finds a colour given the name.
-
#find_name(colour) ⇒ String
Finds a colour name given the colour.
-
#get_all_names ⇒ Array<String>
(also: #all_names)
List all known colours by name.
-
#initialize ⇒ Wx::ColourDatabase
constructor
Constructs the colour database.
-
#use_scheme(scheme) ⇒ void
Select the colour scheme to use.
Constructor Details
#initialize ⇒ Wx::ColourDatabase
Constructs the colour database.
It will be initialized at the first use.
1203 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1203 def initialize; end |
Instance Method Details
#add_colour(colourName, colour) ⇒ void
This method returns an undefined value.
Adds a colour to the database.
If a colour with the same name already exists, it is replaced.
1211 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1211 def add_colour(colourName, colour) end |
#find(colourName) ⇒ Wx::Colour
Finds a colour given the name.
Returns an invalid colour object (that is, Wx::Colour#is_ok will return false) if the colour wasn’t found in the database.
1218 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1218 def find(colourName) end |
#find_name(colour) ⇒ String
Finds a colour name given the colour.
Returns an empty string if the colour is not found in the database.
1225 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1225 def find_name(colour) end |
#get_all_names ⇒ Array<String> Also known as: all_names
List all known colours by name.
1229 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1229 def get_all_names; end |
#use_scheme(scheme) ⇒ void
This method returns an undefined value.
Select the colour scheme to use.
By default, Wx::ColourDatabase uses CSS scheme which returns the standard values for the colours defined in the CSS specification, see www.w3.org/TR/css-color-4/#named-colors If preserving compatibility with the behaviour and appearance of the previous wxWidgets versions is important, you may switch to the traditional colour scheme by using this function with Traditional argument, e.g. call
wxTheColourDatabase->UseScheme(wxColourDatabase::Traditional);
during the application initialization. Please note that in the previous versions WXGTK already used CSS colour values, unlike all the other ports, so Traditional is not actually backwards compatible for WXGTK, but does make the colour values consistent across all platforms and the same as had been used by WXMSW and WXOSX before. In other words, to obtain 100% compatibility with the previous versions, the #use_scheme call above should be made for all ports except WXGTK. Note that the colour names defined only by wxWidgets, which notably includes all colour variants with spaces in their names, are still available in the default CSS colour scheme, with their traditional values but the names of colours defined by CSS standard are taken from it, e.g. “GREEN” corresponds to #00ff00
in the traditional scheme but to #008000
in the CSS scheme. Similarly, CSS colour names that were not defined by the previous wxWidgets versions are available even when using the traditional scheme, the scheme choice only affects the values of the colours defined by both wxWidgets and CSS with different values.
1245 |
# File 'lib/wx/doc/gen/gdi_common.rb', line 1245 def use_scheme(scheme) end |