Changeset 4943

Show
Ignore:
Timestamp:
06/24/08 08:51:41 (5 months ago)
Author:
matti.tahvonen@…
Message:

fixes #1743 (natural height horizontal expand layout)

Location:
trunk/src/com/itmill/toolkit
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java

    r4369 r4943  
    353353    public void iLayout() { 
    354354        if (orientationMode == ORIENTATION_HORIZONTAL) { 
    355             int pixels = getOffsetHeight() - getTopMargin() - getBottomMargin(); 
    356             if (pixels < 0) { 
    357                 pixels = 0; 
     355            int pixels; 
     356            if ("".equals(height)) { 
     357                // try to find minimum height by looping all widgets 
     358                int maxHeight = 0; 
     359                Iterator iterator = getPaintables().iterator(); 
     360                while (iterator.hasNext()) { 
     361                    Widget w = (Widget) iterator.next(); 
     362                    int h = w.getOffsetHeight(); 
     363                    if (h > maxHeight) { 
     364                        maxHeight = h; 
     365                    } 
     366                } 
     367                pixels = maxHeight; 
     368            } else { 
     369                pixels = getOffsetHeight() - getTopMargin() - getBottomMargin(); 
     370                if (pixels < 0) { 
     371                    pixels = 0; 
     372                } 
    358373            } 
    359374            DOM.setStyleAttribute(marginElement, "height", pixels + "px"); 
  • trunk/src/com/itmill/toolkit/tests/TestForExpandLayout.java

    r3662 r4943  
    1010import com.itmill.toolkit.ui.Label; 
    1111import com.itmill.toolkit.ui.OrderedLayout; 
     12import com.itmill.toolkit.ui.Panel; 
    1213 
    1314/** 
     
    2829    public void createNewView() { 
    2930        main.removeAllComponents(); 
    30         for (int i = 0; i < 10; i++) { 
     31        for (int i = 0; i < 6; i++) { 
    3132            final ExpandLayout el = new ExpandLayout( 
    3233                    OrderedLayout.ORIENTATION_HORIZONTAL); 
    33             for (int j = 0; j < 10; j++) { 
     34            for (int j = 0; j < i + 3; j++) { 
    3435                final Label l = new Label("label" + i + ":" + j); 
    3536                el.addComponent(l); 
    3637            } 
    3738            if (i > 0) { 
    38                 el.setHeight(1, ExpandLayout.UNITS_EM); 
     39                // el.setMargin(true); 
     40                el.setSizeUndefined(); 
     41                el.setWidth("100%"); 
     42                if (i % 2 == 0) { 
     43                    el.setHeight("8em"); 
     44                    Panel p = new Panel("tp"); 
     45                    p.addComponent(new Label("panelc")); 
     46                    p.setHeight("100%"); 
     47                    p.setWidth("100px"); 
     48                    el.addComponent(p); 
     49                } 
    3950            } 
    4051            main.addComponent(el);