void setItemCount (int count, int hParent, int hItem) { boolean redraw = false; if (OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0) == 0) { redraw = drawCount == 0 && OS.IsWindowVisible (handle); if (redraw) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); } int itemCount = 0; while (hItem != 0 && itemCount < count) { hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem); itemCount++; } TVITEM tvItem = new TVITEM (); tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM; while (hItem != 0) { tvItem.hItem = hItem; OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem); hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem); TreeItem item = tvItem.lParam != -1 ? items [tvItem.lParam] : null; if (item != null && !item.isDisposed ()) { item.dispose (); } else { releaseItem (tvItem.hItem, tvItem, false); destroyItem (null, tvItem.hItem); } } if ((style & SWT.VIRTUAL) != 0) { for (int i=itemCount; i<count; i++) { createItem (null, hParent, OS.TVI_LAST, 0); } } else { shrink = true; int extra = Math.max (4, (count + 3) / 4 * 4); TreeItem [] newItems = new TreeItem [items.length + extra]; System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; for (int i=itemCount; i<count; i++) { new TreeItem (this, SWT.NONE, hParent, OS.TVI_LAST, 0); } } if (redraw) { OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0); OS.InvalidateRect (handle, null, true); }
public void setItemCount (int count) { checkWidget (); count = Math.max (0, count); int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0); setItemCount (count, OS.TVGN_ROOT, hItem);
void setItemCount (int count, int hParent, int hItem) {	boolean redraw = false;	if (OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0) == 0) {		redraw = drawCount == 0 && OS.IsWindowVisible (handle);		if (redraw) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);	}	int itemCount = 0;	while (hItem != 0 && itemCount < count) {		hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);		itemCount++;	}	TVITEM tvItem = new TVITEM ();	tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;	while (hItem != 0) {		tvItem.hItem = hItem;		OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);		hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);		TreeItem item = tvItem.lParam != -1 ? items [tvItem.lParam] : null;		if (item != null && !item.isDisposed ()) {			item.dispose ();		} else {			releaseItem (tvItem.hItem, tvItem, false);			destroyItem (null, tvItem.hItem);		}	}	if ((style & SWT.VIRTUAL) != 0) {		for (int i=itemCount; i<count; i++) {			createItem (null, hParent, OS.TVI_LAST, 0);		}	} else {		shrink = true;		int extra = Math.max (4, (count + 3) / 4 * 4);		TreeItem [] newItems = new TreeItem [items.length + extra];		System.arraycopy (items, 0, newItems, 0, items.length);		items = newItems;		for (int i=itemCount; i<count; i++) {			new TreeItem (this, SWT.NONE, hParent, OS.TVI_LAST, 0);		}	}	if (redraw) {		OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);		OS.InvalidateRect (handle, null, true);	}}