TCanvas( unit KOL.pas ) ï TObj ï _TObj

TCanvas = object( TObj )

Very similar to VCL's TCanvas object. But with some changes, specific for KOL: there is no necessary to use canvases in all applications. And graphic tools objects are not created with canvas, but only if really accessed in program. (Actually, even if paint box used, only programmer decides, if to implement painting using Canvas or to call low level API drawing functions working directly with DC). Therefore TCanvas has some powerful extensions: rotated text support, geometric pen support - just by changing correspondent properties of certain graphic tool objects (Font.FontOrientation, Pen.GeometricPen). See also additional Font properties (Font.FontWeight, Font.FontQuality, etc.

### TCanvas properties

property Handle: HDC;
GDI device context object handle. Never created by Canvas itself (to use Canvas with memory bitmaps, always create DC by yourself and assign it to the Handle property of Canvas object, or use property Canvas of a bitmap).

property PenPos: TPoint;
Position of a pen.

property Pen: PGraphicTool; Ñ
Pen of Canvas object. Do not change its Pen.OnChange event value.

property Brush: PGraphicTool; Ñ
Brush of Canvas object. Do not change its Brush.OnChange event value.

property Font: PGraphicTool; Ñ
Font of Canvas object. Do not change its Font.OnChange event value.

property ModeCopy: TCopyMode;
Current copy mode. Is used in CopyRect method.

property Pixels[ X, Y: Integer ]: TColor;
Obvious.

#### Properties, inherited from TObj

### TCanvas methods

destructor Destroy; virtual; N

procedure OffsetAndRotate( Xoff, Yoff: Integer; Angle: Double );
Transforms world coordinates so that Xoff and Yoff become the coordinates of the origin (0,0) and all further drawing is done rotated around that point by the Angle (which is given in radians)

procedure Arc( X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer ); stdcall;
Draws arc. For more info, see Delphi TCanvas help.

procedure Chord( X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer ); stdcall;
Draws chord. For more info, see Delphi TCanvas help.

procedure DrawFocusRect( const Rect: TRect );
Draws rectangle to represent focused visual object. For more info, see Delphi TCanvas help.

procedure Ellipse( X1, Y1, X2, Y2: Integer );
Draws an ellipse. For more info, see Delphi TCanvas help.

procedure FillRect( const Rect: TRect );
Fills rectangle. For more info, see Delphi TCanvas help.

procedure FillRgn( const Rgn: HRgn );
Fills region. For more info, see Delphi TCanvas help.

procedure FloodFill( X, Y: Integer; Color: TColor; FillStyle: TFillStyle );
Fills a figure with givien color, floodfilling its surface. For more info, see Delphi TCanvas help.

procedure FrameRect( const Rect: TRect );
Draws a rectangle using Brush settings (color, etc.). For more info, see Delphi TCanvas help.

procedure MoveTo( X, Y: Integer );
Moves current PenPos to a new position. For more info, see Delphi TCanvas help.

procedure LineTo( X, Y: Integer );
Draws a line from current PenPos up to new position. For more info, see Delphi TCanvas help.

procedure Pie( X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer ); stdcall;
Draws a pie. For more info, see Delphi TCanvas help.

procedure Polygon( const Points: array of TPoint );
Draws a polygon. For more info, see Delphi TCanvas help.

procedure Polyline( const Points: array of TPoint );
Draws a bound for polygon. For more info, see Delphi TCanvas help.

procedure Rectangle( X1, Y1, X2, Y2: Integer );
Draws a rectangle using current Pen and/or Brush. For more info, see Delphi TCanvas help.

procedure RoundRect( X1, Y1, X2, Y2, X3, Y3: Integer );
Draws a rounded rectangle. For more info, see Delphi TCanvas help.

procedure TextOutA( X, Y: Integer; const Text: AnsiString ); stdcall;
Draws an ANSI text. For more info, see Delphi TCanvas help.

procedure TextOut( X, Y: Integer; const Text: KOLString ); stdcall;
Draws a text. For more info, see Delphi TCanvas help.

procedure ExtTextOut( X, Y: Integer; Options: DWORD; const Rect: TRect; const Text: AnsiString; const Spacing: array of Integer );

procedure TextRect( const Rect: TRect; X, Y: Integer; const Text: Ansistring );
Draws a text, clipping output into given rectangle. For more info, see Delphi TCanvas help.

procedure DrawText( Text: AnsiString; var Rect: TRect; Flags: DWord );

function TextExtent( const Text: Ansistring ): TSize;
Calculates size of a Text, using current Font settings. Does not need in Handle for Canvas object (if it is not yet allocated, temporary device context is created and used.

procedure TextArea( const Text: AnsiString; var Sz: TSize; var P0: TPoint );
Calculates size and starting point to output Text, taking into considaration all Font attributes, including Orientation (only if GlobalGraphics_UseFontOrient flag is set to True, i.e. if rotated fonts are used). Like for TextExtent, does not need in Handle (and if this last is not yet allocated/assigned, temporary device context is created and used).

procedure WTextArea( const Text: WideString; var Sz: TSize; var P0: TPoint );
Calculates size and starting point to output Text, taking into considaration all Font attributes, including Orientation (only if GlobalGraphics_UseFontOrient flag is set to True, i.e. if rotated fonts are used). Like for TextExtent, does not need in Handle (and if this last is not yet allocated/assigned, temporary device context is created and used).

function TextWidth( const Text: Ansistring ): Integer;
Calculates text width (using TextArea).

function TextHeight( const Text: Ansistring ): Integer;
Calculates text height (using TextArea).

function ClipRect: TRect;
returns ClipBox. by Dmitry Zharov.

procedure WTextOut( X, Y: Integer; const WText: WideString ); stdcall;
Draws a Unicode text.

procedure WExtTextOut( X, Y: Integer; Options: DWORD; const Rect: TRect; const WText: WideString; const Spacing: array of Integer );

procedure WDrawText( WText: WideString; var Rect: TRect; Flags: DWord );

procedure WTextRect( const Rect: TRect; X, Y: Integer; const WText: WideString );
Draws a Unicode text, clipping output into given rectangle.

function WTextExtent( const WText: WideString ): TSize;
Calculates Unicode text width and height.

function WTextWidth( const WText: WideString ): Integer;
Calculates Unicode text width.

function WTextHeight( const WText: WideString ): Integer;
Calculates Unicode text height.

procedure CopyRect( const DstRect: TRect; SrcCanvas: PCanvas; const SrcRect: TRect );
Copyes a rectangle from source to destination, using StretchBlt.

function Assign( SrcCanvas: PCanvas ): Boolean;

function RequiredState( ReqState: DWORD ): HDC; stdcall; N
It is possible to call this method before using Handle property to pass it into API calls - to provide valid combinations of pen, brush and font, selected into device context. This method can not provide valid Handle - You always must create it by yourself and assign to TCanvas.Handle property manually. To optimize assembler version, returns Handle value.

procedure DeselectHandles;
Call this method to deselect all graphic tool objects from the canvas.

#### Methods, inherited from TObj

### TCanvas events

property OnGetHandle: TOnGetHandle; N
For internal use only.

property OnChange: TOnEvent;

#### Events, inherited from TObj

### TCanvas fields

fIsPaintDC: Boolean; N
TRUE, if DC obtained during current WM_PAINT (or WM_ERASEBKGND?) processing for a control. This affects a way how Handle is released.

#### Fields, inherited from TObj

[ Index ]

This help is generated 14-Jun-2010 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov
Modified (C) 2003 by Alexander Bartov