Changeset 14 for trunk/StudioPackage/UDataModule.pas
- Timestamp:
- Aug 6, 2012, 10:49:50 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/UDataModule.pas
r13 r14 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, Forms, SpecializedList, USource,9 U ModularSystem, ULDStudioAPI;8 Classes, SysUtils, FileUtil, Forms, ActnList, Controls, SpecializedList, 9 USource, UModularSystem, ULDStudioAPI, Menus, ComCtrls; 10 10 11 11 type … … 40 40 41 41 TDataModule1 = class(TDataModule) 42 published 43 ActionListRegistred: TActionList; 44 ImageListMain: TImageList; 45 API: TLDStudioAPI; 46 procedure APIDockForm(Form: TForm; Target: TDockTarget); 47 procedure APIRegisterFileType(FileType: TSourceType); 48 procedure APIRegisterForm(Form: TForm); 49 procedure APIRegisterMainMenuItem(MenuItem: TMenuItem; 50 ParentItem: TMenuItem; Index: Integer); 51 procedure APIUnregisterAction(Action: TAction); 52 procedure APIUnregisterFileType(FileType: TSourceType); 53 procedure APIUnregisterForm(Form: TForm); 54 procedure APIUnregisterMainMenuItem(MenuItem: TMenuItem); 42 55 procedure DataModuleCreate(Sender: TObject); 43 56 procedure DataModuleDestroy(Sender: TObject); 57 procedure APIOpenFile(FileName: string); 58 procedure APIRegisterAction(Action: TAction); 44 59 private 45 API: TLDStudioAPI;60 procedure DockToPageControl(PageControl: TPageControl; Form: TForm); 46 61 public 47 62 ModuleManager: TModuleManager; … … 127 142 FileTypes.OwnsObjects := False; 128 143 OpenedFiles := TOpenedFiles.Create; 129 API := TLDStudioAPI.Create;130 144 ModuleManager := TModuleManager.Create(nil); 131 145 ModuleManager.API := API; … … 138 152 FormModuleList := TFormModuleList.Create(nil); 139 153 140 TLDStudioAPI(ModuleManager.API).MainForm := FormMain;141 TLDStudioAPI(ModuleManager.API).MainMenu := FormMain.MainMenu;142 TLDStudioAPI(ModuleManager.API).FileTypes := FileTypes;143 154 FormMain.Show; 144 155 end; 145 156 157 procedure TDataModule1.APIUnregisterMainMenuItem(MenuItem: TMenuItem); 158 begin 159 MenuItem.Parent.Delete(MenuItem.Parent.IndexOf(MenuItem)); 160 end; 161 162 procedure TDataModule1.APIRegisterMainMenuItem(MenuItem: TMenuItem; 163 ParentItem: TMenuItem; Index: Integer); 164 begin 165 if Assigned(ParentItem) then ParentItem.Insert(Index, MenuItem) 166 else FormMain.MainMenu.Items.Insert(Index, MenuItem); 167 end; 168 169 procedure TDataModule1.APIRegisterForm(Form: TForm); 170 begin 171 Form.Parent := FormMain; 172 end; 173 174 procedure TDataModule1.APIRegisterFileType(FileType: TSourceType); 175 begin 176 FileTypes.Add(FileType); 177 end; 178 179 procedure TDataModule1.DockToPageControl(PageControl: TPageControl; Form: TForm 180 ); 181 var 182 NewTabSheet: TTabSheet; 183 begin 184 NewTabSheet := TTabSheet.Create(PageControl); 185 NewTabSheet.Parent := PageControl; 186 NewTabSheet.Visible := True; 187 NewTabSheet.Caption := Form.Caption; 188 Form.Align := alClient; 189 Form.ManualDock(NewTabSheet, nil, alClient); 190 Form.Visible := True; 191 end; 192 193 procedure TDataModule1.APIDockForm(Form: TForm; Target: TDockTarget); 194 begin 195 with FormMain do 196 case Target of 197 dtCenter: DockToPageControl(PageControlCenter, Form); 198 // dtTop: DockToPageControl(PageControlTop, Form); 199 dtLeft: DockToPageControl(PageControlLeft, Form); 200 dtRight: DockToPageControl(PageControlRight, Form); 201 dtBottom: DockToPageControl(PageControlBottom, Form); 202 end; 203 end; 204 205 procedure TDataModule1.APIUnregisterAction(Action: TAction); 206 begin 207 Action.ActionList := nil; 208 end; 209 210 procedure TDataModule1.APIUnregisterFileType(FileType: TSourceType); 211 begin 212 FileTypes.Remove(FileType); 213 end; 214 215 procedure TDataModule1.APIUnregisterForm(Form: TForm); 216 begin 217 Form.Parent := nil; 218 end; 219 146 220 procedure TDataModule1.DataModuleDestroy(Sender: TObject); 147 221 begin 148 222 FreeAndNil(ModuleManager); 149 FreeAndNil(API);150 223 FreeAndNil(FormMain); 151 224 FreeAndNil(FormSourceCode); … … 156 229 end; 157 230 231 procedure TDataModule1.APIOpenFile(FileName: string); 232 begin 233 OpenedFiles.OpenFile(FileName); 234 end; 235 236 procedure TDataModule1.APIRegisterAction(Action: TAction); 237 begin 238 Action.ActionList := ActionListRegistred; 239 end; 240 158 241 end. 159 242
Note:
See TracChangeset
for help on using the changeset viewer.