Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Platform - User Assistance (UA) » ScrolledFormText horizontal scrollbar (sorry for the cross-post)
ScrolledFormText horizontal scrollbar (sorry for the cross-post) [message #473828] Mon, 02 June 2008 05:46 Go to next message
Eclipse User
Originally posted by: fraserofthenight.gmail.com

Sorry about the cross-post, but in e.p.swt, it seemed like this was the
better place to ask, and I'm not sure if everyone checks both places. If
I did some serious internet faux-pas here by cross-posting, feel free to
put me into line with a few well-placed flames & death threats.

I'm using a ScrolledFormText (in Eclipse Forms 3.3.2) which I only want
to scroll vertically. However, when I place text in it that goes off the
form vertically, there is some slight horizontal scrolling (about the
width of a scrollbar ;-P). This is avoided if I set alwaysShowScrollbars
to true, but then there's always a horizontal scrollbar there just
staring at me with those two beady little arrows. So is there any way to
jut never have the horizontal scrolling or scrollbar at all?

Here's the snippet I was able to pare it down to:

package org.eclipse.swt.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.ScrolledFormText;

public class Snippet1
{
public static final String NO_TEXT = "<form></form>";

public static final String TEXT = "<form><p><b>Emit
Templates</b></p>" +
"<p>Controls whether or not template code is emitted:</p>" +
"<li>Auto -- For targets that support templates, the
\"All\" mode is used. Otherwise, the \"Private\" mode is used.</li>" +
"<li>Normal -- Emit templates, expecting multiple copies to
be merged by the linker.</li>" +
"<li>Private -- Emit templates, but make them private to
the translation unit. The executable will have multiple copies of code
and data.</li>" +
"<li>All -- Emit all template instances with public
visibility. Do this even if they would not normally be emitted.</li>" +
"<li>None -- Do not emit templates at all.</li></form>";

public static void main (String [] args)
{
Display display = new Display ();
Shell shell = new Shell(display);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
shell.setLayout(layout);

Group helpGroup = new Group(shell, SWT.SHADOW_IN);
GridData gd = new GridData();
gd.horizontalSpan = 1;
gd.widthHint = 225;
gd.heightHint = 200;
helpGroup.setLayoutData(gd);
layout = new GridLayout();
layout.numColumns = 1;
helpGroup.setLayout(layout);

final ScrolledFormText helpForm = new
ScrolledFormText(helpGroup, true);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 1;
helpForm.setLayoutData(gd);
//helpForm.setAlwaysShowScrollBars(true);
helpForm.setExpandVertical(true);
helpForm.setExpandHorizontal(false);
helpForm.setText(NO_TEXT);

Button switchButton = new Button(shell, SWT.PUSH);
gd = new GridData();
gd.horizontalSpan = 1;
switchButton.setLayoutData(gd);
switchButton.setText("Switch");
switchButton.addSelectionListener(new SelectionAdapter()
{
private boolean mode;

public void widgetSelected(SelectionEvent e)
{
if(mode)
helpForm.setText(NO_TEXT);
else
helpForm.setText(TEXT);
mode = !mode;
}
});

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

One more note: this only happens if the text is set during operation. If
I start with text that extends outside the form vertically, the
scrollbar is set correctly.

Thank you for your help,
Again, sorry about the cross-post,
All the best,
Robert
Re: ScrolledFormText horizontal scrollbar (sorry for the cross-post) [message #473831 is a reply to message #473828] Tue, 03 June 2008 12:03 Go to previous message
Eclipse User
Originally posted by: fraserofthenight.gmail.com

Robert Fraser wrote:
> Sorry about the cross-post, but in e.p.swt, it seemed like this was the
> better place to ask, and I'm not sure if everyone checks both places. If
> I did some serious internet faux-pas here by cross-posting, feel free to
> put me into line with a few well-placed flames & death threats.
>
> I'm using a ScrolledFormText (in Eclipse Forms 3.3.2) which I only want
> to scroll vertically. However, when I place text in it that goes off the
> form vertically, there is some slight horizontal scrolling (about the
> width of a scrollbar ;-P). This is avoided if I set alwaysShowScrollbars
> to true, but then there's always a horizontal scrollbar there just
> staring at me with those two beady little arrows. So is there any way to
> jut never have the horizontal scrolling or scrollbar at all?
>
> Here's the snippet I was able to pare it down to:
>
> package org.eclipse.swt.snippets;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.ui.forms.widgets.ScrolledFormText;
>
> public class Snippet1
> {
> public static final String NO_TEXT = "<form></form>";
>
> public static final String TEXT = "<form><p><b>Emit
> Templates</b></p>" +
> "<p>Controls whether or not template code is emitted:</p>" +
> "<li>Auto -- For targets that support templates, the \"All\"
> mode is used. Otherwise, the \"Private\" mode is used.</li>" +
> "<li>Normal -- Emit templates, expecting multiple copies to
> be merged by the linker.</li>" +
> "<li>Private -- Emit templates, but make them private to the
> translation unit. The executable will have multiple copies of code and
> data.</li>" +
> "<li>All -- Emit all template instances with public
> visibility. Do this even if they would not normally be emitted.</li>" +
> "<li>None -- Do not emit templates at all.</li></form>";
>
> public static void main (String [] args)
> {
> Display display = new Display ();
> Shell shell = new Shell(display);
> GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> shell.setLayout(layout);
>
> Group helpGroup = new Group(shell, SWT.SHADOW_IN);
> GridData gd = new GridData();
> gd.horizontalSpan = 1;
> gd.widthHint = 225;
> gd.heightHint = 200;
> helpGroup.setLayoutData(gd);
> layout = new GridLayout();
> layout.numColumns = 1;
> helpGroup.setLayout(layout);
>
> final ScrolledFormText helpForm = new
> ScrolledFormText(helpGroup, true);
> gd = new GridData(GridData.FILL_BOTH);
> gd.horizontalSpan = 1;
> helpForm.setLayoutData(gd);
> //helpForm.setAlwaysShowScrollBars(true);
> helpForm.setExpandVertical(true);
> helpForm.setExpandHorizontal(false);
> helpForm.setText(NO_TEXT);
>
> Button switchButton = new Button(shell, SWT.PUSH);
> gd = new GridData();
> gd.horizontalSpan = 1;
> switchButton.setLayoutData(gd);
> switchButton.setText("Switch");
> switchButton.addSelectionListener(new SelectionAdapter()
> {
> private boolean mode;
>
> public void widgetSelected(SelectionEvent e)
> {
> if(mode)
> helpForm.setText(NO_TEXT);
> else
> helpForm.setText(TEXT);
> mode = !mode;
> }
> });
>
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> One more note: this only happens if the text is set during operation. If
> I start with text that extends outside the form vertically, the
> scrollbar is set correctly.
>
> Thank you for your help,
> Again, sorry about the cross-post,
> All the best,
> Robert

Sorry, this has been resolved in the SWT group. Thanks for putting up w/
the cross-post.
Re: ScrolledFormText horizontal scrollbar (sorry for the cross-post) [message #614397 is a reply to message #473828] Tue, 03 June 2008 12:03 Go to previous message
Eclipse User
Originally posted by: fraserofthenight.gmail.com

Robert Fraser wrote:
> Sorry about the cross-post, but in e.p.swt, it seemed like this was the
> better place to ask, and I'm not sure if everyone checks both places. If
> I did some serious internet faux-pas here by cross-posting, feel free to
> put me into line with a few well-placed flames & death threats.
>
> I'm using a ScrolledFormText (in Eclipse Forms 3.3.2) which I only want
> to scroll vertically. However, when I place text in it that goes off the
> form vertically, there is some slight horizontal scrolling (about the
> width of a scrollbar ;-P). This is avoided if I set alwaysShowScrollbars
> to true, but then there's always a horizontal scrollbar there just
> staring at me with those two beady little arrows. So is there any way to
> jut never have the horizontal scrolling or scrollbar at all?
>
> Here's the snippet I was able to pare it down to:
>
> package org.eclipse.swt.snippets;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.ui.forms.widgets.ScrolledFormText;
>
> public class Snippet1
> {
> public static final String NO_TEXT = "<form></form>";
>
> public static final String TEXT = "<form><p><b>Emit
> Templates</b></p>" +
> "<p>Controls whether or not template code is emitted:</p>" +
> "<li>Auto -- For targets that support templates, the \"All\"
> mode is used. Otherwise, the \"Private\" mode is used.</li>" +
> "<li>Normal -- Emit templates, expecting multiple copies to
> be merged by the linker.</li>" +
> "<li>Private -- Emit templates, but make them private to the
> translation unit. The executable will have multiple copies of code and
> data.</li>" +
> "<li>All -- Emit all template instances with public
> visibility. Do this even if they would not normally be emitted.</li>" +
> "<li>None -- Do not emit templates at all.</li></form>";
>
> public static void main (String [] args)
> {
> Display display = new Display ();
> Shell shell = new Shell(display);
> GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> shell.setLayout(layout);
>
> Group helpGroup = new Group(shell, SWT.SHADOW_IN);
> GridData gd = new GridData();
> gd.horizontalSpan = 1;
> gd.widthHint = 225;
> gd.heightHint = 200;
> helpGroup.setLayoutData(gd);
> layout = new GridLayout();
> layout.numColumns = 1;
> helpGroup.setLayout(layout);
>
> final ScrolledFormText helpForm = new
> ScrolledFormText(helpGroup, true);
> gd = new GridData(GridData.FILL_BOTH);
> gd.horizontalSpan = 1;
> helpForm.setLayoutData(gd);
> //helpForm.setAlwaysShowScrollBars(true);
> helpForm.setExpandVertical(true);
> helpForm.setExpandHorizontal(false);
> helpForm.setText(NO_TEXT);
>
> Button switchButton = new Button(shell, SWT.PUSH);
> gd = new GridData();
> gd.horizontalSpan = 1;
> switchButton.setLayoutData(gd);
> switchButton.setText("Switch");
> switchButton.addSelectionListener(new SelectionAdapter()
> {
> private boolean mode;
>
> public void widgetSelected(SelectionEvent e)
> {
> if(mode)
> helpForm.setText(NO_TEXT);
> else
> helpForm.setText(TEXT);
> mode = !mode;
> }
> });
>
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> One more note: this only happens if the text is set during operation. If
> I start with text that extends outside the form vertically, the
> scrollbar is set correctly.
>
> Thank you for your help,
> Again, sorry about the cross-post,
> All the best,
> Robert

Sorry, this has been resolved in the SWT group. Thanks for putting up w/
the cross-post.
Previous Topic:Dynamic Help
Next Topic:simple cheatsheet editor doesn't support command results property?
Goto Forum:
  


Current Time: Thu Aug 28 07:18:04 EDT 2014

Powered by FUDForum. Page generated in 0.04428 seconds