FastReport Class Hierarchy

Top  Next

 

 

_img1

 

"TfrxComponent" is the base class for all FastReport components. Objects of this type have attributes such as “coordinates”, “size”, “font” and “visibility” and have lists of subordinate objects. The class also has methods which allow for the saving and restoration of the object state to or from a stream.

 

TfrxComponent = class(TComponent)

protected

procedure SetParent(AParent: TfrxComponent); virtual;

procedure SetLeft(Value: Extended); virtual;

procedure SetTop(Value: Extended); virtual;

procedure SetWidth(Value: Extended); virtual;

procedure SetHeight(Value: Extended); virtual;

procedure SetFont(Value: TFont); virtual;

procedure SetParentFont(Value: Boolean); virtual;

procedure SetVisible(Value: Boolean); virtual;

procedure FontChanged(Sender: TObject); virtual;

public

constructor Create(AOwner: TComponent); override;

procedure Assign(Source: TPersistent); override;

procedure Clear; virtual;

procedure CreateUniqueName;

procedure LoadFromStream(Stream: TStream); virtual;

procedure SaveToStream(Stream: TStream); virtual;

procedure SetBounds(ALeft, ATop, AWidth, AHeight: Extended);

function FindObject(const AName: String): TfrxComponent;

class function GetDescription: String; virtual;

 

property Objects: TList readonly;

property AllObjects: TList readonly;

property Parent: TfrxComponent;

property Page: TfrxPage readonly;

property Report: TfrxReport readonly;

property IsDesigning: Boolean;

property IsLoading: Boolean;

property IsPrinting: Boolean;

property BaseName: String;

 

property Left: Extended;

property Top: Extended;

property Width: Extended;

property Height: Extended;

property AbsLeft: Extended readonly;

property AbsTop: Extended readonly;

 

property Font: TFont;

property ParentFont: Boolean;

property Restrictions: TfrxRestrictions;

property Visible: Boolean;

end;

 

 

- Clear                clears object contents and deletes all its child objects
- CreateUniqueNamecreates unique name for object placed into report
- LoadFromStream        loads object and all its child objects from stream
- SaveToStream        saves object to stream
- SetBounds                sets object coordinates and size
- FindObject                searches for object with specified name among child objects
- GetDescription        returns object’s description

 

The following methods are called when modifying the corresponding properties. If additional handling is needed, you can override them:

 

- SetParent

- SetLeft

- SetTop

- SetWidth

- SetHeight

- SetFont

- SetParentFont

- SetVisible

- FontChanged

 

The following properties are defined in the “TfrxComponent” class:

 

- Objects        list of child objects
- AllObjects        list of all subordinate objects
- Parent        link to parent object
- Page        link to report page on which object resides
- Report        link to report in which object appears
- IsDesigning        “True” if designer is running
- IsLoading        “True” if object is being loaded from stream
- IsPrinting        “True” if object is being printed out
- BaseName        object base name; this value is used in “CreateUniqueName” method
- Left                object X-coordinate (relative to parent)
- Top                object Y-coordinate (relative to parent)
- Width        object width
- Height        object height
- AbsLeft        object absolute X-coordinate
- AbsTop        object absolute Y-coordinate
- Font                object font
- ParentFont        if “True” then uses parent object font settings
- Restrictionsset of flags which restricts one or more object operations
- Visible        object visibility

 

 

The next base class is “TfrxReportComponent”. Objects of this type can be placed into a report design. This class has the “Draw” method for drawing the object and also the “BeforePrint/GetData/AfterPrint” methods, which are called when the report is running.

 

TfrxReportComponent = class(TfrxComponent)

public

procedure Draw(Canvas: TCanvas;

                ScaleX, ScaleY, OffsetX, OffsetY: Extended); virtual; abstract;

procedure BeforePrint; virtual;

procedure GetData; virtual;

procedure AfterPrint; virtual;

function GetComponentText: String; virtual;

property OnAfterPrint: TfrxNotifyEvent;

property OnBeforePrint: TfrxNotifyEvent;

end;

 

The "Draw" method is called to draw the object, with parameters:

- Canvason canvas
- Scalescaling along the X- and Y-axes
- Offsetoffset relative to canvas edges

 

The "BeforePrint" method is called immediately before object handling (during the report building process). This method saves the object state.

 

The "GetData" method is called to load data into the object.

 

The "AfterPrint" method is called after object handling. This method restores the object state.

 

"TfrxDialogComponent" is the base class for writing non-visual components that can be used in dialogue forms in a report.

 

