mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 16:21:47 +02:00
LCL: Icon: sort
git-svn-id: trunk@57178 -
This commit is contained in:
parent
d5a2162347
commit
de98dc8a6f
@ -1629,6 +1629,7 @@ type
|
|||||||
function GetIndex(AFormat: TPixelFormat; AHeight, AWidth: Word): Integer;
|
function GetIndex(AFormat: TPixelFormat; AHeight, AWidth: Word): Integer;
|
||||||
class function GetImagesClass: TIconImageClass; virtual;
|
class function GetImagesClass: TIconImageClass; virtual;
|
||||||
procedure Add(AIconImage: TIconImage);
|
procedure Add(AIconImage: TIconImage);
|
||||||
|
procedure Sort;
|
||||||
function Count: Integer;
|
function Count: Integer;
|
||||||
property Images[AIndex: Integer]: TIconImage read GetImage;
|
property Images[AIndex: Integer]: TIconImage read GetImage;
|
||||||
end;
|
end;
|
||||||
@ -1740,6 +1741,7 @@ type
|
|||||||
function MaskHandleAllocated: boolean; override;
|
function MaskHandleAllocated: boolean; override;
|
||||||
function PaletteAllocated: boolean; override;
|
function PaletteAllocated: boolean; override;
|
||||||
procedure SetHandles(ABitmap, AMask: HBITMAP); override;
|
procedure SetHandles(ABitmap, AMask: HBITMAP); override;
|
||||||
|
procedure Sort;
|
||||||
function GetBestIndexForSize(ASize: TSize): Integer;
|
function GetBestIndexForSize(ASize: TSize): Integer;
|
||||||
|
|
||||||
property Current: Integer read FCurrent write SetCurrent;
|
property Current: Integer read FCurrent write SetCurrent;
|
||||||
|
@ -12,6 +12,16 @@
|
|||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IconCompare(Item1, Item2: Pointer): Integer;
|
||||||
|
var
|
||||||
|
Icon1: TIconImage absolute Item1;
|
||||||
|
Icon2: TIconImage absolute Item2;
|
||||||
|
begin
|
||||||
|
Result := CompareValue(Icon1.Width, Icon2.Width);
|
||||||
|
if Result=0 then
|
||||||
|
Result := -CompareValue(Ord(Icon1.PixelFormat), Ord(Icon2.PixelFormat));
|
||||||
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
IconSignature: array [0..3] of Byte = (0, 0, 1, 0);
|
IconSignature: array [0..3] of Byte = (0, 0, 1, 0);
|
||||||
|
|
||||||
@ -121,6 +131,11 @@ begin
|
|||||||
Result := inherited IsEmpty and (Count = 0);
|
Result := inherited IsEmpty and (Count = 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSharedIcon.Sort;
|
||||||
|
begin
|
||||||
|
FImages.Sort(@IconCompare);
|
||||||
|
end;
|
||||||
|
|
||||||
function TSharedIcon.GetImage(const AIndex: Integer): TIconImage;
|
function TSharedIcon.GetImage(const AIndex: Integer): TIconImage;
|
||||||
begin
|
begin
|
||||||
Result := TIconImage(FImages[AIndex]);
|
Result := TIconImage(FImages[AIndex]);
|
||||||
@ -1000,6 +1015,19 @@ begin
|
|||||||
// nothing
|
// nothing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomIcon.Sort;
|
||||||
|
var
|
||||||
|
ACurrent: Pointer;
|
||||||
|
begin
|
||||||
|
if FCurrent>=0 then
|
||||||
|
ACurrent := TSharedIcon(FSharedImage).FImages[FCurrent]
|
||||||
|
else
|
||||||
|
ACurrent := nil;
|
||||||
|
TSharedIcon(FSharedImage).Sort;
|
||||||
|
if ACurrent<>nil then
|
||||||
|
FCurrent := TSharedIcon(FSharedImage).FImages.IndexOf(ACurrent);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomIcon.SetSize(AWidth, AHeight: integer);
|
procedure TCustomIcon.SetSize(AWidth, AHeight: integer);
|
||||||
begin
|
begin
|
||||||
if FCurrent <> -1
|
if FCurrent <> -1
|
||||||
|
Loading…
Reference in New Issue
Block a user