The attached patch adds a couple of useful procedure to the graphics
library, i.e. InflateRect and OffsetRect. They are derived from the
Delphi counterparts, and are useful to increase or decrease the size of
a rectangle, or to move it. This happens frequently when drawing in the
client area of a component, and one has to take into account border
width, or simulate the button up/down, etc.
Regards,
Giuliano Colla
Index: graphics.pp
===================================================================
--- graphics.pp (revisione 9820)
+++ graphics.pp (copia locale)
@@ -1310,6 +1310,9 @@
function FPColorToTColor(const FPColor: TFPColor): TColor;
function TColorToFPColor(const c: TColor): TFPColor;
+procedure InflateRect(var ARect: TRect; X, Y: Integer);
+procedure OffsetRect(var ARect: TRect; X, Y: Integer);
+
// fonts
procedure GetCharsetValues(Proc: TGetStrProc);
function CharsetToIdent(Charset: Longint; var Ident: string): Boolean;
@@ -1679,6 +1682,27 @@
Result.Alpha:=FPImage.alphaOpaque;
end;
+procedure InflateRect(var ARect: TRect; X, Y: Integer);
+begin
+ with ARect do begin
+ Dec(Top, Y);
+ Inc(Bottom, Y);
+ Dec(Left, X);
+ Inc(Right, X);
+ end;
+end;
+
+procedure OffsetRect(var ARect: TRect; X, Y: Integer);
+begin
+ with ARect do begin
+ Inc(Left, X);
+ Inc(Top, Y);
+ Inc(Right, X);
+ Inc(Bottom, Y);
+ end;
+end;
+
+
{$I graphicsobject.inc}
{$I graphic.inc}
{$I picture.inc}