mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 23:09:07 +02:00
+ Added progressevent
This commit is contained in:
parent
b7ae35ec3b
commit
7b37f2dd4a
@ -170,6 +170,18 @@ begin
|
|||||||
inherited create;
|
inherited create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPCustomImageHandler.Progress(Stage: TProgressStage;
|
||||||
|
PercentDone: Byte; RedrawNow: Boolean; const R: TRect;
|
||||||
|
const Msg: AnsiString; var Continue: Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
If Assigned(FOnProgress) then
|
||||||
|
FOnProgress(Self,Stage,PercentDone,RedrawNow,R,Msg,Continue)
|
||||||
|
else If Assigned(FImage) then
|
||||||
|
// It is debatable whether we should pass ourselves or the image ?
|
||||||
|
FImage.Progress(Self,Stage,PercentDone,RedrawNow,R,Msg,Continue);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFPCustomImageReader }
|
{ TFPCustomImageReader }
|
||||||
|
|
||||||
constructor TFPCustomImageReader.Create;
|
constructor TFPCustomImageReader.Create;
|
||||||
|
@ -217,6 +217,14 @@ begin
|
|||||||
FPImgError (StrInvalidIndex,[ErrorText[StrImageY],y]);
|
FPImgError (StrInvalidIndex,[ErrorText[StrImageY],y]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TFPCustomImage.Progress(Sender: TObject; Stage: TProgressStage;
|
||||||
|
PercentDone: Byte; RedrawNow: Boolean; const R: TRect;
|
||||||
|
const Msg: AnsiString; var Continue: Boolean);
|
||||||
|
begin
|
||||||
|
If Assigned(FOnProgress) then
|
||||||
|
FonProgress(Sender,Stage,PercentDone,RedrawNow,R,Msg,Continue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TFPMemoryImage }
|
{ TFPMemoryImage }
|
||||||
|
|
||||||
|
@ -34,6 +34,14 @@ type
|
|||||||
TFPColorArray = array [0..maxint] of TFPColor;
|
TFPColorArray = array [0..maxint] of TFPColor;
|
||||||
PFPColorArray = ^TFPColorArray;
|
PFPColorArray = ^TFPColorArray;
|
||||||
|
|
||||||
|
TFPImgProgressStage = (psStarting, psRunning, psEnding);
|
||||||
|
TFPImgProgressEvent = procedure (Sender: TObject; Stage: TFPImgProgressStage;
|
||||||
|
PercentDone: Byte; RedrawNow: Boolean; const R: TRect;
|
||||||
|
const Msg: AnsiString; var Continue : Boolean) of object;
|
||||||
|
// Delphi compatibility
|
||||||
|
TProgressStage = TFPImgProgressStage;
|
||||||
|
TProgressEvent = TFPImgProgressEvent;
|
||||||
|
|
||||||
TFPPalette = class
|
TFPPalette = class
|
||||||
private
|
private
|
||||||
FData : PFPColorArray;
|
FData : PFPColorArray;
|
||||||
@ -57,6 +65,7 @@ type
|
|||||||
|
|
||||||
TFPCustomImage = class
|
TFPCustomImage = class
|
||||||
private
|
private
|
||||||
|
FOnProgress : TFPImgProgressEvent;
|
||||||
FExtra : TStringlist;
|
FExtra : TStringlist;
|
||||||
FPalette : TFPPalette;
|
FPalette : TFPPalette;
|
||||||
FHeight, FWidth : integer;
|
FHeight, FWidth : integer;
|
||||||
@ -82,6 +91,9 @@ type
|
|||||||
function GetInternalColor (x,y:integer) : TFPColor; virtual;
|
function GetInternalColor (x,y:integer) : TFPColor; virtual;
|
||||||
procedure SetInternalPixel (x,y:integer; Value:integer); virtual; abstract;
|
procedure SetInternalPixel (x,y:integer; Value:integer); virtual; abstract;
|
||||||
function GetInternalPixel (x,y:integer) : integer; virtual; abstract;
|
function GetInternalPixel (x,y:integer) : integer; virtual; abstract;
|
||||||
|
procedure Progress(Sender: TObject; Stage: TProgressStage;
|
||||||
|
PercentDone: Byte; RedrawNow: Boolean; const R: TRect;
|
||||||
|
const Msg: AnsiString; var Continue: Boolean); Virtual;
|
||||||
public
|
public
|
||||||
constructor create (AWidth,AHeight:integer); virtual;
|
constructor create (AWidth,AHeight:integer); virtual;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
@ -105,6 +117,7 @@ type
|
|||||||
property ExtraKey [index:integer] : string read GetExtraKey write SetExtraKey;
|
property ExtraKey [index:integer] : string read GetExtraKey write SetExtraKey;
|
||||||
procedure RemoveExtra (const key:string);
|
procedure RemoveExtra (const key:string);
|
||||||
function ExtraCount : integer;
|
function ExtraCount : integer;
|
||||||
|
property OnProgress: TFPImgProgressEvent read FOnProgress write FOnProgress;
|
||||||
end;
|
end;
|
||||||
TFPCustomImageClass = class of TFPCustomImage;
|
TFPCustomImageClass = class of TFPCustomImage;
|
||||||
|
|
||||||
@ -125,13 +138,17 @@ type
|
|||||||
|
|
||||||
TFPCustomImageHandler = class
|
TFPCustomImageHandler = class
|
||||||
private
|
private
|
||||||
|
FOnProgress : TFPImgProgressEvent;
|
||||||
FStream : TStream;
|
FStream : TStream;
|
||||||
FImage : TFPCustomImage;
|
FImage : TFPCustomImage;
|
||||||
protected
|
protected
|
||||||
|
procedure Progress(Stage: TProgressStage; PercentDone: Byte; RedrawNow: Boolean; const R: TRect;
|
||||||
|
const Msg: AnsiString; var Continue: Boolean); Virtual;
|
||||||
property TheStream : TStream read FStream;
|
property TheStream : TStream read FStream;
|
||||||
property TheImage : TFPCustomImage read FImage;
|
property TheImage : TFPCustomImage read FImage;
|
||||||
public
|
public
|
||||||
constructor Create; virtual;
|
constructor Create; virtual;
|
||||||
|
Property OnProgress : TFPImgProgressEvent Read FOnProgress Write FOnProgress;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TFPCustomImageReader = class (TFPCustomImageHandler)
|
TFPCustomImageReader = class (TFPCustomImageHandler)
|
||||||
|
Loading…
Reference in New Issue
Block a user