1 16 package com.google.gwt.user.client.ui; 17 18 import com.google.gwt.user.client.DOM; 19 import com.google.gwt.user.client.Element; 20 21 28 public class VerticalPanel extends CellPanel implements HasAlignment { 29 30 private HorizontalAlignmentConstant horzAlign = ALIGN_LEFT; 31 private VerticalAlignmentConstant vertAlign = ALIGN_TOP; 32 33 36 public VerticalPanel() { 37 DOM.setElementProperty(getTable(), "cellSpacing", "0"); 38 DOM.setElementProperty(getTable(), "cellPadding", "0"); 39 } 40 41 47 public void add(Widget w) { 48 insert(w, getWidgetCount()); 49 } 50 51 public HorizontalAlignmentConstant getHorizontalAlignment() { 52 return horzAlign; 53 } 54 55 public VerticalAlignmentConstant getVerticalAlignment() { 56 return vertAlign; 57 } 58 59 68 public void insert(Widget w, int beforeIndex) { 69 Element tr = DOM.createTR(); 70 Element td = DOM.createTD(); 71 beforeIndex = super.insert(w, td, beforeIndex); 72 DOM.appendChild(tr, td); 73 DOM.insertChild(getBody(), tr, beforeIndex); 74 75 setCellHorizontalAlignment(w, horzAlign); 76 setCellVerticalAlignment(w, vertAlign); 77 } 78 79 public boolean remove(Widget w) { 80 if (w.getParent() != this) { 81 return false; 82 } 83 84 Element td = DOM.getParent(w.getElement()); 85 Element tr = DOM.getParent(td); 86 DOM.removeChild(getBody(), tr); 87 88 super.remove(w); 89 return true; 90 } 91 92 98 public void setHorizontalAlignment(HorizontalAlignmentConstant align) { 99 horzAlign = align; 100 } 101 102 108 public void setVerticalAlignment(VerticalAlignmentConstant align) { 109 vertAlign = align; 110 } 111 } 112 | Popular Tags |