Skip to main content

TdxUIAdornerManager.OnAdornerCustomDraw Event

Allows you to custom paint a UI adorner.

Declaration

property OnAdornerCustomDraw: TdxAdornerCustomDrawEvent read; write;

Remarks

This event occurs every time a guide or badge UI adorner is about to be painted. You can handle the OnAdornerCustomDraw event to override or complement the default draw routines for all or only specific adorners that you can identify by class names and indexes within the guide or badge collection.

For instance, the hot-tracked state of guides is not displayed by default:

The following code example implements the OnAdornerCustomDraw event handler displaying a semi-transparent light-red color fill within the hot-tracked guide’s boundaries:

uses
..., cxGeometry, dxCoreGraphics, dxGDIPlusClasses;
//...
procedure TMyForm.dxUIAdornerManager1AdornerCustomDraw(AManager: TdxUIAdornerManager; AAdorner: TdxCustomAdorner; ACanvas: TdxGPCanvas; AViewInfo: TdxCustomAdornerViewInfo; var ADone: Boolean);
var
  AGuideViewInfo: TdxGuideViewInfo;
begin
  if Aadorner is TdxGuide then  // Checks if the currently painted element is a guide UI adorner
    begin
      AGuideViewInfo := AViewInfo as TdxGuideViewInfo;  // Casts the provided ViewInfo parameter to the TdxGuideViewInfo class
      if AGuideViewInfo.State = astHotTracked then  // Checks if the currently painted guide is hot-tracked
        begin
          ADone := False;  // Allows painting the default guide outlines
          ACanvas.FillRectangle(AGuideViewInfo.Bounds, dxMakeAlphaColor(127, 255, 127, 127));  // Fills the hot-tracked guide's area with a semi-transparent light-red color with the default guide outlines painted over the area
        end
      else if AGuideViewInfo.State = astPressed then  // Checks if a mouse button is pressed over the currently painted guide
        begin
          ADone := True;  // Disables the default guide outlines
          ACanvas.FillRectangle(AGuideViewInfo.Bounds, dxMakeAlphaColor(255, 127, 255, 127));  // Fills the cut out rectangle with an opaque light green color, thus replacing the default guide outlines
        end;
    end;
end;

Refer to the TdxAdornerCustomDrawEvent procedural type description for detailed information on all parameters accessible within an OnAdornerCustomDraw event handler.

Note

To custom paint only a specific guide or badge adorner, handle its OnCustomDraw event instead.

See Also