Menu

[327ada]: / Source / EnviroFrm.pas  Maximize  Restore  History

Download this file

511 lines (442 with data), 16.7 kB

  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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
{
This file is part of Dev-C++
Copyright (c) 2004 Bloodshed Software
Dev-C++ is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Dev-C++ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Dev-C++; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit EnviroFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, ExtCtrls, ExtDlgs, Buttons,
CheckLst, Grids, ValEdit, ComCtrls, vcl.Themes, Vcl.BaseImageCollection,
Vcl.ImageCollection, Vcl.VirtualImage, System.ImageList, Vcl.ImgList;
type
TEnviroForm = class(TForm)
dlgPic: TOpenPictureDialog;
btnOk: TBitBtn;
btnCancel: TBitBtn;
btnHelp: TBitBtn;
PagesMain: TPageControl;
tabGeneral: TTabSheet;
lblMRU: TLabel;
lblMsgTabs: TLabel;
lblLang: TLabel;
lblTheme: TLabel;
cbBackups: TCheckBox;
cbMinOnRun: TCheckBox;
cbDefCpp: TCheckBox;
cbShowBars: TCheckBox;
cbMultiLineTab: TCheckBox;
rgbAutoOpen: TRadioGroup;
gbDebugger: TGroupBox;
cbWatchHint: TCheckBox;
gbProgress: TGroupBox;
cbShowProgress: TCheckBox;
cbAutoCloseProgress: TCheckBox;
seMRUMax: TSpinEdit;
cboTabsTop: TComboBox;
cboLang: TComboBox;
cboTheme: TComboBox;
tabPaths: TTabSheet;
lblUserDir: TLabel;
lblTemplatesDir: TLabel;
lblSplash: TLabel;
lblIcoLib: TLabel;
lblLangPath: TLabel;
btnDefBrws: TSpeedButton;
btnOutputbrws: TSpeedButton;
btnBrwIcon: TSpeedButton;
btnBrwLang: TSpeedButton;
btnBrwSplash: TSpeedButton;
edUserDir: TEdit;
edTemplatesDir: TEdit;
edSplash: TEdit;
edIcoLib: TEdit;
edLang: TEdit;
tabExternal: TTabSheet;
lblExternal: TLabel;
btnExtAdd: TSpeedButton;
btnExtDel: TSpeedButton;
vleExternal: TValueListEditor;
tabAssocs: TTabSheet;
lblAssocFileTypes: TLabel;
lblAssocDesc: TLabel;
lstAssocFileTypes: TCheckListBox;
cbPauseConsole: TCheckBox;
cbCheckAssocs: TCheckBox;
edOptionsDir: TEdit;
lblOptionsDir: TLabel;
btnResetDev: TButton;
TabAppearance: TTabSheet;
LblStyle: TLabel;
UIfontlabel: TLabel;
cbUIfont: TComboBox;
cbUIfontsize: TComboBox;
ListBoxStyle: TListBox;
lblSize: TLabel;
Panel1: TPanel;
Button1: TButton;
ComboBox1: TComboBox;
CheckBox1: TCheckBox;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Button2: TButton;
Button3: TButton;
RadioGroup1: TRadioGroup;
procedure BrowseClick(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure btnHelpClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure vleExternalEditButtonClick(Sender: TObject);
procedure vleExternalValidate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: string);
procedure btnExtAddClick(Sender: TObject);
procedure btnExtDelClick(Sender: TObject);
procedure cbUIfontDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure cbUIfontsizeDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure cbUIfontsizeChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnResetDevClick(Sender: TObject);
procedure ListBoxStyleClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
private
procedure LoadText;
end;
implementation
uses
System.UITypes, ShellAPI, Filectrl, devcfg, MultiLangSupport, version, DataFrm, utils, FileAssocs, ImageTheme, main,
StrUtils;
{$R *.dfm}
procedure TEnviroForm.BrowseClick(Sender: TObject);
var
s: String;
begin
case TComponent(Sender).Tag of
1: {// default dir browse} begin
s := edUserDir.Text;
if NewSelectDirectory(Lang[ID_ENV_SELUSERDIR], '', s) then
edUserDir.Text := IncludeTrailingPathDelimiter(s);
end;
2: {// output dir browse} begin
s := ExpandFileto(edTemplatesDir.Text, devDirs.Exec);
if NewSelectDirectory(Lang[ID_ENV_SELTEMPLATESDIR], '', s) then
edTemplatesDir.Text := IncludeTrailingPathDelimiter(s);
end;
3: {// icon library browse} begin
s := ExpandFileto(edIcoLib.Text, devDirs.Exec);
if NewSelectDirectory(Lang[ID_ENV_SELICOLIB], '', s) then
edIcoLib.Text := IncludeTrailingPathDelimiter(s);
end;
4: {// splash screen browse} begin
dlgPic.InitialDir := ExtractFilePath(edSplash.Text);
if dlgPic.Execute then
edSplash.Text := dlgPic.FileName;
end;
5: {// Language Dir} begin
s := ExpandFileto(edLang.Text, devDirs.Exec);
if NewSelectDirectory(Lang[ID_ENV_SELLANGDIR], '', s) then
edLang.Text := IncludeTrailingPathDelimiter(ExtractRelativePath(devDirs.Exec, s));
end;
end;
end;
procedure TEnviroForm.btnOkClick(Sender: TObject);
var
I: integer;
s: String;
begin
with devData do begin
DefCpp := cbDefCpp.Checked;
ShowBars := cbShowBars.Checked;
MultiLineTab := cbMultiLineTab.Checked;
BackUps := cbBackups.Checked;
MinOnRun := cbMinOnRun.Checked;
ConsolePause := cbPauseConsole.Checked;
CheckAssocs := cbCheckAssocs.Checked;
MRUMax := seMRUMax.Value;
if not MultiLineTab then begin
if cboTabsTop.ItemIndex in [2, 3] then begin
MessageBox(application.handle, PChar(Lang[ID_ENV_MULTILINETABERROR]), PChar(Lang[ID_ERROR]), MB_OK);
cboTabsTop.ItemIndex := 0;
end;
end;
MsgTabs := TTabPosition(cboTabsTop.ItemIndex);
AutoOpen := rgbAutoOpen.ItemIndex;
Splash := edSplash.Text;
s := Lang.FileFromDescription(cboLang.Text);
LangChange := s <> Language;
Language := s;
ThemeChange := cboTheme.Text <> devData.Theme;
Theme := 'NewLook'; //cboTheme.Text;
ShowProgress := cbShowProgress.Checked;
AutoCloseProgress := cbAutoCloseProgress.Checked;
WatchHint := cbWatchHint.Checked;
InterfaceFont := cbUIFont.Text;
InterfaceFontSize := StrToIntDef(cbUIfontsize.Text, 9);
//Set Delphi Style
StyleChange := ListBoxStyle.ItemIndex <> devData.Style;
Style := ListBoxStyle.ItemIndex;
if Style > 0 then
TStyleManager.TrySetStyle(cDelphiStyle[Style]);
end;
MainForm.Font.Name := devData.InterfaceFont;
MainForm.Font.Size := devData.InterfaceFontSize;
try
// Force update
for I := 0 to AssociationsCount - 1 do
if lstAssocFileTypes.Checked[I] then
Associate(I)
else
Unassociate(I);
except
MessageBox(application.handle, PChar(Lang[ID_ENV_UACERROR]), PChar(Lang[ID_ERROR]), MB_OK);
devData.CheckAssocs := false; // don't bother the user again on next startup
end;
devDirs.Icons := IncludeTrailingPathDelimiter(ExpandFileto(edIcoLib.Text, devDirs.Exec));
devDirs.Templates := IncludeTrailingPathDelimiter(ExpandFileto(edTemplatesDir.Text, devDirs.Exec));
devDirs.Default := edUserDir.Text;
if edLang.Text <> ExtractRelativePath(devDirs.Exec, devDirs.Lang) then begin
devDirs.Lang := IncludeTrailingPathDelimiter(ExpandFileto(edLang.Text, devDirs.Exec));
Lang.CheckLanguageFiles;
end;
devExternalPrograms.Programs.Assign(vleExternal.Strings);
end;
procedure TEnviroForm.ListBoxStyleClick(Sender: TObject);
begin
Panel1.StyleName := cDelphiStyle[ListBoxStyle.ItemIndex];
Panel1.Repaint;
for var I := 0 to Panel1.ControlCount-1 do
Panel1.Controls[i].Repaint;
end;
procedure TEnviroForm.LoadText;
begin
// Set interface font
Font.Name := devData.InterfaceFont;
Font.Size := devData.InterfaceFontSize;
Caption := Lang[ID_ENV];
//Tabs
tabGeneral.Caption := Lang[ID_ENV_GENTAB];
tabPaths.Caption := Lang[ID_ENV_PATHTAB];
tabAssocs.Caption := Lang[ID_ENV_FASSTAB];
tabExternal.Caption := Lang[ID_ENV_EXTERNALS];
//Buttons
btnOk.Caption := Lang[ID_BTN_OK];
btnCancel.Caption := Lang[ID_BTN_CANCEL];
btnHelp.Caption := Lang[ID_BTN_HELP];
//Controls
cbDefCpp.Caption := Lang[ID_ENV_DEFCPP];
cbShowBars.Caption := Lang[ID_ENV_SHOWBARS];
cbMultiLineTab.Caption := Lang[ID_ENV_MULTILINETABS];
cbBackups.Caption := Lang[ID_ENV_BACKUPS];
cbMinOnRun.Caption := Lang[ID_ENV_MINONRUN];
cbPauseConsole.Caption := Lang[ID_ENV_PAUSECONSOLE];
cbCheckAssocs.Caption := Lang[ID_ENV_CHECKASSOCS];
gbProgress.Caption := Lang[ID_ENV_COMPPROGRESSWINDOW];
cbShowProgress.Caption := Lang[ID_ENV_SHOWPROGRESS];
cbAutoCloseProgress.Caption := Lang[ID_ENV_AUTOCLOSEPROGRESS];
cbWatchHint.Caption := Lang[ID_ENV_WATCHHINT];
gbDebugger.Caption := Lang[ID_ENV_DEBUGGER];
rgbAutoOpen.Caption := Lang[ID_ENV_AUTOOPEN];
rgbAutoOpen.Items[0] := Lang[ID_ENV_AUTOALL];
rgbAutoOpen.Items[1] := Lang[ID_ENV_AUTOFIRST];
rgbAutoOpen.Items[2] := Lang[ID_ENV_AUTOREMEMBER];
rgbAutoOpen.Items[3] := Lang[ID_ENV_AUTONONE];
cboTabsTop.Items[0] := Lang[ID_ENV_TOP];
cboTabsTop.Items[1] := Lang[ID_ENV_BOTTOM];
cboTabsTop.Items[2] := Lang[ID_ENV_LEFT];
cboTabsTop.Items[3] := Lang[ID_ENV_RIGHT];
lblLang.Caption := Lang[ID_ENV_LANGUAGE];
LblStyle.Caption := Lang[ID_ENV_THEME];
lblmsgTabs.Caption := Lang[ID_ENV_MSGTABS];
lblMRU.Caption := Lang[ID_ENV_MRU];
UIfontlabel.Caption := Lang[ID_LANGFORM_FONT];
lblSize.Caption := Lang[ID_EOPT_SIZE];
lblOptionsDir.Caption := Lang[ID_ENV_OPTIONSDIRHINT];
btnResetDev.Caption := Lang[ID_ENV_RESETDEV];
lblUserDir.Caption := Lang[ID_ENV_USERDIR];
lblTemplatesDir.Caption := Lang[ID_ENV_TEMPLATESDIR];
lblIcoLib.Caption := Lang[ID_ENV_ICOLIB];
lblSplash.Caption := Lang[ID_ENV_SPLASH];
lblLangPath.Caption := Lang[ID_ENV_SELLANGDIR];
// externals tab
lblExternal.Caption := Lang[ID_ENV_EXTERNPROGASSOCS];
vleExternal.TitleCaptions.Clear;
vleExternal.TitleCaptions.Add(Lang[ID_ENV_EXTERNEXT]);
vleExternal.TitleCaptions.Add(Lang[ID_ENV_EXTERNPROG]);
btnExtAdd.Caption := Lang[ID_BTN_ADD];
btnExtDel.Caption := Lang[ID_BTN_DELETE];
// associations tab
lblAssocFileTypes.Caption := Lang[ID_ENV_FASSTYPES];
lblAssocDesc.Caption := Lang[ID_ENV_FASSDESC];
end;
procedure TEnviroForm.SpeedButton2Click(Sender: TObject);
begin
Close;
end;
procedure TEnviroForm.btnHelpClick(Sender: TObject);
begin
OpenHelpFile('index.htm');
end;
procedure TEnviroForm.FormCreate(Sender: TObject);
var
I, sel: integer;
begin
LoadText;
with devData do begin
// General, left column
cbDefCpp.Checked := defCpp;
cbBackups.Checked := BackUps;
cbMinOnRun.Checked := MinOnRun;
cbShowBars.Checked := ShowBars;
cbMultiLineTab.Checked := MultiLineTab;
cbPauseConsole.Checked := ConsolePause;
cbCheckAssocs.Checked := CheckAssocs;
cbWatchHint.Checked := WatchHint;
cbShowProgress.Checked := ShowProgress;
cbAutoCloseProgress.Checked := AutoCloseProgress;
// General, right column
seMRUMax.Value := MRUMax;
cboTabsTop.ItemIndex := Integer(msgTabs);
// List the languages
cboLang.Items.BeginUpdate;
try
cboLang.Clear;
for I := 0 to Lang.Langs.Count - 1 do begin
sel := cboLang.Items.Add(Lang.Langs.ValueFromIndex[I]);
if SameText(Lang.CurrentLanguage, cboLang.Items[I]) then
cboLang.ItemIndex := sel;
end;
finally
cboLang.Items.EndUpdate;
end;
// List the themes
//cboTheme.Items.Clear;
//devImageThemes.GetThemeTitles(cboTheme.Items);
//cboTheme.ItemIndex := devImageThemes.IndexOf(devImageThemes.CurrentTheme.Title);
//Style Delphi
ListBoxStyle.ItemIndex := Style;
ListBoxStyleClick(Self);
// Add all font families and select the current one
cbUIfont.Items.Assign(Screen.Fonts);
for I := 0 to cbUIfont.Items.Count - 1 do
if cbUIfont.Items.Strings[I] = InterfaceFont then begin
cbUIfont.ItemIndex := I;
break;
end;
// Do the same for the size selection
for I := 0 to cbUIfontsize.Items.Count - 1 do
if StrToIntDef(cbUIfontsize.Items.Strings[I], -1) = InterfaceFontSize then begin
cbUIfontsize.ItemIndex := I;
break;
end;
// General tab, right column, last entry
rgbAutoOpen.ItemIndex := AutoOpen;
// Directories tab
edOptionsDir.Text := devDirs.Config;
edUserDir.Text := devDirs.Default;
edTemplatesDir.Text := ExtractRelativePath(devDirs.Exec, devDirs.Templates);
edIcoLib.Text := ExtractRelativePath(devDirs.Exec, devDirs.Icons);
edLang.Text := ExtractRelativePath(devDirs.Exec, devDirs.Lang);
edSplash.Text := Splash;
// External Programs tab
vleExternal.Strings.Assign(devExternalPrograms.Programs);
for I := 0 to vleExternal.Strings.Count - 1 do
vleExternal.ItemProps[I].EditStyle := esEllipsis;
// File associations tab
CheckAssociations(false); // read only, don't try to fix them
lstAssocFileTypes.Clear;
for I := 0 to AssociationsCount - 1 do begin
lstAssocFileTypes.Items.Add(Format('%s (*.%s)', [Associations[I, 1], Associations[I, 0]]));
lstAssocFileTypes.Checked[lstAssocFileTypes.Items.Count - 1] := IsAssociated(I);
end;
end;
end;
procedure TEnviroForm.vleExternalEditButtonClick(Sender: TObject);
begin
if Trim(vleExternal.Cells[0, vleExternal.Row]) = '' then begin
MessageDlg('Add an extension first!', mtError, [mbOk], 0);
Exit;
end;
with TOpenDialog.Create(Self) do try
Filter := FLT_ALLFILES;
if Execute then
vleExternal.Cells[1, vleExternal.Row] := Filename;
finally
Free;
end;
end;
procedure TEnviroForm.vleExternalValidate(Sender: TObject; ACol,
ARow: Integer; const KeyName, KeyValue: string);
var
idx: integer;
begin
if vleExternal.FindRow(KeyName, idx) and (idx <> ARow) then begin
MessageDlg('Extension exists...', mtError, [mbOk], 0);
vleExternal.Col := 0;
vleExternal.Row := ARow;
Abort;
end;
vleExternal.ItemProps[ARow - 1].EditStyle := esEllipsis;
end;
procedure TEnviroForm.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TEnviroForm.btnExtAddClick(Sender: TObject);
begin
vleExternal.InsertRow('', '', True);
vleExternal.Row := vleExternal.RowCount - 1;
vleExternal.Col := 0;
vleExternal.SetFocus;
end;
procedure TEnviroForm.btnExtDelClick(Sender: TObject);
begin
if (vleExternal.Row = 1) and (vleExternal.RowCount = 2) and (vleExternal.Cells[0, 1] = '') then
exit;
if (vleExternal.RowCount > 1) and (vleExternal.Row > 0) then
vleExternal.DeleteRow(vleExternal.Row);
end;
procedure TEnviroForm.cbUIfontDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with TComboBox(Control) do begin
Canvas.Font.Name := Items.Strings[Index];
Canvas.Font.Size := strtoint(cbUIfontsize.Text);
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left, Rect.Top, Canvas.Font.Name);
end;
end;
procedure TEnviroForm.cbUIfontsizeDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with TComboBox(Control) do begin
Canvas.Font.Name := cbUIfont.Text;
Canvas.Font.Size := strtoint(Items.Strings[Index]);
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left, Rect.Top, Items.Strings[Index]);
end;
end;
procedure TEnviroForm.cbUIfontsizeChange(Sender: TObject);
begin
cbUIfont.Repaint;
end;
procedure TEnviroForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TEnviroForm.btnResetDevClick(Sender: TObject);
begin
// Remove settings on exit
RemoveOptionsDir(devDirs.Config);
// Quit without saving
TerminateProcess(GetCurrentProcess, 0);
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.