* 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,24 +1,27 @@
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
TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom);
TCornerKind = (cpRound, cpNormal); TCornerKind = (cpRound, cpNormal);
TBackgroundKind = (bkSolid, bkVerticalGradient, bkHorizontalGradient, TBackgroundKind = (bkSolid, bkVerticalGradient, bkHorizontalGradient,
bkConcave); bkConcave);
type TGUITools = class(TObject) TGUITools = class(TObject)
private
protected protected
class procedure FillGradientRectangle(ACanvas: TCanvas; Rect: T2DIntRect; ColorFrom: TColor; ColorTo: TColor; GradientKind: TBackgroundKind); class procedure FillGradientRectangle(ACanvas: TCanvas; Rect: T2DIntRect; ColorFrom: TColor;
ColorTo: TColor; GradientKind: TBackgroundKind);
class procedure SaveClipRgn(DC : HDC; var OrgRgnExists : boolean; var OrgRgn : HRGN); class procedure SaveClipRgn(DC : HDC; var OrgRgnExists : boolean; var OrgRgn : HRGN);
class procedure RestoreClipRgn(DC : HDC; OrgRgnExists : boolean; var OrgRgn : HRGN); class procedure RestoreClipRgn(DC : HDC; OrgRgnExists : boolean; var OrgRgn : HRGN);
public public
@ -363,7 +366,7 @@ type TGUITools = class(TObject)
TextColor, TextColor,
OutlineColor: TColor; OutlineColor: TColor;
Align: TAlignment); overload; inline; Align: TAlignment); overload; inline;
end; 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