Changeset 5059
- Timestamp:
- 07/04/08 09:52:12 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
r5057 r5059 39 39 public static final int ORIENTATION_HORIZONTAL = 1; 40 40 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; 48 47 49 48 int orientationMode = ORIENTATION_VERTICAL; … … 207 206 // Only non-cached UIDL:s can introduce changes 208 207 if (!uidl.getBooleanAttribute("cached")) { 208 209 updateMarginAndSpacingSizesFromCSS(uidl); 209 210 210 211 // Swith between orientation modes if necessary … … 318 319 } 319 320 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 320 333 /** 321 334 * While setting width, ensure that margin div is also resized properly. … … 335 348 // Calculate margin pixel width 336 349 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; 339 352 DOM.setStyleAttribute(margin, "width", cw + "px"); 340 353 … … 366 379 // Calculate margin pixel height 367 380 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; 370 383 DOM.setStyleAttribute(margin, "height", ch + "px"); 371 384 … … 427 440 : "offsetHeight"); 428 441 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; 431 444 } 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; 434 447 } 435 448 … … 444 457 int numChild = childWidgets.size(); 445 458 if (hasComponentSpacing) { 446 size -= ((orientationMode == ORIENTATION_HORIZONTAL) ? HSPACING447 : VSPACING)459 size -= ((orientationMode == ORIENTATION_HORIZONTAL) ? hSpacing 460 : vSpacing) 448 461 * (numChild - 1); 449 462 } … … 489 502 // Update margin classes 490 503 DOM.setStyleAttribute(margin, "paddingTop", 491 margins.hasTop() ? MARGIN_TOP+ "px" : "0");504 margins.hasTop() ? marginTop + "px" : "0"); 492 505 DOM.setStyleAttribute(margin, "paddingLeft", 493 margins.hasLeft() ? MARGIN_LEFT+ "px" : "0");506 margins.hasLeft() ? marginLeft + "px" : "0"); 494 507 DOM.setStyleAttribute(margin, "paddingBottom", 495 margins.hasBottom() ? MARGIN_BOTTOM+ "px" : "0");508 margins.hasBottom() ? marginBottom + "px" : "0"); 496 509 DOM.setStyleAttribute(margin, "paddingRight", 497 margins.hasRight() ? MARGIN_RIGHT+ "px" : "0");510 margins.hasRight() ? marginRight + "px" : "0"); 498 511 499 512 // Update calculated height if needed … … 501 514 if (currentMarginHeight != null && !"".equals(currentMarginHeight)) { 502 515 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; 505 518 DOM.setStyleAttribute(margin, "height", ch + "px"); 506 519 } … … 508 521 if (currentMarginWidth != null && !"".equals(currentMarginWidth)) { 509 522 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; 512 525 DOM.setStyleAttribute(margin, "width", cw + "px"); 513 526 } … … 751 764 orientationMode == ORIENTATION_HORIZONTAL ? "paddingLeft" 752 765 : "marginTop", 753 b ? (orientationMode == ORIENTATION_HORIZONTAL ? HSPACING754 : VSPACING)766 b ? (orientationMode == ORIENTATION_HORIZONTAL ? hSpacing 767 : vSpacing) 755 768 + "px" : "0"); 756 769 }
