TcxCustomEditProperties.OnButtonGlyphDrawParameters Event
Allows you to customize the appearance of individual editor button glyphs.
Declaration
property OnButtonGlyphDrawParameters: TcxEditButtonGlyphDrawParametersEvent read; write;
Remarks
You can handle the OnButtonGlyphDrawParameters
event to change editor button glyphs or apply a different palette to a vector button glyph depending on the target editor button and its current state (disabled, normal, pressed, or selected).
Event Occurrence
The OnButtonGlyphDrawParameters
event occurs every time the editor is about to determine how to draw an editor button glyph. This event does not occur for editor buttons that display text instead of a glyph.
Event Parameters
You can use the AButtonIndex
parameter to identify the button whose glyph appearance the editor is about to determine. AGlyph
and APalette
parameters allow you to display a different glyph for the processed button and apply a different color palette to the glyph if it is an SVG image.
Refer to the TcxEditButtonGlyphDrawParametersEvent procedural type description for detailed information on all parameters accessible within an OnButtonGlyphDrawParameters
event.
Code Example: Multiple Glyph Color Palettes
The following code example changes glyph color palettes for two buttons in a button editor in hot-tracked and pressed states:
procedure TMyForm.cxButtonEdit1PropertiesButtonGlyphDrawParameters(
Sender: TObject; AButtonIndex: Integer; AState: TcxEditButtonState;
var AGlyph: TGraphic; var APalette: IdxColorPalette);
var
AColorPalette: IdxColorPalette;
begin
if AState = TcxEditButtonState.ebsNormal then Exit; // No appearance changes for the Normal state
AColorPalette := TdxSimpleColorPalette.Create(TdxAlphaColors.Empty, TdxAlphaColors.Empty);
if AButtonIndex = 0 then // Checks if the first editor button is pressed or hot-tracked
begin
if AState = TcxEditButtonState.ebsSelected then // Defines a custom palette for the hot-tracked state
begin
TdxSimpleColorPalette(AColorPalette).FillColor := TdxAlphaColors.Yellow;
TdxSimpleColorPalette(AColorPalette).StrokeColor := TdxAlphaColors.GreenYellow;
end
else if AState = TcxEditButtonState.ebsPressed then // Defines a custom palette for the pressed state
begin
TdxSimpleColorPalette(AColorPalette).FillColor := TdxAlphaColors.Green;
TdxSimpleColorPalette(AColorPalette).StrokeColor := TdxAlphaColors.LimeGreen;
end;
end
else if AButtonIndex = 1 then // Checks if the second editor button is pressed or hot-tracked
begin
if AState = TcxEditButtonState.ebsSelected then // Defines a custom palette for the hot-tracked state
begin
TdxSimpleColorPalette(AColorPalette).FillColor := TdxAlphaColors.LightCoral;
TdxSimpleColorPalette(AColorPalette).StrokeColor := TdxAlphaColors.LightSalmon;
end
else if AState = TcxEditButtonState.ebsPressed then // Defines a custom palette for the pressed state
begin
TdxSimpleColorPalette(AColorPalette).FillColor := TdxAlphaColors.Red;
TdxSimpleColorPalette(AColorPalette).StrokeColor := TdxAlphaColors.Maroon;
end;
end;
APalette := AColorPalette;
AColorPalette := nil;
end;