-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunitformdebug.pas
More file actions
107 lines (86 loc) · 1.86 KB
/
unitformdebug.pas
File metadata and controls
107 lines (86 loc) · 1.86 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
unit UnitFormDebug;
{$mode ObjFPC}{$H+}
{$modeswitch objectivec1}
interface
uses
Classes,
SysUtils,
Forms,
CocoaAll,
Controls,
Graphics,
Dialogs,
StdCtrls,
ExtCtrls,
UnitSettings;
type
{ TFormDebug }
TFormDebug = class(TForm)
Button1: TButton;
CheckBox1: TCheckBox;
Memo1: TMemo;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure Log(msg: String);
private
LastLogMessage: String;
Configuration: TConfiguration;
private
procedure LogProc;
public
procedure SetUp;
end;
var
FormDebug: TFormDebug;
implementation
{$R *.lfm}
{ TFormDebug }
procedure TFormDebug.FormCreate(Sender: TObject);
begin
Configuration:=TConfiguration.Create(Application.Location);
Configuration.Load;
end;
procedure TFormDebug.FormShow(Sender: TObject);
begin
NSView(Handle).window.setFrameAutosaveName(NSSTR(ClassName));
end;
procedure TFormDebug.Button1Click(Sender: TObject);
begin
FormDebug.Memo1.Clear;
end;
procedure TFormDebug.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseAction:=caHide;
end;
procedure TFormDebug.FormDestroy(Sender: TObject);
begin
FreeAndNil(Configuration);
end;
{ helpers }
procedure TFormDebug.Log(msg: String);
begin
if Configuration.Settings.Debug then
begin
LastLogMessage:=DateTimeToStr(Now) + ' ' + msg;
TThread.Synchronize(nil, @LogProc);
end;
end;
procedure TFormDebug.LogProc;
begin
if (LastLogMessage <> '') and CheckBox1.Checked then
begin
Memo1.Lines.BeginUpdate;
Memo1.Lines.Add(LastLogMessage);
Memo1.Lines.EndUpdate;
end;
LastLogMessage:=''
end;
procedure TFormDebug.SetUp;
begin
Configuration.Load;
end;
end.