- Timestamp:
- Apr 7, 2024, 11:50:48 PM (9 months ago)
- Location:
- trunk/Packages/Kernel
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Kernel/Kernel.API.pas
r60 r61 38 38 end; 39 39 40 { T KernelApi }40 { TSystemApi } 41 41 42 TKernelApi = class 43 Kernel: TObject; //TKernel; 44 function Call(Command: TApiCommand; Data: Pointer): Pointer; 45 procedure WriteText(Text: string); 46 procedure DrawText(CanvasId: Integer; P: TPoint; Text: string; Color: TColor); 47 procedure DrawLine(CanvasId: Integer; P1, P2: TPoint; Color: TColor); 48 procedure DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor); 49 procedure DrawFrame(CanvasId: Integer; Rect: TRectangle; Color: TColor); 50 procedure Sleep(Time: TDateTime); 51 procedure ReadMessage(Message: TIPCMessage); 52 function WindowCreate: Integer; 53 function GetWindowCanvas(WindowId: Integer): Integer; 54 procedure WindowSetAttr(WindowId: Integer; Bounds: TRectangle; Visible: Boolean); 42 TSystemApi = class 43 function Call(Command: TApiCommand; Data: Pointer): Pointer; virtual; abstract; 44 procedure WriteText(Text: string); virtual; abstract; 45 procedure DrawText(CanvasId: Integer; P: TPoint; Text: string; Color: TColor); virtual; abstract; 46 procedure DrawLine(CanvasId: Integer; P1, P2: TPoint; Color: TColor); virtual; abstract; 47 procedure DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor); virtual; abstract; 48 procedure DrawFrame(CanvasId: Integer; Rect: TRectangle; Color: TColor); virtual; abstract; 49 procedure Sleep(Time: TDateTime); virtual; abstract; 50 procedure ReadMessage(Message: TIPCMessage); virtual; abstract; 51 function WindowCreate: Integer; virtual; abstract; 52 function GetWindowCanvas(WindowId: Integer): Integer; virtual; abstract; 53 procedure WindowSetAttr(WindowId: Integer; Bounds: TRectangle; Visible: Boolean); virtual; abstract; 55 54 end; 56 55 … … 166 165 end; 167 166 168 { TKernelApi }169 170 function TKernelApi.Call(Command: TApiCommand; Data: Pointer171 ): Pointer;172 begin173 case Command of174 acDrawLine: DrawLine(TDrawLineParams(Data^).CanvasId, TDrawLineParams(Data^).P1,175 TDrawLineParams(Data^).P2, TDrawLineParams(Data^).Color);176 acDrawRect: DrawRect(TDrawRectParams(Data^).CanvasId, TDrawRectParams(Data^).Rect,177 TDrawRectParams(Data^).Color);178 acDrawFrame: DrawFrame(TDrawRectParams(Data^).CanvasId, TDrawRectParams(Data^).Rect,179 TDrawRectParams(Data^).Color);180 acDrawText: DrawText(TDrawTextParams(Data^).CanvasId, TDrawTextParams(Data^).P,181 TDrawTextParams(Data^).Text, TDrawTextParams(Data^).Color);182 acSleep: Sleep(TDateTime(Data^));183 acWindowCreate: Result := Pointer(WindowCreate);184 acWindowSetAttr: WindowSetAttr(TWindowSetAttrParams(Data^).WindowId,185 TWindowSetAttrParams(Data^).Bounds, TWindowSetAttrParams(Data^).Visible);186 acWriteText: WriteText(string(Data));187 acReadMessage: ReadMessage(Data);188 acGetWindowCanvas: Result := Pointer(GetWindowCanvas(Integer(Data)));189 end;190 end;191 192 procedure TKernelApi.WriteText(Text: string);193 var194 Device: TDeviceSerial;195 begin196 Device := TDeviceSerial(TKernel(Kernel).Devices.FindByName('Serial0'));197 if Assigned(Device) then begin198 Device.WriteText(Text);199 end else raise Exception.Create('Device Serial0 not found');200 end;201 202 procedure TKernelApi.DrawText(CanvasId: Integer; P: TPoint; Text: string; Color: TColor);203 var204 Screen: TScreen;205 Canvas: TCanvas;206 begin207 Canvas := TKernel(Kernel).Desktop.FindCanvasById(CanvasId);208 if Assigned(Canvas) then begin209 Canvas.DrawText(P, Text, Color);210 end;211 end;212 213 procedure TKernelApi.DrawLine(CanvasId: Integer; P1, P2: TPoint; Color: TColor);214 var215 Screen: TScreen;216 Canvas: TCanvas;217 begin218 Canvas := TKernel(Kernel).Desktop.FindCanvasById(CanvasId);219 if Assigned(Canvas) then begin220 Canvas.DrawLine(P1.Add(Canvas.Position), P2.Add(Canvas.Position), Color);221 end;222 end;223 224 procedure TKernelApi.DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor);225 var226 Canvas: TCanvas;227 begin228 Canvas := TKernel(Kernel).Desktop.FindCanvasById(CanvasId);229 if Assigned(Canvas) then begin230 Canvas.DrawRect(Rect, Color);231 end;232 end;233 234 procedure TKernelApi.DrawFrame(CanvasId: Integer; Rect: TRectangle;235 Color: TColor);236 var237 Canvas: TCanvas;238 begin239 Canvas := TKernel(Kernel).Desktop.FindCanvasById(CanvasId);240 if Assigned(Canvas) then begin241 Canvas.DrawFrame(Rect, Color);242 end;243 end;244 245 procedure TKernelApi.Sleep(Time: TDateTime);246 var247 Task: TTask;248 begin249 Task := TKernel(Kernel).Scheduler.GetCurrentTask;250 Task.Sleep(Time);251 end;252 253 procedure TKernelApi.ReadMessage(Message: TIPCMessage);254 var255 Task: TTask;256 begin257 Task := TKernel(Kernel).Scheduler.GetCurrentTask;258 while Task.Messages.List.Count = 0 do Task.WaitForMessage;259 end;260 261 function TKernelApi.WindowCreate: Integer;262 var263 Window: TWindow;264 begin265 Window := TKernel(Kernel).Desktop.CreateWindow;266 Window.Desktop := TKernel(Kernel).Desktop;267 Result := Window.Id;268 end;269 270 function TKernelApi.GetWindowCanvas(WindowId: Integer): Integer;271 var272 Window: TWindow;273 Canvas: TCanvas;274 begin275 Window := TWindow(TKernel(Kernel).Desktop.FindObjectById(WindowId));276 if Assigned(Window) then begin277 Canvas := Window.Canvas;278 Result := Canvas.Id;279 end else Result := -1;280 end;281 282 procedure TKernelApi.WindowSetAttr(WindowId: Integer; Bounds: TRectangle; Visible: Boolean);283 var284 Window: TWindow;285 begin286 Window := TWindow(TKernel(Kernel).Desktop.FindObjectById(WindowId));287 if Assigned(Window) then begin288 Window.Bounds := Bounds;289 Window.Canvas.Position := Bounds.Position;290 Window.Visible := Visible;291 Window.Desktop.Paint;292 end;293 end;294 295 296 167 end. 297 168 -
trunk/Packages/Kernel/Kernel.Core.pas
r60 r61 6 6 Classes, SysUtils, Kernel.List, Kernel.FileSystem, Kernel.Memory, 7 7 Kernel.Screen, Kernel.Device, Kernel.App, Kernel.Scheduler, Kernel.Api, 8 Kernel.Graphics, Generics.Collections ;8 Kernel.Graphics, Generics.Collections, Kernel.IPC; 9 9 10 10 type … … 25 25 TKernel = class 26 26 private 27 Api: T KernelApi;27 Api: TSystemApi; 28 28 procedure InitVideo; 29 29 function KernelApiExecute(Command: TApiCommand; Data: Pointer): Pointer; … … 47 47 48 48 implementation 49 50 uses 51 Kernel.KernelAPI; 49 52 50 53 { TDrive } … … 162 165 Screens := TObjectList<TScreen>.Create; 163 166 Api := TKernelApi.Create; 164 Api.Kernel := Self;167 TKernelApi(Api).Kernel := Self; 165 168 Desktop := TDesktop.Create; 166 169 end; -
trunk/Packages/Kernel/Kernel.Screen.pas
r60 r61 4 4 5 5 uses 6 SysUtils, Math, Kernel.Graphics ;6 SysUtils, Math, Kernel.Graphics, Kernel.Device; 7 7 8 8 type … … 31 31 function GetVideoMemory: PByte; 32 32 public 33 Device: T Object; // TDeviceVideo;33 Device: TDeviceVideo; 34 34 Size: TPoint; 35 35 DPI: Integer; … … 44 44 45 45 implementation 46 47 uses48 Kernel.Device;49 46 50 47 { TScreenCanvas } -
trunk/Packages/Kernel/Kernel.lpk
r60 r61 24 24 </Other> 25 25 </CompilerOptions> 26 <Files Count="1 3">26 <Files Count="14"> 27 27 <Item1> 28 28 <Filename Value="Kernel.API.pas"/> … … 78 78 <UnitName Value="KernelPackage"/> 79 79 </Item13> 80 <Item14> 81 <Filename Value="Kernel.KernelAPI.pas"/> 82 <UnitName Value="Kernel.KernelAPI"/> 83 </Item14> 80 84 </Files> 81 85 <CompatibilityMode Value="True"/> -
trunk/Packages/Kernel/KernelPackage.pas
r60 r61 11 11 Kernel.API, Kernel.App, Kernel.Classes, Kernel.FileSystem, Kernel.Graphics, 12 12 Kernel.Core, Kernel.List, Kernel.Memory, Kernel.Device, Kernel.Screen, 13 Kernel.IPC, Kernel.Scheduler, LazarusPackageIntf;13 Kernel.IPC, Kernel.Scheduler, Kernel.KernelAPI, LazarusPackageIntf; 14 14 15 15 implementation
Note:
See TracChangeset
for help on using the changeset viewer.