View | Details | Raw Unified | Return to bug 219206
Collapse All | Expand All

(-)Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java (+6 lines)
Lines 77-82 Link Here
77
 */
77
 */
78
public ToolItem (ToolBar parent, int style) {
78
public ToolItem (ToolBar parent, int style) {
79
	super (parent, checkStyle (style));
79
	super (parent, checkStyle (style));
80
	if ((style & SWT.CHECK) != 0){
81
		System.out.println("check item");
82
	}
80
	this.parent = parent;
83
	this.parent = parent;
81
	parent.createItem (this, parent.getItemCount ());
84
	parent.createItem (this, parent.getItemCount ());
82
}
85
}
Lines 119-124 Link Here
119
 */
122
 */
120
public ToolItem (ToolBar parent, int style, int index) {
123
public ToolItem (ToolBar parent, int style, int index) {
121
	super (parent, checkStyle (style));
124
	super (parent, checkStyle (style));
125
	if ((style & SWT.CHECK) != 0){
126
		System.out.println("check item");
127
	}
122
	this.parent = parent;
128
	this.parent = parent;
123
	parent.createItem (this, index);
129
	parent.createItem (this, index);
124
}
130
}
(-)Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java (+13 lines)
Lines 286-295 Link Here
286
286
287
Point layout (Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache) {
287
Point layout (Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache) {
288
	Control [] children = composite.getChildren ();
288
	Control [] children = composite.getChildren ();
289
	FormAnchor[] anchors = new FormAnchor [children.length];
289
	for (int i=0; i<children.length; i++) {
290
	for (int i=0; i<children.length; i++) {
290
		Control child = children [i];
291
		Control child = children [i];
291
		FormData data = (FormData) child.getLayoutData ();
292
		FormData data = (FormData) child.getLayoutData ();
292
		if (data == null) child.setLayoutData (data = new FormData ());
293
		if (data == null) child.setLayoutData (data = new FormData ());
294
		if (data.right != null && data.right.anchor != null) {
295
			FormAnchor anchor = data.right.anchor;
296
			for (int j = 0; j < anchors.length; j++) {
297
				if (anchors [j] == anchor) break;
298
				if (anchors [j] == null) {
299
					anchors [j] = anchor;
300
					anchor.flushCache ();
301
					break;
302
				}
303
			}
304
			anchor.addChild (child);
305
		}
293
		if (flushCache) data.flushCache ();
306
		if (flushCache) data.flushCache ();
294
		data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
307
		data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
295
	}
308
	}
(-)Eclipse SWT/common/org/eclipse/swt/layout/FormData.java (+12 lines)
Lines 197-204 Link Here
197
	if (isVisited) return cacheLeft = new FormAttachment (0, 0);
197
	if (isVisited) return cacheLeft = new FormAttachment (0, 0);
198
	if (left == null) {
198
	if (left == null) {
199
		if (right == null) return cacheLeft = new FormAttachment (0, 0);
199
		if (right == null) return cacheLeft = new FormAttachment (0, 0);
200
		if (right.anchor != null && !right.anchor.initialized) return new FormAttachment (0, 0); // ?? workaround for inifinite loop
200
		return cacheLeft = getRightAttachment (control, spacing, flushCache).minus (getWidth (control, flushCache));
201
		return cacheLeft = getRightAttachment (control, spacing, flushCache).minus (getWidth (control, flushCache));
201
	}
202
	}
203
	if (left.anchor != null) {
204
		return cacheLeft = left.anchor.getFormAttachment (control, spacing, flushCache).plus (left.offset + spacing);
205
	}
202
	Control leftControl = left.control;
206
	Control leftControl = left.control;
203
	if (leftControl != null) {
207
	if (leftControl != null) {
204
		if (leftControl.isDisposed ()) {
208
		if (leftControl.isDisposed ()) {
Lines 239-251 Link Here
239
	return string.substring (index + 1, string.length ());
243
	return string.substring (index + 1, string.length ());
240
}
244
}
241
245
246
FormAnchor getRightAnchor () {
247
	return right == null ? null : right.anchor;
248
}
249
242
FormAttachment getRightAttachment (Control control, int spacing, boolean flushCache) {
250
FormAttachment getRightAttachment (Control control, int spacing, boolean flushCache) {
243
	if (cacheRight != null) return cacheRight;
251
	if (cacheRight != null) return cacheRight;
244
	if (isVisited) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
252
	if (isVisited) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
245
	if (right == null) {
253
	if (right == null) {
246
		if (left == null) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
254
		if (left == null) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
255
		if (left.anchor != null && !left.anchor.initialized) return new FormAttachment (0, getWidth (control, flushCache)); // ??? workaround fo infinite loop
247
		return cacheRight = getLeftAttachment (control, spacing, flushCache).plus (getWidth (control, flushCache));
256
		return cacheRight = getLeftAttachment (control, spacing, flushCache).plus (getWidth (control, flushCache));
248
	}
257
	}
258
	if (right.anchor != null) {
259
		return cacheRight = right.anchor.getFormAttachment (control, spacing, flushCache).plus (right.offset - spacing);
260
	}
249
	Control rightControl = right.control;
261
	Control rightControl = right.control;
250
	if (rightControl != null) {
262
	if (rightControl != null) {
251
		if (rightControl.isDisposed ()) {
263
		if (rightControl.isDisposed ()) {
(-)Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java (+11 lines)
Lines 128-133 Link Here
128
	 * </ul>
128
	 * </ul>
129
	 */
129
	 */
130
	public int alignment;
130
	public int alignment;
131
	
132
	public FormAnchor anchor;
131
133
132
/**
134
/**
133
 * Constructs a new instance of this class.
135
 * Constructs a new instance of this class.
Lines 225-230 Link Here
225
	this.alignment = alignment;
227
	this.alignment = alignment;
226
}
228
}
227
229
230
public FormAttachment (FormAnchor anchor) {
231
	this.anchor = anchor;
232
}
233
234
public FormAttachment (FormAnchor anchor, int offset) {
235
	this.anchor = anchor;
236
	this.offset = offset;
237
}
238
228
FormAttachment divide (int value) {
239
FormAttachment divide (int value) {
229
	return new FormAttachment (numerator, denominator * value, offset / value);
240
	return new FormAttachment (numerator, denominator * value, offset / value);
230
}
241
}
(-)Eclipse (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.swt.layout;
12
13
import org.eclipse.swt.widgets.Control;
14
15
16
public class FormAnchor {
17
18
	public int minX = 0;
19
	
20
	boolean initialized = false;
21
	int cacheX = 0;
22
	Control[] cacheControls;
23
	
24
void flushCache () {
25
	initialized = false;
26
	cacheX = minX;
27
	cacheControls = new Control [0];
28
}
29
30
void addChild (Control child) {
31
	Control[] newChildren = new Control [cacheControls.length + 1];
32
	System.arraycopy(cacheControls, 0, newChildren, 0, cacheControls.length);
33
	newChildren[cacheControls.length] = child;
34
	cacheControls = newChildren;
35
}
36
37
FormAttachment getFormAttachment (Control control, int spacing, boolean flushCache) {
38
	if (!initialized) {
39
		if (cacheControls != null) {
40
			int width = control.getParent().getClientArea().width; // ?? this isn't the right way to get the width
41
			for (int i = 0; i < cacheControls.length; i++) {
42
				Control child = cacheControls [i];
43
				FormData data = (FormData) child.getLayoutData ();
44
				FormAttachment left = data.getLeftAttachment (child, spacing, flushCache).plus (data.getWidth (child, flushCache));
45
				int x2 = left.solveX (width);
46
				if (data.right != null)
47
					x2 -= data.right.offset;
48
				cacheX = Math.max (cacheX, x2);
49
			}
50
		}
51
		initialized = true;
52
	}
53
	return new FormAttachment (0, cacheX);
54
}
55
}

Return to bug 219206