Mercurial > projects > dwt-addons
annotate dwtx/jface/text/source/OverviewRulerHoverManager.d @ 133:7d818bd32d63
Fix ctors to this with gvim regexp
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:29:22 +0200 |
parents | c4fb132a086c |
children | 51e6e63f930e |
rev | line source |
---|---|
129 | 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 dwtx.jface.text.source.OverviewRulerHoverManager; | |
14 | |
131 | 15 import dwtx.jface.text.source.ISharedTextColors; // packageimport |
16 import dwtx.jface.text.source.ILineRange; // packageimport | |
17 import dwtx.jface.text.source.IAnnotationPresentation; // packageimport | |
18 import dwtx.jface.text.source.IVerticalRulerInfoExtension; // packageimport | |
19 import dwtx.jface.text.source.ICharacterPairMatcher; // packageimport | |
20 import dwtx.jface.text.source.TextInvocationContext; // packageimport | |
21 import dwtx.jface.text.source.LineChangeHover; // packageimport | |
22 import dwtx.jface.text.source.IChangeRulerColumn; // packageimport | |
23 import dwtx.jface.text.source.IAnnotationMap; // packageimport | |
24 import dwtx.jface.text.source.IAnnotationModelListenerExtension; // packageimport | |
25 import dwtx.jface.text.source.ISourceViewerExtension2; // packageimport | |
26 import dwtx.jface.text.source.IAnnotationHover; // packageimport | |
27 import dwtx.jface.text.source.ContentAssistantFacade; // packageimport | |
28 import dwtx.jface.text.source.IAnnotationAccess; // packageimport | |
29 import dwtx.jface.text.source.IVerticalRulerExtension; // packageimport | |
30 import dwtx.jface.text.source.IVerticalRulerColumn; // packageimport | |
31 import dwtx.jface.text.source.LineNumberRulerColumn; // packageimport | |
32 import dwtx.jface.text.source.MatchingCharacterPainter; // packageimport | |
33 import dwtx.jface.text.source.IAnnotationModelExtension; // packageimport | |
34 import dwtx.jface.text.source.ILineDifferExtension; // packageimport | |
35 import dwtx.jface.text.source.DefaultCharacterPairMatcher; // packageimport | |
36 import dwtx.jface.text.source.LineNumberChangeRulerColumn; // packageimport | |
37 import dwtx.jface.text.source.IAnnotationAccessExtension; // packageimport | |
38 import dwtx.jface.text.source.ISourceViewer; // packageimport | |
39 import dwtx.jface.text.source.AnnotationModel; // packageimport | |
40 import dwtx.jface.text.source.ILineDifferExtension2; // packageimport | |
41 import dwtx.jface.text.source.IAnnotationModelListener; // packageimport | |
42 import dwtx.jface.text.source.IVerticalRuler; // packageimport | |
43 import dwtx.jface.text.source.DefaultAnnotationHover; // packageimport | |
44 import dwtx.jface.text.source.SourceViewer; // packageimport | |
45 import dwtx.jface.text.source.SourceViewerConfiguration; // packageimport | |
46 import dwtx.jface.text.source.AnnotationBarHoverManager; // packageimport | |
47 import dwtx.jface.text.source.CompositeRuler; // packageimport | |
48 import dwtx.jface.text.source.ImageUtilities; // packageimport | |
49 import dwtx.jface.text.source.VisualAnnotationModel; // packageimport | |
50 import dwtx.jface.text.source.IAnnotationModel; // packageimport | |
51 import dwtx.jface.text.source.ISourceViewerExtension3; // packageimport | |
52 import dwtx.jface.text.source.ILineDiffInfo; // packageimport | |
53 import dwtx.jface.text.source.VerticalRulerEvent; // packageimport | |
54 import dwtx.jface.text.source.ChangeRulerColumn; // packageimport | |
55 import dwtx.jface.text.source.ILineDiffer; // packageimport | |
56 import dwtx.jface.text.source.AnnotationModelEvent; // packageimport | |
57 import dwtx.jface.text.source.AnnotationColumn; // packageimport | |
58 import dwtx.jface.text.source.AnnotationRulerColumn; // packageimport | |
59 import dwtx.jface.text.source.IAnnotationHoverExtension; // packageimport | |
60 import dwtx.jface.text.source.AbstractRulerColumn; // packageimport | |
61 import dwtx.jface.text.source.ISourceViewerExtension; // packageimport | |
62 import dwtx.jface.text.source.AnnotationMap; // packageimport | |
63 import dwtx.jface.text.source.IVerticalRulerInfo; // packageimport | |
64 import dwtx.jface.text.source.IAnnotationModelExtension2; // packageimport | |
65 import dwtx.jface.text.source.LineRange; // packageimport | |
66 import dwtx.jface.text.source.IAnnotationAccessExtension2; // packageimport | |
67 import dwtx.jface.text.source.VerticalRuler; // packageimport | |
68 import dwtx.jface.text.source.JFaceTextMessages; // packageimport | |
69 import dwtx.jface.text.source.IOverviewRuler; // packageimport | |
70 import dwtx.jface.text.source.Annotation; // packageimport | |
71 import dwtx.jface.text.source.IVerticalRulerListener; // packageimport | |
72 import dwtx.jface.text.source.ISourceViewerExtension4; // packageimport | |
73 import dwtx.jface.text.source.AnnotationPainter; // packageimport | |
74 import dwtx.jface.text.source.IAnnotationHoverExtension2; // packageimport | |
75 import dwtx.jface.text.source.OverviewRuler; // packageimport | |
76 | |
77 | |
129 | 78 import dwt.dwthelper.utils; |
79 | |
80 | |
81 | |
82 import dwt.custom.StyledText; | |
83 import dwt.graphics.Point; | |
84 import dwt.graphics.Rectangle; | |
85 import dwt.widgets.ScrollBar; | |
86 import dwtx.jface.text.IInformationControlCreator; | |
87 | |
88 /** | |
89 * This manager controls the layout, content, and visibility of an information | |
90 * control in reaction to mouse hover events issued by the overview ruler of a | |
91 * source viewer. | |
92 * | |
93 * @since 2.1 | |
94 */ | |
95 class OverviewRulerHoverManager : AnnotationBarHoverManager { | |
96 | |
97 /** | |
98 * Creates an overview hover manager with the given parameters. In addition, | |
99 * the hovers anchor is RIGHT and the margin is 5 points to the right. | |
100 * | |
101 * @param ruler the overview ruler this manager connects to | |
102 * @param sourceViewer the source viewer this manager connects to | |
103 * @param annotationHover the annotation hover providing the information to be displayed | |
104 * @param creator the information control creator | |
105 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
106 public this(IOverviewRuler ruler, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) { |
129 | 107 super(ruler, sourceViewer, annotationHover, creator); |
108 setAnchor(ANCHOR_LEFT); | |
109 StyledText textWidget= sourceViewer.getTextWidget(); | |
110 if (textWidget !is null) { | |
111 ScrollBar verticalBar= textWidget.getVerticalBar(); | |
112 if (verticalBar !is null) | |
113 setMargins(verticalBar.getSize().x, 5); | |
114 } | |
115 } | |
116 | |
117 /* | |
118 * @see AbstractHoverInformationControlManager#computeInformation() | |
119 */ | |
120 protected void computeInformation() { | |
121 Point location= getHoverEventLocation(); | |
122 int line= getVerticalRulerInfo().toDocumentLineNumber(location.y); | |
123 IAnnotationHover hover= getAnnotationHover(); | |
124 | |
125 IInformationControlCreator controlCreator= null; | |
126 if (hover instanceof IAnnotationHoverExtension) | |
127 controlCreator= ((IAnnotationHoverExtension)hover).getHoverControlCreator(); | |
128 setCustomInformationControlCreator(controlCreator); | |
129 | |
130 setInformation(hover.getHoverInfo(getSourceViewer(), line), computeArea(location.y)); | |
131 } | |
132 | |
133 /** | |
134 * Determines graphical area covered for which the hover is valid. | |
135 * | |
136 * @param y y-coordinate in the vertical ruler | |
137 * @return the graphical extend where the hover is valid | |
138 */ | |
139 private Rectangle computeArea(int y) { | |
140 // This is OK (see constructor) | |
141 IOverviewRuler overviewRuler= (IOverviewRuler) getVerticalRulerInfo(); | |
142 | |
143 int hover_height= overviewRuler.getAnnotationHeight(); | |
144 int hover_width= getVerticalRulerInfo().getControl().getSize().x; | |
145 | |
146 // Calculate y-coordinate for hover | |
147 int hover_y= y; | |
148 bool hasAnnotation= true; | |
149 while (hasAnnotation && hover_y > y - hover_height) { | |
150 hover_y--; | |
151 hasAnnotation= overviewRuler.hasAnnotation(hover_y); | |
152 } | |
153 hover_y++; | |
154 | |
155 return new Rectangle(0, hover_y, hover_width, hover_height); | |
156 } | |
157 } |