Class TDemo (unit DemoComp)

Inherits from

TGraphicControl

Demo how to draw line chart with preview and printing capabilities. } { You can use this as normal component or with PaintTo method you can setup print previewing and printing to printer.

Constructors


constructor Create(AOwner: TComponent);



Functions

destructor Destroy;


procedure Paint;

Paint: Default painting procedure.

procedure PaintNoErase;

PaintNoErase: Calling this routine from parent form's OnPaint event causes this component's area in form to be validated so Windows' default painting procedure do not erase this area before drawing.

procedure PaintTo(c: TCanvas; x, y, w, h: integer);


function ValuesToPoint(x, y: longint; var p: TPoint): boolean;


procedure DrawLine;

Draw markers on x- and y-axis.

procedure DrawPicture;

Here's actual painting procedure.

procedure DrawTitles;


procedure DrawXandYAxis;

Restore original font and delete own ones.

procedure SetTitle(value: string);


procedure SetXTitle(value: string);


procedure SetYTitle(value: string);


Properties

property Align :


property Title : string


property XTitle : string


property YTitle : string


Events

Variables

fBottom : longint;


fCanvas : TCanvas;

Canvas where to draw.

fData : array[0..10] of integer;

Data array for points.

fHeight : longint;


fLeft : longint;

These variables defines size and position of the actual drawing area.

fNormalLine : longint;


fOffScreen : TBitmap;

Offscreen bitmap for drawing.

fRight : longint;


fThinLine : longint;

Line widths.

fTitle : string;

Titles for chart, x-axis and y-axis.

fTop : longint;


fWidth : longint;


fX0 : longint;

These variables defines size and position of chart area inside the actual drawing area.

fX1 : longint;


fXTitle : string;


fY0 : longint;


fY1 : longint;


fYTitle : string;



Constructors


constructor Create(AOwner: TComponent);


Functions


destructor Destroy;


procedure Paint;

Paint: Default painting procedure. Uses off-screen bitmap for flicker-free drawing.


procedure PaintNoErase;

PaintNoErase: Calling this routine from parent form's OnPaint event causes this component's area in form to be validated so Windows' default painting procedure do not erase this area before drawing. Result is flicker-free component. This requires that entire area off component must be draw inside component. That's why there's Rectangle call in Paint.


procedure PaintTo(c: TCanvas; x, y, w, h: integer);


function ValuesToPoint(x, y: longint; var p: TPoint): boolean;


procedure DrawLine;

Draw markers on x- and y-axis.


procedure DrawPicture;

Here's actual painting procedure. It draw all objects like fonts, lines etc. relative to size of drawing area.


procedure DrawTitles;


procedure DrawXandYAxis;

Restore original font and delete own ones.


procedure SetTitle(value: string);


procedure SetXTitle(value: string);


procedure SetYTitle(value: string);


Properties


property Align :


property Title : string


property XTitle : string


property YTitle : string


Events


Variables


fBottom : longint;


fCanvas : TCanvas;

Canvas where to draw. Depending on situation it's assign to off-screen bitmap, some component's canvas or printers canvas.


fData : array[0..10] of integer;

Data array for points.


fHeight : longint;


fLeft : longint;

These variables defines size and position of the actual drawing area.


fNormalLine : longint;


fOffScreen : TBitmap;

Offscreen bitmap for drawing. Finally contents of the off-screen bitmap is copied to component's own canvas.


fRight : longint;


fThinLine : longint;

Line widths. Values are depending on the size of canvas where to draw.


fTitle : string;

Titles for chart, x-axis and y-axis.


fTop : longint;


fWidth : longint;


fX0 : longint;

These variables defines size and position of chart area inside the actual drawing area.


fX1 : longint;


fXTitle : string;


fY0 : longint;


fY1 : longint;


fYTitle : string;