PageRenderTime 55ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/ide/mainbase.pas

http://github.com/graemeg/lazarus
Pascal | 1967 lines | 1588 code | 217 blank | 162 comment | 105 complexity | f84a116ee812e1a9e5af3dc0acd87103 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception
  1. {
  2. /***************************************************************************
  3. mainbase.pas - the "integrated" in IDE
  4. ----------------------------------------
  5. TMainIDEBase is the ancestor of TMainIDE. The various top level parts of the
  6. IDE (called bosses/managers) access the TMainIDE via TMainIDEBase.
  7. main.pp - TMainIDE = class(TMainIDEBase)
  8. The highest manager/boss of the IDE. Only lazarus.pp uses
  9. this unit.
  10. mainbase.pas - TMainIDEBase = class(TMainIDEInterface)
  11. The ancestor class used by (and only by) the other
  12. bosses/managers like debugmanager, pkgmanager.
  13. mainintf.pas - TMainIDEInterface = class(TLazIDEInterface)
  14. The interface class of the top level functions of the IDE.
  15. TMainIDEInterface is used by functions/units, that uses
  16. several different parts of the IDE (designer, source editor,
  17. codetools), so they can't be added to a specific boss and
  18. which are yet too small to become a boss of their own.
  19. lazideintf.pas - TLazIDEInterface = class(TComponent)
  20. For designtime packages, this is the interface class of the
  21. top level functions of the IDE.
  22. ***************************************************************************/
  23. ***************************************************************************
  24. * *
  25. * This source is free software; you can redistribute it and/or modify *
  26. * it under the terms of the GNU General Public License as published by *
  27. * the Free Software Foundation; either version 2 of the License, or *
  28. * (at your option) any later version. *
  29. * *
  30. * This code is distributed in the hope that it will be useful, but *
  31. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  33. * General Public License for more details. *
  34. * *
  35. * A copy of the GNU General Public License is available on the World *
  36. * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
  37. * obtain it by writing to the Free Software Foundation, *
  38. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  39. * *
  40. ***************************************************************************
  41. }
  42. unit MainBase;
  43. {$mode objfpc}{$H+}
  44. interface
  45. {$I ide.inc}
  46. uses
  47. {$IFDEF IDE_MEM_CHECK}
  48. MemCheck,
  49. {$ENDIF}
  50. Math, Classes, LCLType, LCLProc, LCLIntf, Buttons, Menus, ComCtrls,
  51. SysUtils, types, Controls, Graphics, ExtCtrls, Dialogs, LazFileUtils, Forms,
  52. CodeToolManager, AVL_Tree, SynEditKeyCmds, PackageIntf,
  53. // IDEIntf
  54. IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf, NewItemIntf,
  55. IDECommands, IDEWindowIntf, ProjectIntf, ToolBarIntf,
  56. // IDE
  57. LazConf, LazarusIDEStrConsts, ProjectDefs, Project, IDEDialogs,
  58. TransferMacros, ObjectInspector, PropEdits, BuildManager,
  59. EnvironmentOpts, EditorOptions, CompilerOptions, KeyMapping, IDEProcs,
  60. Debugger, IDEOptionDefs, Splash, Designer,
  61. SourceEditor, FindInFilesDlg,
  62. MainBar, MainIntf, SourceSynEditor, PseudoTerminalDlg,
  63. DesktopManager, ImgList;
  64. type
  65. TResetToolFlag = (
  66. rfInteractive,
  67. rfCloseOnDone,
  68. rfSuccessOnTrigger
  69. );
  70. TResetToolFlags = set of TResetToolFlag;
  71. { TMainIDEBase }
  72. TMainIDEBase = class(TMainIDEInterface)
  73. private
  74. FWindowMenuActiveForm: TCustomForm;
  75. FDisplayState: TDisplayState;
  76. procedure SetDisplayState(AValue: TDisplayState);
  77. protected
  78. FNeedUpdateHighlighters: boolean;
  79. function CreateMenuSeparator : TMenuItem;
  80. procedure CreateMenuItem(Section: TIDEMenuSection;
  81. var MenuCommand: TIDEMenuCommand;
  82. const MenuItemName, MenuItemCaption: String;
  83. const bmpName: String = '';
  84. mnuEnabled: Boolean = true;
  85. mnuChecked: Boolean = false;
  86. mnuVisible: Boolean = true);
  87. procedure CreateMenuSeparatorSection(ParentSection: TIDEMenuSection;
  88. var Section: TIDEMenuSection; const AName: String);
  89. procedure CreateMenuSubSection(ParentSection: TIDEMenuSection;
  90. var Section: TIDEMenuSection;
  91. const AName, ACaption: String;
  92. const bmpName: String = '');
  93. procedure CreateMainMenuItem(var Section: TIDEMenuSection;
  94. const MenuItemName, MenuItemCaption: String);
  95. procedure SetupMainMenu; virtual;
  96. procedure SetupFileMenu; virtual;
  97. procedure SetupEditMenu; virtual;
  98. procedure SetupSearchMenu; virtual;
  99. procedure SetupViewMenu; virtual;
  100. procedure SetupSourceMenu; virtual;
  101. procedure SetupProjectMenu; virtual;
  102. procedure SetupRunMenu; virtual;
  103. procedure SetupPackageMenu; virtual;
  104. procedure SetupToolsMenu; virtual;
  105. procedure SetupWindowsMenu; virtual;
  106. procedure SetupHelpMenu; virtual;
  107. procedure LoadMenuShortCuts; virtual;
  108. procedure SetToolStatus(const AValue: TIDEToolStatus); override;
  109. procedure DoMnuWindowClicked(Sender: TObject);
  110. procedure mnuOpenProjectClicked(Sender: TObject); virtual; abstract;
  111. procedure mnuOpenRecentClicked(Sender: TObject); virtual; abstract;
  112. procedure mnuWindowItemClick(Sender: TObject); virtual;
  113. procedure mnuCenterWindowItemClick(Sender: TObject); virtual;
  114. procedure mnuWindowSourceItemClick(Sender: TObject); virtual;
  115. procedure mnuBuildModeClicked(Sender: TObject); virtual; abstract;
  116. procedure UpdateWindowMenu;
  117. public
  118. function DoResetToolStatus(AFlags: TResetToolFlags): boolean; virtual; abstract;
  119. constructor Create(TheOwner: TComponent); override;
  120. procedure StartIDE; virtual; abstract;
  121. destructor Destroy; override;
  122. procedure CreateOftenUsedForms; virtual; abstract;
  123. function GetMainBar: TForm; override;
  124. procedure SetRecentProjectFilesMenu;
  125. procedure SetRecentFilesMenu;
  126. function BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
  127. out ActiveUnitInfo: TUnitInfo;
  128. Flags: TCodeToolsFlags): boolean;
  129. function BeginCodeTool(ADesigner: TDesigner;
  130. var ActiveSrcEdit: TSourceEditor;
  131. out ActiveUnitInfo: TUnitInfo;
  132. Flags: TCodeToolsFlags): boolean;
  133. procedure ActivateCodeToolAbortableMode;
  134. function OnCodeToolBossCheckAbort: boolean;
  135. procedure DoShowDesignerFormOfCurrentSrc(AComponentPaletteClassSelected: Boolean); virtual; abstract;
  136. function CreateDesignerForComponent(AnUnitInfo: TUnitInfo;
  137. AComponent: TComponent): TCustomForm; virtual; abstract;
  138. procedure UpdateSaveMenuItemsAndButtons(UpdateSaveAll: boolean); virtual; abstract;
  139. procedure DoMergeDefaultProjectOptions(AProject: TProject);
  140. procedure DoSwitchToFormSrc(var ActiveSourceEditor:TSourceEditor;
  141. var ActiveUnitInfo:TUnitInfo);
  142. procedure DoSwitchToFormSrc(ADesigner: TIDesigner;
  143. var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
  144. procedure GetUnitInfoForDesigner(ADesigner: TIDesigner;
  145. out ActiveSourceEditor: TSourceEditorInterface;
  146. out ActiveUnitInfo: TUnitInfo); override;
  147. procedure GetCurrentUnitInfo(out ActiveSourceEditor: TSourceEditorInterface;
  148. out ActiveUnitInfo: TUnitInfo); override;
  149. procedure GetCurrentUnit(out ActiveSourceEditor: TSourceEditor;
  150. out ActiveUnitInfo: TUnitInfo); virtual; abstract;
  151. procedure GetDesignerUnit(ADesigner: TDesigner;
  152. out ActiveSourceEditor: TSourceEditor; out ActiveUnitInfo: TUnitInfo); virtual; abstract;
  153. procedure GetObjectInspectorUnit(
  154. out ActiveSourceEditor: TSourceEditor; out ActiveUnitInfo: TUnitInfo); virtual; abstract;
  155. procedure GetUnitWithForm(AForm: TCustomForm;
  156. out ActiveSourceEditor: TSourceEditor; out ActiveUnitInfo: TUnitInfo); virtual; abstract;
  157. procedure GetUnitWithPersistent(APersistent: TPersistent;
  158. out ActiveSourceEditor: TSourceEditor; out ActiveUnitInfo: TUnitInfo); virtual; abstract;
  159. procedure DoShowComponentList(State: TIWGetFormState = iwgfShowOnTop); virtual; abstract;
  160. function DoOpenMacroFile(Sender: TObject; const AFilename: string): TModalResult; override;
  161. procedure SetRecentSubMenu(Section: TIDEMenuSection; FileList: TStringList;
  162. OnClickEvent: TNotifyEvent); override;
  163. procedure UpdateHighlighters(Immediately: boolean = false); override;
  164. procedure FindInFilesPerDialog(AProject: TProject); override;
  165. procedure FindInFiles(AProject: TProject; const FindText: string); override;
  166. procedure SelComponentPageButtonMouseDown(Sender: TObject;
  167. Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual; abstract;
  168. procedure SelComponentPageButtonClick(Sender: TObject); virtual; abstract;
  169. public
  170. property WindowMenuActiveForm: TCustomForm read FWindowMenuActiveForm write FWindowMenuActiveForm;
  171. property DisplayState: TDisplayState read FDisplayState write SetDisplayState;
  172. end;
  173. { TJumpToSectionToolButton }
  174. TJumpToSectionToolButton = class(TIDEToolButton)
  175. private
  176. procedure AddMenuItem(aCmd: TIDEMenuCommand);
  177. public
  178. procedure DoOnAdded; override;
  179. procedure RefreshMenu;
  180. end;
  181. { TSetBuildModeToolButton }
  182. TSetBuildModeToolButton = class(TIDEToolButton)
  183. private
  184. procedure RefreshMenu(Sender: TObject);
  185. procedure mnuSetBuildModeClick(Sender: TObject);
  186. public
  187. procedure DoOnAdded; override;
  188. end;
  189. { TOpenFileToolButton }
  190. TOpenFileToolButton = class(TIDEToolButton)
  191. private
  192. FIndex: TStringList;
  193. procedure RefreshMenu(Sender: TObject);
  194. procedure mnuOpenFile(Sender: TObject);
  195. procedure mnuProjectFile(Sender: TObject);
  196. public
  197. constructor Create(aOwner: TComponent); override;
  198. destructor Destroy; override;
  199. procedure DoOnAdded; override;
  200. end;
  201. { TOpenFileMenuItem }
  202. TOpenFileMenuItem = class(TMenuItem)
  203. public
  204. FileName: string;
  205. end;
  206. { TNewFormUnitToolButton }
  207. TNewFormUnitToolButton = class(TIDEToolButton)
  208. private
  209. SetDefaultMenuItem: TMenuItem;
  210. procedure RefreshMenu(Sender: TObject);
  211. procedure mnuSetFormUnitTemplate(Sender: TObject);
  212. protected
  213. class function FindDefaultTemplateName(Category: TNewIDEItemCategory): string; virtual; abstract;
  214. class procedure SetTemplateName(const TemplateName: string); virtual; abstract;
  215. class procedure UpdateHint(const AHint: string); virtual; abstract;
  216. public
  217. procedure DoOnAdded; override;
  218. class procedure UpdateHints;
  219. end;
  220. { TNewUnitToolButton }
  221. TNewUnitToolButton = class(TNewFormUnitToolButton)
  222. protected
  223. class function FindDefaultTemplateName(Category: TNewIDEItemCategory): string; override;
  224. class procedure SetTemplateName(const TemplateName: string); override;
  225. class procedure UpdateHint(const AHint: string); override;
  226. end;
  227. { TNewFormToolButton }
  228. TNewFormToolButton = class(TNewFormUnitToolButton)
  229. protected
  230. class function FindDefaultTemplateName(Category: TNewIDEItemCategory): string; override;
  231. class procedure SetTemplateName(const TemplateName: string); override;
  232. class procedure UpdateHint(const AHint: string); override;
  233. end;
  234. { TNewFormUnitMenuItem }
  235. TNewFormUnitMenuItem = class(TMenuItem)
  236. public
  237. TemplateName: string;
  238. end;
  239. function GetMainIde: TMainIDEBase;
  240. property MainIDE: TMainIDEBase read GetMainIde;
  241. { Normally the IDE builds itself with packages named in config files.
  242. When the IDE should keep the packages installed in the current executable
  243. set KeepInstalledPackages to true. }
  244. var KeepInstalledPackages: boolean = false;
  245. implementation
  246. function GetMainIde: TMainIDEBase;
  247. begin
  248. Result := TMainIDEBase(MainIDEInterface)
  249. end;
  250. { TNewFormUnitToolButton }
  251. procedure TNewFormUnitToolButton.DoOnAdded;
  252. begin
  253. inherited DoOnAdded;
  254. PopupMenu := TPopupMenu.Create(Self);
  255. PopupMenu.OnPopup := @RefreshMenu;
  256. SetDefaultMenuItem:=TMenuItem.Create(PopupMenu);
  257. SetDefaultMenuItem.Caption:=lisSetDefault;
  258. PopupMenu.Items.Add(SetDefaultMenuItem);
  259. UpdateHints;
  260. end;
  261. procedure TNewFormUnitToolButton.mnuSetFormUnitTemplate(Sender: TObject);
  262. begin
  263. SetTemplateName((Sender as TNewFormUnitMenuItem).TemplateName);
  264. EnvironmentOptions.Save(False);
  265. UpdateHints;
  266. end;
  267. procedure TNewFormUnitToolButton.RefreshMenu(Sender: TObject);
  268. var
  269. TemplateName: String;
  270. Category: TNewIDEItemCategory;
  271. i: Integer;
  272. CurTemplate: TNewIDEItemTemplate;
  273. TheIndex: Integer;
  274. xItem: TNewFormUnitMenuItem;
  275. begin
  276. Category:=NewIDEItems.FindCategoryByPath(FileDescGroupName,true);
  277. TemplateName:=FindDefaultTemplateName(Category);
  278. // create menu items
  279. TheIndex:=0;
  280. for i:=0 to Category.Count-1 do begin
  281. CurTemplate:=Category[i];
  282. if not CurTemplate.VisibleInNewDialog then continue;
  283. if TheIndex<SetDefaultMenuItem.Count then
  284. xItem:=SetDefaultMenuItem[TheIndex] as TNewFormUnitMenuItem
  285. else begin
  286. xItem:=TNewFormUnitMenuItem.Create(SetDefaultMenuItem);
  287. SetDefaultMenuItem.Add(xItem);
  288. end;
  289. xItem.OnClick:=@mnuSetFormUnitTemplate;
  290. xItem.Caption:=CurTemplate.LocalizedName;
  291. xItem.TemplateName:=CurTemplate.Name;
  292. xItem.ShowAlwaysCheckable:=true;
  293. xItem.Checked:=CompareText(TemplateName,CurTemplate.Name)=0;
  294. inc(TheIndex);
  295. end;
  296. // remove unneeded items
  297. while SetDefaultMenuItem.Count>TheIndex do
  298. SetDefaultMenuItem.Items[SetDefaultMenuItem.Count-1].Free;
  299. end;
  300. class procedure TNewFormUnitToolButton.UpdateHints;
  301. var
  302. Category: TNewIDEItemCategory;
  303. TemplateName: String;
  304. Template: TNewIDEItemTemplate;
  305. begin
  306. if not Assigned(NewIDEItems) then
  307. Exit;
  308. Category:=NewIDEItems.FindCategoryByPath(FileDescGroupName,true);
  309. TemplateName:=FindDefaultTemplateName(Category);
  310. if TemplateName<>'' then //try to get the LocalizedName
  311. begin
  312. Template:=Category.FindTemplateByName(TemplateName);
  313. if Assigned(Template) then
  314. TemplateName := Template.LocalizedName;
  315. end;
  316. UpdateHint(Format(lisMenuNewCustom, [TemplateName]));
  317. end;
  318. { TNewFormToolButton }
  319. class function TNewFormToolButton.FindDefaultTemplateName(
  320. Category: TNewIDEItemCategory): string;
  321. begin
  322. Result:=EnvironmentOptions.NewFormTemplate;
  323. if (Result='') or (Category.FindTemplateByName(Result)=nil) then
  324. Result:=FileDescNameLCLForm;
  325. end;
  326. class procedure TNewFormToolButton.SetTemplateName(const TemplateName: string);
  327. begin
  328. EnvironmentOptions.NewFormTemplate:=TemplateName;
  329. end;
  330. class procedure TNewFormToolButton.UpdateHint(const AHint: string);
  331. begin
  332. MainIDEBar.itmFileNewForm.Hint := AHint;
  333. end;
  334. { TNewUnitToolButton }
  335. class function TNewUnitToolButton.FindDefaultTemplateName(
  336. Category: TNewIDEItemCategory): string;
  337. begin
  338. Result:=EnvironmentOptions.NewUnitTemplate;
  339. if (Result='') or (Category.FindTemplateByName(Result)=nil) then
  340. Result:=FileDescNamePascalUnit;
  341. end;
  342. class procedure TNewUnitToolButton.SetTemplateName(const TemplateName: string);
  343. begin
  344. EnvironmentOptions.NewUnitTemplate:=TemplateName;
  345. end;
  346. class procedure TNewUnitToolButton.UpdateHint(const AHint: string);
  347. begin
  348. MainIDEBar.itmFileNewUnit.Hint := AHint;
  349. end;
  350. { TOpenFileToolButton }
  351. constructor TOpenFileToolButton.Create(aOwner: TComponent);
  352. begin
  353. inherited Create(aOwner);
  354. FIndex := TStringList.Create;
  355. end;
  356. destructor TOpenFileToolButton.Destroy;
  357. begin
  358. FIndex.Free;
  359. inherited Destroy;
  360. end;
  361. procedure TOpenFileToolButton.DoOnAdded;
  362. begin
  363. inherited DoOnAdded;
  364. DropdownMenu := TPopupMenu.Create(Self);
  365. DropdownMenu.OnPopup := @RefreshMenu;
  366. DropdownMenu.Images := TCustomImageList.Create(Self);
  367. DropdownMenu.Images.Width := 16;
  368. DropdownMenu.Images.Height := 16;
  369. Style := tbsDropDown;
  370. end;
  371. procedure TOpenFileToolButton.mnuOpenFile(Sender: TObject);
  372. begin
  373. if MainIDE.DoOpenEditorFile((Sender as TOpenFileMenuItem).FileName,-1,-1,
  374. [ofAddToRecent])=mrOk then
  375. begin
  376. MainIDE.SetRecentFilesMenu;
  377. MainIDE.SaveEnvironment;
  378. end;
  379. end;
  380. procedure TOpenFileToolButton.mnuProjectFile(Sender: TObject);
  381. begin
  382. MainIDE.DoOpenProjectFile((Sender as TOpenFileMenuItem).FileName,[ofAddToRecent]);
  383. end;
  384. procedure TOpenFileToolButton.RefreshMenu(Sender: TObject);
  385. procedure AddFile(const AFileName: string; const AOnClick: TNotifyEvent);
  386. var
  387. AMenuItem: TOpenFileMenuItem;
  388. xExt: string;
  389. begin
  390. AMenuItem := TOpenFileMenuItem.Create(DropdownMenu);
  391. DropdownMenu.Items.Add(AMenuItem);
  392. AMenuItem.OnClick := AOnClick;
  393. AMenuItem.FileName := AFileName;
  394. AMenuItem.Caption := AFilename;
  395. xExt := ExtractFileExt(AFileName);
  396. if SameFileName(xExt, '.lpi') or SameFileName(xExt, '.lpr') then
  397. AMenuItem.ImageIndex := LoadProjectIconIntoImages(AFileName, DropdownMenu.Images, FIndex);
  398. end;
  399. procedure AddFiles(List: TStringList; MaxCount: integer; const AOnClick: TNotifyEvent);
  400. var
  401. i: integer;
  402. begin
  403. i := 0;
  404. while (i < List.Count) and (i < MaxCount) do
  405. begin
  406. AddFile(List[i], AOnClick);
  407. inc(i);
  408. end;
  409. end;
  410. begin
  411. DropdownMenu.Items.Clear;
  412. // first add recent projects
  413. AddFiles(EnvironmentOptions.RecentProjectFiles, EnvironmentOptions.MaxRecentProjectFiles, @mnuProjectFile);
  414. // add a separator
  415. DropdownMenu.Items.AddSeparator;
  416. // then add recent files
  417. AddFiles(EnvironmentOptions.RecentOpenFiles, EnvironmentOptions.MaxRecentOpenFiles, @mnuOpenFile);
  418. end;
  419. { TSetBuildModeToolButton }
  420. procedure TSetBuildModeToolButton.DoOnAdded;
  421. begin
  422. inherited DoOnAdded;
  423. DropdownMenu := TPopupMenu.Create(Self);
  424. DropdownMenu.OnPopup := @RefreshMenu;
  425. Style := tbsDropDown;
  426. end;
  427. procedure TSetBuildModeToolButton.mnuSetBuildModeClick(Sender: TObject);
  428. var
  429. TheMenuItem: TMenuItem;
  430. TheIndex: LongInt;
  431. NewMode: TProjectBuildMode;
  432. begin
  433. TheMenuItem := (Sender as TMenuItem);
  434. if TheMenuItem.Caption = '-' then exit;
  435. TheIndex := TheMenuItem.MenuIndex;
  436. if (TheIndex < 0) or (TheIndex >= Project1.BuildModes.Count) then exit;
  437. NewMode := Project1.BuildModes[TheIndex];
  438. if NewMode = Project1.ActiveBuildMode then exit;
  439. if not (MainIDE.ToolStatus in [itNone,itDebugger]) then begin
  440. IDEMessageDialog('Error','You can not change the build mode while compiling.',
  441. mtError,[mbOk]);
  442. exit;
  443. end;
  444. Project1.ActiveBuildMode := NewMode;
  445. MainBuildBoss.SetBuildTargetProject1(false);
  446. MainIDE.UpdateCaption;
  447. end;
  448. procedure TSetBuildModeToolButton.RefreshMenu(Sender: TObject);
  449. var
  450. aMenu: TPopupMenu;
  451. CurIndex: Integer;
  452. i: Integer;
  453. procedure AddMode(CurMode: TProjectBuildMode);
  454. var
  455. AMenuItem: TMenuItem;
  456. begin
  457. if aMenu.Items.Count > CurIndex then
  458. AMenuItem := aMenu.Items[CurIndex]
  459. else
  460. begin
  461. AMenuItem := TMenuItem.Create(DropdownMenu);
  462. AMenuItem.Name := aMenu.Name + 'Mode' + IntToStr(CurIndex);
  463. AMenuItem.OnClick := @mnuSetBuildModeClick;
  464. aMenu.Items.Add(AMenuItem);
  465. end;
  466. AMenuItem.Caption := CurMode.GetCaption;
  467. AMenuItem.Checked := (Project1<>nil) and (Project1.ActiveBuildMode=CurMode);
  468. AMenuItem.ShowAlwaysCheckable:=true;
  469. inc(CurIndex);
  470. end;
  471. begin
  472. // fill the PopupMenu:
  473. CurIndex := 0;
  474. aMenu := DropdownMenu;
  475. if Project1<>nil then
  476. for i:=0 to Project1.BuildModes.Count-1 do
  477. AddMode(Project1.BuildModes[i]);
  478. // remove unused menuitems
  479. while aMenu.Items.Count > CurIndex do
  480. aMenu.Items[aMenu.Items.Count - 1].Free;
  481. end;
  482. { TJumpToSectionToolButton }
  483. procedure TJumpToSectionToolButton.DoOnAdded;
  484. begin
  485. inherited DoOnAdded;
  486. RefreshMenu;
  487. end;
  488. procedure TJumpToSectionToolButton.AddMenuItem(aCmd: TIDEMenuCommand);
  489. var
  490. xItem: TMenuItem;
  491. begin
  492. xItem := TMenuItem.Create(DropdownMenu);
  493. DropdownMenu.Items.Add(xItem);
  494. xItem.Caption := aCmd.Caption;
  495. xItem.OnClick := aCmd.OnClick;
  496. xItem.ImageIndex := aCmd.ImageIndex;
  497. end;
  498. procedure TJumpToSectionToolButton.RefreshMenu;
  499. begin
  500. if DropdownMenu = nil then
  501. begin
  502. DropdownMenu := TPopupMenu.Create(Self);
  503. if Assigned(FToolBar) then
  504. DropdownMenu.Images := FToolBar.Images;
  505. Style := tbsDropDown;
  506. end;
  507. DropdownMenu.Items.Clear;
  508. AddMenuItem(MainIDEBar.itmJumpToInterface);
  509. AddMenuItem(MainIDEBar.itmJumpToInterfaceUses);
  510. AddMenuItem(MainIDEBar.itmJumpToImplementation);
  511. AddMenuItem(MainIDEBar.itmJumpToImplementationUses);
  512. AddMenuItem(MainIDEBar.itmJumpToInitialization);
  513. end;
  514. //{$IFDEF LCLCarbon}
  515. //var
  516. // mnuApple: TIDEMenuSection = nil;
  517. //{$ENDIF}
  518. { TMainIDEBase }
  519. procedure TMainIDEBase.mnuWindowItemClick(Sender: TObject);
  520. var
  521. i: Integer;
  522. Form: TCustomForm;
  523. nfd: Boolean;
  524. begin
  525. i:=Screen.CustomFormCount-1;
  526. while (i>=0) do begin
  527. Form:=Screen.CustomForms[i];
  528. nfd := EnvironmentOptions.Desktop.IDENameForDesignedFormList;
  529. if (nfd and (Form.Name=(Sender as TIDEMenuCommand).Caption))
  530. or ((not nfd) and (Form.Caption=(Sender as TIDEMenuCommand).Caption)) then
  531. begin
  532. IDEWindowCreators.ShowForm(Form,true);
  533. break;
  534. end;
  535. dec(i);
  536. end;
  537. end;
  538. procedure TMainIDEBase.mnuCenterWindowItemClick(Sender: TObject);
  539. var
  540. i: Integer;
  541. Form: TCustomForm;
  542. r, NewBounds: TRect;
  543. nfd: Boolean;
  544. begin
  545. i:=Screen.CustomFormCount-1;
  546. while (i>=0) do begin
  547. Form:=Screen.CustomForms[i];
  548. nfd := EnvironmentOptions.Desktop.IDENameForDesignedFormList;
  549. if (nfd and (Form.Name=(Sender as TIDEMenuCommand).Caption))
  550. or ((not nfd) and (Form.Caption=(Sender as TIDEMenuCommand).Caption)) then
  551. begin
  552. // show
  553. if not Form.IsVisible then
  554. IDEWindowCreators.ShowForm(Form,true);
  555. // move to monitor of main IDE bar
  556. Form:=GetParentForm(Form);
  557. if Form<>MainIDEBar then begin
  558. // center on main IDE
  559. Form.MakeFullyVisible(MainIDEBar.Monitor,true);
  560. debugln(['TMainIDEBase.mnuCenterWindowItemClick ',DbgSName(Form),' ',dbgs(Form.BoundsRect)]);
  561. r:=MainIDEBar.BoundsRect;
  562. if Form.Width<MainIDEBar.Width then
  563. NewBounds.Left:=(r.Left+r.Right-Form.Width) div 2
  564. else
  565. NewBounds.Left:=r.Left+50;
  566. if Form.Height<MainIDEBar.Height then
  567. NewBounds.Top:=(r.Top+r.Bottom-Form.Height) div 2
  568. else
  569. NewBounds.Top:=r.Top+50;
  570. NewBounds.Right:=NewBounds.Left+Max(70,Form.Width);
  571. NewBounds.Bottom:=NewBounds.Top+Max(70,Form.Height);
  572. debugln(['TMainIDEBase.mnuCenterWindowItemClick New=',dbgs(NewBounds)]);
  573. Form.BoundsRect:=NewBounds;
  574. Form.WindowState:=wsNormal;
  575. Form.BringToFront;
  576. end;
  577. break;
  578. end;
  579. dec(i);
  580. end;
  581. end;
  582. procedure TMainIDEBase.mnuWindowSourceItemClick(Sender: TObject);
  583. var
  584. i: LongInt;
  585. begin
  586. if SourceEditorManager = nil then exit;
  587. i:=(sender as TIDEMenuCommand).tag;
  588. if (i<0) or (i>=SourceEditorManager.SourceEditorCount) then exit;
  589. SourceEditorManager.ActiveEditor := SourceEditorManager.SourceEditors[i];
  590. SourceEditorManager.ShowActiveWindowOnTop(True);
  591. end;
  592. procedure TMainIDEBase.SetToolStatus(const AValue: TIDEToolStatus);
  593. begin
  594. if ToolStatus=AValue then exit;
  595. inherited SetToolStatus(AValue);
  596. UpdateCaption;
  597. end;
  598. constructor TMainIDEBase.Create(TheOwner: TComponent);
  599. begin
  600. // Do not own everything in one big component hierachy. Otherwise the
  601. // notifications slow down everything
  602. fOwningComponent:=TComponent.Create(nil);
  603. inherited Create(TheOwner);
  604. end;
  605. destructor TMainIDEBase.Destroy;
  606. begin
  607. FreeThenNil(fOwningComponent);
  608. inherited Destroy;
  609. end;
  610. procedure TMainIDEBase.GetUnitInfoForDesigner(ADesigner: TIDesigner;
  611. out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo);
  612. var
  613. SrcEdit: TSourceEditor;
  614. begin
  615. ActiveSourceEditor:=nil;
  616. ActiveUnitInfo:=nil;
  617. if ADesigner is TDesigner then begin
  618. GetDesignerUnit(TDesigner(ADesigner),SrcEdit,ActiveUnitInfo);
  619. ActiveSourceEditor:=SrcEdit;
  620. end;
  621. end;
  622. procedure TMainIDEBase.GetCurrentUnitInfo(
  623. out ActiveSourceEditor: TSourceEditorInterface; out ActiveUnitInfo: TUnitInfo);
  624. var
  625. ASrcEdit: TSourceEditor;
  626. AnUnitInfo: TUnitInfo;
  627. begin
  628. GetCurrentUnit(ASrcEdit, AnUnitInfo);
  629. ActiveSourceEditor:=ASrcEdit;
  630. ActiveUnitInfo:=AnUnitInfo;
  631. end;
  632. function TMainIDEBase.GetMainBar: TForm;
  633. begin
  634. Result:=MainIDEBar;
  635. end;
  636. procedure TMainIDEBase.SetRecentProjectFilesMenu;
  637. begin
  638. SetRecentSubMenu(itmProjectRecentOpen,
  639. EnvironmentOptions.RecentProjectFiles,
  640. @mnuOpenProjectClicked);
  641. end;
  642. procedure TMainIDEBase.SetRecentFilesMenu;
  643. begin
  644. SetRecentSubMenu(itmFileRecentOpen,
  645. EnvironmentOptions.RecentOpenFiles,
  646. @mnuOpenRecentClicked);
  647. end;
  648. function TMainIDEBase.BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
  649. out ActiveUnitInfo: TUnitInfo; Flags: TCodeToolsFlags): boolean;
  650. begin
  651. Result:=BeginCodeTool(nil,ActiveSrcEdit,ActiveUnitInfo,Flags);
  652. end;
  653. function TMainIDEBase.BeginCodeTool(ADesigner: TDesigner;
  654. var ActiveSrcEdit: TSourceEditor; out ActiveUnitInfo: TUnitInfo;
  655. Flags: TCodeToolsFlags): boolean;
  656. var
  657. Edit: TIDESynEditor;
  658. begin
  659. Result:=false;
  660. if (ctfUseGivenSourceEditor in Flags) and (Project1<>nil)
  661. and (ActiveSrcEdit<>nil) then begin
  662. ActiveUnitInfo := Project1.EditorInfoWithEditorComponent(ActiveSrcEdit).UnitInfo;
  663. end
  664. else begin
  665. ActiveSrcEdit:=nil;
  666. ActiveUnitInfo:=nil;
  667. end;
  668. // check global stati
  669. if (ToolStatus in [itCodeTools,itCodeToolAborting]) then begin
  670. debugln('TMainIDEBase.BeginCodeTool impossible ',dbgs(ord(ToolStatus)));
  671. exit;
  672. end;
  673. if (not (ctfSourceEditorNotNeeded in Flags)) and (SourceEditorManager.SourceEditorCount=0)
  674. then begin
  675. //DebugLn('TMainIDEBase.BeginCodeTool no source editor');
  676. exit;
  677. end;
  678. // check source editor
  679. if not (ctfUseGivenSourceEditor in Flags) then begin
  680. if ctfSwitchToFormSource in Flags then
  681. DoSwitchToFormSrc(ADesigner,ActiveSrcEdit,ActiveUnitInfo)
  682. else if ADesigner<>nil then
  683. GetDesignerUnit(ADesigner,ActiveSrcEdit,ActiveUnitInfo)
  684. else
  685. GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
  686. end;
  687. if (not (ctfSourceEditorNotNeeded in Flags)) and
  688. ((ActiveSrcEdit=nil) or (ActiveUnitInfo=nil))
  689. then exit;
  690. // init codetools
  691. SaveSourceEditorChangesToCodeCache(nil);
  692. if ActiveSrcEdit<>nil then begin
  693. Edit:=ActiveSrcEdit.EditorComponent;
  694. CodeToolBoss.VisibleEditorLines:=Edit.LinesInWindow;
  695. CodeToolBoss.TabWidth:=Edit.TabWidth;
  696. CodeToolBoss.IndentSize:=Edit.BlockIndent+Edit.BlockTabIndent*Edit.TabWidth;
  697. CodeToolBoss.UseTabs:=Edit.BlockTabIndent>0;
  698. end else begin
  699. CodeToolBoss.VisibleEditorLines:=25;
  700. CodeToolBoss.TabWidth:=EditorOpts.TabWidth;
  701. CodeToolBoss.IndentSize:=EditorOpts.BlockIndent+EditorOpts.BlockTabIndent*EditorOpts.TabWidth;
  702. CodeToolBoss.UseTabs:=EditorOpts.BlockTabIndent>0;
  703. end;
  704. if ctfActivateAbortMode in Flags then
  705. ActivateCodeToolAbortableMode;
  706. Result:=true;
  707. end;
  708. procedure TMainIDEBase.ActivateCodeToolAbortableMode;
  709. begin
  710. if ToolStatus=itNone then
  711. RaiseException('TMainIDEBase.ActivateCodeToolAbortableMode Error 1');
  712. ToolStatus:=itCodeTools;
  713. CodeToolBoss.OnCheckAbort:=@OnCodeToolBossCheckAbort;
  714. CodeToolBoss.Abortable:=true;
  715. end;
  716. function TMainIDEBase.OnCodeToolBossCheckAbort: boolean;
  717. begin
  718. Result:=true;
  719. if ToolStatus<>itCodeTools then exit;
  720. Application.ProcessMessages;
  721. Result:=ToolStatus<>itCodeTools;
  722. end;
  723. procedure TMainIDEBase.DoMergeDefaultProjectOptions(AProject: TProject);
  724. var
  725. AFilename: String;
  726. ShortFilename: String;
  727. begin
  728. // load default project options if exists
  729. AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename;
  730. if not FileExistsUTF8(AFilename) then
  731. CopySecondaryConfigFile(DefaultProjectOptionsFilename);
  732. if FileExistsUTF8(AFilename) then
  733. if AProject.ReadProject(AFilename,nil,False)<>mrOk then
  734. DebugLn(['TMainIDEBase.DoLoadDefaultCompilerOptions failed']);
  735. // change target file name
  736. AFilename:=ExtractFileName(AProject.CompilerOptions.TargetFilename);
  737. if AFilename='' then
  738. exit; // using default -> ok
  739. if CompareFilenames(AFilename,ExtractFilename(AProject.ProjectInfoFile))=0
  740. then exit; // target file name and project name fit -> ok
  741. // change target file to project name
  742. ShortFilename:=ExtractFileNameOnly(AProject.ProjectInfoFile);
  743. if ShortFilename<>'' then
  744. AProject.CompilerOptions.TargetFilename:=
  745. ExtractFilePath(AProject.CompilerOptions.TargetFilename)
  746. +ShortFilename+ExtractFileExt(AFilename);
  747. AProject.CompilerOptions.Modified:=false;
  748. end;
  749. procedure TMainIDEBase.DoSwitchToFormSrc(var ActiveSourceEditor: TSourceEditor;
  750. var ActiveUnitInfo: TUnitInfo);
  751. begin
  752. DoSwitchToFormSrc(nil,ActiveSourceEditor,ActiveUnitInfo);
  753. end;
  754. procedure TMainIDEBase.DoSwitchToFormSrc(ADesigner: TIDesigner;
  755. var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
  756. begin
  757. if (ADesigner<>nil) then
  758. ActiveUnitInfo:=Project1.UnitWithComponent(ADesigner.LookupRoot)
  759. else if (GlobalDesignHook.LookupRoot<>nil)
  760. and (GlobalDesignHook.LookupRoot is TComponent) then
  761. ActiveUnitInfo:=Project1.UnitWithComponent(TComponent(GlobalDesignHook.LookupRoot))
  762. else
  763. ActiveUnitInfo:=nil;
  764. if (ActiveUnitInfo<>nil) and (ActiveUnitInfo.OpenEditorInfoCount > 0) then begin
  765. ActiveSourceEditor := TSourceEditor(ActiveUnitInfo.OpenEditorInfo[0].EditorComponent);
  766. SourceEditorManagerIntf.ActiveEditor := ActiveSourceEditor;
  767. end
  768. else
  769. ActiveSourceEditor:=nil;
  770. end;
  771. procedure TMainIDEBase.DoMnuWindowClicked(Sender: TObject);
  772. begin
  773. UpdateWindowMenu;
  774. end;
  775. procedure TMainIDEBase.SetDisplayState(AValue: TDisplayState);
  776. begin
  777. if FDisplayState=AValue then Exit;
  778. FDisplayState:=AValue;
  779. {$IFDEF VerboseIDEDisplayState}
  780. debugln(['TMainIDEBase.SetDisplayState ',dbgs(DisplayState)]);
  781. {$ENDIF}
  782. end;
  783. function TMainIDEBase.CreateMenuSeparator : TMenuItem;
  784. begin
  785. Result := TMenuItem.Create(MainIDEBar);
  786. Result.Caption := '-';
  787. end;
  788. procedure TMainIDEBase.CreateMenuItem(Section: TIDEMenuSection;
  789. var MenuCommand: TIDEMenuCommand; const MenuItemName, MenuItemCaption: String;
  790. const bmpName: String; mnuEnabled: Boolean; mnuChecked: Boolean;
  791. mnuVisible: Boolean);
  792. begin
  793. MenuCommand:=RegisterIDEMenuCommand(Section,MenuItemName,MenuItemCaption);
  794. MenuCommand.Enabled:=mnuEnabled;
  795. MenuCommand.Checked:=mnuChecked;
  796. MenuCommand.Visible:=mnuVisible;
  797. if bmpName<>'' then
  798. MenuCommand.ImageIndex := IDEImages.LoadImage(16, bmpName);
  799. end;
  800. procedure TMainIDEBase.CreateMenuSeparatorSection(
  801. ParentSection: TIDEMenuSection; var Section: TIDEMenuSection;
  802. const AName: String);
  803. begin
  804. Section:=RegisterIDEMenuSection(ParentSection,AName);
  805. Section.ChildrenAsSubMenu := false;
  806. end;
  807. procedure TMainIDEBase.CreateMenuSubSection(ParentSection: TIDEMenuSection;
  808. var Section: TIDEMenuSection; const AName, ACaption: String;
  809. const bmpName: String = '');
  810. begin
  811. Section:=RegisterIDESubMenu(ParentSection,AName,ACaption);
  812. if bmpName<>'' then
  813. Section.ImageIndex := IDEImages.LoadImage(16, bmpName);
  814. end;
  815. procedure TMainIDEBase.CreateMainMenuItem(var Section: TIDEMenuSection;
  816. const MenuItemName, MenuItemCaption: String);
  817. begin
  818. Section:=RegisterIDESubMenu(mnuMain,MenuItemName,MenuItemCaption);
  819. end;
  820. procedure TMainIDEBase.SetupMainMenu;
  821. begin
  822. MainIDEBar.mnuMainMenu := TMainMenu.Create(MainIDEBar);
  823. MainIDEBar.mnuMainMenu.Images := IDEImages.Images_16;
  824. with MainIDEBar do begin
  825. mnuMain:=RegisterIDEMenuRoot('IDEMainMenu',nil);
  826. {$ifdef LCLCarbon}
  827. // Under Apple there is a special policy: every application should create
  828. // a special Apple menu and put Quit, About there.
  829. // See issue: http://bugs.freepascal.org/view.php?id=12294
  830. // See http://lists.apple.com/archives/carbon-development/2002/Apr/msg01183.html, for details
  831. //CreateMainMenuItem(mnuApple,'AppleApplication','');
  832. {$endif}
  833. CreateMainMenuItem(mnuFile,'File',lisMenuFile);
  834. CreateMainMenuItem(mnuEdit,'Edit',lisMenuEdit);
  835. CreateMainMenuItem(mnuSearch,'Search',lisMenuSearch);
  836. CreateMainMenuItem(mnuView,'View',lisMenuView);
  837. CreateMainMenuItem(mnuSource,'Source',lisMenuSource);
  838. CreateMainMenuItem(mnuProject,'Project',lisMenuProject);
  839. CreateMainMenuItem(mnuRun,'Run',lisMenuRun);
  840. CreateMainMenuItem(mnuPackage,'Package',lisMenuPackage);
  841. mnuComponent:=mnuPackage;
  842. CreateMainMenuItem(mnuTools,'Tools',lisMenuTools);
  843. CreateMainMenuItem(mnuWindow,'Window',lisMenuWindow);
  844. mnuWindow.OnClick := @DoMnuWindowClicked;
  845. CreateMainMenuItem(mnuHelp,'Help',lisMenuHelp);
  846. end;
  847. end;
  848. procedure TMainIDEBase.SetupFileMenu;
  849. var
  850. ParentMI: TIDEMenuSection;
  851. begin
  852. with MainIDEBar do begin
  853. CreateMenuSeparatorSection(mnuFile,itmFileNew,'itmFileNew');
  854. ParentMI:=itmFileNew;
  855. CreateMenuItem(ParentMI,itmFileNewUnit,'itmFileNewUnit',lisMenuNewUnit,'item_unit');
  856. CreateMenuItem(ParentMI,itmFileNewForm,'itmFileNewForm',lisMenuNewForm,'item_form');
  857. CreateMenuItem(ParentMI,itmFileNewOther,'itmFileNewOther',lisMenuNewOther,'menu_new');
  858. CreateMenuSeparatorSection(mnuFile,itmFileOpenSave,'itmFileOpenSave');
  859. ParentMI:=itmFileOpenSave;
  860. CreateMenuItem(ParentMI, itmFileOpen, 'itmFileOpen', lisMenuOpen, 'laz_open');
  861. CreateMenuItem(ParentMI,itmFileRevert,'itmFileRevert',lisMenuRevert, 'menu_file_revert');
  862. CreateMenuItem(ParentMI, itmFileOpenUnit, 'itmFileOpenUnit', lisMenuOpenUnit, 'laz_openunit');
  863. CreateMenuSubSection(ParentMI,itmFileRecentOpen,'itmFileRecentOpen',lisMenuOpenRecent);
  864. CreateMenuItem(ParentMI,itmFileSave,'itmFileSave',lisMenuSave,'laz_save');
  865. CreateMenuItem(ParentMI,itmFileSaveAs,'itmFileSaveAs',lisMenuSaveAs,'menu_saveas');
  866. CreateMenuItem(ParentMI,itmFileSaveAll,'itmFileSaveAll',lisSaveAll,'menu_save_all');
  867. CreateMenuItem(ParentMI,itmFileExportHtml,'itmFileExportHtml',lisExportHtml);
  868. CreateMenuItem(ParentMI,itmFileClose,'itmFileClose',lisMenuCloseEditorFile,'menu_close',false);
  869. CreateMenuItem(ParentMI,itmFileCloseAll,'itmFileCloseAll',lisMenuCloseAll,'menu_close_all',false);
  870. CreateMenuSeparatorSection(mnuFile,itmFileDirectories,'itmFileDirectories');
  871. ParentMI:=itmFileDirectories;
  872. CreateMenuItem(ParentMI,itmFileCleanDirectory,'itmFileCleanDirectory',lisMenuCleanDirectory, 'menu_clean');
  873. CreateMenuSeparatorSection(mnuFile,itmFileIDEStart,'itmFileIDEStart');
  874. ParentMI:=itmFileIDEStart;
  875. CreateMenuItem(ParentMI,itmFileRestart,'itmFileRestart',lisRestart, 'laz_refresh');
  876. CreateMenuItem(ParentMI,itmFileQuit,'itmFileQuit',lisBtnQuit, 'menu_exit');
  877. end;
  878. end;
  879. procedure TMainIDEBase.SetupEditMenu;
  880. var
  881. ParentMI: TIDEMenuSection;
  882. begin
  883. with MainIDEBar do begin
  884. CreateMenuSeparatorSection(mnuEdit,itmEditReUndo,'itmEditReUndo');
  885. ParentMI:=itmEditReUndo;
  886. CreateMenuItem(ParentMI,itmEditUndo,'itmEditUndo',lisUndo,'menu_undo');
  887. CreateMenuItem(ParentMI,itmEditRedo,'itmEditRedo',lisRedo,'menu_redo');
  888. CreateMenuSeparatorSection(mnuEdit,itmEditClipboard,'itmEditClipboard');
  889. ParentMI:=itmEditClipboard;
  890. CreateMenuItem(ParentMI,itmEditCut,'itmEditCut',lisCut,'laz_cut');
  891. CreateMenuItem(ParentMI,itmEditCopy,'itmEditCopy',lisCopy,'laz_copy');
  892. CreateMenuItem(ParentMI,itmEditPaste,'itmEditPaste',lisPaste,'laz_paste');
  893. // "Select" menu items
  894. CreateMenuSeparatorSection(mnuEdit,itmEditSelect,'itmEditSelect');
  895. ParentMI:=itmEditSelect;
  896. CreateMenuItem(ParentMI,itmEditSelectAll,'itmEditSelectAll',lisMenuSelectAll, 'menu_select_all');
  897. CreateMenuItem(ParentMI,itmEditSelectToBrace,'itmEditSelectToBrace',lisMenuSelectToBrace);
  898. CreateMenuItem(ParentMI,itmEditSelectCodeBlock,'itmEditSelectCodeBlock',lisMenuSelectCodeBlock);
  899. CreateMenuItem(ParentMI,itmEditSelectWord,'itmEditSelectWord',lisMenuSelectWord);
  900. CreateMenuItem(ParentMI,itmEditSelectLine,'itmEditSelectLine',lisMenuSelectLine);
  901. CreateMenuItem(ParentMI,itmEditSelectParagraph,'itmEditSelectParagraph',lisMenuSelectParagraph);
  902. // "Char Conversion" menu items
  903. CreateMenuSeparatorSection(mnuEdit,itmEditBlockActions,'itmEditBlockActions');
  904. ParentMI:=itmEditBlockActions;
  905. CreateMenuItem(ParentMI,itmEditIndentBlock,'itmEditIndentBlock',lisMenuIndentSelection,'menu_indent');
  906. CreateMenuItem(ParentMI,itmEditUnindentBlock,'itmEditUnindentBlock',lisMenuUnindentSelection,'menu_unindent');
  907. CreateMenuItem(ParentMI,itmEditUpperCaseBlock,'itmEditUpperCaseBlock',lisMenuUpperCaseSelection, 'menu_edit_uppercase');
  908. CreateMenuItem(ParentMI,itmEditLowerCaseBlock,'itmEditLowerCaseBlock',lisMenuLowerCaseSelection, 'menu_edit_lowercase');
  909. CreateMenuItem(ParentMI,itmEditSwapCaseBlock,'itmEditSwapCaseBlock',lisMenuSwapCaseSelection, 'menu_edit_uppercase');
  910. CreateMenuItem(ParentMI,itmEditSortBlock,'itmEditSortBlock',lisMenuSortSelection, 'menu_edit_sort');
  911. CreateMenuItem(ParentMI,itmEditTabsToSpacesBlock,'itmEditTabsToSpacesBlock',lisMenuTabsToSpacesSelection);
  912. CreateMenuItem(ParentMI,itmEditSelectionBreakLines,'itmEditSelectionBreakLines',lisMenuBeakLinesInSelection);
  913. // *** insert text ***:
  914. CreateMenuSeparatorSection(mnuEdit,itmEditInsertions,'itmEditInsertions');
  915. ParentMI:=itmEditInsertions;
  916. CreateMenuItem(ParentMI,itmEditInsertCharacter,'itmEditInsertCharacter',lisMenuInsertCharacter);
  917. end;
  918. end;
  919. procedure TMainIDEBase.SetupSearchMenu;
  920. var
  921. ParentMI: TIDEMenuSection;
  922. begin
  923. with MainIDEBar do begin
  924. CreateMenuSeparatorSection(mnuSearch,itmSearchFindReplace,'itmSearchFindReplace');
  925. ParentMI:=itmSearchFindReplace;
  926. CreateMenuItem(ParentMI,itmSearchFind, 'itmSearchFind', lisMenuFind2, 'menu_search_find');
  927. CreateMenuItem(ParentMI,itmSearchFindNext,'itmSearchFindNext',lisMenuFindNext, 'menu_search_find_next');
  928. CreateMenuItem(ParentMI,itmSearchFindPrevious,'itmSearchFindPrevious',lisMenuFindPrevious, 'menu_search_find_previous');
  929. CreateMenuItem(ParentMI,itmSearchFindInFiles,'itmSearchFindInFiles',lisMenuFindInFiles, 'menu_search_files');
  930. CreateMenuItem(ParentMI, itmSearchReplace, 'itmSearchReplace', lisBtnDlgReplace, 'menu_search_replace');
  931. CreateMenuItem(ParentMI,itmIncrementalFind,'itmIncrementalFind',lisMenuIncrementalFind, 'menu_search_incremental');
  932. CreateMenuSeparatorSection(mnuSearch,itmJumpings,'itmJumpings');
  933. ParentMI:=itmJumpings;
  934. CreateMenuItem(ParentMI,itmGotoLine,'itmGotoLine',lisMenuGotoLine, 'menu_goto_line');
  935. CreateMenuItem(ParentMI,itmJumpBack,'itmJumpBack',lisMenuJumpBack, 'menu_search_jumpback');
  936. CreateMenuItem(ParentMI,itmJumpForward,'itmJumpForward',lisMenuJumpForward, 'menu_search_jumpforward');
  937. CreateMenuItem(ParentMI,itmAddJumpPoint,'itmAddJumpPoint',lisMenuAddJumpPointToHistory);
  938. CreateMenuItem(ParentMI,itmJumpToNextError,'itmJumpToNextError',lisMenuJumpToNextError);
  939. CreateMenuItem(ParentMI,itmJumpToPrevError,'itmJumpToPrevError',lisMenuJumpToPrevError);
  940. CreateMenuSubSection(ParentMI,itmJumpToSection,'itmJumpToSection',lisMenuJumpTo);
  941. ParentMI:=itmJumpToSection;
  942. CreateMenuItem(ParentMI,itmJumpToInterface,'itmJumpToInterface',lisMenuJumpToInterface, 'menu_jumpto_interface');
  943. CreateMenuItem(ParentMI,itmJumpToInterfaceUses,'itmJumpToInterfaceUses',lisMenuJumpToInterfaceUses, 'menu_jumpto_interfaceuses');
  944. CreateMenuItem(ParentMI,itmJumpToImplementation,'itmJumpToImplementation',lisMenuJumpToImplementation, 'menu_jumpto_implementation');
  945. CreateMenuItem(ParentMI,itmJumpToImplementationUses,'itmJumpToImplementationUses',lisMenuJumpToImplementationUses, 'menu_jumpto_implementationuses');
  946. CreateMenuItem(ParentMI,itmJumpToInitialization,'itmJumpToInitialization',lisMenuJumpToInitialization, 'menu_jumpto_initialization');
  947. CreateMenuSeparatorSection(mnuSearch,itmBookmarks,'itmBookmarks');
  948. ParentMI:=itmBookmarks;
  949. CreateMenuItem(ParentMI,itmSetFreeBookmark,'itmSetFreeBookmark',lisMenuSetFreeBookmark, 'menu_search_set_bookmark');
  950. CreateMenuItem(ParentMI,itmJumpToNextBookmark,'itmJumpToNextBookmark',lisMenuJumpToNextBookmark, 'menu_search_next_bookmark');
  951. CreateMenuItem(ParentMI,itmJumpToPrevBookmark,'itmJumpToPrevBookmark',lisMenuJumpToPrevBookmark, 'menu_search_previous_bookmark');
  952. CreateMenuSeparatorSection(mnuSearch,itmCodeToolSearches,'itmCodeToolSearches');
  953. ParentMI:=itmCodeToolSearches;
  954. CreateMenuItem(ParentMI,itmFindBlockOtherEnd,'itmFindBlockOtherEnd',lisMenuFindBlockOtherEndOfCodeBlock);
  955. CreateMenuItem(ParentMI,itmFindBlockStart,'itmFindBlockStart',lisMenuFindCodeBlockStart);
  956. CreateMenuItem(ParentMI,itmFindDeclaration,'itmFindDeclaration',lisMenuFindDeclarationAtCursor);
  957. CreateMenuItem(ParentMI,itmOpenFileAtCursor,'itmOpenFileAtCursor',lisMenuOpenFilenameAtCursor,'menu_search_openfile_atcursor');
  958. CreateMenuItem(ParentMI,itmGotoIncludeDirective,'itmGotoIncludeDirective',lisMenuGotoIncludeDirective);
  959. CreateMenuItem(ParentMI,itmSearchFindIdentifierRefs,'itmSearchFindIdentifierRefs',lisMenuFindIdentifierRefs);
  960. CreateMenuItem(ParentMI,itmSearchProcedureList,'itmSearchProcedureList',lisMenuProcedureList);
  961. end;
  962. end;
  963. procedure TMainIDEBase.SetupViewMenu;
  964. var
  965. ParentMI: TIDEMenuSection;
  966. begin
  967. with MainIDEBar do begin
  968. CreateMenuSeparatorSection(mnuView,itmViewMainWindows,'itmViewMainWindows');
  969. ParentMI:=itmViewMainWindows;
  970. CreateMenuItem(ParentMI,itmViewToggleFormUnit,'itmViewToggleFormUnit',lisMenuViewToggleFormUnit, 'menu_view_toggle_form_unit');
  971. CreateMenuItem(ParentMI,itmViewInspector,'itmViewInspector',lisMenuViewObjectInspector, 'menu_view_inspector');
  972. CreateMenuItem(ParentMI,itmViewSourceEditor,'itmViewSourceEditor',lisMenuViewSourceEditor, 'menu_view_source_editor');
  973. CreateMenuItem(ParentMI,itmViewMessage,'itmViewMessage',lisMenuViewMessages);
  974. CreateMenuItem(ParentMI,itmViewCodeExplorer,'itmViewCodeExplorer',lisMenuViewCodeExplorer, 'menu_view_code_explorer');
  975. CreateMenuItem(ParentMI,itmViewFPDocEditor,'itmViewFPDocEditor',lisFPDocEditor);
  976. CreateMenuItem(ParentMI,itmViewCodeBrowser,'itmViewCodeBrowser',lisMenuViewCodeBrowser, 'menu_view_code_browser');
  977. CreateMenuItem(ParentMI,itmSourceUnitDependencies,'itmSourceUnitDependencies',lisMenuViewUnitDependencies);
  978. CreateMenuItem(ParentMI,itmViewRestrictionBrowser,'itmViewRestrictionBrowser',lisMenuViewRestrictionBrowser, 'menu_view_rectriction_browser');
  979. CreateMenuItem(ParentMI,itmViewComponents,'itmViewComponents',lisMenuViewComponents);
  980. CreateMenuItem(ParentMI,itmJumpHistory,'itmJumpHistory',lisMenuViewJumpHistory);
  981. CreateMenuItem(ParentMI,itmMacroListView,'itmMacroListView',lisMenuMacroListView);
  982. CreateMenuSeparatorSection(mnuView,itmViewDesignerWindows,'itmViewDesignerWindows');
  983. ParentMI:=itmViewDesignerWindows;
  984. CreateMenuItem(ParentMI,itmViewAnchorEditor,'itmViewAnchorEditor',lisMenuViewAnchorEditor,'menu_view_anchor_editor');
  985. CreateMenuItem(ParentMI,itmViewTabOrder,'itmViewTabOrder',lisMenuViewTabOrder,'tab_order');
  986. CreateMenuSeparatorSection(mnuView,itmViewSecondaryWindows,'itmViewSecondaryWindows');
  987. ParentMI:=itmViewSecondaryWindows;
  988. CreateMenuItem(ParentMI,itmViewSearchResults,'itmViewSearchResults',lisMenuViewSearchResults);
  989. CreateMenuSubSection(ParentMI,itmViewDebugWindows,'itmViewDebugWindows',lisMenuDebugWindows,'debugger');
  990. begin
  991. CreateMenuItem(itmViewDebugWindows,itmViewWatches,'itmViewWatches',lisMenuViewWatches,'debugger_watches');
  992. CreateMenuItem(itmViewDebugWindows,itmViewBreakPoints,'itmViewBreakPoints',lisMenuViewBreakPoints,'debugger_breakpoints');
  993. CreateMenuItem(itmViewDebugWindows,itmViewLocals,'itmViewLocals',lisMenuViewLocalVariables);
  994. if HasConsoleSupport then
  995. CreateMenuItem(itmViewDebugWindows,itmViewPseudoTerminal,'itmViewPseudoTerminal',lisMenuViewPseudoTerminal)
  996. else
  997. itmViewPseudoTerminal := nil;
  998. CreateMenuItem(itmViewDebugWindows,itmViewRegisters,'itmViewRegisters',lisMenuViewRegisters);
  999. CreateMenuItem(itmViewDebugWindows,itmViewCallStack,'itmViewCallStack',lisMenuViewCallStack,'debugger_call_stack');
  1000. CreateMenuItem(itmViewDebugWindows,itmViewThreads,'itmViewThreads',lisMenuViewThreads);
  1001. CreateMenuItem(itmViewDebugWindows,itmViewAssembler,'itmViewAssembler',lisMenuViewAssembler);
  1002. CreateMenuItem(itmViewDebugWindows,itmViewDebugEvents,'itmViewDebugEvents',lisMenuViewDebugEvents,'debugger_event_log');
  1003. CreateMenuItem(itmViewDebugWindows,itmViewDebugOutput,'itmViewDebugOutput',lisMenuViewDebugOutput,'debugger_output');
  1004. CreateMenuItem(itmViewDebugWindows,itmViewDbgHistory,'itmViewDbgHistory',lisMenuViewHistory);
  1005. end;
  1006. CreateMenuSubSection(ParentMI, itmViewIDEInternalsWindows, 'itmViewIDEInternalsWindows', lisMenuIDEInternals);
  1007. begin
  1008. CreateMenuItem(itmViewIDEInternalsWindows, itmViewFPCInfo, 'itmViewFPCInfo', lisMenuAboutFPC);
  1009. CreateMenuItem(itmViewIDEInternalsWindows, itmViewIDEInfo, 'itmViewIDEInfo', lisAboutIDE);
  1010. CreateMenuItem(itmViewIDEInternalsWindows, itmViewNeedBuild, 'itmViewNeedBuild', lisMenuWhatNeedsBuilding);
  1011. {$IFDEF EnableFPDocSearch}
  1012. CreateMenuItem(itmViewIDEInternalsWindows, itmSearchInFPDocFiles,'itmSearchInFPDocFiles','Search in FPDoc files');
  1013. {$ENDIF}
  1014. end;
  1015. end;
  1016. end;
  1017. procedure TMainIDEBase.SetupSourceMenu;
  1018. var
  1019. ParentMI, SubParentMI: TIDEMenuSection;
  1020. begin
  1021. with MainIDEBar do begin
  1022. CreateMenuSeparatorSection(mnuSource,itmSourceBlockActions,'itmSourceBlockActions');
  1023. ParentMI:=itmSourceBlockActions;
  1024. CreateMenuItem(ParentMI,itmSourceCommentBlock,'itmSourceCommentBlock',lisMenuCommentSelection, 'menu_comment');
  1025. CreateMenuItem(ParentMI,itmSourceUncommentBlock,'itmSourceUncommentBlock',lisMenuUncommentSelection, 'menu_uncomment');
  1026. CreateMenuItem(ParentMI,itmSourceToggleComment,'itmSourceToggleComment',lisMenuToggleComment, 'menu_comment');
  1027. CreateMenuItem(ParentMI,itmSourceEncloseBlock,'itmSourceEncloseBlock',lisMenuEncloseSelection);
  1028. CreateMenuItem(ParentMI,itmSourceEncloseInIFDEF,'itmSourceEncloseInIFDEF',lisMenuEncloseInIFDEF);
  1029. CreateMenuItem(ParentMI,itmSourceCompleteCodeInteractive,'itmSourceCompleteCodeInteractive',lisMenuCompleteCodeInteractive);
  1030. CreateMenuItem(ParentMI,itmRefactorInvertAssignment,'itmInvertAssignment',uemInvertAssignment);
  1031. CreateMenuItem(ParentMI,itmSourceUseUnit,'itmSourceUseUnit',lisMenuUseUnit);
  1032. // Refactor
  1033. CreateMenuSeparatorSection(mnuSource,itmSourceRefactor,'itmSourceRefactor');
  1034. CreateMenuSubSection(ParentMI,itmSourceRefactor,'itmSourceRefactor',uemRefactor);
  1035. SubParentMI:=itmSourceRefactor;
  1036. CreateMenuSeparatorSection(SubParentMI,itmRefactorCodeTools,'itmRefactorCodeTools');
  1037. ParentMI:=itmRefactorCodeTools;
  1038. CreateMenuItem(ParentMI,itmRefactorRenameIdentifier,'itmRefactorRenameIdentifier',lisMenuRenameIdentifier);
  1039. CreateMenuItem(ParentMI,itmRefactorExtractProc,'itmRefactorExtractProc',lisMenuExtractProc);
  1040. CreateMenuSeparatorSection(SubParentMI,itmRefactorAdvanced,'itmRefactorAdvanced');
  1041. ParentMI:=itmRefactorAdvanced;
  1042. CreateMenuItem(ParentMI,itmRefactorShowAbstractMethods,'itmShowAbstractMethods',srkmecAbstractMethods);
  1043. CreateMenuItem(ParentMI,itmRefactorShowEmptyMethods,'itmShowEmptyMethods',srkmecEmptyMethods);
  1044. CreateMenuItem(ParentMI,itmRefactorShowUnusedUnits,'itmShowUnusedUnits',srkmecUnusedUnits);
  1045. {$IFDEF EnableFindOverloads}
  1046. CreateMenuItem(ParentMI,itmRefactorFindOverloads,'itmFindOverloads',srkmecFindOverloadsCapt);
  1047. {$ENDIF}
  1048. CreateMenuSeparatorSection(SubParentMI,itmRefactorTools,'itmRefactorTools');
  1049. ParentMI:=itmRefactorTools;
  1050. CreateMenuItem(ParentMI,itmRefactorMakeResourceString,'itmRefactorMakeResourceString',
  1051. lisMenuMakeResourceString,'menu_tool_make_resourcestring');
  1052. // CodeToolChecks
  1053. CreateMenuSeparatorSection(mnuSource,itmSourceCodeToolChecks,'itmSourceCodeToolChecks');
  1054. ParentMI:=itmSourceCodeToolChecks;
  1055. CreateMenuItem(ParentMI,itmSourceSyntaxCheck,'itmSourceSyntaxCheck',lisMenuQuickSyntaxCheck, 'menu_tool_syntax_check');
  1056. CreateMenuItem(ParentMI,itmSourceGuessUnclosedBlock,'itmSourceGuessUnclosedBlock',lisMenuGuessUnclosedBlock);
  1057. CreateMenuItem(ParentMI,itmSourceGuessMisplacedIFDEF,'itmSourceGuessMisplacedIFDEF',lisMenuGuessMisplacedIFDEF);
  1058. CreateMenuSeparatorSection(mnuSource,itmSourceInsertions,'itmSourceInsertions');
  1059. ParentMI:=itmSourceInsertions;
  1060. // *** insert text ***:
  1061. CreateMenuSubSection(ParentMI,itmSourceInsertCVSKeyWord,'itmSourceInsertCVSKeyWord',lisMenuInsertCVSKeyword);
  1062. SubParentMI:=itmSourceInsertCVSKeyWord;
  1063. // insert CVS keyword sub menu items
  1064. CreateMenuItem(SubParentMI,itmSourceInsertCVSAuthor,'itmSourceInsertCVSAuthor','Author');
  1065. CreateMenuItem(SubParentMI,itmSourceInsertCVSDate,'itmSourceInsertCVSDate','Date');
  1066. CreateMenuItem(SubParentMI,itmSourceInsertCVSHeader,'itmSourceInsertCVSHeader','Header');
  1067. CreateMenuItem(SubParentMI,itmSourceInsertCVSID,'itmSourceInsertCVSID','ID');
  1068. CreateMenuItem(SubParentMI,itmSourceInsertCVSLog,'itmSourceInsertCVSLog','Log');
  1069. CreateMenuItem(SubParentMI,itmSourceInsertCVSName,'itmSourceInsertCVSName','Name');
  1070. CreateMenuItem(SubParentMI,itmSourceInsertCVSRevision,'itmSourceInsertCVSRevision','Revision');
  1071. CreateMenuItem(SubParentMI,itmSourceInsertCVSSource,'itmSourceInsertCVSSource','Source');
  1072. CreateMenuSubSection(ParentMI,itmSourceInsertGeneral,'itmSourceInsertGeneral',lisMenuInsertGeneral);
  1073. SubParentMI:=itmSourceInsertGeneral;
  1074. // insert general text sub menu items
  1075. CreateMenuItem(SubParentMI,itmSourceInsertGPLNotice,'itmSourceInsertGPLNotice',lisMenuInsertGPLNotice);
  1076. CreateMenuItem(SubParentMI,itmSourceInsertGPLNoticeTranslated,'itmSourceInsertGPLNoticeTranslated',lisMenuInsertGPLNoticeTranslated);
  1077. CreateMenuItem(SubParentMI,itmSourceInsertLGPLNotice,'itmSourceInsertLGPLNotice',lisMenuInsertLGPLNotice);
  1078. CreateMenuItem(SubParentMI,itmSourceInsertLGPLNoticeTranslated,'itmSourceInsertLGPLNoticeTranslated',lisMenuInsertLGPLNoticeTranslated);
  1079. CreateMenuItem(SubParentMI,itmSourceInsertModifiedLGPLNotice,'itmSourceInsertModifiedLGPLNotice',lisMenuInsertModifiedLGPLNotice);
  1080. CreateMenuItem(SubParentMI,itmSourceInsertModifiedLGPLNoticeTranslated,'itmSourceInsertModifiedLGPLNoticeTranslated',lisMenuInsertModifiedLGPLNoticeTranslated);
  1081. CreateMenuItem(SubParentMI,itmSourceInsertMITNotice,'itmSourceInsertMITNotice',lisMenuInsertMITNotice);
  1082. CreateMenuItem(SubParentMI,itmSourceInsertMITNoticeTranslated,'itmSourceInsertMITNoticeTranslated',lisMenuInsertMITNoticeTranslated);
  1083. CreateMenuItem(SubParentMI,itmSourceInsertUsername,'itmSourceInsertUsername',lisMenuInsertUsername);
  1084. CreateMenuItem(SubParentMI,itmSourceInsertDateTime,'itmSourceInsertDateTime',lisMenuInsertDateTime);
  1085. CreateMenuItem(SubParentMI,itmSourceInsertChangeLogEntry,'itmSourceInsertChangeLogEntry',lisMenuInsertChangeLogEntry);
  1086. CreateMenuItem(SubParentMI,itmSourceInsertGUID,'itmSourceInsertGUID',srkmecInsertGUID);
  1087. CreateMenuItem(itmSourceInsertions,itmSourceInsertFilename,'itmSourceInsertFilename',lisMenuInsertFilename);
  1088. CreateMenuSeparatorSection(mnuSource,itmSourceTools,'itmSourceTools');
  1089. ParentMI:=itmSourceTools;
  1090. CreateMenuItem(ParentMI,itmSourceUnitInfo,'itmViewUnitInfo',lisMenuViewUnitInfo, 'menu_view_unit_info');
  1091. end;
  1092. end;
  1093. procedure TMainIDEBase.SetupProjectMenu;
  1094. var
  1095. ParentMI: TIDEMenuSection;
  1096. begin
  1097. with MainIDEBar do begin
  1098. CreateMenuSeparatorSection(mnuProject,itmProjectNewSection,'itmProjectNewSection');
  1099. ParentMI:=itmProjectNewSection;
  1100. CreateMenuItem(ParentMI,itmProjectNew,'itmProjectNew',lisMenuNewProject, 'item_project');
  1101. CreateMenuItem(ParentMI,itmProjectNewFromFile,'itmProjectNewFromFile',lisMenuNewProjectFromFile, 'menu_project_from_file');
  1102. CreateMenuSeparatorSection(mnuProject,itmProjectOpenSection,'itmProjectOpenSection');
  1103. ParentMI:=itmProjectOpenSection;
  1104. CreateMenuItem(ParentMI,itmProjectOpen,'itmProjectOpen',lisMenuOpenProject,'menu_project_open');
  1105. CreateMenuSubSection(ParentMI,itmProjectRecentOpen,'itmProjectRecentOpen',lisMenuOpenRecentProject);
  1106. CreateMenuItem(ParentMI,itmProjectClose,'itmProjectClose',lisMenuCloseProject, 'menu_project_close');
  1107. CreateMenuSeparatorSection(mnuProject,itmProjectSaveSection,'itmProjectSaveSection');
  1108. ParentMI:=itmProjectSaveSection;
  1109. CreateMenuItem(ParentMI,itmProjectSave,'itmProjectSave',lisMenuSaveProject, 'menu_project_save');
  1110. CreateMenuItem(ParentMI,itmProjectSaveAs,'itmProjectSaveAs',lisMenuSaveProjectAs, 'menu_project_saveas');
  1111. CreateMenuItem(ParentMI, itmProjectResaveFormsWithI18n, 'itmProjectResaveFo'
  1112. +'rmsWithI18n', lisMenuResaveFormsWithI18n);
  1113. CreateMenuItem(ParentMI,itmProjectPublish,'itmProjectPublish',lisMenuPublishProject);
  1114. CreateMenuSeparatorSection(mnuProject,itmProjectWindowSection,'itmProjectWindowSection');
  1115. ParentMI:=itmProjectWindowSection;
  1116. CreateMenuItem(ParentMI,itmProjectInspector,'itmProjectInspector',lisMenuProjectInspector+' ...','menu_project_inspector');
  1117. CreateMenuItem(ParentMI,itmProjectOptions,'itmProjectOptions',lisMenuProjectOptions,'menu_project_options');
  1118. CreateMenuSeparatorSection(mnuProject,itmProjectAddRemoveSection,'itmProjectAddRemoveSection');
  1119. ParentMI:=itmProjectAddRemoveSection;
  1120. CreateMenuItem(ParentMI,itmProjectAddTo,'itmProjectAddTo',lisMenuAddToProject, 'menu_project_add');
  1121. CreateMenuItem(ParentMI,itmProjectRemoveFrom,'itmProjectRemoveFrom',lisMenuRemoveFromProject, 'menu_project_remove');
  1122. CreateMenuItem(ParentMI,itmProjectViewUnits,'itmProjectViewUnits',lisMenuViewUnits, 'menu_view_units');
  1123. CreateMenuItem(ParentMI,itmProjectViewForms,'itmProjectViewForms',lisMenuViewForms, 'menu_view_forms');
  1124. CreateMenuItem(ParentMI,itmProjectViewSource,'itmProjectViewSource',lisMenuViewProjectSource, 'menu_project_viewsource');
  1125. end;
  1126. end;
  1127. procedure TMainIDEBase.SetupRunMenu;
  1128. var
  1129. ParentMI: TIDEMenuSection;
  1130. begin
  1131. with MainIDEBar do begin
  1132. CreateMenuSeparatorSection(mnuRun,itmRunBuilding,'itmRunBuilding');
  1133. ParentMI:=itmRunBuilding;
  1134. CreateMenuItem(ParentMI,itmRunMenuCompile,'itmRunMenuCompile',lisCompile,'menu_build');
  1135. CreateMenuItem(ParentMI,itmRunMenuBuild,'itmRunMenuBuild',lisBuild,'menu_build_all');
  1136. CreateMenuItem(ParentMI,itmRunMenuQuickCompile,'itmRunMenuQuickCompile',lisMenuQuickCompile,'menu_quick_compile');
  1137. CreateMenuItem(ParentMI,itmRunMenuCleanUpAndBuild,'itmRunMenuCleanUpAndBuild',lisMenuCleanUpAndBuild,'menu_build');
  1138. CreateMenuItem(ParentMI,itmRunMenuBuildManyModes,'itmRunMenuBuildManyModes',lisMenuCompileManyModes,'menu_build_all');
  1139. CreateMenuItem(ParentMI,itmRunMenuAbortBuild,'itmRunMenuAbortBuild',lisMenuAbortBuild,'menu_abort_build');
  1140. CreateMenuSeparatorSection(mnuRun,itmRunnning,'itmRunnning');
  1141. ParentMI:=itmRunnning;
  1142. CreateMenuItem(ParentMI,itmRunMenuRunWithoutDebugging,'itmRunMenuRunWithoutDebugging',lisMenuRunWithoutDebugging,'menu_run_withoutdebugging');
  1143. CreateMenuItem(ParentMI,itmRunMenuRun,'itmRunMenuRun',lisMenuProjectRun,'menu_run');
  1144. CreateMenuItem(ParentMI,itmRunMenuPause,'itmRunMenuPause',lisPause,'menu_pause', False);
  1145. CreateMenuItem(ParentMI,itmRunMenuShowExecutionPoint,'itmRunMenuShowExecutionPoint',
  1146. lisMenuShowExecutionPoint,'debugger_show_execution_point', False);
  1147. CreateMenuItem(ParentMI,itmRunMenuStepInto,'itmRunMenuStepInto',lisMenuStepInto,'menu_stepinto');
  1148. CreateMenuItem(ParentMI,itmRunMenuStepOver,'itmRunMenuStepOver',lisMenuStepOver,'menu_stepover');
  1149. CreateMenuItem(ParentMI,itmRunMenuStepOut,'itmRunMenuStepOut',lisMenuStepOut,'menu_stepout');
  1150. CreateMenuItem(ParentMI,itmRunMenuRunToCursor,'itmRunMenuRunToCursor',lisMenuRunToCursor,'menu_run_cursor');
  1151. CreateMenuItem(ParentMI,itmRunMenuStop,'itmRunMenuStop',lisStop,'menu_stop', False);
  1152. CreateMenuItem(ParentMI,itmRunMenuAttach,'itmRunMenuAttach',srkmecAttach+' ...','', False);
  1153. CreateMenuItem(ParentMI,itmRunMenuDetach,'itmRunMenuDetach',srkmecDetach,'', False);
  1154. CreateMenuItem(ParentMI,itmRunMenuRunParameters,'itmRunMenuRunParameters',lisMenuRunParameters, 'menu_run_parameters');
  1155. CreateMenuItem(ParentMI,itmRunMenuResetDebugger,'itmRunMenuResetDebugger',lisMenuResetDebugger, 'menu_reset_debugger');
  1156. CreateMenuSeparatorSection(mnuRun,itmRunBuildingFile,'itmRunBuildingFile');
  1157. ParentMI:=itmRunBuildingFile;
  1158. CreateMenuItem(ParentMI,itmRunMenuBuildFile,'itmRunMenuBuildFile',lisMenuBuildFile, 'menu_build_file');
  1159. CreateMenuItem(ParentMI,itmRunMenuRunFile,'itmRunMenuRunFile',lisMenuRunFile,'menu_run_file');
  1160. CreateMenuItem(ParentMI,itmRunMenuConfigBuildFile,'itmRunMenuConfigBuildFile',lisMenuConfigBuildFile, 'menu_build_run_file');
  1161. CreateMenuSeparatorSection(mnuRun,itmRunDebugging,'itmRunDebugging');
  1162. ParentMI:=itmRunDebugging;
  1163. CreateMenuItem(ParentMI,itmRunMenuInspect,'itmRunMenuInspect',lisMenuInspect, 'debugger_inspect', False);
  1164. CreateMenuItem(ParentMI,itmRunMenuEvaluate,'itmRunMenuEvaluate',lisMenuEvaluate, 'debugger_modify', False);
  1165. CreateMenuItem(ParentMI,itmRunMenuAddWatch,'itmRunMenuAddWatch',lisMenuAddWatch, '', False);
  1166. CreateMenuSubSection(ParentMI,itmRunMenuAddBreakpoint,'itmRunMenuAddBreakpoint',lisMenuAddBreakpoint, '');
  1167. CreateMenuItem(itmRunMenuAddBreakpoint,itmRunMenuAddBPSource,'itmRunMenuAdddBPSource',lisSourceBreakpoint, '', False);
  1168. CreateMenuItem(itmRunMenuAddBreakpoint,itmRunMenuAddBPAddress,'itmRunMenuAddBPAddress',lisAddressBreakpoint, '', False);
  1169. CreateMenuItem(itmRunMenuAddBreakpoint,itmRunMenuAddBpWatchPoint,'itmRunMenuAddBpWatchPoint',lisWatchPointBreakpoint, '', False);
  1170. end;
  1171. end;
  1172. procedure TMainIDEBase.SetupPackageMenu;
  1173. var
  1174. ParentMI: TIDEMenuSection;
  1175. begin
  1176. with MainIDEBar do begin
  1177. CreateMenuSeparatorSection(mnuComponent,itmPkgOpening,'itmPkgOpening');
  1178. ParentMI:=itmPkgOpening;
  1179. CreateMenuItem(ParentMI,itmPkgNewPackage,'itmPkgNewPackage',lisMenuNewPackage);
  1180. CreateMenuItem(ParentMI,itmPkgOpenLoadedPackage,'itmPkgOpenPackage',lisMenuOpenPackage,'pkg_installed');
  1181. CreateMenuItem(ParentMI,itmPkgOpenPackageFile,'itmPkgOpenPackageFile',lisMenuOpenPackageFile,'pkg_open');
  1182. CreateMenuItem(ParentMI,itmPkgOpenPackageOfCurUnit,'itmPkgOpenPackageOfCurUnit',lisMenuOpenPackageOfCurUnit);
  1183. CreateMenuSubSection(ParentMI,itmPkgOpenRecent,'itmPkgOpenRecent',lisMenuOpenRecentPkg);
  1184. CreateMenuSeparatorSection(mnuComponent,itmPkgUnits,'itmPkgUnits');
  1185. ParentMI:=itmPkgUnits;
  1186. CreateMenuItem(ParentMI,itmPkgAddCurFileToPkg,'itmPkgAddCurFileToPkg',lisMenuAddCurFileToPkg,'pkg_add');
  1187. CreateMenuItem(ParentMI, itmPkgAddNewComponentToPkg, 'itmPkgAddNewComponentToPkg', lisMenuNewComponent+' ...', 'pkg_add');
  1188. CreateMenuSeparatorSection(mnuComponent,itmPkgGraphSection,'itmPkgGraphSection');
  1189. ParentMI:=itmPkgGraphSection;
  1190. CreateMenuItem(ParentMI,itmPkgPkgGraph,'itmPkgPkgGraph',lisMenuPackageGraph+' ...','pkg_graph');
  1191. CreateMenuItem(ParentMI,itmPkgPackageLinks,'itmPkgPackageLinks',lisMenuPackageLinks);
  1192. CreateMenuItem(ParentMI,itmPkgEditInstallPkgs,'itmPkgEditInstallPkgs',lisMenuEditInstallPkgs,'pkg_properties');
  1193. {$IFDEF CustomIDEComps}
  1194. CreateMenuItem(ParentMI,itmCompsConfigCustomComps,'itmCompsConfigCustomComps',lisMenuConfigCustomComps);
  1195. {$ENDIF}
  1196. end;
  1197. end;
  1198. procedure TMainIDEBase.SetupToolsMenu;
  1199. var
  1200. ParentMI: TIDEMenuSection;
  1201. begin
  1202. with MainIDEBar do begin
  1203. CreateMenuSeparatorSection(mnuTools,itmOptionsDialogs,'itmOptionsDialogs');
  1204. ParentMI:=itmOptionsDialogs;
  1205. CreateMenuItem(ParentMI,itmEnvGeneralOptions,'itmEnvGeneralOptions',
  1206. lisMenuGeneralOptions,'menu_environment_options');
  1207. CreateMenuItem(ParentMI,itmToolRescanFPCSrcDir,'itmToolRescanFPCSrcDir',
  1208. lisMenuRescanFPCSourceDirectory);
  1209. CreateMenuItem(ParentMI,itmEnvCodeTemplates,'itmEnvCodeTemplates',lisMenuEditCodeTemplates,'');
  1210. CreateMenuItem(ParentMI,itmEnvCodeToolsDefinesEditor,'itmEnvCodeToolsDefinesEditor',
  1211. lisMenuCodeToolsDefinesEditor,'menu_codetoolsdefineseditor');
  1212. CreateMenuSeparatorSection(mnuTools,itmCustomTools,'itmCustomTools');
  1213. ParentMI:=itmCustomTools;
  1214. CreateMenuItem(ParentMI,itmToolConfigure,'itmToolConfigure',lisMenuConfigExternalTools);
  1215. CreateMenuSeparatorSection(mnuTools,itmSecondaryTools,'itmSecondaryTools');
  1216. ParentMI:=itmSecondaryTools;
  1217. CreateMenuItem(ParentMI,itmToolManageDesktops,'itmToolManageDesktops', lisDesktops, 'menu_manage_desktops');
  1218. CreateMenuItem(ParentMI,itmToolManageExamples,'itmToolManageExamples',lisMenuExampleProjects, 'camera');
  1219. CreateMenuItem(ParentMI,itmToolDiff,'itmToolDiff',lisMenuCompareFiles, 'menu_tool_diff');
  1220. CreateMenuSeparatorSection(mnuTools,itmConversion,'itmConversion');
  1221. ParentMI:=itmConversion;
  1222. CreateMenuItem(ParentMI,itmToolConvertEncoding,'itmToolConvertEncoding',lisMenuConvertEncoding);
  1223. CreateMenuItem(ParentMI,itmToolCheckLFM,'itmToolCheckLFM',lisMenuCheckLFM, 'menu_tool_check_lfm');
  1224. CreateMenuSubSection(mnuTools,itmDelphiConversion,'itmDelphiConversion',lisMenuDelphiConversion,'menu_tool_dfm_to_lfm');
  1225. ParentMI:=itmDelphiConversion;
  1226. CreateMenuItem(ParentMI,itmToolConvertDelphiUnit,'itmToolConvertDelphiUnit',lisMenuConvertDelphiUnit,'menu_tool_dfm_to_lfm');
  1227. CreateMenuItem(ParentMI,itmToolConvertDelphiProject,'itmToolConvertDelphiProject',lisMenuConvertDelphiProject,'menu_tool_dfm_to_lfm');
  1228. CreateMenuItem(ParentMI,itmToolConvertDelphiPackage,'itmToolConvertDelphiPackage',lisMenuConvertDelphiPackage,'menu_tool_dfm_to_lfm');
  1229. CreateMenuItem(ParentMI,itmToolConvertDFMtoLFM,'itmToolConvertDFMtoLFM',lisMenuConvertDFMtoLFM,'menu_tool_dfm_to_lfm');
  1230. CreateMenuSeparatorSection(mnuTools,itmBuildingLazarus,'itmBuildingLazarus');
  1231. ParentMI:=itmBuildingLazarus;
  1232. CreateMenuItem(ParentMI,itmToolBuildLazarus,'itmToolBuildLazarus',lisMenuBuildLazarus,'menu_build_lazarus');
  1233. CreateMenuItem(ParentMI,itmToolConfigureBuildLazarus,'itmToolConfigureBuildLazarus',
  1234. lisMenuConfigureBuildLazarus, 'menu_configure_build_lazarus');
  1235. end;
  1236. end;
  1237. procedure TMainIDEBase.SetupWindowsMenu;
  1238. var
  1239. ParentMI: TIDEMenuSection;
  1240. begin
  1241. with MainIDEBar do begin
  1242. CreateMenuSeparatorSection(mnuWindow,itmWindowManagers,'itmWindowManagers');
  1243. ParentMI:=itmWindowManagers;
  1244. CreateMenuItem(ParentMI,itmWindowManager,'itmWindowManager', lisManageSourceEditors, 'pkg_files');
  1245. // Populated later with a list of editor names
  1246. CreateMenuSeparatorSection(mnuWindow,itmWindowLists,'itmWindowLists');
  1247. CreateMenuSeparatorSection(mnuWindow,itmCenterWindowLists,'itmCenterWindowLists');
  1248. itmCenterWindowLists.ChildrenAsSubMenu:=true;
  1249. itmCenterWindowLists.Caption:=lisCenterALostWindow;
  1250. CreateMenuSeparatorSection(mnuWindow,itmTabLists,'itmTabLists');
  1251. CreateMenuSubSection(itmTabLists,itmTabListProject,'itmTabListProject', dlgEnvProject);
  1252. CreateMenuSeparatorSection(itmTabLists, itmTabListPackage, 'itmTabListPackage');
  1253. CreateMenuSubSection(itmTabLists,itmTabListOther,'itmTabListOther', lisMEOther);
  1254. end;
  1255. end;
  1256. procedure TMainIDEBase.SetupHelpMenu;
  1257. var
  1258. ParentMI: TIDEMenuSection;
  1259. begin
  1260. with MainIDEBar do begin
  1261. CreateMenuSeparatorSection(mnuHelp,itmOnlineHelps,'itmOnlineHelps');
  1262. ParentMI:=itmOnlineHelps;
  1263. CreateMenuItem(ParentMI,itmHelpOnlineHelp,'itmHelpOnlineHelp',
  1264. lisMenuOnlineHelp, 'menu_help');
  1265. CreateMenuItem(ParentMI,itmHelpReportingBug,'itmHelpReportingBug',
  1266. lisMenuReportingBug, 'menu_reportingbug');
  1267. // old behavior restored, until Tiger issue is fixed.
  1268. // http://bugs.freepascal.org/view.php?id=14411
  1269. (*
  1270. {$ifdef LCLCarbon}
  1271. // under Carbon: add About item to the Apple menu
  1272. CreateMenuItem(mnuApple, itmHelpAboutLazarus,'itmHelpAboutLazarus',
  1273. lisAboutLazarus, 'menu_information');
  1274. CreateMenuSeparatorSection(mnuHelp,itmInfoHelps,'itmInfoHelps');
  1275. {$else}*)
  1276. // otherwise: add About item to the Help menu
  1277. CreateMenuSeparatorSection(mnuHelp,itmInfoHelps,'itmInfoHelps');
  1278. ParentMI:=itmInfoHelps;
  1279. CreateMenuItem(ParentMI,itmHelpAboutLazarus,'itmHelpAboutLazarus',
  1280. lisAboutLazarus, 'menu_information');
  1281. //{$endif}
  1282. CreateMenuSeparatorSection(mnuHelp,itmHelpTools,'itmHelpTools');
  1283. ParentMI:=itmHelpTools;
  1284. end;
  1285. end;
  1286. procedure TMainIDEBase.LoadMenuShortCuts;
  1287. function GetCmdAndBtn(ACommand: word; out ToolButton: TIDEButtonCommand): TIDECommand;
  1288. begin
  1289. Result:=IDECommandList.FindIDECommand(ACommand);
  1290. if Result<>nil then
  1291. ToolButton := RegisterIDEButtonCommand(Result)
  1292. else
  1293. ToolButton := nil;
  1294. end;
  1295. function GetCommand(ACommand: word): TIDECommand;
  1296. var
  1297. ToolButton: TIDEButtonCommand;
  1298. begin
  1299. Result:=GetCmdAndBtn(ACommand, ToolButton);
  1300. end;
  1301. function GetCommand(ACommand: word; ToolButtonClass: TIDEToolButtonClass): TIDECommand;
  1302. var
  1303. ToolButton: TIDEButtonCommand;
  1304. begin
  1305. Result:=GetCmdAndBtn(ACommand, ToolButton);
  1306. if ToolButton<>nil then
  1307. ToolButton.ToolButtonClass := ToolButtonClass;
  1308. end;
  1309. var
  1310. xBtnItem: TIDEButtonCommand;
  1311. begin
  1312. with MainIDEBar do begin
  1313. // file menu
  1314. itmFileNewUnit.Command:=GetCommand(ecNewUnit, TNewUnitToolButton);
  1315. itmFileNewForm.Command:=GetCommand(ecNewForm, TNewFormToolButton);
  1316. itmFileNewOther.Command:=GetCommand(ecNew);
  1317. itmFileOpen.Command:=GetCommand(ecOpen, TOpenFileToolButton);
  1318. itmFileOpenUnit.Command:=GetCommand(ecOpenUnit);
  1319. itmFileRevert.Command:=GetCommand(ecRevert);
  1320. itmFileSave.Command:=GetCommand(ecSave);
  1321. itmFileSaveAs.Command:=GetCommand(ecSaveAs);
  1322. itmFileSaveAll.Command:=GetCommand(ecSaveAll);
  1323. itmFileClose.Command:=GetCommand(ecClose);
  1324. itmFileCloseAll.Command:=GetCommand(ecCloseAll);
  1325. itmFileCleanDirectory.Command:=GetCommand(ecCleanDirectory);
  1326. itmFileQuit.Command:=GetCommand(ecQuit);
  1327. // edit menu
  1328. itmEditUndo.Command:=GetCommand(ecUndo);
  1329. itmEditRedo.Command:=GetCommand(ecRedo);
  1330. itmEditCut.Command:=GetCommand(ecCut);
  1331. itmEditCopy.Command:=GetCommand(ecCopy);
  1332. itmEditPaste.Command:=GetCommand(ecPaste);
  1333. itmEditSelectAll.Command:=GetCommand(ecSelectAll);
  1334. itmEditSelectToBrace.Command:=GetCommand(ecSelectToBrace);
  1335. itmEditSelectCodeBlock.Command:=GetCommand(ecSelectCodeBlock);
  1336. itmEditSelectWord.Command:=GetCommand(ecSelectWord);
  1337. itmEditSelectLine.Command:=GetCommand(ecSelectLine);
  1338. itmEditSelectParagraph.Command:=GetCommand(ecSelectParagraph);
  1339. itmEditIndentBlock.Command:=GetCommand(ecBlockIndent);
  1340. itmEditUnindentBlock.Command:=GetCommand(ecBlockUnindent);
  1341. itmEditUpperCaseBlock.Command:=GetCommand(ecSelectionUpperCase);
  1342. itmEditLowerCaseBlock.Command:=GetCommand(ecSelectionLowerCase);
  1343. itmEditSwapCaseBlock.Command:=GetCommand(ecSelectionSwapCase);
  1344. itmEditSortBlock.Command:=GetCommand(ecSelectionSort);
  1345. itmEditTabsToSpacesBlock.Command:=GetCommand(ecSelectionTabs2Spaces);
  1346. itmEditSelectionBreakLines.Command:=GetCommand(ecSelectionBreakLines);
  1347. itmEditInsertCharacter.Command:=GetCommand(ecInsertCharacter);
  1348. // search menu
  1349. itmSearchFind.Command:=GetCommand(ecFind);
  1350. itmSearchFindNext.Command:=GetCommand(ecFindNext);
  1351. itmSearchFindPrevious.Command:=GetCommand(ecFindPrevious);
  1352. itmSearchFindInFiles.Command:=GetCommand(ecFindInFiles);
  1353. itmSearchFindIdentifierRefs.Command:=GetCommand(ecFindIdentifierRefs);
  1354. itmSearchReplace.Command:=GetCommand(ecReplace);
  1355. itmIncrementalFind.Command:=GetCommand(ecIncrementalFind);
  1356. itmGotoLine.Command:=GetCommand(ecGotoLineNumber);
  1357. itmJumpBack.Command:=GetCommand(ecJumpBack);
  1358. itmJumpForward.Command:=GetCommand(ecJumpForward);
  1359. itmAddJumpPoint.Command:=GetCommand(ecAddJumpPoint);
  1360. itmJumpToNextError.Command:=GetCommand(ecJumpToNextError);
  1361. itmJumpToPrevError.Command:=GetCommand(ecJumpToPrevError);
  1362. itmSetFreeBookmark.Command:=GetCommand(ecSetFreeBookmark);
  1363. itmJumpToNextBookmark.Command:=GetCommand(ecNextBookmark);
  1364. itmJumpToPrevBookmark.Command:=GetCommand(ecPrevBookmark);
  1365. itmJumpToInterface.Command:=GetCommand(ecJumpToInterface, TJumpToSectionToolButton);
  1366. itmJumpToInterfaceUses.Command:=GetCommand(ecJumpToInterfaceUses, TJumpToSectionToolButton);
  1367. itmJumpToImplementation.Command:=GetCommand(ecJumpToImplementation, TJumpToSectionToolButton);
  1368. itmJumpToImplementationUses.Command:=GetCommand(ecJumpToImplementationUses, TJumpToSectionToolButton);
  1369. itmJumpToInitialization.Command:=GetCommand(ecJumpToInitialization, TJumpToSectionToolButton);
  1370. GetCmdAndBtn(ecJumpToProcedureHeader, xBtnItem);
  1371. xBtnItem.Caption := lisMenuJumpToProcedureHeader;
  1372. xBtnItem.OnClick := @SourceEditorManager.JumpToProcedureHeaderClicked;
  1373. xBtnItem.ImageIndex := IDEImages.LoadImage(16, 'menu_jumpto_procedureheader');
  1374. GetCmdAndBtn(ecJumpToProcedureBegin, xBtnItem);
  1375. xBtnItem.Caption := lisMenuJumpToProcedureBegin;
  1376. xBtnItem.ImageIndex := IDEImages.LoadImage(16, 'menu_jumpto_procedurebegin');
  1377. xBtnItem.OnClick := @SourceEditorManager.JumpToProcedureBeginClicked;
  1378. itmFindBlockOtherEnd.Command:=GetCommand(ecFindBlockOtherEnd);
  1379. itmFindBlockStart.Command:=GetCommand(ecFindBlockStart);
  1380. itmFindDeclaration.Command:=GetCommand(ecFindDeclaration);
  1381. itmOpenFileAtCursor.Command:=GetCommand(ecOpenFileAtCursor);
  1382. itmGotoIncludeDirective.Command:=GetCommand(ecGotoIncludeDirective);
  1383. itmSearchProcedureList.Command:=GetCommand(ecProcedureList);
  1384. // view menu
  1385. itmViewToggleFormUnit.Command:=GetCommand(ecToggleFormUnit);
  1386. itmViewInspector.Command:=GetCommand(ecToggleObjectInsp);
  1387. itmViewSourceEditor.Command:=GetCommand(ecToggleSourceEditor);
  1388. itmViewCodeExplorer.Command:=GetCommand(ecToggleCodeExpl);
  1389. itmViewFPDocEditor.Command:=GetCommand(ecToggleFPDocEditor);
  1390. itmViewCodeBrowser.Command:=GetCommand(ecToggleCodeBrowser);
  1391. itmViewRestrictionBrowser.Command:=GetCommand(ecToggleRestrictionBrowser);
  1392. itmViewComponents.Command:=GetCommand(ecViewComponents);
  1393. itmMacroListView.Command:=GetCommand(ecViewMacroList);
  1394. itmJumpHistory.Command:=GetCommand(ecViewJumpHistory);
  1395. itmViewMessage.Command:=GetCommand(ecToggleMessages);
  1396. itmViewSearchResults.Command:=GetCommand(ecToggleSearchResults);
  1397. itmViewAnchorEditor.Command:=GetCommand(ecViewAnchorEditor);
  1398. itmViewTabOrder.Command:=GetCommand(ecViewTabOrder);
  1399. //itmPkgPackageLinks.Command:=GetCommand(ec?);
  1400. // source menu
  1401. itmSourceCommentBlock.Command:=GetCommand(ecSelectionComment);
  1402. itmSourceUncommentBlock.Command:=GetCommand(ecSelectionUncomment);
  1403. itmSourceToggleComment.Command:=GetCommand(ecToggleComment);
  1404. itmSourceEncloseBlock.Command:=GetCommand(ecSelectionEnclose);
  1405. itmSourceEncloseInIFDEF.Command:=GetCommand(ecSelectionEncloseIFDEF);
  1406. itmSourceCompleteCodeInteractive.Command:=GetCommand(ecCompleteCodeInteractive);
  1407. itmSourceUseUnit.Command:=GetCommand(ecUseUnit);
  1408. itmSourceSyntaxCheck.Command:=GetCommand(ecSyntaxCheck);
  1409. itmSourceGuessUnclosedBlock.Command:=GetCommand(ecGuessUnclosedBlock);
  1410. itmSourceGuessMisplacedIFDEF.Command:=GetCommand(ecGuessMisplacedIFDEF);
  1411. itmSourceInsertCVSAuthor.Command:=GetCommand(ecInsertCVSAuthor);
  1412. itmSourceInsertCVSDate.Command:=GetCommand(ecInsertCVSDate);
  1413. itmSourceInsertCVSHeader.Command:=GetCommand(ecInsertCVSHeader);
  1414. itmSourceInsertCVSID.Command:=GetCommand(ecInsertCVSID);
  1415. itmSourceInsertCVSLog.Command:=GetCommand(ecInsertCVSLog);
  1416. itmSourceInsertCVSName.Command:=GetCommand(ecInsertCVSName);
  1417. itmSourceInsertCVSRevision.Command:=GetCommand(ecInsertCVSRevision);
  1418. itmSourceInsertCVSSource.Command:=GetCommand(ecInsertCVSSource);
  1419. itmSourceInsertGPLNotice.Command:=GetCommand(ecInsertGPLNotice);
  1420. itmSourceInsertGPLNoticeTranslated.Command:=GetCommand(ecInsertGPLNoticeTranslated);
  1421. itmSourceInsertLGPLNotice.Command:=GetCommand(ecInsertLGPLNotice);
  1422. itmSourceInsertLGPLNoticeTranslated.Command:=GetCommand(ecInsertLGPLNoticeTranslated);
  1423. itmSourceInsertModifiedLGPLNotice.Command:=GetCommand(ecInsertModifiedLGPLNotice);
  1424. itmSourceInsertModifiedLGPLNoticeTranslated.Command:=GetCommand(ecInsertModifiedLGPLNoticeTranslated);
  1425. itmSourceInsertMITNotice.Command:=GetCommand(ecInsertMITNotice);
  1426. itmSourceInsertMITNoticeTranslated.Command:=GetCommand(ecInsertMITNoticeTranslated);
  1427. itmSourceInsertUsername.Command:=GetCommand(ecInsertUserName);
  1428. itmSourceInsertDateTime.Command:=GetCommand(ecInsertDateTime);
  1429. itmSourceInsertChangeLogEntry.Command:=GetCommand(ecInsertChangeLogEntry);
  1430. itmSourceInsertGUID.Command:=GetCommand(ecInsertGUID);
  1431. itmSourceInsertFilename.Command:=GetCommand(ecInsertFilename);
  1432. itmSourceUnitInfo.Command:=GetCommand(ecViewUnitInfo);
  1433. itmSourceUnitDependencies.Command:=GetCommand(ecViewUnitDependencies);
  1434. // refactor menu
  1435. itmRefactorRenameIdentifier.Command:=GetCommand(ecRenameIdentifier);
  1436. itmRefactorExtractProc.Command:=GetCommand(ecExtractProc);
  1437. itmRefactorInvertAssignment.Command:=GetCommand(ecInvertAssignment);
  1438. itmRefactorShowAbstractMethods.Command:=GetCommand(ecShowAbstractMethods);
  1439. itmRefactorShowEmptyMethods.Command:=GetCommand(ecRemoveEmptyMethods);
  1440. itmRefactorShowUnusedUnits.Command:=GetCommand(ecRemoveUnusedUnits);
  1441. {$IFDEF EnableFindOverloads}
  1442. itmRefactorFindOverloads.Command:=GetCommand(ecFindOverloads);
  1443. {$ENDIF}
  1444. itmRefactorMakeResourceString.Command:=GetCommand(ecMakeResourceString);
  1445. // project menu
  1446. itmProjectNew.Command:=GetCommand(ecNewProject);
  1447. itmProjectNewFromFile.Command:=GetCommand(ecNewProjectFromFile);
  1448. itmProjectOpen.Command:=GetCommand(ecOpenProject);
  1449. itmProjectClose.Command:=GetCommand(ecCloseProject);
  1450. itmProjectSave.Command:=GetCommand(ecSaveProject);
  1451. itmProjectSaveAs.Command:=GetCommand(ecSaveProjectAs);
  1452. itmProjectResaveFormsWithI18n.Command:=GetCommand(ecProjectResaveFormsWithI18n);
  1453. itmProjectPublish.Command:=GetCommand(ecPublishProject);
  1454. itmProjectInspector.Command:=GetCommand(ecProjectInspector);
  1455. itmProjectOptions.Command:=GetCommand(ecProjectOptions);
  1456. itmProjectAddTo.Command:=GetCommand(ecAddCurUnitToProj);
  1457. itmProjectRemoveFrom.Command:=GetCommand(ecRemoveFromProj);
  1458. itmProjectViewUnits.Command:=GetCommand(ecViewProjectUnits);
  1459. itmProjectViewForms.Command:=GetCommand(ecViewProjectForms);
  1460. itmProjectViewSource.Command:=GetCommand(ecViewProjectSource);
  1461. GetCmdAndBtn(ecProjectChangeBuildMode, xBtnItem);
  1462. xBtnItem.Caption := lisChangeBuildMode;
  1463. xBtnItem.ToolButtonClass:=TSetBuildModeToolButton;
  1464. xBtnItem.ImageIndex := IDEImages.LoadImage(16, 'menu_compiler_options');
  1465. xBtnItem.OnClick := @mnuBuildModeClicked;
  1466. // run menu
  1467. itmRunMenuCompile.Command:=GetCommand(ecCompile);
  1468. itmRunMenuBuild.Command:=GetCommand(ecBuild);
  1469. itmRunMenuQuickCompile.Command:=GetCommand(ecQuickCompile);
  1470. itmRunMenuCleanUpAndBuild.Command:=GetCommand(ecCleanUpAndBuild);
  1471. itmRunMenuBuildManyModes.Command:=GetCommand(ecBuildManyModes);
  1472. itmRunMenuAbortBuild.Command:=GetCommand(ecAbortBuild);
  1473. itmRunMenuRunWithoutDebugging.Command:=GetCommand(ecRunWithoutDebugging);
  1474. itmRunMenuRun.Command:=GetCommand(ecRun);
  1475. itmRunMenuPause.Command:=GetCommand(ecPause);
  1476. itmRunMenuStepInto.Command:=GetCommand(ecStepInto);
  1477. itmRunMenuStepOver.Command:=GetCommand(ecStepOver);
  1478. itmRunMenuStepOut.Command:=GetCommand(ecStepOut);
  1479. itmRunMenuRunToCursor.Command:=GetCommand(ecRunToCursor);
  1480. itmRunMenuStop.Command:=GetCommand(ecStopProgram);
  1481. itmRunMenuAttach.Command:=GetCommand(ecAttach);
  1482. itmRunMenuDetach.Command:=GetCommand(ecDetach);
  1483. itmRunMenuResetDebugger.Command:=GetCommand(ecResetDebugger);
  1484. itmRunMenuRunParameters.Command:=GetCommand(ecRunParameters);
  1485. itmRunMenuBuildFile.Command:=GetCommand(ecBuildFile);
  1486. itmRunMenuRunFile.Command:=GetCommand(ecRunFile);
  1487. itmRunMenuConfigBuildFile.Command:=GetCommand(ecConfigBuildFile);
  1488. // package menu
  1489. itmPkgNewPackage.Command:=GetCommand(ecNewPackage);
  1490. itmPkgOpenLoadedPackage.Command:=GetCommand(ecOpenPackage);
  1491. itmPkgOpenPackageFile.Command:=GetCommand(ecOpenPackageFile);
  1492. itmPkgOpenPackageOfCurUnit.Command:=GetCommand(ecOpenPackageOfCurUnit);
  1493. itmPkgAddCurFileToPkg.Command:=GetCommand(ecAddCurFileToPkg);
  1494. itmPkgAddNewComponentToPkg.Command:=GetCommand(ecNewPkgComponent);
  1495. itmPkgPkgGraph.Command:=GetCommand(ecPackageGraph);
  1496. itmPkgPackageLinks.Command:=GetCommand(ecPackageLinks);
  1497. itmPkgEditInstallPkgs.Command:=GetCommand(ecEditInstallPkgs);
  1498. {$IFDEF CustomIDEComps}
  1499. itmCompsConfigCustomComps.Command:=GetCommand(ecConfigCustomComps);
  1500. {$ENDIF}
  1501. // tools menu
  1502. itmEnvGeneralOptions.Command:=GetCommand(ecEnvironmentOptions);
  1503. itmToolRescanFPCSrcDir.Command:=GetCommand(ecRescanFPCSrcDir);
  1504. itmEnvCodeTemplates.Command:=GetCommand(ecEditCodeTemplates);
  1505. itmEnvCodeToolsDefinesEditor.Command:=GetCommand(ecCodeToolsDefinesEd);
  1506. itmToolConfigure.Command:=GetCommand(ecExtToolSettings);
  1507. itmToolManageDesktops.Command:=GetCommand(ecManageDesktops, TShowDesktopsToolButton);
  1508. itmToolManageExamples.Command:=GetCommand(ecManageExamples);
  1509. itmToolDiff.Command:=GetCommand(ecDiff);
  1510. itmToolConvertDFMtoLFM.Command:=GetCommand(ecConvertDFM2LFM);
  1511. itmToolCheckLFM.Command:=GetCommand(ecCheckLFM);
  1512. itmToolConvertDelphiUnit.Command:=GetCommand(ecConvertDelphiUnit);
  1513. itmToolConvertDelphiProject.Command:=GetCommand(ecConvertDelphiProject);
  1514. itmToolConvertDelphiPackage.Command:=GetCommand(ecConvertDelphiPackage);
  1515. itmToolConvertEncoding.Command:=GetCommand(ecConvertEncoding);
  1516. itmToolBuildLazarus.Command:=GetCommand(ecBuildLazarus);
  1517. itmToolConfigureBuildLazarus.Command:=GetCommand(ecConfigBuildLazarus);
  1518. // window menu
  1519. itmWindowManager.Command:=GetCommand(ecManageSourceEditors);
  1520. // help menu
  1521. itmHelpAboutLazarus.Command:=GetCommand(ecAboutLazarus);
  1522. itmHelpOnlineHelp.Command:=GetCommand(ecOnlineHelp);
  1523. itmHelpReportingBug.Command:=GetCommand(ecReportingBug);
  1524. end;
  1525. end;
  1526. function TMainIDEBase.DoOpenMacroFile(Sender: TObject; const AFilename: string
  1527. ): TModalResult;
  1528. begin
  1529. Result:=DoOpenEditorFile(AFilename,-1,-1,
  1530. [ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofConvertMacros]);
  1531. end;
  1532. procedure TMainIDEBase.UpdateWindowMenu;
  1533. function GetMenuItem(Index: Integer; ASection: TIDEMenuSection): TIDEMenuItem; inline;
  1534. begin
  1535. if ASection.Count > Index then
  1536. Result := ASection.Items[Index]
  1537. else
  1538. begin
  1539. Result := RegisterIDEMenuCommand(ASection.GetPath,'Window'+IntToStr(Index)+ASection.Name,'');
  1540. Result.CreateMenuItem;
  1541. end;
  1542. end;
  1543. procedure ClearMenuItem(ARemainCount: Integer; ASection: TIDEMenuSection); inline;
  1544. begin
  1545. with ASection do
  1546. while Count > ARemainCount do
  1547. Items[Count-1].Free;
  1548. end;
  1549. var
  1550. WindowsList: TFPList;
  1551. i, j, ItemCount, ItemCountProject, ItemCountOther: Integer;
  1552. CurMenuItem: TIDEMenuItem;
  1553. AForm: TForm;
  1554. EdList: TStringList;
  1555. EditorCur: TSourceEditor;
  1556. P: TIDEPackage;
  1557. M: TIDEMenuSection;
  1558. s: String;
  1559. begin
  1560. //DebugLn('TMainIDEBase.UpdateWindowMenu: enter');
  1561. WindowsList:=TFPList.Create;
  1562. // add typical IDE windows at the start of the list
  1563. for i := 0 to SourceEditorManager.SourceWindowCount - 1 do
  1564. WindowsList.Add(SourceEditorManager.SourceWindows[i]);
  1565. if (ObjectInspector1<>nil) and (ObjectInspector1.Visible) then
  1566. WindowsList.Add(ObjectInspector1);
  1567. // add special IDE windows
  1568. for i:=0 to Screen.FormCount-1 do begin
  1569. AForm:=Screen.Forms[i];
  1570. //debugln(['TMainIDEBase.UpdateWindowMenu ',DbgSName(AForm),' Vis=',AForm.IsVisible,' Des=',DbgSName(AForm.Designer)]);
  1571. if (not AForm.IsVisible) or (AForm=MainIDEBar) or (AForm=SplashForm)
  1572. or IsFormDesign(AForm) or (WindowsList.IndexOf(AForm)>=0) then
  1573. continue;
  1574. if IDEDockMaster<>nil then
  1575. begin
  1576. if not IDEDockMaster.AddableInWindowMenu(AForm) then continue;
  1577. end else begin
  1578. if AForm.Parent<>nil then continue;
  1579. end;
  1580. WindowsList.Add(AForm);
  1581. end;
  1582. // add designer forms and datamodule forms
  1583. for i:=0 to Screen.FormCount-1 do begin
  1584. AForm:=Screen.Forms[i];
  1585. if (AForm.Designer<>nil) and (WindowsList.IndexOf(AForm)<0) then
  1586. WindowsList.Add(AForm);
  1587. end;
  1588. // create menuitems for all windows
  1589. ItemCount := WindowsList.Count;
  1590. for i:=0 to WindowsList.Count-1 do
  1591. begin
  1592. // in the 'bring to front' list
  1593. CurMenuItem := GetMenuItem(i, itmWindowLists);
  1594. if EnvironmentOptions.Desktop.IDENameForDesignedFormList
  1595. and IsFormDesign(TWinControl(WindowsList[i])) then
  1596. CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
  1597. else
  1598. CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
  1599. CurMenuItem.MenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
  1600. CurMenuItem.OnClick:=@mnuWindowItemClick;
  1601. // in the 'center' list
  1602. CurMenuItem := GetMenuItem(i, itmCenterWindowLists);
  1603. if EnvironmentOptions.Desktop.IDENameForDesignedFormList
  1604. and IsFormDesign(TWinControl(WindowsList[i])) then
  1605. CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Name
  1606. else
  1607. CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
  1608. CurMenuItem.OnClick:=@mnuCenterWindowItemClick;
  1609. end;
  1610. //create source page menuitems
  1611. itmTabListProject.Visible := False;
  1612. itmTabListOther.Visible := False;
  1613. itmTabListProject.MenuItem.Checked := False;
  1614. itmTabListOther.MenuItem.Checked := False;
  1615. itmTabListPackage.Clear;
  1616. if SourceEditorManager.SourceEditorCount > 0 then begin
  1617. ItemCountProject := 0;
  1618. ItemCountOther := 0;
  1619. EdList := TStringList.Create;
  1620. EdList.OwnsObjects := False;
  1621. EdList.Sorted := True;
  1622. // sort
  1623. for i := 0 to SourceEditorManager.SourceEditorCount - 1 do begin
  1624. EdList.AddObject(SourceEditorManager.SourceEditors[i].PageName+' '
  1625. +SourceEditorManager.SourceEditors[i].FileName
  1626. +SourceEditorManager.SourceEditors[i].Owner.Name,
  1627. TObject(PtrUInt(i))
  1628. );
  1629. end;
  1630. for i := 0 to EdList.Count - 1 do
  1631. begin
  1632. j := PtrUInt(EdList.Objects[i]);
  1633. EditorCur := SourceEditorManager.SourceEditors[j];
  1634. if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then begin
  1635. M := itmTabListProject;
  1636. CurMenuItem := GetMenuItem(ItemCountProject, M);
  1637. inc(ItemCountProject);
  1638. end else begin
  1639. SourceEditorManager.OnPackageForSourceEditor(P, EditorCur);
  1640. if P <> nil then begin
  1641. s := Format(lisTabsFor, [p.Name]);
  1642. if itmTabListPackage.FindByName(S) is TIDEMenuSection then
  1643. M := TIDEMenuSection(itmTabListPackage.FindByName(S))
  1644. else
  1645. M := RegisterIDESubMenu(itmTabListPackage, S, S);
  1646. CurMenuItem := GetMenuItem(M.Count, M);
  1647. end else begin
  1648. M := itmTabListOther;
  1649. CurMenuItem := GetMenuItem(ItemCountOther, M);
  1650. inc(ItemCountOther);
  1651. end;
  1652. end;
  1653. M.Visible := True;
  1654. if EditorCur.SharedEditorCount > 1 then
  1655. CurMenuItem.Caption := EditorCur.PageName + ' ('+TForm(EditorCur.Owner).Caption+')'
  1656. //CurMenuItem.Caption := EditorCur.PageName
  1657. // + ' ('+IntToStr(1+SourceEditorManager.IndexOfSourceWindow(TSourceEditorWindowInterface(EditorCur.Owner)))+')'
  1658. else
  1659. CurMenuItem.Caption := EditorCur.PageName;
  1660. if CurMenuItem.MenuItem <> nil then
  1661. CurMenuItem.MenuItem.Checked := SourceEditorManager.ActiveEditor = EditorCur;
  1662. if (SourceEditorManager.ActiveEditor = EditorCur) and (M.MenuItem <> nil) then
  1663. M.MenuItem.Checked := true;
  1664. CurMenuItem.OnClick := @mnuWindowSourceItemClick;
  1665. CurMenuItem.Tag := j;
  1666. end;
  1667. EdList.Free;
  1668. ClearMenuItem(ItemCountProject, itmTabListProject);
  1669. ClearMenuItem(ItemCountOther, itmTabListOther);
  1670. for i := 0 to itmTabListPackage.Count - 1 do begin
  1671. if itmTabListPackage.Items[i] is TIDEMenuSection then begin
  1672. M := itmTabListPackage.Items[i] as TIDEMenuSection;
  1673. M.Caption := M.Caption + Format(' (%d)', [M.Count]);
  1674. end;
  1675. end;
  1676. itmTabListProject.Caption := dlgEnvProject + Format(' (%d)', [itmTabListProject.Count]);
  1677. itmTabListOther.Caption := lisMEOther + Format(' (%d)', [itmTabListOther.Count]);
  1678. if itmTabListPackage.TopSeparator <> nil then
  1679. itmTabListPackage.TopSeparator.Visible := False;
  1680. if itmTabListOther.TopSeparator <> nil then
  1681. itmTabListOther.TopSeparator.Visible := False;
  1682. end;
  1683. // remove unused menuitems
  1684. ClearMenuItem(ItemCount, itmWindowLists);
  1685. ClearMenuItem(ItemCount, itmCenterWindowLists);
  1686. WindowsList.Free; // clean up
  1687. end;
  1688. procedure TMainIDEBase.SetRecentSubMenu(Section: TIDEMenuSection;
  1689. FileList: TStringList; OnClickEvent: TNotifyEvent);
  1690. var
  1691. i: integer;
  1692. AMenuItem: TIDEMenuItem;
  1693. begin
  1694. // create enough menuitems
  1695. while Section.Count<FileList.Count do begin
  1696. AMenuItem:=RegisterIDEMenuCommand(Section.GetPath,
  1697. Section.Name+'Recent'+IntToStr(Section.Count),'');
  1698. end;
  1699. // delete unused menuitems
  1700. while Section.Count>FileList.Count do
  1701. Section.Items[Section.Count-1].Free;
  1702. Section.Enabled:=(Section.Count>0);
  1703. // set captions and event
  1704. for i:=0 to FileList.Count-1 do begin
  1705. AMenuItem:=Section.Items[i];
  1706. AMenuItem.Caption := FileList[i];
  1707. AMenuItem.OnClick := OnClickEvent;
  1708. end;
  1709. end;
  1710. procedure TMainIDEBase.UpdateHighlighters(Immediately: boolean = false);
  1711. var
  1712. ASrcEdit: TSourceEditor;
  1713. h: TLazSyntaxHighlighter;
  1714. i: Integer;
  1715. AnEditorInfo: TUnitEditorInfo;
  1716. begin
  1717. if Immediately then begin
  1718. FNeedUpdateHighlighters:=false;
  1719. for h := Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do
  1720. if Highlighters[h]<>nil then begin
  1721. Highlighters[h].BeginUpdate;
  1722. EditorOpts.GetHighlighterSettings(Highlighters[h]);
  1723. Highlighters[h].EndUpdate;
  1724. end;
  1725. if Project1<>nil then begin
  1726. for i := 0 to SourceEditorManager.SourceEditorCount - 1 do begin
  1727. ASrcEdit := SourceEditorManager.SourceEditors[i];
  1728. AnEditorInfo:=Project1.EditorInfoWithEditorComponent(ASrcEdit);
  1729. if AnEditorInfo <> nil then
  1730. ASrcEdit.SyntaxHighlighterType := AnEditorInfo.SyntaxHighlighter;
  1731. end;
  1732. end;
  1733. end else begin
  1734. FNeedUpdateHighlighters:=true;
  1735. end;
  1736. end;
  1737. procedure TMainIDEBase.FindInFilesPerDialog(AProject: TProject);
  1738. begin
  1739. FindInFilesDialog.FindInFilesPerDialog(AProject);
  1740. end;
  1741. procedure TMainIDEBase.FindInFiles(AProject: TProject; const FindText: string);
  1742. begin
  1743. FindInFilesDialog.FindInFiles(AProject, FindText);
  1744. end;
  1745. end.