Commits

Anonymous committed 0b25ffd

#b6875455#
when drawing/painting a check box or radio button, then take the zoom into account when calculating the
distance between the radio/check image, and the actual text.
This ensures that in contexts where controls can and will be zoomed (i.e. in documents), the text doesn't
'jump' relative to other text surrounding the control.

Comments (0)

Files changed (3)

vcl/inc/vcl/button.hxx

     SAL_DLLPRIVATE void     ImplDrawRadioButtonState();
     SAL_DLLPRIVATE void     ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                               const Point& rPos, const Size& rSize,
-                              const Size& rImageSize, long nImageSep,
-                              Rectangle& rStateRect, Rectangle& rMouseRect,
-                              bool bLayout = false );
+                              const Size& rImageSize, Rectangle& rStateRect,
+                              Rectangle& rMouseRect, bool bLayout = false );
     SAL_DLLPRIVATE void     ImplDrawRadioButton( bool bLayout = false );
     SAL_DLLPRIVATE void     ImplInvalidateOrDrawRadioButtonState();
     SAL_DLLPRIVATE void     ImplUncheckAllOther();
     SAL_DLLPRIVATE Size     ImplGetRadioImageSize() const;
+    SAL_DLLPRIVATE long     ImplGetImageToTextDistance() const;
 
     // Copy assignment is forbidden and not implemented.
 	SAL_DLLPRIVATE          RadioButton(const RadioButton &);
     SAL_DLLPRIVATE void         ImplInvalidateOrDrawCheckBoxState();
     SAL_DLLPRIVATE void         ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                                     const Point& rPos, const Size& rSize,
-                                    const Size& rImageSize, long nImageSep,
-                                    Rectangle& rStateRect,
+                                    const Size& rImageSize, Rectangle& rStateRect,
                                     Rectangle& rMouseRect, bool bLayout );
     SAL_DLLPRIVATE void         ImplDrawCheckBox( bool bLayout = false );
+    SAL_DLLPRIVATE long         ImplGetImageToTextDistance() const;
     SAL_DLLPRIVATE Size         ImplGetCheckImageSize() const;
 
     // Copy assignment is forbidden and not implemented.

vcl/inc/vcl/window.hxx

 #define IMPL_MSGBOX_OFFSET_EXTRA_X      0
 #define IMPL_MSGBOX_OFFSET_EXTRA_Y      2
 #define IMPL_SEP_MSGBOX_IMAGE           8
-#define IMPL_SEP_BUTTON_IMAGE           4
 
 #define DLGWINDOW_PREV                  0
 #define DLGWINDOW_NEXT                  1

vcl/source/control/button.cxx

 
 void RadioButton::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                             const Point& rPos, const Size& rSize,
-                            const Size& rImageSize, long nImageSep,
-                            Rectangle& rStateRect,
-                            Rectangle& rMouseRect,
-                            bool bLayout )
+                            const Size& rImageSize, Rectangle& rStateRect,
+                            Rectangle& rMouseRect, bool bLayout )
 {
     WinBits                 nWinStyle = GetStyle();
     XubString               aText( GetText() );
         {
             USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
 
+            const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
             Size aSize( rSize );
             Point aPos( rPos );
-
             aPos.X() += rImageSize.Width() + nImageSep;
             aSize.Width() -= rImageSize.Width() + nImageSep;
 
 
     // Draw control text
     ImplDraw( this, 0, Point(), GetOutputSizePixel(),
-              aImageSize, IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout );
+              aImageSize, maStateRect, maMouseRect, bLayout );
 
     if( !bLayout || (IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)==TRUE) )
     {
         pDev->SetTextFillColor();
 
         ImplDraw( pDev, nFlags, aPos, aSize,
-                  aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ),
-                  aStateRect, aMouseRect );
+                  aImageSize, aStateRect, aMouseRect );
 
         Point   aCenterPos = aStateRect.Center();
         long    nRadX = aImageSize.Width()/2;
 
 // -----------------------------------------------------------------------
 
+long RadioButton::ImplGetImageToTextDistance() const
+{
+    // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
+    // which might have been aligned with the text of the check box
+    return CalcZoom( 4 );
+}
+
+// -----------------------------------------------------------------------
+
 Size RadioButton::ImplGetRadioImageSize() const
 {
     Size aSize;
     {
         // subtract what will be added later
         nMaxWidth-=2;
-        nMaxWidth -= IMPL_SEP_BUTTON_IMAGE;
+        nMaxWidth -= ImplGetImageToTextDistance();
 
         Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
                                       aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
         aSize.Width()+=2;   // for focus rect
-        aSize.Width() += IMPL_SEP_BUTTON_IMAGE;
+        aSize.Width() += ImplGetImageToTextDistance();
         aSize.Width() += aTextSize.Width();
         if ( aSize.Height() < aTextSize.Height() )
             aSize.Height() = aTextSize.Height();
 
 void CheckBox::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
                          const Point& rPos, const Size& rSize,
-                         const Size& rImageSize, long nImageSep,
-                         Rectangle& rStateRect, Rectangle& rMouseRect,
-                         bool bLayout )
+                         const Size& rImageSize, Rectangle& rStateRect,
+                         Rectangle& rMouseRect, bool bLayout )
 {
     WinBits                 nWinStyle = GetStyle();
     XubString               aText( GetText() );
     {
         USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
 
+        const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
         Size aSize( rSize );
         Point aPos( rPos );
         aPos.X() += rImageSize.Width() + nImageSep;
         HideFocus();
 
     ImplDraw( this, 0, Point(), GetOutputSizePixel(), aImageSize,
-              IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout );
+              maStateRect, maMouseRect, bLayout );
 
     if( !bLayout )
     {
     pDev->SetTextFillColor();
 
     ImplDraw( pDev, nFlags, aPos, aSize,
-              aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ),
-              aStateRect, aMouseRect, false );
+              aImageSize, aStateRect, aMouseRect, false );
 
     pDev->SetLineColor();
     pDev->SetFillColor( Color( COL_BLACK ) );
 
 // -----------------------------------------------------------------------
 
+long CheckBox::ImplGetImageToTextDistance() const
+{
+    // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
+    // which might have been aligned with the text of the check box
+    return CalcZoom( 4 );
+}
+
+// -----------------------------------------------------------------------
+
 Size CheckBox::ImplGetCheckImageSize() const
 {
     Size aSize;
     {
         // subtract what will be added later
         nMaxWidth-=2;
-        nMaxWidth -= IMPL_SEP_BUTTON_IMAGE;
+        nMaxWidth -= ImplGetImageToTextDistance();
 
         Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
                                       aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
         aSize.Width()+=2;    // for focus rect
-        aSize.Width() += IMPL_SEP_BUTTON_IMAGE;
+        aSize.Width() += ImplGetImageToTextDistance();
         aSize.Width() += aTextSize.Width();
         if ( aSize.Height() < aTextSize.Height() )
             aSize.Height() = aTextSize.Height();