Re: Using the FTC as an editor, then drawing rendered text

Brendan,

When I have more than one paragraph, it only seems to provide the height 
of the first paragraph.  Any ideas?

- Ryan Dary

Brendan Murphy wrote:
> Ryan Dary wrote:
>> So that does draw to a picture for me... but I think I'm sizing things
>> wrong.  Can you describe to me the right way to setup the "hidden" ftc
>> control?
>>
>> I need to be able to tell the FTC a maximum width for the text, but I
>> need it to tell me the height of the rendered text.  This way, I can
>> pass it the xml data as well as the maximum width, and it can pass me
>> back a picture that "fits" the contents of the text.
>>
>> Perhaps there is some more work I need to add to my code (in the
>> previous message)
> 
> Note, you need to get a fresh reference to the display picture
> after each time you resize the FTC. The reason for this is the FTC
> needs to resize the internal display to fit the new size of the
> control. If don't get a new reference, you will be using a picture
> that the FTC isn't using any more.
> 
> To set the width, this depends on the mode you want to set the FTC
> in. From your previous descriptions of what you were trying to do,
> I will assume you want to put the FTC in edit mode. So once you
> set the FTC in edit mode, you can set the control's width
> directly. I have modified your original code slightly because you
> want to change the control's width and not the window's size.
> 
> me.TextField.getDoc.setXML( xmlData )
> me.TextField.Width = maxWidth
> me.TextField.resize
> 
> At this point, the display is the right width and the text has
> been composed. Next we need to get the height. (Note, I am mixing
> in some pseudo code here.)
> 
> p =  
> me.TextField.getDoc.getParagraph(me.TextField.getDoc.getParagraphCount  
> - 1)
> height = p.getProxyItem(0).getComposePosition + p.getHeight(true) +  
> bottom margin height
> 
> Basically what we are doing is going to the last paragraph and
> getting its rendering position. Note, I have not tested this code
> out, so there is a chance it may not work because I can't remember
> if the composition position is calculated if it is not visible. I
> am pretty sure it does, but if not then don't worry because there
> are other ways to calculate this.
> 
> Now you can take the height and plug it back into the control's
> height.
> 
> me.TextField.height = height
> me.TextField.resize
> 
> Now you are ready to get the display picture.
> 
> Tell me how this works.
> 
> FTC Website: 
> http://www.truenorthsoftware.com/FormattedTextControl/FormattedTextControl.html
> Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
> List Archive: www.freelists.org/archives/ftcdev
> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" in 
> the subject field.
> 
> 
> 
> 
FTC Website: 
http://www.truenorthsoftware.com/FormattedTextControl/FormattedTextControl.html
Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
List Archive: www.freelists.org/archives/ftcdev
Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" in 
the subject field.



Other related posts: