source: trunk/Packages/CoolDocking/Demo/IDE/UMainForm.pas

Last change on this file was 73, checked in by chronos, 12 years ago
  • Modified: Packages are now stored as uncomporessed and are linked with relative path to project.
File size: 8.7 KB
Line 
1unit UMainForm;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
9 ActnList, ExtCtrls, ComCtrls, StdCtrls, UCDClient, UCDLayout,
10 UToolPaletteForm, UObjectInspectorForm, UProjectManagerForm, UStructureForm,
11 UMessagesForm, UCallStackForm, ULocalVariablesForm, UToDoListForm,
12 UWatchListForm, UThreadStatusForm, USourceEditorForm, UCDWindowList,
13 UCDCustomize, UComponentTree, UCDConjoinForm, UCDManager,
14 UCDMaster, UCDCommon;
15
16const
17 DefaultLayoutName = 'Default Layout';
18 DockLayoutFileName = 'Layout.xml';
19
20type
21
22 { TMainForm }
23
24 TMainForm = class(TForm)
25 published
26 AResetDefaultLayout: TAction;
27 AViewComponentTree: TAction;
28 AExit: TAction;
29 ANewFile: TAction;
30 ACustomizeDocking: TAction;
31 ADesktopSave: TAction;
32 AViewThreadStatus: TAction;
33 AViewWatchList: TAction;
34 AViewToDoList: TAction;
35 AViewLocalVariables: TAction;
36 AViewCallStack: TAction;
37 AViewMessages: TAction;
38 AViewStructure: TAction;
39 AViewToolPalette: TAction;
40 AViewProjectManager: TAction;
41 AViewObjectInspector: TAction;
42 AViewWindowList: TAction;
43 ComboBox1: TComboBox;
44 CoolDockClient1: TCDClient;
45 CoolDockCustomize1: TCDCustomize;
46 CoolDockLayoutList1: TCDLayoutList;
47 CoolDockMaster1: TCDMaster;
48 CoolDockWindowList1: TCDWindowList;
49 ImageList1: TImageList;
50 Label1: TLabel;
51 MenuItem11: TMenuItem;
52 MenuItem10: TMenuItem;
53 MenuItem12: TMenuItem;
54 MenuItem13: TMenuItem;
55 MenuItem14: TMenuItem;
56 MenuItem15: TMenuItem;
57 MenuItem16: TMenuItem;
58 MenuItem17: TMenuItem;
59 MenuItem18: TMenuItem;
60 MenuItem19: TMenuItem;
61 MenuItem20: TMenuItem;
62 MenuItem21: TMenuItem;
63 MenuItem22: TMenuItem;
64 MenuItem23: TMenuItem;
65 MenuItem24: TMenuItem;
66 MenuItem25: TMenuItem;
67 MenuItem26: TMenuItem;
68 MenuItem27: TMenuItem;
69 MenuItem28: TMenuItem;
70 MenuItem9: TMenuItem;
71 MenuItem8: TMenuItem;
72 MenuItem7: TMenuItem;
73 MenuItem6: TMenuItem;
74 MenuItem5: TMenuItem;
75 MenuItem4: TMenuItem;
76 MenuItem3: TMenuItem;
77 MenuItem2: TMenuItem;
78 ActionList1: TActionList;
79 MenuItem1: TMenuItem;
80 MainMenu1: TMainMenu;
81 DockPanel: TPanel;
82 ToolBar1: TToolBar;
83 ToolButton1: TToolButton;
84 procedure ACustomizeDockingExecute(Sender: TObject);
85 procedure ADesktopSaveExecute(Sender: TObject);
86 procedure AExitExecute(Sender: TObject);
87 procedure ANewFileExecute(Sender: TObject);
88 procedure AResetDefaultLayoutExecute(Sender: TObject);
89 procedure AViewComponentTreeExecute(Sender: TObject);
90 procedure AViewThreadStatusExecute(Sender: TObject);
91 procedure AViewCallStackExecute(Sender: TObject);
92 procedure AViewLocalVariablesExecute(Sender: TObject);
93 procedure AViewMessagesExecute(Sender: TObject);
94 procedure AViewObjectInspectorExecute(Sender: TObject);
95 procedure AViewProjectManagerExecute(Sender: TObject);
96 procedure AViewStructureExecute(Sender: TObject);
97 procedure AViewToDoListExecute(Sender: TObject);
98 procedure AViewToolPaletteExecute(Sender: TObject);
99 procedure AViewWatchListExecute(Sender: TObject);
100 procedure AViewWindowListExecute(Sender: TObject);
101 procedure ComboBox1Select(Sender: TObject);
102 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
103 procedure FormShow(Sender: TObject);
104 public
105 NewFileIndex: Integer;
106 SourceCodeContainer: TCDConjoinForm;
107 procedure InitDefaultDockLayout;
108 end;
109
110var
111 MainForm: TMainForm;
112
113implementation
114
115{$R *.lfm}
116
117{ TMainForm }
118
119procedure TMainForm.AViewToolPaletteExecute(Sender: TObject);
120begin
121 ToolPaletteForm.Show;
122end;
123
124procedure TMainForm.AViewWatchListExecute(Sender: TObject);
125begin
126 WatchListForm.Show;
127end;
128
129procedure TMainForm.AViewWindowListExecute(Sender: TObject);
130begin
131 CoolDockWindowList1.Execute;
132end;
133
134procedure TMainForm.ComboBox1Select(Sender: TObject);
135begin
136 if (ComboBox1.ItemIndex <> - 1) and (ComboBox1.ItemIndex < CoolDockLayoutList1.Items.Count) then
137 TCDLayout(CoolDockLayoutList1.Items[ComboBox1.ItemIndex]).Restore;
138end;
139
140procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
141begin
142 CoolDockLayoutList1.SaveToFile(DockLayoutFileName);
143end;
144
145procedure TMainForm.FormShow(Sender: TObject);
146begin
147 with CoolDockLayoutList1 do begin
148 if FileExistsUTF8(DockLayoutFileName) then
149 LoadFromFile(DockLayoutFileName);
150 InitDefaultDockLayout;
151 PopulateStringList(ComboBox1.Items);
152 end;
153end;
154
155procedure TMainForm.InitDefaultDockLayout;
156var
157 NewContainer1: TCDConjoinForm;
158 NewContainer2: TCDConjoinForm;
159 DefaultLayout: TCDLayout;
160begin
161 DefaultLayout := CoolDockLayoutList1.FindByName(DefaultLayoutName);
162 if not Assigned(DefaultLayout) then begin
163 NewContainer1 := TCDManager(DockPanel.DockManager).CreateConjoinForm;
164 TCDManager(NewContainer1.DockManager).DockStyle := dsPopupTabs;
165 TCDManager(NewContainer1.DockManager).HeaderPos := hpLeft;
166 NewContainer1.Visible := True;
167
168 StructureForm.ManualDock(NewContainer1, nil, alTop);
169 StructureForm.Show;
170 ObjectInspectorForm.ManualDock(NewContainer1, nil, alTop);
171 ObjectInspectorForm.Show;
172
173 NewContainer2 := TCDManager(DockPanel.DockManager).CreateConjoinForm;
174 TCDManager(NewContainer2.DockManager).DockStyle := dsPopupTabs;
175 TCDManager(NewContainer2.DockManager).HeaderPos := hpRight;
176 NewContainer2.Visible := True;
177
178 ProjectManagerForm.ManualDock(NewContainer2, nil, alTop);
179 ProjectManagerForm.Show;
180 ToolPaletteForm.ManualDock(NewContainer2, nil, alTop);
181 ToolPaletteForm.Show;
182
183 SourceCodeContainer := TCDManager(DockPanel.DockManager).CreateConjoinForm;
184 TCDManager(SourceCodeContainer.DockManager).DockStyle := dsTabs;
185 TCDManager(SourceCodeContainer.DockManager).HeaderPos := hpTop;
186 SourceCodeContainer.Visible := True;
187
188 //NewContainer1.ManualDock(DockPanel);
189 NewContainer1.Show;
190 SourceCodeContainer.ManualDock(DockPanel);
191 SourceCodeContainer.Show;
192 //NewContainer2.ManualDock(DockPanel);
193 NewContainer2.Show;
194
195 DefaultLayout := TCDLayout.Create;
196 DefaultLayout.Name := DefaultLayoutName;
197 CoolDockLayoutList1.Items.Add(DefaultLayout);
198 DefaultLayout.Store;
199 end;
200end;
201
202procedure TMainForm.AViewProjectManagerExecute(Sender: TObject);
203begin
204 ProjectManagerForm.Show;
205end;
206
207procedure TMainForm.AViewStructureExecute(Sender: TObject);
208begin
209 StructureForm.Show;
210end;
211
212procedure TMainForm.AViewToDoListExecute(Sender: TObject);
213begin
214 ToDoListForm.Show;
215end;
216
217procedure TMainForm.AViewObjectInspectorExecute(Sender: TObject);
218begin
219 ObjectInspectorForm.Show;
220end;
221
222procedure TMainForm.AViewCallStackExecute(Sender: TObject);
223begin
224 CallStackForm.Show;
225end;
226
227procedure TMainForm.AViewThreadStatusExecute(Sender: TObject);
228begin
229 ThreadStatusForm.Show;
230end;
231
232procedure TMainForm.ADesktopSaveExecute(Sender: TObject);
233var
234 NewLayout: TCDLayout;
235begin
236 if ComboBox1.Text <> '' then begin
237 if ComboBox1.Items.IndexOf(ComboBox1.Text) = -1 then begin
238 NewLayout := TCDLayout.Create;
239 NewLayout.Name := ComboBox1.Text;
240 NewLayout.Store;
241 CoolDockLayoutList1.Items.Add(NewLayout);
242 end else
243 TCDLayout(CoolDockLayoutList1.Items[ComboBox1.Items.IndexOf(ComboBox1.Text)]).Store;
244 CoolDockLayoutList1.SaveToFile(DockLayoutFileName);
245 CoolDockLayoutList1.PopulateStringList(ComboBox1.Items);
246 end else ShowMessage('Enter layout name');
247end;
248
249procedure TMainForm.AExitExecute(Sender: TObject);
250begin
251 Close;
252end;
253
254procedure TMainForm.ANewFileExecute(Sender: TObject);
255var
256 NewFile: TSourceEditorForm;
257begin
258 Application.CreateForm(TSourceEditorForm, NewFile);
259 //NewFile := TSourceEditorForm.Create(nil);
260 Inc(NewFileIndex);
261 NewFile.Caption := 'Unit ' + IntToStr(NewFileIndex);
262 NewFile.ManualDock(SourceCodeContainer);
263 NewFile.Show;
264end;
265
266procedure TMainForm.AResetDefaultLayoutExecute(Sender: TObject);
267var
268 DefaultLayout: TCDLayout;
269begin
270 DefaultLayout := CoolDockLayoutList1.FindByName(DefaultLayoutName);
271 if Assigned(DefaultLayout) then
272 CoolDockLayoutList1.Items.Remove(DefaultLayout);
273 InitDefaultDockLayout;
274end;
275
276procedure TMainForm.AViewComponentTreeExecute(Sender: TObject);
277begin
278 ComponentTree.Show;
279end;
280
281procedure TMainForm.ACustomizeDockingExecute(Sender: TObject);
282begin
283 CoolDockCustomize1.Execute;
284 CoolDockLayoutList1.PopulateStringList(ComboBox1.Items);
285end;
286
287procedure TMainForm.AViewLocalVariablesExecute(Sender: TObject);
288begin
289 LocalVariablesForm.Show;
290end;
291
292procedure TMainForm.AViewMessagesExecute(Sender: TObject);
293begin
294 MessagesForm.Show;
295end;
296
297end.
298
Note: See TracBrowser for help on using the repository browser.