Colors - Free Pascal Wiki
Colors - Free Pascal Wiki
Colors
From Free Pascal wiki
Contents
1 Overview
2 Convert TColor to RGB and back
3 System colors
3.1 Example: clInfoBk, clInfoText
3.2 Theme changes
3.3 Table of system colors
4 Drawing theme elements on your custom controls
Overview
The standard color in the LCL is TColor, which is compatible to Delphi's TColor. TColor can be an RGB, 3x8bit,
value or a system color like clDefault. The LCL can work together with the fpImage system which uses the
TFPColor (RGBA, 4x16bit).
// standard colors
clBlack = TColor($000000);
clMaroon = TColor($000080);
clGreen = TColor($008000);
clOlive = TColor($008080);
clNavy = TColor($800000);
clPurple = TColor($800080);
clTeal = TColor($808000);
clGray = TColor($808080);
clSilver = TColor($C0C0C0);
clRed = TColor($0000FF);
clLime = TColor($00FF00);
clYellow = TColor($00FFFF);
clBlue = TColor($FF0000);
clFuchsia = TColor($FF00FF);
clAqua = TColor($FFFF00);
clLtGray = TColor($C0C0C0); // clSilver alias
clDkGray = TColor($808080); // clGray alias
clWhite = TColor($FFFFFF);
System colors
Example: clInfoBk, clInfoText
System colors are color constants with a special meaning. Their real value depends on the context and theme. They
are not simple colors. For example clInfoBk:
A hint window on MS Windows might have a white background so the above will draw white. On Linux/gtk2 it
might be a metallic texture, so the above will draw the texture. If you want to put some text onto this you need a
corresponding color like clInfoText, otherwise your text might be unreadable for the user. For example:
The system color clInfoBk can not be used for Pen.Color and not for Font.Color. If you do so the result is
undefined and depends on the widgetset and user theme. The same for clInfoText: It can only be used as a
Font.Color. Using it as Brush.Color may not work. At the moment all widgetsets allow to use it as Pen.Color too.
Theme changes
When the user switches the theme the system colors changes. A clInfoBk might change from white to blue or from
a color to a texture. This change will happen when you allocate a new Brush handle. Keep in mind that a simple
assignment Brush.Color:=clInfoBk does not allocate a Brush Handle. The Brush Handle is allocated on use. For
example:
Delphi Supported
Constant LCL definition
notes Widgetsets
drawsnothing. Using it as Control's color is undefined. The
clNone - all
control will not get transparent.
Using it for Brush will use the normal background brush of
the target DC (device context).
The unit Themes provides functions to draw single elements of standard controls. For example to draw an expand
sign like a TTreeView use the following code:
uses Themes;
...