Changeset 16
- Timestamp:
- Dec 28, 2017, 1:14:31 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Apps/UClock.pas
r13 r16 38 38 WindowId := API.WindowCreate; 39 39 CanvasId := API.GetWindowCanvas(WindowId); 40 API.WindowSetAttr(WindowId, TRectangle.Create(100, 50, 300, 200), True);40 API.WindowSetAttr(WindowId, TRectangle.Create(100, 150, 300, 200), True); 41 41 while not Task.Terminated do begin 42 42 API.WriteText('test'); 43 API.DrawRect(CanvasId, TRectangle.Create(60, 60, 180, 180), $ ffffff);43 API.DrawRect(CanvasId, TRectangle.Create(60, 60, 180, 180), $b0ffff); 44 44 API.DrawText(CanvasId, TPoint.Create(10, 10), 'Text', 0); 45 45 Angle := Frac(Now / (10 * OneSecond)) * 2 * Pi; … … 69 69 WindowId := API.WindowCreate; 70 70 CanvasId := API.GetWindowCanvas(WindowId); 71 API.WindowSetAttr(WindowId, TRectangle.Create(1 00, 100, 300, 200), True);71 API.WindowSetAttr(WindowId, TRectangle.Create(120, 100, 400, 200), True); 72 72 while not Task.Terminated do begin 73 73 API.WriteText('test2'); -
trunk/Packages/Kernel/UAPI.pas
r15 r16 11 11 type 12 12 TApiCommand = (acNone, acWriteText, acDrawText, acDrawLine, acDrawRect, acSleep, 13 acReadMessage, acWindowCreate, acWindowSetAttr, acGetWindowCanvas); 13 acReadMessage, acWindowCreate, acWindowSetAttr, acGetWindowCanvas, 14 acDrawFrame); 14 15 15 16 TDrawTextParams = record … … 48 49 procedure DrawLine(CanvasId: Integer; P1, P2: TPoint; Color: TColor); 49 50 procedure DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor); 51 procedure DrawFrame(CanvasId: Integer; Rect: TRectangle; Color: TColor); 50 52 procedure Sleep(Time: TDateTime); 51 53 procedure ReadMessage(Message: TIPCMessage); … … 66 68 procedure DrawLine(CanvasId: Integer; P1, P2: TPoint; Color: TColor); 67 69 procedure DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor); 70 procedure DrawFrame(CanvasId: Integer; Rect: TRectangle; Color: TColor); 68 71 procedure Sleep(Time: TDateTime); 69 72 procedure ReadMessage(Message: TIPCMessage); … … 124 127 end; 125 128 129 procedure TUserApi.DrawFrame(CanvasId: Integer; Rect: TRectangle; Color: TColor 130 ); 131 var 132 Params: TDrawRectParams; 133 begin 134 Params.CanvasId := CanvasId; 135 Params.Rect := Rect; 136 Params.Color := Color; 137 Call(acDrawFrame, @Params); 138 end; 139 126 140 procedure TUserApi.Sleep(Time: TDateTime); 127 141 begin … … 163 177 TDrawLineParams(Data^).P2, TDrawLineParams(Data^).Color); 164 178 acDrawRect: DrawRect(TDrawRectParams(Data^).CanvasId, TDrawRectParams(Data^).Rect, 179 TDrawRectParams(Data^).Color); 180 acDrawFrame: DrawFrame(TDrawRectParams(Data^).CanvasId, TDrawRectParams(Data^).Rect, 165 181 TDrawRectParams(Data^).Color); 166 182 acDrawText: DrawText(TDrawTextParams(Data^).CanvasId, TDrawTextParams(Data^).P, … … 210 226 procedure TKernelApi.DrawRect(CanvasId: Integer; Rect: TRectangle; Color: TColor); 211 227 var 212 Screen: TScreen;213 228 Canvas: TCanvas; 214 229 begin … … 216 231 if Assigned(Canvas) then begin 217 232 Canvas.DrawRect(Rect, Color); 233 end; 234 end; 235 236 procedure TKernelApi.DrawFrame(CanvasId: Integer; Rect: TRectangle; 237 Color: TColor); 238 var 239 Canvas: TCanvas; 240 begin 241 Canvas := TKernel(Kernel).Desktop.FindCanvasById(CanvasId); 242 if Assigned(Canvas) then begin 243 Canvas.DrawFrame(Rect, Color); 218 244 end; 219 245 end; … … 265 291 Window.Canvas.Position := Bounds.Position; 266 292 Window.Visible := Visible; 293 Window.Desktop.Paint; 267 294 end; 268 295 end; -
trunk/Packages/Kernel/UGraphics.pas
r15 r16 16 16 X: Integer; 17 17 Y: Integer; 18 function Create(X, Y: Integer): TPoint; 18 function Create(X, Y: Integer): TPoint; inline; 19 19 function Add(P: TPoint): TPoint; 20 20 end; … … 36 36 Size: TPoint; 37 37 function PointInside(P: TPoint): Boolean; 38 function Create(Left, Top, Width, Height: Integer): TRectangle; overload; 39 function Create(Position, Size: TPoint): TRectangle; overload; 38 function Create(Left, Top, Width, Height: Integer): TRectangle; overload; inline; 39 function Create(Position, Size: TPoint): TRectangle; overload; inline; 40 40 function AddPoint(P: TPoint): TRectangle; 41 41 property Left: Integer read GetLeft write SetLeft; … … 57 57 procedure DrawLine(P1, P2: TPoint; Color: TColor); virtual; 58 58 procedure DrawRect(Rect: TRectangle; Color: TColor); virtual; 59 procedure DrawFrame(Rect: TRectangle; Color: TColor); virtual; 59 60 procedure SetPixel(P: TPoint; Color: TColor); virtual; 60 61 end; … … 217 218 end; 218 219 220 procedure TCanvas.DrawFrame(Rect: TRectangle; Color: TColor); 221 begin 222 if Assigned(Parent) then 223 Parent.DrawFrame(Rect.AddPoint(Position), Color); 224 end; 225 219 226 procedure TCanvas.SetPixel(P: TPoint; Color: TColor); 220 227 begin … … 246 253 begin 247 254 inherited Paint; 248 Canvas.DrawRect(Bounds, $ff0000); 255 Canvas.DrawRect(TRectangle.Create(TPoint.Create(0, 0), Bounds.Size), $a0a0a0); 256 Canvas.DrawFrame(TRectangle.Create(TPoint.Create(0, 0), Bounds.Size), $000000); 249 257 end; 250 258 -
trunk/Packages/Kernel/UScreen.pas
r15 r16 11 11 TScreen = class; 12 12 13 { TScreenCanvas } 14 13 15 TScreenCanvas = class(TCanvas) 14 16 Screen: TScreen; … … 16 18 procedure DrawLine(P1, P2: TPoint; Color: TColor); override; 17 19 procedure DrawRect(Rect: TRectangle; Color: TColor); override; 20 procedure DrawFrame(Rect: TRectangle; Color: TColor); override; 18 21 procedure SetPixel(P: TPoint; Color: TColor); override; 19 22 end; … … 71 74 end; 72 75 76 procedure TScreenCanvas.DrawFrame(Rect: TRectangle; Color: TColor); 77 var 78 X, Y: Integer; 79 begin 80 for Y := Rect.Top to Rect.Bottom do begin 81 SetPixel(TPoint.Create(Rect.Left, Y), Color); 82 SetPixel(TPoint.Create(Rect.Right, Y), Color); 83 end; 84 for X := Rect.Left to Rect.Right do begin 85 SetPixel(TPoint.Create(X, Rect.Top), Color); 86 SetPixel(TPoint.Create(X, Rect.Bottom), Color); 87 end; 88 Screen.VideoMemoryUpdated; 89 end; 90 73 91 procedure TScreenCanvas.SetPixel(P: TPoint; Color: TColor); 74 92 begin
Note:
See TracChangeset
for help on using the changeset viewer.