Just a little more detail - when no explicit size is set, the assumption is
that the caller wants the dialog to be sized automatically based on the
preferred size of its content. Allowing the dialog to be resized in this case
would require applying an explicit preferred size to the dialog such that
further calls to layout() would use the explicitly-set size rather than the
default reported by the window's skin. This would invalidate the caller's
presumed intention to have the dialog sized automatically.
So, if you want your dialog to be resizable, you just need to set an explicit
preferred size yourself (since this makes it clear that you do not want the
dialog to be sized automatically). If you want your dialog to open at its
default size, you could potentially override open() to clear any previously
explicitly set preferred size and then set it to the value returned by
getPreferredSize().
Again, hope this helps.
Greg
On May 26, 2010, at 3:20 PM, Greg Brown wrote:
> Correct - this is by design. In Pivot, a window's size is defined by its
> preferred width and height properties rather than the actual width and height
> properties. This is because, like all other components, a window relies on
> its parent container (an instance of Display) to set its size. During layout,
> DisplaySkin sets the size of the window to its preferred size, whether
> explicitly defined by the caller or determined by the window's skin. When an
> explicit preferred size is not set, TerraFrameSkin (which TerraDialogSkin
> extends) reports a preferred size based on the size of its content. The
> "resizable" style is ignored in this case. However, if either preferred width
> or height is set, the flag is respected.
>
> This is different from AWT/Swing, which uses the pack() method to size a
> window to its content. In Pivot, packing happens automatically when one or
> both preferred dimensions is not set.
>
> Hope this helps.
>
> Greg
>
>
> On May 26, 2010, at 12:11 PM, Chris Bartlett wrote:
>
>> I've been struggling for a few hours trying to figure out how to make a
>> org.apache.pivot.wtk.Dialog resizable. (Using a copy of the 1.5 trunk
>> refreshed earlier today)
>>
>> Using org.apache.pivot.tutorials.windows.Windows as a base, I modified
>> 'dialog.wtkx' to include styles="{resizable:true}" in the Dialog
>> element.
>>
>> This doesn't have any effect unless the preferredWidth and/or
>> preferredHeight properties are also set.
>> The code in org.apache.pivot.wtk.skin.terra.TerraFrameSkin.mouseMove()
>> suggests this is deliberate.
>>
>> Am I missing something here as to why the preferred width & height are
>> relevant, or should this be classified as a bug?
>> IMHO settiing the resizable style should allow the Frame/Dialog to be
>> resized (unless it is maximized).
>>
>> Regards,
>>
>> Chris
>>
>>
>