Home » Eclipse Projects » Standard Widget Toolkit (SWT) » sizing Text
|
Re: sizing Text [message #467016 is a reply to message #467015] |
Sun, 22 January 2006 22:19 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Use the width hint but also use FILL_HORIZONTAL. Grab says to expand the
cell that the control is in to use whatever extra space is available,
but FILL tells it to ALSO size the control to that cell's width,
otherwise it will size the control only to the preferred size, which is
the width hint.
Carl Hagenmaier wrote:
> I am trying to create a WizardPage that contains, along with other
> things, a Text object. I want to size the WizardDialog, and let the
> Text fill the available horizontal space, REGARDLESS of the length of
> the string contained in the Text object.
>
> This seems like a reasonable configuration, but I can't figure out how
> to implement it.
>
> It seems that if I don't set width hint on the Text, when I add the
> wizard page it recomputes the size of the page based on the length of
> the actual string. In my case this means a HUGE dialog. If I set width
> hint, the Text object doesn't fill the dialog even though the GridData
> is set for grab horizontal.
>
> Any suggestions?
>
>
>
--
Thanks,
Rich Kulp
|
|
| |
Re: sizing Text [message #467021 is a reply to message #467017] |
Mon, 23 January 2006 03:29 |
Carl Hagenmaier Messages: 11 Registered: July 2009 |
Junior Member |
|
|
I've tried both of these suggestions, and ...
My problem is that I cannot get the "filling/grabbing" Text *AND* limit
the size of the dialog. I use WizardDialog.setPageSize(xsize, ysize) to
set the size I want. But along the way (WizardDialog.setWizard ->
updateSizeForWizard -> calculatePageSizeDelta) computeSize(SWT.DEFAULT,
SWT.DEFAULT, true) is called on the control for the WizardPage. Because
of the "SWT.DEFAULT", computeSize returns the size unrestricted by my
previous setPageSize, that is, it returns a size large enough to display
the entire string in the Text, that is, BIG.
I can debug and change the SWT.DEFAULTs in computeSize to xsize and ysize
and it works just fine. My gut says overriding methods in WizardDialog is
NOT the thing to do, but what else is there?
|
|
|
Re: sizing Text [message #467032 is a reply to message #467021] |
Mon, 23 January 2006 15:49 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
If you specify a widthHint for the GridData of the Text widget, this will be
used when computeSize(SWT.DEFAULT, SWT.DEFAULT) is called on the control
for the WizardPage.
public static void main (String [] args) {
String string = "Adding SWT Appeal to your Application\nSWT is a
widget toolkit for Java designed to provide efficient, portable access to
the user-interface facilities of the operating systems on which it is
implemented. It provides a rich set of native widgets for user interface
design. In 3.1 and 3.2, SWT has introduced many new features to
differentiate your application and give it polish. This talk will describe
ways you can use these features to spice up your application.";
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
Text t = new Text(parent, SWT.WRAP | SWT.BORDER);
t.setText(string);
GridData data = new GridData(SWT.FILL, SWT.TOP, true, false);
data.widthHint = 200;
t.setLayoutData(data);
Button b = new Button(parent, SWT.PUSH);
b.setText("Button 1");
b = new Button(parent, SWT.PUSH);
b.setText("Button 2");
b = new Button(parent, SWT.PUSH);
b.setText("Button 3");
b = new Button(parent, SWT.PUSH);
b.setText("Button 4");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
"Carl Hagenmaier" <carl@voxa.com> wrote in message
news:67def13b4bca8a7df7bf0402e58ea0d4$1@www.eclipse.org...
> I've tried both of these suggestions, and ...
>
> My problem is that I cannot get the "filling/grabbing" Text *AND* limit
> the size of the dialog. I use WizardDialog.setPageSize(xsize, ysize) to
> set the size I want. But along the way (WizardDialog.setWizard ->
> updateSizeForWizard -> calculatePageSizeDelta) computeSize(SWT.DEFAULT,
> SWT.DEFAULT, true) is called on the control for the WizardPage. Because
> of the "SWT.DEFAULT", computeSize returns the size unrestricted by my
> previous setPageSize, that is, it returns a size large enough to display
> the entire string in the Text, that is, BIG.
>
> I can debug and change the SWT.DEFAULTs in computeSize to xsize and ysize
> and it works just fine. My gut says overriding methods in WizardDialog is
> NOT the thing to do, but what else is there?
>
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 19:59:34 GMT 2024
Powered by FUDForum. Page generated in 0.02986 seconds
|