Changeset 5059

Show
Ignore:
Timestamp:
07/04/08 09:52:12 (6 months ago)
Author:
joonas.lehtinen@…
Message:

Added stubs for using CSS reader for #1904

Files:
1 modified

Legend:

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

    r5057 r5059  
    3939    public static final int ORIENTATION_HORIZONTAL = 1; 
    4040 
    41     // TODO Read these from CSS as in #1904 
    42     private static final int HSPACING = 8; 
    43     private static final int VSPACING = 8; 
    44     private static final int MARGIN_TOP = 15; 
    45     private static final int MARGIN_BOTTOM = 15; 
    46     private static final int MARGIN_LEFT = 18; 
    47     private static final int MARGIN_RIGHT = 18; 
     41    private int hSpacing = -1; 
     42    private int vSpacing = -1; 
     43    private int marginTop = -1; 
     44    private int marginBottom = -1; 
     45    private int marginLeft = -1; 
     46    private int marginRight = -1; 
    4847 
    4948    int orientationMode = ORIENTATION_VERTICAL; 
     
    207206        // Only non-cached UIDL:s can introduce changes 
    208207        if (!uidl.getBooleanAttribute("cached")) { 
     208 
     209            updateMarginAndSpacingSizesFromCSS(uidl); 
    209210 
    210211            // Swith between orientation modes if necessary 
     
    318319    } 
    319320 
     321    private void updateMarginAndSpacingSizesFromCSS(UIDL uidl) { 
     322        // TODO Read spacing and margins from CSS as documented in #1904. 
     323        // Somehow refresh after updates 
     324 
     325        hSpacing = 8; 
     326        vSpacing = 8; 
     327        marginTop = 15; 
     328        marginBottom = 15; 
     329        marginLeft = 18; 
     330        marginRight = 18; 
     331    } 
     332 
    320333    /** 
    321334     * While setting width, ensure that margin div is also resized properly. 
     
    335348            // Calculate margin pixel width 
    336349            int cw = DOM.getElementPropertyInt(root, "offsetWidth"); 
    337             cw -= margins.hasLeft() ? MARGIN_LEFT : 0; 
    338             cw -= margins.hasRight() ? MARGIN_RIGHT : 0; 
     350            cw -= margins.hasLeft() ? marginLeft : 0; 
     351            cw -= margins.hasRight() ? marginRight : 0; 
    339352            DOM.setStyleAttribute(margin, "width", cw + "px"); 
    340353 
     
    366379            // Calculate margin pixel height 
    367380            int ch = DOM.getElementPropertyInt(root, "offsetHeight"); 
    368             ch -= margins.hasTop() ? MARGIN_TOP : 0; 
    369             ch -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 
     381            ch -= margins.hasTop() ? marginTop : 0; 
     382            ch -= margins.hasBottom() ? marginBottom : 0; 
    370383            DOM.setStyleAttribute(margin, "height", ch + "px"); 
    371384 
     
    427440                        : "offsetHeight"); 
    428441        if (orientationMode == ORIENTATION_HORIZONTAL) { 
    429             size -= margins.hasLeft() ? MARGIN_LEFT : 0; 
    430             size -= margins.hasRight() ? MARGIN_RIGHT : 0; 
     442            size -= margins.hasLeft() ? marginLeft : 0; 
     443            size -= margins.hasRight() ? marginRight : 0; 
    431444        } else { 
    432             size -= margins.hasTop() ? MARGIN_TOP : 0; 
    433             size -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 
     445            size -= margins.hasTop() ? marginTop : 0; 
     446            size -= margins.hasBottom() ? marginBottom : 0; 
    434447        } 
    435448 
     
    444457        int numChild = childWidgets.size(); 
    445458        if (hasComponentSpacing) { 
    446             size -= ((orientationMode == ORIENTATION_HORIZONTAL) ? HSPACING 
    447                     : VSPACING) 
     459            size -= ((orientationMode == ORIENTATION_HORIZONTAL) ? hSpacing 
     460                    : vSpacing) 
    448461                    * (numChild - 1); 
    449462        } 
     
    489502        // Update margin classes 
    490503        DOM.setStyleAttribute(margin, "paddingTop", 
    491                 margins.hasTop() ? MARGIN_TOP + "px" : "0"); 
     504                margins.hasTop() ? marginTop + "px" : "0"); 
    492505        DOM.setStyleAttribute(margin, "paddingLeft", 
    493                 margins.hasLeft() ? MARGIN_LEFT + "px" : "0"); 
     506                margins.hasLeft() ? marginLeft + "px" : "0"); 
    494507        DOM.setStyleAttribute(margin, "paddingBottom", 
    495                 margins.hasBottom() ? MARGIN_BOTTOM + "px" : "0"); 
     508                margins.hasBottom() ? marginBottom + "px" : "0"); 
    496509        DOM.setStyleAttribute(margin, "paddingRight", 
    497                 margins.hasRight() ? MARGIN_RIGHT + "px" : "0"); 
     510                margins.hasRight() ? marginRight + "px" : "0"); 
    498511 
    499512        // Update calculated height if needed 
     
    501514        if (currentMarginHeight != null && !"".equals(currentMarginHeight)) { 
    502515            int ch = DOM.getElementPropertyInt(root, "offsetHeight"); 
    503             ch -= margins.hasTop() ? MARGIN_TOP : 0; 
    504             ch -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 
     516            ch -= margins.hasTop() ? marginTop : 0; 
     517            ch -= margins.hasBottom() ? marginBottom : 0; 
    505518            DOM.setStyleAttribute(margin, "height", ch + "px"); 
    506519        } 
     
    508521        if (currentMarginWidth != null && !"".equals(currentMarginWidth)) { 
    509522            int cw = DOM.getElementPropertyInt(root, "offsetWidth"); 
    510             cw -= margins.hasLeft() ? MARGIN_LEFT : 0; 
    511             cw -= margins.hasRight() ? MARGIN_RIGHT : 0; 
     523            cw -= margins.hasLeft() ? marginLeft : 0; 
     524            cw -= margins.hasRight() ? marginRight : 0; 
    512525            DOM.setStyleAttribute(margin, "width", cw + "px"); 
    513526        } 
     
    751764                    orientationMode == ORIENTATION_HORIZONTAL ? "paddingLeft" 
    752765                            : "marginTop", 
    753                     b ? (orientationMode == ORIENTATION_HORIZONTAL ? HSPACING 
    754                             : VSPACING) 
     766                    b ? (orientationMode == ORIENTATION_HORIZONTAL ? hSpacing 
     767                            : vSpacing) 
    755768                            + "px" : "0"); 
    756769        }