Browse Source

Merge branch 'thirdparty_dev' into dev

Source commit: 4d8b7f5d11f3754ea5e0506d1158ccc9125e9132
Martin Prikryl 8 years ago
parent
commit
d45f45bcc7
2 changed files with 35 additions and 12 deletions
  1. 0 4
      source/packages/png/PngComponentsRegister.pas
  2. 35 8
      source/packages/png/PngImageList.pas

+ 0 - 4
source/packages/png/PngComponentsRegister.pas

@@ -15,10 +15,6 @@ const
 
 procedure Register;
 begin
-  {$if CompilerVersion >= 24.0 }
-    TPngImageList.IDE_WriteData_Hack := true;
-  {$ifend}
-
   //Register all components
   RegisterComponents(SPageName, [TPngSpeedButton, TPngBitBtn, TPngImageList,
     TPngImageCollection, TPngCheckListBox]);

+ 35 - 8
source/packages/png/PngImageList.pas

@@ -22,7 +22,6 @@ type
     FPngImages: TPngImageCollectionItems;
     FPngOptions: TPngOptions;
   class var
-    FIDE_WriteData_Hack: Boolean;
     function GetHeight: Integer;
     function GetWidth: Integer;
     procedure SetHeight(const Value: Integer);
@@ -50,6 +49,7 @@ type
     function AddImage(Value: TCustomImageList; Index: Integer): Integer; virtual;
     procedure AddImages(Value: TCustomImageList); virtual;
     function AddMasked(Image: TBitmap; MaskColor: TColor): Integer; virtual;
+    procedure Assign(Source: TPersistent); override;
     procedure BeginUpdate;
     procedure Clear; virtual;
     procedure Delete(Index: Integer); virtual;
@@ -63,9 +63,8 @@ type
     procedure Replace(Index: Integer; Image, Mask: TBitmap); virtual;
     procedure ReplaceIcon(Index: Integer; Image: TIcon); virtual;
     procedure ReplaceMasked(Index: Integer; NewImage: TBitmap; MaskColor: TColor); virtual;
-    class property IDE_WriteData_Hack: Boolean read FIDE_WriteData_Hack write
-        FIDE_WriteData_Hack;
   published
+    property ColorDepth default cd32Bit;
     property EnabledImages: Boolean read FEnabledImages write SetEnabledImages default True;
     property Height read GetHeight write SetHeight default 16;
     property PngImages: TPngImageCollectionItems read FPngImages write SetPngImages;
@@ -307,6 +306,7 @@ end;
 constructor TPngImageList.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
+  ColorDepth := cd32Bit;
   if ImageListCount = 0 then
     ApplyMethodPatches;
   Inc(ImageListCount);
@@ -500,12 +500,39 @@ begin
   end;
 end;
 
+procedure TPngImageList.Assign(Source: TPersistent);
+var
+  pngSource: TPngImageList;
+begin
+  if Source is TPngImageList then begin
+    pngSource := TPngImageList(Source);
+    BeginUpdate;
+    try
+      PngImages := pngSource.PngImages;
+      EnabledImages := pngSource.EnabledImages;
+      PngOptions := pngSource.PngOptions;
+    finally
+      EndUpdate(true);
+    end;
+  end;
+
+  if Source is TCustomImageList then begin
+    ColorDepth := TCustomImageList(Source).ColorDepth;
+  end;
+
+  inherited;
+end;
+
 procedure TPngImageList.AssignTo(Dest: TPersistent);
+var
+  pngDest: TPngImageList;
 begin
   inherited;
   if Dest is TPngImageList then begin
-    TPngImageList(Dest).PngImages := FPngImages;
-    TPngImageList(Dest).EnabledImages := FEnabledImages;
+    pngDest := TPngImageList(Dest);
+    pngDest.PngImages := PngImages;
+    pngDest.EnabledImages := EnabledImages;
+    pngDest.PngOptions := PngOptions;
   end;
 end;
 
@@ -994,8 +1021,8 @@ end;
 
 procedure TPngImageList.ReadData(Stream: TStream);
 begin
-//  if not (csReading in ComponentState) then
-//    inherited;
+  if not (csReading in ComponentState) then
+    inherited;
   //Make sure nothing gets read from the DFM
 end;
 
@@ -1146,7 +1173,7 @@ end;
 
 procedure TPngImageList.WriteData(Stream: TStream);
 begin
-  if IDE_WriteData_Hack and not (csWriting in ComponentState) then
+  if not (csWriting in ComponentState) then
     inherited;
   //Make sure nothing gets written to the DFM
 end;