Browse Source

* Apply patch from Margers to fix bug ID #6496

git-svn-id: trunk@40804 -
michael 6 years ago
parent
commit
a9696520fb
2 changed files with 22 additions and 6 deletions
  1. 21 6
      packages/ide/fpide.pas
  2. 1 0
      packages/ide/fpmwnd.inc

+ 21 - 6
packages/ide/fpide.pas

@@ -1657,7 +1657,10 @@ procedure TIDEApp.UpdateRecentFileList;
 var P: PMenuItem;
     {ID,}I: word;
     FileMenu: PMenuItem;
+    R: TRect;
+    AdjustRecentCount : word;
 begin
+  if not assigned(MenuBar) then exit;
 {  ID:=cmRecentFileBase;}
   FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
   repeat
@@ -1683,13 +1686,25 @@ begin
   if (P<>nil) and IsSeparator(P) then
      RemoveMenuItem(FileMenu^.SubMenu,P);
 
-  if RecentFileCount>0 then
-     AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
-  for I:=1 to RecentFileCount do
+  GetExtent(R);
+  AdjustRecentCount :=0;
+  {calculate how much lines on screen for reacent files can be used }
+  if r.b.y-r.a.y -19 > 0 then AdjustRecentCount:=r.b.y-r.a.y -19;
+  {only if there is enough space then show all reacent files }
+  {else cut list shorter }
+  if RecentFileCount < AdjustRecentCount then
+     AdjustRecentCount:=RecentFileCount;
+
+  if AdjustRecentCount>0 then
   begin
-    P:=NewItem('~'+IntToStr(I)+'~ '+ShrinkPath(SmartPath(RecentFiles[I].FileName),27),' ',
-        kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
-    AppendMenuItem(FileMenu^.SubMenu,P);
+     AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
+
+    for I:=1 to AdjustRecentCount do
+    begin
+      P:=NewItem('~'+IntToStr(I)+'~ '+ShrinkPath(SmartPath(RecentFiles[I].FileName),27),' ',
+          kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
+      AppendMenuItem(FileMenu^.SubMenu,P);
+    end;
   end;
 end;
 

+ 1 - 0
packages/ide/fpmwnd.inc

@@ -38,6 +38,7 @@ begin
       Mode.col:=x;
       Mode.row:=y;
       SetScreenVideoMode(Mode);
+      UpdateRecentFileList; {ensure file menu not go over screen}
       Redraw;
     end;
 end;