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 56758 Details for
Bug 170201
And possibility to use percentage values for height and width for GridLayout/RowLayout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Example Patch for RowLayout/RowData
clipboard17020.txt (text/plain), 6.72 KB, created by
Thomas Schindl
on 2007-01-11 07:09:58 EST
(
hide
)
Description:
Example Patch for RowLayout/RowData
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2007-01-11 07:09:58 EST
Size:
6.72 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java,v >retrieving revision 1.34 >diff -u -r1.34 RowLayout.java >--- Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java 9 May 2006 19:47:04 -0000 1.34 >+++ Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java 11 Jan 2007 12:01:34 -0000 >@@ -196,12 +196,12 @@ > return extent; > } > >-Point computeSize (Control control, boolean flushCache) { >+Point computeSize (Control control, boolean flushCache, double totalWidthWeight, double totalHeightWeight, int containerWidth, int containerHeight) { > int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT; > RowData data = (RowData) control.getLayoutData (); > if (data != null) { >- wHint = data.width; >- hHint = data.height; >+ wHint = Math.max(data.width, (data.widthWeight > 0)?(int)(totalWidthWeight/data.widthWeight*containerWidth):data.width ); >+ hHint = Math.max(data.height, (data.heightWeight > 0)?(int)(totalHeightWeight/data.heightWeight*containerHeight):data.height); > } > return control.computeSize (wHint, hHint, flushCache); > } >@@ -229,21 +229,30 @@ > Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) { > Control [] children = composite.getChildren (); > int count = 0; >+ int totalWidthWeight = 0; >+ int totalHeightWeight = 0; >+ > for (int i=0; i<children.length; i++) { > Control control = children [i]; > RowData data = (RowData) control.getLayoutData (); > if (data == null || !data.exclude) { > children [count++] = children [i]; >+ if( data != null ) { >+ totalWidthWeight += data.widthWeight; >+ totalHeightWeight += data.heightWeight; >+ } > } > } > if (count == 0) { > return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); > } > int childWidth = 0, childHeight = 0, maxHeight = 0; >+ >+ Rectangle rect = composite.getClientArea (); > if (!pack) { > for (int i=0; i<count; i++) { > Control child = children [i]; >- Point size = computeSize (child, flushCache); >+ Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,rect.width,rect.height); > childWidth = Math.max (childWidth, size.x); > childHeight = Math.max (childHeight, size.y); > } >@@ -251,7 +260,7 @@ > } > int clientX = 0, clientY = 0; > if (move) { >- Rectangle rect = composite.getClientArea (); >+ > clientX = rect.x; > clientY = rect.y; > } >@@ -266,7 +275,7 @@ > for (int i=0; i<count; i++) { > Control child = children [i]; > if (pack) { >- Point size = computeSize (child, flushCache); >+ Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,rect.width,rect.height); > childWidth = size.x; > childHeight = size.y; > } >@@ -336,21 +345,30 @@ > Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) { > Control [] children = composite.getChildren (); > int count = 0; >+ int totalWidthWeight = 0; >+ int totalHeightWeight = 0; >+ > for (int i=0; i<children.length; i++) { > Control control = children [i]; > RowData data = (RowData) control.getLayoutData (); > if (data == null || !data.exclude) { > children [count++] = children [i]; >+ if( data != null ) { >+ totalWidthWeight += data.widthWeight; >+ totalHeightWeight += data.heightWeight; >+ } > } > } > if (count == 0) { > return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); > } > int childWidth = 0, childHeight = 0, maxWidth = 0; >+ Rectangle rect = composite.getClientArea (); >+ > if (!pack) { > for (int i=0; i<count; i++) { > Control child = children [i]; >- Point size = computeSize (child, flushCache); >+ Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,rect.width,rect.height); > childWidth = Math.max (childWidth, size.x); > childHeight = Math.max (childHeight, size.y); > } >@@ -358,7 +376,7 @@ > } > int clientX = 0, clientY = 0; > if (move) { >- Rectangle rect = composite.getClientArea (); >+ > clientX = rect.x; > clientY = rect.y; > } >@@ -373,7 +391,7 @@ > for (int i=0; i<count; i++) { > Control child = children [i]; > if (pack) { >- Point size = computeSize (child, flushCache); >+ Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,rect.width,rect.height); > childWidth = size.x; > childHeight = size.y; > } >Index: Eclipse SWT/common/org/eclipse/swt/layout/RowData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java,v >retrieving revision 1.23 >diff -u -r1.23 RowData.java >--- Eclipse SWT/common/org/eclipse/swt/layout/RowData.java 9 May 2006 19:47:04 -0000 1.23 >+++ Eclipse SWT/common/org/eclipse/swt/layout/RowData.java 11 Jan 2007 12:01:33 -0000 >@@ -67,6 +67,22 @@ > */ > public boolean exclude = false; > >+ /** >+ * widthWeight specifies the preferred width in comparison with the other >+ * controls who are children of this container. In conjunction with this >+ * value {@link #width} acts as the minimum value which and the maximum >+ * is passed into Control.computeSize(int, int, boolean) >+ */ >+ public int widthWeight = 0; >+ >+ /** >+ * heightWeight specifies the preferred height in comparison with the other >+ * controls who are children of this container. In conjunction with this >+ * value {@link #height} acts as the minimum value which and the maximum >+ * is passed into Control.computeSize(int, int, boolean) >+ */ >+ public int heightWeight = 0; >+ > /** > * Constructs a new instance of RowData using > * default values. >@@ -88,6 +104,23 @@ > } > > /** >+ * Constructs a new instance of RowData according to the parameters. >+ * A value of SWT.DEFAULT indicates that no minimum width or >+ * no minimum height is specified. >+ * >+ * @param width a minimum width for the control >+ * @param height a minimum height for the control >+ * @param widthWeight the width weight of the control in comparison with other controls >+ * @param heightWeight the height weight of the control in comparison with other controls >+ */ >+public RowData (int width, int height, int widthWeight, int heightWeight) { >+ this.width = width; >+ this.height = height; >+ this.widthWeight = widthWeight; >+ this.heightWeight = heightWeight; >+} >+ >+/** > * Constructs a new instance of RowData according to the parameter. > * A value of SWT.DEFAULT indicates that no minimum width or > * no minimum height is specified.
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 170201
:
56758
|
56761