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