-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathreadint.pas
executable file
·88 lines (70 loc) · 2.12 KB
/
readint.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
unit readint;
interface
uses
{$IFDEF FPC} LResources,{$ENDIF}
Buttons{only Lazarus?},SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin, types;
type
{ TReadIntForm }
TReadIntForm = class(TForm)
ReadIntEdit: TSpinEdit;
ReadIntLabel: TLabel;
OKBtn: TButton;
procedure FormCreate(Sender: TObject);
function GetInt(lStr: string; lMin,lDefault,lMax: integer): integer;
procedure OKBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ReadIntForm: TReadIntForm;
implementation
//uses nifti_img_view,{license,} MultiSlice, render;
{$IFDEF FPC} {$R *.lfm} {$ENDIF}
{$IFNDEF FPC}
{$R *.DFM}
{$ENDIF}
{$ifdef LCLCocoa}
uses mainunit, nsappkitext; //darkmode
{$ENDIF}
function TReadIntForm.GetInt(lStr: string; lMin,lDefault,lMax: integer): integer;
var
w,h: integer;
begin
ReadIntLabel.caption := lStr+' ['+inttostr(lMin)+'..'+inttostr(lMax)+']';
ReadIntEdit.AnchorSide[akLeft].Side := asrRight;
ReadIntEdit.AnchorSide[akLeft].Control := ReadIntLabel;
ReadIntEdit.Anchors := ReadIntEdit.Anchors + [akLeft];
ReadIntEdit.BorderSpacing.Left := 12;
ReadIntEdit.MinValue := lMin;
ReadIntEdit.MaxValue := lMax;
ReadIntEdit.Value := lDefault;
OKBtn.AnchorSide[akLeft].Side := asrRight;
OKBtn.AnchorSide[akLeft].Control := ReadIntLabel;
OKBtn.Anchors := OKBtn.Anchors + [akLeft];
OKBtn.BorderSpacing.Left := 12;
ReadIntForm.HandleNeeded;
ReadIntForm.GetPreferredSize(w,h);
ReadIntForm.Width:= w+12;
{$IFDEF LCLCocoa}
//ReadIntForm.PopupMode:= pmAuto; //see issue 33616
setThemeMode(ReadIntForm, gPrefs.DarkMode);
{$ENDIF}
ReadIntForm.ShowModal;
result := ReadIntEdit.Value;
end;
procedure TReadIntForm.FormCreate(Sender: TObject);
begin
//ScaleDPI(Self,48);
end;
procedure TReadIntForm.OKBtnClick(Sender: TObject);
begin
ReadIntForm.ModalResult := mrOK;
end;
initialization
{$IFDEF FPC}
// {$I readint.lrs}
{$ENDIF}
end.