Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 89896 Details for
Bug 219206
FormLayout - add the ability to vertically align multiple items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to FormLayout
FormLayout.patch (text/plain), 7.84 KB, created by
Veronika Irvine
on 2008-02-15 19:45:32 EST
(
hide
)
Description:
Patch to FormLayout
Filename:
MIME Type:
Creator:
Veronika Irvine
Created:
2008-02-15 19:45:32 EST
Size:
7.84 KB
patch
obsolete
>### 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<children.length; i++) { > Control child = children [i]; > FormData data = (FormData) child.getLayoutData (); > if (data == null) child.setLayoutData (data = new FormData ()); >+ if (data.right != null && data.right.anchor != null) { >+ FormAnchor anchor = data.right.anchor; >+ for (int j = 0; j < anchors.length; j++) { >+ if (anchors [j] == anchor) break; >+ if (anchors [j] == null) { >+ anchors [j] = anchor; >+ anchor.flushCache (); >+ break; >+ } >+ } >+ anchor.addChild (child); >+ } > if (flushCache) data.flushCache (); > data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null; > } >Index: Eclipse SWT/common/org/eclipse/swt/layout/FormData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormData.java,v >retrieving revision 1.34 >diff -u -r1.34 FormData.java >--- Eclipse SWT/common/org/eclipse/swt/layout/FormData.java 9 May 2006 19:47:04 -0000 1.34 >+++ Eclipse SWT/common/org/eclipse/swt/layout/FormData.java 16 Feb 2008 00:30:36 -0000 >@@ -197,8 +197,12 @@ > if (isVisited) return cacheLeft = new FormAttachment (0, 0); > if (left == null) { > if (right == null) return cacheLeft = new FormAttachment (0, 0); >+ if (right.anchor != null && !right.anchor.initialized) return new FormAttachment (0, 0); // ?? workaround for inifinite loop > return cacheLeft = getRightAttachment (control, spacing, flushCache).minus (getWidth (control, flushCache)); > } >+ if (left.anchor != null) { >+ return cacheLeft = left.anchor.getFormAttachment (control, spacing, flushCache).plus (left.offset + spacing); >+ } > Control leftControl = left.control; > if (leftControl != null) { > if (leftControl.isDisposed ()) { >@@ -239,13 +243,21 @@ > return string.substring (index + 1, string.length ()); > } > >+FormAnchor getRightAnchor () { >+ return right == null ? null : right.anchor; >+} >+ > FormAttachment getRightAttachment (Control control, int spacing, boolean flushCache) { > if (cacheRight != null) return cacheRight; > if (isVisited) return cacheRight = new FormAttachment (0, getWidth (control, flushCache)); > if (right == null) { > if (left == null) return cacheRight = new FormAttachment (0, getWidth (control, flushCache)); >+ if (left.anchor != null && !left.anchor.initialized) return new FormAttachment (0, getWidth (control, flushCache)); // ??? workaround fo infinite loop > return cacheRight = getLeftAttachment (control, spacing, flushCache).plus (getWidth (control, flushCache)); > } >+ if (right.anchor != null) { >+ return cacheRight = right.anchor.getFormAttachment (control, spacing, flushCache).plus (right.offset - spacing); >+ } > Control rightControl = right.control; > if (rightControl != null) { > if (rightControl.isDisposed ()) { >Index: Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java,v >retrieving revision 1.24 >diff -u -r1.24 FormAttachment.java >--- Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java 9 May 2006 19:47:04 -0000 1.24 >+++ Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java 16 Feb 2008 00:30:36 -0000 >@@ -128,6 +128,8 @@ > * </ul> > */ > 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); >+} >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 219206
:
89895
| 89896