Home Component Writing
New Blog Posts: Merging Reports - Part 1 and Part 2

Custom Shape component: What code actually paints the component?

edited January 2010 in Component Writing
Hi all,

I'm trying to create my own descendant from TppShape to draw a specific shape
based on same pipeline value.
I've studied the MyCheckbox example, and got lots of information from it
regarding creating the component and its associated classes.
But I can't find where i have to implement the actual drawing of the component.

Can anybody help or direct me to an example which can teach me this?

Thanks
Bas Schouten

Comments

  • edited January 2010
    Think i'v found the structure in all this, please confirm i'm on the right
    path here:

    The drawcommand associated with a Component is used when the comp has to
    be drawn, by calling TppDrawCommand.Draw(TppDevice)
    This in turns calls TppDevice.Draw(TppDrawcommand), which calls the device
    specific draw-methods bsaed on the drawcommand type like DrawShape and Drawtext.

    So if i want to draw my own shape (consisting of a few lines) i have to create
    a new DrawCommand and override TppDrawCommand.Draw(aDevice).
    In this implementation of the Draw method, i have to create several TppDrawLine
    objects each representing one of the lines to draw, and call each of their
    Drawmethods, relaying the device supplied in the original call
  • edited January 2010
    Hi Bas,


    This is one way to do it. You can also directly draw the shape to the
    canvas similar to the way it currently works in ReportBuilder. Take a look
    at the TppScreenDevice.DrawShape routine in ppViewer.pas or
    TppPrinterDevice.DrawShape in ppPrnDev.pas. When creating custom
    components, this code will obviously be inside the DrawCommand.Draw routine,
    however looking at the device code may be helpful.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2010
    Hello Nico,

    thanks for the tips.

    I got it working now, by repeately calling the Draw command of a runtime-generated
    TLineDrawcommand object, with changing top, left, widht and heights. I think
    i'm working more "device indpendent" this way.

    greetings
    bas
This discussion has been closed.