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.
type PCanvas = ^ TCanvas;
type TFillStyle =( fsSurface, fsBorder );
Available filling styles. For more info see Win32 or Delphi help files.
type TFillMode =( fmAlternate, fmWinding );
Available filling modes. For more info see Win32 or Delphi help files.
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.
TCanvas methods
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: KOLString ): 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: KOLString; 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: KOLWideString; 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: KOLString ): Integer;
Calculates text width (using TextArea).
function TextHeight( const Text: KOLString ): Integer;
Calculates text height (using TextArea).
function ClipRect: TRect;
returns ClipBox. by Dmitry Zharov.
procedure WTextOut( X, Y: Integer; const WText: KOLWideString ); stdcall;
Draws a Unicode text.
procedure WExtTextOut( X, Y: Integer; Options: DWORD; const Rect: TRect; const WText: KOLWideString; const Spacing: array of Integer );
procedure WDrawText( WText: KOLWideString; var Rect: TRect; Flags: DWord );
procedure WTextRect( const Rect: TRect; X, Y: Integer; const WText: KOLWideString );
Draws a Unicode text, clipping output into given rectangle.
function WTextExtent( const WText: KOLWideString ): TSize;
Calculates Unicode text width and height.
function WTextWidth( const WText: KOLWideString ): Integer;
Calculates Unicode text width.
function WTextHeight( const WText: KOLWideString ): 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;
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.
TCanvas events
property OnGetHandle: TOnGetHandle;
For internal use only.
property OnChange: TOnEvent;
TCanvas fields
TRUE, if DC obtained during current WM_PAINT (or WM_ERASEBKGND?) processing for a control. This affects a way how Handle is released.
TRUE if Canvas was created on base of existing DC, so DC is not beloning to the Canvas and should not be deleted when the Canvas object is destroyed.
Fields, inherited from TObj