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

Ryan Dary wrote:
I'm designing this with one FTC editor that I reuse for each of the elements that contain text. So, the user would click on an element on their drawing and an editor window pops up. If they click on a rectangle, they can choose the border and background color. If they choose a "text" element, then I popup an FTC editor window. The user edits the content and clicks okay. Then I update the text element on the drawing with the newly styled text. It is that last step of drawing the text on my custom drawing element that I'm wanting to do.

So, I'm wondering if I can use the "back-end" of FTC in order to perform the rendering in my custom objects, without the FTC GUI elements.

Does that make sense?

It would be nice if I could use FTDocument to perform the drawing without needing to use the FormattedText control.

If I were to sum up what you want to achieve, it would be that you
want to use the FTC to do all the gritty rendering steps for you
outside the FTC (as in your canvas). The answer is yes you can do
that. Here is some pseudo code to show you the steps.

- The user clicks on text element button in your application.

- You bring up an FTC window to allow the user to edit their text.

- The user closes the FTC editor.

- Hide the FTC window.
  * The key here is to NOT close the FTC window, but hide it.

- Reconfigure the FTC control.
  - Put in edit mode and set the margins appropriately.
  - Make sure the scroll positions are set to zero.
  - Hide the scrollbars.
  - Put in read only mode (to hide the blinking cursor).
  - Resize the control to match the area in the main canvas
    where the text is going
  - Call updateFull if needed.

- Extract the rendered text.
  - The FTC is doubled buffered so you can extract the buffer
     and copy it to your canvas.
  - Call FormattedText.getDisplay to get the buffer.

- Dispose of the FTC window.

I don't know how you want to display the text in your canvas, but
I will assume you want your text area to grow to encompass the
rendered text the user entered. To do that you will need to go in
and calculate the height of the text for a given width of display.
So you need to set the FTC width and then let it recompose the
text. Then you can go in and get the height of the text and reset
the FTC's height to match and then get the display buffer.

Does this make sense?

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: