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

Need help with a writing a new component: DBRotatedText

edited September 2002 in Component Writing
I just modified the RotatedLabel component by Artem A. Berman to a data
aware component (DBRotatedText).
I have a few problems that I'm not sure how to fix.

1. Remove the property: WordWrap (or get WordWrap to work)
2. Remove the property: Caption
3. Create a .res file that contains a bitmap of the new component.

Besides these problems it works fine.
Any help would be appreciated.

Thanks,
Paul Klomp
paul@rxcmpd.com

p.s. Pretty fun for my first component with ReportBuilder!

Comments

  • edited September 2002
    I fixed the property CAPTION and created a new res file. Those items are
    now corrected.
    I still need help with WordWrap. (either removing it or getting it to work
    correctly)

    Thanks!

    Paul Klomp



  • edited September 2002
    It should be possible to wrap rotated text, but it isn't as simple as
    rendering rotated text on a page, because the wrapping affects the space
    used during report generation.

    Have a look at the ppMemo.pas unit. It uses the ppPlaintext.pas unit to wrap
    text. The TppDBMemo would be a good place to look for an example of wrapping
    text. Basically, you'll need to calculate the area that the memo has to
    generate to. The easiest approach is to add the functinoality to determine
    how this memo is goign to stretch. There are four items in this set and you
    can set more than one to be in use. FOr example, you could set the right and
    bottom side to be soft-stretchable. Given this, how would you handle page
    breaks on a dynamic height memo? Does the memo start printing the text
    bottom aligned or top aligned?

    One solution that the report emulation text file device uses is to create
    multiple single line draw commands when there is a wordwrapping memo to be
    printed in the file. Intially, a singe draw command is created on the page.
    The device then breaks up the singel draw command into mulitple draw
    commands. For your rotated example, when that draw command is told to draw
    itself, it can figure out if it can't fit itself on one line and has to wrap
    the text. You can measure the text to break up the lines. Then create new
    draw commands, one for each line, then free the original draw command. Use
    the TDrawRotatedText.Draw routine.

    It gets even more complicated as you rotate to an angle which is not a
    factor of 90 degrees. You have to draw each line of text on a different
    stroke path starting from a different X and Y. These have to be calculated
    as you wrap the text to see how many lines will fit. One solution is to try
    and generate all of them in a clip region on the canvas. This way you can
    try to draw them all, but the clip region will keep you from drawing beyond
    the available space.


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.