List of usage examples for com.google.gwt.dom.client TextAreaElement getClientHeight
@Override
public int getClientHeight()
From source file:org.opencms.ui.client.CmsAutoGrowingTextAreaConnector.java
License:Open Source License
/** * Resize the text area.<p>/*from w ww. j a v a 2 s . c o m*/ */ protected void handle() { Element e = m_widget.getElement(); if (e instanceof TextAreaElement) { TextAreaElement elem = (TextAreaElement) e; int scrollHeight = elem.getScrollHeight(); // allow text area to shrink if (m_lastValue.length() > elem.getValue().length()) { elem.setRows(getState().getMinRows()); } int currentRows = elem.getRows(); if (m_lineHeight == 0) { elem.setRows(2); int heightTwo = elem.getClientHeight(); elem.setRows(1); int heightOne = elem.getClientHeight(); m_lineHeight = heightTwo - heightOne; m_paddingHeight = heightOne - m_lineHeight; elem.setRows(currentRows); } if (m_lineHeight > 0) { int totalHeight = scrollHeight - m_paddingHeight; int requiredRows = ((scrollHeight - m_paddingHeight) / m_lineHeight); if ((totalHeight % m_lineHeight) > 0) { requiredRows++; } int minRows = getState().getMinRows(); int maxRows = getState().getMaxRows(); if ((requiredRows <= minRows) && (currentRows != minRows)) { elem.setRows(minRows); } else if ((requiredRows >= maxRows) && (currentRows != maxRows)) { elem.setRows(maxRows); } else if (requiredRows != currentRows) { elem.setRows(requiredRows); } } } }