Debian Codegraph @

builds/install/arch-specific/win32/FirebirdInstallGUIFunctions.inc

raw
1 (* Initial Developer's Public License.
2 The contents of this file are subject to the Initial Developer's Public
3 License Version 1.0 (the "License"). You may not use this file except
4 in compliance with the License. You may obtain a copy of the License at
5 http://www.ibphoenix.com?a=ibphoenix&page=ibp_idpl
6 Software distributed under the License is distributed on an "AS IS" basis,
7 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8 for the specific language governing rights and limitations under the
9 License.
10
11 The Original Code is copyright 2007 Paul Reeves.
12
13 The Initial Developer of the Original Code is Paul Reeves.
14
15 All Rights Reserved.
16
17 GUI related functions for the Firebird Installer.
18
19 o ResizeWizardFormHeight
20 - Change height of Wizard Form
21 - Adjust the position of each control to work in new height.
22
23 o ResizeWizardFormWidth
24 - Make form wider
25
26 o MoveOuterNoteBook
27 - Move OuterNotebook and Bevel.
28 Value moved should match value passed to ResizeWizardFormWidth.
29
30 o EnumerateObjectList;
31 - Simple demonstration of object enumeration.
32
33 o Show Help
34 - CreateHelpDlg;
35 - ShowHelpDlg: Integer;
36 - CloseHelpDlg;
37
38 o Show some debug info for debugging inno setup script
39 - CreateDebugDlg
40 - CloseDebugDlg;
41 - ShowDebugDlg
42
43 *)
44
45 var
46 CompGroup1Array: array of string;
47 CompGroup2Array: array of string;
48 CompGroup3Array: array of string;
49 CompGroupButtonsArray: array of string;
50 CompGroup1, CompGroup2, CompGroup3, CompGroupButtons: TStringList;
51
52 // This is a non-exhaustive list of components that need to be repositioned
53 // and/or resized if the form size is changed. Use EnumerateObjectList to
54 // get a full list of components.
55 procedure SetupWizardFormComponentsArrays;
56 var
57 i: integer;
58 begin
59
60 SetArrayLength(CompGroup1Array,24);
61
62 CompGroup1Array[0]:='WelcomePage';
63 CompGroup1Array[1]:='WelcomeLabel2';
64 CompGroup1Array[2]:='InnerPage';
65 CompGroup1Array[3]:='InnerNotebook';
66 CompGroup1Array[4]:='LicensePage';
67 CompGroup1Array[5]:='LicenseMemo';
68 CompGroup1Array[6]:='PasswordPage';
69 CompGroup1Array[7]:='InfoBeforePage';
70 CompGroup1Array[8]:='InfoBeforeMemo';
71 CompGroup1Array[9]:='UserInfoPage';
72 CompGroup1Array[10]:='SelectDirPage';
73 CompGroup1Array[11]:='SelectComponentsPage';
74 CompGroup1Array[12]:='ComponentsList';
75 CompGroup1Array[13]:='SelectProgramGroupPage';
76 CompGroup1Array[14]:='SelectTasksPage';
77 CompGroup1Array[15]:='TasksList';
78 CompGroup1Array[16]:='ReadyPage';
79 CompGroup1Array[17]:='ReadyMemo';
80 CompGroup1Array[18]:='PreparingPage';
81 CompGroup1Array[19]:='InstallingPage';
82 CompGroup1Array[20]:='InfoAfterPage';
83 CompGroup1Array[21]:='InfoAfterMemo';
84 CompGroup1Array[22]:='FinishedPage';
85 CompGroup1Array[23]:='OuterNotebook';
86
87 CompGroup1 := TStringList.create;
88
89 for i := 0 to GetArrayLength( CompGroup1Array )-1 do begin
90 CompGroup1.add( CompGroup1Array[i] );
91 CompGroup1.objects[i] := (WizardForm.FindComponent(CompGroup1Array[i]));
92 end;
93
94 SetArrayLength(CompGroup2Array,8);
95 CompGroup2Array[0] := 'Bevel';
96 CompGroup2Array[1] := 'BeveledLabel';
97 CompGroup2Array[2] := 'LicenseAcceptedRadio';
98 CompGroup2Array[3] := 'LicenseNotAcceptedRadio';
99 CompGroup2Array[4] := 'DiskSpaceLabel';
100 CompGroup2Array[5] := 'ComponentsDiskSpaceLabel';
101 CompGroup2Array[6] := 'NoIconsCheck';
102 CompGroup2Array[7] := 'RunList';
103
104 CompGroup2 := TStringList.create;
105 for i := 0 to GetArrayLength( CompGroup2Array )-1 do begin
106 CompGroup2.add(CompGroup2Array[i]);
107 CompGroup2.objects[i] := (WizardForm.FindComponent(CompGroup2Array[i]));
108 end;
109
110 SetArrayLength(CompGroup3Array,1);
111 CompGroup3Array[0] := 'WizardBitmapImage';
112 CompGroup3 := TStringList.create;
113 for i:=0 to GetArrayLength(CompGroup3Array)-1 do begin
114 CompGroup3.add(CompGroup3Array[i]);
115 CompGroup3.objects[i] := (WizardForm.FindComponent(CompGroup3Array[i]));
116 end;
117
118 SetArrayLength(CompGroupButtonsArray,3);
119 CompGroupButtonsArray[0] := 'BackButton';
120 CompGroupButtonsArray[1] := 'NextButton';
121 CompGroupButtonsArray[2] := 'CancelButton';
122 CompGroupButtons := TStringList.create;
123 for i:=0 to GetArrayLength(CompGroupButtonsArray)-1 do begin
124 CompGroupButtons.add(CompGroupButtonsArray[i]);
125 CompGroupButtons.objects[i] := (WizardForm.FindComponent(CompGroupButtonsArray[i]));
126 end;
127
128 end;
129
130 procedure ResizeWizardFormHeight(AValue: Integer);
131 var
132 i: integer;
133 begin
134 wizardform.height := wizardform.height+AValue;
135 wizardform.top := wizardform.top - (AValue div 2);
136
137 // Group 1 - reset height of components
138 for i:=0 to GetArrayLength(CompGroup1Array)-1 do
139 TControl(CompGroup1.objects[i]).height := TControl(CompGroup1.objects[i]).height + Avalue;
140
141 // Group 2 - reset top of components
142 for i:=0 to GetArrayLength(CompGroup2Array)-1 do
143 TControl(CompGroup2.objects[i]).top := TControl(CompGroup2.objects[i]).top + AValue;
144
145 // Group 3 - reset top of components but keep 'centered' vertically.
146 for i:=0 to GetArrayLength(CompGroup3Array)-1 do
147 TControl( CompGroup3.objects[i]).top := TControl(CompGroup3.objects[i]).top + (AValue div 2);
148
149 // Group Buttons - reset top of components
150 for i:=0 to GetArrayLength(CompGroupButtonsArray)-1 do
151 TControl(CompGroupButtons.objects[i]).top := TControl(CompGroupButtons.objects[i]).top + AValue;
152
153 end;
154
155
156 // This needs more work. for now it is not used by the installer.
157 procedure ResizeWizardFormWidth(AValue: Integer);
158 var
159 i: integer;
160 begin
161 wizardform.width := wizardform.width + AValue;
162 wizardform.left := wizardform.left - (AValue div 2);
163
164 // Group 1 - reset width of components
165 for i:=0 to GetArrayLength(CompGroup1Array)-1 do begin
166 TControl(CompGroup1.objects[i]).width := TControl(CompGroup1.objects[i]).width + Avalue;
167 // TControl(CompGroup1.objects[i]).left := TControl(CompGroup1.objects[i]).left + (Avalue div 2);
168 end;
169
170 // Group 2 - reset left of components
171 for i:=0 to GetArrayLength(CompGroup2Array)-1 do begin
172 TControl(CompGroup2.objects[i]).left := TControl(CompGroup2.objects[i]).left + AValue;
173 TControl(CompGroup2.objects[i]).width := TControl(CompGroup2.objects[i]).width + (AValue div 2);
174 end;
175
176 // Group 3 - reset left of components but keep 'centered' horizontally.
177 // for i:=0 to GetArrayLength(CompGroup3Array)-1 do
178 // TControl( CompGroup3.objects[i]).left := TControl(CompGroup3.objects[i]).left - (AValue div 2);
179
180 // Group 4 - reset left of buttons
181 for i:=0 to GetArrayLength(CompGroupButtonsArray)-1 do begin
182 TControl(CompGroupButtons.objects[i]).left := TControl(CompGroupButtons.objects[i]).left + AValue;
183 end;
184
185 end;
186
187 procedure MoveOuterNoteBookRight(AValue: Integer);
188 begin
189 with wizardform do begin
190 OuterNotebook.left := wizardform.OuterNotebook.left + AValue;
191 Bevel.left := Bevel.left + AValue;
192 end;
193 end;
194
195 procedure MoveOuterNoteBookLeft(AValue: Integer);
196 begin
197 with wizardform do begin
198 OuterNotebook.left := wizardform.OuterNotebook.left - AValue;
199 Bevel.left := Bevel.left - AValue;
200 end;
201 end;
202
203 const
204 group1 = ' group one';
205 group2 = ' group two';
206 group3 = ' group three';
207 group4 = ' group not allocated.';
208
209 procedure EnumerateObjectList;
210 //Walk through the components on the InnoSetup install wizard
211 var
212 Alist: TStringList;
213 i: integer;
214 aComponent: string;
215
216 begin
217 Alist := TStringList.create;
218 for i := 0 to WizardForm.ComponentCount -1 do begin
219 aComponent := WizardForm.Components[i].name;
220 if CompGroup1.IndexOf( aComponent ) > -1 then
221 aComponent := aComponent + group1
222 else if CompGroup2.IndexOf( aComponent ) > -1 then
223 aComponent := aComponent + group2
224 else if CompGroup3.IndexOf( aComponent ) > -1 then
225 aComponent := aComponent + group3
226 else
227 aComponent := aComponent + group4;
228
229
230 AList.add( aComponent );
231 end;
232 WizardForm.INFOBEFOREMEMO.lines.assign(Alist);
233 end;
234
235
236 var
237 HelpDlg: TForm;
238
239 procedure CreateHelpDlg;
240 var
241 HelpFileName: String;
242 HelpMemo: TMemo;
243 OKButton: TButton;
244 begin
245 ExtractTemporaryFile ('installation_scripted.txt');
246 HelpFileName := ExpandConstant ('{tmp}\installation_scripted.txt');
247 HelpDlg := TForm.create(nil);
248 with HelpDlg do begin
249 BorderStyle := bsDialog;
250 Position := poScreenCenter;
251 ClientWidth := 450;
252 ClientHeight := 550;
253 Caption := 'Firebird Installation - command-line parameters.';
254 end;
255 HelpMemo := TMemo.Create(HelpDlg);
256 with HelpMemo do begin
257 Parent := HelpDlg;
258 ScrollBars := ssVertical;
259 Lines.LoadFromFile(HelpFileName);
260 Align := alTop;
261 Height := 500;
262 ReadOnly := True;
263 end;
264 OKButton := TButton.create(HelpDlg);
265 with OKButton do begin
266 Parent := HelpDlg;
267 Left := (Parent.width div 2) - width div 2;
268 top := Parent.ClientHeight - 40;
269 Caption := 'OK';
270 ModalResult := mrOK;
271 end;
272 HelpDlg.ActiveControl := OKButton;
273 end;
274
275
276 procedure CloseHelpDlg;
277 begin
278 with HelpDlg do begin
279 Close;
280 Free;
281 end;
282 end;
283
284
285 function ShowHelpDlg: Integer;
286 begin
287 CreateHelpDlg;
288 result := HelpDlg.ShowModal;
289 CloseHelpDlg;
290 end;
291
292
293 // Add a simple debug dialogue
294 var
295 DebugDlg: TForm;
296
297 procedure CreateDebugDlg(aString: String; ADescription: String);
298 var
299 DebugText: TMemo;
300 // DebugDescription: TLabel;
301 OKButton: TButton;
302 begin
303 DebugDlg := TForm.create(nil);
304 with DebugDlg do begin
305 BorderStyle := bsSizeable;
306 Position := poScreenCenter;
307 ClientWidth := 450;
308 ClientHeight := 350;
309 Caption := 'Firebird Installation - command-line parameters.';
310 end;
311 DebugText := TMemo.Create(DebugDlg);
312 with DebugText do begin
313 Parent := DebugDlg;
314 ScrollBars := ssVertical;
315 Lines.Text :=aString;
316 Align := alTop;
317 Height := 200;
318 ReadOnly := True;
319 end;
320 OKButton := TButton.create(DebugDlg);
321 with OKButton do begin
322 Parent := DebugDlg;
323 Left := (Parent.width div 2) - width div 2;
324 top := Parent.ClientHeight - 40;
325 Caption := 'OK';
326 ModalResult := mrOK;
327 end;
328 DebugDlg.ActiveControl := OKButton;
329
330 end;
331
332
333 procedure CloseDebugDlg;
334 begin
335 with DebugDlg do begin
336 Close;
337 Free;
338 end;
339 end;
340
341
342 function ShowDebugDlg(aString: String; aDescription: String): Integer;
343 begin
344 CreateDebugDlg(aString,aDescription);
345 result := DebugDlg.ShowModal;
346 CloseDebugDlg;
347 end;
348
349
350 procedure CreateAdminUserPage;
351
352 begin
353
354 AdminUserPage := CreateInputQueryPage(wpSelectTasks,
355 ExpandConstant( '{cm:CreateSYSDBAPassword}' )
356 , ExpandConstant( '{cm:ClickThroughPWCreation}' ) + #13#10 +
357 ExpandConstant( '{cm:PasswordNote}' ) , '' );
358 AdminUserPage.Add( ExpandConstant( '{cm:SYSDBAPassword}' ), True);
359 AdminUserPage.Add( ExpandConstant( '{cm:RetypeSYSDBAPassword}' ), True);
360
361 AdminUserPage.Values[0] := SYSDBAPassword;
362 AdminUserPage.Values[1] := SYSDBAPassword;
363
364 end;
365
366
367 procedure DonateButtonOnClick(Sender: TObject);
368 var
369 ErrorCode: Integer;
370 begin
371 ShellExecAsOriginalUser('open', 'https://firebirdsql.org/en/donate/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
372 end;
373
374
375 procedure CreateDonorPage;
376 var
377 DonorText: AnsiString;
378
379 begin
380
381 // NOTE - The rtf must be pasted as a single line in the custom_messages.inc for the translated language. When removomg the EOLs pay attention that \par is always followed by a space.
382 (*
383 {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\colortbl ;\red0\green0\blue255;}{\*\generator Riched20 10.0.17763}\viewkind4\uc1\pard\sa200\sl276\slmult1\qj\f0\fs24\lang9 Firebird has empowered users worldwide with its reliable and powerful database capabilities, thanks to years of dedicated development and community collaboration.\par \pard\li568\ri568\sa200\sl240\slmult1\qj\par \pard\sa200\sl276\slmult1\qj To ensure Firebird\rquote s continued growth and advancement, we invite you to {{\field{\*\fldinst{HYPERLINK "https://firebirdsql.org/en/donate"}}{\fldrslt{\ul\cf1 make a donation}}}}\f0\fs24 through the Firebird Foundation. Your generous contributions help fund ongoing development, maintain critical infrastructure, and expand the features you rely on. Additionally, our affordable subscriptions offer exclusive benefits designed to enhance your Firebird experience.\par \par Every contribution, big or small, plays a vital role in keeping Firebird innovative and robust for everyone.\par \par Visit our {{\field{\*\fldinst{HYPERLINK https://firebirdsql.org/en/firebird-foundation/ }}{\fldrslt{website\ul0\cf0}}}}\f0\fs24 to explore how you can contribute to this mission and help ensure Firebird\rquote s bright future. Thank you for being a valued part of the Firebird community!\par };
384 *)
385
386 DonorPage := CreateCustomPage( wpInfoAfter, 'Support Firebird Development', '');
387 // For testing place it after the welcome page
388 // DonorPage := CreateCustomPage( wpWelcome, 'Support Firebird Development', '');
389
390 DonorText := ExpandConstant('{cm:DonorPage}');
391
392 RichEditViewer := TRichEditViewer.Create(DonorPage);
393 RichEditViewer.Width := DonorPage.SurfaceWidth;
394 RichEditViewer.Height := DonorPage.SurfaceHeight;
395 RichEditViewer.Anchors := [akLeft, akTop, akRight, akBottom];
396 RichEditViewer.BevelKind := bkNone;
397 RichEditViewer.BorderStyle := bsNone;
398 RichEditViewer.Parent := DonorPage.Surface;
399 RichEditViewer.ScrollBars := ssNone;
400 RichEditViewer.UseRichEdit := True;
401 RichEditViewer.RTFText := DonorText;
402 RichEditViewer.ReadOnly := True;
403
404 DonateButton := TNewButton.Create(WizardForm);
405 DonateButton.Left := 10;
406 DonateButton.Top := WizardForm.CancelButton.Top;
407 // NOTE - If adding new translations be sure to check that this button is wide enough
408 // for the translation of 'Donate Now'.
409 DonateButton.Width := WizardForm.CancelButton.Width + 40;
410 DonateButton.Height := WizardForm.CancelButton.Height;
411 DonateButton.Anchors := [akLeft, akBottom];
412 DonateButton.Caption := ExpandConstant('{cm:DonateNow}');
413 DonateButton.OnClick := @DonateButtonOnClick;
414 DonateButton.Parent := WizardForm;
415 DonateButton.Visible := False;
416
417 end;
418
419