forked from benibela/apim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainunit.pas
242 lines (192 loc) · 7.8 KB
/
mainunit.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
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
{
Copyright (C) 2001-2008 Benito van der Zander, www.benibela.de
This file is part of API Manager.
API Manager 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 3 of the License, or
(at your option) any later version.
API Manager 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 API Manager. If not, see <http://www.gnu.org/licenses/>.
}
{History:
- 2008:
Weiterentwicklung, Wechsel von Delphi -> Lazarus
Umbenennung von APIV (API Verwalter??) in API Manager
(wegen Namenskonflikt einem anderen APIV von 2000)
- Ende 2002:
Fertigstellung der Version 2
- 2001:
Erste Veröffentlichung von APIV (entweder Version 1 oder 2)
}
unit mainunit;
interface
{$mode objfpc}{$h+}
uses
LResources, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
menus,sysutils, StdCtrls, LDockTree, ExtCtrls,windowcontrolfuncs,
ButtonPanel;
type
{ TmainForm }
TmainForm = class(TForm)
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
MenuItem10: TMenuItem;
MenuItem11: TMenuItem;
MenuItem12: TMenuItem;
MenuItem13: TMenuItem;
MenuItem14: TMenuItem;
MenuItem15: TMenuItem;
MenuItem16: TMenuItem;
MenuItem17: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
MenuItem8: TMenuItem;
MenuItem9: TMenuItem;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure insertToNewPageClick(Sender: TObject);
procedure insertIntoPageClick(Sender: TObject);
procedure MenuItem17Click(Sender: TObject);
procedure subFormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure subFormResize(Sender: TObject);
private
{ Private-Deklarationen}
function addSubForm(id:longint; insertTo:Tform; createpage:boolean):tform;
procedure addSubForm(newform:Tform; insertTo:Tform; createpage:boolean); //(insertTo <>nil) and createpage => not defined
procedure addExistingSubForm(newform:Tform; insertTo:Tform; createpage:boolean); //(insertTo <>nil) and createpage => not defined
//procedure showNewSibling(sender:tform; newform: tform);
procedure showHandle(sender:tobject; newFormID: longint; var callback: TCallbackComponent);
public
{ Public-Deklarationen}
end;
var
mainForm: TmainForm;
implementation
uses applicationConfig, searchTool,windowList,processList,systemOptions,bbutils, options,windowPropertySheet,welcome,ptranslateutils,apimshared,wstyles,AnchorDocking,AnchorDockStorage;
{$I mainunit.atr}
{ TmainForm }
procedure TmainForm.FormCreate(Sender: TObject);
var
i:longint;
boundLeft, boundTop, boundWidth, boundHeight: Integer;
begin
initUnitTranslation(CurrentUnitName,tr);
tr.translate(self);
Caption := 'API Manager ' + currentVersionStr;
DockMaster.MakeDockSite(Self,[akBottom],admrpNone,false);;
boundLeft := globalConfig.GetValue('mainForm/left',left);
boundTop := globalConfig.GetValue('mainForm/top',top);
boundWidth := globalConfig.GetValue('mainForm/width',width);
boundHeight := globalConfig.GetValue('mainForm/height',height);
if boundWidth > screen.Width then boundWidth := screen.Width;
if boundHeight > screen.Height then boundHeight := screen.Height;
if boundLeft + boundWidth > screen.Width then boundLeft := (screen.Width - boundWidth) div 2;
if boundTop + boundHeight > screen.Height then boundTop := (screen.Height - boundHeight) div 2;
SetBounds(boundLeft, boundTop, boundWidth, boundHeight);
SetPropA(messageWindow,propertyMainWindow,handle);
end;
procedure TmainForm.FormShow(Sender: TObject);
var
infoForm: TWelcomeFrm;
begin
infoForm:=twelcomefrm.Create(self);
infoForm.onNewWindow:=@insertToNewPageClick;
DockMaster.MakeDockable(infoForm,true,false,false);
DockMaster.GetAnchorSite(infoForm).Header.HeaderPosition := adlhpTop;
DockMaster.ManualDock(DockMaster.GetAnchorSite(infoForm), self, alClient, nil);
OnShow := nil;
end;
procedure TmainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
globalConfig.SetValue('mainForm/left',left);
globalConfig.SetValue('mainForm/top',top);
globalConfig.SetValue('mainForm/width',width);
globalConfig.SetValue('mainForm/height',height);
end;
procedure TmainForm.insertToNewPageClick(Sender: TObject);
begin
addSubForm(tcomponent(sender).Tag,nil,true);
end;
procedure TmainForm.insertIntoPageClick(Sender: TObject);
begin
addSubForm(tcomponent(sender).Tag,nil,false);
end;
procedure TmainForm.MenuItem17Click(Sender: TObject);
begin
close;
end;
procedure TmainForm.subFormClose(Sender: TObject; var CloseAction: TCloseAction
);
begin
CloseAction:=caFree;
end;
procedure TmainForm.subFormResize(Sender: TObject);
begin
if not (sender is tform) then exit;
tform(sender).VertScrollBar.visible:=tform(sender).ClientHeight<tform(sender).VertScrollBar.range;
end;
//needed for user input
function TmainForm.addSubForm(id: longint; insertTo:Tform; createpage: boolean):tform;
begin
case id of
SEARCHTOOLFRM_ID: result:=TsearchToolFrm.Create(self);
WINDOWLISTFRM_ID: result:=TWindowListFrm.Create(self);
PROCESSLISTFRM_ID: result:=TprocessListFrm.Create(self);
SYSTEMOPTIONSFRM_ID: result:=TsystemOptionsFrm.Create(self);
OPTIONSFRM_ID: result:=ToptionFrm.Create(self);
PROPERTYSHEETFRM_ID: result:=TWindowPropertySheetFrm.Create(self);
WINDOWSTYLELISTFRM_ID: result:=Twindowstyleform.Create(self)
else raise exception.create('invalid form id');
end;
if result.FindComponent('callbackcomponent')=nil then
TCallbackComponent.Create(result);
TCallbackComponent(result.FindComponent('callbackcomponent')).onShowForm:=@showHandle;
TCallbackComponent(result.FindComponent('callbackcomponent')).id:=id;
addSubForm(result,insertTo,createpage);
end;
procedure TmainForm.addSubForm(newform: Tform; insertTo:Tform; createpage: boolean);
begin
addExistingSubForm(newform,insertTo,createpage);
newform.OnClose := @subFormClose;
newForm.VertScrollBar.Visible:=true;
end;
procedure TmainForm.addExistingSubForm(newform: Tform; insertTo: Tform; createpage: boolean);
var
site: TAnchorDockHostSite;
begin
DockMaster.MakeDockable(newform,false);
DockMaster.GetAnchorSite(newform).Header.HeaderPosition := adlhpTop;
if insertTo <> nil then
DockMaster.ManualDock(DockMaster.GetAnchorSite(newform), DockMaster.GetAnchorSite(insertTo), alBottom, insertTo)
else begin
if not createpage then begin
createpage := true;
site := (DockManager as TAnchorDockManager).GetChildSite;
if site.Pages <> nil then begin
DockMaster.ManualDock(DockMaster.GetAnchorSite(newform), site.Pages.GetActiveSite, alBottom, nil);
createpage := false;
end;
end;
if createpage then
DockMaster.ManualDock(DockMaster.GetAnchorSite(newform), self, alClient, nil)
end;
DockMaster.MakeDockable(newform,true,true);
Invalidate;
end;
procedure TmainForm.showHandle(sender: tobject; newFormID: longint;
var callback: TCallbackComponent);
begin
callback:=addSubForm(newFormID,sender as tform,false).FindComponent('callbackcomponent') as TCallbackComponent;
end;
initialization
{$I mainunit.lrs}
end.