Home Component Writing
New Blog Post: Email: Multi-Service

Accessing objects from componets

edited August 2004 in Component Writing
Hi



We have added style and stylesheet support to ReportBuilder, but need one
last thing: accessing the styles from the components.

We are not sure where to store the information from the stylesheet to easily
access it from the components.

We have added a style-property to all components, but still need an easy way
to access the information stored in the stylesheet. One place where we need
this is when the end-user has to choose a style from the stylesheet.

In other terms: We have our own class (the stylesheet) that we need to
access from the implementation section in the components.



Where is the best place to store the stylesheet object to make it easy to
access from the components?



Hope you can give some input.

Steffen Friismose

Comments

  • edited August 2004

    Consider whether you want to have one global stylesheet for all reports, or
    a stylesheet for each report.

    1. Global Stylesheet

    Make the StyleSheet a global singleton object that is accessible by simply
    including it in the uses clause.

    example:

    interface

    function gStyleSheet: TmyStyleSheet; // global function

    implementation

    var
    uStyleSheet: TmyStyleSheet; // unit level variable

    function gStyleSheet: TmyStyleSheet;
    begin
    //create global object, the first time it is requested

    if (uStyleSheet = nil) then
    uStyleSheet := TmyStyleSheet.Create(nil);

    Result := uStyleSheet;

    end;





    2. Report.StyleSheet

    Make the StyleSheet a property of TmyReport (a TppReport descendant). Then
    you can access it from a Component using myComponent.Band.Report.




    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2004
    Thanks

    We have ended up using a combination of the two: the global one for
    accessing the data in the stylesheets, and the one on the report for storing
    what stylesheet is active on the report. We are not going to store the
    stylesheet with the report since we will have approx. 150 reports and 3
    stylesheet when the project is done.
    The reports are dynamically changed when a different stylesheet is selected,
    and all stylesheets are used for all reports.

    Thanks a lot
    Steffen with team

This discussion has been closed.