Scroll within a tableItem [message #532566] |
Mon, 10 May 2010 13:15 |
|
I have a tableItem which its control extends the size of the screen, but I can't get to add a scroll. I was able to add a scroll, but it didn't reach the the end of the tableItem. I wrote a short program which illustrates the problem (my code is much more complex and I use a lot of layers).
The example includes a tabFolder with a single tabItem. I added a grid layout with 5 labels. When I shrink the dialog, I can't see the right end of the strings.
here is the code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
public class SimulateView {
static public void main(){
Shell m_shell;
Display display = PlatformUI.getWorkbench().getDisplay();
m_shell = new Shell(display, SWT.SHELL_TRIM /*| SWT.SCROLL_LINE/*| SWT.H_SCROLL | SWT.CLIP_CHILDREN | SWT.CLIP_SIBLINGS*/ /*| SWT.SCROLL_PAGE*/);
m_shell.setText("Simulation");
FillLayout flayout = new FillLayout(SWT.FILL);
flayout.marginHeight = 0;
flayout.marginWidth = 5;
m_shell.setLayout(flayout);
//create the tab folder
CTabFolder tab = new CTabFolder(m_shell, SWT.TOP );
//create the tab item
CTabItem item = new CTabItem(tab, SWT.RESIZE | SWT.H_SCROLL);
item.setText("tab Item");
//create the top 3 labels
Composite topcomposite = new Composite(tab, SWT.RESIZE | SWT.SCROLL_PAGE);
topcomposite.setLayout(new GridLayout(5, true));
new Label(topcomposite, SWT.NONE).setText("first Lable ");
new Label(topcomposite, SWT.NONE).setText(" ");
new Label(topcomposite, SWT.NONE).setText("second Lable");
new Label(topcomposite, SWT.NONE).setText(" ");
new Label(topcomposite, SWT.NONE).setText("third Lable ");
item.setControl(topcomposite);
m_shell.open();
}
}
I couldn't figure out how to add a PNG of my dialog.
Thanks,
Nir
|
|
|
Re: Scroll within a tableItem [message #532567 is a reply to message #532566] |
Mon, 10 May 2010 13:19 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You need to use a ScrolledComposite inside the TabItem.
Tom
Am 10.05.10 15:15, schrieb nir dweck:
> I have a tableItem which its control extends the size of the screen, but
> I can't get to add a scroll. I was able to add a scroll, but it didn't
> reach the the end of the tableItem. I wrote a short program which
> illustrates the problem (my code is much more complex and I use a lot of
> layers). The example includes a tabFolder with a single tabItem. I added
> a grid layout with 5 labels. When I shrink the dialog, I can't see the
> right end of the strings.
> here is the code:
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.CTabFolder;
> import org.eclipse.swt.custom.CTabItem;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.ui.PlatformUI;
>
> public class SimulateView {
>
> static public void main(){
> Shell m_shell;
> Display display = PlatformUI.getWorkbench().getDisplay();
> m_shell = new Shell(display, SWT.SHELL_TRIM /*|
> SWT.SCROLL_LINE/*| SWT.H_SCROLL | SWT.CLIP_CHILDREN |
> SWT.CLIP_SIBLINGS*/ /*| SWT.SCROLL_PAGE*/);
> m_shell.setText("Simulation");
> FillLayout flayout = new FillLayout(SWT.FILL);
> flayout.marginHeight = 0;
> flayout.marginWidth = 5;
> m_shell.setLayout(flayout);
> //create the tab folder
> CTabFolder tab = new CTabFolder(m_shell, SWT.TOP );
> //create the tab item
> CTabItem item = new CTabItem(tab, SWT.RESIZE | SWT.H_SCROLL);
> item.setText("tab Item");
> //create the top 3 labels
> Composite topcomposite = new Composite(tab, SWT.RESIZE |
> SWT.SCROLL_PAGE);
> topcomposite.setLayout(new GridLayout(5, true));
>
> new Label(topcomposite, SWT.NONE).setText("first Lable ");
> new Label(topcomposite, SWT.NONE).setText(" ");
> new Label(topcomposite, SWT.NONE).setText("second Lable");
> new Label(topcomposite, SWT.NONE).setText(" ");
> new Label(topcomposite, SWT.NONE).setText("third Lable ");
> item.setControl(topcomposite);
> m_shell.open();
> }
> }
>
> I couldn't figure out how to add a PNG of my dialog.
> Thanks,
> Nir
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03118 seconds