Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 399786
Collapse All | Expand All

(-)a/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java (-13 / +37 lines)
Lines 387-392 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
387
	private InternalListener fInternalListener= new InternalListener();
387
	private InternalListener fInternalListener= new InternalListener();
388
	/** The font of this column */
388
	/** The font of this column */
389
	private Font fFont;
389
	private Font fFont;
390
	private int fFontScaleFactor = 2;
391
	private Font fBiggerFont;
390
	/** The indentation cache */
392
	/** The indentation cache */
391
	private int[] fIndentation;
393
	private int[] fIndentation;
392
	/** Indicates whether this column reacts on text change events */
394
	/** Indicates whether this column reacts on text change events */
Lines 642-648 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
642
644
643
		if (fFont != null)
645
		if (fFont != null)
644
			fCanvas.setFont(fFont);
646
			fCanvas.setFont(fFont);
645
647
		
646
		updateNumberOfDigits();
648
		updateNumberOfDigits();
647
		computeIndentations();
649
		computeIndentations();
648
		return fCanvas;
650
		return fCanvas;
Lines 670-699 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
670
	 * @param dest the GC to draw into
672
	 * @param dest the GC to draw into
671
	 */
673
	 */
672
	private void doubleBufferPaint(GC dest) {
674
	private void doubleBufferPaint(GC dest) {
673
675
		
674
		Point size= fCanvas.getSize();
676
		Point size= fCanvas.getSize();
675
677
676
		if (size.x <= 0 || size.y <= 0)
678
		if (size.x <= 0 || size.y <= 0)
677
			return;
679
			return;
678
680
		
679
		if (fBuffer != null) {
681
		if (fBuffer != null) {
680
			Rectangle r= fBuffer.getBounds();
682
			Rectangle r= fBuffer.getBounds();
681
			if (r.width != size.x || r.height != size.y) {
683
			if (r.width != size.x * fFontScaleFactor || r.height != size.y * fFontScaleFactor) {
682
				fBuffer.dispose();
684
				fBuffer.dispose();
683
				fBuffer= null;
685
				fBuffer= null;
684
			}
686
			}
685
		}
687
		}
686
		if (fBuffer == null)
688
		if (fBuffer == null)
687
			fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
689
			fBuffer= new Image(fCanvas.getDisplay(), size.x * fFontScaleFactor, size.y * fFontScaleFactor);
688
690
		
689
		GC gc= new GC(fBuffer);
691
		GC gc= new GC(fBuffer);
690
		gc.setFont(fCanvas.getFont());
692
		if(fBiggerFont == null)
693
			fBiggerFont = newBiggerFont(fCanvas.getFont());
694
		
695
		gc.setFont(fBiggerFont);
696
		
691
		if (fForeground != null)
697
		if (fForeground != null)
692
			gc.setForeground(fForeground);
698
			gc.setForeground(fForeground);
693
699
694
		try {
700
		try {
695
			gc.setBackground(getBackground(fCanvas.getDisplay()));
701
			gc.setBackground(getBackground(fCanvas.getDisplay()));
696
			gc.fillRectangle(0, 0, size.x, size.y);
702
			gc.fillRectangle(0, 0, size.x * fFontScaleFactor, size.y * fFontScaleFactor);
697
703
698
			ILineRange visibleLines= JFaceTextUtil.getVisibleModelLines(fCachedTextViewer);
704
			ILineRange visibleLines= JFaceTextUtil.getVisibleModelLines(fCachedTextViewer);
699
			if (visibleLines == null)
705
			if (visibleLines == null)
Lines 704-710 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
704
			gc.dispose();
710
			gc.dispose();
705
		}
711
		}
706
712
707
		dest.drawImage(fBuffer, 0, 0);
713
		double f = 1.0/fFontScaleFactor;
714
		dest.drawImage(fBuffer, 0,0,(int)(size.x / f),(int)(size.y / f),0,0,size.x,size.y);
708
	}
715
	}
709
716
710
	/**
717
	/**
Lines 749-755 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
749
			if (widgetLine == -1)
756
			if (widgetLine == -1)
750
				continue;
757
				continue;
751
758
752
			int lineHeight= fCachedTextWidget.getLineHeight(fCachedTextWidget.getOffsetAtLine(widgetLine));
759
			int lineHeight= fFontScaleFactor * fCachedTextWidget.getLineHeight(fCachedTextWidget.getOffsetAtLine(widgetLine));
753
			paintLine(line, y, lineHeight, gc, display);
760
			paintLine(line, y, lineHeight, gc, display);
754
			y += lineHeight;
761
			y += lineHeight;
755
		}
762
		}
Lines 871-877 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
871
	 * @see IVerticalRulerColumn#setFont(Font)
878
	 * @see IVerticalRulerColumn#setFont(Font)
872
	 */
879
	 */
873
	public void setFont(Font font) {
880
	public void setFont(Font font) {
874
		fFont= font;
881
		fBiggerFont = newBiggerFont(font);
882
		fFont = font;
875
		if (fCanvas != null && !fCanvas.isDisposed()) {
883
		if (fCanvas != null && !fCanvas.isDisposed()) {
876
			fCanvas.setFont(fFont);
884
			fCanvas.setFont(fFont);
877
			updateNumberOfDigits();
885
			updateNumberOfDigits();
Lines 879-884 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
879
		}
887
		}
880
	}
888
	}
881
889
890
	/*
891
	 * Create a copy of the given font with the fontSize scaled
892
	 * by "fFontScaleFactor". This is necessary due to the higher
893
	 * resolution required for retina displays. 
894
	 */
895
	private Font newBiggerFont(Font font) {
896
		if(fBiggerFont != null){
897
			fBiggerFont.dispose();
898
		}
899
		FontData[] fd = new FontData[font.getFontData().length];
900
		for(int i = 0; i < fd.length;i++){
901
			FontData current = font.getFontData()[i];
902
			fd[i] = new FontData(current.getName(),current.getHeight() * fFontScaleFactor, current.getStyle());
903
		}
904
		return new Font(font.getDevice(), fd);
905
	}
906
882
	/**
907
	/**
883
	 * Returns the parent (composite) ruler of this ruler column.
908
	 * Returns the parent (composite) ruler of this ruler column.
884
	 *
909
	 *
Lines 913-916 public class LineNumberRulerColumn implements IVerticalRulerColumn { Link Here
913
		return -1;
938
		return -1;
914
	}
939
	}
915
940
916
}
941
}
917
- 

Return to bug 399786