@@ -705,7 +705,7 @@ long createGdipBrush(Color color, int alpha) {
705
705
*/
706
706
public void draw (GC gc , int x , int y ) {
707
707
checkLayout ();
708
- drawInPixels (gc , DPIUtil . scaleUp ( getDevice (), x , getZoom ( gc )), DPIUtil . scaleUp ( getDevice (), y , getZoom ( gc )) );
708
+ drawInPixels (gc , x , y );
709
709
}
710
710
711
711
/**
@@ -729,11 +729,11 @@ public void draw (GC gc, int x, int y) {
729
729
*/
730
730
public void draw (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) {
731
731
checkLayout ();
732
- drawInPixels (gc , DPIUtil . scaleUp ( getDevice (), x , getZoom ( gc )), DPIUtil . scaleUp ( getDevice (), y , getZoom ( gc )) , selectionStart , selectionEnd , selectionForeground , selectionBackground );
732
+ drawInPixels (gc , x , y , selectionStart , selectionEnd , selectionForeground , selectionBackground );
733
733
}
734
734
735
- void drawInPixels (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) {
736
- drawInPixels (gc , x , y , selectionStart , selectionEnd , selectionForeground , selectionBackground , 0 );
735
+ void drawInPixels (GC gc , int xInPoints , int yInPoints , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) {
736
+ drawInPixels (gc , xInPoints , yInPoints , selectionStart , selectionEnd , selectionForeground , selectionBackground , 0 );
737
737
}
738
738
739
739
/**
@@ -765,7 +765,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
765
765
*/
766
766
public void draw (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground , int flags ) {
767
767
checkLayout ();
768
- drawInPixels (gc , DPIUtil . scaleUp ( getDevice (), x , getZoom ( gc )), DPIUtil . scaleUp ( getDevice (), y , getZoom ( gc )) , selectionStart , selectionEnd , selectionForeground , selectionBackground , flags );
768
+ drawInPixels (gc , x , y , selectionStart , selectionEnd , selectionForeground , selectionBackground , flags );
769
769
}
770
770
771
771
private int getNativeZoom (GC gc ) {
@@ -783,19 +783,19 @@ private int getZoom() {
783
783
return DPIUtil .getZoomForAutoscaleProperty (nativeZoom );
784
784
}
785
785
786
- void drawInPixels (GC gc , int x , int y ) {
787
- drawInPixels (gc , x , y , -1 , -1 , null , null );
786
+ void drawInPixels (GC gc , int xInPoints , int yInPoints ) {
787
+ drawInPixels (gc , xInPoints , yInPoints , -1 , -1 , null , null );
788
788
}
789
789
790
- void drawInPixels (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground , int flags ) {
790
+ void drawInPixels (GC gc , int xInPoints , int yInPoints , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground , int flags ) {
791
791
computeRuns (gc );
792
792
if (gc == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
793
793
if (gc .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
794
794
if (selectionForeground != null && selectionForeground .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
795
795
if (selectionBackground != null && selectionBackground .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
796
796
int length = text .length ();
797
797
if (length == 0 && flags == 0 ) return ;
798
- y += getScaledVerticalIndent () ;
798
+ yInPoints += verticalIndentInPoints ;
799
799
long hdc = gc .handle ;
800
800
Rectangle clip = gc .getClippingInPixels ();
801
801
GCData data = gc .data ;
@@ -835,12 +835,15 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
835
835
selectionEnd = translateOffset (Math .min (Math .max (0 , selectionEnd ), length - 1 ));
836
836
}
837
837
}
838
+ int x = DPIUtil .scaleUp (getDevice (), xInPoints , getZoom (gc ));
838
839
RECT rect = new RECT ();
839
840
OS .SetBkMode (hdc , OS .TRANSPARENT );
840
841
for (int line =0 ; line <runs .length ; line ++) {
841
842
int drawX = x + getLineIndentInPixel (line );
842
- int drawY = y + DPIUtil .scaleUp (getDevice (), lineY [line ], getZoom (gc ));
843
+ int drawY = DPIUtil .scaleUp (getDevice (), yInPoints + lineY [line ], getZoom (gc ));
843
844
StyleItem [] lineRuns = runs [line ];
845
+ int drawYWithLineHeight = DPIUtil .scaleUp (getDevice (), yInPoints + lineY [line +1 ] - lineSpacingInPoints , getZoom (gc ));
846
+ int drawYWithLineHeightWithSpacing = DPIUtil .scaleUp (getDevice (), yInPoints + lineY [line +1 ], getZoom (gc ));
844
847
int lineHeight = DPIUtil .scaleUp (getDevice (), lineY [line +1 ] - lineY [line ] - lineSpacingInPoints , getZoom (gc ));
845
848
int lineHeightWithSpacing = DPIUtil .scaleUp (getDevice (), lineY [line +1 ] - lineY [line ], getZoom (gc ));
846
849
//Draw last line selection
@@ -870,7 +873,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
870
873
Gdip .Graphics_FillRectangle (gdipGraphics , gdipSelBackground , drawX + lineWidthInPixels [line ], drawY , width , lineHeightWithSpacing );
871
874
} else {
872
875
OS .SelectObject (hdc , selBackground );
873
- OS .PatBlt (hdc , drawX + lineWidthInPixels [line ], drawY , width , lineHeightWithSpacing , OS .PATCOPY );
876
+ OS .PatBlt (hdc , drawX + lineWidthInPixels [line ], drawY , width , drawYWithLineHeightWithSpacing , OS .PATCOPY );
874
877
}
875
878
}
876
879
}
@@ -885,9 +888,9 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
885
888
if (drawX + run .width >= clip .x ) {
886
889
if (!run .lineBreak || run .softBreak ) {
887
890
if (extents ) {
888
- OS .SetRect (rect , drawX , drawY , drawX + run .width , drawY + lineHeightWithSpacing );
891
+ OS .SetRect (rect , drawX , drawY , drawX + run .width , drawYWithLineHeightWithSpacing );
889
892
}else {
890
- OS .SetRect (rect , drawX , drawY , drawX + run .width , drawY + lineHeight );
893
+ OS .SetRect (rect , drawX , drawY , drawX + run .width , drawYWithLineHeight );
891
894
}
892
895
if (gdip ) {
893
896
drawRunBackgroundGDIP (run , gdipGraphics , rect , selectionStart , selectionEnd , alpha , gdipSelBackground , hasSelection );
0 commit comments