1 | unit UMainForm;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
7 | Dialogs, Menus, ExtCtrls, StdCtrls, ComCtrls, DockPanel, URegistry,
|
---|
8 | UApplicationInfo, UDockManagement, ActnList, XPStyleActnCtrls, ActnMan,
|
---|
9 | UProject, XPMan, ImgList, DockManagerPro, StdStyleActnCtrls, ToolWin,
|
---|
10 | ActnCtrls, ActnMenus;
|
---|
11 |
|
---|
12 | type
|
---|
13 | TMainForm = class(TForm)
|
---|
14 | DockPanel1: TDockPanel;
|
---|
15 | DockPanel2: TDockPanel;
|
---|
16 | DockPanel3: TDockPanel;
|
---|
17 | ActionManager1: TActionManager;
|
---|
18 | ActionExit: TAction;
|
---|
19 | ActionProjectOpen: TAction;
|
---|
20 | ActionProjectSaveAs: TAction;
|
---|
21 | ActionFileOpen: TAction;
|
---|
22 | ActionFileSave: TAction;
|
---|
23 | ActionFileClose: TAction;
|
---|
24 | ActionFileCloseAll: TAction;
|
---|
25 | ActionUnitTest: TAction;
|
---|
26 | ActionPrint: TAction;
|
---|
27 | ActionFileSaveAs: TAction;
|
---|
28 | ImageList1: TImageList;
|
---|
29 | ActionMainMenuBar1: TActionMainMenuBar;
|
---|
30 | ActionFile: TAction;
|
---|
31 | ActionFileNew: TAction;
|
---|
32 | ActionFileReopen: TAction;
|
---|
33 | ActionFileSaveAll: TAction;
|
---|
34 | ActionEdit: TAction;
|
---|
35 | OpenDialog1: TOpenDialog;
|
---|
36 | SaveDialog1: TSaveDialog;
|
---|
37 | FindDialog1: TFindDialog;
|
---|
38 | ReplaceDialog1: TReplaceDialog;
|
---|
39 | ActionEditUndo: TAction;
|
---|
40 | ActionEditRedo: TAction;
|
---|
41 | ActionEditCut: TAction;
|
---|
42 | ActionEditCopy: TAction;
|
---|
43 | ActionEditPaste: TAction;
|
---|
44 | ActionEditDelete: TAction;
|
---|
45 | ActionEditSelectAll: TAction;
|
---|
46 | ActionEditAlignToGrid: TAction;
|
---|
47 | ActionEditBringToFront: TAction;
|
---|
48 | ActionEditSendToBack: TAction;
|
---|
49 | ActionEditAlign: TAction;
|
---|
50 | ActionEditSize: TAction;
|
---|
51 | ActionEditScale: TAction;
|
---|
52 | ActionEditTabOrder: TAction;
|
---|
53 | ActionEditCreationOrder: TAction;
|
---|
54 | ActionEditFlipChildren: TAction;
|
---|
55 | ActionEditLockControls: TAction;
|
---|
56 | ActionSearch: TAction;
|
---|
57 | ActionView: TAction;
|
---|
58 | ActionProject: TAction;
|
---|
59 | ActionRun: TAction;
|
---|
60 | ActionComponent: TAction;
|
---|
61 | ActionTools: TAction;
|
---|
62 | ActionWindow: TAction;
|
---|
63 | ActionHelp: TAction;
|
---|
64 | procedure FormShow(Sender: TObject);
|
---|
65 | procedure ObjectInspector1Click(Sender: TObject);
|
---|
66 | procedure oolPalete1Click(Sender: TObject);
|
---|
67 | procedure Structure1Click(Sender: TObject);
|
---|
68 | procedure ProjectManager1Click(Sender: TObject);
|
---|
69 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
70 | procedure FormCreate(Sender: TObject);
|
---|
71 | procedure FormDestroy(Sender: TObject);
|
---|
72 | procedure ActionExitExecute(Sender: TObject);
|
---|
73 | procedure ActionFileUpdate(Sender: TObject);
|
---|
74 | procedure ActionEditExecute(Sender: TObject);
|
---|
75 | procedure ActionProjectOpenExecute(Sender: TObject);
|
---|
76 | procedure ActionFileOpenExecute(Sender: TObject);
|
---|
77 | procedure ActionProjectSaveAsExecute(Sender: TObject);
|
---|
78 | private
|
---|
79 | CustomDockManager: TDDockManager;
|
---|
80 | BaseDockPanel: TDBaseDockPanel;
|
---|
81 | RegistryRootKey: HKEY;
|
---|
82 | RegistryKey: string;
|
---|
83 | procedure LoadFormPosition(Form: TForm);
|
---|
84 | procedure SaveFormPosition(Form: TForm);
|
---|
85 | { Private declarations }
|
---|
86 | public
|
---|
87 |
|
---|
88 | end;
|
---|
89 |
|
---|
90 | var
|
---|
91 | MainForm: TMainForm;
|
---|
92 |
|
---|
93 | implementation
|
---|
94 |
|
---|
95 | uses UObjectInspector, UCodeEdit, UComponentPalette, UStructureView,
|
---|
96 | UProjectManager;
|
---|
97 |
|
---|
98 | {$R *.dfm}
|
---|
99 |
|
---|
100 | procedure TMainForm.ActionEditExecute(Sender: TObject);
|
---|
101 | begin
|
---|
102 | //
|
---|
103 | end;
|
---|
104 |
|
---|
105 | procedure TMainForm.ActionExitExecute(Sender: TObject);
|
---|
106 | begin
|
---|
107 | Close;
|
---|
108 | end;
|
---|
109 |
|
---|
110 | procedure TMainForm.ActionFileOpenExecute(Sender: TObject);
|
---|
111 | begin
|
---|
112 | if OpenDialog1.Execute then begin
|
---|
113 | end;
|
---|
114 | end;
|
---|
115 |
|
---|
116 | procedure TMainForm.ActionFileUpdate(Sender: TObject);
|
---|
117 | begin
|
---|
118 | //
|
---|
119 | end;
|
---|
120 |
|
---|
121 | procedure TMainForm.ActionProjectOpenExecute(Sender: TObject);
|
---|
122 | begin
|
---|
123 | if OpenDialog1.Execute then begin
|
---|
124 | end;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | procedure TMainForm.ActionProjectSaveAsExecute(Sender: TObject);
|
---|
128 | begin
|
---|
129 | if SaveDialog1.Execute then begin
|
---|
130 | end;
|
---|
131 | end;
|
---|
132 |
|
---|
133 | procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
134 | begin
|
---|
135 | SaveFormPosition(Self);
|
---|
136 | CustomDockManager.SaveToRegistry;
|
---|
137 | end;
|
---|
138 |
|
---|
139 | procedure TMainForm.FormCreate(Sender: TObject);
|
---|
140 | begin
|
---|
141 | RegistryRootKey := HKEY_CURRENT_USER;
|
---|
142 | RegistryKey := ApplicationInfo.CompanyName + '\' + ApplicationInfo.Name;
|
---|
143 | //LoadFromRegistry;
|
---|
144 |
|
---|
145 | CustomDockManager := TDDockManager.Create(Self);
|
---|
146 | CustomDockManager.RegistryKey := RegistryKey;
|
---|
147 | BaseDockPanel := TDBaseDockPanel.Create(Self);
|
---|
148 | with BaseDockPanel do begin
|
---|
149 | Parent := Self;
|
---|
150 | Align := alClient;
|
---|
151 | Visible := True;
|
---|
152 | BevelOuter := bvNone;
|
---|
153 | end;
|
---|
154 | CustomDockManager.BaseDockPanel := BaseDockPanel;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | procedure TMainForm.FormDestroy(Sender: TObject);
|
---|
158 | begin
|
---|
159 | CustomDockManager.Free;
|
---|
160 | end;
|
---|
161 |
|
---|
162 | procedure TMainForm.FormShow(Sender: TObject);
|
---|
163 | begin
|
---|
164 | // Init dock init list
|
---|
165 | with CustomDockManager do begin
|
---|
166 | RegisterDockForm(ComponentPalette, 100, 400, 'PanelLeft', True);
|
---|
167 | RegisterDockForm(ProjectManager, 100, 400, 'PanelLeft', True);
|
---|
168 | RegisterDockForm(ObjectInspector, 100, 400, 'PanelRight', True);
|
---|
169 | RegisterDockForm(StructureView, 100, 400, 'PanelRight', True);
|
---|
170 | RegisterDockForm(CodeEdit, 500, 400, 'PanelCenter', True);
|
---|
171 | with BaseDockPanel do begin
|
---|
172 | PanelLeft.Tag := 300;
|
---|
173 | PanelTop.Tag := 150;
|
---|
174 | PanelRight.Tag := 150;
|
---|
175 | PanelBottom.Tag := 150;
|
---|
176 | end;
|
---|
177 | end;
|
---|
178 | CustomDockManager.LoadFromRegistry;
|
---|
179 |
|
---|
180 | LoadFormPosition(Self);
|
---|
181 | CodeEdit.Show;
|
---|
182 | ActionManager1.Style := XPStyle;
|
---|
183 | end;
|
---|
184 |
|
---|
185 | procedure TMainForm.ObjectInspector1Click(Sender: TObject);
|
---|
186 | begin
|
---|
187 | with ObjectInspector do Visible := not Visible;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | procedure TMainForm.oolPalete1Click(Sender: TObject);
|
---|
191 | begin
|
---|
192 | with ComponentPalette do Visible := not Visible;
|
---|
193 | end;
|
---|
194 |
|
---|
195 | procedure TMainForm.ProjectManager1Click(Sender: TObject);
|
---|
196 | begin
|
---|
197 | with ProjectManager do Visible := not Visible;
|
---|
198 | end;
|
---|
199 |
|
---|
200 | procedure TMainForm.Structure1Click(Sender: TObject);
|
---|
201 | begin
|
---|
202 | with StructureView do Visible := not Visible;
|
---|
203 | end;
|
---|
204 |
|
---|
205 | procedure TMainForm.LoadFormPosition(Form: TForm);
|
---|
206 | begin
|
---|
207 | with Form, TRegistryEx.Create do
|
---|
208 | try
|
---|
209 | RootKey := RegistryRootKey;
|
---|
210 | OpenKey(RegistryKey + '\Forms\' + Form.Name, True);
|
---|
211 | Width := ReadIntegerWithDefault('Width', Width);
|
---|
212 | Height := ReadIntegerWithDefault('Height', Height);
|
---|
213 | Top := ReadIntegerWithDefault('Top', (Screen.Height - Height) div 2);
|
---|
214 | Left := ReadIntegerWithDefault('Left', (Screen.Width - Width) div 2);
|
---|
215 | if Left < 0 then Left := 0;
|
---|
216 | if Left > (Screen.Width - 50) then Left := Screen.Width - 50;
|
---|
217 | if Top < 0 then Top := 0;
|
---|
218 | if Top > (Screen.Height - 50) then Top := Screen.Height - 50;
|
---|
219 | if ReadBoolWithDefault('Maximized', False) then begin
|
---|
220 | WindowState := wsMaximized;
|
---|
221 | end;
|
---|
222 | finally
|
---|
223 | Free;
|
---|
224 | end;
|
---|
225 | end;
|
---|
226 |
|
---|
227 | procedure TMainForm.SaveFormPosition(Form: TForm);
|
---|
228 | var
|
---|
229 | Pl : TWindowPlacement; // used for API call
|
---|
230 | R: TRect; // used for wdw pos
|
---|
231 | begin
|
---|
232 | {Calculate window's normal size and position using
|
---|
233 | Windows API call - the form's Width, Height, Top and
|
---|
234 | Left properties will give maximized window size if
|
---|
235 | form is maximised, which is not what we want here}
|
---|
236 | Pl.Length := SizeOf(TWindowPlacement);
|
---|
237 | GetWindowPlacement(Form.Handle, @Pl);
|
---|
238 | R := Pl.rcNormalPosition;
|
---|
239 |
|
---|
240 | with Form, TRegistryEx.Create do
|
---|
241 | try
|
---|
242 | RootKey := RegistryRootKey;
|
---|
243 | OpenKey(RegistryKey + '\Forms\' + Form.Name, True);
|
---|
244 | WriteInteger('Width', R.Right - R.Left);
|
---|
245 | WriteInteger('Height', R.Bottom - R.Top);
|
---|
246 | WriteInteger('Top', R.Top);
|
---|
247 | WriteInteger('Left', R.Left);
|
---|
248 | WriteBool('Maximized', WindowState = wsMaximized);
|
---|
249 | finally
|
---|
250 | Free;
|
---|
251 | end;
|
---|
252 | end;
|
---|
253 |
|
---|
254 | end.
|
---|