<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">First of all, Waste 3 automatically recalculates line-breaks when necessary, while in Waste 2 we need to tell waste it by calling WECalText. No problem.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>However, recalculating line-breaks when the destination rectangle changes leads to spurious mistakes. We claim that the mistake is in the line break algorithm. </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Here is the code that will be called during a life resize:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>/* remember offset of first visible character */</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>WEGetViewRect(&lr, text); <SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>// the old view rect</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>topCharPosition = *(LongPt*)&lr; <SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>// old topChar offset</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>topCharOffset = WEGetOffset(&topCharPosition, &edge, text);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>dprintf("rewrapping: topCharOffset = %i, edge = %i, view left = %i, </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                </SPAN>view top = %i", topCharOffset, edge, lr.left, lr.top);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>/* reset destination rectangle and recalculate line breaks */</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>_SetDestinationRect(instance);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>_SetViewRect(instance);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>if ( (err = WECalText(text)) != noErr ) {</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>dprintf("error calculating line breaks...");</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>goto cleanup ;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>}</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>lineWidth = WEGetMaxLineWidth(text);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>/* scroll the destination rectangle to keep the previous */</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>/* first visible character at the top of the view rectangle */</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>WEGetPoint(topCharOffset, kHilite, &topCharPosition, &lineHeight, text);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>dprintf("rewrapping: topCharPosition = %i, %i, lineWidth = %i, lineHeight = %i", </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                </SPAN>topCharPosition.h, topCharPosition.v, lineWidth, lineHeight);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>// note that sometimes the topCharPosition is way off with respect to topCharOffset</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>// and potentially is related to WECalText doing something wrong??</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>WEGetDestRect(&lr, text);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>offsetX = controltop.h - topCharPosition.h;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>offsetY = controltop.v - topCharPosition.v;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>dprintf("offsetX %i, offsetY %i", offsetX, offsetY);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>WEOffsetLongRect(&lr, offsetX, offsetY);</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>WESetDestRect(&lr, text);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>cleanup: ;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>A good pass through the above gives:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>rewrapping: topCharOffset = 1728, edge = 0, view left = 8, view top = 37</DIV><DIV>rewrapping: topCharPosition = 8, 613, lineWidth = 312, lineHeight = 16</DIV><DIV>offsetX 0, offsetY -576</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>and the next pass gives:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>rewrapping: topCharOffset = 1728, edge = 0, view left = 8, view top = 37</DIV><DIV>rewrapping: topCharPosition = 324, 485, lineWidth = 391, lineHeight = 16</DIV><DIV>offsetX -316, offsetY -448</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>and suddenly the field is scrolled to the left. This offsetX change relates to the length of the word used in the field. </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The example used was:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" face="Geneva">WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset WEGetOffset etc</FONT></DIV><DIV><FONT class="Apple-style-span" face="Geneva"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Geneva">and the field width was less than 5 words. </FONT></DIV><DIV><FONT class="Apple-style-span" face="Geneva"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Geneva">When the field width is increased to 5 words, Waste is moving the dest rectangle 4 words to the left if that would be of value here (Waste 2) or 2 words to the left (Waste 3). Then moving to a width that can contain 6 of the above words on a line, the field snaps back to an offsetX of 0:</FONT></DIV><DIV><FONT class="Apple-style-span" face="Geneva"><BR class="khtml-block-placeholder"></FONT></DIV><DIV>rewrapping: topCharOffset = 1728, edge = 0, view left = 8, view top = 37</DIV><DIV>rewrapping: topCharPosition = 8, 421, lineWidth = 470, lineHeight = 16</DIV><DIV>offsetX 0, offsetY -384</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>With Waste 2, but snaps further to the left as a function of the word length.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Any thoughts, comments, workarounds etc? </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Alfred</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>