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

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> 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
https://dev.eclipse.org/mailman/listinfo/nebula-dev