comparison dwtx/jface/text/source/AnnotationBarHoverManager.d @ 145:02cd5f1224d3

...
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 22:31:00 +0200
parents 53b889547456
children f70d9508c95c
comparison
equal deleted inserted replaced
144:16a71f577815 145:02cd5f1224d3
124 */ 124 */
125 public class AnnotationBarHoverManager : AbstractHoverInformationControlManager { 125 public class AnnotationBarHoverManager : AbstractHoverInformationControlManager {
126 126
127 /** 127 /**
128 * The information control closer for the hover information. Closes the information control as soon as the mouse pointer leaves the subject area, a mouse button is pressed, the user presses a key, or the subject control is resized or moved. 128 * The information control closer for the hover information. Closes the information control as soon as the mouse pointer leaves the subject area, a mouse button is pressed, the user presses a key, or the subject control is resized or moved.
129 * 129 *
130 * @since 3.0 130 * @since 3.0
131 * @deprecated As of 3.4, no longer used as closer from super class is used 131 * @deprecated As of 3.4, no longer used as closer from super class is used
132 */ 132 */
133 protected class Closer : MouseTrackAdapter , IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, DisposeListener, ShellListener, Listener { 133 protected class Closer : MouseTrackAdapter , IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, DisposeListener, ShellListener, Listener {
134 134
188 fSubjectControl.addMouseMoveListener(this); 188 fSubjectControl.addMouseMoveListener(this);
189 fSubjectControl.addMouseTrackListener(this); 189 fSubjectControl.addMouseTrackListener(this);
190 fSubjectControl.getShell().addShellListener(this); 190 fSubjectControl.getShell().addShellListener(this);
191 fSubjectControl.addControlListener(this); 191 fSubjectControl.addControlListener(this);
192 fSubjectControl.addKeyListener(this); 192 fSubjectControl.addKeyListener(this);
193 193
194 fDisplay= fSubjectControl.getDisplay(); 194 fDisplay= fSubjectControl.getDisplay();
195 if (!fDisplay.isDisposed() && fHideOnMouseWheel) { 195 if (!fDisplay.isDisposed() && fHideOnMouseWheel) {
196 fHasWheelFilter= true; 196 fHasWheelFilter= true;
197 fDisplay.addFilter(DWT.MouseWheel, this); 197 fDisplay.addFilter(DWT.MouseWheel, this);
198 } 198 }
214 fSubjectControl.removeMouseTrackListener(this); 214 fSubjectControl.removeMouseTrackListener(this);
215 fSubjectControl.getShell().removeShellListener(this); 215 fSubjectControl.getShell().removeShellListener(this);
216 fSubjectControl.removeControlListener(this); 216 fSubjectControl.removeControlListener(this);
217 fSubjectControl.removeKeyListener(this); 217 fSubjectControl.removeKeyListener(this);
218 } 218 }
219 219
220 if (fDisplay !is null && !fDisplay.isDisposed() && fHasWheelFilter) 220 if (fDisplay !is null && !fDisplay.isDisposed() && fHasWheelFilter)
221 fDisplay.removeFilter(DWT.MouseWheel, this); 221 fDisplay.removeFilter(DWT.MouseWheel, this);
222 fHasWheelFilter= false; 222 fHasWheelFilter= false;
223 223
224 fDisplay= null; 224 fDisplay= null;
225 225
226 } 226 }
227 227
228 /** 228 /**
229 * Stops the information control and if <code>delayRestart</code> is set allows restart only after a certain delay. 229 * Stops the information control and if <code>delayRestart</code> is set allows restart only after a certain delay.
230 * 230 *
231 * @param delayRestart <code>true</code> if restart should be delayed 231 * @param delayRestart <code>true</code> if restart should be delayed
232 * @deprecated As of 3.4, replaced by {@link #stop()}. Note that <code>delayRestart</code> was never honored. 232 * @deprecated As of 3.4, replaced by {@link #stop()}. Note that <code>delayRestart</code> was never honored.
233 */ 233 */
234 protected void stop(bool delayRestart) { 234 protected void stop(bool delayRestart) {
235 stop(); 235 stop();
260 * @see MouseListener#mouseDoubleClick(MouseEvent) 260 * @see MouseListener#mouseDoubleClick(MouseEvent)
261 */ 261 */
262 public void mouseDoubleClick(MouseEvent event) { 262 public void mouseDoubleClick(MouseEvent event) {
263 hideInformationControl(); 263 hideInformationControl();
264 } 264 }
265 265
266 /* 266 /*
267 * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) 267 * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event)
268 * @since 3.2 268 * @since 3.2
269 */ 269 */
270 public void handleEvent(Event event) { 270 public void handleEvent(Event event) {
362 * @since 3.0 362 * @since 3.0
363 */ 363 */
364 protected bool fAllowMouseExit= false; 364 protected bool fAllowMouseExit= false;
365 /** 365 /**
366 * Whether we should hide the over on mouse wheel action. 366 * Whether we should hide the over on mouse wheel action.
367 * 367 *
368 * @since 3.2 368 * @since 3.2
369 */ 369 */
370 private bool fHideOnMouseWheel= true; 370 private bool fHideOnMouseWheel= true;
371 371
372 /** 372 /**
373 * The current annotation hover. 373 * The current annotation hover.
374 * @since 3.2 374 * @since 3.2
375 */ 375 */
376 private IAnnotationHover fCurrentHover; 376 private IAnnotationHover fCurrentHover;
441 setCustomInformationControlCreator(null); 441 setCustomInformationControlCreator(null);
442 setInformation(hover.getHoverInfo(fSourceViewer, line), computeArea(line)); 442 setInformation(hover.getHoverInfo(fSourceViewer, line), computeArea(line));
443 } 443 }
444 444
445 } 445 }
446 446
447 /* 447 /*
448 * @see dwtx.jface.text.AbstractInformationControlManager#showInformationControl(dwt.graphics.Rectangle) 448 * @see dwtx.jface.text.AbstractInformationControlManager#showInformationControl(dwt.graphics.Rectangle)
449 * @since 3.2 449 * @since 3.2
450 */ 450 */
451 protected void showInformationControl(Rectangle subjectArea) { 451 protected void showInformationControl(Rectangle subjectArea) {
452 super.showInformationControl(subjectArea); 452 super.showInformationControl(subjectArea);
453 fCurrentHover= getHover(getHoverEvent()); 453 fCurrentHover= getHover(getHoverEvent());
454 } 454 }
455 455
456 /* 456 /*
457 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() 457 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl()
458 * @since 3.2 458 * @since 3.2
459 */ 459 */
460 protected void hideInformationControl() { 460 protected void hideInformationControl() {
531 int topDelta= Math.max(topLine - rangeTopLine, 0); 531 int topDelta= Math.max(topLine - rangeTopLine, 0);
532 532
533 Rectangle size= text.getClientArea(); 533 Rectangle size= text.getClientArea();
534 Rectangle trim= text.computeTrim(0, 0, 0, 0); 534 Rectangle trim= text.computeTrim(0, 0, 0, 0);
535 int height= size.height - trim.height; 535 int height= size.height - trim.height;
536 536
537 int lines= JFaceTextUtil.getLineIndex(text, height) - text.getTopIndex(); 537 int lines= JFaceTextUtil.getLineIndex(text, height) - text.getTopIndex();
538 538
539 int bottomLine= topLine + lines; 539 int bottomLine= topLine + lines;
540 540
541 int rangeBottomLine= getWidgetLineNumber(lineRange.getStartLine() + lineRange.getNumberOfLines() - 1); 541 int rangeBottomLine= getWidgetLineNumber(lineRange.getStartLine() + lineRange.getNumberOfLines() - 1);
542 int bottomDelta= Math.max(rangeBottomLine - bottomLine, 0); 542 int bottomDelta= Math.max(rangeBottomLine - bottomLine, 0);
543 543
544 return new LineRange(lineRange.getStartLine() + topDelta, lineRange.getNumberOfLines() - bottomDelta - topDelta); 544 return new LineRange(lineRange.getStartLine() + topDelta, lineRange.getNumberOfLines() - bottomDelta - topDelta);
545 545
806 /** 806 /**
807 * Returns an adapter that gives access to internal methods. 807 * Returns an adapter that gives access to internal methods.
808 * <p> 808 * <p>
809 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients. 809 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.
810 * </p> 810 * </p>
811 * 811 *
812 * @return the replaceable information control accessor 812 * @return the replaceable information control accessor
813 * @since 3.4 813 * @since 3.4
814 * @noreference This method is not intended to be referenced by clients. 814 * @noreference This method is not intended to be referenced by clients.
815 * @nooverride This method is not intended to be re-implemented or extended by clients. 815 * @nooverride This method is not intended to be re-implemented or extended by clients.
816 */ 816 */
817 public InternalAccessor getInternalAccessor() { 817 public InternalAccessor getInternalAccessor() {
818 return new class() InternalAccessor { 818 return new class() InternalAccessor {
819 public IInformationControl getCurrentInformationControl() { 819 public IInformationControl getCurrentInformationControl() {
820 return AnnotationBarHoverManager.super.getInternalAccessor().getCurrentInformationControl(); 820 return outer.superGetInternalAccessor().getCurrentInformationControl();
821 } 821 }
822 822
823 public void setInformationControlReplacer(InformationControlReplacer replacer) { 823 public void setInformationControlReplacer(InformationControlReplacer replacer) {
824 AnnotationBarHoverManager.super.getInternalAccessor().setInformationControlReplacer(replacer); 824 outer.superGetInternalAccessor().setInformationControlReplacer(replacer);
825 } 825 }
826 826
827 public InformationControlReplacer getInformationControlReplacer() { 827 public InformationControlReplacer getInformationControlReplacer() {
828 return AnnotationBarHoverManager.super.getInternalAccessor().getInformationControlReplacer(); 828 return outer.superGetInternalAccessor().getInformationControlReplacer();
829 } 829 }
830 830
831 public bool canReplace(IInformationControl control) { 831 public bool canReplace(IInformationControl control) {
832 return AnnotationBarHoverManager.super.getInternalAccessor().canReplace(control); 832 return outer.superGetInternalAccessor().canReplace(control);
833 } 833 }
834 834
835 public bool isReplaceInProgress() { 835 public bool isReplaceInProgress() {
836 return AnnotationBarHoverManager.super.getInternalAccessor().isReplaceInProgress(); 836 return outer.superGetInternalAccessor().isReplaceInProgress();
837 } 837 }
838 838
839 public void replaceInformationControl(bool takeFocus) { 839 public void replaceInformationControl(bool takeFocus) {
840 AnnotationBarHoverManager.super.getInternalAccessor().replaceInformationControl(takeFocus); 840 outer.superGetInternalAccessor().replaceInformationControl(takeFocus);
841 } 841 }
842 842
843 public void cropToClosestMonitor(Rectangle bounds) { 843 public void cropToClosestMonitor(Rectangle bounds) {
844 AnnotationBarHoverManager.super.getInternalAccessor().cropToClosestMonitor(bounds); 844 outer.superGetInternalAccessor().cropToClosestMonitor(bounds);
845 } 845 }
846 846
847 public void setHoverEnrichMode(EnrichMode mode) { 847 public void setHoverEnrichMode(EnrichMode mode) {
848 AnnotationBarHoverManager.super.getInternalAccessor().setHoverEnrichMode(mode); 848 outer.superGetInternalAccessor().setHoverEnrichMode(mode);
849 } 849 }
850 850
851 public bool getAllowMouseExit() { 851 public bool getAllowMouseExit() {
852 return fAllowMouseExit; 852 return fAllowMouseExit;
853 } 853 }
854 }; 854 };
855 } 855 }
856 private InternalAccessor superGetInternalAccessor() {
857 return super.getInternalAccessor();
858 }
856 } 859 }
857 860