Changeset 5117
- Timestamp:
- 07/25/08 06:49:03 (4 months ago)
- Location:
- incubator/widgets/coordinatelayout/src/com/itmill/toolkit
- Files:
-
- 2 modified
-
tests/tickets/Ticket1267.java (modified) (8 diffs)
-
ui/gwt/client/ui/ICoordinateLayout.java (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
incubator/widgets/coordinatelayout/src/com/itmill/toolkit/tests/tickets/Ticket1267.java
r4980 r5117 7 7 import com.itmill.toolkit.data.Property.ValueChangeListener; 8 8 import com.itmill.toolkit.ui.CheckBox; 9 import com.itmill.toolkit.ui.Component; 9 10 import com.itmill.toolkit.ui.CoordinateLayout; 10 11 import com.itmill.toolkit.ui.GridLayout; … … 19 20 public class Ticket1267 extends Application { 20 21 21 final int[] values = new int[6];22 22 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"); 31 24 32 25 public void init() { … … 35 28 36 29 SplitPanel sPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); 37 Panel right = new Panel();38 39 final GridLayout rightLayout = new GridLayout(3, 6);40 30 41 31 table.setPageLength(10); … … 65 55 table.setSizeFull(); 66 56 layout.addComponent(table); 57 layout.setCoordinates(table, layout.new Coordinates("0,-1,-1,0,-1,-1")); 67 58 68 59 Coordinates xy1 = layout.new Coordinates("0, -1, -1, 0, 20%, -1"); … … 95 86 */ 96 87 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]; 97 103 Arrays.fill(values, -1); 98 104 … … 139 145 sliderArray[j].setEnabled(false); 140 146 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); 142 154 } 143 155 } … … 148 160 Double newValue = (Double) event.getProperty().getValue(); 149 161 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); 151 169 labelArray[j].setValue(new Integer(values[j])); 152 170 } … … 155 173 156 174 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]); 160 178 } 161 179 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; 170 181 } 171 182 } -
incubator/widgets/coordinatelayout/src/com/itmill/toolkit/ui/gwt/client/ui/ICoordinateLayout.java
r4989 r5117 53 53 DOM.setStyleAttribute(getElement(), "border", "0"); 54 54 55 System.out.println(" *** ICoordinateLayout init ***");55 System.out.println("\n*** ICoordinateLayout init ***"); 56 56 } 57 57 … … 129 129 */ 130 130 public void iLayout() { 131 // Run layout functions for children.. 132 Util.runDescendentsLayout(this); 131 133 132 134 // Get our current area … … 145 147 // Extract the values from the UIDL 146 148 final UIDL componentUIDL = (UIDL) componentIterator.next(); 147 final String componentId = componentUIDL.getId();148 149 final UIDL coords = componentUIDL.getChildUIDL(0); 149 150 final UIDL dimensions = componentUIDL.getChildUIDL(1); … … 177 178 178 179 // Ask the component for its size only once. 179 if (componentToWidth.get(component Id) == null) {180 componentToWidth.put(component Id, new Integer(181 componentWidget.getOffsetWidth()));180 if (componentToWidth.get(componentDataPaintable) == null) { 181 componentToWidth.put(componentDataPaintable, 182 new Integer(componentWidget.getOffsetWidth())); 182 183 } else { 183 width = ((Integer) componentToWidth .get(componentId))184 . intValue();184 width = ((Integer) componentToWidth 185 .get(componentDataPaintable)).intValue(); 185 186 } 186 187 } … … 199 200 200 201 // Ask the component for its size only once. 201 if (componentToHeight.get(component Id) == null) {202 componentToHeight.put(component Id, new Integer(203 componentWidget.getOffsetHeight()));202 if (componentToHeight.get(componentDataPaintable) == null) { 203 componentToHeight.put(componentDataPaintable, 204 new Integer(componentWidget.getOffsetHeight())); 204 205 } else { 205 height = ((Integer) componentToHeight .get(componentId))206 . intValue();206 height = ((Integer) componentToHeight 207 .get(componentDataPaintable)).intValue(); 207 208 } 208 209 … … 242 243 absoluteBottom, absoluteLeft, width, height); 243 244 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 } 248 258 249 259 // ...but make sure they don't change anything important … … 284 294 DOM.setStyleAttribute(e, "height", Integer.toString(height) + "px"); 285 295 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 } 286 312 } 287 313 … … 317 343 /* 318 344 * 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) 320 348 */ 321 349 public boolean hasChildComponent(Widget w) { … … 356 384 /* 357 385 * Calculates percentage from value if needed 358 *359 386 */ 360 387 protected int calculateRealCoord(String key, UIDL coords, … … 383 410 /* 384 411 * These methods calculate the final coordinates for a given component. 385 *386 412 */ 387 413 protected int calculateAbsoluteLeft(int width, int left, int right) { … … 471 497 } 472 498 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 489 499 public boolean remove(Widget w) { 490 500 boolean wasRemoved = super.remove(w);
