forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompStartup.pas
174 lines (147 loc) · 4.86 KB
/
CompStartup.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
unit CompStartup;
{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Compiler IDE Startup form
}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
UIStateForm, StdCtrls, ExtCtrls;
type
TStartupFormResult = (srNone, srEmpty, srWizard, srOpenFile, srOpenDialog,
srOpenDialogExamples);
TStartupForm = class(TUIStateForm)
OKButton: TButton;
CancelButton: TButton;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
EmptyRadioButton: TRadioButton;
WizardRadioButton: TRadioButton;
OpenRadioButton: TRadioButton;
OpenListBox: TListBox;
StartupCheck: TCheckBox;
NewImage: TImage;
OpenImage: TImage;
DonateImage: TImage;
MailingListImage: TImage;
procedure RadioButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DblClick_(Sender: TObject);
procedure OpenListBoxClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
procedure DonateImageClick(Sender: TObject);
procedure MailingListImageClick(Sender: TObject);
private
FResult: TStartupFormResult;
FResultMainFileName: TFileName;
procedure SetMRUFilesList(const MRUFilesList: TStringList);
procedure UpdateImages;
protected
procedure CreateWnd; override;
procedure CreateParams(var Params: TCreateParams); override;
public
property MRUFilesList: TStringList write SetMRUFilesList;
property Result: TStartupFormResult read FResult;
property ResultMainFileName: TFileName read FResultMainFileName;
end;
implementation
uses
CompMsgs, CmnFunc, CmnFunc2, CompFunc, CompForm, ComCtrls;
{$R *.DFM}
procedure TStartupForm.SetMRUFilesList(const MRUFilesList: TStringList);
begin
OpenListBox.Items.AddStrings(MRUFilesList);
UpdateHorizontalExtent(OpenListBox);
end;
procedure TStartupForm.UpdateImages;
function GetImage(const Button: TToolButton; const WH: Integer): TWICImage;
begin
Result := CompileForm.LightToolBarImageCollection.GetSourceImage(Button.ImageIndex, WH, WH)
end;
var
WH: Integer;
begin
{ After a DPI change the button's Width and Height isn't yet updated, so calculate it ourselves }
WH := MulDiv(16, CurrentPPI, 96);
NewImage.Picture.Graphic:= GetImage(CompileForm.NewMainFileButton, WH);
OpenImage.Picture.Graphic := GetImage(CompileForm.OpenMainFileButton, WH);
end;
procedure TStartupForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
begin
UpdateImages;
end;
procedure TStartupForm.FormCreate(Sender: TObject);
begin
FResult := srNone;
InitFormFont(Self);
UpdateImages;
OpenListBox.Items.Add(SCompilerExampleScripts);
OpenListBox.Items.Add(SCompilerMoreFiles);
OpenListBox.ItemIndex := 0;
UpdateHorizontalExtent(OpenListBox);
ActiveControl := OpenRadioButton;
end;
{ This and CreateParams make bsSizeable (which has an unwanted icon) look like bsDialog, see:
https://stackoverflow.com/questions/32096482/delphi-resizable-bsdialog-form/32098633 }
procedure TStartupForm.CreateWnd;
begin
inherited;
SendMessage(Handle, WM_SETICON, ICON_BIG, 0);
end;
procedure TStartupForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
end;
procedure TStartupForm.RadioButtonClick(Sender: TObject);
begin
EmptyRadioButton.Checked := Sender = EmptyRadioButton;
WizardRadioButton.Checked := Sender = WizardRadioButton;
OpenRadioButton.Checked := Sender = OpenRadioButton;
if Sender = OpenRadioButton then begin
if OpenListBox.ItemIndex = -1 then
OpenListBox.ItemIndex := 0;
end
else
OpenListBox.ItemIndex := -1;
end;
procedure TStartupForm.DblClick_(Sender: TObject);
begin
if OkButton.Enabled then
OkButton.Click;
end;
procedure TStartupForm.OpenListBoxClick(Sender: TObject);
begin
OpenRadioButton.Checked := True;
end;
procedure TStartupForm.DonateImageClick(Sender: TObject);
begin
OpenDonateSite;
end;
procedure TStartupForm.MailingListImageClick(Sender: TObject);
begin
OpenMailingListSite;
end;
procedure TStartupForm.OKButtonClick(Sender: TObject);
begin
if EmptyRadioButton.Checked then
FResult := srEmpty
else if WizardRadioButton.Checked then
FResult := srWizard
else { if OpenRadioButton.Checked then } begin
if OpenListBox.ItemIndex = 0 then
FResult := srOpenDialogExamples
else if OpenListBox.ItemIndex > 1 then begin
FResult := srOpenFile;
FResultMainFileName := OpenListBox.Items[OpenListBox.ItemIndex];
end else
FResult := srOpenDialog;
end;
end;
end.