ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Q: I'm using a layout shape to represent an area for editable text that will have a fixed position, style, font, size, and width. This layout shape has some default text that the user is prompted to change (text content only; no other attributes). Each time text is added (the new text replaces the previous text string), the UI code asks whether the size of the new string goes beyond the defined width. I do this by comparing the width of the local bounds with the width given within the layout-shape geometry found within the layout-options structure. In all cases, the justification setting is 0, but the flush setting varies (left/0, center/0.5, right/1.0). When the user enters text into this shape, the bounds (as defined by my logic above) may or may not be found. That is, sometimes the bounds defined by the shape and the local bounds reach a point where the local bounds are wider than that indicated by the shape. However, in other cases, the local bounds diverge toward the width, but it never reaches or surpasses it. In this situation, the text is updated and begins to compress itself within the defined width. Sometimes, it appears that the compression or the meeting of the bounds depends on the font and/or the text used, but at other times, this does not seem to apply. Here is my algorithm:
How can I allow text to be entered till the width is reached, but not compressed? Can I do this based on the above detail? If there is something wrong with this approach, can you suggest another approach I could use? A: The problem you describe was fixed in QuickDraw GX 1.1.1 by adding a new API call. The prototype for this call is:
This function returns information that was always generated during layout's justification processing, but was never made publicly visible before. It represents the signed difference between the specified width for the layout and the measured (unjustified) width. By setting a width in the layout options, but leaving the justification factor
at zero, you can keep adding text until the results of the
Some examples may help clarify the usage of this call: Suppose you create a layout with the width field of the gxLayoutOptions set to 500 points and the justification factor set to fract1 (i.e., full justification). If the unjustified width of the layout is only 450 points, this function returns +50 points. Similarly, if the unjustified width is 525 points, this function returns -25 points. A positive value means the line will be typographically stretched in order to fill the specified width, while a negative value means the line will be typographically condensed. Note that the justification factor in the
|
|