TfrxDialogComponent = class(TfrxReportComponent)

public

property Bitmap: TBitmap;

property Component: TComponent;

published

property Left;

property Top;

end;

 

 

“TfrxDialogControl” is the base class for writing common controls that can be used in dialogue forms in a report. This class has a large number of general properties and events shared by most of the common controls.

 

TfrxDialogControl = class(TfrxReportComponent)

protected

procedure InitControl(AControl: TControl);

public

property Caption: String;

property Color: TColor;

property Control: TControl;

property OnClick: TfrxNotifyEvent;

property OnDblClick: TfrxNotifyEvent;

property OnEnter: TfrxNotifyEvent;

property OnExit: TfrxNotifyEvent;

property OnKeyDown: TfrxKeyEvent;

property OnKeyPress: TfrxKeyPressEvent;

property OnKeyUp: TfrxKeyEvent;

property OnMouseDown: TfrxMouseEvent;

property OnMouseMove: TfrxMouseMoveEvent;

property OnMouseUp: TfrxMouseEvent;

published

property Left;

property Top;

property Width;

property Height;

property Font;

property ParentFont;

property Enabled: Boolean;

property Visible;

end;

 

When writing your own custom control, you should inherit from this class, move the required properties to the “published” section, and then add new properties for your common control. The writing of custom controls  will be discussed in detail in the next chapter.

 

"TfrxView" is the base class for most components that can be placed on the report design page. Objects of this class have attributes such as “Frame” and “Filling” and can also be connected to a data source. Most FastReport standard objects inherit from this class.

 

TfrxView = class(TfrxReportComponent)

protected

 FX, FY, FX1, FY1, FDX, FDY, FFrameWidth: Integer;

 FScaleX, FScaleY: Extended;

 FCanvas: TCanvas;

procedure BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); virtual;

procedure DrawBackground;

procedure DrawFrame;

procedure DrawLine(x, y, x1, y1, w: Integer);

public

function IsDataField: Boolean;

property BrushStyle: TBrushStyle;

property Color: TColor;

property DataField: String;

property DataSet: TfrxDataSet;

property Frame: TfrxFrame;

published

property Align: TfrxAlign;

property Printable: Boolean;

property ShiftMode: TfrxShiftMode;

property TagStr: String;

property Left;

property Top;

property Width;

property Height;

property Restrictions;

property Visible;

property OnAfterPrint;

property OnBeforePrint;

end;

 

The following methods are defined in this class:

 

- BeginDrawcalled by the “Draw” method; calculates integer-valued coordinates and size of drawing area.

       Calculated values are exposed as FX, FY, FX1, FY1, FDX and FDY variables.

       Frame width (exposed as FFrameWidth) is also calculated

- DrawBackgrounddraws object background
- DrawFrame        draws object frame
- DrawLine        draws line with specified coordinates and width
- IsDataFieldreturns “True” if DataSet and DataField properties contain non-empty values

 

One can refer to the following properties after calling the “BeginDraw” method:

 

- FX, FY, FX1, FY1,

    FDX, FDY,

    FFrameWidththe object frame coordinates, sizes and width calculated using the Scale and Offset parameters

- FscaleX,

    FScaleYX & Y-scaling, which are copies of the ScaleX and ScaleY parameters from the Draw method
- FCanvasthe canvas, which is a copy of the Canvas parameter from the Draw method

 

The class defines the following properties, which are found in most report objects:

 

- BrushStyle        object fill style
- Color        object fill color
- DataField        name of data field to which object is connected
- DataSet        data source
- Frame        object frame
- Align        object alignment relative to its parent
- Printable        defines whether given object can be printed out
- ShiftMode        shift mode of object in cases when a stretchable object is placed above it
- TagStr        field for storing user information

 

 

"TfrxStretcheable" is the base class for writing components which modify their height depending on the data placed in them.

 

TfrxStretcheable = class(TfrxView)

public

function CalcHeight: Extended; virtual;

function DrawPart: Extended; virtual;

procedure InitPart; virtual;

published

property StretchMode: TfrxStretchMode;

end;

 

Objects of this class can be stretched vertically and also split into smaller pieces when the objects don't have sufficient width on the output page. The objects are split enough times to fit all of their data into the available space.

 

The following methods are defined in this class:

 

- CalcHeight         calculates and returns object height according to the data placed in it
- InitPart         called before object splitting
- DrawPart         draws next data chunk placed in object

        “Return value” is the amount of unused space where it was impossible to display data