Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nebula-dev] computeSize in Control

On 11.05.12 09.03, Tom Schindl wrote:
The preferred size only if you pass SWT.DEFAULT as a hint!

Yes, like I did in

int w = (wHint != SWT.DEFAULT ? wHint : /* your preferred width */);
int h = (hHint != SWT.DEFAULT ? hHint : /* your preferred height */);
return new Point(w, h);


Tom

Am 11.05.12 09:00, schrieb Hallvard Trætteberg:
Well, some places say it should return the preferred size. In the case
of GeoMap, I think it is reasonable to at least ask for the size
corresponding to one map tile.

Hallvard

On 10.05.12 17.33, Matthew Hall wrote:
The computeSize method should report the minimum size needed by the
control. Expanding the control to fill available space is the
responsibility of the container control, using layout data hints.

-Matthew

On May 10, 2012 8:25 AM, "Hallvard Trætteberg"<hal@xxxxxxxxxxx
<mailto:hal@xxxxxxxxxxx>>  wrote:

     Hi,

     I have been looking at implementing computeSize in GeoMap, so it
     "grabs" more space than the minimum when there are no constraints. I
     test it by creating an anonymous subclass in GeoMapViewer's
     constructor. First I tried

             public GeoMapViewer(Composite parent, int flags) {
                     this(new GeoMap(parent, flags) {
                             @Override
                             public Point computeSize(int wHint, int
     hHint, boolean changed) {
                                     int w = (wHint != SWT.DEFAULT ?
     wHint : Integer.MAX_VALUE);
                                     int h = (hHint != SWT.DEFAULT ?
     hHint : Integer.MAX_VALUE);
                                     return new Point(w, h);
                             }
                     });
             }

     The idea is to indicate that ideally GeoMap wants as much space as
     possible. I was pretty surprised that the wish for Integer.MAX_VALUE
     width and height was granted, in the sense that getSize() reported
     these dimensions not that the layout actually gave it that much
     space. This gave problems in the paint method, so I reduced the
     value from Integer.MAX_VALUE to 256 * 8.

     Two question:
     - (how) can the computeSize method say that it wants as much as
     possible, but can accept nothing?
     - why isn't the size returned by getSize() actually reduced to the
     visible size instead of the value asked for by computeSize?

     Hallvard
     _________________________________________________
     nebula-dev mailing list
     nebula-dev@xxxxxxxxxxx<mailto:nebula-dev@xxxxxxxxxxx>
     https://dev.eclipse.org/__mailman/listinfo/nebula-dev
     <https://dev.eclipse.org/mailman/listinfo/nebula-dev>



_______________________________________________
nebula-dev mailing list
nebula-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/nebula-dev
_______________________________________________
nebula-dev mailing list
nebula-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/nebula-dev




Back to the top