forked from geraldholdsworth/DiscImageManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAFSPartitionUnit.pas
150 lines (131 loc) · 4.74 KB
/
AFSPartitionUnit.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
unit AFSPartitionUnit;
{$mode objfpc}{$H+}
interface
uses
Classes,SysUtils,Forms,Controls,Graphics,Dialogs,ComCtrls,StdCtrls,ExtCtrls,
GJHCustomComponents;
type
{ TAFSPartitionForm }
TAFSPartitionForm = class(TForm)
OpenDFSFile: TOpenDialog;
PartitionSizeLabel: TLabel;
PartitionSize: TGJHSlider;
rad_type40T,
rad_type80T,
rad_typeAFS,
rad_typeDOS: TGJHRadioBox;
FromFileButton,
OKButton,
CancelButton: TGJHButton;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure PartitionSizeChange(Sender: TObject);
procedure rad_typeClick(Sender: TObject);
procedure FromFileClick(Sender: TObject);
private
public
maxAFSSize,
maxDOSSize : Cardinal;
fromFile : Boolean;
end;
var
AFSPartitionForm: TAFSPartitionForm;
implementation
uses MainUnit;
{$R *.lfm}
{ TAFSPartitionForm }
{------------------------------------------------------------------------------}
//Update the size label
{------------------------------------------------------------------------------}
procedure TAFSPartitionForm.PartitionSizeChange(Sender: TObject);
begin
PartitionSizeLabel.Caption:=FloatToStr((PartitionSize.Position*$100)/1024)+'KB';
end;
{------------------------------------------------------------------------------}
//Ensure we don't create anything bigger than the FS can handle
{------------------------------------------------------------------------------}
procedure TAFSPartitionForm.rad_typeClick(Sender: TObject);
begin
if rad_typeAFS.Ticked then PartitionSize.Max:=maxAFSSize;
if rad_typeDOS.Ticked then PartitionSize.Max:=maxDOSSize;
end;
{------------------------------------------------------------------------------}
//Tile the form
{------------------------------------------------------------------------------}
procedure TAFSPartitionForm.FormPaint(Sender: TObject);
begin
MainForm.FileInfoPanelPaint(Sender);
end;
{------------------------------------------------------------------------------}
//Create the form
{------------------------------------------------------------------------------}
procedure TAFSPartitionForm.FormCreate(Sender: TObject);
function CreateRadioBox(text: String): TGJHRadioBox;
begin
Result:=TGJHRadioBox.Create(AFSPartitionForm as TControl);
Result.Parent:=AFSPartitionForm as TWinControl;
Result.Top:=PartitionSize.Top+PartitionSize.Height;
Result.Visible:=True;
Result.Caption:=text;
Result.OnClick:=@rad_typeClick;
Result.Font.Color:=clBlack;
end;
var
ratio : Real;
begin
ratio:=PixelsPerInch/DesignTimePPI;
//Create the slider
PartitionSize:=TGJHSlider.Create(AFSPartitionForm as TControl);
PartitionSize.Parent:=AFSPartitionForm as TWinControl;
PartitionSize.Top:=PartitionSizeLabel.Height;
PartitionSize.Align:=alTop;
PartitionSize.Orientation:=csHorizontal;
PartitionSize.Height:=Round(30*ratio);
PartitionSize.Min:=0;
PartitionSize.Max:=10;
PartitionSize.Pointers:=False;
PartitionSize.Outline:=csOutInner;
PartitionSize.OnChange:=@PartitionSizeChange;
PartitionSize.Font.Color:=clBlack;
//Create the radio boxes
rad_typeAFS:=CreateRadioBox('Acorn File Server');
rad_typeDOS:=CreateRadioBox('DOS Plus');
rad_type40T:=CreateRadioBox('40 Track');
rad_type80T:=CreateRadioBox('80 Track');
//Create the buttons
FromFileButton:=MainForm.CreateButton(AFSPartitionForm as TControl,
'From File...',False,Round(8*ratio),
rad_typeAFS.Top+rad_typeAFS.Height+Round(8*ratio),
mrNone);
FromFileButton.Enabled:=False;
FromFileButton.OnClick:=@FromFileClick;
CancelButton:=MainForm.CreateButton(AFSPartitionForm as TControl,'Cancel',
False,
FromFileButton.Left+FromFileButton.Width+Round(8*ratio),
FromFileButton.Top,mrCancel);
OKButton:=MainForm.CreateButton(AFSPartitionForm as TControl,'OK',True,
CancelButton.Left+CancelButton.Width+Round(8*ratio),
FromFileButton.Top-Round(4*ratio),mrOK);
Width:=OKButton.Left+OKButton.Width+8;
//Adjust the radio button positions
rad_typeAFS.Left:=Round(8*ratio);
rad_typeDOS.Left:=Width div 2;
rad_type40T.Left:=rad_typeAFS.Left;
rad_type80T.Left:=rad_typeDOS.Left;
//Adjust the form height
Height:=OKButton.Top+OKButton.Height+Round(8*ratio);
end;
{------------------------------------------------------------------------------}
//User clicked on 'From File'
{------------------------------------------------------------------------------}
procedure TAFSPartitionForm.FromFileClick(Sender: TObject);
begin
FromFileButton.ModalResult:=mrNone;
//Currently only for adding DFS image
if OpenDFSFile.Execute then
begin
fromFile:=True;
FromFileButton.ModalResult:=mrOK;
end;
end;
end.