[Libreoffice-commits] .: 3 commits - svtools/source vcl/inc vcl/source

Noel Power noelp at kemper.freedesktop.org
Wed Aug 1 09:03:14 PDT 2012


 svtools/source/brwbox/ebbcontrols.cxx |   25 +------------------
 vcl/inc/vcl/button.hxx                |   33 ++++++++++++++------------
 vcl/source/control/button.cxx         |   43 ++++++++++++----------------------
 3 files changed, 36 insertions(+), 65 deletions(-)

New commits:
commit ff54a3c291b8aa104992a0285207166cf25ddd86
Author: Noel Power <noel.power at novell.com>
Date:   Wed Aug 1 17:01:44 2012 +0100

    simpler fix fo fdo#51336 - change vcl checkbox no-label behaviour
    
    Change-Id: I1563dc2afc49c7b1115192db00fbd08a7524154e

diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 1d7b025..fd607f2 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -268,6 +268,7 @@ namespace svt
         EnableChildTransparentMode();
 
         pBox = new TriStateBox(this,WB_CENTER|WB_VCENTER);
+        pBox->SetLegacyNoTextAlign( true );
         pBox->EnableChildTransparentMode();
         pBox->SetPaintTransparent( sal_True );
         pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) );
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index 9c5d6a3..9daf41a 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -292,7 +292,11 @@ private:
     sal_Bool            mbRadioCheck;
     sal_Bool            mbStateChanged;
     Link            maToggleHdl;
-
+    // when mbLegacyNoTextAlign is set then the old behaviour where
+    // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
+    // occurs, otherwise the image ( radiobutton circle ) is placed
+    // to the left or right ( depending on RTL or LTR settings )
+    bool            mbLegacyNoTextAlign;
     SAL_DLLPRIVATE void     ImplInitRadioButtonData();
     SAL_DLLPRIVATE WinBits  ImplInitStyle( const Window* pPrevWindow, WinBits nStyle );
     SAL_DLLPRIVATE void     ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
@@ -409,7 +413,11 @@ private:
     TriState        meSaveValue;
     sal_Bool            mbTriState;
     Link            maToggleHdl;
-
+    // when mbLegacyNoTextAlign is set then the old behaviour where
+    // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
+    // occurs, otherwise the image ( checkbox box ) is placed
+    // to the left or right ( depending on RTL or LTR settings )
+    bool            mbLegacyNoTextAlign;
     SAL_DLLPRIVATE void         ImplInitCheckBoxData();
     SAL_DLLPRIVATE WinBits      ImplInitStyle( const Window* pPrevWindow, WinBits nStyle );
     SAL_DLLPRIVATE void         ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
@@ -481,6 +489,8 @@ public:
 
     void            SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; }
     const Link&     GetToggleHdl() const { return maToggleHdl; }
+    bool            IsLegacyNoTextAlign() { return mbLegacyNoTextAlign; }
+    void            SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; }
 };
 
 inline void CheckBox::Check( sal_Bool bCheck )
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 1770bf8..37752bb 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2193,9 +2193,9 @@ void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
         }
         else
         {
-            if ( nWinStyle & WB_CENTER )
+            if ( mbLegacyNoTextAlign && ( nWinStyle & WB_CENTER ) )
                 rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
-            else if ( nWinStyle & WB_RIGHT )
+            else if ( mbLegacyNoTextAlign && ( nWinStyle & WB_RIGHT ) )
                 rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width(); //-1;
             else
                 rStateRect.Left() = rPos.X(); //+1;
@@ -2421,7 +2421,7 @@ void RadioButton::ImplCallClick( sal_Bool bGrabFocus, sal_uInt16 nFocusFlags )
 // -----------------------------------------------------------------------
 
 RadioButton::RadioButton( Window* pParent, WinBits nStyle ) :
-    Button( WINDOW_RADIOBUTTON )
+    Button( WINDOW_RADIOBUTTON ), mbLegacyNoTextAlign( false )
 {
     ImplInitRadioButtonData();
     ImplInit( pParent, nStyle );
@@ -2430,7 +2430,7 @@ RadioButton::RadioButton( Window* pParent, WinBits nStyle ) :
 // -----------------------------------------------------------------------
 
 RadioButton::RadioButton( Window* pParent, const ResId& rResId ) :
-    Button( WINDOW_RADIOBUTTON )
+    Button( WINDOW_RADIOBUTTON ), mbLegacyNoTextAlign( false )
 {
     ImplInitRadioButtonData();
     rResId.SetRT( RSC_RADIOBUTTON );
@@ -3256,9 +3256,9 @@ void CheckBox::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
     }
     else
     {
-        if ( nWinStyle & WB_CENTER )
+        if ( mbLegacyNoTextAlign && ( nWinStyle & WB_CENTER ) )
             rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
-        else if ( nWinStyle & WB_RIGHT )
+        else if ( mbLegacyNoTextAlign && ( nWinStyle & WB_RIGHT ) )
             rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
         else
             rStateRect.Left() = rPos.X();
@@ -3354,7 +3354,7 @@ void CheckBox::ImplCheck()
 // -----------------------------------------------------------------------
 
 CheckBox::CheckBox( Window* pParent, WinBits nStyle ) :
-    Button( WINDOW_CHECKBOX )
+    Button( WINDOW_CHECKBOX ), mbLegacyNoTextAlign( false )
 {
     ImplInitCheckBoxData();
     ImplInit( pParent, nStyle );
@@ -3363,7 +3363,7 @@ CheckBox::CheckBox( Window* pParent, WinBits nStyle ) :
 // -----------------------------------------------------------------------
 
 CheckBox::CheckBox( Window* pParent, const ResId& rResId ) :
-    Button( WINDOW_CHECKBOX )
+    Button( WINDOW_CHECKBOX ), mbLegacyNoTextAlign( false )
 {
     ImplInitCheckBoxData();
     rResId.SetRT( RSC_CHECKBOX );
commit d616ea80b27e65d83710f811a6f32637f3c7284a
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jul 31 20:42:04 2012 +0100

    Revert "additional fix for fdo#51336 for radiobuttons"
    
    This reverts commit 2bc2d09bba2e3f34e8ce13571de9ff7007e1c2b6.

diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index 719feaa..9c5d6a3 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -314,10 +314,6 @@ private:
 protected:
     using Control::ImplInitSettings;
     using Window::ImplInit;
-    // allows the behaviour of horizontal placement of the checbox image to be
-    // overridden.
-    virtual void ImplHandleHoriAlign( const Point& rPos, const Size& rSize,
-                                    const Size& rImageSize, Rectangle& rStateRect );
     SAL_DLLPRIVATE void     ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
 
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 75c28da..1770bf8 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2129,14 +2129,6 @@ if ( bNativeOK == sal_False )
 
 // -----------------------------------------------------------------------
 
-void RadioButton:: ImplHandleHoriAlign( const Point& rPos, const Size& /*rSize*/,
-                                    const Size& /*rImageSize*/, Rectangle& rStateRect )
-{
-    // align Checkbox image left ( always )
-    rStateRect.Left() = rPos.X();
-}
-// -----------------------------------------------------------------------
-
 void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
                             const Point& rPos, const Size& rSize,
                             const Size& rImageSize, Rectangle& rStateRect,
@@ -2201,9 +2193,12 @@ void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
         }
         else
         {
-            // allow specific handling of WB_CENTER, WB_LEFT & WB_RIGHT by
-            // by subclasses
-            ImplHandleHoriAlign( rPos, rSize, rImageSize, rStateRect );
+            if ( nWinStyle & WB_CENTER )
+                rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
+            else if ( nWinStyle & WB_RIGHT )
+                rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width(); //-1;
+            else
+                rStateRect.Left() = rPos.X(); //+1;
             if ( nWinStyle & WB_VCENTER )
                 rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
             else if ( nWinStyle & WB_BOTTOM )
commit 59d9a39abc6d4915fce55e55008107a7081b38d9
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jul 31 20:41:51 2012 +0100

    Revert "fdo#51336 - change vcl checkbox no-label behaviour"
    
    This reverts commit a1345cd93a57ec7d9352f2c71ec2664332ce5e76.

diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index b0ab801..1d7b025 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -253,28 +253,6 @@ namespace svt
     //= CheckBoxControl
     //==================================================================
     //------------------------------------------------------------------
-
-    class CBCntrlTriState : public TriStateBox
-    {
-        CBCntrlTriState( const CBCntrlTriState & );
-        CBCntrlTriState& operator= ( const CBCntrlTriState & );
-    protected:
-        virtual void ImplHandleHoriAlign( const Point& rPos, const Size& rSize,
-                                    const Size& rImageSize, Rectangle& rStateRect )
-        {
-            WinBits nWinStyle = GetStyle();
-            if ( nWinStyle & WB_CENTER )
-                rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
-            else if ( nWinStyle & WB_RIGHT )
-                rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
-            else
-                rStateRect.Left() = rPos.X();
-        }
-    public:
-        CBCntrlTriState( Window* pParent, WinBits nStyle = 0 ) : TriStateBox( pParent, nStyle ) {}
-        CBCntrlTriState( Window* pParent, const ResId& rResId ) : TriStateBox( pParent, rResId ) {}
-    };
-
     CheckBoxControl::CheckBoxControl(Window* pParent, WinBits nWinStyle)
                    :Control(pParent, nWinStyle)
     {
@@ -289,7 +267,7 @@ namespace svt
 
         EnableChildTransparentMode();
 
-        pBox = new CBCntrlTriState(this,WB_CENTER|WB_VCENTER);
+        pBox = new TriStateBox(this,WB_CENTER|WB_VCENTER);
         pBox->EnableChildTransparentMode();
         pBox->SetPaintTransparent( sal_True );
         pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) );
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index 0fd0bcf..719feaa 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -406,6 +406,7 @@ public:
 
 class VCL_DLLPUBLIC CheckBox : public Button
 {
+private:
     Rectangle       maStateRect;
     Rectangle       maMouseRect;
     TriState        meState;
@@ -424,7 +425,7 @@ class VCL_DLLPUBLIC CheckBox : public Button
     SAL_DLLPRIVATE void         ImplDrawCheckBox( bool bLayout = false );
     SAL_DLLPRIVATE long         ImplGetImageToTextDistance() const;
     SAL_DLLPRIVATE Size         ImplGetCheckImageSize() const;
-private:
+
     // Copy assignment is forbidden and not implemented.
     SAL_DLLPRIVATE              CheckBox(const CheckBox &);
     SAL_DLLPRIVATE              CheckBox& operator= (const CheckBox &);
@@ -432,19 +433,15 @@ private:
 protected:
     using Control::ImplInitSettings;
     using Window::ImplInit;
-    // allows the behaviour of horizontal placement of the checbox image to be
-    // overridden.
-    virtual void ImplHandleHoriAlign( const Point& rPos, const Size& rSize,
-                                    const Size& rImageSize, Rectangle& rStateRect );
     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
-                   virtual void FillLayoutData() const;
-                   virtual const Font&
+    SAL_DLLPRIVATE virtual void FillLayoutData() const;
+    SAL_DLLPRIVATE virtual const Font&
                                 GetCanonicalFont( const StyleSettings& _rStyle ) const;
-                   virtual const Color&
+    SAL_DLLPRIVATE virtual const Color&
                                 GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
 
-                   virtual void ImplDrawCheckBoxState();
+    SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState();
     SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; }
     SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; }
 public:
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 406377b..75c28da 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3261,9 +3261,12 @@ void CheckBox::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
     }
     else
     {
-        // allow specific handling of WB_CENTER, WB_LEFT & WB_RIGHT by
-        // by subclasses
-        ImplHandleHoriAlign( rPos, rSize, rImageSize, rStateRect );
+        if ( nWinStyle & WB_CENTER )
+            rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
+        else if ( nWinStyle & WB_RIGHT )
+            rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
+        else
+            rStateRect.Left() = rPos.X();
         if ( nWinStyle & WB_VCENTER )
             rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
         else if ( nWinStyle & WB_BOTTOM )
@@ -3305,15 +3308,6 @@ void CheckBox::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
 
 // -----------------------------------------------------------------------
 
-void CheckBox:: ImplHandleHoriAlign( const Point& rPos, const Size& /*rSize*/,
-                                    const Size& /*rImageSize*/, Rectangle& rStateRect )
-{
-    // align Checkbox image left ( always )
-    rStateRect.Left() = rPos.X();
-}
-
-// -----------------------------------------------------------------------
-
 void CheckBox::ImplDrawCheckBox( bool bLayout )
 {
     Size aImageSize = ImplGetCheckImageSize();


More information about the Libreoffice-commits mailing list