Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » scolledComposite & canvas
scolledComposite & canvas [message #446043] Tue, 16 November 2004 15:54 Go to next message
Yue Ma is currently offline Yue MaFriend
Messages: 2
Registered: July 2009
Junior Member
Hi,all
I met some problems when I use SWT's Canvas control.
When I draw on Canvas the max size of Canvas only can extend to 32767, here
I set the max size 33000 so I can see the effect.
I don't know if this is a bug of Canvas or this is Windows control feature.
Can you give me some suggestions?
The following is the code I test.
Platform: WinXP Prefessional, Eclipse 3.0.1 RC.

public class Scroll {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(shell, SWT.HORIZONTAL |
SWT.VERTICAL);
sc.setLayout(new FillLayout());
final Canvas canvas = new Canvas(sc,0);
canvas.setSize(33000, 200);
sc.setContent(canvas);
sc.setMinSize(33000,33000);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);

canvas.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent arg0) {
// TODO Auto-generated method stub
GC gc = arg0.gc;
//here 33000 is bigger than 32767 so drawing operations is end at 32767.
gc.drawLine(0, 0, 33000, 200);
gc.dispose();
}
});

shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch()){
display.sleep();
}
}
display.dispose();
}
}
Re: scolledComposite & canvas [message #446045 is a reply to message #446043] Tue, 16 November 2004 16:28 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Rather than using ScrolledComposite, you should use the built in scroll
capabilities of Canvas.

See:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup

In the example, Shell is used but Shell can be replaced with Canvas.

"Yue MA" <mayue@cn.ibm.com> wrote in message
news:cnd7r5$kvs$1@www.eclipse.org...
> Hi,all
> I met some problems when I use SWT's Canvas control.
> When I draw on Canvas the max size of Canvas only can extend to 32767,
> here
> I set the max size 33000 so I can see the effect.
> I don't know if this is a bug of Canvas or this is Windows control
> feature.
> Can you give me some suggestions?
> The following is the code I test.
> Platform: WinXP Prefessional, Eclipse 3.0.1 RC.
>
> public class Scroll {
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> ScrolledComposite sc = new ScrolledComposite(shell, SWT.HORIZONTAL |
> SWT.VERTICAL);
> sc.setLayout(new FillLayout());
> final Canvas canvas = new Canvas(sc,0);
> canvas.setSize(33000, 200);
> sc.setContent(canvas);
> sc.setMinSize(33000,33000);
> sc.setExpandHorizontal(true);
> sc.setExpandVertical(true);
>
> canvas.addPaintListener(new PaintListener(){
> public void paintControl(PaintEvent arg0) {
> // TODO Auto-generated method stub
> GC gc = arg0.gc;
> //here 33000 is bigger than 32767 so drawing operations is end at 32767.
> gc.drawLine(0, 0, 33000, 200);
> gc.dispose();
> }
> });
>
> shell.open();
> while(!shell.isDisposed()){
> if(!display.readAndDispatch()){
> display.sleep();
> }
> }
> display.dispose();
> }
> }
>
>
Previous Topic:How to change the tooltip delay?
Next Topic:Problem with Table & CellEditor & mouse click
Goto Forum:
  


Current Time: Sat Oct 24 08:46:39 GMT 2020

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

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

Back to the top