mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 10:39:20 +02:00
LCLTaskDialog: use descriptive const instead of magic numbers.
This commit is contained in:
parent
a802987646
commit
02765cb9db
@ -799,6 +799,9 @@ var
|
|||||||
|
|
||||||
var
|
var
|
||||||
ARadioOffset: integer;
|
ARadioOffset: integer;
|
||||||
|
const
|
||||||
|
FirstButtonIndex = 100;
|
||||||
|
FirstRadioButtonIndex = 200;
|
||||||
begin
|
begin
|
||||||
if (byte(aCommonButtons)=0) and (Buttons='') then begin
|
if (byte(aCommonButtons)=0) and (Buttons='') then begin
|
||||||
aCommonButtons := [cbOk];
|
aCommonButtons := [cbOk];
|
||||||
@ -830,8 +833,8 @@ begin
|
|||||||
Config.pszMainInstruction := PWideChar(_WS(Inst));
|
Config.pszMainInstruction := PWideChar(_WS(Inst));
|
||||||
Config.pszContent := PWideChar(_WS(Content));
|
Config.pszContent := PWideChar(_WS(Content));
|
||||||
RUCount := 0;
|
RUCount := 0;
|
||||||
AddRU(Buttons,Config.cButtons,100);
|
AddRU(Buttons,Config.cButtons,FirstButtonIndex);
|
||||||
AddRU(Radios,Config.cRadioButtons,200);
|
AddRU(Radios,Config.cRadioButtons,FirstRadioButtonIndex);
|
||||||
if Config.cButtons>0 then
|
if Config.cButtons>0 then
|
||||||
Config.pButtons := @But[0];
|
Config.pButtons := @But[0];
|
||||||
if Config.cRadioButtons>0 then
|
if Config.cRadioButtons>0 then
|
||||||
@ -857,7 +860,7 @@ begin
|
|||||||
works correctly if nDefaultRadioButton does NOT point to a radiobutton in the pRadioButtons array.
|
works correctly if nDefaultRadioButton does NOT point to a radiobutton in the pRadioButtons array.
|
||||||
}
|
}
|
||||||
if not (tdfNoDefaultRadioButton in AFlags) then
|
if not (tdfNoDefaultRadioButton in AFlags) then
|
||||||
Config.nDefaultRadioButton := aRadioDef+200;
|
Config.nDefaultRadioButton := aRadioDef+FirstRadioButtonIndex;
|
||||||
Config.cxWidth := MulDiv(aWidth, 4, DialogBaseUnits); // cxWidth needed in "dialog units"
|
Config.cxWidth := MulDiv(aWidth, 4, DialogBaseUnits); // cxWidth needed in "dialog units"
|
||||||
Config.pfCallback := @TaskDialogCallbackProc;
|
Config.pfCallback := @TaskDialogCallbackProc;
|
||||||
Config.lpCallbackData := @self;
|
Config.lpCallbackData := @self;
|
||||||
@ -898,7 +901,7 @@ begin
|
|||||||
end else
|
end else
|
||||||
if aWidth<120 then aWidth := 120;
|
if aWidth<120 then aWidth := 120;
|
||||||
Dialog.Form.ClientWidth := aWidth;
|
Dialog.Form.ClientWidth := aWidth;
|
||||||
Dialog.Form.Height := 200;
|
Dialog.Form.Height := FirstRadioButtonIndex;
|
||||||
Dialog.Form.Caption := Title;
|
Dialog.Form.Caption := Title;
|
||||||
// create a white panel for the main dialog part
|
// create a white panel for the main dialog part
|
||||||
Panel := TPanel.Create(Dialog.Form);
|
Panel := TPanel.Create(Dialog.Form);
|
||||||
@ -1005,7 +1008,7 @@ begin
|
|||||||
Hint := aHint; // note shown as Hint
|
Hint := aHint; // note shown as Hint
|
||||||
end;
|
end;
|
||||||
inc(Y,Height+2);
|
inc(Y,Height+2);
|
||||||
ModalResult := i+100;
|
ModalResult := i+FirstButtonIndex;
|
||||||
OnClick := Dialog.Form.HandleEmulatedButtonClicked;
|
OnClick := Dialog.Form.HandleEmulatedButtonClicked;
|
||||||
if ModalResult=aButtonDef then
|
if ModalResult=aButtonDef then
|
||||||
Dialog.Form.ActiveControl := CommandLink;
|
Dialog.Form.ActiveControl := CommandLink;
|
||||||
@ -1085,7 +1088,7 @@ begin
|
|||||||
try
|
try
|
||||||
Text := SysUtils.trim(Buttons);
|
Text := SysUtils.trim(Buttons);
|
||||||
for i := Count-1 downto 0 do
|
for i := Count-1 downto 0 do
|
||||||
AddButton(Strings[i],i+100);
|
AddButton(Strings[i],i+FirstButtonIndex);
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
@ -1163,7 +1166,7 @@ begin
|
|||||||
RadioRes := 0;
|
RadioRes := 0;
|
||||||
for i := 0 to high(Rad) do
|
for i := 0 to high(Rad) do
|
||||||
if Rad[i].Checked then
|
if Rad[i].Checked then
|
||||||
RadioRes := i+200;
|
RadioRes := i+FirstRadioButtonIndex;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(Dialog.Form);
|
FreeAndNil(Dialog.Form);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user