@@ -705,16 +705,16 @@ long createGdipBrush(Color color, int alpha) {
705705 */
706706public void draw (GC gc , int x , int y ) {
707707 checkLayout ();
708- drawInPixels (gc , DPIUtil . scaleUp ( getDevice (), x , getZoom ( gc )), DPIUtil . scaleUp ( getDevice (), y , getZoom ( gc )) );
708+ drawInPixels (gc , x , y );
709709}
710710
711711/**
712712 * Draws the receiver's text using the specified GC at the specified
713713 * point.
714714 *
715715 * @param gc the GC to draw
716- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
717- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
716+ * @param xInPoints the x coordinate of the top left corner of the rectangular area where the text is to be drawn
717+ * @param yInPoints the y coordinate of the top left corner of the rectangular area where the text is to be drawn
718718 * @param selectionStart the offset where the selections starts, or -1 indicating no selection
719719 * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
720720 * @param selectionForeground selection foreground, or NULL to use the system default color
@@ -727,13 +727,13 @@ public void draw (GC gc, int x, int y) {
727727 * <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
728728 * </ul>
729729 */
730- public void draw (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) {
730+ public void draw (GC gc , int xInPoints , int yInPoints , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) {
731731 checkLayout ();
732- drawInPixels (gc , DPIUtil . scaleUp ( getDevice (), x , getZoom ( gc )), DPIUtil . scaleUp ( getDevice (), y , getZoom ( gc )) , selectionStart , selectionEnd , selectionForeground , selectionBackground );
732+ drawInPixels (gc , xInPoints , yInPoints , selectionStart , selectionEnd , selectionForeground , selectionBackground );
733733}
734734
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 );
737737}
738738
739739/**
@@ -765,7 +765,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
765765 */
766766public void draw (GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground , int flags ) {
767767 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 );
769769}
770770
771771private int getNativeZoom (GC gc ) {
@@ -783,19 +783,19 @@ private int getZoom() {
783783 return DPIUtil .getZoomForAutoscaleProperty (nativeZoom );
784784}
785785
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 );
788788}
789789
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 ) {
791791 computeRuns (gc );
792792 if (gc == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
793793 if (gc .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
794794 if (selectionForeground != null && selectionForeground .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
795795 if (selectionBackground != null && selectionBackground .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
796796 int length = text .length ();
797797 if (length == 0 && flags == 0 ) return ;
798- y += getScaledVerticalIndent () ;
798+ yInPoints += verticalIndentInPoints ;
799799 long hdc = gc .handle ;
800800 Rectangle clip = gc .getClippingInPixels ();
801801 GCData data = gc .data ;
@@ -835,12 +835,15 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
835835 selectionEnd = translateOffset (Math .min (Math .max (0 , selectionEnd ), length - 1 ));
836836 }
837837 }
838+ int x = DPIUtil .scaleUp (getDevice (), xInPoints , getZoom (gc ));
838839 RECT rect = new RECT ();
839840 OS .SetBkMode (hdc , OS .TRANSPARENT );
840841 for (int line =0 ; line <runs .length ; line ++) {
841842 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 ));
843844 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 ));
844847 int lineHeight = DPIUtil .scaleUp (getDevice (), lineY [line +1 ] - lineY [line ] - lineSpacingInPoints , getZoom (gc ));
845848 int lineHeightWithSpacing = DPIUtil .scaleUp (getDevice (), lineY [line +1 ] - lineY [line ], getZoom (gc ));
846849 //Draw last line selection
@@ -870,7 +873,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
870873 Gdip .Graphics_FillRectangle (gdipGraphics , gdipSelBackground , drawX + lineWidthInPixels [line ], drawY , width , lineHeightWithSpacing );
871874 } else {
872875 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 );
874877 }
875878 }
876879 }
@@ -885,9 +888,9 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
885888 if (drawX + run .width >= clip .x ) {
886889 if (!run .lineBreak || run .softBreak ) {
887890 if (extents ) {
888- OS .SetRect (rect , drawX , drawY , drawX + run .width , drawY + lineHeightWithSpacing );
891+ OS .SetRect (rect , drawX , drawY , drawX + run .width , drawYWithLineHeightWithSpacing );
889892 }else {
890- OS .SetRect (rect , drawX , drawY , drawX + run .width , drawY + lineHeight );
893+ OS .SetRect (rect , drawX , drawY , drawX + run .width , drawYWithLineHeight );
891894 }
892895 if (gdip ) {
893896 drawRunBackgroundGDIP (run , gdipGraphics , rect , selectionStart , selectionEnd , alpha , gdipSelBackground , hasSelection );
0 commit comments