forked from Alexey-T/CudaText
-
Notifications
You must be signed in to change notification settings - Fork 0
/
formabout.pas
170 lines (142 loc) · 3.93 KB
/
formabout.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
(*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) Alexey Torgashin
*)
unit formabout;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
Menus, ButtonPanel, IniFiles,
LCLProc, LCLType, LCLIntf,
proc_msg,
proc_globdata,
proc_editor,
proc_customdialog,
ATLinkLabel,
ATSynEdit,
ATSynEdit_Commands;
type
{ TfmAbout }
TfmAbout = class(TForm)
ButtonPanel1: TButtonPanel;
LabelName: TLabel;
labelPlatform: TLabel;
labelVersion: TLabel;
memo: TATSynEdit;
MenuItem37: TMenuItem;
mnuTextCopy: TMenuItem;
mnuTextOpenUrl: TMenuItem;
mnuTextSel: TMenuItem;
PopupText: TPopupMenu;
procedure bCreditsClick(Sender: TObject);
procedure bOkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
procedure mnuTextCopyClick(Sender: TObject);
procedure mnuTextOpenUrlClick(Sender: TObject);
procedure mnuTextSelClick(Sender: TObject);
private
{ private declarations }
procedure Localize;
public
{ public declarations }
FLabelLink: TATLabelLink;
FCredits: string;
end;
implementation
uses InterfaceBase;
{$R *.lfm}
{ TfmAbout }
procedure TfmAbout.Localize;
const
section = 'd_about';
var
ini: TIniFile;
fn: string;
begin
fn:= GetAppLangFilename;
if not FileExists(fn) then exit;
ini:= TIniFile.Create(fn);
try
Caption:= ini.ReadString(section, '_', Caption);
with ButtonPanel1.OKButton do Caption:= msgButtonOk;
with ButtonPanel1.HelpButton do Caption:= ini.ReadString(section, 'cre', Caption);
with mnuTextCopy do Caption:= ini.ReadString('m_e', 'cp', Caption);
with mnuTextSel do Caption:= ini.ReadString('m_se', 'al', Caption);
with mnuTextOpenUrl do Caption:= ini.ReadString('ct', 'url', Caption);
finally
FreeAndNil(ini);
end;
end;
procedure TfmAbout.bOkClick(Sender: TObject);
begin
ModalResult:= mrCancel;
end;
procedure TfmAbout.FormCreate(Sender: TObject);
begin
Localize;
memo.DoubleBuffered:= UiOps.DoubleBuffered;
memo.Font.Name:= EditorOps.OpFontName;
memo.Font.Size:= EditorOps.OpFontSize;
memo.PopupText:= PopupText;
FLabelLink:= TATLabelLink.Create(Self);
FLabelLink.Parent:= Self;
FLabelLink.Caption:= 'UVviewsoft.com';
FLabelLink.Link:= 'http://uvviewsoft.com';
FLabelLink.Left:= LabelName.Left;
FLabelLink.AnchorSideTop.Control:= labelPlatform;
FLabelLink.AnchorSideTop.Side:= asrBottom;
FLabelLink.BorderSpacing.Top:= labelPlatform.BorderSpacing.Top;
labelPlatform.Caption:= Format('%s-%s-%s, fpc %s', [
LowerCase({$I %FPCTARGETOS%}),
{$I %FPCTARGETCPU%},
GetLCLWidgetTypeName,
{$I %FPCVersion%}
]);
end;
procedure TfmAbout.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_ESCAPE then Close;
end;
procedure TfmAbout.FormShow(Sender: TObject);
begin
DoForm_ScaleAuto(Self, true);
UpdateFormOnTop(Self);
//big title
labelName.Font.Style:= [fsBold];
labelName.Font.Size:= 20;
memo.Hide;
memo.Align:= alClient;
memo.Strings.Clear;
memo.Strings.LoadFromString(msgAboutCredits);
memo.DoCaretSingle(0, 0);
memo.ModeReadOnly:= true;
memo.Font.Name:= EditorOps.OpFontName;
end;
procedure TfmAbout.mnuTextCopyClick(Sender: TObject);
begin
memo.DoCommand(cCommand_ClipboardCopy);
end;
procedure TfmAbout.mnuTextOpenUrlClick(Sender: TObject);
var
Str: string;
begin
Str:= EditorGetLinkAtScreenCoord(memo, PopupText.PopupPoint);
if Str<>'' then
OpenURL(Str);
end;
procedure TfmAbout.mnuTextSelClick(Sender: TObject);
begin
memo.DoCommand(cCommand_SelectAll);
end;
procedure TfmAbout.bCreditsClick(Sender: TObject);
begin
memo.Show;
ButtonPanel1.HelpButton.Enabled:= false;
end;
end.