* Initial compilation fix of spkguitools

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1696 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum 2011-06-18 01:46:25 +00:00
parent 4b819ad6f7
commit c3832331aa

View File

@ -1,369 +1,372 @@
unit SpkGuiTools; unit SpkGuiTools;
{$mode ObjFpc}
{$H+}
{$DEFINE SPKGUITOOLS} {$DEFINE SPKGUITOOLS}
{.$define EnhancedRecordSupport}
interface interface
{$MESSAGE HINT 'W tym module konsekwentnie ka¿dy rect opisuje dok³adny prostok¹t (a nie, jak w przypadku WINAPI - bez dolnej i prawej krawêdzi)'} {$MESSAGE HINT 'W tym module konsekwentnie ka¿dy rect opisuje dok³adny prostok¹t (a nie, jak w przypadku WINAPI - bez dolnej i prawej krawêdzi)'}
uses Windows, Graphics, SysUtils, Math, Classes, Controls, ImgList, uses
SpkGraphTools, SpkMath; LCLType, Graphics, SysUtils, Math, Classes, Controls, ImgList, SpkGraphTools, SpkMath;
type TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom); type
TCornerKind = (cpRound, cpNormal); TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom);
TBackgroundKind = (bkSolid, bkVerticalGradient, bkHorizontalGradient, TCornerKind = (cpRound, cpNormal);
bkConcave); TBackgroundKind = (bkSolid, bkVerticalGradient, bkHorizontalGradient,
bkConcave);
type TGUITools = class(TObject) TGUITools = class(TObject)
private protected
protected class procedure FillGradientRectangle(ACanvas: TCanvas; Rect: T2DIntRect; ColorFrom: TColor;
class procedure FillGradientRectangle(ACanvas: TCanvas; Rect: T2DIntRect; ColorFrom: TColor; ColorTo: TColor; GradientKind: TBackgroundKind); ColorTo: TColor; GradientKind: TBackgroundKind);
class procedure SaveClipRgn(DC : HDC; var OrgRgnExists : boolean; var OrgRgn : HRGN);
class procedure RestoreClipRgn(DC : HDC; OrgRgnExists : boolean; var OrgRgn : HRGN);
public
// *** Lines ***
class procedure SaveClipRgn(DC : HDC; var OrgRgnExists : boolean; var OrgRgn : HRGN); // Performance:
class procedure RestoreClipRgn(DC : HDC; OrgRgnExists : boolean; var OrgRgn : HRGN); // w/ClipRect: Bitmap is faster (2x)
public // wo/ClipRect: Canvas is faster (a little)
// *** Lines *** class procedure DrawHLine(ABitmap : TBitmap;
x1, x2 : integer;
y : integer;
Color : TColor); overload; inline;
class procedure DrawHLine(ABitmap : TBitmap;
x1, x2 : integer;
y : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawHLine(ACanvas : TCanvas;
x1, x2 : integer;
y : integer;
Color : TColor); overload; inline;
class procedure DrawHLine(ACanvas : TCanvas;
x1, x2 : integer;
y : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// Performance:
// w/ClipRect: Bitmap is faster (2x) // Performance:
// wo/ClipRect: Canvas is faster (a little) // w/ClipRect: Bitmap is faster (2x)
class procedure DrawHLine(ABitmap : TBitmap; // wo/ClipRect: Canvas is faster (a little)
x1, x2 : integer; class procedure DrawVLine(ABitmap : TBitmap;
y : integer; x : integer;
Color : TColor); overload; inline; y1, y2 : integer;
class procedure DrawHLine(ABitmap : TBitmap; Color : TColor); overload; inline;
x1, x2 : integer; class procedure DrawVLine(ABitmap : TBitmap;
y : integer; x : integer;
Color : TColor; y1, y2 : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawVLine(ACanvas : TCanvas;
x : integer;
y1, y2 : integer;
Color : TColor); overload; inline;
class procedure DrawVLine(ACanvas : TCanvas;
x : integer;
y1, y2 : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// *** Background and frame tools ***
// Performance:
// w/ClipRect: Bitmap is faster (extremely)
// wo/ClipRect: Bitmap is faster (extremely)
class procedure DrawAARoundCorner(ABitmap : TBitmap;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor); overload; inline;
class procedure DrawAARoundCorner(ABitmap : TBitmap;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor); overload; inline;
class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// Performance:
// w/ClipRect: Bitmap is faster (extremely)
// wo/ClipRect: Bitmap is faster (extremely)
class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect;
Radius : integer;
Color : TColor); overload; inline;
class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect;
Radius : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect;
Radius : integer;
Color : TColor); overload; inline;
class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect;
Radius : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure RenderBackground(ABuffer : TBitmap;
Rect : T2DIntRect;
Color1, Color2 : TColor;
BackgroundKind : TBackgroundKind); inline;
class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Convex : boolean = true); overload; inline;
class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
ClipRect : T2DIntRect;
Convex : boolean = true); overload; inline;
class procedure CopyCorner(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector;
DstPoint: T2DIntVector;
Radius: integer); overload; inline;
class procedure CopyCorner(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector;
DstPoint: T2DIntVector;
Radius: integer;
ClipRect : T2DIntRect); overload; inline;
class procedure CopyRectangle(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector;
DstPoint: T2DIntVector;
Width: integer;
Height : integer); overload; inline;
class procedure CopyRectangle(ABuffer : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Width : integer;
Height : integer;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawHLine(ACanvas : TCanvas; class procedure CopyMaskRectangle(ABuffer : TBitmap;
x1, x2 : integer; AMask : TBitmap;
y : integer; ABitmap : TBitmap;
Color : TColor); overload; inline;
class procedure DrawHLine(ACanvas : TCanvas;
x1, x2 : integer;
y : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// Performance:
// w/ClipRect: Bitmap is faster (2x)
// wo/ClipRect: Canvas is faster (a little)
class procedure DrawVLine(ABitmap : TBitmap;
x : integer;
y1, y2 : integer;
Color : TColor); overload; inline;
class procedure DrawVLine(ABitmap : TBitmap;
x : integer;
y1, y2 : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawVLine(ACanvas : TCanvas;
x : integer;
y1, y2 : integer;
Color : TColor); overload; inline;
class procedure DrawVLine(ACanvas : TCanvas;
x : integer;
y1, y2 : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// *** Background and frame tools ***
// Performance:
// w/ClipRect: Bitmap is faster (extremely)
// wo/ClipRect: Bitmap is faster (extremely)
class procedure DrawAARoundCorner(ABitmap : TBitmap;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor); overload; inline;
class procedure DrawAARoundCorner(ABitmap : TBitmap;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor); overload; inline;
class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
// Performance:
// w/ClipRect: Bitmap is faster (extremely)
// wo/ClipRect: Bitmap is faster (extremely)
class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect;
Radius : integer;
Color : TColor); overload; inline;
class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect;
Radius : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect;
Radius : integer;
Color : TColor); overload; inline;
class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect;
Radius : integer;
Color : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure RenderBackground(ABuffer : TBitmap;
Rect : T2DIntRect;
Color1, Color2 : TColor;
BackgroundKind : TBackgroundKind); inline;
class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
Convex : boolean = true); overload; inline;
class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Radius : integer;
CornerPos : TCornerPos;
ClipRect : T2DIntRect;
Convex : boolean = true); overload; inline;
class procedure CopyCorner(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector;
DstPoint: T2DIntVector;
Radius: integer); overload; inline;
class procedure CopyCorner(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector;
DstPoint: T2DIntVector;
Radius: integer;
ClipRect : T2DIntRect); overload; inline;
class procedure CopyRectangle(ABuffer : TBitmap;
ABitmap: TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint: T2DIntVector; DstPoint : T2DIntVector;
Width: integer; Width : integer;
Height : integer); overload; inline; Height : integer); overload; inline;
class procedure CopyRectangle(ABuffer : TBitmap; class procedure CopyMaskRectangle(ABuffer : TBitmap;
AMask : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width : integer; Width : integer;
Height : integer; Height : integer;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure CopyMaskRectangle(ABuffer : TBitmap;
AMask : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Width : integer;
Height : integer); overload; inline;
class procedure CopyMaskRectangle(ABuffer : TBitmap;
AMask : TBitmap;
ABitmap : TBitmap;
SrcPoint : T2DIntVector;
DstPoint : T2DIntVector;
Width : integer;
Height : integer;
ClipRect : T2DIntRect); overload; inline;
// Performance (RenderBackground + CopyRoundRect vs DrawRoundRect): // Performance (RenderBackground + CopyRoundRect vs DrawRoundRect):
// w/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger // w/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger
// wo/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger // wo/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger
class procedure CopyRoundRect(ABuffer : TBitmap; class procedure CopyRoundRect(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width, Height : integer; Width, Height : integer;
Radius : integer; Radius : integer;
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload; inline;
class procedure CopyRoundRect(ABuffer : TBitmap; class procedure CopyRoundRect(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width, Height : integer; Width, Height : integer;
Radius : integer; Radius : integer;
ClipRect : T2DIntRect; ClipRect : T2DIntRect;
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload; inline;
class procedure DrawRoundRect(ACanvas : TCanvas; class procedure DrawRoundRect(ACanvas : TCanvas;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind; GradientKind : TBackgroundKind;
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload; inline;
class procedure DrawRoundRect(ACanvas : TCanvas; class procedure DrawRoundRect(ACanvas : TCanvas;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind; GradientKind : TBackgroundKind;
ClipRect : T2DIntRect; ClipRect : T2DIntRect;
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload; inline;
class procedure DrawRegion(ACanvas : TCanvas; class procedure DrawRegion(ACanvas : TCanvas;
Region : HRGN; Region : HRGN;
Rect : T2DIntRect; Rect : T2DIntRect;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind); overload; inline; GradientKind : TBackgroundKind); overload; inline;
class procedure DrawRegion(ACanvas : TCanvas; class procedure DrawRegion(ACanvas : TCanvas;
Region : HRGN; Region : HRGN;
Rect : T2DIntRect; Rect : T2DIntRect;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind; GradientKind : TBackgroundKind;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
// Imagelist tools // Imagelist tools
class procedure DrawImage(ABitmap : TBitmap; class procedure DrawImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector); overload; inline; Point : T2DIntVector); overload; inline;
class procedure DrawImage(ABitmap : TBitmap; class procedure DrawImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawImage(ACanvas : TCanvas; class procedure DrawImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector); overload; inline; Point : T2DIntVector); overload; inline;
class procedure DrawImage(ACanvas : TCanvas; class procedure DrawImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawDisabledImage(ABitmap : TBitmap; class procedure DrawDisabledImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector); overload; inline; Point : T2DIntVector); overload; inline;
class procedure DrawDisabledImage(ABitmap : TBitmap; class procedure DrawDisabledImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawDisabledImage(ACanvas : TCanvas; class procedure DrawDisabledImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector); overload; inline; Point : T2DIntVector); overload; inline;
class procedure DrawDisabledImage(ACanvas : TCanvas; class procedure DrawDisabledImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
// Text tools // Text tools
class procedure DrawText(ABitmap : TBitmap; class procedure DrawText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor); overload; inline; TextColor : TColor); overload; inline;
class procedure DrawText(ABitmap : TBitmap; class procedure DrawText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawMarkedText(ACanvas : TCanvas; class procedure DrawMarkedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
AMarkPhrase : string; AMarkPhrase : string;
TextColor : TColor; TextColor : TColor;
CaseSensitive : boolean = false); overload; inline; CaseSensitive : boolean = false); overload; inline;
class procedure DrawMarkedText(ACanvas : TCanvas; class procedure DrawMarkedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
AMarkPhrase : string; AMarkPhrase : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect; ClipRect : T2DIntRect;
CaseSensitive : boolean = false); overload; inline; CaseSensitive : boolean = false); overload; inline;
class procedure DrawText(ACanvas : TCanvas; class procedure DrawText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor); overload; inline; TextColor : TColor); overload; inline;
class procedure DrawText(ACanvas : TCanvas; class procedure DrawText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawFitWText(ABitmap : TBitmap; class procedure DrawFitWText(ABitmap : TBitmap;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
AText : string;
TextColor : TColor;
Align : TAlignment); overload; inline;
class procedure DrawFitWText(ACanvas : TCanvas;
x1, x2 : integer;
y : integer;
AText : string;
TextColor : TColor;
Align : TAlignment); overload; inline;
class procedure DrawOutlinedText(ABitmap : TBitmap;
x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
Align : TAlignment); overload; inline; OutlineColor : TColor); overload; inline;
class procedure DrawFitWText(ACanvas : TCanvas; class procedure DrawOutlinedText(ABitmap : TBitmap;
x1, x2 : integer; x, y : integer;
y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
Align : TAlignment); overload; inline; OutlineColor : TColor;
ClipRect : T2DIntRect); overload; inline;
class procedure DrawOutlinedText(ABitmap : TBitmap; class procedure DrawOutlinedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor); overload; inline; OutlineColor : TColor); overload; inline;
class procedure DrawOutlinedText(ABitmap : TBitmap; class procedure DrawOutlinedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor; OutlineColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload; inline;
class procedure DrawOutlinedText(ACanvas : TCanvas; class procedure DrawFitWOutlinedText(ABitmap: TBitmap;
x, y : integer; x1, x2 : integer;
AText : string; y: integer;
TextColor : TColor; AText: string;
OutlineColor : TColor); overload; inline; TextColor,
class procedure DrawOutlinedText(ACanvas : TCanvas; OutlineColor: TColor;
x, y : integer; Align: TAlignment); overload; inline;
AText : string; class procedure DrawFitWOutlinedText(ACanvas: TCanvas;
TextColor : TColor; x1, x2 : integer;
OutlineColor : TColor; y: integer;
ClipRect : T2DIntRect); overload; inline; AText: string;
class procedure DrawFitWOutlinedText(ABitmap: TBitmap; TextColor,
x1, x2 : integer; OutlineColor: TColor;
y: integer; Align: TAlignment); overload; inline;
AText: string; end;
TextColor,
OutlineColor: TColor;
Align: TAlignment); overload; inline;
class procedure DrawFitWOutlinedText(ACanvas: TCanvas;
x1, x2 : integer;
y: integer;
AText: string;
TextColor,
OutlineColor: TColor;
Align: TAlignment); overload; inline;
end;
implementation implementation
@ -373,7 +376,7 @@ class procedure TGUITools.CopyRoundCorner(ABuffer, ABitmap: TBitmap; SrcPoint,
DstPoint: T2DIntVector; Radius: integer; CornerPos: TCornerPos; DstPoint: T2DIntVector; Radius: integer; CornerPos: TCornerPos;
ClipRect: T2DIntRect; Convex: boolean); ClipRect: T2DIntRect; Convex: boolean);
var BufferRect, BitmapRect : T2DIntRect; var BufferRect, BitmapRect, TempRect : T2DIntRect;
OrgSrcRect, UnClippedDstRect, OrgDstRect : T2DIntRect; OrgSrcRect, UnClippedDstRect, OrgDstRect : T2DIntRect;
SrcRect : T2DIntRect; SrcRect : T2DIntRect;
Offset : T2DIntVector; Offset : T2DIntVector;
@ -396,19 +399,33 @@ if Radius<1 then
if (ABuffer.width=0) or (ABuffer.height=0) or if (ABuffer.width=0) or (ABuffer.height=0) or
(ABitmap.width=0) or (ABitmap.height=0) then exit; (ABitmap.width=0) or (ABitmap.height=0) then exit;
//todo minimize use of temps here
{$ifdef EnhancedRecordSupport}
BufferRect:=T2DIntRect.create(0, 0, ABuffer.width-1, ABuffer.height-1); BufferRect:=T2DIntRect.create(0, 0, ABuffer.width-1, ABuffer.height-1);
if not(BufferRect.IntersectsWith(T2DIntRect.create(SrcPoint.x, if not(BufferRect.IntersectsWith(T2DIntRect.create(SrcPoint.x,
SrcPoint.y, SrcPoint.y,
SrcPoint.x+Radius-1, SrcPoint.x+Radius-1,
SrcPoint.y+Radius-1), SrcPoint.y+Radius-1),
OrgSrcRect)) then exit; OrgSrcRect)) then exit;
{$else}
BufferRect.create(0, 0, ABuffer.width-1, ABuffer.height-1);
TempRect.Create(SrcPoint.x, SrcPoint.y, SrcPoint.x+Radius-1, SrcPoint.y+Radius-1);
if not(BufferRect.IntersectsWith(TempRect, OrgSrcRect)) then exit;
{$endif}
{$ifdef EnhancedRecordSupport}
BitmapRect:=T2DIntRect.create(0, 0, ABitmap.width-1, ABitmap.height-1); BitmapRect:=T2DIntRect.create(0, 0, ABitmap.width-1, ABitmap.height-1);
if not(BitmapRect.IntersectsWith(T2DIntRect.create(DstPoint.x, if not(BitmapRect.IntersectsWith(T2DIntRect.create(DstPoint.x,
DstPoint.y, DstPoint.y,
DstPoint.x+Radius-1, DstPoint.x+Radius-1,
DstPoint.y+Radius-1), DstPoint.y+Radius-1),
UnClippedDstRect)) then exit; UnClippedDstRect)) then exit;
{$else}
BitmapRect.create(0, 0, ABitmap.width-1, ABitmap.height-1);
//todo: calling create twice
TempRect.Create(DstPoint.x, DstPoint.y, DstPoint.x+Radius-1, DstPoint.y+Radius-1);
if not(BitmapRect.IntersectsWith(TempRect, UnClippedDstRect)) then exit;
{$endif}
if not(ClipRect.IntersectsWith(UnClippedDstRect, OrgDstRect)) then if not(ClipRect.IntersectsWith(UnClippedDstRect, OrgDstRect)) then
exit; exit;
@ -418,12 +435,21 @@ Offset:=DstPoint - SrcPoint;
if not(OrgSrcRect.IntersectsWith(OrgDstRect - Offset, SrcRect)) then exit; if not(OrgSrcRect.IntersectsWith(OrgDstRect - Offset, SrcRect)) then exit;
// Ustalamy pozycjê œrodka ³uku // Ustalamy pozycjê œrodka ³uku
{$ifdef EnhancedRecordSupport}
case CornerPos of case CornerPos of
cpLeftTop: Center:=T2DIntVector.create(SrcPoint.x + radius - 1, SrcPoint.y + Radius - 1); cpLeftTop: Center:=T2DIntVector.create(SrcPoint.x + radius - 1, SrcPoint.y + Radius - 1);
cpRightTop: Center:=T2DIntVector.create(SrcPoint.x, SrcPoint.y + Radius - 1); cpRightTop: Center:=T2DIntVector.create(SrcPoint.x, SrcPoint.y + Radius - 1);
cpLeftBottom: Center:=T2DIntVector.Create(SrcPoint.x + radius - 1, SrcPoint.y); cpLeftBottom: Center:=T2DIntVector.Create(SrcPoint.x + radius - 1, SrcPoint.y);
cpRightBottom: Center:=T2DIntVector.Create(SrcPoint.x, SrcPoint.y); cpRightBottom: Center:=T2DIntVector.Create(SrcPoint.x, SrcPoint.y);
end; end;
{$else}
case CornerPos of
cpLeftTop: Center.create(SrcPoint.x + radius - 1, SrcPoint.y + Radius - 1);
cpRightTop: Center.create(SrcPoint.x, SrcPoint.y + Radius - 1);
cpLeftBottom: Center.Create(SrcPoint.x + radius - 1, SrcPoint.y);
cpRightBottom: Center.Create(SrcPoint.x, SrcPoint.y);
end;
{$endif}
// Czy jest cokolwiek do przetworzenia? // Czy jest cokolwiek do przetworzenia?
if Convex then if Convex then