Browse Source

Make clock visible and have it as an option of choice.

Margers 1 month ago
parent
commit
fddf4b3215

+ 3 - 1
packages/ide/fp.pas

@@ -172,7 +172,7 @@ begin
             else
             if (copy(Param,3,1)='-') then
               StartupOptions:=StartupOptions and not soHeapMonitor;
-            OverrideLastDirOption:=true;
+            OverrideHeapMonitor:=true;
           end else
 {$ifdef go32v2}
         if (UpcaseStr(Param)='NOLFN') or (UpcaseStr(Param)='N') then
@@ -225,6 +225,7 @@ begin
               else
               if (Param='-') then
                 StartupOptions:=StartupOptions and (not soReturnToLastDir);
+              OverrideLastDirOption:=true;
             end;
           'S' :
              if Length(Param)=1 then
@@ -480,6 +481,7 @@ BEGIN
   IDEApp.Update;
   IDEApp.UpdateMode;
   IDEApp.UpdateTarget;
+  IDEApp.UpdateClockAndHeap;
 
   ProcessParams(false);
 

+ 4 - 0
packages/ide/fpconst.pas

@@ -144,6 +144,10 @@ const
      moCloseOnGotoSource  = $00000002;
      moChangeDirOnOpen    = $00000004;
 
+     { Desktop Option constants }
+     dpClockView          = $00000001;
+     dpHeapMonitor        = $00000002;
+
      { Desktop Location constants }
      dlCurrentDir         = $00;
      dlConfigFileDir      = $01;

+ 36 - 6
packages/ide/fpide.pas

@@ -157,6 +157,7 @@ type
       procedure RemoveRecentFile(Index: integer);
     public
       procedure CurDirChanged;
+      procedure UpdateClockAndHeap; { update visiblity of ClockView and HeapView }
     private
       procedure UpdatePrimaryFile;
       procedure UpdateINIFile;
@@ -664,6 +665,9 @@ resourcestring  menu_local_gotosource = '~G~oto source';
                 label_preferences_closeongotosource = 'C~l~ose on go to source';
                 label_preferences_changedironopen = 'C~h~ange dir on open';
                 label_preferences_options = 'Options';
+                label_preferences_showclock = 'Show ~c~lock';
+                label_preferences_showheapmonitor = 'Show heap ~m~onitor';
+                label_preferences_clockheap = 'Desktop';
 
                 {Desktop preferences dialog.}
                 dialog_desktoppreferences = 'Desktop Preferences';
@@ -862,10 +866,11 @@ begin
   InitAdvMsgBox;
   InsideDone:=false;
   IsRunning:=true;
-  MenuBar^.GetBounds(R); R.A.X:=R.B.X-8;
+  MenuBar^.GetBounds(R); R.A.X:=R.B.X-9;
   New(ClockView, Init(R));
   ClockView^.GrowMode:=gfGrowLoX+gfGrowHiX;
-  Application^.Insert(ClockView);
+  {  Insert only if and when we are going to look at it (hide is not sufficient measure)
+  Application^.Insert(ClockView);   }
   New(ClipboardWindow, Init);
   Desktop^.Insert(ClipboardWindow);
   New(CalcWindow, Init); CalcWindow^.Hide;
@@ -875,10 +880,10 @@ begin
   Desktop^.Insert(CompilerMessageWindow);
   Message(@Self,evBroadcast,cmUpdate,nil);
   { heap viewer }
-  GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-9; R.A.Y:=R.B.Y-1;
+  GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-8; R.A.Y:=R.B.Y-1;
   New(HeapView, InitKb(R));
-  if (StartupOptions and soHeapMonitor)=0 then HeapView^.Hide;
-  Insert(HeapView);
+  if OverrideHeapMonitor and ((StartupOptions and soHeapMonitor)<>0) then
+    Insert(HeapView);
   Drivers.ShowMouse;
 {$ifdef Windows}
   // WindowsShowMouse;
@@ -1129,7 +1134,14 @@ begin
        end;
    end;
    loadmenubar;
-   insert(menubar);
+   Insert(MenuBar);
+   if (DesktopPreferences and dpClockView)<>0 then
+   begin
+     { In theory InsertBefore should do the trick, but it does not }
+     { Push ClockView in front of MenuBar }
+     Delete(ClockView);
+     Insert(ClockView);
+   end;
 end;
 
 procedure TIDEApp.InitStatusLine;
@@ -1819,6 +1831,19 @@ begin
   end;
 end;
 
+procedure TIDEApp.UpdateClockAndHeap;
+begin
+  if not OverrideHeapMonitor then
+  begin
+    Application^.Delete(HeapView);
+    if ((DesktopPreferences and dpHeapMonitor)<>0) then
+      Application^.Insert(HeapView);
+  end;
+  Application^.Delete(ClockView);
+  if (DesktopPreferences and dpClockView)<>0 then
+    Application^.Insert(ClockView);
+end;
+
 procedure TIDEApp.DosShell;
 var
   s : string;
@@ -1949,6 +1974,11 @@ destructor TIDEApp.Done;
 begin
   InsideDone:=true;
   IsRunning:=false;
