Difference between revisions of "TColorListBox"
From Lazarus wiki
Jump to navigationJump to search (New screenshot) |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{TColorListBox}} | |
+ | [[File:tcolorlistbox screenshot.png|right]] | ||
+ | A '''TColorListBox''' [[image:tcolorlistbox.png]] is a component that shows a (scrollable) list of colors from which the user can select one. It is available from the [[Additional tab]] of the [[Component Palette]]. | ||
+ | |||
+ | Specific properties of <code>TColorListBox</code> are: | ||
+ | * <code>ColorRectOffset</code> - margin around each color rectangle | ||
+ | * <code>ColorRectWidth</code> - width of a color rectangle | ||
+ | * <code>Style</code> - defines the items shown in the listbox, and how the colors are named | ||
+ | ** <code>cbStandardColors</code> - includes the 16 LCL standard colors in the list, e.g. <code>clRed</code> or <code>clBlue</code> | ||
+ | ** <code>cbExtendedColors</code> - includes the 4 LCL extended colors: <code>clMoneyGreen</code>, <code>clSkyBlue</code>, <code>clCream</code>, <code>clMedGray</code> | ||
+ | ** <code>cbSystemColors</code> - includes the OS- and theme-dependent system colors | ||
+ | ** <code>cbIncludeNone</code> - includes the special color <code>clNone</code>. Use the property <code>NoneColorColor</code> to determine the replacement color. If <code>NoneColorColor</code> is set to <code>clNone</code> the color rectangle displays a crossed-out box like in many drawing programs. | ||
+ | ** <code>cbIncludeDefault</code> - include the special color <code>clDefault</code>. Property <code>DefaultColorColor</code> determines the actual color displayed. | ||
+ | ** <code>cbCustomColor</code> - the first listbox item is customizable by means of the standard color dialog. | ||
+ | ** <code>cbPrettyNames</code> - displays "pretty" color names next to the color boxes, e.g. 'Red'. Without this option the internal color names are used, e.g. 'clRed'. | ||
+ | ** <code>cbCustomColors</code> - includes user-provided colors at the end of the list. The colors must be defined by a stringlist in the <code>OnGetColors</code> event, like this: | ||
+ | <syntaxhighlight lang="Pascal"> procedure TForm1.ColorListBox1GetColors(Sender: TCustomColorListBox; Items: TStrings); | ||
+ | begin | ||
+ | Items.AddObject('Gold', TObject(PtrInt($00D7FF))); | ||
+ | Items.AddObject('Chocolate', TObject(PtrInt($1E69D2))); | ||
+ | Items.AddObject('Light blue', TObject(PtrInt($E6D8AD))); | ||
+ | end;</syntaxhighlight> | ||
+ | |||
+ | <br clear="all"/> | ||
==See also== | ==See also== | ||
* [[doc:lcl/colorbox/tcolorlistbox.html|TColorListBox doc]] | * [[doc:lcl/colorbox/tcolorlistbox.html|TColorListBox doc]] | ||
* [[TColorBox]] | * [[TColorBox]] | ||
* [[TListBox]] | * [[TListBox]] | ||
− | |||
{{LCL Components}} | {{LCL Components}} |
Latest revision as of 22:01, 2 August 2019
│
English (en) │
Esperanto (eo) │
suomi (fi) │
français (fr) │
русский (ru) │
A TColorListBox is a component that shows a (scrollable) list of colors from which the user can select one. It is available from the Additional tab of the Component Palette.
Specific properties of TColorListBox
are:
ColorRectOffset
- margin around each color rectangleColorRectWidth
- width of a color rectangleStyle
- defines the items shown in the listbox, and how the colors are namedcbStandardColors
- includes the 16 LCL standard colors in the list, e.g.clRed
orclBlue
cbExtendedColors
- includes the 4 LCL extended colors:clMoneyGreen
,clSkyBlue
,clCream
,clMedGray
cbSystemColors
- includes the OS- and theme-dependent system colorscbIncludeNone
- includes the special colorclNone
. Use the propertyNoneColorColor
to determine the replacement color. IfNoneColorColor
is set toclNone
the color rectangle displays a crossed-out box like in many drawing programs.cbIncludeDefault
- include the special colorclDefault
. PropertyDefaultColorColor
determines the actual color displayed.cbCustomColor
- the first listbox item is customizable by means of the standard color dialog.cbPrettyNames
- displays "pretty" color names next to the color boxes, e.g. 'Red'. Without this option the internal color names are used, e.g. 'clRed'.cbCustomColors
- includes user-provided colors at the end of the list. The colors must be defined by a stringlist in theOnGetColors
event, like this:
procedure TForm1.ColorListBox1GetColors(Sender: TCustomColorListBox; Items: TStrings);
begin
Items.AddObject('Gold', TObject(PtrInt($00D7FF)));
Items.AddObject('Chocolate', TObject(PtrInt($1E69D2)));
Items.AddObject('Light blue', TObject(PtrInt($E6D8AD)));
end;
See also