* 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;
{$mode ObjFpc}
{$H+}
{$DEFINE SPKGUITOOLS}
{.$define EnhancedRecordSupport}
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)'}
uses Windows, Graphics, SysUtils, Math, Classes, Controls, ImgList,
SpkGraphTools, SpkMath;
uses
LCLType, Graphics, SysUtils, Math, Classes, Controls, ImgList, SpkGraphTools, SpkMath;
type TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom);
type
TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom);
TCornerKind = (cpRound, cpNormal);
TBackgroundKind = (bkSolid, bkVerticalGradient, bkHorizontalGradient,
bkConcave);
type TGUITools = class(TObject)
private
TGUITools = class(TObject)
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 RestoreClipRgn(DC : HDC; OrgRgnExists : boolean; var OrgRgn : HRGN);
public
@ -363,7 +366,7 @@ type TGUITools = class(TObject)
TextColor,
OutlineColor: TColor;
Align: TAlignment); overload; inline;
end;
end;
implementation
@ -373,7 +376,7 @@ class procedure TGUITools.CopyRoundCorner(ABuffer, ABitmap: TBitmap; SrcPoint,
DstPoint: T2DIntVector; Radius: integer; CornerPos: TCornerPos;
ClipRect: T2DIntRect; Convex: boolean);
var BufferRect, BitmapRect : T2DIntRect;
var BufferRect, BitmapRect, TempRect : T2DIntRect;
OrgSrcRect, UnClippedDstRect, OrgDstRect : T2DIntRect;
SrcRect : T2DIntRect;
Offset : T2DIntVector;
@ -396,19 +399,33 @@ if Radius<1 then
if (ABuffer.width=0) or (ABuffer.height=0) or
(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);
if not(BufferRect.IntersectsWith(T2DIntRect.create(SrcPoint.x,
SrcPoint.y,
SrcPoint.x+Radius-1,
SrcPoint.y+Radius-1),
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);
if not(BitmapRect.IntersectsWith(T2DIntRect.create(DstPoint.x,
DstPoint.y,
DstPoint.x+Radius-1,
DstPoint.y+Radius-1),
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
exit;
@ -418,12 +435,21 @@ Offset:=DstPoint - SrcPoint;
if not(OrgSrcRect.IntersectsWith(OrgDstRect - Offset, SrcRect)) then exit;
// Ustalamy pozycjê œrodka ³uku
{$ifdef EnhancedRecordSupport}
case CornerPos of
cpLeftTop: Center:=T2DIntVector.create(SrcPoint.x + radius - 1, SrcPoint.y + Radius - 1);
cpRightTop: Center:=T2DIntVector.create(SrcPoint.x, SrcPoint.y + Radius - 1);
cpLeftBottom: Center:=T2DIntVector.Create(SrcPoint.x + radius - 1, SrcPoint.y);
cpRightBottom: Center:=T2DIntVector.Create(SrcPoint.x, SrcPoint.y);
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?
if Convex then