Getting a submorph to spaceFill
stéphane ducasse
ducasse at iam.unibe.ch
Wed Mar 24 19:19:35 UTC 2004
ned would it make sense to have that in the image?
Stef
On 24 mars 04, at 18:16, Ned Konz wrote:
> On Wednesday 24 March 2004 4:35 am, Ed Cavazos wrote:
>> Hello!
>>
>> I've only been Squeaking for 2 days so I've got a very elementary
>> question
>> about Morphic layout stuff...
>>
>> Below is a code snipet which illustrates the problem.
>>
>> "**************************************************"
>> am := AlignmentMorph new.
>> am extent: 500 at 500.
>>
>> picopaint := PicoPaintMorph new.
>> picopaint hResizing: #spaceFill.
>> picopaint vResizing: #spaceFill.
>>
>> am addMorphBack: picopaint.
>> am openInWorld.
>> "**************************************************"
>>
>> The PicoPaintMorph is from the "Introduction to Morphic" article by
>> John
>> Maloney.
>>
>> So after invoking doit, the AlignmentMorph appears and the
>> PicoPaintMorph
>> is inside it. However, the size of the PicoPaintMorph is still it's
>> initial
>> size. That is, it hasn't filled up the remaining space in the
>> AlignmentMorph. If I activate the halo's on the AlignmentMorph and
>> manually
>> resize it, the PicoPaintMorph finally get's resized. How do I get it
>> to
>> fill the space from the very beginning so that it looks correct as
>> soon as
>> I send 'openInWorld' to the AlignmentMorph?
>
> As you've probably guessed, the initial layout doesn't send #extent:
> so your
> morph doesn't get resized. Instead it gets sent #bounds:.
>
> Rather than overriding #bounds: as well, a better way to do this might
> be to
> check the form size at drawing time.
>
> The attached version of PicoPaint does this by adding an accessor for
> form
> that checks to see if the size has been changed and copies the form if
> necessary.
>
> The two direct references to the form instance variable were replaced
> with
> calls to this accessor.
>
> --
> Ned Konz
> http://bike-nomad.com/squeak/
> <PicoPaintLazyForm-nk.1.cs>
More information about the Squeak-dev
mailing list
|