Refactoring TTaskDialog:

- Use meaningfull names for private vars of TLCLTaskDialog
- Factor out SetupPanel
- Consistent capitalization of "Result" ,"True" and "False"
- Remove property VerifyChecked, set appropriate flag instead
- More debugln statements
- Add some comments
The emulated dialog is now more or less functional (we don't return RadioResult yet).
This commit is contained in:
Bart 2023-07-20 19:54:20 +02:00
parent 0b9130a2a3
commit 1420ce0a69
2 changed files with 152 additions and 190 deletions

View File

@ -239,7 +239,8 @@ begin
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]); debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]);
debugln(['New: ButtonID=',ButtonID]); debugln(['New: ButtonID=',ButtonID]);
debugln(['New: FModalResult=',FModalResult]); debugln(['New: FModalResult=',FModalResult]);
debugln(['New: VerifyChecked=',tfVerificationFlagChecked in FFlags]);
//ToDo: we need to retrieve RadioResult, since we cannot set RadioButton (it's read only)
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0); FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);

View File

@ -25,18 +25,27 @@ type
/// the Task Dialog structure which created the form /// the Task Dialog structure which created the form
FDlg: TTaskDialog; FDlg: TTaskDialog;
FRadioRes: Integer; FRadioRes: Integer;
FVerifyCheck: Boolean;
FVerifyChecked: Boolean; FVerifyChecked: Boolean;
Rad: array of TRadioButton; RadioButtonArray: array of TRadioButton;
CustomButtons, Radios, DialogCaption, DlgTitle, DlgText,
ExpandedButtonCaption, ExpandedText, FooterText,
VerificationText, Selection: String;
CommonButtons: TTaskDialogCommonButtons;
Buttons, Radios, Title, Instruction, Content,
TaskDlgInfoCollapse, Info, Footer,
Verify, Selection: String;
aCommonButtons: TTaskDialogCommonButtons;
Panel: TPanel; Panel: TPanel;
Image: TImage;
/// the labels corresponding to the Task Dialog main elements
Element: array[tdeContent..tdeMainInstruction] of TLabel;
/// the Task Dialog selection list
Combo: TComboBox;
/// the Task Dialog optional query editor
Edit: TEdit;
/// the Task Dialog optional checkbox
VerifyCheckBox: TCheckBox;
Image: TImage; //Dialog Icon;
procedure SetupIcon(out IconBorder,X,Y: Integer; AParent: TWinControl); procedure SetupIcon(out IconBorder,X,Y: Integer; AParent: TWinControl);
procedure SetupPanel;
procedure AddRadios(ARadioOffSet, AWidth, ARadioDef, AFontHeight: Integer; var X,Y: Integer; AParent: TWinControl); procedure AddRadios(ARadioOffSet, AWidth, ARadioDef, AFontHeight: Integer; var X,Y: Integer; AParent: TWinControl);
procedure AddCommandLinkButtons(var X, Y: Integer; AWidth, AButtonDef, AFontHeight: Integer; AParent: TWinControl); procedure AddCommandLinkButtons(var X, Y: Integer; AWidth, AButtonDef, AFontHeight: Integer; AParent: TWinControl);
procedure AddButtonsAndCheckBox(var X,Y, XB: Integer; AWidth, AButtonDef: Integer; APArent: TWinControl); procedure AddButtonsAndCheckBox(var X,Y, XB: Integer; AWidth, AButtonDef: Integer; APArent: TWinControl);
@ -51,16 +60,6 @@ type
function Execute: Integer; function Execute: Integer;
public public
/// the labels corresponding to the Task Dialog main elements
Element: array[tdeContent..tdeMainInstruction] of TLabel;
/// the Task Dialog selection list
Combo: TComboBox;
/// the Task Dialog optional query editor
Edit: TEdit;
/// the Task Dialog optional checkbox
Verif: TCheckBox;
property VerifyChecked: Boolean read FVerifyCheck write FVerifyChecked;
property RadioRes: Integer read FRadioRes; property RadioRes: Integer read FRadioRes;
end; end;
@ -132,8 +131,8 @@ end;
function CR(const aText: string): string; function CR(const aText: string): string;
begin begin
if pos('\n', aText) = 0 then if pos('\n', aText) = 0 then
result := aText else Result := aText else
result := StringReplace(aText, '\n', #10, [rfReplaceAll]); Result := StringReplace(aText, '\n', #10, [rfReplaceAll]);
end; end;
//if aText contains '\n' //if aText contains '\n'
@ -157,12 +156,12 @@ end;
function TD_BTNS(button: TTaskDialogCommonButton): pointer; function TD_BTNS(button: TTaskDialogCommonButton): pointer;
begin begin
case button of case button of
tcbOK: result := @rsMbOK; tcbOK: Result := @rsMbOK;
tcbYes: result := @rsMbYes; tcbYes: Result := @rsMbYes;
tcbNo: result := @rsMbNo; tcbNo: Result := @rsMbNo;
tcbCancel: result := @rsMbCancel; tcbCancel: Result := @rsMbCancel;
tcbRetry: result := @rsMbRetry; tcbRetry: Result := @rsMbRetry;
tcbClose: result := @rsMbClose; tcbClose: Result := @rsMbClose;
end; end;
end; end;
@ -195,6 +194,9 @@ begin
end; end;
//Note: do we really need this??
//We already use resourcestrings that can be translated using
//translations unit
function TD_Trans(const aString: string): string; function TD_Trans(const aString: string): string;
begin begin
if Assigned(TaskDialog_Translate) then if Assigned(TaskDialog_Translate) then
@ -208,13 +210,13 @@ end;
function IconMessage(Icon: TLCLTaskDialogIcon): string; function IconMessage(Icon: TLCLTaskDialogIcon): string;
begin begin
case Icon of case Icon of
tiWarning: result := rsMtWarning; tiWarning: Result := rsMtWarning;
tiQuestion: result := rsMtConfirmation; tiQuestion: Result := rsMtConfirmation;
tiError: result := rsMtError; tiError: Result := rsMtError;
tiInformation, tiShield: result := rsMtInformation; tiInformation, tiShield: Result := rsMtInformation;
else result := ''; else Result := '';
end; end;
result := TD_Trans(result); Result := TD_Trans(Result);
end; end;
@ -246,7 +248,7 @@ begin
inherited CreateNew(AOwner, Num); inherited CreateNew(AOwner, Num);
if (AOwner is TCustomTaskDialog) then if (AOwner is TCustomTaskDialog) then
FDlg := TTaskDialog(AOwner); FDlg := TTaskDialog(AOwner);
Rad := nil; RadioButtonArray := nil;
KeyPreview := True; KeyPreview := True;
end; end;
@ -291,13 +293,20 @@ begin
*) *)
if Verif<>nil then if VerifyCheckBox<>nil then
FVerifyChecked := Verif.Checked; begin
if VerifyCheckBox.Checked then
FDlg.Flags := FDlg.Flags + [tfVerificationFlagChecked]
else
FDlg.Flags := FDlg.Flags - [tfVerificationFlagChecked]
end;
FRadioRes := 0; FRadioRes := 0;
for i := 0 to high(Rad) do for i := 0 to high(RadioButtonArray) do
if Rad[i].Checked then if RadioButtonArray[i].Checked then
FRadioRes := i+FirstRadioButtonIndex; FRadioRes := i+FirstRadioButtonIndex;
end; end;
@ -331,13 +340,24 @@ begin
end else end else
begin begin
Image := nil; Image := nil;
if (not (tfEmulateClassicStyle in FDlg.Flags)) and (Instruction <> '') then if (not (tfEmulateClassicStyle in FDlg.Flags)) and (DlgTitle <> '') then
IconBorder := IconBorder*2; IconBorder := IconBorder*2;
X := IconBorder; X := IconBorder;
Y := IconBorder; Y := IconBorder;
end; end;
end; end;
procedure TLCLTaskDialog.SetupPanel;
begin
Panel := TPanel.Create(Self);
Panel.Parent := Self;
Panel.Align := alTop;
Panel.BorderStyle := bsNone;
Panel.BevelOuter := bvNone;
if not (tfEmulateClassicStyle in FDlg.Flags) then
Panel.Color := clWindow;
end;
procedure TLCLTaskDialog.AddRadios(ARadioOffSet, AWidth, ARadioDef, AFontHeight: Integer; var X,Y: Integer; AParent: TWinControl); procedure TLCLTaskDialog.AddRadios(ARadioOffSet, AWidth, ARadioDef, AFontHeight: Integer; var X,Y: Integer; AParent: TWinControl);
var var
i: Integer; i: Integer;
@ -346,10 +366,10 @@ begin
with TStringList.Create do with TStringList.Create do
try try
Text := SysUtils.Trim(Radios); Text := SysUtils.Trim(Radios);
SetLength(Rad,Count); SetLength(RadioButtonArray,Count);
for i := 0 to Count-1 do begin for i := 0 to Count-1 do begin
Rad[i] := TRadioButton.Create(Self); RadioButtonArray[i] := TRadioButton.Create(Self);
with Rad[i] do begin with RadioButtonArray[i] do begin
Parent := AParent; Parent := AParent;
AutoSize := False; AutoSize := False;
SetBounds(X+16,Y,aWidth-32-X, (6-AFontHeight) + ARadioOffset); SetBounds(X+16,Y,aWidth-32-X, (6-AFontHeight) + ARadioOffset);
@ -378,7 +398,7 @@ begin
with TStringList.Create do with TStringList.Create do
try try
inc(Y,8); inc(Y,8);
Text := SysUtils.Trim(Buttons); Text := SysUtils.Trim(CustomButtons);
for i := 0 to Count-1 do for i := 0 to Count-1 do
begin begin
CommandLink := TBitBtn.Create(Self); CommandLink := TBitBtn.Create(Self);
@ -439,26 +459,26 @@ var
XB := aWidth-WB; XB := aWidth-WB;
inc(Y,32); inc(Y,32);
end; end;
result := TButton.Create(Self); Result := TButton.Create(Self);
result.Parent := AParent; Result.Parent := AParent;
if (tfEmulateClassicStyle in FDlg.Flags) then if (tfEmulateClassicStyle in FDlg.Flags) then
result.SetBounds(XB,Y,WB-10,22) Result.SetBounds(XB,Y,WB-10,22)
else else
result.SetBounds(XB,Y,WB-12,28); Result.SetBounds(XB,Y,WB-12,28);
result.Caption := s; Result.Caption := s;
result.ModalResult := ModalResult; Result.ModalResult := ModalResult;
result.TabOrder := CurrTabOrder; Result.TabOrder := CurrTabOrder;
result.OnClick := @HandleEmulatedButtonClicked; Result.OnClick := @HandleEmulatedButtonClicked;
case ModalResult of case ModalResult of
mrOk: begin mrOk: begin
result.Default := True; Result.Default := True;
if aCommonButtons=[tcbOk] then if CommonButtons=[tcbOk] then
result.Cancel := True; Result.Cancel := True;
end; end;
mrCancel: result.Cancel := True; mrCancel: Result.Cancel := True;
end; end;
if ModalResult=aButtonDef then if ModalResult=aButtonDef then
ActiveControl := result; ActiveControl := Result;
end; end;
begin begin
CurrTabOrder := Panel.TabOrder; CurrTabOrder := Panel.TabOrder;
@ -467,7 +487,7 @@ begin
if not (tfUseCommandLinks in FDlg.Flags) then if not (tfUseCommandLinks in FDlg.Flags) then
with TStringList.Create do with TStringList.Create do
try try
Text := SysUtils.trim(Buttons); Text := SysUtils.trim(CustomButtons);
for i := Count-1 downto 0 do for i := Count-1 downto 0 do
AddButton(Strings[i],i+FirstButtonIndex); AddButton(Strings[i],i+FirstButtonIndex);
finally finally
@ -475,21 +495,21 @@ begin
end; end;
for Btn := high(TTaskDialogCommonButton) downto low(TTaskDialogCommonButton) do for Btn := high(TTaskDialogCommonButton) downto low(TTaskDialogCommonButton) do
begin begin
if (Btn in aCommonButtons) then if (Btn in CommonButtons) then
AddButton(TD_Trans(LoadResString(TD_BTNS(Btn))), TD_BTNMOD[Btn]); AddButton(TD_Trans(LoadResString(TD_BTNS(Btn))), TD_BTNMOD[Btn]);
end; end;
if Verify<>'' then if VerificationText<>'' then
begin begin
Verif := TCheckBox.Create(Self); VerifyCheckBox := TCheckBox.Create(Self);
with Verif do with VerifyCheckBox do
begin begin
Parent := AParent; Parent := AParent;
if X+16+Canvas.TextWidth(Verify)>XB then begin if X+16+Canvas.TextWidth(VerificationText)>XB then begin
inc(Y,32); inc(Y,32);
XB := aWidth; XB := aWidth;
end; end;
SetBounds(X,Y,XB-X,24); SetBounds(X,Y,XB-X,24);
Caption := Verify; Caption := VerificationText;
Checked := FVerifyChecked; Checked := FVerifyChecked;
end; end;
end; end;
@ -509,15 +529,6 @@ begin
end; end;
//const
// LCL_IMAGES: array[TTaskDialogIcon] of Integer = (
// 0, idDialogWarning, idDialogConfirm, idDialogError, idDialogInfo, 0, idDialogShield);
//LCL_FOOTERIMAGES: array[TTaskDialogFooterIcon] of Integer = (
// 0, idDialogWarning, idDialogConfirm, idDialogError, idDialogInfo, idDialogShield);
procedure TLCLTaskDialog.SetupControls; procedure TLCLTaskDialog.SetupControls;
var var
//TaskDlg: LCLTaskDialog.TTaskDialog; //TaskDlg: LCLTaskDialog.TTaskDialog;
@ -525,12 +536,11 @@ var
B: TTaskDialogBaseButtonItem; B: TTaskDialogBaseButtonItem;
ButtonID: Integer; ButtonID: Integer;
ARadioOffset, FontHeight, aWidth, IconBorder, X, Y, i, XB: integer; ARadioOffset, FontHeight, aWidth, IconBorder, X, Y, i, XB: integer;
Par: TWinControl; CurrParent: TWinControl;
aDialogIcon: TLCLTaskDialogIcon; aDialogIcon: TLCLTaskDialogIcon;
CommandLink: TBitBtn; CommandLink: TBitBtn;
aHint: String; aHint: String;
List: TStringListUTF8Fast; List: TStringListUTF8Fast;
CurrTabOrder: TTabOrder;
Btn: TTaskDialogCommonButton; Btn: TTaskDialogCommonButton;
@ -541,89 +551,45 @@ var
if Text = '' then if Text = '' then
exit(nil); exit(nil);
result := TLabel.Create(Self); Result := TLabel.Create(Self);
result.Parent := Par; Result.Parent := CurrParent;
result.WordWrap := True; Result.WordWrap := True;
if BigFont then if BigFont then
begin begin
if (tfEmulateClassicStyle in FDlg.Flags) then if (tfEmulateClassicStyle in FDlg.Flags) then
begin begin
result.Font.Height := FontHeight-2; Result.Font.Height := FontHeight-2;
result.Font.Style := [fsBold] Result.Font.Style := [fsBold]
end end
else else
begin begin
result.Font.Height := FontHeight-4; Result.Font.Height := FontHeight-4;
result.Font.Color := clHighlight; Result.Font.Color := clHighlight;
end; end;
end end
else else
result.Font.Height := FontHeight; Result.Font.Height := FontHeight;
result.AutoSize := False; Result.AutoSize := False;
R.Left := 0; R.Left := 0;
R.Top := 0; R.Top := 0;
W := aWidth-X-8; W := aWidth-X-8;
R.Right := W; R.Right := W;
R.Bottom := result.Height; R.Bottom := Result.Height;
LCLIntf.DrawText(result.Canvas.Handle,PChar(Text),Length(Text),R,DT_CALCRECT or DT_WORDBREAK);//lazarus does not return box height on OSX (Lazarus bug), the height is stored in the rect in all cases, so we don't need to use the result LCLIntf.DrawText(Result.Canvas.Handle,PChar(Text),Length(Text),R,DT_CALCRECT or DT_WORDBREAK);//lazarus does not return box height on OSX (Lazarus bug), the height is stored in the rect in all cases, so we don't need to use the Result
result.SetBounds(X,Y,W,R.Bottom); Result.SetBounds(X,Y,W,R.Bottom);
result.Caption := Text; Result.Caption := Text;
inc(Y,R.Bottom+16); inc(Y,R.Bottom+16);
end; end;
function NoCR(const aText: string): string;
var k: integer;
begin
result := aText;
aHint := '';
k := pos('\n',result);
if k>0 then begin
aHint := CR(copy(result,k+2,maxInt));
SetLength(result,k-1);
end;
end;
function AddButton(const s: string; ModalResult: integer): TButton;
var
WB: integer;
begin
WB := Canvas.TextWidth(s)+52;
dec(XB,WB);
if XB<X shr 1 then begin
XB := aWidth-WB;
inc(Y,32);
end;
result := TButton.Create(Self);
result.Parent := Par;
if (tfEmulateClassicStyle in FDlg.Flags) then
result.SetBounds(XB,Y,WB-10,22)
else
result.SetBounds(XB,Y,WB-12,28);
result.Caption := s;
result.ModalResult := ModalResult;
result.TabOrder := CurrTabOrder;
result.OnClick := @HandleEmulatedButtonClicked;
case ModalResult of
mrOk: begin
result.Default := True;
if aCommonButtons=[tcbOk] then
result.Cancel := True;
end;
mrCancel: result.Cancel := True;
end;
if ModalResult=aButtonDef then
ActiveControl := result;
end;
procedure AddBevel; procedure AddBevel;
var var
BX: integer; BX: integer;
begin begin
with TBevel.Create(Self) do begin with TBevel.Create(Self) do begin
Parent := Par; Parent := CurrParent;
if (Image<>nil) and (Y<Image.Top+Image.Height) then if (Image<>nil) and (Y<Image.Top+Image.Height) then
BX := X else BX := X else
BX := 2; BX := 2;
@ -644,9 +610,9 @@ begin
else else
aButtonDef := TD_BTNMOD[FDlg.DefaultButton]; aButtonDef := TD_BTNMOD[FDlg.DefaultButton];
Buttons := ''; CustomButtons := '';
for B in FDlg.Buttons do for B in FDlg.Buttons do
Buttons := Buttons + B.Caption + #10; CustomButtons := CustomButtons + B.Caption + #10;
Radios := ''; Radios := '';
for B in FDlg.RadioButtons do for B in FDlg.RadioButtons do
Radios := Radios + B.Caption + #10; Radios := Radios + B.Caption + #10;
@ -655,33 +621,35 @@ begin
//This field/parameter is currently not used in Dialogs.TTaskDialog and not passed so we cannot initialize it properly yet //This field/parameter is currently not used in Dialogs.TTaskDialog and not passed so we cannot initialize it properly yet
Selection := ''; Selection := '';
Title := FDlg.Caption; DialogCaption := FDlg.Caption;
Instruction := FDlg.Title; DlgTitle := FDlg.Title;
Content := FDlg.Text; DlgText := FDlg.Text;
TaskDlgInfoCollapse := FDlg.ExpandButtonCaption; ExpandedButtonCaption := FDlg.ExpandButtonCaption;
Info := FDlg.ExpandedText; ExpandedText := FDlg.ExpandedText;
Footer := FDlg.FooterText; FooterText := FDlg.FooterText;
Verify := FDlg.VerificationText; VerificationText := FDlg.VerificationText;
FVerifyChecked := (tfVerificationFlagChecked in FDlg.Flags); FVerifyChecked := (tfVerificationFlagChecked in FDlg.Flags);
aCommonButtons := FDlg.CommonButtons; CommonButtons := FDlg.CommonButtons;
if (aCommonButtons=[]) and (Buttons='') then if (CommonButtons=[]) and (CustomButtons='') then
begin begin
aCommonButtons := [tcbOk]; CommonButtons := [tcbOk];
if (aButtonDef = 0) then if (aButtonDef = 0) then
aButtonDef := mrOk; aButtonDef := mrOk;
end; end;
if (Title = '') then if (DialogCaption = '') then
if (Application.MainForm = nil) then if (Application.MainForm = nil) then
Title := Application.Title else DialogCaption := Application.Title
Title := Application.MainForm.Caption; else
// DialogCaption := Application.MainForm.Caption;
if (Instruction = '') then
Instruction := IconMessage(TF_DIALOGICON(FDlg.MainIcon));
//
if (DlgTitle = '') then
DlgTitle := IconMessage(TF_DIALOGICON(FDlg.MainIcon));
//Dialog.OnButtonClicked := aOnButtonClicked;
PixelsPerInch := 96; // we are using 96 PPI in the code, scale it automatically at ShowModal PixelsPerInch := 96; // we are using 96 PPI in the code, scale it automatically at ShowModal
@ -706,9 +674,9 @@ begin
aWidth := FDlg.FWidth; aWidth := FDlg.FWidth;
if (aWidth <= 0) then if (aWidth <= 0) then
begin begin
aWidth := Canvas.TextWidth(Instruction); aWidth := Canvas.TextWidth(DlgTitle);
if (aWidth > 300) or (Canvas.TextWidth(Content) > 300) or if (aWidth > 300) or (Canvas.TextWidth(DlgText) > 300) or
(Length(Buttons) > 40) then (Length(CustomButtons) > 40) then
aWidth := 480 else aWidth := 480 else
aWidth := 420; aWidth := 420;
end end
@ -717,31 +685,24 @@ begin
ClientWidth := aWidth; ClientWidth := aWidth;
Height := FirstRadioButtonIndex; Height := FirstRadioButtonIndex;
Caption := Title; Caption := DialogCaption;
// create a white panel for the main dialog part // create a white panel for the main dialog part
Panel := TPanel.Create(Self); SetupPanel;
Panel.Parent := Self; CurrParent := Panel;
Panel.Align := alTop;
Panel.BorderStyle := bsNone;
Panel.BevelOuter := bvNone;
if not (tfEmulateClassicStyle in FDlg.Flags) then begin
Panel.Color := clWindow;
end;
Par := Panel;
// handle main dialog icon // handle main dialog icon
SetupIcon(IconBorder, X, Y, Par); SetupIcon(IconBorder, X, Y, CurrParent);
// add main texts (Instruction, Content, Information) // add main texts (DlgTitle, DlgText, Information)
Element[tdeMainInstruction] := AddLabel(Instruction, True); Element[tdeMainInstruction] := AddLabel(DlgTitle, True);
Element[tdeContent] := AddLabel(Content, False); Element[tdeContent] := AddLabel(DlgText, False);
if (Info <> '') then if (ExpandedText <> '') then
// no information collapse/expand yet: it's always expanded // no information collapse/expand yet: it's always expanded
Element[tdeExpandedInfo] := AddLabel(Info, False); Element[tdeExpandedInfo] := AddLabel(ExpandedText, False);
// add radio buttons // add radio CustomButtons
if Radios<>'' then if Radios<>'' then
begin begin
(* (*
@ -755,19 +716,19 @@ begin
{$ENDIF} {$ENDIF}
*) *)
ARadioOffset := 1; ARadioOffset := 1;
AddRadios(ARadioOffSet, aWidth, aRadioDef, FontHeight, X, Y, Par); AddRadios(ARadioOffSet, aWidth, aRadioDef, FontHeight, X, Y, CurrParent);
end; end;
// add command links buttons // add command links CustomButtons
if (tfUseCommandLinks in FDlg.Flags) and (Buttons<>'') then if (tfUseCommandLinks in FDlg.Flags) and (CustomButtons<>'') then
AddCommandLinkButtons(X, Y, aWidth, aButtonDef, FontHeight, Par); AddCommandLinkButtons(X, Y, aWidth, aButtonDef, FontHeight, CurrParent);
(* (*
This needs expanding of TTaskDialogFlags and a new field Content in TTaskDialog. This needs expanding of TTaskDialogFlags and a new field DlgText in TTaskDialog.
Basically this code was never excuted from Dialogs.TTaskDialog Basically this code was never excuted from Dialogs.TTaskDialog
// add selection list or query editor // add selection list or query editor
@ -777,7 +738,7 @@ begin
try try
Combo := TComboBox.Create(self); Combo := TComboBox.Create(self);
with Combo do begin with Combo do begin
Parent := Par; Parent := CurrParent;
SetBounds(X,Y,aWidth-32-X,22); SetBounds(X,Y,aWidth-32-X,22);
if (tfQuery in FDlg.Flags) then if (tfQuery in FDlg.Flags) then
Style := csDropDown Style := csDropDown
@ -802,7 +763,7 @@ begin
Dialog.Form.Edit := TEdit.Create(Dialog.Form); Dialog.Form.Edit := TEdit.Create(Dialog.Form);
with Dialog.Form.Edit do with Dialog.Form.Edit do
begin begin
Parent := Par; Parent := CurrParent;
SetBounds(X,Y,aWidth-16-X,22); SetBounds(X,Y,aWidth-16-X,22);
Text := Query; Text := Query;
if tdfQueryMasked in aFlags then if tdfQueryMasked in aFlags then
@ -818,23 +779,22 @@ begin
// from now we won't add components to the white panel, but to the form // from now we won't add components to the white panel, but to the form
Panel.Height := Y; Panel.Height := Y;
Par := Self; CurrParent := Self;
// add buttons and verification checkbox XB := 0;
if (aCommonButtons <> []) or (Verify<>'') or // add CustomButtons and verification checkbox
((Buttons<>'') and not (tfUseCommandLinks in FDlg.Flags)) then if (CommonButtons <> []) or (VerificationText<>'') or
((CustomButtons<>'') and not (tfUseCommandLinks in FDlg.Flags)) then
begin begin
AddButtonsAndCheckBox(X, Y, XB, aWidth, aButtonDef, Par); AddButtonsAndCheckBox(X, Y, XB, aWidth, aButtonDef, CurrParent);
end end;
else
XB := 0;
// add footer text with optional icon // add FooterText text with optional icon
if (Footer <> '') then if (FooterText <> '') then
begin begin
if XB<>0 then if XB<>0 then
AddBevel AddBevel
@ -843,7 +803,7 @@ begin
if (LCL_FOOTERIMAGES[TF_FOOTERICON(FDlg.FooterIcon)]<>0) then if (LCL_FOOTERIMAGES[TF_FOOTERICON(FDlg.FooterIcon)]<>0) then
begin begin
Image := TImage.Create(Self); Image := TImage.Create(Self);
Image.Parent := Par; Image.Parent := CurrParent;
Image.Images := DialogGlyphs; Image.Images := DialogGlyphs;
Image.ImageWidth := 16; Image.ImageWidth := 16;
Image.ImageIndex := DialogGlyphs.DialogIcon[LCL_FOOTERIMAGES[TF_FOOTERICON(FDlg.FooterIcon)]]; Image.ImageIndex := DialogGlyphs.DialogIcon[LCL_FOOTERIMAGES[TF_FOOTERICON(FDlg.FooterIcon)]];
@ -853,11 +813,12 @@ begin
Image.Center := True; Image.Center := True;
Image.SetBounds(24,Y,16,16); Image.SetBounds(24,Y,16,16);
X := 40+Image.Width; X := 40+Image.Width;
end else end
else
begin begin
X := 24; X := 24;
end; end;
Element[tdeFooter] := AddLabel(Footer, False); Element[tdeFooter] := AddLabel(FooterText, False);
end; end;