[Q][morphic] absolute and relative coordinates
Ned Konz
ned at bike-nomad.com
Tue Sep 2 20:28:57 UTC 2003
On Monday 01 September 2003 12:47 am, Martin Drautzburg wrote:
> I have constructed morph that consists of several submorphs
> (circles and lines) and embedded this morph into an owning morph.
> The circles and lines were create with ablsolute coordinates, i.e.
> as if the upperLeft corner of my morph was 0 at 0.
>
> Once my morph is embedded into its owner its upperLeft corner
> certainly is not 0 at 0 anymore and any *new* circles and lines I add
> then end up outside the morph's bounding rectangle.
>
> I can add topLeft to all coordinates and things appear where they
> should.
>
> What is the standard way of doing this, i.e. manipulationg a morph
> in-situ and contruction a morph ?
It depends on what kind of layout management you need. Assuming that
your morph isn't locked down to a particular size, you probably need
to deal with changes to its size.
You can either provide your own layout method, or you can use an
existing LayoutPolicy subclass if it fits your needs. The current
ones include:
* TableLayout -- for laying things out in rows and columns, possibly
with wrapping. Good to use when you have a list of submorphs that is
dynamic.
* ProportionalLayout -- for laying things out relative to the parent
morph bounds. You can provide fractional bounds and optional offsets
to position your objects. Remember, though, that this layout is done
with respect to the position (the upper left corner) of the parent
and submorphs.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|