[BUG][FIX] DisplayText can answer wrong extent under Morphic

Boris Gaertner Boris.Gaertner at gmx.net
Mon Nov 22 18:16:31 UTC 2004


This bug report is for Squeak 3.7 latest update #5987
It applies also to Squeak 3.8 and to Squeak 3.9 alfa latest update #6328

To see the problem, evaluate the following statement
both in a Morphic project and in an MVC project:

   | text dt |

text := 'Display fill: (10 @ 10 extent: 100 @ 100)
        rule: Form over
        fillColor: (Color red)' asText.
  dt := DisplayText text: text
                    textStyle: (TextStyle named: 'Accumon') copy.
  dt foregroundColor: Color black
     backgroundColor: Color lightBlue.
  dt displayAt: 10 @ 80.

In the MVC project, you see the complete text displayed
on a light blue background.
In the Morphic project, the text is truncated on the right.  :-(

With 
   dt := DisplayText text: text.

in place of

  dt := DisplayText text: text
                    textStyle: (TextStyle named: 'Accumon') copy.

it works both in MVC and in Morphic.

Problem analysis:

The problem is that the change of the textstyle does not
invalidate the already computed bounds of the TextMorph.

There are several fixes possible (finding the right fix for a
problem in the Morphic framework is often not that easy.)

1. Solution. (DisplTextSol1.cs)
This is a pragmatic solution:  The text style of the TextMorph
is set first and the content second. This avoids the problem
that a change of the text style is not properly handled. 

This does not change morphic features and it works.

2. Solution. (DisplTextSol2.cs)

The immediate recreation of the paragraph computes
new bounds. This is also a solution that we should call
a work-around.

3. Solution. (DisplTextSol3.cs)
This is a change in TextMorph that enforces the recomputation
of the paragraph layout when the cached state is released.
This is perhaps the most correct solution, but I hesitate to
recommend it: Will it cause problems elsewhere? I do not
know. 

Comments and recommendations are highly welcome.

Greetings, Boris


-------------- next part --------------
A non-text attachment was scrubbed...
Name: DisplTextSol3.cs
Type: application/octet-stream
Size: 656 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041122/e5a7db5e/DisplTextSol3.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DisplTextSol2.cs
Type: application/octet-stream
Size: 1176 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041122/e5a7db5e/DisplTextSol2.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DisplTextSol1.cs
Type: application/octet-stream
Size: 1440 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041122/e5a7db5e/DisplTextSol1.obj


More information about the Squeak-dev mailing list