Search Results for

    Show / Hide Table of Contents

    FastReport Classes Hierarchy

    TfrxComponent is the base class for all FastReport components. Objects of this type have parameters, such as coordinates, size, font, visibility, and lists of subordinate objects. This class also contains methods which allow saving/restoring of object state to/from 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.

    • CreateUniqueName – creates unique name for object placed into report.

    • LoadFromStream – loads object contents and all its child objects from stream.

    • SaveToStream – saves object to stream.

    • SetBounds – set 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 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 TfrxComponent class:

    • Objects – list of child objects;

    • AllObjects – list of all subordinate objects;

    • Parent – link to parent object;

    • Page – link to report page, which object belongs to;

    • Report – link to report, which object belongs to;

    • 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 basic name. This value is used in CreateUniqueName method;

    • Left – object X coordinate (relatively to parent);

    • Top - object Y coordinate (relatively to parent);

    • Width – object width;

    • Height – object height;

    • AbsLeft – X object absolute coordinate;

    • AbsTop – Y object absolute coordinate;

    • Font – object font;

    • ParentFont – if “True,” then uses parent object font settings;

    • Restrictions – set of flags, which restrict one or another object operation;

    • Visible – object visibility.

    The next basic class is TfrxReportComponent. Objects of this type can be placed into report design. This class contains Draw method for object drawing as well as BeforePrint/GetData/AfterPrint methods, which are called on report 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;
    

    Draw method is called on object drawing. Parameters are the following:

    • Canvas – canvas;

    • Scale – scale by X-axis and Y-axis;

    • Offset – offset relatively canvas edges.

    BeforePrint method is called right before object handling (during report building process). This method saves object state.

    GetData method is called to load data into object.

    AfterPrint is called after object handling. This method restores object state.

    TfrxDialogComponent class is basic one for writing non-visual components, which can be placed to dialogue form in report.

      TfrxDialogComponent = class(TfrxReportComponent)
      public
        property Bitmap: TBitmap;
        property Component: TComponent;
      published
        property Left;
        property Top;
      end;
    

    TfrxDialogControl class is basic one for writing common control, which can be placed on a dialogue form in report. This class contains a large number of general properties and events shared by most 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 element, you should inherit from this class, transfer required properties to “published” section, and then specify new properties for your common control. Control element writing will be discussed in detail in the next chapter.

    TfrxView class is basic one for most components, which can be placed on the report design page. Objects of this type have parameters such as Frame and Fill, and also can be connected to a data source. Most FastReport standard objects are inherited 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:

    • BeginDraw - method is called from Draw method and calculates integer-valued coordinates and drawing area sizes. Calculated values are presented as FX, FY, FX1, FY1, FDX, and FDY variables. Frame width (it is placed in FFrameWidth) is also calculated;

    • DrawBackground - draws object background;

    • DrawFrame - draws object frame;

    • DrawLine – draws line with specified coordinates and width;

    • IsDataField returns “True,” if DataSet and DataField properties contain nonempty values.

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

    • FX, FY, FX1, FY1, FDX, FDY, FFrameWidth are object frame coordinates, sizes and width calculated according to Scale and Offset parameters;

    • FScaleX, FScaleY are scales, which are copies of ScaleX and ScaleY parameters from Draw method;

    • FCanvas is canvas, which is a copy of Canvas parameter from Draw method.

    Following properties, which are general for most report objects, are defined in this class:

    • BrushStyle – object filling style;

    • Color – object filling color;

    • DataField - data field name, which object is connected to;

    • DataSet - data source;

    • Frame – object frame;

    • Align - object aligning relatively to its parent;

    • Printable – defines whether given object should be printed out;

    • ShiftMode is object shifting mode in cases when stretchable object is placed over given one;

    • TagStr - field for user information storage.

    TfrxStretcheable class is basic one for writing components, which modify their height depending on data placed in it.

      TfrxStretcheable = class(TfrxView)
      public
        function CalcHeight: Extended; virtual;
        function DrawPart: Extended; virtual;
        procedure InitPart; virtual;
      published
        property StretchMode: TfrxStretchMode;
      end;
    

    Objects of given class can be stretched, and also "broken" into pieces in cases when object does not find room on output page. At the same time, object is displayed piecemeal until all its data is displayed.

    Following methods are defined in this class:

    • CalcHeight is to calculate and return object height according to data placed in it;

    • InitPart is called before object splitting;

    • DrawPart redraws next data chunk placed in object. “Return value” is value of unused space where it was impossible to display data.

    Back to top © Copyright Fast Reports Inc.