Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/MatchingCharacterPainter.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | b6bad70d540a |
children |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
118 /** The paint position manager */ | 118 /** The paint position manager */ |
119 private IPaintPositionManager fPaintPositionManager; | 119 private IPaintPositionManager fPaintPositionManager; |
120 /** The strategy for finding matching characters */ | 120 /** The strategy for finding matching characters */ |
121 private ICharacterPairMatcher fMatcher; | 121 private ICharacterPairMatcher fMatcher; |
122 /** The position tracking the matching characters */ | 122 /** The position tracking the matching characters */ |
123 private Position fPairPosition= new Position(0, 0); | 123 private Position fPairPosition; |
124 /** The anchor indicating whether the character is left or right of the caret */ | 124 /** The anchor indicating whether the character is left or right of the caret */ |
125 private int fAnchor; | 125 private int fAnchor; |
126 | 126 |
127 | 127 |
128 /** | 128 /** |
133 * | 133 * |
134 * @param sourceViewer | 134 * @param sourceViewer |
135 * @param matcher | 135 * @param matcher |
136 */ | 136 */ |
137 public this(ISourceViewer sourceViewer, ICharacterPairMatcher matcher) { | 137 public this(ISourceViewer sourceViewer, ICharacterPairMatcher matcher) { |
138 fPairPosition= new Position(0, 0); | |
138 fSourceViewer= sourceViewer; | 139 fSourceViewer= sourceViewer; |
139 fMatcher= matcher; | 140 fMatcher= matcher; |
140 fTextWidget= sourceViewer.getTextWidget(); | 141 fTextWidget= sourceViewer.getTextWidget(); |
141 } | 142 } |
142 | 143 |
242 */ | 243 */ |
243 private void draw(GC gc, int offset, int length) { | 244 private void draw(GC gc, int offset, int length) { |
244 if (gc !is null) { | 245 if (gc !is null) { |
245 | 246 |
246 gc.setForeground(fColor); | 247 gc.setForeground(fColor); |
247 | 248 |
248 Rectangle bounds; | 249 Rectangle bounds; |
249 if (length > 0) | 250 if (length > 0) |
250 bounds= fTextWidget.getTextBounds(offset, offset + length - 1); | 251 bounds= fTextWidget.getTextBounds(offset, offset + length - 1); |
251 else { | 252 else { |
252 Point loc= fTextWidget.getLocationAtOffset(offset); | 253 Point loc= fTextWidget.getLocationAtOffset(offset); |
253 bounds= new Rectangle(loc.x, loc.y, 1, fTextWidget.getLineHeight(offset)); | 254 bounds= new Rectangle(loc.x, loc.y, 1, fTextWidget.getLineHeight(offset)); |
254 } | 255 } |
255 | 256 |
256 // draw box around line segment | 257 // draw box around line segment |
257 gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1); | 258 gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1); |
258 | 259 |
259 // draw box around character area | 260 // draw box around character area |
260 // int widgetBaseline= fTextWidget.getBaseline(); | 261 // int widgetBaseline= fTextWidget.getBaseline(); |
306 // otherwise only do something if position is different | 307 // otherwise only do something if position is different |
307 | 308 |
308 // remove old highlighting | 309 // remove old highlighting |
309 handleDrawRequest(null); | 310 handleDrawRequest(null); |
310 // update position | 311 // update position |
311 fPairPosition.isDeleted= false; | 312 fPairPosition.isDeleted_= false; |
312 fPairPosition.offset= pair.getOffset(); | 313 fPairPosition.offset= pair.getOffset(); |
313 fPairPosition.length= pair.getLength(); | 314 fPairPosition.length= pair.getLength(); |
314 fAnchor= fMatcher.getAnchor(); | 315 fAnchor= fMatcher.getAnchor(); |
315 // apply new highlighting | 316 // apply new highlighting |
316 handleDrawRequest(null); | 317 handleDrawRequest(null); |
318 } | 319 } |
319 } else { | 320 } else { |
320 | 321 |
321 fIsActive= true; | 322 fIsActive= true; |
322 | 323 |
323 fPairPosition.isDeleted= false; | 324 fPairPosition.isDeleted_= false; |
324 fPairPosition.offset= pair.getOffset(); | 325 fPairPosition.offset= pair.getOffset(); |
325 fPairPosition.length= pair.getLength(); | 326 fPairPosition.length= pair.getLength(); |
326 fAnchor= fMatcher.getAnchor(); | 327 fAnchor= fMatcher.getAnchor(); |
327 | 328 |
328 fTextWidget.addPaintListener(this); | 329 fTextWidget.addPaintListener(this); |