Changeset 522 for GraphicTest/Packages/Graphics32/GR32_Backends_VCL.pas
- Timestamp:
- Apr 17, 2019, 10:42:18 AM (5 years ago)
- Location:
- GraphicTest/Packages/Graphics32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/Graphics32
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
GraphicTest/Packages/Graphics32/GR32_Backends_VCL.pas
r450 r522 40 40 uses 41 41 SysUtils, Classes, Windows, Graphics, GR32, GR32_Backends, GR32_Containers, 42 GR32_Image, GR32_Backends_Generic ;42 GR32_Image, GR32_Backends_Generic, GR32_Paths; 43 43 44 44 type … … 50 50 TGDIBackend = class(TCustomBackend, IPaintSupport, 51 51 IBitmapContextSupport, IDeviceContextSupport, 52 ITextSupport, IFontSupport, ICanvasSupport )52 ITextSupport, IFontSupport, ICanvasSupport, ITextToPathSupport) 53 53 private 54 54 procedure FontChangedHandler(Sender: TObject); … … 96 96 97 97 procedure Draw(const DstRect, SrcRect: TRect; hSrc: HDC); overload; 98 procedure DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; DstX, DstY: Integer); overload;99 procedure DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; const DstRect, SrcRect: TRect); overload;98 procedure DrawTo(hDst: HDC; DstX, DstY: Integer); overload; 99 procedure DrawTo(hDst: HDC; const DstRect, SrcRect: TRect); overload; 100 100 101 101 property Handle: HDC read GetHandle; 102 102 103 103 { ITextSupport } 104 procedure Textout(X, Y: Integer; const Text: String); overload;105 procedure Textout(X, Y: Integer; const ClipRect: TRect; const Text: String); overload;106 procedure Textout(var DstRect: TRect; const Flags: Cardinal; const Text: String); overload;107 function TextExtent(const Text: String): TSize;104 procedure Textout(X, Y: Integer; const Text: string); overload; 105 procedure Textout(X, Y: Integer; const ClipRect: TRect; const Text: string); overload; 106 procedure Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string); overload; 107 function TextExtent(const Text: string): TSize; 108 108 109 109 procedure TextoutW(X, Y: Integer; const Text: Widestring); overload; … … 121 121 property Font: TFont read GetFont write SetFont; 122 122 property OnFontChange: TNotifyEvent read FOnFontChange write FOnFontChange; 123 124 { ITextToPathSupport } 125 procedure TextToPath(Path: TCustomPath; const X, Y: TFloat; const Text: WideString); overload; 126 procedure TextToPath(Path: TCustomPath; const DstRect: TFloatRect; const Text: WideString; Flags: Cardinal); overload; 127 function MeasureText(const DstRect: TFloatRect; const Text: WideString; Flags: Cardinal): TFloatRect; 123 128 124 129 { ICanvasSupport } … … 158 163 procedure DoPaintRect(ABuffer: TBitmap32; ARect: TRect; ACanvas: TCanvas); 159 164 160 function GetHandle: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; // Dummy165 function GetHandle: HDC; // Dummy 161 166 protected 162 167 FBitmapInfo: TBitmapInfo; … … 173 178 174 179 { IDeviceContextSupport } 175 procedure Draw(const DstRect, SrcRect: TRect; hSrc: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}); overload;176 procedure DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; DstX, DstY: Integer); overload;177 procedure DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; const DstRect, SrcRect: TRect); overload;180 procedure Draw(const DstRect, SrcRect: TRect; hSrc: HDC); overload; 181 procedure DrawTo(hDst: HDC; DstX, DstY: Integer); overload; 182 procedure DrawTo(hDst: HDC; const DstRect, SrcRect: TRect); overload; 178 183 end; 179 184 180 185 implementation 186 187 uses 188 GR32_Text_VCL; 181 189 182 190 var … … 227 235 228 236 if FBits = nil then 229 raise E xception.Create(RCStrCannotAllocateDIBHandle);237 raise EBackend.Create(RCStrCannotAllocateDIBHandle); 230 238 231 239 FHDC := CreateCompatibleDC(0); … … 235 243 FBitmapHandle := 0; 236 244 FBits := nil; 237 raise E xception.Create(RCStrCannotCreateCompatibleDC);245 raise EBackend.Create(RCStrCannotCreateCompatibleDC); 238 246 end; 239 247 … … 245 253 FBitmapHandle := 0; 246 254 FBits := nil; 247 raise Exception.Create(RCStrCannotSelectAnObjectIntoDC); 248 end; 255 raise EBackend.Create(RCStrCannotSelectAnObjectIntoDC); 256 end; 257 end; 258 259 function TGDIBackend.MeasureText(const DstRect: TFloatRect; 260 const Text: WideString; Flags: Cardinal): TFloatRect; 261 begin 262 Result := GR32_Text_VCL.MeasureText(Font.Handle, DstRect, Text, Flags); 249 263 end; 250 264 … … 292 306 end; 293 307 294 function TGDIBackend.TextExtent(const Text: String): TSize;295 var 296 DC: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};308 function TGDIBackend.TextExtent(const Text: string): TSize; 309 var 310 DC: HDC; 297 311 OldFont: HGDIOBJ; 298 312 begin … … 318 332 function TGDIBackend.TextExtentW(const Text: Widestring): TSize; 319 333 var 320 DC: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};334 DC: HDC; 321 335 OldFont: HGDIOBJ; 322 336 begin … … 341 355 end; 342 356 343 procedure TGDIBackend.Textout(X, Y: Integer; const Text: String);357 procedure TGDIBackend.Textout(X, Y: Integer; const Text: string); 344 358 var 345 359 Extent: TSize; … … 390 404 end; 391 405 392 procedure TGDIBackend.Textout(X, Y: Integer; const ClipRect: TRect; const Text: String);406 procedure TGDIBackend.Textout(X, Y: Integer; const ClipRect: TRect; const Text: string); 393 407 var 394 408 Extent: TSize; … … 411 425 412 426 FOwner.Changed(DstRect); 427 end; 428 429 procedure TGDIBackend.TextToPath(Path: TCustomPath; const X, Y: TFloat; 430 const Text: WideString); 431 var 432 R: TFloatRect; 433 begin 434 R := FloatRect(X, Y, X, Y); 435 GR32_Text_VCL.TextToPath(Font.Handle, Path, R, Text, 0); 436 end; 437 438 procedure TGDIBackend.TextToPath(Path: TCustomPath; const DstRect: TFloatRect; 439 const Text: WideString; Flags: Cardinal); 440 begin 441 GR32_Text_VCL.TextToPath(Font.Handle, Path, DstRect, Text, Flags); 413 442 end; 414 443 … … 430 459 end; 431 460 432 procedure TGDIBackend.Textout(var DstRect: TRect; const Flags: Cardinal; const Text: String);461 procedure TGDIBackend.Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string); 433 462 begin 434 463 UpdateFont; … … 440 469 end; 441 470 442 procedure TGDIBackend.DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; DstX, DstY: Integer);471 procedure TGDIBackend.DrawTo(hDst: HDC; DstX, DstY: Integer); 443 472 begin 444 473 StretchDIBits( … … 447 476 end; 448 477 449 procedure TGDIBackend.DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; const DstRect, SrcRect: TRect);478 procedure TGDIBackend.DrawTo(hDst: HDC; const DstRect, SrcRect: TRect); 450 479 begin 451 480 StretchBlt( … … 486 515 end; 487 516 488 function TGDIBackend.GetHandle: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};517 function TGDIBackend.GetHandle: HDC; 489 518 begin 490 519 Result := FHDC; … … 512 541 end; 513 542 514 procedure TGDIBackend.Draw(const DstRect, SrcRect: TRect; hSrc: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF});543 procedure TGDIBackend.Draw(const DstRect, SrcRect: TRect; hSrc: HDC); 515 544 begin 516 545 if FOwner.Empty then Exit; … … 642 671 var 643 672 Bitmap : HBITMAP; 644 DeviceContext : {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};673 DeviceContext : HDC; 645 674 Buffer : Pointer; 646 675 OldObject : HGDIOBJ; … … 671 700 end; 672 701 end else 673 raise E xception.Create('Can''t create compatible DC''');702 raise EBackend.Create(RCStrCannotCreateCompatibleDC); 674 703 finally 675 704 DeleteDC(DeviceContext); … … 678 707 end; 679 708 680 procedure TGDIMemoryBackend.Draw(const DstRect, SrcRect: TRect; hSrc: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF});709 procedure TGDIMemoryBackend.Draw(const DstRect, SrcRect: TRect; hSrc: HDC); 681 710 begin 682 711 if FOwner.Empty then Exit; 683 712 684 713 if not FOwner.MeasuringMode then 685 raise E xception.Create('Not supported!');714 raise EBackend.Create('Not supported!'); 686 715 687 716 FOwner.Changed(DstRect); 688 717 end; 689 718 690 procedure TGDIMemoryBackend.DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF}; DstX, DstY: Integer);719 procedure TGDIMemoryBackend.DrawTo(hDst: HDC; DstX, DstY: Integer); 691 720 var 692 721 Bitmap : HBITMAP; 693 DeviceContext : {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};722 DeviceContext : HDC; 694 723 Buffer : Pointer; 695 724 OldObject : HGDIOBJ; 696 725 begin 697 if SetDIBitsToDevice(hDst, DstX, DstY, 698 FOwner.Width, FOwner.Height, 0, 0, 0, FOwner.Height, FBits, FBitmapInfo, 699 DIB_RGB_COLORS) = 0 then 726 if SetDIBitsToDevice(hDst, DstX, DstY, FOwner.Width, FOwner.Height, 0, 0, 0, 727 FOwner.Height, FBits, FBitmapInfo, DIB_RGB_COLORS) = 0 then 700 728 begin 701 729 // create compatible device context … … 720 748 end; 721 749 end else 722 raise E xception.Create('Can''t create compatible DC''');750 raise EBackend.Create(RCStrCannotCreateCompatibleDC); 723 751 finally 724 752 DeleteDC(DeviceContext); … … 727 755 end; 728 756 729 procedure TGDIMemoryBackend.DrawTo(hDst: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};757 procedure TGDIMemoryBackend.DrawTo(hDst: HDC; 730 758 const DstRect, SrcRect: TRect); 731 759 var 732 760 Bitmap : HBITMAP; 733 DeviceContext : {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};761 DeviceContext : HDC; 734 762 Buffer : Pointer; 735 763 OldObject : HGDIOBJ; … … 761 789 end; 762 790 end else 763 raise E xception.Create('Can''t create compatible DC''');791 raise EBackend.Create(RCStrCannotCreateCompatibleDC); 764 792 finally 765 793 DeleteDC(DeviceContext); … … 768 796 end; 769 797 770 function TGDIMemoryBackend.GetHandle: {$IFDEF BCB}Cardinal{$ELSE}HDC{$ENDIF};798 function TGDIMemoryBackend.GetHandle: HDC; 771 799 begin 772 800 Result := 0;
Note:
See TracChangeset
for help on using the changeset viewer.