1{
2 /***************************************************************************
3                                  imglist.pp
4                                  ----------
5                Component Library TCustomImageList, TChangeLink Controls
6                   Initial Revision  : Fri Aug 16 21:00:00 CET 1999
7
8
9 ***************************************************************************/
10
11 *****************************************************************************
12  This file is part of the Lazarus Component Library (LCL)
13
14  See the file COPYING.modifiedLGPL.txt, included in this distribution,
15  for details about the license.
16 *****************************************************************************
17}
18
19{
20@author(TCustomImageList - Marc Weustink <weus@quicknet.nl>)
21@author(TChangeLink - Marc Weustink <weus@quicknet.nl>)
22@created(16-Aug-1999)
23@lastmod(26-feb-2003)
24
25Detailed description of the Unit.
26
27History
28  26-feb-2003 Olivier Guilbaud <golivier@free.fr>
29     - Add TCustomImageList.Assign()
30     - Add TCustomImageList.WriteData()
31     - Add TCustomImageList.ReadData()
32     - Add override TCustomImageList.DefineProperties()
33       Warning : the delphi or kylix format of datas is not compatible.
34     - Modify Delete and Clear for preserve memory
35}
36unit ImgList;
37
38{$mode objfpc}{$H+}
39{$modeswitch advancedrecords}
40
41interface
42
43{$ifdef Trace}
44  {$ASSERTIONS ON}
45{$endif}
46
47uses
48  // RTL + FCL
49  Types, math, SysUtils, Classes, FPReadBMP, FPimage, FPImgCanv, FPCanvas,
50  Contnrs, zstream, Laz_AVL_Tree,
51  // LazUtils
52  FPCAdds, LazLoggerBase, LazUtilities, AvgLvlTree,
53  // LCL
54  LCLStrConsts, LCLIntf, LResources, LCLType, LCLProc, Graphics, GraphType,
55  LCLClasses, IntfGraphics,
56  WSReferences, RtlConsts;
57
58type
59  TImageIndex = type integer;
60
61  { TChangeLink }
62  {
63    @abstract(Use a TChangelink to get notified of imagelist changes)
64    Introduced by Marc Weustink <weus@quicknet.nl>
65    Currently maintained by Marc Weustink <weus@quicknet.nl>
66  }
67
68  TCustomImageList = class; //forward declaration
69
70  TDestroyResolutionHandleEvent = procedure(Sender: TCustomImageList; AWidth: Integer; AReferenceHandle: TLCLHandle) of object;
71
72  TChangeLink = class(TObject)
73  private
74    FSender: TCustomImageList;
75    FOnChange: TNotifyEvent;
76    FOnDestroyResolutionHandle: TDestroyResolutionHandleEvent;
77
78    procedure DoDestroyResolutionReference(const AWidth: Integer; AResolutionReference: TLCLHandle);
79  public
80    destructor Destroy; override;
81    procedure Change; virtual;
82    property OnChange: TNotifyEvent read FOnChange write FOnChange;
83    property OnDestroyResolutionHandle: TDestroyResolutionHandleEvent read FOnDestroyResolutionHandle write FOnDestroyResolutionHandle;
84    property Sender: TCustomImageList read FSender write FSender;
85  end;
86
87  { TCustomImageList }
88  {
89    @abstract(Contains a list of images)
90    Introduced by Marc Weustink <marc@dommelstein.net>
91
92    Delphis TCustomImageList is based on the Win32 imagelists which has
93    internally only one bitmap to hold all images. This reduces handle
94    allocation.
95    The original TCustomImageList implementation was LCL only based, so for
96    other platforms the single bitmap implementation had some speed drawbacks.
97    Therefore it was implemented as list of bitmaps, however it doesnt reduce
98    handle allocation.
99    In its current form, the imagelist is again based on a 32bit RGBA raw
100    imagedata and the widgetset is notified when images are added or removed,
101    so the widgetset can create its own optimal storage. The LCL keeps only the
102    data, so all transparency info will be stored cross platform. (not all
103    platforms have a 8bit alpha channel).
104
105    NOTE: due to its implementation, the TCustomImageList is not a TBitmap
106    collection. If a fast storage of bitmaps is needed, create your own list!
107  }
108
109  // Some temp rework defines, for old functionality both need so be set
110
111  TDrawingStyle = (dsFocus, dsSelected, dsNormal, dsTransparent);
112  TImageType = (itImage, itMask);
113  TOverlay = 0..14; // windows limitation
114
115  TCustomImageListResolution = class(TLCLReferenceComponent)
116  private
117    FWidth: Integer;
118    FHeight: Integer;
119    FData: array of TRGBAQuad;
120    FReference: TWSCustomImageListReference;
121    FAllocCount: Integer;
122    FImageList: TCustomImageList;
123    FCount: Integer;
124    FAutoCreatedInDesignTime: Boolean;
125
126    procedure AllocData(ACount: Integer);
127    function  GetReference: TWSCustomImageListReference;
128
129    function Add(Image, Mask: TCustomBitmap): Integer;
130    procedure InternalInsert(AIndex: Integer; AData: PRGBAQuad); overload;
131    procedure InternalMove(ACurIndex, ANewIndex: Cardinal; AIgnoreCurrent: Boolean);
132    procedure InternalReplace(AIndex: Integer; AData: PRGBAQuad);
133    function  InternalSetData(AIndex: Integer; AData: PRGBAQuad): PRGBAQuad;
134    procedure CheckIndex(AIndex: Integer; AForInsert: Boolean = False);
135
136    procedure Clear;
137    procedure Delete(AIndex: Integer);
138
139    procedure GetFullRawImage(out Image: TRawImage);
140
141    procedure AddImages(AValue: TCustomImageListResolution);
142
143    procedure WriteData(AStream: TStream; const ACompress: Boolean);
144    procedure ReadData(AStream: TStream);
145  protected
146    function  GetReferenceHandle: THandle; override;
147    function  WSCreateReference(AParams: TCreateParams): PWSReference; override;
148    class procedure WSRegisterClass; override;
149    procedure ReferenceDestroying; override;
150  public
151    destructor Destroy; override;
152  public
153    function GetHotSpot: TPoint; virtual;
154    procedure FillDescription(out ADesc: TRawImageDescription);
155    procedure GetBitmap(Index: Integer; Image: TCustomBitmap); overload;
156    procedure GetBitmap(Index: Integer; Image: TCustomBitmap; AEffect: TGraphicsDrawEffect); overload;
157    procedure GetIcon(Index: Integer; Image: TIcon; AEffect: TGraphicsDrawEffect); overload;
158    procedure GetIcon(Index: Integer; Image: TIcon); overload;
159    procedure GetFullBitmap(Image: TCustomBitmap; AEffect: TGraphicsDrawEffect = gdeNormal);
160    procedure GetRawImage(Index: Integer; out Image: TRawImage);
161
162    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
163    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect); overload;
164    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
165      AEnabled: Boolean = True); overload;
166    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
167      ADrawEffect: TGraphicsDrawEffect); overload; virtual;
168    procedure StretchDraw(Canvas: TCanvas; Index: Integer; ARect: TRect; Enabled: Boolean = True);
169
170    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; AEnabled: Boolean = True); overload;
171    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawEffect: TGraphicsDrawEffect); overload;
172    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawingStyle:
173      TDrawingStyle; AImageType: TImageType; ADrawEffect: TGraphicsDrawEffect); overload;
174
175    property ImageList: TCustomImageList read FImageList;
176    property Width: Integer read FWidth;
177    property Height: Integer read FHeight;
178    property Count: Integer read FCount;
179
180    property AutoCreatedInDesignTime: Boolean read FAutoCreatedInDesignTime write FAutoCreatedInDesignTime;
181
182    property Reference: TWSCustomImageListReference read GetReference;
183  end;
184
185  { TScaledImageListResolution }
186
187  TScaledImageListResolution = record
188  private
189    FResolution: TCustomImageListResolution;
190    FScaleFactor: Double;
191    FWidth: Integer;
192    FHeight: Integer;
193    function GetCount: Integer;
194    function GetSize: TSize;
195    function GetValid: Boolean;
196  public
197    class function Create(AResolution: TCustomImageListResolution;
198      const AScaleFactor: Double): TScaledImageListResolution; static; // FPC record constructor bug
199
200    procedure GetBitmap(Index: Integer; Image: TCustomBitmap); overload;
201    procedure GetBitmap(Index: Integer; Image: TCustomBitmap; AEffect: TGraphicsDrawEffect); overload;
202
203    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
204    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect); overload;
205    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
206      AEnabled: Boolean = True); overload;
207    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
208      ADrawEffect: TGraphicsDrawEffect); overload;
209    procedure StretchDraw(Canvas: TCanvas; Index: Integer; ARect: TRect; Enabled: Boolean = True);
210
211    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; AEnabled: Boolean = True); overload;
212    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawEffect: TGraphicsDrawEffect); overload;
213    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawingStyle:
214      TDrawingStyle; AImageType: TImageType; ADrawEffect: TGraphicsDrawEffect); overload;
215
216    property Width: Integer read FWidth;
217    property Height: Integer read FHeight;
218    property Size: TSize read GetSize;
219    property Resolution: TCustomImageListResolution read FResolution;
220    property Count: Integer read GetCount;
221    property Valid: Boolean read GetValid;
222  end;
223
224  TCustomImageListResolutionClass = class of TCustomImageListResolution;
225  TCustomImageListResolutions = class(TObject)
226  private
227    FList: TObjectList;
228    FImageList: TCustomImageList;
229    FResolutionClass: TCustomImageListResolutionClass;
230
231    function Find(const AImageWidth: Integer; out Index: Integer): Boolean;
232    function GetImageLists(const AImageWidth: Integer): TCustomImageListResolution;
233    function GetImageLists(const AImageWidth: Integer; const AScaleFromExisting,
234      AutoCreatedInDesignTime: Boolean): TCustomImageListResolution;
235    function GetItems(const AIndex: Integer): TCustomImageListResolution;
236    function GetCount: Integer;
237    function FindBestToCopyFrom(const ATargetWidth, AIgnoreIndex: Integer): Integer;
238  public
239    constructor Create(const AImageList: TCustomImageList; const AResolutionClass: TCustomImageListResolutionClass);
240    destructor Destroy; override;
241  public
242    function FindBestToScaleFrom(const ATargetWidth: Integer): Integer;
243    procedure Delete(const AIndex: Integer);
244    procedure Clear;
245
246    property ImageLists[const AImageWidth: Integer]: TCustomImageListResolution read GetImageLists;
247    property Items[const AIndex: Integer]: TCustomImageListResolution read GetItems; default;
248    property Count: Integer read GetCount;
249  end;
250
251  TCustomImageListResolutionEnumerator = class
252  private
253    FCurrent: Integer;
254    FImgList: TCustomImageList;
255    FDesc: Boolean;
256    function GetCurrent: TCustomImageListResolution;
257  public
258    function GetEnumerator: TCustomImageListResolutionEnumerator;
259    constructor Create(AImgList: TCustomImageList; ADesc: Boolean);
260    function MoveNext: Boolean;
261    property Current: TCustomImageListResolution read GetCurrent;
262  end;
263
264  TCustomImageListGetWidthForPPI = procedure(Sender: TCustomImageList;
265    AImageWidth, APPI: Integer; var AResultWidth: Integer) of object;
266
267  TCustomImageList = class(TLCLComponent)
268  private
269    FDrawingStyle: TDrawingStyle;
270    FData: TCustomImageListResolutions;
271    FImageType: TImageType;
272    FHeight: Integer;
273    FMasked: boolean;
274    FShareImages: Boolean;
275    FWidth: Integer;
276    FAllocBy: Integer;
277    FBlendColor: TColor;
278    FOnChange: TNotifyEvent;
279    FChangeLinkList: TList;
280    FBkColor: TColor;
281    FChanged: boolean;
282    FUpdateCount: integer;
283    FOverlays: array[TOverlay] of Integer;
284    fHasOverlays: boolean;
285    FOnGetWidthForPPI: TCustomImageListGetWidthForPPI;
286    FScaled: Boolean;
287
288    procedure NotifyChangeLink;
289    procedure SetBkColor(const Value: TColor);
290    procedure SetDrawingStyle(const AValue: TDrawingStyle);
291    procedure SetHeight(const Value: Integer);
292    procedure SetMasked(const AValue: boolean);
293    procedure SetShareImages(const AValue: Boolean);
294    procedure SetWidth(const Value: Integer);
295    function GetReference(AImageWidth: Integer): TWSCustomImageListReference;
296    function GetReferenceForPPI(AImageWidth, APPI: Integer): TWSCustomImageListReference;
297    function GetResolutionForPPI(AImageWidth, APPI: Integer;
298      const ACanvasScaleFactor: Double): TScaledImageListResolution;
299    function GetWidthForPPI(AImageWidth, APPI: Integer): Integer;
300    function GetHeightForPPI(AImageWidth, APPI: Integer): Integer;
301    function GetHeightForWidth(AWidth: Integer): Integer;
302    function GetCount: Integer;
303    function GetSizeForPPI(AImageWidth, APPI: Integer): TSize;
304    function GetBestIconIndexForSize(AIcon: TCustomIcon; AWidth: Integer): Integer; // the icon must be sorted
305    function GetResolutionByIndex(AIndex: Integer): TCustomImageListResolution;
306    function GetResolutionCount: Integer;
307    procedure CreateDefaultResolution;
308    procedure DoDestroyResolutionReference(const AWidth: Integer; AResolutionReference: TLCLHandle);
309  protected
310    function GetResolution(AImageWidth: Integer): TCustomImageListResolution;
311    function GetResolutionClass: TCustomImageListResolutionClass; virtual;
312    procedure CheckIndex(AIndex: Integer; AForInsert: Boolean = False);
313    procedure Initialize; virtual;
314    procedure DefineProperties(Filer: TFiler); override;
315    procedure SetWidthHeight(NewWidth, NewHeight: integer);
316    procedure ClearOverlays;
317  public
318    constructor Create(AOwner: TComponent); override;
319    constructor CreateSize(AWidth, AHeight: Integer);
320    destructor Destroy; override;
321
322    class procedure ScaleImage(const ABitmap, AMask: TCustomBitmap;
323      TargetWidth, TargetHeight: Integer; var AData: TRGBAQuadArray);
324    class procedure ScaleImage(const ABitmap, AMask: TCustomBitmap;
325      SourceRect: TRect; TargetWidth, TargetHeight: Integer; var AData: TRGBAQuadArray);
326    class procedure ScaleImage(const ABitmap, AMask: HBITMAP;
327      SourceRect: TRect; TargetWidth, TargetHeight: Integer; var AData: TRGBAQuadArray);
328
329    procedure AssignTo(Dest: TPersistent); override;
330    procedure Assign(Source: TPersistent); override;
331    procedure WriteData(AStream: TStream); virtual;
332    procedure ReadData(AStream: TStream); virtual;
333    procedure WriteAdvData(AStream: TStream); virtual;
334    procedure ReadAdvData(AStream: TStream); virtual;
335    function Equals(Obj: TObject): boolean;
336      {$IF FPC_FULLVERSION>=20402}override;{$ENDIF}
337    procedure BeginUpdate;
338    procedure EndUpdate;
339
340    function Add(Image, Mask: TCustomBitmap): Integer;
341    function AddMultipleResolutions(Images: array of TCustomBitmap): Integer; // always pass sorted array from smallest to biggest
342    function AddSliced(Image: TCustomBitmap; AHorizontalCount, AVerticalCount: Integer): Integer;
343    function AddSlice(Image: TCustomBitmap; AImageRect: TRect): Integer;
344    function AddSliceCentered(Image: TCustomBitmap): Integer;
345    function AddIcon(Image: TCustomIcon): Integer;
346    procedure AddImages(AValue: TCustomImageList);
347    function AddMasked(Image: TBitmap; MaskColor: TColor): Integer;
348    function AddLazarusResource(const ResourceName: string; MaskColor: TColor = clNone): integer;
349    function AddResourceName(Instance: THandle; const ResourceName: string; MaskColor: TColor = clNone): integer;
350    procedure Change;
351    procedure Clear;
352    procedure Delete(AIndex: Integer);
353    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
354    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect); overload;
355    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
356      AEnabled: Boolean = True); overload;
357    procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawingStyle: TDrawingStyle; AImageType: TImageType;
358      ADrawEffect: TGraphicsDrawEffect); overload;
359    procedure DrawForPPI(ACanvas: TCanvas; AX, AY, AIndex: Integer;
360      AImageWidthAt96PPI, ATargetPPI: Integer; ACanvasFactor: Double; AEnabled: Boolean = True); overload;
361    procedure DrawForPPI(ACanvas: TCanvas; AX, AY, AIndex: Integer;
362      AImageWidthAt96PPI, ATargetPPI: Integer; ACanvasFactor: Double; ADrawEffect: TGraphicsDrawEffect); overload;
363    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; AEnabled: Boolean = True); overload;
364    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawEffect: TGraphicsDrawEffect); overload;
365    procedure DrawOverlay(ACanvas: TCanvas; AX, AY, AIndex: Integer; AOverlay: TOverlay; ADrawingStyle:
366      TDrawingStyle; AImageType: TImageType; ADrawEffect: TGraphicsDrawEffect); overload;
367
368    procedure GetBitmap(Index: Integer; Image: TCustomBitmap); overload;
369    procedure GetBitmap(Index: Integer; Image: TCustomBitmap; AEffect: TGraphicsDrawEffect); overload;
370    procedure GetFullBitmap(Image: TCustomBitmap; AEffect: TGraphicsDrawEffect = gdeNormal);
371    procedure GetFullRawImage(out Image: TRawImage);
372
373    procedure GetIcon(Index: Integer; Image: TIcon; AEffect: TGraphicsDrawEffect); overload;
374    procedure GetIcon(Index: Integer; Image: TIcon); overload;
375    procedure GetRawImage(Index: Integer; out Image: TRawImage);
376    function GetHotSpot: TPoint;
377
378    procedure Insert(AIndex: Integer; AImage, AMask: TCustomBitmap);
379    procedure InsertIcon(AIndex: Integer; AIcon: TCustomIcon);
380    procedure InsertMasked(Index: Integer; AImage: TCustomBitmap; MaskColor: TColor);
381    procedure Move(ACurIndex, ANewIndex: Integer);
382    procedure Overlay(AIndex: Integer; Overlay: TOverlay);
383    property HasOverlays: boolean read fHasOverlays;
384    procedure Replace(AIndex: Integer; AImage, AMask: TCustomBitmap; const AllResolutions: Boolean = True);
385    procedure ReplaceSlice(AIndex: Integer; Image: TCustomBitmap; AImageRect: TRect; const AllResolutions: Boolean = True);
386    procedure ReplaceSliceCentered(AIndex, AImageWidth: Integer; Image: TCustomBitmap; const AllResolutions: Boolean = True);
387    procedure ReplaceIcon(AIndex: Integer; AIcon: TCustomIcon);
388    procedure ReplaceMasked(Index: Integer; NewImage: TCustomBitmap; MaskColor: TColor; const AllResolutions: Boolean = True);
389    procedure RegisterChanges(Value: TChangeLink);
390    procedure StretchDraw(Canvas: TCanvas; Index: Integer; ARect: TRect; Enabled: Boolean = True);
391    procedure UnRegisterChanges(Value: TChangeLink);
392
393    procedure RegisterResolutions(const AResolutionWidths: array of Integer); virtual;
394    procedure DeleteResolution(const AWidth: Integer);
395    function FindResolution(AImageWidth: Integer; out AResolution: TCustomImageListResolution): Boolean;
396  public
397    property AllocBy: Integer read FAllocBy write FAllocBy default 4;
398    property BlendColor: TColor read FBlendColor write FBlendColor default clNone;
399    property BkColor: TColor read FBkColor write SetBkColor default clNone;
400    property Count: Integer read GetCount;
401    property DrawingStyle: TDrawingStyle read FDrawingStyle write SetDrawingStyle default dsNormal;
402    property Height: Integer read FHeight write SetHeight default 16;
403    property HeightForPPI[AImageWidth, APPI: Integer]: Integer read GetHeightForPPI;
404    property HeightForWidth[AWidth: Integer]: Integer read GetHeightForWidth;
405    property Width: Integer read FWidth write SetWidth default 16;
406    property WidthForPPI[AImageWidth, APPI: Integer]: Integer read GetWidthForPPI;
407    property SizeForPPI[AImageWidth, APPI: Integer]: TSize read GetSizeForPPI;
408    property OnChange: TNotifyEvent read FOnChange write FOnChange;
409    property Masked: boolean read FMasked write SetMasked default False;
410    property Reference[AImageWidth: Integer]: TWSCustomImageListReference read GetReference;
411    property ReferenceForPPI[AImageWidth, APPI: Integer]: TWSCustomImageListReference read GetReferenceForPPI;
412    property Resolution[AImageWidth: Integer]: TCustomImageListResolution read GetResolution;
413    property ResolutionByIndex[AIndex: Integer]: TCustomImageListResolution read GetResolutionByIndex;
414    property ResolutionForPPI[AImageWidth, APPI: Integer; const ACanvasScaleFactor: Double]: TScaledImageListResolution read GetResolutionForPPI;
415    property ResolutionCount: Integer read GetResolutionCount;
416    function Resolutions: TCustomImageListResolutionEnumerator;
417    function ResolutionsDesc: TCustomImageListResolutionEnumerator;
418    property Scaled: Boolean read FScaled write FScaled default False;
419    property ShareImages: Boolean read FShareImages write SetShareImages default False;
420    property ImageType: TImageType read FImageType write FImageType default itImage;
421    property OnGetWidthForPPI: TCustomImageListGetWidthForPPI read FOnGetWidthForPPI write FOnGetWidthForPPI;
422  end;
423
424  TLCLGlyphsMissingResources = (
425    gmrAllMustExist, // Show exception if any image/resolution is not found
426    gmrOneMustExist, // Show exception if no resolution is found. Missing resolutions will be auto-generated from the biggest one.
427    gmrIgnoreAll);   // Ignore all missing resources. No image will be added and TLCLGlyphs.GetImageIndex Result is -1 if no resolution is found.
428
429  TLCLGlyphs = class(TCustomImageList)
430  private type
431    TEntryKey = record
432      GlyphName: string;
433    end;
434    PEntryKey = ^TEntryKey;
435
436    TEntry = class
437    public
438      // key
439      GlyphName: string;
440
441      // value
442      ImageIndex: Integer; // the image index in TLCLGlyphs
443    end;
444    TResolution = record
445      Width: Integer;
446      ScaleSuffix: Integer;
447    end;
448
449  private
450    FMissingResources: TLCLGlyphsMissingResources;
451    FImageIndexes: TAvgLvlTree;
452    FLoadResolutions: array of TResolution;
453    FSuffix100Scale: Integer;
454  public
455    function GetImageIndex(const AResourceName: string): Integer;
456
457    // AResolutionWidths must be sorted from smallest to biggest
458    procedure RegisterResolutions(const AResolutionWidths: array of Integer); override;
459    procedure RegisterResolutions(const AResolutionWidths, AResolutionScaleSuffixes: array of Integer); overload;
460
461    procedure SetWidth100Suffix(const AWidth100Suffix: Integer);
462
463    constructor Create(AOwner: TComponent); override;
464    destructor Destroy; override;
465
466    property MissingResources: TLCLGlyphsMissingResources read FMissingResources write FMissingResources;
467  end;
468
469function LCLGlyphs: TLCLGlyphs;
470function GetDefaultGlyph(ResourceName: string; ScalePercent: Integer = 100;
471  IgnoreMissingResource: Boolean = False): TCustomBitmap;
472
473implementation
474
475uses
476  WSImglist;
477
478{$I imglist.inc}
479
480end.
481
482