- introduce a new class for shared icns icon
  - add 2 hacks to allow correct assigning between cursors, icons, and icnsIcons (Marc, please review)

git-svn-id: trunk@16877 -
This commit is contained in:
paul 2008-10-05 09:17:23 +00:00
parent 0294f3618f
commit ddea740b16
3 changed files with 23 additions and 2 deletions

View File

@ -1475,6 +1475,7 @@ type
FRequestedSize: TSize;
procedure MaskHandleNeeded; override;
procedure PaletteNeeded; override;
function CanShareImage(AClass: TSharedRasterImageClass): Boolean; override;
procedure CheckRequestedSize;
function GetIndex(AFormat: TPixelFormat; AHeight, AWidth: Word): Integer;
function GetBitmapHandle: HBITMAP; override;
@ -1557,6 +1558,9 @@ type
property Items[Index: Integer]: PIcnsRec read GetItem write SetItem; default;
end;
TSharedIcnsIcon = class(TSharedIcon)
end;
{ TIcnsIcon }
TIcnsIcon = class(TCustomIcon)
@ -1566,6 +1570,7 @@ type
procedure IcnsAdd(AIconType: TicnsIconType; ARawImage: TRawImage);
procedure IcnsProcess;
protected
class function GetSharedImageClass: TSharedRasterImageClass; override;
procedure ReadData(Stream: TStream); override;
procedure ReadStream(AStream: TMemoryStream; ASize: Longint); override;
procedure WriteStream(AStream: TMemoryStream); override;

View File

@ -145,6 +145,11 @@ begin
FCurrent := GetBestIndexForSize(FRequestedSize);
end;
class function TIcnsIcon.GetSharedImageClass: TSharedRasterImageClass;
begin
Result := TSharedIcnsIcon;
end;
constructor TIcnsIcon.Create;
begin
inherited Create;

View File

@ -304,6 +304,7 @@ end;
procedure TCustomIcon.Assign(Source: TPersistent);
begin
BeginUpdate;
if Source is TCustomIcon
then begin
FCurrent := -1;
@ -311,7 +312,6 @@ begin
else
if Source is TRasterImage
then begin
BeginUpdate;
Clear;
with TRasterImage(Source) do
@ -326,8 +326,13 @@ begin
if Source is TCustomIcon
then begin
FCurrent := TCustomIcon(Source).Current;
FCurrent := TCustomIcon(Source).Current
end;
// temporary hack since TRasterImage assign cannot handle multiply rawimages
if (Source is TCustomIcon) and (TCustomIcon(Source).GetSharedImageClass <> GetSharedImageClass) then
UnshareImage(True);
EndUpdate;
end;
procedure TCustomIcon.AssignImage(ASource: TRasterImage);
@ -651,6 +656,12 @@ begin
// nothing to do, handled by image itself
end;
function TCustomIcon.CanShareImage(AClass: TSharedRasterImageClass): Boolean;
begin
// temporary hack to make Assign work between cursors, icons and icnsicons
Result := AClass.InheritsFrom(TSharedIcon);
end;
procedure TCustomIcon.CheckRequestedSize;
begin
if (FRequestedSize.cx = 0) and (FRequestedSize.cy = 0) then