/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception org.eclipse.swt.SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
/** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver's list. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget (); return list.getItemHeight (); } /**
@Override public void mouseMove(MouseEvent e){ int item_height = list.getItemHeight(); int y = e.y; int item_index = y/item_height; if ( list.getSelectionIndex() != item_index ){ list.setSelection( item_index ); } } });
boolean needsVScrollBar() { int availableHeight = getClientArea().height; int height = getItemCount() * getItemHeight(); return height > availableHeight; }
Point getItemDimensions() { int width = 0; int height = 0; if( getItemCount() > 0 ) { int availableWidth = getClientArea().width; if( ( style & SWT.H_SCROLL ) == 0 && isMarkupEnabledFor( this ) ) { width = availableWidth; } else { width = Math.max( getMaxItemWidth(), availableWidth ); } height = getItemHeight(); } return new Point( width, height ); }
final int getVisibleItemCount() { int clientHeight = getBounds().height; if( ( style & SWT.H_SCROLL ) != 0 ) { clientHeight -= getHorizontalBar().getSize().y; } int result = 0; if( clientHeight >= 0 ) { int itemHeight = getItemHeight(); result = clientHeight / itemHeight; } return result; }
public void reveal(Object element) { Assert.isNotNull(element); int index = getElementIndex(element); if (index == -1) { return; } // algorithm patterned after List.showSelection() int count = list.getItemCount(); if (count == 0) { return; } int height = list.getItemHeight(); Rectangle rect = list.getClientArea(); int topIndex = list.getTopIndex(); int visibleCount = Math.max(rect.height / height, 1); int bottomIndex = Math.min(topIndex + visibleCount, count) - 1; if ((topIndex <= index) && (index <= bottomIndex)) { return; } int newTop = Math.min(Math.max(index - (visibleCount / 2), 0), count - 1); list.setTopIndex(newTop); }
protected List createDropDownList(Composite parent) { // create the list list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); // fill the list populateList(list); GridData data = new GridData( GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); data.heightHint = list.getItemHeight() * LIST_ITEM_COUNT; list.setLayoutData(data); listCreated = true; return list; } protected Text createDropDownDetails(Composite parent)
@Override public void reveal(Object element) { Assert.isNotNull(element); int index = getElementIndex(element); if (index == -1) { return; } // algorithm patterned after List.showSelection() int count = list.getItemCount(); if (count == 0) { return; } int height = list.getItemHeight(); Rectangle rect = list.getClientArea(); int topIndex = list.getTopIndex(); int visibleCount = Math.max(rect.height / height, 1); int bottomIndex = Math.min(topIndex + visibleCount, count) - 1; if ((topIndex <= index) && (index <= bottomIndex)) { return; } int newTop = Math.min(Math.max(index - (visibleCount / 2), 0), count - 1); list.setTopIndex(newTop); }
@Override public void reveal(Object element) { Assert.isNotNull(element); int index = getElementIndex(element); if (index == -1) { return; } // algorithm patterned after List.showSelection() int count = list.getItemCount(); if (count == 0) { return; } int height = list.getItemHeight(); Rectangle rect = list.getClientArea(); int topIndex = list.getTopIndex(); int visibleCount = Math.max(rect.height / height, 1); int bottomIndex = Math.min(topIndex + visibleCount, count) - 1; if ((topIndex <= index) && (index <= bottomIndex)) { return; } int newTop = Math.min(Math.max(index - (visibleCount / 2), 0), count - 1); list.setTopIndex(newTop); }
data.heightHint = buildList.getItemHeight(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL;
gridData.horizontalSpan = 3; gridData.grabExcessVerticalSpace = true; Rectangle trim = lsDevices.computeTrim(0, 0, 0, lsDevices.getItemHeight() * 5); gridData.heightHint = trim.height; lsDevices.setLayoutData(gridData);
int height = 0; if (hHint == SWT.DEFAULT) { int itemHeight = getItemHeight () + CELL_GAP; height = itemCount * itemHeight; } else {
| GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); data.heightHint = list.getItemHeight() * LIST_ITEM_COUNT; data.horizontalSpan = 2; list.setLayoutData(data);
@Override public Point computeSize( int wHint, int hHint, boolean changed ) { checkWidget (); int width = getMaxItemWidth(); int height = getItemHeight() * getItemCount(); if( width == 0 ) { width = DEFAULT_WIDTH; } if( height == 0 ) { height = DEFAULT_HEIGHT; } if( wHint != SWT.DEFAULT ) { width = wHint; } if( hHint != SWT.DEFAULT ) { height = hHint; } BoxDimensions border = getBorder(); width += border.left + border.right; height += border.top + border.bottom; if( ( style & SWT.V_SCROLL ) != 0 ) { width += getVerticalBar().getSize().x; } if( ( style & SWT.H_SCROLL ) != 0 ) { height += getHorizontalBar().getSize().y; } return new Point( width, height ); }
int itemCount = list.getItemCount (); itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount); int itemHeight = list.getItemHeight () * itemCount; Point listSize = list.computeSize (SWT.DEFAULT, itemHeight, false); list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);