Changeset 5117

Show
Ignore:
Timestamp:
07/25/08 06:49:03 (4 months ago)
Author:
risto.yrjana@…
Message:

Corrected rendering order, works in Safari but broken in FF

Location:
incubator/widgets/coordinatelayout/src/com/itmill/toolkit
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • incubator/widgets/coordinatelayout/src/com/itmill/toolkit/tests/tickets/Ticket1267.java

    r4980 r5117  
    77import com.itmill.toolkit.data.Property.ValueChangeListener; 
    88import com.itmill.toolkit.ui.CheckBox; 
     9import com.itmill.toolkit.ui.Component; 
    910import com.itmill.toolkit.ui.CoordinateLayout; 
    1011import com.itmill.toolkit.ui.GridLayout; 
     
    1920public class Ticket1267 extends Application { 
    2021 
    21     final int[] values = new int[6]; 
    2222    final CoordinateLayout layout = new CoordinateLayout(); 
    23     final Table table = new Table(); 
    24  
    25     public void updateCoords() { 
    26         Coordinates newCoord = layout.new Coordinates(values[0], values[1], 
    27                 values[2], values[3], values[4], values[5]); 
    28         newCoord.setUnitsPercent(true, true, true, true, true, true); 
    29         layout.setCoordinates(table, newCoord); 
    30     } 
     23    Table table = new Table("Test table"); 
    3124 
    3225    public void init() { 
     
    3528 
    3629        SplitPanel sPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); 
    37         Panel right = new Panel(); 
    38  
    39         final GridLayout rightLayout = new GridLayout(3, 6); 
    4030 
    4131        table.setPageLength(10); 
     
    6555        table.setSizeFull(); 
    6656        layout.addComponent(table); 
     57        layout.setCoordinates(table, layout.new Coordinates("0,-1,-1,0,-1,-1")); 
    6758 
    6859        Coordinates xy1 = layout.new Coordinates("0, -1, -1, 0, 20%, -1"); 
     
    9586         */ 
    9687 
     88        sPanel.addComponent(layout); 
     89 
     90        sPanel.addComponent(getControlPanel(table)); 
     91 
     92        sPanel.setSplitPosition(75); 
     93 
     94        main.setLayout(sPanel); 
     95        setMainWindow(main); 
     96    } 
     97 
     98    public Panel getControlPanel(final Component c) { 
     99        Panel newPanel = new Panel("Controls for " + c.getCaption()); 
     100        newPanel.setLayout(new GridLayout(3, 6)); 
     101 
     102        final int[] values = new int[6]; 
    97103        Arrays.fill(values, -1); 
    98104 
     
    139145                        sliderArray[j].setEnabled(false); 
    140146                        labelArray[j].setEnabled(false); 
    141                         updateCoords(); 
     147 
     148                        Coordinates newCoord = layout.new Coordinates( 
     149                                values[0], values[1], values[2], values[3], 
     150                                values[4], values[5]); 
     151                        newCoord.setUnitsPercent(true, true, true, true, true, 
     152                                true); 
     153                        layout.setCoordinates(c, newCoord); 
    142154                    } 
    143155                } 
     
    148160                    Double newValue = (Double) event.getProperty().getValue(); 
    149161                    values[j] = (int) newValue.doubleValue(); 
    150                     updateCoords(); 
     162 
     163                    Coordinates newCoord = layout.new Coordinates(values[0], 
     164                            values[1], values[2], values[3], values[4], 
     165                            values[5]); 
     166                    newCoord 
     167                            .setUnitsPercent(true, true, true, true, true, true); 
     168                    layout.setCoordinates(c, newCoord); 
    151169                    labelArray[j].setValue(new Integer(values[j])); 
    152170                } 
     
    155173 
    156174        for (int i = 0; i < sliderArray.length; i++) { 
    157             rightLayout.addComponent(checkBoxArray[i]); 
    158             rightLayout.addComponent(sliderArray[i]); 
    159             rightLayout.addComponent(labelArray[i]); 
     175            newPanel.addComponent(checkBoxArray[i]); 
     176            newPanel.addComponent(sliderArray[i]); 
     177            newPanel.addComponent(labelArray[i]); 
    160178        } 
    161179 
    162         sPanel.addComponent(layout); 
    163         right.setLayout(rightLayout); 
    164         sPanel.addComponent(right); 
    165  
    166         sPanel.setSplitPosition(75); 
    167  
    168         main.setLayout(sPanel); 
    169         setMainWindow(main); 
     180        return newPanel; 
    170181    } 
    171182} 
  • incubator/widgets/coordinatelayout/src/com/itmill/toolkit/ui/gwt/client/ui/ICoordinateLayout.java

    r4989 r5117  
    5353        DOM.setStyleAttribute(getElement(), "border", "0"); 
    5454 
    55         System.out.println("*** ICoordinateLayout init ***"); 
     55        System.out.println("\n*** ICoordinateLayout init ***"); 
    5656    } 
    5757 
     
    129129     */ 
    130130    public void iLayout() { 
     131        // Run layout functions for children.. 
     132        Util.runDescendentsLayout(this); 
    131133 
    132134        // Get our current area 
     
    145147            // Extract the values from the UIDL 
    146148            final UIDL componentUIDL = (UIDL) componentIterator.next(); 
    147             final String componentId = componentUIDL.getId(); 
    148149            final UIDL coords = componentUIDL.getChildUIDL(0); 
    149150            final UIDL dimensions = componentUIDL.getChildUIDL(1); 
     
    177178 
    178179                    // Ask the component for its size only once. 
    179                     if (componentToWidth.get(componentId) == null) { 
    180                         componentToWidth.put(componentId, new Integer( 
    181                                 componentWidget.getOffsetWidth())); 
     180                    if (componentToWidth.get(componentDataPaintable) == null) { 
     181                        componentToWidth.put(componentDataPaintable, 
     182                                new Integer(componentWidget.getOffsetWidth())); 
    182183                    } else { 
    183                         width = ((Integer) componentToWidth.get(componentId)) 
    184                                 .intValue(); 
     184                        width = ((Integer) componentToWidth 
     185                                .get(componentDataPaintable)).intValue(); 
    185186                    } 
    186187                } 
     
    199200 
    200201                    // Ask the component for its size only once. 
    201                     if (componentToHeight.get(componentId) == null) { 
    202                         componentToHeight.put(componentId, new Integer( 
    203                                 componentWidget.getOffsetHeight())); 
     202                    if (componentToHeight.get(componentDataPaintable) == null) { 
     203                        componentToHeight.put(componentDataPaintable, 
     204                                new Integer(componentWidget.getOffsetHeight())); 
    204205                    } else { 
    205                         height = ((Integer) componentToHeight.get(componentId)) 
    206                                 .intValue(); 
     206                        height = ((Integer) componentToHeight 
     207                                .get(componentDataPaintable)).intValue(); 
    207208                    } 
    208209 
     
    242243                    absoluteBottom, absoluteLeft, width, height); 
    243244 
    244         } 
    245  
    246         // Run layout functions for children.. 
    247         Util.runDescendentsLayout(this); 
     245            // Update caption position 
     246            Caption c = (Caption) componentToCaption 
     247                    .get(componentDataPaintable); 
     248            if (c != null) { 
     249                int cTop = absoluteTop - c.getOffsetHeight(); 
     250                int cRight = absoluteLeft + c.getOffsetWidth(); 
     251                int cBottom = absoluteBottom + height; 
     252                int cLeft = absoluteLeft; 
     253 
     254                setWidgetPosition(c, cTop, cRight, cBottom, cLeft, c 
     255                        .getOffsetWidth(), c.getOffsetHeight()); 
     256            } 
     257        } 
    248258 
    249259        // ...but make sure they don't change anything important 
     
    284294        DOM.setStyleAttribute(e, "height", Integer.toString(height) + "px"); 
    285295 
     296    } 
     297 
     298    public void updateCaption(Paintable component, UIDL uidl) { 
     299        Caption c = (Caption) componentToCaption.get(component); 
     300 
     301        if (Caption.isNeeded(uidl)) { 
     302            if (c == null) { 
     303                c = new Caption(component, client); 
     304                add(c); 
     305                componentToCaption.put(component, c); 
     306            } 
     307            c.updateCaption(uidl); 
     308        } else if (c != null) { 
     309            remove(c); 
     310            componentToCaption.remove(component); 
     311        } 
    286312    } 
    287313 
     
    317343    /* 
    318344     *  
    319      * @see com.itmill.toolkit.terminal.gwt.client.Container#hasChildComponent(com.google.gwt.user.client.ui.Widget) 
     345     * @see 
     346     * com.itmill.toolkit.terminal.gwt.client.Container#hasChildComponent(com 
     347     * .google.gwt.user.client.ui.Widget) 
    320348     */ 
    321349    public boolean hasChildComponent(Widget w) { 
     
    356384    /* 
    357385     * Calculates percentage from value if needed 
    358      *  
    359386     */ 
    360387    protected int calculateRealCoord(String key, UIDL coords, 
     
    383410    /* 
    384411     * These methods calculate the final coordinates for a given component. 
    385      *  
    386412     */ 
    387413    protected int calculateAbsoluteLeft(int width, int left, int right) { 
     
    471497    } 
    472498 
    473     public void updateCaption(Paintable component, UIDL uidl) { 
    474         Caption c = (Caption) componentToCaption.get(component); 
    475  
    476         if (Caption.isNeeded(uidl)) { 
    477             if (c == null) { 
    478                 c = new Caption(component, client); 
    479                 add(c); 
    480                 componentToCaption.put(component, c); 
    481             } 
    482             c.updateCaption(uidl); 
    483         } else if (c != null) { 
    484             remove(c); 
    485             componentToCaption.remove(component); 
    486         } 
    487     } 
    488  
    489499    public boolean remove(Widget w) { 
    490500        boolean wasRemoved = super.remove(w);