Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to wrap text widget.
how to wrap text widget. [message #436935] Wed, 26 May 2004 13:01 Go to next message
Eclipse UserFriend
Originally posted by: mnaglik.NOSPAM.gazeta.pl

Hello,
I'm reading great article from eclipse.org
/Creating Your Own Widgets using SWT/
and have some problems wrapping text widget.

here are my questions:

1. how can I set the same size of widget as non wrapped widget?
(which method shoud i override?)

2. how can I aquire proper resizing of my control
(on rowlayout its getting bigger and bigger while resizing)

TIA
Marcin
my snippet:
----
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;

public class MyTest extends Composite {
private Text text;

public MyTest(Composite arg0, int arg1) {
super(arg0, SWT.NONE);
text = new Text(this, arg1);

addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
onResize();
}
});

addListener(SWT.FocusIn, new Listener() {
public void handleEvent(Event e) {
onFocusIn();
}
});

}

public Point computeSize(int wHint, int hHint) {
return text.computeSize(wHint, hHint, true);
}

public Rectangle computeTrim(int x, int y, int width, int height) {
return text.computeTrim(x, y, width, height);
}

void onResize() {
Rectangle area = getClientArea();
text.setBounds(0, 0, area.width, area.height);
}

void onFocusIn() {
text.setFocus();
}



}
Re: how to wrap text widget. [message #436937 is a reply to message #436935] Wed, 26 May 2004 13:19 Go to previous message
Eclipse UserFriend
Originally posted by: mnaglik.NOSPAM.gazeta.pl

marcin naglik wrote:
> 1. how can I set the same size of widget as non wrapped widget?
> (which method shoud i override?)

I found that
public Point computeSize(int wHint, int hHint,boolean arg) {
return text.computeSize(wHint, hHint, arg);
}

works ok for the size

marcin
Previous Topic:Dispose in Windows
Next Topic:Call dispose on application exit?
Goto Forum:
  


Current Time: Wed Apr 24 14:05:17 GMT 2024

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

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

Back to the top