IDE.MainForm.UpdateMenuHelper.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. unit IDE.MainForm.UpdateMenuHelper;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Compiler form - Menu update helper which has the find & replace helper as ancestor
  8. Not used by MainForm: it uses IDE.MainForm.FinalHelper instead
  9. }
  10. interface
  11. uses
  12. Menus,
  13. IDE.MainForm, IDE.MainForm.FindReplaceHelper;
  14. type
  15. TMainFormUpdateMenuHelper = class helper(TMainFormFindReplaceHelper) for TMainForm
  16. procedure UpdateFileMenu(const Menu: TMenuItem);
  17. procedure UpdateNewMainFileButtons;
  18. procedure UpdateSaveMenuItemAndButton;
  19. procedure UpdateEditMenu(const Menu: TMenuItem);
  20. procedure UpdateViewMenu(const Menu: TMenuItem);
  21. procedure UpdateBuildMenu(const Menu: TMenuItem);
  22. procedure UpdateMemosTabSetMenu(const Menu: TMenuItem);
  23. procedure UpdateHelpMenu(const Menu: TMenuItem);
  24. procedure UpdateSimpleMenu(const Menu: TMenuItem);
  25. procedure UpdateToolsMenu(const Menu: TMenuItem);
  26. procedure UpdateRunMenu;
  27. procedure UpdateRunMenu2(const Menu: TMenuItem);
  28. procedure UpdateBreakPointsMenu(const Menu: TMenuItem);
  29. procedure UpdateTargetMenu;
  30. { Private }
  31. procedure _UpdateMenuBitmapsIfNeeded;
  32. procedure _ApplyMenuBitmaps(const ParentMenuItem: TMenuItem);
  33. procedure _UpdateReopenTabMenu(const Menu: TMenuItem);
  34. function _AnyMemoHasBreakPoint: Boolean;
  35. end;
  36. implementation
  37. uses
  38. Windows, CommCtrl,
  39. SysUtils, Generics.Collections, VirtualImageList, ComCtrls,
  40. PathFunc,
  41. Shared.LicenseFunc,
  42. IDE.HelperFunc, IDE.IDEScintEdit;
  43. procedure TMainFormUpdateMenuHelper._UpdateMenuBitmapsIfNeeded;
  44. procedure AddMenuBitmap(const MenuBitmaps: TMenuBitmaps; const DC: HDC; const BitmapInfo: TBitmapInfo;
  45. const MenuItem: TMenuItem; const ImageList: TVirtualImageList; const ImageIndex: Integer); overload;
  46. begin
  47. var pvBits: Pointer;
  48. var Bitmap := CreateDIBSection(DC, bitmapInfo, DIB_RGB_COLORS, pvBits, 0, 0);
  49. var OldBitmap := SelectObject(DC, Bitmap);
  50. if ImageList_Draw(ImageList.Handle, ImageIndex, DC, 0, 0, ILD_TRANSPARENT) then
  51. MenuBitmaps.Add(MenuItem, Bitmap)
  52. else begin
  53. SelectObject(DC, OldBitmap);
  54. DeleteObject(Bitmap);
  55. end;
  56. end;
  57. procedure AddMenuBitmap(const MenuBitmaps: TMenuBitmaps; const DC: HDC; const BitmapInfo: TBitmapInfo;
  58. const MenuItem: TMenuItem; const ImageList: TVirtualImageList; const ImageName: String); overload;
  59. begin
  60. AddMenuBitmap(MenuBitmaps, DC, BitmapInfo, MenuItem, ImageList, ImageList.GetIndexByName(ImageName));
  61. end;
  62. type
  63. TButtonedMenu = TPair<TMenuItem, TToolButton>;
  64. TNamedMenu = TPair<TMenuItem, String>;
  65. function BM(const MenuItem: TMenuItem; const ToolButton: TToolButton): TButtonedMenu;
  66. begin
  67. Result := TButtonedMenu.Create(MenuItem, ToolButton); { This is a record so no need to free }
  68. end;
  69. function NM(const MenuItem: TMenuItem; const Name: String): TNamedMenu;
  70. begin
  71. Result := TNamedMenu.Create(MenuItem, Name); { This is a record so no need to free }
  72. end;
  73. begin
  74. { This will create bitmaps for the current DPI using ImageList_Draw.
  75. These draw perfectly even on Windows 7. Other techniques don't work because
  76. they loose transparency or only look good on Windows 8 and later. Or they do
  77. work but cause lots more VCL code to be run than just our simple CreateDIB+Draw
  78. combo.
  79. ApplyBitmaps will apply them to menu items using SetMenuItemInfo. The menu item
  80. does not copy the bitmap so they should still be alive after ApplyBitmaps is done.
  81. Depends on FMenuImageList to pick the best size icons for the current DPI
  82. from the collection. }
  83. var ImageList := FMenuImageList;
  84. var NewSize: TSize;
  85. NewSize.cx := ImageList.Width;
  86. NewSize.cy := ImageList.Height;
  87. if (NewSize.cx <> FMenuBitmapsSize.cx) or (NewSize.cy <> FMenuBitmapsSize.cy) or
  88. (ImageList.ImageCollection <> FMenuBitmapsSourceImageCollection) then begin
  89. { Cleanup previous }
  90. for var Bitmap in FMenuBitmaps.Values do
  91. DeleteObject(Bitmap);
  92. FMenuBitmaps.Clear;
  93. { Create }
  94. var DC := CreateCompatibleDC(0);
  95. if DC <> 0 then begin
  96. try
  97. var BitmapInfo := CreateBitmapInfo(NewSize.cx, NewSize.cy, 32);
  98. var ButtonedMenus := [
  99. BM(FNewMainFile, NewMainFileButton),
  100. BM(FOpenMainFile, OpenMainFileButton),
  101. BM(FSave, SaveButton),
  102. BM(BCompile, CompileButton),
  103. BM(BStopCompile, StopCompileButton),
  104. BM(RRun, RunButton),
  105. BM(RPause, PauseButton),
  106. BM(RTerminate, TerminateButton),
  107. BM(HDoc, HelpButton)];
  108. for var ButtonedMenu in ButtonedMenus do
  109. AddMenuBitmap(FMenuBitmaps, DC, BitmapInfo, ButtonedMenu.Key, ImageList, ButtonedMenu.Value.ImageIndex);
  110. var NamedMenus := [
  111. NM(FClearRecent, 'eraser'),
  112. NM(FSaveMainFileAs, 'save-as-filled'),
  113. NM(FSaveAll, 'save-all-filled'),
  114. NM(FPrint, 'printer'),
  115. NM(EUndo, 'command-undo-1'),
  116. NM(ERedo, 'command-redo-1'),
  117. NM(ECut, 'clipboard-cut'),
  118. NM(ECopy, 'clipboard-copy'),
  119. NM(POutputListCopy, 'clipboard-copy'),
  120. NM(EPaste, 'clipboard-paste'),
  121. NM(EDelete, 'symbol-cancel'),
  122. NM(ESelectAll, 'select-all'),
  123. NM(POutputListSelectAll, 'select-all'),
  124. NM(EFind, 'find'),
  125. NM(EFindInFiles, 'folder-open-filled-find'),
  126. //NM(EFindNext, 'unused\find-arrow-right-2'),
  127. //NM(EFindPrevious, 'unused\find-arrow-left-2'),
  128. NM(EReplace, 'replace'),
  129. NM(EFoldLine, 'symbol-remove'),
  130. NM(EUnfoldLine, 'symbol-add'),
  131. NM(VZoomIn, 'zoom-in'),
  132. NM(VZoomOut, 'zoom-out'),
  133. NM(VNextTab, 'control-tab-filled-arrow-right-2'),
  134. NM(VPreviousTab, 'control-tab-filled-arrow-left-2'),
  135. //NM(VCloseCurrentTab, 'unused\control-tab-filled-cancel-2'),
  136. NM(VReopenTabs, 'control-tab-filled-redo-1'),
  137. NM(VReopenTabs2, 'control-tab-filled-redo-1'),
  138. NM(BOpenOutputFolder, 'folder-open-filled'),
  139. NM(RParameters, 'control-edit'),
  140. NM(RRunToCursor, 'debug-start-filled-arrow-right-2'),
  141. NM(RStepInto, 'debug-step-into'),
  142. NM(RStepOver, 'debug-step-over'),
  143. NM(RStepOut, 'debug-step-out'),
  144. NM(RToggleBreakPoint, 'debug-breakpoint-filled'),
  145. NM(RToggleBreakPoint2, 'debug-breakpoint-filled'),
  146. NM(RDeleteBreakPoints, 'debug-breakpoints-filled-eraser'),
  147. NM(RDeleteBreakPoints2, 'debug-breakpoints-filled-eraser'),
  148. NM(REvaluate, 'variables'),
  149. NM(TAddRemovePrograms, 'application'),
  150. NM(TGenerateGUID, 'tag-script-filled'),
  151. NM(TFilesDesigner, 'documents-script-filled'),
  152. NM(TRegistryDesigner, 'control-tree-script-filled'),
  153. NM(TMsgBoxDesigner, 'comment-text-script-filled'),
  154. NM(TSignTools, 'padlock-filled'),
  155. NM(TOptions, 'gear-filled'),
  156. NM(HPurchase, 'shopping-cart'),
  157. NM(HRegister, 'key-filled'),
  158. NM(HDonate, 'heart-filled'),
  159. NM(HMailingList, 'alert-filled'),
  160. NM(HWhatsNew, 'announcement'),
  161. NM(HWebsite, 'home'),
  162. NM(HAbout, 'button-info')];
  163. for var NamedMenu in NamedMenus do
  164. AddMenuBitmap(FMenuBitmaps, DC, BitmapInfo, NamedMenu.Key, ImageList, NamedMenu.Value);
  165. finally
  166. DeleteDC(DC);
  167. end;
  168. end;
  169. FMenuBitmapsSize := NewSize;
  170. FMenuBitmapsSourceImageCollection := FMenuImageList.ImageCollection;
  171. end;
  172. end;
  173. procedure TMainFormUpdateMenuHelper._ApplyMenuBitmaps(const ParentMenuItem: TMenuItem);
  174. begin
  175. _UpdateMenuBitmapsIfNeeded;
  176. { Setting MainMenu1.ImageList or a menu item's .Bitmap to make a menu item
  177. show a bitmap is not OK: it causes the entire menu to become owner drawn
  178. which makes it looks different from native menus and additionally the trick
  179. SetFakeShortCut uses doesn't work with owner drawn menus.
  180. Instead UpdateMenuBitmapsIfNeeded has prepared images which can be applied
  181. to native menu items using SetMenuItemInfo and MIIM_BITMAP - which is what we
  182. do below.
  183. A problem with this is that Delphi's TMenu likes to constantly recreate the
  184. underlying native menu items, for example when updating the caption. Sometimes
  185. it will even destroy and repopulate an entire menu because of a simple change
  186. like setting the caption of a single item!
  187. This means the result of our SetMenuItemInfo call (which Delphi doesn't know
  188. about) will quickly become lost when Delphi recreates the menu item.
  189. Fixing this in the OnChange event is not possible, this is event is more
  190. than useless.
  191. The solution is shown by TMenu.DispatchPopup: in reaction to WM_INITMENUPOPUP
  192. it calls our Click events right before the menu is shown, giving us the
  193. opportunity to call SetMenuItemInfo for the menu's items.
  194. This works unless Delphi decides to destroy and repopulate the menu after
  195. calling Click. Most amazingly it can do that indeed: it does this if the DPI
  196. changed since the last popup or if a automatic hotkey change or line reduction
  197. happens due to the menu's AutoHotkeys or AutoLineReduction properties. To make
  198. things even worse: for the Run menu it does this each and every time it is
  199. opened: this menu currently has a 'Step Out' item which has no shortcut but
  200. also all its letters are taken by another item already. This confuses the
  201. AutoHotkeys code, making it destroy and repopulate the entire menu over and
  202. over because it erroneously thinks a hotkey changed.
  203. To avoid this MainMenu1.AutoHotkeys was set to maManual since we have always
  204. managed the hotkeys ourselves anyway and .AutoLineReduction was also set to
  205. maManual and we now manage that ourselves as well.
  206. This just leave an issue with the icons not appearing on the first popup after
  207. a DPI change and this seems like a minor issue only.
  208. For TPopupMenu: calling ApplyMenuBitmaps(PopupMenu.Items) does work but makes
  209. the popup only show icons without text. This seems to be a limitiation of menus
  210. created by CreatePopupMenu instead of CreateMenu. This is why our popups with
  211. icons are all menu items popped using TMainFormPopupMenu. These menu items
  212. are hidden in the main menu and temporarily shown on popup. Popping an always
  213. hidden menu item (or a visible one as a child of a hidden parent) doesnt work. }
  214. var mmi: TMenuItemInfo;
  215. mmi.cbSize := SizeOf(mmi);
  216. mmi.fMask := MIIM_BITMAP;
  217. for var I := 0 to ParentMenuItem.Count-1 do begin
  218. var MenuItem := ParentMenuItem.Items[I];
  219. if MenuItem.Visible then begin
  220. if FMenuBitmaps.TryGetValue(MenuItem, mmi.hbmpItem) then
  221. SetMenuItemInfo(ParentMenuItem.Handle, MenuItem.Command, False, mmi);
  222. if MenuItem.Count > 0 then
  223. _ApplyMenuBitmaps(MenuItem);
  224. end;
  225. end;
  226. end;
  227. procedure TMainFormUpdateMenuHelper.UpdateFileMenu(const Menu: TMenuItem);
  228. var
  229. I: Integer;
  230. begin
  231. FSaveMainFileAs.Enabled := FActiveMemo = FMainMemo;
  232. FSaveEncoding.Enabled := FSave.Enabled; { FSave.Enabled is kept up-to-date by UpdateSaveMenuItemAndButton }
  233. FSaveEncodingAuto.Checked := FSaveEncoding.Enabled and ((FActiveMemo as TIDEScintFileEdit).SaveEncoding = seAuto);
  234. FSaveEncodingUTF8WithBOM.Checked := FSaveEncoding.Enabled and ((FActiveMemo as TIDEScintFileEdit).SaveEncoding = seUTF8WithBOM);
  235. FSaveEncodingUTF8WithoutBOM.Checked := FSaveEncoding.Enabled and ((FActiveMemo as TIDEScintFileEdit).SaveEncoding = seUTF8WithoutBOM);
  236. FSaveAll.Visible := FOptions.OpenIncludedFiles;
  237. ReadMRUMainFilesList;
  238. FRecent.Visible := FMRUMainFilesList.Count <> 0;
  239. for I := 0 to High(FMRUMainFilesMenuItems) do
  240. with FMRUMainFilesMenuItems[I] do begin
  241. if I < FMRUMainFilesList.Count then begin
  242. Visible := True;
  243. Caption := '&' + IntToStr((I+1) mod 10) + ' ' + DoubleAmp(FMRUMainFilesList[I]);
  244. end
  245. else
  246. Visible := False;
  247. end;
  248. _ApplyMenuBitmaps(Menu);
  249. end;
  250. procedure TMainFormUpdateMenuHelper.UpdateNewMainFileButtons;
  251. begin
  252. if FOptions.UseWizard then begin
  253. FNewMainFile.Caption := '&New...';
  254. FNewMainFile.OnClick := FNewMainFileUserWizardClick;
  255. NewMainFileButton.OnClick := FNewMainFileUserWizardClick;
  256. end else begin
  257. FNewMainFile.Caption := '&New';
  258. FNewMainFile.OnClick := FNewMainFileClick;
  259. NewMainFileButton.OnClick := FNewMainFileClick;
  260. end;
  261. end;
  262. procedure TMainFormUpdateMenuHelper.UpdateSaveMenuItemAndButton;
  263. begin
  264. FSave.Enabled := FActiveMemo is TIDEScintFileEdit;
  265. SaveButton.Enabled := FSave.Enabled;
  266. end;
  267. procedure TMainFormUpdateMenuHelper.UpdateEditMenu(const Menu: TMenuItem);
  268. var
  269. MemoHasFocus, MemoIsReadOnly: Boolean;
  270. begin
  271. MemoHasFocus := FActiveMemo.Focused;
  272. MemoIsReadOnly := FActiveMemo.ReadOnly;
  273. EUndo.Enabled := MemoHasFocus and FActiveMemo.CanUndo;
  274. ERedo.Enabled := MemoHasFocus and FActiveMemo.CanRedo;
  275. ECut.Enabled := MemoHasFocus and not MemoIsReadOnly and not FActiveMemo.SelEmpty;
  276. ECopy.Enabled := MemoHasFocus and not FActiveMemo.SelEmpty;
  277. EPaste.Enabled := MemoHasFocus and FActiveMemo.CanPaste;
  278. EDelete.Enabled := MemoHasFocus and not FActiveMemo.SelEmpty;
  279. ESelectAll.Enabled := MemoHasFocus;
  280. ESelectNextOccurrence.Enabled := MemoHasFocus;
  281. ESelectAllOccurrences.Enabled := MemoHasFocus;
  282. ESelectAllFindMatches.Enabled := MemoHasFocus and (FLastFindText <> '');
  283. EFind.Enabled := MemoHasFocus;
  284. EFindNext.Enabled := MemoHasFocus;
  285. EFindPrevious.Enabled := MemoHasFocus;
  286. EReplace.Enabled := MemoHasFocus and not MemoIsReadOnly;
  287. EFindRegEx.Checked := FOptions.FindRegEx;
  288. EFoldLine.Visible := FOptions.UseFolding;
  289. EFoldLine.Enabled := MemoHasFocus;
  290. EUnfoldLine.Visible := EFoldLine.Visible;
  291. EUnfoldLine.Enabled := EFoldLine.Enabled;
  292. EGoto.Enabled := MemoHasFocus;
  293. EToggleLinesComment.Enabled := not MemoIsReadOnly;
  294. EBraceMatch.Enabled := MemoHasFocus;
  295. _ApplyMenuBitmaps(Menu);
  296. end;
  297. procedure TMainFormUpdateMenuHelper._UpdateReopenTabMenu(const Menu: TMenuItem);
  298. begin
  299. Menu.Clear;
  300. for var I := 0 to FHiddenFiles.Count-1 do begin
  301. var MenuItem := TMenuItem.Create(Menu);
  302. MenuItem.Caption := '&' + IntToStr((I+1) mod 10) + ' ' + DoubleAmp(PathExtractName(FHiddenFiles[I]));
  303. MenuItem.Tag := I;
  304. MenuItem.OnClick := ReopenTabClick;
  305. Menu.Add(MenuItem);
  306. end;
  307. end;
  308. procedure TMainFormUpdateMenuHelper.UpdateViewMenu(const Menu: TMenuItem);
  309. begin
  310. VZoomIn.Enabled := (FActiveMemo.Zoom < 20);
  311. VZoomOut.Enabled := (FActiveMemo.Zoom > -10);
  312. VZoomReset.Enabled := (FActiveMemo.Zoom <> 0);
  313. VToolbar.Checked := ToolbarPanel.Visible;
  314. VStatusBar.Checked := StatusBar.Visible;
  315. VNextTab.Enabled := MemosTabSet.Visible and (MemosTabSet.Tabs.Count > 1);
  316. VPreviousTab.Enabled := VNextTab.Enabled;
  317. VCloseCurrentTab.Enabled := MemosTabSet.Visible and (FActiveMemo <> FMainMemo) and (FActiveMemo <> FPreprocessorOutputMemo);
  318. VReopenTab.Visible := MemosTabSet.Visible and FOptions.OpenIncludedFiles and (FHiddenFiles.Count > 0);
  319. if VReopenTab.Visible then
  320. _UpdateReopenTabMenu(VReopenTab);
  321. VReopenTabs.Visible := VReopenTab.Visible;
  322. VHide.Checked := not StatusPanel.Visible;
  323. VCompilerOutput.Checked := StatusPanel.Visible and (OutputTabSet.TabIndex = tiCompilerOutput);
  324. VDebugOutput.Checked := StatusPanel.Visible and (OutputTabSet.TabIndex = tiDebugOutput);
  325. VDebugCallStack.Checked := StatusPanel.Visible and (OutputTabSet.TabIndex = tiDebugCallStack);
  326. VFindResults.Checked := StatusPanel.Visible and (OutputTabSet.TabIndex = tiFindResults);
  327. VWordWrap.Checked := FOptions.WordWrap;
  328. _ApplyMenuBitmaps(Menu);
  329. end;
  330. procedure TMainFormUpdateMenuHelper.UpdateBuildMenu(const Menu: TMenuItem);
  331. begin
  332. BLowPriority.Checked := FOptions.LowPriorityDuringCompile;
  333. BOpenOutputFolder.Enabled := (FCompiledExe <> '');
  334. _ApplyMenuBitmaps(Menu);
  335. end;
  336. procedure TMainFormUpdateMenuHelper.UpdateMemosTabSetMenu(const Menu: TMenuItem);
  337. begin
  338. { Main and preprocessor memos can't be hidden }
  339. VCloseCurrentTab2.Enabled := (FActiveMemo <> FMainMemo) and (FActiveMemo <> FPreprocessorOutputMemo);
  340. VReopenTab2.Visible := FHiddenFiles.Count > 0;
  341. if VReopenTab2.Visible then
  342. _UpdateReopenTabMenu(VReopenTab2);
  343. VReopenTabs2.Visible := VReopenTab2.Visible;
  344. _ApplyMenuBitmaps(Menu);
  345. end;
  346. procedure TMainFormUpdateMenuHelper.UpdateHelpMenu(const Menu: TMenuItem);
  347. begin
  348. HUnregister.Visible := IsLicensed;
  349. HDonate.Visible := not HUnregister.Visible;
  350. _ApplyMenuBitmaps(Menu);
  351. end;
  352. procedure TMainFormUpdateMenuHelper.UpdateSimpleMenu(const Menu: TMenuItem);
  353. begin
  354. _ApplyMenuBitmaps(Menu);
  355. end;
  356. procedure TMainFormUpdateMenuHelper.UpdateToolsMenu(const Menu: TMenuItem);
  357. var
  358. MemoIsReadOnly: Boolean;
  359. begin
  360. MemoIsReadOnly := FActiveMemo.ReadOnly;
  361. TGenerateGUID.Enabled := not MemoIsReadOnly;
  362. TMsgBoxDesigner.Enabled := not MemoIsReadOnly;
  363. TFilesDesigner.Enabled := not MemoIsReadOnly;
  364. TRegistryDesigner.Enabled := not MemoIsReadOnly;
  365. _ApplyMenuBitmaps(Menu);
  366. end;
  367. function TMainFormUpdateMenuHelper._AnyMemoHasBreakPoint: Boolean;
  368. begin
  369. { Also see RDeleteBreakPointsClick }
  370. for var Memo in FFileMemos do
  371. if Memo.Used and (Memo.BreakPoints.Count > 0) then
  372. Exit(True);
  373. Result := False;
  374. end;
  375. { Should always be called when one of the Enabled states would change because
  376. other code depends on the states being correct always even if the user never
  377. clicks the Run menu. This is unlike the other menus. Note: also updates
  378. BCompile and BStopCompile from the Build menu. }
  379. procedure TMainFormUpdateMenuHelper.UpdateRunMenu;
  380. begin
  381. CheckIfTerminated;
  382. BCompile.Enabled := not FCompiling and not FDebugging;
  383. CompileButton.Enabled := BCompile.Enabled;
  384. BStopCompile.Enabled := FCompiling;
  385. StopCompileButton.Enabled := BStopCompile.Enabled;
  386. RRun.Enabled := not FCompiling and (not FDebugging or FPaused);
  387. RunButton.Enabled := RRun.Enabled;
  388. RPause.Enabled := FDebugging and not FPaused;
  389. PauseButton.Enabled := RPause.Enabled;
  390. RRunToCursor.Enabled := RRun.Enabled and (FActiveMemo is TIDEScintFileEdit);
  391. RStepInto.Enabled := RRun.Enabled;
  392. RStepOver.Enabled := RRun.Enabled;
  393. RStepOut.Enabled := FPaused;
  394. RToggleBreakPoint.Enabled := FActiveMemo is TIDEScintFileEdit;
  395. RTerminate.Enabled := FDebugging and (FDebugClientWnd <> 0);
  396. TerminateButton.Enabled := RTerminate.Enabled;
  397. REvaluate.Enabled := FDebugging and (FDebugClientWnd <> 0);
  398. { See UpdateRunMenu2 for other menu items and also see UpdateBreakPointsMenu }
  399. end;
  400. procedure TMainFormUpdateMenuHelper.UpdateRunMenu2(const Menu: TMenuItem);
  401. begin
  402. RDeleteBreakPoints.Enabled := _AnyMemoHasBreakPoint;
  403. { See UpdateRunMenu for other menu items }
  404. _ApplyMenuBitmaps(Menu);
  405. end;
  406. procedure TMainFormUpdateMenuHelper.UpdateBreakPointsMenu(const Menu: TMenuItem);
  407. begin
  408. RToggleBreakPoint2.Enabled := FActiveMemo is TIDEScintFileEdit;
  409. RDeleteBreakPoints2.Enabled := _AnyMemoHasBreakPoint;
  410. { Also see UpdateRunMenu }
  411. _ApplyMenuBitmaps(Menu);
  412. end;
  413. procedure TMainFormUpdateMenuHelper.UpdateTargetMenu;
  414. begin
  415. if FDebugTarget = dtSetup then begin
  416. RTargetSetup.Checked := True;
  417. TargetSetupButton.Down := True;
  418. end else begin
  419. RTargetUninstall.Checked := True;
  420. TargetUninstallButton.Down := True;
  421. end;
  422. end;
  423. end.