Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] problem about Canvas' max size.


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();
        }
}

Back to the top