What is the difference extent and preferredExtent?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What is the difference extent and preferredExtent?

Costas Menico
Hi,

I am using VC and didn't realize I had to set preferredExtent instead
of extent for setting the size of a view.  What is the difference? and
why is preferred the default yet the VC changes extent?

Costas


Reply | Threaded
Open this post in threaded view
|

Re: What is the difference extent and preferredExtent?

Ian Bartholomew-17
Costas,

> I am using VC and didn't realize I had to set preferredExtent instead
> of extent for setting the size of a view.  What is the difference? and
> why is preferred the default yet the VC changes extent?

In "normal" use, a displayed shell for example, you really only need to
refer to #extent to get/set the current size of a view.  #preferredExtent
just answers the size that was used when the view was opened and will be nil
if the default is used.

In the ViewComposer #extext does the same as above, refers to the extent of
the view being edited (which, after all, is just an instance of the view
class).  Changing the #extent value changes the size of this view as normal.
#preferredExtent, if defined, sets the extent of any _newly created_
instance of the view.

As an experiment, locate the ShellView class and add a method

preferredExtent
    ^400@200

Now, any Shell that is opened, _including_ new shells being created for
editing within the ViewComposer, will have an initial extent of 400@200.

As far as I can see #preferredExtent's main use (apart from causing
confusion) is to allow you to edit views at one size, so you can see the
complete view in the VC, but also be able to specify a different size to be
used for new instances.  I think it may also have some bearing on the way
various LayoutManagers layout their subviews but I haven't really looked
into this.

FWIW, I normally create and edit views by changing the #extent aspect and,
when happy, just cut/paste the point from #extent to #preferredExtent.  I
have, on occasion, wondered about adding a #useExtentAsPreferredExtent
aspect to do this automatically - but never got around to it. I've a feeling
that it is one of those things that starts out looking easy but ends up a
lot more difficult.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: What is the difference extent and preferredExtent?

Bill Schwab-2
Ian,

> FWIW, I normally create and edit views by changing the #extent aspect and,
> when happy, just cut/paste the point from #extent to #preferredExtent.  I
> have, on occasion, wondered about adding a #useExtentAsPreferredExtent
> aspect to do this automatically - but never got around to it. I've a
feeling
> that it is one of those things that starts out looking easy but ends up a
> lot more difficult.

It's not quite the same, but an IDE extension should do the trick.  At least
it would automate the copy/paste/check actions that set and enforce the
preferred extent.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]