void onResize () { Rectangle rect = getClientArea (); int width = Math.max (0, rect.width - spacing * 2); for (int i = 0; i < itemCount; i++) { ExpandItem item = items[i]; item.setBounds (0, 0, width, item.height, false, true); } setScrollbar (); }
private void updateBounds() { int parentWidth = parent.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).x; int scrollBarWidth = parent.getVScrollBarWidth(); int availableWidth = parentWidth - 2 * parent.spacing - scrollBarWidth; width = Math.max( getPreferredWidth(), availableWidth ); setBounds( 0, 0, width, height, false, true ); }
void layoutItems (int index, boolean setScrollbar) { if (index < itemCount) { int y = spacing - yCurrentScroll; for (int i = 0; i < index; i++) { ExpandItem item = items [i]; if (item.expanded) y += item.height; y += item.getHeaderHeight() + spacing; } for (int i = index; i < itemCount; i++) { ExpandItem item = items [i]; item.setBounds (spacing, y, 0, 0, true, false); if (item.expanded) y += item.height; y += item.getHeaderHeight() + spacing; } } if (setScrollbar) setScrollbar (); }
/** * Sets the height of the receiver. This is height of the item when it is expanded, * excluding the height of the header. * * @param height the new height * * @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 void setHeight (int height) { checkWidget (); if (height < 0) return; setBounds (0, 0, width, height, false, true); if (expanded) parent.layoutItems (parent.indexOf (this) + 1, true); }
/** * Sets the height of the receiver. This is height of the item when it is * expanded, excluding the height of the header. * * @param height the new height * @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 void setHeight( int height ) { checkWidget(); if( height >= 0 ) { setBounds( 0, 0, width, height, false, true ); if( expanded ) { parent.layoutItems( parent.indexOf( this ) + 1 ); } } }
/** * Sets the receiver's spacing. Spacing specifies the number of pixels allocated around * each item. * * @param spacing the spacing around each 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 void setSpacing (int spacing) { checkWidget (); if (spacing < 0) return; if (spacing == this.spacing) return; this.spacing = spacing; int width = Math.max (0, getClientArea ().width - spacing * 2); for (int i = 0; i < itemCount; i++) { ExpandItem item = items[i]; if (item.width != width) item.setBounds (0, 0, width, item.height, false, true); } layoutItems (0, true); redraw (); }
for (int i = 0; i < itemCount; i++) { ExpandItem item2 = items[i]; item2.setBounds (0, 0, width, item2.height, false, true);
for (int i = 0; i < itemCount; i++) { ExpandItem item2 = items[i]; item2.setBounds (0, 0, width, item2.height, false, true);
for (int i = 0; i < itemCount; i++) { ExpandItem item2 = items[i]; item2.setBounds (0, 0, width, item2.height, false, true);
item.setBounds( spacing, y, 0, 0, true, false ); if( item.expanded ) { y += item.height; item.setBounds( itemBounds.x, itemBounds.y, width, item.height, true, true ); } else { int width = bounds.width - ( border.left + border.right ) - 2 * spacing; item.setBounds( spacing, itemBounds.y, width, item.height, true, true );