comparison org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.jface.text.source.VerticalRuler;
14
15 import org.eclipse.jface.text.source.ISharedTextColors; // packageimport
16 import org.eclipse.jface.text.source.ILineRange; // packageimport
17 import org.eclipse.jface.text.source.IAnnotationPresentation; // packageimport
18 import org.eclipse.jface.text.source.IVerticalRulerInfoExtension; // packageimport
19 import org.eclipse.jface.text.source.ICharacterPairMatcher; // packageimport
20 import org.eclipse.jface.text.source.TextInvocationContext; // packageimport
21 import org.eclipse.jface.text.source.LineChangeHover; // packageimport
22 import org.eclipse.jface.text.source.IChangeRulerColumn; // packageimport
23 import org.eclipse.jface.text.source.IAnnotationMap; // packageimport
24 import org.eclipse.jface.text.source.IAnnotationModelListenerExtension; // packageimport
25 import org.eclipse.jface.text.source.ISourceViewerExtension2; // packageimport
26 import org.eclipse.jface.text.source.IAnnotationHover; // packageimport
27 import org.eclipse.jface.text.source.ContentAssistantFacade; // packageimport
28 import org.eclipse.jface.text.source.IAnnotationAccess; // packageimport
29 import org.eclipse.jface.text.source.IVerticalRulerExtension; // packageimport
30 import org.eclipse.jface.text.source.IVerticalRulerColumn; // packageimport
31 import org.eclipse.jface.text.source.LineNumberRulerColumn; // packageimport
32 import org.eclipse.jface.text.source.MatchingCharacterPainter; // packageimport
33 import org.eclipse.jface.text.source.IAnnotationModelExtension; // packageimport
34 import org.eclipse.jface.text.source.ILineDifferExtension; // packageimport
35 import org.eclipse.jface.text.source.DefaultCharacterPairMatcher; // packageimport
36 import org.eclipse.jface.text.source.LineNumberChangeRulerColumn; // packageimport
37 import org.eclipse.jface.text.source.IAnnotationAccessExtension; // packageimport
38 import org.eclipse.jface.text.source.ISourceViewer; // packageimport
39 import org.eclipse.jface.text.source.AnnotationModel; // packageimport
40 import org.eclipse.jface.text.source.ILineDifferExtension2; // packageimport
41 import org.eclipse.jface.text.source.IAnnotationModelListener; // packageimport
42 import org.eclipse.jface.text.source.IVerticalRuler; // packageimport
43 import org.eclipse.jface.text.source.DefaultAnnotationHover; // packageimport
44 import org.eclipse.jface.text.source.SourceViewer; // packageimport
45 import org.eclipse.jface.text.source.SourceViewerConfiguration; // packageimport
46 import org.eclipse.jface.text.source.AnnotationBarHoverManager; // packageimport
47 import org.eclipse.jface.text.source.CompositeRuler; // packageimport
48 import org.eclipse.jface.text.source.ImageUtilities; // packageimport
49 import org.eclipse.jface.text.source.VisualAnnotationModel; // packageimport
50 import org.eclipse.jface.text.source.IAnnotationModel; // packageimport
51 import org.eclipse.jface.text.source.ISourceViewerExtension3; // packageimport
52 import org.eclipse.jface.text.source.ILineDiffInfo; // packageimport
53 import org.eclipse.jface.text.source.VerticalRulerEvent; // packageimport
54 import org.eclipse.jface.text.source.ChangeRulerColumn; // packageimport
55 import org.eclipse.jface.text.source.ILineDiffer; // packageimport
56 import org.eclipse.jface.text.source.AnnotationModelEvent; // packageimport
57 import org.eclipse.jface.text.source.AnnotationColumn; // packageimport
58 import org.eclipse.jface.text.source.AnnotationRulerColumn; // packageimport
59 import org.eclipse.jface.text.source.IAnnotationHoverExtension; // packageimport
60 import org.eclipse.jface.text.source.AbstractRulerColumn; // packageimport
61 import org.eclipse.jface.text.source.ISourceViewerExtension; // packageimport
62 import org.eclipse.jface.text.source.AnnotationMap; // packageimport
63 import org.eclipse.jface.text.source.IVerticalRulerInfo; // packageimport
64 import org.eclipse.jface.text.source.IAnnotationModelExtension2; // packageimport
65 import org.eclipse.jface.text.source.LineRange; // packageimport
66 import org.eclipse.jface.text.source.IAnnotationAccessExtension2; // packageimport
67 import org.eclipse.jface.text.source.JFaceTextMessages; // packageimport
68 import org.eclipse.jface.text.source.IOverviewRuler; // packageimport
69 import org.eclipse.jface.text.source.Annotation; // packageimport
70 import org.eclipse.jface.text.source.IVerticalRulerListener; // packageimport
71 import org.eclipse.jface.text.source.ISourceViewerExtension4; // packageimport
72 import org.eclipse.jface.text.source.AnnotationPainter; // packageimport
73 import org.eclipse.jface.text.source.IAnnotationHoverExtension2; // packageimport
74 import org.eclipse.jface.text.source.OverviewRuler; // packageimport
75 import org.eclipse.jface.text.source.OverviewRulerHoverManager; // packageimport
76
77
78 import java.lang.all;
79 import java.util.Iterator;
80 import java.util.Set;
81
82
83
84 import org.eclipse.swt.SWT;
85 import org.eclipse.swt.custom.StyledText;
86 import org.eclipse.swt.events.DisposeEvent;
87 import org.eclipse.swt.events.DisposeListener;
88 import org.eclipse.swt.events.MouseEvent;
89 import org.eclipse.swt.events.MouseListener;
90 import org.eclipse.swt.events.PaintEvent;
91 import org.eclipse.swt.events.PaintListener;
92 import org.eclipse.swt.graphics.Font;
93 import org.eclipse.swt.graphics.GC;
94 import org.eclipse.swt.graphics.Image;
95 import org.eclipse.swt.graphics.Point;
96 import org.eclipse.swt.graphics.Rectangle;
97 import org.eclipse.swt.widgets.Canvas;
98 import org.eclipse.swt.widgets.Composite;
99 import org.eclipse.swt.widgets.Control;
100 import org.eclipse.swt.widgets.Display;
101 import org.eclipse.jface.text.BadLocationException;
102 import org.eclipse.jface.text.IDocument;
103 import org.eclipse.jface.text.IRegion;
104 import org.eclipse.jface.text.ITextListener;
105 import org.eclipse.jface.text.ITextViewer;
106 import org.eclipse.jface.text.ITextViewerExtension5;
107 import org.eclipse.jface.text.IViewportListener;
108 import org.eclipse.jface.text.JFaceTextUtil;
109 import org.eclipse.jface.text.Position;
110 import org.eclipse.jface.text.Region;
111 import org.eclipse.jface.text.TextEvent;
112
113
114 /**
115 * A vertical ruler which is connected to a text viewer. Single column standard
116 * implementation of {@link org.eclipse.jface.text.source.IVerticalRuler}.
117 * <p>
118 * The same can be achieved by using <code>CompositeRuler</code> configured
119 * with an <code>AnnotationRulerColumn</code>. Clients may use this class as
120 * is.
121 *
122 * @see org.eclipse.jface.text.ITextViewer
123 */
124 public final class VerticalRuler : IVerticalRuler, IVerticalRulerExtension {
125
126 /**
127 * Internal listener class.
128 */
129 class InternalListener : IViewportListener, IAnnotationModelListener, ITextListener {
130
131 /*
132 * @see IViewportListener#viewportChanged(int)
133 */
134 public void viewportChanged(int verticalPosition) {
135 if (verticalPosition !is fScrollPos)
136 redraw();
137 }
138
139 /*
140 * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
141 */
142 public void modelChanged(IAnnotationModel model) {
143 update();
144 }
145
146 /*
147 * @see ITextListener#textChanged(TextEvent)
148 */
149 public void textChanged(TextEvent e) {
150 if (fTextViewer !is null && e.getViewerRedrawState())
151 redraw();
152 }
153 }
154
155 /** The vertical ruler's text viewer */
156 private ITextViewer fTextViewer;
157 /** The ruler's canvas */
158 private Canvas fCanvas;
159 /** The vertical ruler's model */
160 private IAnnotationModel fModel;
161 /** Cache for the actual scroll position in pixels */
162 private int fScrollPos;
163 /** The buffer for double buffering */
164 private Image fBuffer;
165 /** The line of the last mouse button activity */
166 private int fLastMouseButtonActivityLine= -1;
167 /** The internal listener */
168 private InternalListener fInternalListener;
169 /** The width of this vertical ruler */
170 private int fWidth;
171 /**
172 * The annotation access of this vertical ruler
173 * @since 3.0
174 */
175 private IAnnotationAccess fAnnotationAccess;
176
177 /**
178 * Constructs a vertical ruler with the given width.
179 *
180 * @param width the width of the vertical ruler
181 */
182 public this(int width) {
183 this(width, null);
184 }
185
186 /**
187 * Constructs a vertical ruler with the given width and the given annotation
188 * access.
189 *
190 * @param width the width of the vertical ruler
191 * @param annotationAcccess the annotation access
192 * @since 3.0
193 */
194 public this(int width, IAnnotationAccess annotationAcccess) {
195
196 fInternalListener= new InternalListener();
197
198 fWidth= width;
199 fAnnotationAccess= annotationAcccess;
200 }
201
202 /*
203 * @see IVerticalRuler#getControl()
204 */
205 public Control getControl() {
206 return fCanvas;
207 }
208
209 /*
210 * @see IVerticalRuler#createControl(Composite, ITextViewer)
211 */
212 public Control createControl(Composite parent, ITextViewer textViewer) {
213
214 fTextViewer= textViewer;
215
216 fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
217
218 fCanvas.addPaintListener(new class() PaintListener {
219 public void paintControl(PaintEvent event) {
220 if (fTextViewer !is null)
221 doubleBufferPaint(event.gc);
222 }
223 });
224
225 fCanvas.addDisposeListener(new class() DisposeListener {
226 public void widgetDisposed(DisposeEvent e) {
227 handleDispose();
228 fTextViewer= null;
229 }
230 });
231
232 fCanvas.addMouseListener(new class() MouseListener {
233 public void mouseUp(MouseEvent event) {
234 }
235
236 public void mouseDown(MouseEvent event) {
237 fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
238 }
239
240 public void mouseDoubleClick(MouseEvent event) {
241 fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
242 }
243 });
244
245 if (fTextViewer !is null) {
246 fTextViewer.addViewportListener(fInternalListener);
247 fTextViewer.addTextListener(fInternalListener);
248 }
249
250 return fCanvas;
251 }
252
253 /**
254 * Disposes the ruler's resources.
255 */
256 private void handleDispose() {
257
258 if (fTextViewer !is null) {
259 fTextViewer.removeViewportListener(fInternalListener);
260 fTextViewer.removeTextListener(fInternalListener);
261 fTextViewer= null;
262 }
263
264 if (fModel !is null)
265 fModel.removeAnnotationModelListener(fInternalListener);
266
267 if (fBuffer !is null) {
268 fBuffer.dispose();
269 fBuffer= null;
270 }
271 }
272
273
274 /**
275 * Double buffer drawing.
276 *
277 * @param dest the GC to draw into
278 */
279 private void doubleBufferPaint(GC dest) {
280
281 Point size= fCanvas.getSize();
282
283 if (size.x <= 0 || size.y <= 0)
284 return;
285
286 if (fBuffer !is null) {
287 Rectangle r= fBuffer.getBounds();
288 if (r.width !is size.x || r.height !is size.y) {
289 fBuffer.dispose();
290 fBuffer= null;
291 }
292 }
293 if (fBuffer is null)
294 fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
295
296 GC gc= new GC(fBuffer);
297 gc.setFont(fTextViewer.getTextWidget().getFont());
298 try {
299 gc.setBackground(fCanvas.getBackground());
300 gc.fillRectangle(0, 0, size.x, size.y);
301
302 if ( cast(ITextViewerExtension5)fTextViewer )
303 doPaint1(gc);
304 else
305 doPaint(gc);
306
307 } finally {
308 gc.dispose();
309 }
310
311 dest.drawImage(fBuffer, 0, 0);
312 }
313
314 /**
315 * Returns the document offset of the upper left corner of the
316 * widgets view port, possibly including partially visible lines.
317 *
318 * @return the document offset of the upper left corner including partially visible lines
319 * @since 2.0
320 */
321 private int getInclusiveTopIndexStartOffset() {
322
323 StyledText textWidget= fTextViewer.getTextWidget();
324 if (textWidget !is null && !textWidget.isDisposed()) {
325 int top= JFaceTextUtil.getPartialTopIndex(fTextViewer);
326 try {
327 IDocument document= fTextViewer.getDocument();
328 return document.getLineOffset(top);
329 } catch (BadLocationException x) {
330 }
331 }
332
333 return -1;
334 }
335
336
337
338 /**
339 * Draws the vertical ruler w/o drawing the Canvas background.
340 *
341 * @param gc the GC to draw into
342 */
343 protected void doPaint(GC gc) {
344
345 if (fModel is null || fTextViewer is null)
346 return;
347
348 IAnnotationAccessExtension annotationAccessExtension= null;
349 if ( cast(IAnnotationAccessExtension)fAnnotationAccess )
350 annotationAccessExtension= cast(IAnnotationAccessExtension) fAnnotationAccess;
351
352 StyledText styledText= fTextViewer.getTextWidget();
353 IDocument doc= fTextViewer.getDocument();
354
355 int topLeft= getInclusiveTopIndexStartOffset();
356 int bottomRight= fTextViewer.getBottomIndexEndOffset();
357 int viewPort= bottomRight - topLeft;
358
359 Point d= fCanvas.getSize();
360 fScrollPos= styledText.getTopPixel();
361
362 int topLine= -1, bottomLine= -1;
363 try {
364 IRegion region= fTextViewer.getVisibleRegion();
365 topLine= doc.getLineOfOffset(region.getOffset());
366 bottomLine= doc.getLineOfOffset(region.getOffset() + region.getLength());
367 } catch (BadLocationException x) {
368 return;
369 }
370
371 // draw Annotations
372 Rectangle r= new Rectangle(0, 0, 0, 0);
373 int maxLayer= 1; // loop at least once though layers.
374
375 for (int layer= 0; layer < maxLayer; layer++) {
376 Iterator iter= fModel.getAnnotationIterator();
377 while (iter.hasNext()) {
378 IAnnotationPresentation annotationPresentation= null;
379 Annotation annotation= cast(Annotation) iter.next();
380
381 int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
382 if (annotationAccessExtension !is null)
383 lay= annotationAccessExtension.getLayer(annotation);
384 else if ( cast(IAnnotationPresentation)annotation ) {
385 annotationPresentation= cast(IAnnotationPresentation)annotation;
386 lay= annotationPresentation.getLayer();
387 }
388 maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
389 if (lay !is layer) // wrong layer: skip annotation
390 continue;
391
392 Position position= fModel.getPosition(annotation);
393 if (position is null)
394 continue;
395
396 if (!position.overlapsWith(topLeft, viewPort))
397 continue;
398
399 try {
400
401 int offset= position.getOffset();
402 int length= position.getLength();
403
404 int startLine= doc.getLineOfOffset(offset);
405 if (startLine < topLine)
406 startLine= topLine;
407
408 int endLine= startLine;
409 if (length > 0)
410 endLine= doc.getLineOfOffset(offset + length - 1);
411 if (endLine > bottomLine)
412 endLine= bottomLine;
413
414 startLine -= topLine;
415 endLine -= topLine;
416
417 r.x= 0;
418 r.y= JFaceTextUtil.computeLineHeight(styledText, 0, startLine, startLine) - fScrollPos;
419
420 r.width= d.x;
421 int lines= endLine - startLine;
422
423 r.height= JFaceTextUtil.computeLineHeight(styledText, startLine, endLine + 1, (lines+1));
424
425 if (r.y < d.y && annotationAccessExtension !is null) // annotation within visible area
426 annotationAccessExtension.paint(annotation, gc, fCanvas, r);
427 else if (annotationPresentation !is null)
428 annotationPresentation.paint(gc, fCanvas, r);
429
430 } catch (BadLocationException e) {
431 }
432 }
433 }
434 }
435
436 /**
437 * Draws the vertical ruler w/o drawing the Canvas background. Uses
438 * <code>ITextViewerExtension5</code> for its implementation. Will replace
439 * <code>doPaint(GC)</code>.
440 *
441 * @param gc the GC to draw into
442 */
443 protected void doPaint1(GC gc) {
444
445 if (fModel is null || fTextViewer is null)
446 return;
447
448 IAnnotationAccessExtension annotationAccessExtension= null;
449 if ( cast(IAnnotationAccessExtension)fAnnotationAccess )
450 annotationAccessExtension= cast(IAnnotationAccessExtension) fAnnotationAccess;
451
452 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fTextViewer;
453 StyledText textWidget= fTextViewer.getTextWidget();
454
455 fScrollPos= textWidget.getTopPixel();
456 Point dimension= fCanvas.getSize();
457
458 // draw Annotations
459 Rectangle r= new Rectangle(0, 0, 0, 0);
460 int maxLayer= 1; // loop at least once through layers.
461
462 for (int layer= 0; layer < maxLayer; layer++) {
463 Iterator iter= fModel.getAnnotationIterator();
464 while (iter.hasNext()) {
465 IAnnotationPresentation annotationPresentation= null;
466 Annotation annotation= cast(Annotation) iter.next();
467
468 int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
469 if (annotationAccessExtension !is null)
470 lay= annotationAccessExtension.getLayer(annotation);
471 else if ( cast(IAnnotationPresentation)annotation ) {
472 annotationPresentation= cast(IAnnotationPresentation)annotation;
473 lay= annotationPresentation.getLayer();
474 }
475 maxLayer= Math.max(maxLayer, lay+1); // dynamically update layer maximum
476 if (lay !is layer) // wrong layer: skip annotation
477 continue;
478
479 Position position= fModel.getPosition(annotation);
480 if (position is null)
481 continue;
482
483 IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
484 if (widgetRegion is null)
485 continue;
486
487 int startLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset());
488 if (startLine is -1)
489 continue;
490
491 int endLine= extension.widgetLineOfWidgetOffset(widgetRegion.getOffset() + Math.max(widgetRegion.getLength() -1, 0));
492 if (endLine is -1)
493 continue;
494
495 r.x= 0;
496 r.y= JFaceTextUtil.computeLineHeight(textWidget, 0, startLine, startLine) - fScrollPos;
497
498 r.width= dimension.x;
499 int lines= endLine - startLine;
500
501 r.height= JFaceTextUtil.computeLineHeight(textWidget, startLine, endLine + 1, lines+1);
502
503 if (r.y < dimension.y && annotationAccessExtension !is null) // annotation within visible area
504 annotationAccessExtension.paint(annotation, gc, fCanvas, r);
505 else if (annotationPresentation !is null)
506 annotationPresentation.paint(gc, fCanvas, r);
507 }
508 }
509 }
510
511 /**
512 * Thread-safe implementation.
513 * Can be called from any thread.
514 */
515 /*
516 * @see IVerticalRuler#update()
517 */
518 public void update() {
519 if (fCanvas !is null && !fCanvas.isDisposed()) {
520 Display d= fCanvas.getDisplay();
521 if (d !is null) {
522 d.asyncExec(new class() Runnable {
523 public void run() {
524 redraw();
525 }
526 });
527 }
528 }
529 }
530
531 /**
532 * Redraws the vertical ruler.
533 */
534 private void redraw() {
535 if (fCanvas !is null && !fCanvas.isDisposed()) {
536 GC gc= new GC(fCanvas);
537 doubleBufferPaint(gc);
538 gc.dispose();
539 }
540 }
541
542 /*
543 * @see IVerticalRuler#setModel(IAnnotationModel)
544 */
545 public void setModel(IAnnotationModel model) {
546 if (model !is fModel) {
547
548 if (fModel !is null)
549 fModel.removeAnnotationModelListener(fInternalListener);
550
551 fModel= model;
552
553 if (fModel !is null)
554 fModel.addAnnotationModelListener(fInternalListener);
555
556 update();
557 }
558 }
559
560 /*
561 * @see IVerticalRuler#getModel()
562 */
563 public IAnnotationModel getModel() {
564 return fModel;
565 }
566
567 /*
568 * @see IVerticalRulerInfo#getWidth()
569 */
570 public int getWidth() {
571 return fWidth;
572 }
573
574 /*
575 * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
576 */
577 public int getLineOfLastMouseButtonActivity() {
578 IDocument doc= fTextViewer.getDocument();
579 if (doc is null || fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines())
580 fLastMouseButtonActivityLine= -1;
581 return fLastMouseButtonActivityLine;
582 }
583
584 /*
585 * @see IVerticalRulerInfo#toDocumentLineNumber(int)
586 */
587 public int toDocumentLineNumber(int y_coordinate) {
588 if (fTextViewer is null || y_coordinate is -1)
589 return -1;
590
591 StyledText text= fTextViewer.getTextWidget();
592 int line= text.getLineIndex(y_coordinate);
593
594 if (line is text.getLineCount() - 1) {
595 // check whether y_coordinate exceeds last line
596 if (y_coordinate > text.getLinePixel(line + 1))
597 return -1;
598 }
599
600 return widgetLine2ModelLine(fTextViewer, line);
601 }
602
603 /**
604 * Returns the line of the viewer's document that corresponds to the given widget line.
605 *
606 * @param viewer the viewer
607 * @param widgetLine the widget line
608 * @return the corresponding line of the viewer's document
609 * @since 2.1
610 */
611 protected final static int widgetLine2ModelLine(ITextViewer viewer, int widgetLine) {
612
613 if ( cast(ITextViewerExtension5)viewer ) {
614 ITextViewerExtension5 extension= cast(ITextViewerExtension5) viewer;
615 return extension.widgetLine2ModelLine(widgetLine);
616 }
617
618 try {
619 IRegion r= viewer.getVisibleRegion();
620 IDocument d= viewer.getDocument();
621 return widgetLine += d.getLineOfOffset(r.getOffset());
622 } catch (BadLocationException x) {
623 }
624 return widgetLine;
625 }
626
627 /*
628 * @see IVerticalRulerExtension#setFont(Font)
629 * @since 2.0
630 */
631 public void setFont(Font font) {
632 }
633
634 /*
635 * @see IVerticalRulerExtension#setLocationOfLastMouseButtonActivity(int, int)
636 * @since 2.0
637 */
638 public void setLocationOfLastMouseButtonActivity(int x, int y) {
639 fLastMouseButtonActivityLine= toDocumentLineNumber(y);
640 }
641
642 /**
643 * Adds the given mouse listener.
644 *
645 * @param listener the listener to be added
646 * @deprecated will be removed
647 * @since 2.0
648 */
649 public void addMouseListener(MouseListener listener) {
650 if (fCanvas !is null && !fCanvas.isDisposed())
651 fCanvas.addMouseListener(listener);
652 }
653
654 /**
655 * Removes the given mouse listener.
656 *
657 * @param listener the listener to be removed
658 * @deprecated will be removed
659 * @since 2.0
660 */
661 public void removeMouseListener(MouseListener listener) {
662 if (fCanvas !is null && !fCanvas.isDisposed())
663 fCanvas.removeMouseListener(listener);
664 }
665 }