This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMCSEMainWindowUnit.pas
118 lines (98 loc) · 2.53 KB
/
MMCSEMainWindowUnit.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
unit MMCSEMainWindowUnit;
interface
uses
Types,
SysUtils,
Classes,
Controls,
Forms,
Menus,
UAdditionalTypes,
UAdditionalExceptions,
UVCL,
EmptyLogEntity,
DefaultLogEntity,
LogMemoryStorage,
VCLLogViewPanel,
CommonUnit,
ControlPanelUnit;
type
TEmulatorMainForm = class(TForm)
public
constructor Create(aOwner: TComponent); override;
procedure Startup;
protected
fLog: TEmptyLog;
FLogMemory: TLogMemoryStorage;
fLogPanel: TLogViewPanel;
fControlPanel: TControlPanel;
procedure SetLog(const aLog: TEmptyLog);
procedure AdjustInitialPosition;
function DoMouseWheel(aShift: TShiftState; aWheelDelta: Integer; aMousePos: TPoint): boolean;
override;
procedure DestroyThis;
public
property Log: TEmptyLog read fLog write SetLog;
// set this before Startup
property LogMemory: TLogMemoryStorage read FLogMemory write FLogMemory;
property LogPanel: TLogViewPanel read fLogPanel;
property ControlPanel: TControlPanel read fControlPanel;
procedure DisposeContent;
destructor Destroy; override;
end;
implementation
constructor TEmulatorMainForm.Create(aOwner: TComponent);
begin
inherited CreateNew(aOwner);
end;
procedure TEmulatorMainForm.Startup;
begin
AdjustInitialPosition;
fLog := TLog.Create(GlobalLogManager, 'EmulatorMainForm');
{$REGION Log panel}
AssertAssigned(LogMemory, 'LogMemory', TVariableType.Prop);
fLogPanel := TLogViewPanel.Create(self);
LogPanel.Parent := self;
LogPanel.Align := alClient;
LogPanel.LogMemory := LogMemory;
LogPanel.Startup;
{$ENDREGION}
{$REGION Control panel}
fControlPanel := TControlPanel.Create(self);
ControlPanel.Align := alBottom;
ControlPanel.Parent := self;
{$ENDREGION}
end;
procedure TEmulatorMainForm.SetLog(const aLog: TEmptyLog);
begin
ReplaceLog(fLog, aLog);
end;
procedure TEmulatorMainForm.AdjustInitialPosition;
begin
Width := Screen.DesktopWidth div 3 * 2;
Height := Screen.DesktopHeight div 3 * 2;
Position := poDesktopCenter;
end;
function TEmulatorMainForm.DoMouseWheel(aShift: TShiftState; aWheelDelta: Integer;
aMousePos: TPoint): boolean;
begin
result := IsMouseOverControl(LogPanel);
if result then
LogPanel.ReceiveMouseWheel(aShift, aWheelDelta, aMousePos);
end;
procedure TEmulatorMainForm.DestroyThis;
begin
DisposeContent;
FreeAndNil(fLog);
end;
procedure TEmulatorMainForm.DisposeContent;
begin
if LogPanel <> nil then
FreeAndNil(fLogPanel);
end;
destructor TEmulatorMainForm.Destroy;
begin
DestroyThis;
inherited Destroy;
end;
end.