### Eclipse Workspace Patch 1.0 #P org.eclipse.swt.snippets Index: src/org/eclipse/swt/snippets/Snippet253.java =================================================================== RCS file: src/org/eclipse/swt/snippets/Snippet253.java diff -N src/org/eclipse/swt/snippets/Snippet253.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/swt/snippets/Snippet253.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 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.snippets; + +/* + * example snippet: Hello World + * + * For a list of all SWT example snippets see + * http://www.eclipse.org/swt/snippets/ + */ +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.*; + +public class Snippet253 { + +public static void main (String [] args) { + Display display = new Display (); + Shell shell = new Shell(display); + shell.setLayout(new FillLayout()); + Group group = new Group(shell,SWT.NONE); + group.setLayout(new RowLayout()); + + Button b = new Button(group,SWT.PUSH); + b.setText("50%-Fixed"); + b.setLayoutData(new RowData(SWT.DEFAULT,SWT.DEFAULT,1,0)); + + b = new Button(group,SWT.PUSH); + b.setText("Fixed"); + b.setLayoutData(new RowData(100,SWT.DEFAULT)); + + b = new Button(group,SWT.PUSH); + b.setText("50%-Fixed"); + b.setLayoutData(new RowData(SWT.DEFAULT,SWT.DEFAULT,1,0)); + + shell.open (); + while (!shell.isDisposed ()) { + if (!display.readAndDispatch ()) display.sleep (); + } + display.dispose (); +} +} #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 14:02:46 -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)(data.widthWeight/totalWidthWeight*containerWidth):data.width ); + hHint = Math.max(data.height, (data.heightWeight > 0)?(int)(data.heightWeight/totalHeightWeight*containerHeight):data.height); } return control.computeSize (wHint, hHint, flushCache); } @@ -229,21 +229,46 @@ Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) { Control [] children = composite.getChildren (); int count = 0; + + Rectangle rect = composite.getClientArea (); + int totalWidthWeight = 0; + int totalHeightWeight = 0; + int heightToUse=rect.height - (marginTop + marginHeight * 2 + marginBottom); + int widthToUse=rect.width - (marginLeft + marginWidth * 2 + marginRight); + for (int i=0; i