mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 15:37:51 +02:00
TTaskDialog: start implementing TTaskDialogProgressBar: skeleton only, does not communicate with the dialog yet.
This commit is contained in:
parent
2885935b2d
commit
fe0ed266ce
@ -1792,6 +1792,9 @@ type
|
||||
|
||||
TProgressBarStyle = (pbstNormal, pbstMarquee);
|
||||
|
||||
//used by TTaskDialogProgressBar, but Delphi defines it in ComCtrls unit
|
||||
TProgressBarState = (pbsNormal, pbsError, pbsPaused);
|
||||
|
||||
{ TCustomProgressBar }
|
||||
{
|
||||
@abstract(Simple progressbar.)
|
||||
|
@ -27,6 +27,7 @@ uses
|
||||
LMessages, LResources, LCLIntf, InterfaceBase, LCLStrConsts, LCLType,
|
||||
Forms, Controls, Themes, Graphics, Buttons, ButtonPanel, StdCtrls,
|
||||
ExtCtrls, LCLClasses, ClipBrd, Menus, {LCLTaskDialog,} DialogRes,
|
||||
ComCtrls,
|
||||
// LazUtils
|
||||
GraphType, FileUtil, LazFileUtils, LazStringUtils, LazLoggerBase;
|
||||
|
||||
@ -634,6 +635,35 @@ type
|
||||
property Items[Index: Integer]: TTaskDialogBaseButtonItem read GetItem write SetItem; default;
|
||||
end;
|
||||
|
||||
TProgressBarState = ComCtrls.TProgressBarState; //it's where Delphi defines this type, so we need to follow
|
||||
|
||||
{ TTaskDialogProgressBar }
|
||||
|
||||
TTaskDialogProgressBar = class(TPersistent)
|
||||
private
|
||||
Dlg: TCustomTaskDialog;
|
||||
FMarqueeSpeed: Cardinal;
|
||||
FMax: Integer;
|
||||
FMin: Integer;
|
||||
FPosition: Integer;
|
||||
FState: TProgressBarState;
|
||||
procedure SetMarqueeSpeed(AValue: Cardinal);
|
||||
procedure SetMax(AValue: Integer);
|
||||
procedure SetMin(AValue: Integer);
|
||||
procedure SetPosition(AValue: Integer);
|
||||
procedure SetState(AValue: TProgressBarState);
|
||||
public
|
||||
constructor Create(ADialog: TCustomTaskDialog);
|
||||
procedure Initialize; //call after dialog has been instatiated to send message to the dialog window
|
||||
published
|
||||
property MarqueeSpeed: Cardinal read FMarqueeSpeed write SetMarqueeSpeed default 0;
|
||||
property Max: Integer read FMax write SetMax default 100;
|
||||
property Min: Integer read FMin write SetMin default 0;
|
||||
property Position: Integer read FPosition write SetPosition default 0;
|
||||
property State: TProgressBarState read FState write SetState default pbsNormal;
|
||||
end;
|
||||
|
||||
|
||||
{ TCustomTaskDialog }
|
||||
|
||||
TCustomTaskDialog = class(TLCLComponent)
|
||||
@ -665,6 +695,7 @@ type
|
||||
FOnRadioButtonClicked: TNotifyEvent;
|
||||
FOnTimer: TTaskDlgTimerEvent;
|
||||
FOnVerificationClicked: TNotifyEvent;
|
||||
FProgressBar: TTaskDialogProgressBar;
|
||||
FQueryChoices: TStrings;
|
||||
FQueryResult: String;
|
||||
FQueryItemIndex: Integer;
|
||||
@ -729,6 +760,7 @@ type
|
||||
property MainIcon: TTaskDialogIcon read FMainIcon write FMainIcon default tdiInformation;
|
||||
property Handle: THandle read FHandle; //Handle to the dialog window
|
||||
property ModalResult: TModalResult read FModalResult write FModalResult;
|
||||
property ProgressBar: TTaskDialogProgressBar read FProgressBar write FProgressBar;
|
||||
property QueryChoices: TStrings read FQueryChoices write SetQueryChoices;
|
||||
property QueryItemIndex: Integer read FQueryItemIndex write FQueryItemIndex;
|
||||
property QueryResult: String read FQueryResult write FQueryResult;
|
||||
@ -770,6 +802,7 @@ type
|
||||
property FooterIcon;
|
||||
property FooterText;
|
||||
property MainIcon;
|
||||
property ProgressBar;
|
||||
property RadioButtons;
|
||||
property QueryChoices;
|
||||
property QueryItemIndex;
|
||||
|
@ -61,6 +61,71 @@ begin
|
||||
inherited SetItem(Index, Value);
|
||||
end;
|
||||
|
||||
{ TTaskDialogProgressBar }
|
||||
|
||||
procedure TTaskDialogProgressBar.SetMarqueeSpeed(AValue: Cardinal);
|
||||
begin
|
||||
if FMarqueeSpeed = AValue then Exit;
|
||||
FMarqueeSpeed := AValue;
|
||||
//ToDo: send TDM_SET_PROGRESS_BAR_MARQUEE to Dlg
|
||||
end;
|
||||
|
||||
procedure TTaskDialogProgressBar.SetMax(AValue: Integer);
|
||||
begin
|
||||
if FMax = AValue then Exit;
|
||||
FMax := AValue;
|
||||
if (FMin > FMax) then
|
||||
FMin := FMax;
|
||||
//ToDo: send TDM_SET_PROGRESS_BAR_RANGE to Dlg
|
||||
end;
|
||||
|
||||
procedure TTaskDialogProgressBar.SetMin(AValue: Integer);
|
||||
begin
|
||||
if FMin = AValue then Exit;
|
||||
FMin := AValue;
|
||||
if (FMin > FMax) then
|
||||
FMin := FMax;
|
||||
//ToDo: send TDM_SET_PROGRESS_BAR_RANGE to Dlg
|
||||
end;
|
||||
|
||||
procedure TTaskDialogProgressBar.SetPosition(AValue: Integer);
|
||||
begin
|
||||
if FPosition = AValue then Exit;
|
||||
FPosition := AValue;
|
||||
if (FPosition < FMin) then
|
||||
FPosition := FMIn
|
||||
else
|
||||
if (FPosition > FMax) then
|
||||
FPosition := FMax;
|
||||
//ToDo: send TDM_SET_PROGRESS_BAR_POS to Dlg
|
||||
//Todo 2: test if Delphi raises an excpetion if FPosition is out of range
|
||||
end;
|
||||
|
||||
procedure TTaskDialogProgressBar.SetState(AValue: TProgressBarState);
|
||||
begin
|
||||
if FState = AValue then Exit;
|
||||
FState := AValue;
|
||||
//ToDo: send TDM_SET_PROGRESS_BAR_STATE to Dlg
|
||||
end;
|
||||
|
||||
constructor TTaskDialogProgressBar.Create(ADialog: TCustomTaskDialog);
|
||||
begin
|
||||
inherited Create;
|
||||
Dlg := ADialog;
|
||||
FMin := 0;
|
||||
FMax := 100;
|
||||
FMarqueeSpeed := 0;
|
||||
end;
|
||||
|
||||
procedure TTaskDialogProgressBar.Initialize;
|
||||
//this should be invoked as soon as the dialog has been instatiated (so Dlg.Handle <> 0),
|
||||
//so probably in Dlg.DoOnConstructed??
|
||||
begin
|
||||
//ToDo:
|
||||
// send TDM_SET_MARQUEE_PROGRESS_BAR to Dlg (differentiates between "normal" and marguee)
|
||||
// send range, position and state to dialog.
|
||||
end;
|
||||
|
||||
{ TTaskDialogRadioButtonItem }
|
||||
|
||||
constructor TTaskDialogRadioButtonItem.Create(ACollection: TCollection);
|
||||
@ -98,6 +163,7 @@ begin
|
||||
|
||||
FCustomFooterIcon := TIcon.Create;
|
||||
FCustomMainIcon := TIcon.Create;
|
||||
FProgressBar := TTaskDialogProgressBar.Create(Self);
|
||||
|
||||
FHandle := 0;
|
||||
end;
|
||||
@ -139,6 +205,7 @@ begin
|
||||
FQueryChoices.Free;
|
||||
FCustomFooterIcon.Free;
|
||||
FCustomMainIcon.Free;
|
||||
FProgressBar.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -188,6 +255,7 @@ end;
|
||||
|
||||
procedure TCustomTaskDialog.DoOnDialogConstructed;
|
||||
begin
|
||||
FProgressBar.Initialize;
|
||||
if Assigned(FOnDialogConstructed) then
|
||||
FOnDialogConstructed(Self);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user