Ignore:
Timestamp:
Oct 25, 2012, 2:11:47 PM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UJobProgressView.pas

    r378 r432  
    111111    Finished: Boolean;
    112112    FOnJobFinish: TJobProgressViewMethod;
     113    FOnOwnerDraw: TNotifyEvent;
     114    FOwnerDraw: Boolean;
    113115    FShowDelay: Integer;
    114116    FTerminate: Boolean;
     
    116118    TotalStartTime: TDateTime;
    117119    Log: TStringList;
    118     Form: TFormJobProgressView;
    119120    procedure SetTerminate(const AValue: Boolean);
    120121    procedure UpdateProgress;
     
    122123    procedure StartJobs;
    123124    procedure UpdateHeight;
     125    procedure JobProgressChange(Sender: TObject);
    124126  public
     127    Form: TFormJobProgressView;
    125128    Jobs: TObjectList; // TListObject<TJob>
    126129    CurrentJob: TJob;
     
    136139    property Terminate: Boolean read FTerminate write SetTerminate;
    137140  published
     141    property OwnerDraw: Boolean read FOwnerDraw write FOwnerDraw;
    138142    property ShowDelay: Integer read FShowDelay write FShowDelay;
    139143    property AutoClose: Boolean read FAutoClose write FAutoClose;
    140144    property OnJobFinish: TJobProgressViewMethod read FOnJobFinish
    141145      write FOnJobFinish;
     146    property OnOwnerDraw: TNotifyEvent read FOnOwnerDraw
     147      write FOnOwnerDraw;
    142148  end;
    143149
     
    196202  NewJob.Progress.Max := 100;
    197203  NewJob.Progress.Reset;
     204  NewJob.Progress.OnChange := JobProgressChange;
    198205  Jobs.Add(NewJob);
    199206  //ReloadJobList;
     
    212219  Terminate := False;
    213220
    214   Form.BringToFront;
     221  if not OwnerDraw then Form.BringToFront;
    215222
    216223  Finished := False;
     
    244251      CurrentJobIndex := I;
    245252      CurrentJob := TJob(Jobs[I]);
     253      JobProgressChange(Self);
    246254      StartTime := Now;
    247255      Form.LabelEstimatedTimePart.Caption := Format(SEstimatedTime, ['']);
     
    339347end;
    340348
     349procedure TJobProgressView.JobProgressChange(Sender: TObject);
     350begin
     351  if Assigned(FOnOwnerDraw) then
     352    FOnOwnerDraw(Self);
     353end;
     354
    341355procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject);
    342356var
     
    357371  if not Visible then begin
    358372    TimerUpdate.Interval := UpdateInterval;
    359     Show;
     373    if not JobProgressView.OwnerDraw then Show;
    360374  end;
    361375end;
     
    509523destructor TJobProgressView.Destroy;
    510524begin
    511   Log.Free;
    512   Jobs.Free;
    513   inherited Destroy;
     525  FreeAndNil(Log);
     526  FreeAndNil(Jobs);
     527  inherited;
    514528end;
    515529
     
    519533    FLock.Acquire;
    520534    FMax := AValue;
     535    if FMax < 1 then FMax := 1;
    521536    if FValue >= FMax then FValue := FMax;
    522537  finally
     
    610625begin
    611626  Progress.Free;
    612   inherited Destroy;
     627  inherited;
    613628end;
    614629
Note: See TracChangeset for help on using the changeset viewer.