Difference between revisions of "ColorPalette"
(→Change Log: Version 0.2 changes) |
(→Author) |
||
Line 63: | Line 63: | ||
<center>[[Image:ColorPalette.png|ColorPalette]]</center> | <center>[[Image:ColorPalette.png|ColorPalette]]</center> | ||
− | === | + | ===Authors=== |
− | [[User:Tombo|Tom Gregorovic]] | + | [[User:Tombo|Tom Gregorovic]] and Werner Pamler |
===License=== | ===License=== |
Revision as of 22:45, 22 August 2015
│
English (en) │
français (fr) │
About
ColorPalette is a cross-platform color palette grid with ability to select a color from a palette. The OnSelectColor event is fired when the user clicks onto a color.
Palettes
The components supports a series of built-in palettes as determined by the PaletteKind property:
- pkStandardPalette: the 16 standard color defined by the graphics unit
- pkExtendedPalette: the same, but extended by the 4 extra colors clMoneyGreen, clSkyBlue, clCream, clMedGray
- pkSystemPalette: the 25 system colors defined by the graphics unit
- pkStandardAndSystemPalette: the standard colors plus the system colors
- pkExtendedAndSystemPalette: the extended colors plus the system colors
- pkGradientPalette: "all" colors nicely arranged; use GradientSteps to define the horizontal resolution.
- pkWebSafePalette: a set of web-safe colors as defined by a wikipedia article
- pkWebSafePalette2: another set of web-safe colors.
In addition, a custom palette can be loaded from a file by calling the LoadPalette method. The palette files are simple text files according to this example (see also Default.pal in the component folder):
Custom palette example: $COLS 8 # sets count of palette grid columns 0,0,0 # inserts color r,g,b 255,255,255 $NONE # inserts empty palette grid cell $BLENDWB 128,128,128 3 # creates color gradient white -> color -> black with specified steps # The specified steps are applied to the transitions between "white" and "color" # and between "color" and "black", i.e., in total, there are <tt>2*steps+1</tt> color boxes.
There are several methods to manipulate the entries of the loaded palette:
- AddColor(AColor: TColor): adds a new entry to the palette
- DeleteColor(AIndex: Integer): removes the entry with the specified index from the palette
- ClearColors: removes all colors from the palette.
- SavePalette(AFileName: String): saves the currently used palette to a palette file which, in turn, can be re-loaded by means of the LoadPalette method already mentioned.
- Access individual colors by using the Colors[Index] property.
- ColorCount returns the number of colors in the palette.
- SelectedColor: returns the currently selected color
- SelectedIndex: returns the index of the currently selected color.
Color selection
When a color is selected by clicking with the mouse onto a color box an event OnSelectColor is generated; the event gets the rgb value of the selected color as a parameter. If the property ShowSelection is turned on then the selected color is highlighted.
The mouse button needed to fire this event is defined by the property PickShift which is a set of ssLeft, ssRight, ssMiddle TShiftState elements. The default value is ssLeft, i.e. the color is selected by the left mouse button.
The time flow when exactly the color is selected is determined by another property, PickMode:
- pmImmediate: The color is selected, and the event is generated, when the mousebutton goes down.
- pmContinuous: The color is selected, and the event is generated, while the mouse moves (with the button according to PickShift pressed down), and when the mousebutton goes up.
- pmDefault: The color is selected when the mousebutton goes down, and the event is generated when the mousebutton goes up. Both events must occur at the same location. This mode is a left-over from a previous version of the component and should not be used any more.
Screenshots
Authors
Tom Gregorovic and Werner Pamler
License
Modified LGPL
Download
ColorPalette on the Lazarus CCR at SourceForge.net
Change Log
Version 0.2
- New features
- New color selection
- "AddColor", "DeleteColor" etc.
- Builtin palettes
- Border color and border width
- Color hint window
- Incompatible changes
- Different behavior of color selection (the old method corresponds to PickMode=pmDefault).
Version 0.1
Notes
Status: Alpha
Issues:
- Tested on Windows XP.
- Tested with gtk1 and gtk2 under Linux (Kubuntu 6.06).
Installation
Install LazColorPalette package in the Lazarus IDE. The ColorPalette is added to the 'Misc' component palette page.