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
|
{
fpGUI - Free Pascal GUI Library
Application class declarations
Copyright (C) 2000 - 2006 See the file AUTHORS.txt, included in this
distribution, for details of the copyright.
See the file COPYING.modifiedLGPL, included in this distribution,
for details about redistributing fpGUI.
This program 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.
}
{%mainunit fpgui.pp}
{$IFDEF read_interface}
{ Application class declarations }
{ TApplication }
TApplication = class(TDefApplication)
private
// FDisplay: TGfxDisplay;
// FDisplayName: String;
// FForms: TList;
FUserStyle: TStyle;
// function GetDisplay: TGfxDisplay;
// procedure SetDisplayName(const AValue: String);
protected
FDefaultStyle: TStyle;
FTitle: String;
XMLDoc: TXMLDocument;
function GetDefaultStyle: TStyle;
procedure SetTitle(const ATitle: String);
public
// constructor Create; reintroduce;
destructor Destroy; override;
procedure SetupXMLStreaming(const AXMLFilename: String);
// procedure CreateForm(InstanceClass: TComponentClass; var Reference);
// procedure AddForm(AForm: TCustomForm);
// procedure Run;
procedure SetStyle(pNewStyle: TStyle);
// property Display: TGfxDisplay read GetDisplay;
// property DisplayName: String read FDisplayName write SetDisplayName;
property DefaultStyle: TStyle read GetDefaultStyle;
property Title: String read FTitle write SetTitle;
end;
{$ENDIF read_interface}
{$IFDEF read_implementation}
// ===================================================================
// TApplication
// ===================================================================
{
constructor TApplication.Create;
begin
inherited Create(nil);
FForms := TList.Create;
end;
}
destructor TApplication.Destroy;
begin
FUserStyle := nil;
// FForms.Free;
// !!!: Only auto-created styles should be destroyed, not user-provided
if Assigned(FDefaultStyle) then
FDefaultStyle.Free;
// if Assigned(FDisplay) then
// FDisplay.Free;
inherited Destroy;
end;
procedure TApplication.SetupXMLStreaming(const AXMLFilename: String);
begin
ReadXMLFile(XMLDoc, AXMLFilename);
end;
{
procedure TApplication.CreateForm(InstanceClass: TComponentClass; var Reference);
type
PForm = ^TCustomForm;
var
form: PForm;
Filename: String;
TextStream, BinStream: TStream;
begin
form := @Reference;
form^ := TCustomForm(InstanceClass.Create(Self));
Filename := LowerCase(Copy(InstanceClass.ClassName, 2, 255)) + '.frm';
TextStream := TFileStream.Create(Filename, fmOpenRead);
BinStream := TMemoryStream.Create;
ObjectTextToBinary(TextStream, BinStream);
TextStream.Free;
BinStream.Position := 0;
BinStream.ReadComponent(Form^);
BinStream.Free;
Form^.Show;
end;
}
{
procedure TApplication.AddForm(AForm: TCustomForm);
begin
FForms.Add(AForm);
AForm.Show;
end;
}
{
procedure TApplication.Run;
begin
Display.Run;
end;
}
procedure TApplication.SetStyle(pNewStyle: TStyle);
begin
if Assigned(FUserStyle) then
FUserStyle.Free;
FUserStyle := pNewStyle;
end;
{
function TApplication.GetDisplay: TGfxDisplay;
begin
if FDisplay = nil then FDisplay := TDefDisplay.Create(FDisplayName);
Result := FDisplay;
end;
}
{
procedure TApplication.SetDisplayName(const AValue: String);
begin
// The display name cannot be changed after we have created it.
if (FDisplayName=AValue) or (FDisplay<>nil) then exit;
FDisplayName:=AValue;
end;
}
function TApplication.GetDefaultStyle: TStyle;
begin
if Assigned(FUserStyle) then
Result := FUserStyle
else
begin
if not Assigned(FDefaultStyle) then
FDefaultStyle := TDefaultStyle.Create(self);
Result := FDefaultStyle;
end;
end;
procedure TApplication.SetTitle(const ATitle: String);
begin
if ATitle <> FTitle then
begin
FTitle := ATitle;
// !!!: Change title of all forms with Text='' to FTitle
end;
end;
{!!!: Remove this ASAP
function TApplication.XMLReadFormProc(Instance: TComponent): Boolean;
var
Node: TDOMNode;
Reader: TXMLStreamingReader;
begin
Result := False;
if not Assigned(XMLDoc) then
exit;
Node := XMLDoc.DocumentElement.FirstChild;
// Search the correct serialisation node
while True do
begin
if not Assigned(Node) then
exit;
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'component') and
(UpperCase(TDOMElement(Node).GetAttribute('class')) = Instance.ClassName) then
break;
Node := Node.NextSibling;
end;
Reader := TXMLStreamingReader.Create(Node as TDOMElement);
try
Reader.ReadRootComponent(Instance);
finally
Reader.Free;
end;
Result := True;
end;}
{$ENDIF read_implementation}
|