Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Composite's Scrollbar issue
Composite's Scrollbar issue [message #537960] Fri, 04 June 2010 10:34 Go to next message
Jack Clouseau is currently offline Jack ClouseauFriend
Messages: 21
Registered: June 2010
Junior Member
Hi,

I have a composite (with SWT.H_Scroll and SWT.V_Scroll specifications when it's initialized) and have added some controls like Label and text on top of this. Am using GridLayout for this composite and have specified the grabExcessHorizontal and vertical as TRUE and also vertical and horizontalAlignment's as GridData.Fill.

But the problem is, when the screen is drawn, the scrollbars are showing by default even though its fully focus. And the other major issues is, when the workbench is resized( basically when it's minimized) these controls are going out of focus and even though the scrollbars are visible (and also selectable)...these are not functioning.

when i use the scrollbars to move....only the position of the scrolbar is moved and the composite's hidden area are is still not visible.

Can anyone suggest me anything on this issue?

The hierarchy of this composite on which its drawn is like this MyComposite -> CTabItem -> CTabFolder -> Section -> ManagedForm -> ScrolledForm -> Composite.

For all of these the layouts used is GridLayout with the similar GridData specifications as mentioned above for MyComposite....

Any suggestions at the earliest is much appreciated....

Thanks
Re: Composite's Scrollbar issue [message #538008 is a reply to message #537960] Fri, 04 June 2010 13:37 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
You probably want to use ScrolledComposite instead, it can manage much of
this for you, see http://www.eclipse.org/swt/snippets#scrolledcomposite .

Grant


"Jack" <sheki058@gmail.com> wrote in message
news:huakqs$l3n$1@build.eclipse.org...
> Hi,
>
> I have a composite (with SWT.H_Scroll and SWT.V_Scroll specifications when
it's initialized) and have added some controls like Label and text on top of
this. Am using GridLayout for this composite and have specified the
grabExcessHorizontal and vertical as TRUE and also vertical and
horizontalAlignment's as GridData.Fill.
>
> But the problem is, when the screen is drawn, the scrollbars are showing
by default even though its fully focus. And the other major issues is, when
the workbench is resized( basically when it's minimized) these controls are
going out of focus and even though the scrollbars are visible (and also
selectable)...these are not functioning.
>
> when i use the scrollbars to move....only the position of the scrolbar is
moved and the composite's hidden area are is still not visible.
>
> Can anyone suggest me anything on this issue?
>
> The hierarchy of this composite on which its drawn is like this
MyComposite -> CTabItem -> CTabFolder -> Section -> ManagedForm ->
ScrolledForm -> Composite.
>
> For all of these the layouts used is GridLayout with the similar GridData
specifications as mentioned above for MyComposite....
>
> Any suggestions at the earliest is much appreciated....
>
> Thanks
>
Re: Composite's Scrollbar issue [message #538240 is a reply to message #538008] Mon, 07 June 2010 04:40 Go to previous messageGo to next message
Jack Clouseau is currently offline Jack ClouseauFriend
Messages: 21
Registered: June 2010
Junior Member
Grant,

Thanks for the reply...i did even tried with ScrolledComposite before posting here...even that too didn''t work as expected.

Am pasting a sample code which you can run for yourself and check that the scrollbars eventhough it's visible and selectable still it doesn't do it's intended functionality.

This code is similar to the UI code of our project...please run this sample code and let me know..whether the scollbars are functioning in your system....if so, then please suggest me where i could be wrong...

If it;s not functional even in your system...please let me know how to make it work...

As far as i know, the code looks fine, but i gues i have missed out something and may be that is creating the problem....

here is the sample code:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
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.swt.widgets.Text;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ScrolledCompTest extends org.eclipse.swt.widgets.Composite {

/**
* Auto-generated main method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void main(String[] args) {
showGUI();
}

/**
* Overriding checkSubclass allows this class to extend org.eclipse.swt.widgets.Composite
*/
protected void checkSubclass() {
}

/**
* Auto-generated method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void showGUI() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
ScrolledCompTest inst = new ScrolledCompTest(shell, SWT.NULL);
Point size = inst.getSize();
shell.setLayout(new FillLayout());
shell.layout();
if(size.x == 0 && size.y == 0) {
inst.pack();
shell.pack();
} else {
Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
shell.setSize(shellBounds.width, shellBounds.height);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

public ScrolledCompTest(org.eclipse.swt.widgets.Composite parent, int style) {
super(parent, style);
initGUI();
}

private void initGUI() {
try {
GridLayout thisLayout = new GridLayout();
this.setLayout(thisLayout);
this.layout();

final ScrolledComposite scrollComposite = new ScrolledComposite(this, SWT.V_SCROLL | SWT.BORDER);
GridLayout scrolCompLyt = new GridLayout(1, false);
GridData scrolCompLytData = new GridData();
scrolCompLytData.widthHint = 230;
scrolCompLytData.heightHint = 200;
scrollComposite.setLayout(scrolCompLyt);
scrollComposite.setLayoutData(scrolCompLytData);

final Composite comp = new Composite(scrollComposite, SWT.H_SCROLL | SWT.V_SCROLL);
GridLayout compLyt = new GridLayout(2, false);
GridData compLytData = new GridData();
compLytData.widthHint = 300;
compLytData.heightHint = 200;
comp.setLayout(compLyt);
comp.setLayoutData(compLytData);

Label l = new Label(comp, SWT.BORDER);;
l.setText("this is sample lable");
GridData ldata = new GridData();
ldata.widthHint = 200;
l.setLayoutData(ldata);

Text t = new Text(comp, SWT.BORDER);
t.setText("hello");
GridData tdata = new GridData();
tdata.widthHint = 100;
t.setLayoutData(ldata);

scrollComposite.setContent(comp);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);


//pack();
} catch (Exception e) {
e.printStackTrace();
}
}

}



when you run this sample code...by default scroll bars are visible...since the TextField which has text "Hello" is not completely visible.....now when i try to move the scrollbar horizontally to view the hidden text, it doesn;t work...please let me know if you too have this issue....please revert back as soon as possible.....

NOTE::: Anybody can run this code and let me know if the scrollbars are functional...and if possible please tell me where am i going wrong!!!!!

Any suggestions at the earliest will be very grateful...

Thanks...
icon14.gif  Re: Composite's Scrollbar issue [message #538251 is a reply to message #538240] Mon, 07 June 2010 06:29 Go to previous message
Jack Clouseau is currently offline Jack ClouseauFriend
Messages: 21
Registered: June 2010
Junior Member
AllRight...

Guys i found out the problem where i was doing wrong...it was the layout issue. For the control on which we are going to draw the ScrolledComposite should have a "FillLayout"..this way it works...

You guys can check the modified below code which works exactly as expected...

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
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.swt.widgets.Text;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ScrolledCompTest extends org.eclipse.swt.widgets.Composite {

/**
* Auto-generated main method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void main(String[] args) {
showGUI();
}

/**
* Overriding checkSubclass allows this class to extend org.eclipse.swt.widgets.Composite
*/
protected void checkSubclass() {
}

/**
* Auto-generated method to display this
* org.eclipse.swt.widgets.Composite inside a new Shell.
*/
public static void showGUI() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
ScrolledCompTest inst = new ScrolledCompTest(shell, SWT.NULL);
Point size = inst.getSize();
shell.setLayout(new FillLayout());
shell.layout();
if(size.x == 0 && size.y == 0) {
inst.pack();
shell.pack();
} else {
Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
shell.setSize(shellBounds.width, shellBounds.height);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

public ScrolledCompTest(org.eclipse.swt.widgets.Composite parent, int style) {
super(parent, style);
initGUI();
}

private void initGUI() {
try {
FillLayout thisLayout = new FillLayout();
this.setLayout(thisLayout);
this.layout();

final ScrolledComposite scrollComposite = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite comp = new Composite(scrollComposite, SWT.NONE);
GridLayout compLyt = new GridLayout(2, false);
comp.setLayout(compLyt);

Label l = new Label(comp, SWT.BORDER);
l.setText("this is sample lable");
GridData lData = new GridData();
lData.widthHint = 200;
l.setLayoutData(lData);

Text t = new Text(comp, SWT.BORDER);
t.setText("hello");
GridData tData = new GridData();
tData.widthHint = 100;
t.setLayoutData(tData);

scrollComposite.setContent(comp);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));

} catch (Exception e) {
e.printStackTrace();
}
}

}

Anyways thanks to all the guys...who atleast gave a try on this.....

cheers Razz ,
Previous Topic:Migrating from 3.3 to eclipse 3.5
Next Topic:Why is IJobRunnable dependent on UI?
Goto Forum:
  


Current Time: Sun Dec 21 20:58:07 GMT 2014

Powered by FUDForum. Page generated in 0.11609 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software