Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/LineNumberRulerColumn.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 7926b636c282 |
children | c3583c6ec027 |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
581 protected int computeNumberOfDigits() { | 581 protected int computeNumberOfDigits() { |
582 IDocument document= fCachedTextViewer.getDocument(); | 582 IDocument document= fCachedTextViewer.getDocument(); |
583 int lines= document is null ? 0 : document.getNumberOfLines(); | 583 int lines= document is null ? 0 : document.getNumberOfLines(); |
584 | 584 |
585 int digits= 2; | 585 int digits= 2; |
586 while (lines > Math.pow(10, digits) -1) { | 586 while (lines > Math.pow(cast(real)10.0, cast(uint)digits) -1) { |
587 ++digits; | 587 ++digits; |
588 } | 588 } |
589 return digits; | 589 return digits; |
590 } | 590 } |
591 | 591 |
627 | 627 |
628 fIndentation= new int[fCachedNumberOfDigits + 1]; | 628 fIndentation= new int[fCachedNumberOfDigits + 1]; |
629 | 629 |
630 char[] nines= new char[fCachedNumberOfDigits]; | 630 char[] nines= new char[fCachedNumberOfDigits]; |
631 Arrays.fill(nines, '9'); | 631 Arrays.fill(nines, '9'); |
632 String nineString= new String(nines); | 632 String nineString= new_String(nines); |
633 Point p= gc.stringExtent(nineString); | 633 Point p= gc.stringExtent(nineString); |
634 fIndentation[0]= p.x; | 634 fIndentation[0]= p.x; |
635 | 635 |
636 for (int i= 1; i <= fCachedNumberOfDigits; i++) { | 636 for (int i= 1; i <= fCachedNumberOfDigits; i++) { |
637 p= gc.stringExtent(nineString.substring(0, i)); | 637 p= gc.stringExtent(nineString.substring(0, i)); |
651 fParentRuler= parentRuler; | 651 fParentRuler= parentRuler; |
652 fCachedTextViewer= parentRuler.getTextViewer(); | 652 fCachedTextViewer= parentRuler.getTextViewer(); |
653 fCachedTextWidget= fCachedTextViewer.getTextWidget(); | 653 fCachedTextWidget= fCachedTextViewer.getTextWidget(); |
654 | 654 |
655 fCanvas= new class(parentControl, DWT.NO_FOCUS ) Canvas { | 655 fCanvas= new class(parentControl, DWT.NO_FOCUS ) Canvas { |
656 this(Composite c, int s ){ | |
657 super(c,s); | |
658 } | |
656 /* | 659 /* |
657 * @see dwt.widgets.Control#addMouseListener(dwt.events.MouseListener) | 660 * @see dwt.widgets.Control#addMouseListener(dwt.events.MouseListener) |
658 * @since 3.4 | 661 * @since 3.4 |
659 */ | 662 */ |
660 public void addMouseListener(MouseListener listener) { | 663 public void addMouseListener(MouseListener listener) { |
875 */ | 878 */ |
876 protected void paintLine(int line, int y, int lineheight, GC gc, Display display) { | 879 protected void paintLine(int line, int y, int lineheight, GC gc, Display display) { |
877 int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line); | 880 int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line); |
878 | 881 |
879 String s= createDisplayString(line); | 882 String s= createDisplayString(line); |
880 int indentation= fIndentation[s.length()]; | 883 int indentation= fIndentation[s.length]; |
881 int baselineBias= getBaselineBias(gc, widgetLine); | 884 int baselineBias= getBaselineBias(gc, widgetLine); |
882 gc.drawString(s, indentation, y + baselineBias, true); | 885 gc.drawString(s, indentation, y + baselineBias, true); |
883 } | 886 } |
884 | 887 |
885 /** | 888 /** |