fpcanvas.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. Basic canvas definitions.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}{$h+}
  12. unit FPCanvas;
  13. interface
  14. uses Math, sysutils, classes, FPImage, Types;
  15. const
  16. PatternBitCount = sizeof(longword) * 8;
  17. type
  18. PPoint = ^TPoint;
  19. TFPCanvasException = class (Exception);
  20. TFPPenException = class (TFPCanvasException);
  21. TFPBrushException = class (TFPCanvasException);
  22. TFPFontException = class (TFPCanvasException);
  23. TFPCustomCanvas = class;
  24. { TFPCanvasHelper }
  25. TFPCanvasHelper = class(TPersistent)
  26. private
  27. FDelayAllocate: boolean;
  28. FFPColor : TFPColor;
  29. FAllocated,
  30. FFixedCanvas : boolean;
  31. FCanvas : TFPCustomCanvas;
  32. FFlags : word;
  33. FOnChange: TNotifyEvent;
  34. FOnChanging: TNotifyEvent;
  35. procedure NotifyCanvas;
  36. protected
  37. // flags 0-15 are reserved for FPCustomCanvas
  38. function GetAllocated: boolean; virtual;
  39. procedure SetFlags (index:integer; AValue:boolean); virtual;
  40. function GetFlags (index:integer) : boolean; virtual;
  41. procedure CheckAllocated (ValueNeeded:boolean);
  42. procedure SetFixedCanvas (AValue : boolean);
  43. procedure DoAllocateResources; virtual;
  44. procedure DoDeAllocateResources; virtual;
  45. procedure DoCopyProps (From:TFPCanvasHelper); virtual;
  46. procedure SetFPColor (const AValue:TFPColor); virtual;
  47. procedure Changing; dynamic;
  48. procedure Changed; dynamic;
  49. Procedure Lock;
  50. Procedure UnLock;
  51. public
  52. constructor Create; virtual;
  53. destructor Destroy; override;
  54. // prepare helper for use
  55. procedure AllocateResources (ACanvas : TFPCustomCanvas;
  56. CanDelay: boolean = true);
  57. // free all resource used by this helper
  58. procedure DeallocateResources;
  59. property Allocated : boolean read GetAllocated;
  60. // properties cannot be changed when allocated
  61. property FixedCanvas : boolean read FFixedCanvas;
  62. // Canvas for which the helper is allocated
  63. property Canvas : TFPCustomCanvas read FCanvas;
  64. // color of the helper
  65. property FPColor : TFPColor read FFPColor Write SetFPColor;
  66. property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
  67. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  68. property DelayAllocate: boolean read FDelayAllocate write FDelayAllocate;
  69. end;
  70. TFPCustomFont = class (TFPCanvasHelper)
  71. private
  72. FName : string;
  73. FOrientation,
  74. FSize : integer;
  75. protected
  76. procedure DoCopyProps (From:TFPCanvasHelper); override;
  77. procedure SetName (AValue:string); virtual;
  78. procedure SetSize (AValue:integer); virtual;
  79. procedure SetOrientation (AValue:integer); virtual;
  80. function GetOrientation : Integer;
  81. public
  82. function CopyFont : TFPCustomFont;
  83. // Creates a copy of the font with all properties the same, but not allocated
  84. procedure GetTextSize (text:ansistring; var w,h:integer);
  85. function GetTextHeight (text:ansistring) : integer;
  86. function GetTextWidth (text:ansistring) : integer;
  87. property Name : string read FName write SetName;
  88. property Size : integer read FSize write SetSize;
  89. property Bold : boolean index 5 read GetFlags write SetFlags;
  90. property Italic : boolean index 6 read GetFlags write SetFlags;
  91. property Underline : boolean index 7 read GetFlags write SetFlags;
  92. property StrikeThrough : boolean index 8 read GetFlags write SetFlags;
  93. property Orientation: Integer read GetOrientation write SetOrientation default 0;
  94. end;
  95. TFPCustomFontClass = class of TFPCustomFont;
  96. TFPPenStyle = (psSolid, psDash, psDot, psDashDot, psDashDotDot, psinsideFrame, psPattern,psClear);
  97. TFPPenStyleSet = set of TFPPenStyle;
  98. TFPPenMode = (pmBlack, pmWhite, pmNop, pmNot, pmCopy, pmNotCopy,
  99. pmMergePenNot, pmMaskPenNot, pmMergeNotPen, pmMaskNotPen, pmMerge,
  100. pmNotMerge, pmMask, pmNotMask, pmXor, pmNotXor);
  101. TPenPattern = Longword;
  102. TFPPenEndCap = (
  103. pecRound,
  104. pecSquare,
  105. pecFlat
  106. );
  107. TFPPenJoinStyle = (
  108. pjsRound,
  109. pjsBevel,
  110. pjsMiter
  111. );
  112. { TFPCustomPen }
  113. TFPCustomPen = class (TFPCanvasHelper)
  114. private
  115. FStyle : TFPPenStyle;
  116. FWidth : Integer;
  117. FMode : TFPPenMode;
  118. FPattern : longword;
  119. FEndCap: TFPPenEndCap;
  120. FJoinStyle: TFPPenJoinStyle;
  121. protected
  122. procedure DoCopyProps (From:TFPCanvasHelper); override;
  123. procedure SetMode (AValue : TFPPenMode); virtual;
  124. procedure SetWidth (AValue : Integer); virtual;
  125. procedure SetStyle (AValue : TFPPenStyle); virtual;
  126. procedure SetPattern (AValue : longword); virtual;
  127. procedure SetEndCap(AValue: TFPPenEndCap); virtual;
  128. procedure SetJoinStyle(AValue: TFPPenJoinStyle); virtual;
  129. public
  130. function CopyPen : TFPCustomPen;
  131. // Creates a copy of the pen with all properties the same, but not allocated
  132. property Style : TFPPenStyle read FStyle write SetStyle;
  133. property Width : Integer read FWidth write SetWidth;
  134. property Mode : TFPPenMode read FMode write SetMode;
  135. property Pattern : longword read FPattern write SetPattern;
  136. property EndCap : TFPPenEndCap read FEndCap write SetEndCap;
  137. property JoinStyle : TFPPenJoinStyle read FJoinStyle write SetJoinStyle;
  138. end;
  139. TFPCustomPenClass = class of TFPCustomPen;
  140. TFPBrushStyle = (bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal,
  141. bsBDiagonal, bsCross, bsDiagCross, bsImage, bsPattern);
  142. TBrushPattern = array[0..PatternBitCount-1] of TPenPattern;
  143. PBrushPattern = ^TBrushPattern;
  144. TFPCustomBrush = class (TFPCanvasHelper)
  145. private
  146. FStyle : TFPBrushStyle;
  147. FImage : TFPCustomImage;
  148. FPattern : TBrushPattern;
  149. protected
  150. procedure SetStyle (AValue : TFPBrushStyle); virtual;
  151. procedure SetImage (AValue : TFPCustomImage); virtual;
  152. procedure DoCopyProps (From:TFPCanvasHelper); override;
  153. public
  154. function CopyBrush : TFPCustomBrush;
  155. property Style : TFPBrushStyle read FStyle write SetStyle;
  156. property Image : TFPCustomImage read FImage write SetImage;
  157. property Pattern : TBrushPattern read FPattern write FPattern;
  158. end;
  159. TFPCustomBrushClass = class of TFPCustomBrush;
  160. { TFPCustomInterpolation }
  161. TFPCustomInterpolation = class
  162. private
  163. fcanvas: TFPCustomCanvas;
  164. fimage: TFPCustomImage;
  165. protected
  166. procedure Initialize (aimage:TFPCustomImage; acanvas:TFPCustomCanvas); virtual;
  167. procedure Execute (x,y,w,h:integer); virtual; abstract;
  168. public
  169. property Canvas : TFPCustomCanvas read fcanvas;
  170. property Image : TFPCustomImage read fimage;
  171. end;
  172. { TFPBoxInterpolation }
  173. TFPBoxInterpolation = class(TFPCustomInterpolation)
  174. public
  175. procedure Execute (x,y,w,h:integer); override;
  176. end;
  177. { TFPBaseInterpolation }
  178. TFPBaseInterpolation = class (TFPCustomInterpolation)
  179. private
  180. procedure CreatePixelWeights (OldSize, NewSize: integer;
  181. out Entries: Pointer; out EntrySize: integer; out Support: integer);
  182. protected
  183. procedure Execute (x,y,w,h : integer); override;
  184. function Filter (x : double): double; virtual;
  185. function MaxSupport : double; virtual;
  186. end;
  187. { TMitchelInterpolation }
  188. TMitchelInterpolation = class (TFPBaseInterpolation)
  189. protected
  190. function Filter (x : double) : double; override;
  191. function MaxSupport : double; override;
  192. end;
  193. TFPCustomRegion = class
  194. public
  195. function GetBoundingRect: TRect; virtual; abstract;
  196. function IsPointInRegion(AX, AY: Integer): Boolean; virtual; abstract;
  197. end;
  198. { TFPRectRegion }
  199. TFPRectRegion = class(TFPCustomRegion)
  200. public
  201. Rect: TRect;
  202. function GetBoundingRect: TRect; override;
  203. function IsPointInRegion(AX, AY: Integer): Boolean; override;
  204. end;
  205. TFPDrawingMode = (dmOpaque, dmAlphaBlend, dmCustom);
  206. TFPCanvasCombineColors = function(const color1, color2: TFPColor): TFPColor of object;
  207. { TFPCustomCanvas }
  208. TFPCustomCanvas = class(TPersistent)
  209. private
  210. FClipping,
  211. FManageResources: boolean;
  212. FRemovingHelpers : boolean;
  213. FHelpers : TList;
  214. FLocks : integer;
  215. FInterpolation : TFPCustomInterpolation;
  216. FDrawingMode : TFPDrawingMode;
  217. FOnCombineColors : TFPCanvasCombineColors;
  218. function AllowFont (AFont : TFPCustomFont) : boolean;
  219. function AllowBrush (ABrush : TFPCustomBrush) : boolean;
  220. function AllowPen (APen : TFPCustomPen) : boolean;
  221. function CreateDefaultFont : TFPCustomFont;
  222. function CreateDefaultPen : TFPCustomPen;
  223. function CreateDefaultBrush : TFPCustomBrush;
  224. procedure RemoveHelpers;
  225. function GetFont : TFPCustomFont;
  226. function GetBrush : TFPCustomBrush;
  227. function GetPen : TFPCustomPen;
  228. protected
  229. FDefaultFont, FFont : TFPCustomFont;
  230. FDefaultBrush, FBrush : TFPCustomBrush;
  231. FDefaultPen, FPen : TFPCustomPen;
  232. FPenPos : TPoint;
  233. FClipRegion : TFPCustomRegion;
  234. function DoCreateDefaultFont : TFPCustomFont; virtual; abstract;
  235. function DoCreateDefaultPen : TFPCustomPen; virtual; abstract;
  236. function DoCreateDefaultBrush : TFPCustomBrush; virtual; abstract;
  237. procedure SetFont (AValue:TFPCustomFont); virtual;
  238. procedure SetBrush (AValue:TFPCustomBrush); virtual;
  239. procedure SetPen (AValue:TFPCustomPen); virtual;
  240. function DoAllowFont (AFont : TFPCustomFont) : boolean; virtual;
  241. function DoAllowPen (APen : TFPCustomPen) : boolean; virtual;
  242. function DoAllowBrush (ABrush : TFPCustomBrush) : boolean; virtual;
  243. procedure SetColor (x,y:integer; const Value:TFPColor); Virtual; abstract;
  244. function GetColor (x,y:integer) : TFPColor; Virtual; abstract;
  245. procedure SetHeight (AValue : integer); virtual; abstract;
  246. function GetHeight : integer; virtual; abstract;
  247. procedure SetWidth (AValue : integer); virtual; abstract;
  248. function GetWidth : integer; virtual; abstract;
  249. function GetClipRect: TRect; virtual;
  250. procedure SetClipRect(const AValue: TRect); virtual;
  251. function GetClipping: boolean; virtual;
  252. procedure SetClipping(const AValue: boolean); virtual;
  253. procedure SetPenPos(const AValue: TPoint); virtual;
  254. procedure SetClipRegion(const AValue: TFPCustomRegion);
  255. procedure DoLockCanvas; virtual;
  256. procedure DoUnlockCanvas; virtual;
  257. procedure DoTextOut (x,y:integer;text:ansistring); virtual; abstract;
  258. procedure DoGetTextSize (text:ansistring; var w,h:integer); virtual; abstract;
  259. function DoGetTextHeight (text:ansistring) : integer; virtual; abstract;
  260. function DoGetTextWidth (text:ansistring) : integer; virtual; abstract;
  261. procedure DoTextOut (x,y:integer;text:unicodestring); virtual;
  262. procedure DoGetTextSize (text:unicodestring; var w,h:integer); virtual;
  263. function DoGetTextHeight (text:unicodestring) : integer; virtual;
  264. function DoGetTextWidth (text:unicodestring) : integer; virtual;
  265. procedure DoRectangle (Const Bounds:TRect); virtual; abstract;
  266. procedure DoRectangleFill (Const Bounds:TRect); virtual; abstract;
  267. procedure DoRectangleAndFill (Const Bounds:TRect); virtual;
  268. procedure DoEllipseFill (Const Bounds:TRect); virtual; abstract;
  269. procedure DoEllipse (Const Bounds:TRect); virtual; abstract;
  270. procedure DoEllipseAndFill (Const Bounds:TRect); virtual;
  271. procedure DoPolygonFill (const points:array of TPoint); virtual; abstract;
  272. procedure DoPolygon (const points:array of TPoint); virtual; abstract;
  273. procedure DoPolygonAndFill (const points:array of TPoint); virtual;
  274. procedure DoPolyline (const points:array of TPoint); virtual; abstract;
  275. procedure DoFloodFill (x,y:integer); virtual; abstract;
  276. procedure DoMoveTo (x,y:integer); virtual;
  277. procedure DoLineTo (x,y:integer); virtual;
  278. procedure DoLine (x1,y1,x2,y2:integer); virtual; abstract;
  279. procedure DoCopyRect (x,y:integer; canvas:TFPCustomCanvas; Const SourceRect:TRect); virtual; abstract;
  280. procedure DoDraw (x,y:integer; Const image:TFPCustomImage); virtual; abstract;
  281. procedure DoRadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer); virtual;
  282. procedure DoPolyBezier(Points: PPoint; NumPts: Integer;
  283. Filled: boolean = False;
  284. Continuous: boolean = False); virtual;
  285. procedure CheckHelper (AHelper:TFPCanvasHelper); virtual;
  286. procedure AddHelper (AHelper:TFPCanvasHelper);
  287. public
  288. constructor create;
  289. destructor destroy; override;
  290. procedure LockCanvas;
  291. procedure UnlockCanvas;
  292. function Locked: boolean;
  293. function CreateFont : TFPCustomFont;
  294. function CreatePen : TFPCustomPen;
  295. function CreateBrush : TFPCustomBrush;
  296. // using font
  297. procedure TextOut (x,y:integer;text:Ansistring); virtual;
  298. procedure GetTextSize (text:Ansistring; var w,h:integer);
  299. function GetTextHeight (text:Ansistring) : integer;
  300. function GetTextWidth (text:Ansistring) : integer;
  301. function TextExtent(const Text: Ansistring): TSize; virtual;
  302. function TextHeight(const Text: Ansistring): Integer; virtual;
  303. function TextWidth(const Text: Ansistring): Integer; virtual;
  304. procedure TextOut (x,y:integer;text:unicodestring); virtual;
  305. procedure GetTextSize (text:unicodestring; var w,h:integer);
  306. function GetTextHeight (text:unicodestring) : integer;
  307. function GetTextWidth (text:unicodestring) : integer;
  308. function TextExtent(const Text: unicodestring): TSize; virtual;
  309. function TextHeight(const Text: unicodestring): Integer; virtual;
  310. function TextWidth(const Text: unicodestring): Integer; virtual;
  311. // using pen and brush
  312. procedure Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer); virtual;
  313. procedure Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); virtual;
  314. procedure Ellipse (Const Bounds:TRect); virtual;
  315. procedure Ellipse (left,top,right,bottom:integer); virtual;
  316. procedure EllipseC (x,y:integer; rx,ry:longword);
  317. procedure Polygon (Const points:array of TPoint); virtual;
  318. procedure Polyline (Const points:array of TPoint); virtual;
  319. procedure RadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer); virtual;
  320. procedure PolyBezier(Points: PPoint; NumPts: Integer;
  321. Filled: boolean = False;
  322. Continuous: boolean = False); virtual;
  323. procedure PolyBezier(const Points: array of TPoint;
  324. Filled: boolean = False;
  325. Continuous: boolean = False); virtual;
  326. procedure Rectangle (Const Bounds : TRect); virtual;
  327. procedure Rectangle (left,top,right,bottom:integer); virtual;
  328. procedure FillRect(const ARect: TRect); virtual;
  329. procedure FillRect(X1,Y1,X2,Y2: Integer); virtual;
  330. // using brush
  331. procedure FloodFill (x,y:integer); virtual;
  332. procedure Clear;
  333. // using pen
  334. procedure MoveTo (x,y:integer);
  335. procedure MoveTo (p:TPoint);
  336. procedure LineTo (x,y:integer);
  337. procedure LineTo (p:TPoint);
  338. procedure Line (x1,y1,x2,y2:integer);
  339. procedure Line (const p1,p2:TPoint);
  340. procedure Line (const points:TRect);
  341. // other procedures
  342. procedure CopyRect (x,y:integer; canvas:TFPCustomCanvas; SourceRect:TRect); virtual;
  343. procedure Draw (x,y:integer; image:TFPCustomImage); virtual;
  344. procedure StretchDraw (x,y,w,h:integer; source:TFPCustomImage); virtual;
  345. procedure Erase;virtual;
  346. procedure DrawPixel(const x, y: integer; const newcolor: TFPColor);
  347. // properties
  348. property LockCount: Integer read FLocks;
  349. property Font : TFPCustomFont read GetFont write SetFont;
  350. property Pen : TFPCustomPen read GetPen write SetPen;
  351. property Brush : TFPCustomBrush read GetBrush write SetBrush;
  352. property Interpolation : TFPCustomInterpolation read FInterpolation write FInterpolation;
  353. property Colors [x,y:integer] : TFPColor read GetColor write SetColor;
  354. property ClipRect : TRect read GetClipRect write SetClipRect;
  355. property ClipRegion : TFPCustomRegion read FClipRegion write SetClipRegion;
  356. property Clipping : boolean read GetClipping write SetClipping;
  357. property PenPos : TPoint read FPenPos write SetPenPos;
  358. property Height : integer read GetHeight write SetHeight;
  359. property Width : integer read GetWidth write SetWidth;
  360. property ManageResources: boolean read FManageResources write FManageResources;
  361. property DrawingMode : TFPDrawingMode read FDrawingMode write FDrawingMode;
  362. property OnCombineColors : TFPCanvasCombineColors read FOnCombineColors write FOnCombineColors;
  363. end;
  364. TFPCustomDrawFont = class (TFPCustomFont)
  365. private
  366. procedure DrawText (x,y:integer; text:Ansistring);
  367. procedure GetTextSize (text:ansistring; var w,h:integer);
  368. function GetTextHeight (text:ansistring) : integer;
  369. function GetTextWidth (text:ansistring) : integer;
  370. procedure DrawText (x,y:integer; text:unicodestring);
  371. procedure GetTextSize (text: unicodestring; var w,h:integer);
  372. function GetTextHeight (text: unicodestring) : integer;
  373. function GetTextWidth (text: unicodestring) : integer;
  374. protected
  375. procedure DoDrawText (x,y:integer; text:ansistring); virtual; abstract;
  376. procedure DoGetTextSize (text:ansistring; var w,h:integer); virtual; abstract;
  377. function DoGetTextHeight (text:ansistring) : integer; virtual; abstract;
  378. function DoGetTextWidth (text:ansistring) : integer; virtual; abstract;
  379. procedure DoDrawText (x,y:integer; text:unicodestring); virtual;
  380. procedure DoGetTextSize (text: unicodestring; var w,h:integer); virtual;
  381. function DoGetTextHeight (text: unicodestring) : integer; virtual;
  382. function DoGetTextWidth (text: unicodestring) : integer; virtual;
  383. end;
  384. TFPEmptyFont = class (TFPCustomFont)
  385. end;
  386. TFPCustomDrawPen = class (TFPCustomPen)
  387. private
  388. procedure DrawLine (x1,y1,x2,y2:integer);
  389. procedure Polyline (const points:array of TPoint; close:boolean);
  390. procedure Ellipse (left,top, right,bottom:integer);
  391. procedure Rectangle (left,top, right,bottom:integer);
  392. protected
  393. procedure DoDrawLine (x1,y1,x2,y2:integer); virtual; abstract;
  394. procedure DoPolyline (const points:array of TPoint; close:boolean); virtual; abstract;
  395. procedure DoEllipse (left,top, right,bottom:integer); virtual; abstract;
  396. procedure DoRectangle (left,top, right,bottom:integer); virtual; abstract;
  397. end;
  398. TFPEmptyPen = class (TFPCustomPen)
  399. end;
  400. TFPCustomDrawBrush = class (TFPCustomBrush)
  401. private
  402. procedure Rectangle (left,top, right,bottom:integer);
  403. procedure FloodFill (x,y:integer);
  404. procedure Ellipse (left,top, right,bottom:integer);
  405. procedure Polygon (const points:array of TPoint);
  406. public
  407. procedure DoRectangle (left,top, right,bottom:integer); virtual; abstract;
  408. procedure DoEllipse (left,top, right,bottom:integer); virtual; abstract;
  409. procedure DoFloodFill (x,y:integer); virtual; abstract;
  410. procedure DoPolygon (const points:array of TPoint); virtual; abstract;
  411. end;
  412. TFPEmptyBrush = class (TFPCustomBrush)
  413. end;
  414. procedure DecRect (var rect : TRect; delta:integer);
  415. procedure IncRect (var rect : TRect; delta:integer);
  416. procedure DecRect (var rect : TRect);
  417. procedure IncRect (var rect : TRect);
  418. implementation
  419. uses clipping;
  420. const
  421. EFont = 'Font';
  422. EPen = 'Pen';
  423. EBrush = 'Brush';
  424. ErrAllocation = '%s %s be allocated.';
  425. ErrAlloc : array [boolean] of string = ('may not','must');
  426. ErrCouldNotCreate = 'Could not create a %s.';
  427. ErrNoLock = 'Canvas not locked.';
  428. procedure DecRect (var rect : TRect; delta:integer);
  429. begin
  430. with rect do
  431. begin
  432. left := left + delta;
  433. right := right - delta;
  434. top := top + delta;
  435. bottom := bottom - delta;
  436. end;
  437. end;
  438. procedure DecRect (var rect : trect);
  439. begin
  440. DecRect (rect, 1);
  441. end;
  442. procedure IncRect (var rect : trect);
  443. begin
  444. IncRect (rect, 1);
  445. end;
  446. procedure IncRect (var rect : TRect; delta:integer);
  447. begin
  448. with rect do
  449. begin
  450. left := left - delta;
  451. right := right + delta;
  452. top := top - delta;
  453. bottom := bottom + delta;
  454. end;
  455. end;
  456. { TFPRectRegion }
  457. function TFPRectRegion.GetBoundingRect: TRect;
  458. begin
  459. Result := Rect;
  460. end;
  461. function TFPRectRegion.IsPointInRegion(AX, AY: Integer): Boolean;
  462. begin
  463. Result := (AX >= Rect.Left) and (AX <= Rect.Right) and
  464. (AY >= Rect.Top) and (AY <= Rect.Bottom);
  465. end;
  466. {$i FPHelper.inc}
  467. {$i FPFont.inc}
  468. {$i FPPen.inc}
  469. {$i FPBrush.inc}
  470. {$i fpinterpolation.inc}
  471. {$i FPCanvas.inc}
  472. {$i FPCDrawH.inc}
  473. end.