Class TPath (unit region) |
Inherits from
TObject
=== TPath ==================================================================== Encapsulates a windows drawing path. Specfically written for use with the TRegion component and not tested for any other uses. The create method obtains a DC for the whole form and drawing of the path takes place on that DC. The path is begun, and is ended with a call to the EndPath function which returns a region handle. // NB because a path holds a DC open you should minimise the time between BeginPath and EndPath. And ideally protect the call to EndPath in a try finally block (see TRegion.TextOut as an example) so as not to loose the DC due to an exception.
constructor Create (Form: TForm; Font: TFont);
- obtains a DC and begins drawing to it.
procedure BeginPath;
begins drawing to a path (called by create
procedure Bezier (const points: array of TPoint);
draw a bezier curve based on a series of data and control points
procedure BezierTo (const points: array of TPoint);
draw a bezier curve .
procedure CloseFigure;
closes any open shape draw so far
destructor Destroy;
function EndPath : hRgn;
ends drawing and returns a region handle (must be deleting by the caller
procedure LineTo (X, Y : integer);
line from current position to a new position
procedure MoveTo (X, Y : integer);
move drawing poistion to a new coordinate
procedure Polygon (const points: array of TPoint);
draw a polygon based on a series of points
procedure PolyLine (const points: array of TPoint);
draw a polyline based on a series of points
procedure PolyLineTo (const points: array of TPoint);
draw a polyline .
procedure Rectangle (X1, Y1, X2, Y2 : integer);
draw a rectangle (win 95 implemented locally shows example of local implementation of a function not available under win 95 but available under NT4
function TextExtent (const Text: string): TSize;
returns the size of the supplied text need outline only no fill
procedure TextOut (X, Y: Integer; const Text: string);
write text to the path
function TextWidth (const Text: string): integer;
returns width of some text
function CheckPath (Value : integer): integer;
passes through a non-zero number but raises an exception on zero (=error crude error handling
property Handle : hDC
read-only property handle
FFont : TFont;
drawing device context
FForm : TForm;
FHandle : hDC;
form for which the path will be made
constructor Create (Form: TForm; Font: TFont);
obtains a DC and begins drawing to it.
simple point of reference for testing if NT is in use === PATH METHODS =============================================================
procedure BeginPath;
begins drawing to a path (called by create
procedure Bezier (const points: array of TPoint);
draw a bezier curve based on a series of data and control points
procedure BezierTo (const points: array of TPoint);
draw a bezier curve .... moving the drawing point to the end
procedure CloseFigure;
closes any open shape draw so far
destructor Destroy;
function EndPath : hRgn;
ends drawing and returns a region handle (must be deleting by the caller
procedure LineTo (X, Y : integer);
line from current position to a new position
procedure MoveTo (X, Y : integer);
move drawing poistion to a new coordinate
procedure Polygon (const points: array of TPoint);
draw a polygon based on a series of points
procedure PolyLine (const points: array of TPoint);
draw a polyline based on a series of points
procedure PolyLineTo (const points: array of TPoint);
draw a polyline .... moving the drawing point to the end
procedure Rectangle (X1, Y1, X2, Y2 : integer);
draw a rectangle (win 95 implemented locally
shows example of local implementation of a function not available under win 95 but available under NT4
function TextExtent (const Text: string): TSize;
returns the size of the supplied text
need outline only no fill
procedure TextOut (X, Y: Integer; const Text: string);
write text to the path
function TextWidth (const Text: string): integer;
returns width of some text
function CheckPath (Value : integer): integer;
passes through a non-zero number but raises an exception on zero (=error
crude error handling
property Handle : hDC
read-only property handle
FFont : TFont;
drawing device context
FForm : TForm;
FHandle : hDC;
form for which the path will be made