MFColorPicker Component Help


Overview  Installation   Properties  Methods  Events   Terms of Use and Registration


 

Overview

TColorPicker is a TPanel descendant that contains several sub-components allowing the user to implement a multifunction color selector that would be primarily useful for graphics applications, but could be adapted to other uses as well.

Inside the panel are two panels, a color panel containing a spectrum of colors and a color grid representing a 16 color palette, from which the user can select a color for use in the application.

There is also another panel, the currently selected color panel, whose color changes when the mouse moves over the colors in the color panel.

Two other panels, the Primary Color Panel, and the Secondary Color Panel, can be used to represent brush colors in an application ( for example). The Primary Color Panel color can be set by calling the appropriate method, or is set automatically when the user left clicks on either the color panel or the color grid. Likewise, the Secondary Color Panel color can be set by code, or can be set by the user right-mouse clicking on the Color Panel.

If the use right clicks on the Color Grid, the color cell selected is set to the color of the Primary Color Panel.

There are also two buttons, the Save Palette Button and the Load Palette Button, which, when pressed fire events wherein the programmer can call built-in methods to save or restore the colors in the color grid, thus allowing for the creation, storage and use of customized palettes.

 

Installation

Put the MFColorPicker .pas, MFColorPicker.res and MFColorPicker.dcr files in a directory in your library path then select MFColorPicker.pas using the Component/Install Component Menu Selection in the IDE.

 

Properties
PrimaryColor When the use left clicks on the spectrum in the color panel or a cell in the color grid, the color of the Primary Color Panel is set to the color selected.

This color of the Primary Color Panel can be read or set with this TColor property.

SecondaryColor When the use right clicks on the spectrum in the color panel, the color of the Secondary Color Panel is set to the color selected.

This color of the Secondary Color Panel can be read or set with this TColor property.

 

Methods
GetPaletteColor Calling this method allows the application to retrieve the color of a specified color cell in the Color Grid.

It takes the form:

GetPaletteColor(index) : Color;

index is an integer value specifying the color cell

Color is the TColor result.

The cells in the color grid are numbered 0 (top left) to 15 (bottom right).

SetPaletteColor Calling this method allows the application to set the color of a specified color cell in the Color Grid.

It takes the form:

SetPaletteColor(index,color)

index is an integer value specifying the color cell

Color is the TColor value to be set to the cell.

The cells in the color grid are numbered 0 (top left) to 15 (bottom right).

SetStandardPalette After the colors in the color grid have been changed, this method can be called to restore the standard palette colors. The procedure takes no arguments.
SavePalette When this method is called the colors of the cells in the color grid are save to a file.

SavePalette(name);

name is a TString value representing the desired filename.

LoadPalette Call this method to load the colors in the color grid from the values in a file created by the SavePalette method.

 

LoadPalette(name);

name is a TString value representing the filename.

 

Events
OnSavePalette This event is fired when the user presses the Save Palette Button. Typically the event code will call the SavePalette method, but other preliminary code, such as calling a SaveFile Dialog, can be included.
OnLoadPalette This event is fired when the user presses the Load Palette Button. Typically the event code will call the LoadPalette method, but other preliminary code, such as calling an OpenFile Dialog, can be included.
OnNewPrimary This event is fired when the color of the Primary Color Panel changes by the user selecting a new color using the mouse.
OnNewSecondary This event is fired when the color of the Secondary Color Panel changes by the user selecting a new color using the mouse.
OnPaletteChange This event is fired when a cell in the color grid changes color due to the use right clicking it with the mouse. The event passes the application two values: an integer representing the index of the color cell clicked, and a TColor value representung the new color value.

 

Terms of Use and Registration
This component is shareware not freeware. If you decide to use it after evaluation, you must register it. Upon registration you may use the component freely in any freeware or shareware applications you create and distribute.

Use of the component in a commercial application is prohibited without prior written permission from the author. Any additional fee or requirements will be determined based on the nature of the application.

This component is provided to you with the full source code 'On Trust'. If you decide to use it please do the honorable thing and register.

Please visit MicroFrame's website for instructions concerning registration