+  {manualy dispose ClockView and HeapView}
+  Delete(ClockView);
+  Dispose(ClockView);
+  Delete(HeapView);
+  Dispose(HeapView);
   inherited Done;
   Desktop:=nil;
   RemoveBrowsersCollection;

+ 3 - 0
packages/ide/fpini.pas

@@ -154,6 +154,7 @@ const
   ieAutoSave         = 'AutoSaveFlags';
   ieMiscOptions      = 'MiscOptions';
   ieDesktopLocation  = 'DesktopLocation';
+  ieDesktopPreferences= 'DesktopPreferences';
   ieDesktopFlags     = 'DesktopFileFlags';
   ieCenterDebuggerRow= 'CenterCurrentLineWhileDebugging';
   ieShowReadme       = 'ShowReadme';
@@ -591,6 +592,7 @@ begin
   AutoSaveOptions:=INIFile^.GetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
   MiscOptions:=INIFile^.GetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
   DesktopLocation:=INIFile^.GetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
+  DesktopPreferences:=INIFile^.GetIntEntry(secPreferences,ieDesktopPreferences,DesktopPreferences);
   { Misc }
   ShowReadme:=INIFile^.GetIntEntry(secMisc,ieShowReadme,{integer(ShowReadme)}1)<>0;
   Dispose(INIFile, Done);
@@ -776,6 +778,7 @@ begin
   INIFile^.SetIntEntry(secPreferences,ieAutoSave,AutoSaveOptions);
   INIFile^.SetIntEntry(secPreferences,ieMiscOptions,MiscOptions);
   INIFile^.SetIntEntry(secPreferences,ieDesktopLocation,DesktopLocation);
+  INIFile^.SetIntEntry(secPreferences,ieDesktopPreferences,DesktopPreferences);
   { Misc }
   INIFile^.SetIntEntry(secMisc,ieShowReadme,integer(ShowReadme));
   OK:=INIFile^.Update;

+ 16 - 2
packages/ide/fpmopts.inc

@@ -1071,7 +1071,7 @@ var R,R2: TRect;
     ScreenModeInfo : array[1..3] of longint;
     CurVP,VP: PVideoMode;
     RB1: PPlainRadioButtons;
-    CB1,CB2: PPlainCheckBoxes;
+    CB1,CB2,CB3: PPlainCheckBoxes;
     CurIdx: integer;
     i : word;
 begin
@@ -1128,7 +1128,19 @@ begin
 
     GetExtent(R); R.Grow(-2,-2);
     R.A.X:=R.B.X-(R.B.X-R.A.X) div 2 + 1;
-    R.B.Y:=R.A.Y+7;
+    R.B.Y:=R.A.Y+3;
+
+    R.Move(0,R.B.Y-R.A.Y{+1}); R.B.Y:=R.A.Y+4;
+    R2.Copy(R); R2.Grow(-1,-1);
+    New(CB3, Init(R2,
+      NewSItem(label_preferences_showclock,
+      NewSItem(label_preferences_showheapmonitor,
+      nil))));
+    CB3^.Value:=DesktopPreferences;
+    if OverrideHeapMonitor then  { if heap motior state is set by fp parameter }
+      CB3^.EnableMask:=CB3^.EnableMask and not(dpHeapMonitor); { disable heap monitor check box }
+    Insert(New(PGroupView, Init(R, label_preferences_clockheap, CB3)));
+    Insert(CB3);
 
     R.Move(0,R.B.Y-R.A.Y{+1}); R.B.Y:=R.A.Y+5;
     R2.Copy(R); R2.Grow(-1,-1);
@@ -1180,6 +1192,8 @@ begin
      AutoSaveOptions:=CB1^.Value;
      MiscOptions:=CB2^.Value;
      DesktopLocation:=RB1^.Value;
+     DesktopPreferences:=CB3^.Value;
+     UpdateClockAndHeap;
    end;
   Dispose(D, Done);
   Dispose(C, Done);

+ 2 - 0
packages/ide/fpvars.pas

@@ -104,6 +104,7 @@ const INIFileName      : string = ININame;
       AltMouseAction   : integer = acBrowseSymbol;
       StartupOptions   : longint = 0;
       OverrideLastDirOption : boolean = false;
+      OverrideHeapMonitor   : boolean = false;
       LastExitCode     : integer = 0;
       ASCIIChart       : PFPASCIIChart = nil;
       BackgroundPath   : string = BackgroundName;
@@ -111,6 +112,7 @@ const INIFileName      : string = ININame;
                                    dfCodeCompleteWords+dfCodeTemplates;
       DesktopLocation  : byte    = dlConfigFileDir;
       AutoSaveOptions  : longint = asEnvironment+asDesktop;
+      DesktopPreferences:longint = 0; { by default show no Clock, no Heap mointor }
       MiscOptions      : longint = moChangeDirOnOpen+moCloseOnGotoSource;
       EditorModified   : boolean = false;
       IniCenterDebuggerRow : tcentre = do_centre;

+ 1 - 1
packages/ide/wviews.pas

@@ -43,7 +43,7 @@ const
       cmUserBtn3             = $fee2;
       cmUserBtn4             = $fee3;
 
-      CPlainCluster          = #7#8#9#9;
+      CPlainCluster          = #7#8#9#9#13#9;{normal}{ active }{shortcut}{..}{disabled}{..}
 
 type
     longstring = ansistring;