### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java,v retrieving revision 1.71 diff -u -r1.71 ToolItem.java --- Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java 10 Jul 2007 15:46:19 -0000 1.71 +++ Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java 16 Feb 2008 00:30:37 -0000 @@ -77,6 +77,9 @@ */ public ToolItem (ToolBar parent, int style) { super (parent, checkStyle (style)); + if ((style & SWT.CHECK) != 0){ + System.out.println("check item"); + } this.parent = parent; parent.createItem (this, parent.getItemCount ()); } @@ -119,6 +122,9 @@ */ public ToolItem (ToolBar parent, int style, int index) { super (parent, checkStyle (style)); + if ((style & SWT.CHECK) != 0){ + System.out.println("check item"); + } this.parent = parent; parent.createItem (this, index); } Index: Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java,v retrieving revision 1.45 diff -u -r1.45 FormLayout.java --- Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java 31 May 2007 22:04:29 -0000 1.45 +++ Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java 16 Feb 2008 00:30:36 -0000 @@ -286,10 +286,23 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache) { Control [] children = composite.getChildren (); + FormAnchor[] anchors = new FormAnchor [children.length]; for (int i=0; i */ public int alignment; + + public FormAnchor anchor; /** * Constructs a new instance of this class. @@ -225,6 +227,15 @@ this.alignment = alignment; } +public FormAttachment (FormAnchor anchor) { + this.anchor = anchor; +} + +public FormAttachment (FormAnchor anchor, int offset) { + this.anchor = anchor; + this.offset = offset; +} + FormAttachment divide (int value) { return new FormAttachment (numerator, denominator * value, offset / value); } Index: Eclipse SWT/common/org/eclipse/swt/layout/FormAnchor.java =================================================================== RCS file: Eclipse SWT/common/org/eclipse/swt/layout/FormAnchor.java diff -N Eclipse SWT/common/org/eclipse/swt/layout/FormAnchor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Eclipse SWT/common/org/eclipse/swt/layout/FormAnchor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.layout; + +import org.eclipse.swt.widgets.Control; + + +public class FormAnchor { + + public int minX = 0; + + boolean initialized = false; + int cacheX = 0; + Control[] cacheControls; + +void flushCache () { + initialized = false; + cacheX = minX; + cacheControls = new Control [0]; +} + +void addChild (Control child) { + Control[] newChildren = new Control [cacheControls.length + 1]; + System.arraycopy(cacheControls, 0, newChildren, 0, cacheControls.length); + newChildren[cacheControls.length] = child; + cacheControls = newChildren; +} + +FormAttachment getFormAttachment (Control control, int spacing, boolean flushCache) { + if (!initialized) { + if (cacheControls != null) { + int width = control.getParent().getClientArea().width; // ?? this isn't the right way to get the width + for (int i = 0; i < cacheControls.length; i++) { + Control child = cacheControls [i]; + FormData data = (FormData) child.getLayoutData (); + FormAttachment left = data.getLeftAttachment (child, spacing, flushCache).plus (data.getWidth (child, flushCache)); + int x2 = left.solveX (width); + if (data.right != null) + x2 -= data.right.offset; + cacheX = Math.max (cacheX, x2); + } + } + initialized = true; + } + return new FormAttachment (0, cacheX); +} +}