Skip to content

TSVGIconVirtualImageList

Unit: SVGIconVirtualImageList

Inherits from: TVirtualImageList (Delphi 10.3+) or TSVGIconImageListBase

Minimum Delphi Version: 10.3 Rio

Description

TSVGIconVirtualImageList is a virtual image list component that references a TSVGIconImageCollection to provide SVG icons at a specified size. Multiple virtual image lists can share the same icon collection, rendering icons at different sizes without duplicating storage.

This component integrates with Delphi's Virtual ImageList architecture (10.3+) and is fully compatible with all VCL controls that support TImageList.

Published Properties

Image Source

ImageCollection

pascal
property ImageCollection: TSVGIconImageCollection;

Reference to the source icon collection.

Usage:

pascal
SVGIconVirtualImageList1.ImageCollection := SVGIconImageCollection1;

Size Properties

Size

pascal
property Size: Integer;

Uniform size for square icons (sets both Width and Height). Default: 16

Usage:

pascal
SVGIconVirtualImageList1.Size := 32;

Width / Height

pascal
property Width: Integer;
property Height: Integer;

Individual width and height for non-square icons. Default: 16

Usage:

pascal
SVGIconVirtualImageList1.Width := 48;
SVGIconVirtualImageList1.Height := 32;

Rendering Attributes

Opacity

pascal
property Opacity: Byte;

Opacity level for rendered icons (0-255). Default: 255

FixedColor

pascal
property FixedColor: TColor;

Override color for rendering. Default: SVG_INHERIT_COLOR

GrayScale

pascal
property GrayScale: Boolean;

Render icons in grayscale. Default: False

AntiAliasColor

pascal
property AntiAliasColor: TColor;

Background color for anti-aliasing. Default: clBtnFace

ApplyFixedColorToRootOnly

pascal
property ApplyFixedColorToRootOnly: Boolean;

Apply FixedColor only to root SVG elements. Default: False

Disabled State

DisabledGrayScale

pascal
property DisabledGrayScale: Boolean;

Render disabled icons in grayscale. Default: True

DisabledOpacity

pascal
property DisabledOpacity: Byte;

Opacity for disabled icons. Default: 125

DPI Scaling

Scaled

pascal
property Scaled: Boolean;

Enable automatic DPI scaling. Default: True

Events

OnChange

pascal
property OnChange: TNotifyEvent;

Fired when the image list changes.

Public Methods

Create (Delphi 10.3+)

pascal
constructor Create(AOwner: TComponent);

Examples

Basic Setup

pascal
procedure TForm1.FormCreate(Sender: TObject);
begin
  // Create collection with icons
  SVGIconImageCollection1.LoadFromFiles(IconFiles);

  // Small icons for toolbar
  SVGIconVirtualImageListSmall.ImageCollection := SVGIconImageCollection1;
  SVGIconVirtualImageListSmall.Size := 16;
  ToolBar1.Images := SVGIconVirtualImageListSmall;

  // Large icons for ribbon
  SVGIconVirtualImageListLarge.ImageCollection := SVGIconImageCollection1;
  SVGIconVirtualImageListLarge.Size := 48;
  Ribbon1.Images := SVGIconVirtualImageListLarge;
end;

Multiple Sizes from One Collection

pascal
// Same icons, three different sizes
procedure TForm1.SetupImageLists;
begin
  // 16x16 for menus and toolbars
  VirtualImageList16.ImageCollection := IconCollection;
  VirtualImageList16.Size := 16;

  // 32x32 for buttons
  VirtualImageList32.ImageCollection := IconCollection;
  VirtualImageList32.Size := 32;

  // 64x64 for large displays
  VirtualImageList64.ImageCollection := IconCollection;
  VirtualImageList64.Size := 64;

  // All share the same SVG sources, minimal memory overhead
end;

Theme-Aware Virtual List

pascal
procedure TForm1.UpdateTheme(AIsDark: Boolean);
begin
  if AIsDark then
  begin
    SVGIconVirtualImageList1.FixedColor := clWhite;
    SVGIconVirtualImageList1.AntiAliasColor := $202020;
  end
  else
  begin
    SVGIconVirtualImageList1.FixedColor := clBlack;
    SVGIconVirtualImageList1.AntiAliasColor := clWhite;
  end;

  Invalidate;  // Refresh controls
end;

See Also

Released under Apache License, Version 2.0.