Bonjour,

j'ai un canvas avec un scroll et un simple rectangle dessiner dan le canvas.
Lorsque je bouge le scroll, il n'y a aucun effet sur le canvas. rien ne bouge !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
 
public class WeeklyPlanningCanvas extends Canvas{
 
 
	private static final float 	MARGIN = 40;// la marge autour du planning
	private float              	scale = 1f;// l'échelle du planning
 
 
	public WeeklyPlanningCanvas(Composite parent, int style, WeeklyPlanningController controller) {
		super(parent, style);
		this.controller = controller;
 
 
		Point point = new Point(
	            Math.round(((float) getPlanningBounds().getWidth() + MARGIN * 2)
	                       * scale) + 2 * getBorderWidth(),
	            Math.round(((float) getPlanningBounds().getHeight() + MARGIN * 2)
	                       * scale) + 2 * getBorderWidth());
		this.computeSize(point.x, point.y);
		//ajoute des listeners sur le planning
		addCanvasListener();
	}
 
	public Rectangle2D getPlanningBounds(){
		return new Rectangle2D.Float(0, 0, 1000, 1000 );
	}
 
	/**
         * Ajoute un listener 
         * 
         */
	private void addCanvasListener() {
		this.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent event) {					
				WeeklyPlanningCanvas.this.paintControl(event.gc);
			}
		});
	    this.addListener(SWT.Resize, new Listener() {
 
            //@Override
            public void handleEvent(Event event) {
                // Initialisation de la taille de la scrollbar
                ScrollBar sbh = WeeklyPlanningCanvas.this.getHorizontalBar();
                sbh.setMinimum(0);
                sbh.setMaximum((int) getPlanningBounds().getWidth());
                sbh.setSelection(0);
                sbh.setThumb(getSize().x);
 
                ScrollBar sbv = WeeklyPlanningCanvas.this.getVerticalBar();
                sbv.setMinimum(0);
                sbv.setMaximum((int) getPlanningBounds().getHeight());
                sbv.setSelection(0);
                sbv.setThumb(getSize().y);                
            }});
 
	    final ScrollBar hBar = getHorizontalBar ();
	    hBar.addListener (SWT.Selection, new Listener () {
	        public void handleEvent (Event e) {
	            redraw();
	        }
	    });
	    final ScrollBar vBar = getVerticalBar ();
	    vBar.addListener (SWT.Selection, new Listener () {
	        public void handleEvent (Event e) {
	            redraw();
	        }
	    });
	}
 
 
 
	/**
         * Dessine le canvas
         */
	private void paintControl(GC gc) {	
        Image image = (Image) getData("double-buffer-image");
        if (image == null || image.getBounds().width != getSize().x || image.getBounds().height != getSize().y) {
          image = new Image(getDisplay(),getSize().x,getSize().y);
          setData("double-buffer-image", image);
        }
        GC imageGC = new GC(image);       
		paintBackground(imageGC);	    
		imageGC.setAntialias(SWT.ON);
		// dessine  un rectangle
		paintRect(imageGC);
 
		gc.drawImage(image, 0, 0);
		imageGC.dispose();
		gc.dispose();
	}
 
	/**
         * Remplit le fond avec la couleur du systeme
         * 
         * @param imageGC
         */
	private void paintBackground(GC gc) {
		gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		gc.fillRectangle(0, 0, this.getSize().x,
				this.getSize().y);
	}
 
	private void paintRect(GC gc){
		gc.setForeground(this.getDisplay().getSystemColor(
				SWT.COLOR_GRAY));
		gc.drawRectangle(300,300,150,150);
	}
 
 
 
}
Un idée ?

D'avance merci