- Timestamp:
- Oct 10, 2024, 11:05:35 PM (6 weeks ago)
- Location:
- branches/Independent
- Files:
-
- 8 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Independent
- Property svn:ignore
-
old new 3 3 Independent.lps 4 4 Independent.res 5 heaptrclog.trc
-
- Property svn:ignore
-
branches/Independent/Api.pas
r65 r66 7 7 8 8 type 9 THandle = NativeInt; 10 11 { THandles } 12 13 THandles = class(TList<THandle>) 14 NewHandle: THandle; 15 function AddNew: THandle; 16 end; 17 9 18 { TApi } 10 19 … … 13 22 procedure RunApp(Name: string); virtual; abstract; 14 23 procedure Sleep(Time: TDateTime); virtual; abstract; 24 function CreateWindow: THandle; virtual; abstract; 25 procedure SetWindowName(Handle: THandle; Name: string); virtual; abstract; 26 procedure SetWindowRect(Handle: THandle; Rect: TRect); virtual; abstract; 27 procedure SetWindowVisible(Handle: THandle; Visible: Boolean); virtual; abstract; 15 28 end; 16 29 … … 38 51 39 52 implementation 53 54 { THandles } 55 56 function THandles.AddNew: THandle; 57 begin 58 Result := NewHandle; 59 Inc(NewHandle); 60 Add(Result); 61 end; 40 62 41 63 { TApp } -
branches/Independent/Apps.pas
r65 r66 30 30 31 31 procedure TAppTest.Run(Context: TAppContext); 32 var 33 Handle: THandle; 32 34 begin 33 35 with Context.Api do begin … … 35 37 Sleep(OneSecond); 36 38 RunApp('Code'); 39 Handle := CreateWindow; 40 SetWindowName(Handle, 'New window'); 41 SetWindowRect(Handle, Bounds(100, 100, 400, 200)); 42 SetWindowVisible(Handle, True); 43 44 Handle := CreateWindow; 45 SetWindowName(Handle, 'Second window'); 46 SetWindowRect(Handle, Bounds(350, 150, 500, 300)); 47 SetWindowVisible(Handle, True); 37 48 end; 38 49 end; -
branches/Independent/Independent.lpi
r65 r66 24 24 <SearchPaths> 25 25 <IncludeFiles Value="$(ProjOutDir)"/> 26 <OtherUnitFiles Value="Forms"/> 26 27 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 27 28 </SearchPaths> … … 73 74 </Unit> 74 75 <Unit> 75 <Filename Value="Form Main.pas"/>76 <Filename Value="Forms/FormMain.pas"/> 76 77 <IsPartOfProject Value="True"/> 77 78 <ComponentName Value="FormName"/> … … 99 100 <IsPartOfProject Value="True"/> 100 101 </Unit> 102 <Unit> 103 <Filename Value="Forms/FormConsole.pas"/> 104 <IsPartOfProject Value="True"/> 105 <ComponentName Value="FormConsole"/> 106 <ResourceBaseClass Value="Form"/> 107 </Unit> 108 <Unit> 109 <Filename Value="Forms/FormScreen.pas"/> 110 <IsPartOfProject Value="True"/> 111 <ComponentName Value="FormScreen"/> 112 <ResourceBaseClass Value="Form"/> 113 </Unit> 101 114 </Units> 102 115 </ProjectOptions> … … 108 121 <SearchPaths> 109 122 <IncludeFiles Value="$(ProjOutDir)"/> 123 <OtherUnitFiles Value="Forms"/> 110 124 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 111 125 </SearchPaths> … … 131 145 <Debugging> 132 146 <DebugInfoType Value="dsDwarf3"/> 147 <UseHeaptrc Value="True"/> 133 148 </Debugging> 134 149 <Options> -
branches/Independent/Independent.lpr
r65 r66 1 1 program Independent; 2 3 {$mode objfpc}{$H+}4 2 5 3 uses 6 4 {$IFDEF UNIX} 7 cthreads, 5 cthreads, clocale, 8 6 {$ENDIF} 9 7 {$IFDEF HASAMIGA} … … 11 9 {$ENDIF} 12 10 Interfaces, // this includes the LCL widgetset 13 Forms, FormMain, Os, Apps, Api, Console, FileSystem11 Forms, FormMain, FormScreen, SysUtils 14 12 { you can add units after this }; 15 13 16 14 {$R *.res} 17 15 16 {$if declared(UseHeapTrace)} 17 const 18 HeapTraceLog = 'heaptrclog.trc'; 19 {$ENDIF} 20 18 21 begin 22 {$if declared(UseHeapTrace)} 23 // Heap trace 24 DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog); 25 SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog); 26 {$ENDIF} 27 19 28 RequireDerivedFormResource:=True; 20 29 Application.Scaled:=True; -
branches/Independent/Os.pas
r65 r66 53 53 procedure RunApp(Name: string); override; 54 54 procedure Sleep(Time: TDateTime); override; 55 function CreateWindow: THandle; override; 56 procedure SetWindowName(Handle: THandle; Name: string); override; 57 procedure SetWindowRect(Handle: THandle; Rect: TRect); override; 58 procedure SetWindowVisible(Handle: THandle; Visible: Boolean); override; 59 end; 60 61 { TWindow } 62 63 TWindow = class 64 Handle: THandle; 65 Name: string; 66 Visible: Boolean; 67 Rect: TRect; 68 end; 69 70 { TWindows } 71 72 TWindows = class(TObjectList<TWindow>) 73 function AddNew: TWindow; 74 function SearchByHandle(Handle: THandle): TWindow; 55 75 end; 56 76 … … 58 78 59 79 TSystem = class 80 private 81 FOnDraw: TNotifyEvent; 82 procedure Redraw; 83 public 60 84 Console: TConsole; 61 85 FileSystem: TFileSystem; 62 86 Apps: TApps; 63 87 RunningApps: TRunningApps; 88 Windows: TWindows; 89 Handles: THandles; 64 90 procedure RunApp(Name: string); 65 91 procedure Start; 66 92 constructor Create; 67 93 destructor Destroy; override; 94 property OnDraw: TNotifyEvent read FOnDraw write FOnDraw; 68 95 end; 69 96 … … 153 180 end; 154 181 182 function TSystemApi.CreateWindow: THandle; 183 var 184 Window: TWindow; 185 begin 186 Window := System.Windows.AddNew; 187 Window.Handle := System.Handles.AddNew; 188 Result := Window.Handle; 189 end; 190 191 procedure TSystemApi.SetWindowName(Handle: THandle; Name: string); 192 var 193 Window: TWindow; 194 begin 195 Window := System.Windows.SearchByHandle(Handle); 196 if Assigned(Window) then begin 197 Window.Name := Name; 198 System.Redraw; 199 end; 200 end; 201 202 procedure TSystemApi.SetWindowRect(Handle: THandle; Rect: TRect); 203 var 204 Window: TWindow; 205 begin 206 Window := System.Windows.SearchByHandle(Handle); 207 if Assigned(Window) then begin 208 Window.Rect := Rect; 209 System.Redraw; 210 end; 211 end; 212 213 procedure TSystemApi.SetWindowVisible(Handle: THandle; Visible: Boolean); 214 var 215 Window: TWindow; 216 begin 217 Window := System.Windows.SearchByHandle(Handle); 218 if Assigned(Window) then begin 219 Window.Visible := Visible; 220 System.Redraw; 221 end; 222 end; 223 224 { TWindows } 225 226 function TWindows.AddNew: TWindow; 227 begin 228 Result := TWindow.Create; 229 Add(Result); 230 end; 231 232 function TWindows.SearchByHandle(Handle: THandle): TWindow; 233 var 234 I: Integer; 235 begin 236 I := 0; 237 while (I < Count) and (Items[I].Handle <> Handle) do Inc(I); 238 if I < Count then Result := Items[I] 239 else Result := nil; 240 end; 241 155 242 { TSystem } 243 244 procedure TSystem.Redraw; 245 begin 246 if Assigned(FOnDraw) then FOnDraw(Self); 247 end; 156 248 157 249 procedure TSystem.RunApp(Name: string); … … 182 274 constructor TSystem.Create; 183 275 begin 276 Handles := THandles.Create; 277 Windows := TWindows.Create; 184 278 Console := TConsole.Create; 185 279 FileSystem := TFileSystem.Create; … … 194 288 FreeAndNil(Console); 195 289 FreeAndNil(FileSystem); 290 FreeAndNil(Windows); 291 FreeAndNil(Handles); 196 292 inherited; 197 293 end;
Note:
See TracChangeset
for help on using the changeset viewer.