List of usage examples for org.eclipse.swt.widgets ScrollBar setVisible
public void setVisible(boolean visible)
true
, and marks it invisible otherwise. From source file:org.eclipse.swt.examples.accessibility.CTable.java
void updateVerticalBar() { if (drawCount > 0) return;//from w ww .j ava 2 s . c om ScrollBar vBar = getVerticalBar(); if (vBar == null) return; int pageSize = (clientArea.height - getHeaderHeight()) / itemHeight; int maximum = Math.max(1, itemsCount); /* setting a value of 0 here is ignored */ if (maximum != vBar.getMaximum()) { vBar.setMaximum(maximum); } int thumb = Math.min(pageSize, maximum); if (thumb != vBar.getThumb()) { vBar.setThumb(thumb); vBar.setPageIncrement(thumb); } vBar.setVisible(pageSize < maximum); /* reclaim any space now left on the bottom */ if (maximum < topIndex + thumb) { topIndex = maximum - thumb; vBar.setSelection(topIndex); redraw(); } else { int selection = vBar.getSelection(); if (selection != topIndex) { topIndex = selection; redraw(); } } }
From source file:org.eclipse.swt.examples.accessibility.CTable.java
void onResize(Event event) { clientArea = getClientArea();//www . ja v a2s . c om /* vertical scrollbar */ ScrollBar vBar = getVerticalBar(); if (vBar != null) { int clientHeight = (clientArea.height - getHeaderHeight()) / itemHeight; int thumb = Math.min(clientHeight, itemsCount); vBar.setThumb(thumb); vBar.setPageIncrement(thumb); int index = vBar.getSelection(); if (index != topIndex) { topIndex = index; redraw(); } boolean visible = clientHeight < itemsCount; if (visible != vBar.getVisible()) { vBar.setVisible(visible); clientArea = getClientArea(); } } /* horizontal scrollbar */ ScrollBar hBar = getHorizontalBar(); if (hBar != null) { int hBarMaximum = hBar.getMaximum(); int thumb = Math.min(clientArea.width, hBarMaximum); hBar.setThumb(thumb); hBar.setPageIncrement(thumb); horizontalOffset = hBar.getSelection(); boolean visible = clientArea.width < hBarMaximum; if (visible != hBar.getVisible()) { hBar.setVisible(visible); clientArea = getClientArea(); } } /* header */ int headerHeight = Math.max(fontHeight, headerImageHeight) + 2 * getHeaderPadding(); header.setSize(clientArea.width, headerHeight); /* if this is the focus control but there are no items then the boundary focus ring must be repainted */ if (itemsCount == 0 && isFocusControl()) redraw(); }
From source file:org.eclipse.swt.examples.accessibility.CTable.java
void updateHorizontalBar() { if (drawCount > 0) return;/*from ww w . j a va 2 s . com*/ ScrollBar hBar = getHorizontalBar(); if (hBar == null) return; int maxX = 0; if (columns.length > 0) { for (CTableColumn column : columns) { maxX += column.width; } } else { for (int i = 0; i < itemsCount; i++) { Rectangle itemBounds = items[i].getCellBounds(0); maxX = Math.max(maxX, itemBounds.x + itemBounds.width + horizontalOffset); } } int clientWidth = clientArea.width; if (maxX != hBar.getMaximum()) { hBar.setMaximum(Math.max(1, maxX)); /* setting a value of 0 here is ignored */ } int thumb = Math.min(clientWidth, maxX); if (thumb != hBar.getThumb()) { hBar.setThumb(thumb); hBar.setPageIncrement(thumb); } hBar.setVisible(clientWidth < maxX); /* reclaim any space now left on the right */ if (maxX < horizontalOffset + thumb) { horizontalOffset = maxX - thumb; hBar.setSelection(horizontalOffset); redraw(); } else { int selection = hBar.getSelection(); if (selection != horizontalOffset) { horizontalOffset = selection; redraw(); } } }