views:

383

answers:

1

I'm looking for a way to display and edit text inside a custom shaped box (e.g. a circle.) The text needs to use as much of the allowed space as possible, so just positioning an edit box inside the shape is not good enough.

Requirements: 1) Given a GraphicsPath and a string, draw the text within the path. If the text overflows, truncate or raise an event. 2) Allow the user to edit text within the GraphicsPath. 3) All the intelligence of the standard text box with respect to word breaks, word wrap, localization.

There don't seem to be any controls out there that fit these requirements. It probably requires low-level line layout APIs to accomplish this, and I can't find documentation in MSDN about such API's in Windows either.

This is for a high precision tool, so we're willing to put in a lot of effort to get what we need.

Thanks in advance!

A: 

Because you've mentioned it's for a high-precision tool, I would completely avoid relying on built-in TextRenderer methods, as they have problems with accuracy and consistency.

As for shaping the edit control, do you mean changing its shape from a rectangle to a circle, or will the control still occupy a rectangular region? If the former, you can change the Region property or P/Invoke the SetWindowRgn family.

overslacked
Thanks. Re: the shape, the actual editable area needs to be a custom shape. The visible outline will have this shape.
bright
@bright - it seems to me you'll have to be doing this 100% from scratch. I would look into PostScript renderers or something along those lines for inspiration.
overslacked