Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] About RowLayout (SWT3.0 vs SWT3.4)


What's 3.0?  <g>

Between 3.0 and now, SWT layout was fixed to handle the wrapping case.  Before that, you had to explicitly force the wrapping by setting the width hint.  The follow code works on 3.0 and 3.5:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class RowLayoutTester {
        /**
         * @param args
         */
        public static void main(String[] args) {
                final Display display = Display.getDefault();
                final Shell shell = new Shell();
                shell.setSize(327, 253);
                shell.setText("SWT Application");
                shell.setLayout(new GridLayout(1, true));
                final Composite parent = new Composite(shell, SWT.BORDER);
                final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
                parent.setLayoutData(gridData);
                final RowLayout layout = new RowLayout();
                parent.setLayout(layout);
                for (int i = 0; i < 10; i++) {
                        CLabel simulatorLabel = new CLabel(parent, SWT.WRAP);
                        simulatorLabel.setText("Simulator" + i);
                }
                shell.addListener(SWT.Resize, new Listener () {
                        public void handleEvent(Event event) {
                                gridData.widthHint = parent.getClientArea().width;
                        }
                });
                shell.layout();
                shell.open();
                while (!shell.isDisposed()) {
                        if (!display.readAndDispatch())
                                display.sleep();
                }
                display.dispose();
        }
}


xuqingkang2 <xuqingkang2@xxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

02/12/2009 12:50 AM

Please respond to
"Eclipse Platform SWT component developers list."        <platform-swt-dev@xxxxxxxxxxx>

To
swt-dev <platform-swt-dev@xxxxxxxxxxx>
cc
Subject
[platform-swt-dev] About RowLayout (SWT3.0 vs SWT3.4)





Hello everybody!
I have code like following:
-------------------------------------
package basic;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class RowLayoutTester {
/**
 * @param args
 */
public static void main(String[] args) {
 final Display display = Display.getDefault();
 final Shell shell = new Shell();
 shell.setSize(327, 253);
 shell.setText("SWT Application");
 shell.setLayout(new GridLayout(1,true));
 Composite parent = new Composite(shell, SWT.BORDER);
 parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 parent.setLayout(new RowLayout());
 for (int i = 0; i < 10; i++) {
  CLabel simulatorLabel = new CLabel(parent, SWT.WRAP);
  simulatorLabel.setText("Simulator" + i);
 }
 shell.layout();
 shell.open();
 while (!shell.isDisposed()) {
  if (!display.readAndDispatch())
   display.sleep();
 }
 display.dispose();
}
}
-------------------------------------
1,When i run this app in swt3.0(version 3.064):
--1.1,screen is shown like "RowLayout3.0.JPG"(only one row and not wrap all the CLabel).
--1.2,and when i changing the shell's size,the screen also not wrap all the CLabel.
2,When i run this app in swt3.4(version 3.449):
--2.1,screen is shown like "RowLayout3.4.JPG"(automatically wrap all the CLabel in multi-row).
--2.2,when i changing the shell's size,the row will increase or decrease,and all the CLabel will be wrapped in rows.

it is the SWT3.0's bug?
or
how can i do in swt3.0 for all the CLabel can be wrapped in rows.

Thanks in advance.

qingkang xu.


网易邮箱,中国第一大电子邮件服务商 _______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

Attachment: RowLayout3.4.JPG
Description: JPEG image

Attachment: RowLayout3.0.JPG
Description: JPEG image


Back to the top