[Libreoffice-commits] core.git: 4 commits - include/vcl vcl/source

Ivan Timofeev timofeev.i.s at gmail.com
Sat Jun 29 07:07:06 PDT 2013


 include/vcl/outdev.hxx          |    4 -
 vcl/source/control/button.cxx   |   12 +---
 vcl/source/control/edit.cxx     |    2 
 vcl/source/control/lstbox.cxx   |    8 +--
 vcl/source/control/scrbar.cxx   |   98 ++++++++++++++++++++--------------------
 vcl/source/gdi/outdevnative.cxx |    4 -
 vcl/source/window/status.cxx    |   17 +++---
 7 files changed, 70 insertions(+), 75 deletions(-)

New commits:
commit 231fb4182fc9e81f801ff1d1355f7a613d0856c2
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Sat Jun 29 15:33:38 2013 +0400

    make HitTestNativeControl const
    
    Change-Id: I1d3f09cce87fadd8bdc18b2775ebe2a6968d99c1

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b1b143f..b97f416 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1194,7 +1194,7 @@ public:
                                                 ControlPart nPart,
                                                 const Rectangle& rControlRegion,
                                                 const Point& aPos,
-                                                sal_Bool& rIsInside );
+                                                sal_Bool& rIsInside ) const;
 
     // Request rendering of a particular control and/or part
     sal_Bool                DrawNativeControl(  ControlType nType,
diff --git a/vcl/source/gdi/outdevnative.cxx b/vcl/source/gdi/outdevnative.cxx
index fe0ed27..68e65a3 100644
--- a/vcl/source/gdi/outdevnative.cxx
+++ b/vcl/source/gdi/outdevnative.cxx
@@ -166,7 +166,7 @@ sal_Bool OutputDevice::HitTestNativeControl( ControlType nType,
                               ControlPart nPart,
                               const Rectangle& rControlRegion,
                               const Point& aPos,
-                              sal_Bool& rIsInside )
+                              sal_Bool& rIsInside ) const
 {
     if( !lcl_enableNativeWidget( *this ) )
         return sal_False;
commit 7d1e257a6ba2bbb0120753a09c140200ab913991
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Sat Jun 29 15:32:09 2013 +0400

    make IsNativeControlSupported const
    
    Change-Id: I4346b2df94fc8767fce734362901b6248bb6342d

diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index a5781ee..6ee8944 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2891,10 +2891,8 @@ long RadioButton::ImplGetImageToTextDistance() const
 Size RadioButton::ImplGetRadioImageSize() const
 {
     Size aSize;
-    // why are IsNativeControlSupported and GetNativeControlRegion not const ?
-    RadioButton* pThis = const_cast<RadioButton*>(this);
     bool bDefaultSize = true;
-    if( pThis->IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
+    if( IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
     {
         ImplControlValue aControlValue;
         // #i45896# workaround gcc3.3 temporary problem
@@ -3825,10 +3823,8 @@ long CheckBox::ImplGetImageToTextDistance() const
 Size CheckBox::ImplGetCheckImageSize() const
 {
     Size aSize;
-    // why are IsNativeControlSupported and GetNativeControlRegion not const ?
-    CheckBox* pThis = const_cast<CheckBox*>(this);
     bool bDefaultSize = true;
-    if( pThis->IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
+    if( IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
     {
         ImplControlValue aControlValue;
         // #i45896# workaround gcc3.3 temporary problem
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 7ec6fd7..1d08e84 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -1595,9 +1595,8 @@ Size StatusBar::CalcWindowSizePixel() const
     long nMinHeight = GetTextHeight();
     const long nBarTextOffset = STATUSBAR_OFFSET_TEXTY*2;
     long nProgressHeight = nMinHeight + nBarTextOffset;
-    // FIXME: IsNativeControlSupported and GetNativeControlRegion should be const ?
-    StatusBar* pThis = const_cast<StatusBar*>( this );
-    if( pThis->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
+
+    if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
     {
         ImplControlValue aValue;
         Rectangle aControlRegion( (const Point&)Point(), Size( nCalcWidth, nMinHeight ) );
@@ -1611,7 +1610,7 @@ Size StatusBar::CalcWindowSizePixel() const
     }
 
     if( mpImplData->mbDrawItemFrames &&
-        pThis->IsNativeControlSupported( CTRL_FRAME, PART_BORDER ) )
+        IsNativeControlSupported( CTRL_FRAME, PART_BORDER ) )
     {
         ImplControlValue aControlValue( FRAME_DRAW_NODRAW );
         Rectangle aBound, aContent;
commit 1a8addc13734164d649974ea2f6426d12e8992a2
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Sat Jun 29 15:20:03 2013 +0400

    GetNativeControlRegion is const
    
    Change-Id: I0b34001e99036f197a50ff24b854e5a07eac6f06

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 4a649c2..b1b143f 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1187,7 +1187,7 @@ public:
     // These all just call through to the private mpGraphics functions of the same name.
 
     // Query the platform layer for control support
-    sal_Bool                IsNativeControlSupported( ControlType nType, ControlPart nPart );
+    sal_Bool                IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
 
     // Query the native control to determine if it was acted upon
     sal_Bool                HitTestNativeControl(   ControlType nType,
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 78a600b..a5781ee 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2903,7 +2903,7 @@ Size RadioButton::ImplGetRadioImageSize() const
         Rectangle aBoundingRgn, aContentRgn;
 
         // get native size of a radio button
-        if( pThis->GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
+        if( GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
                                            nState, aControlValue, OUString(),
                                            aBoundingRgn, aContentRgn ) )
         {
@@ -3837,7 +3837,7 @@ Size CheckBox::ImplGetCheckImageSize() const
         Rectangle aBoundingRgn, aContentRgn;
 
         // get native size of a check box
-        if( pThis->GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
+        if( GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
                                            nState, aControlValue, OUString(),
                                            aBoundingRgn, aContentRgn ) )
         {
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 513047c..a27fe60 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2926,7 +2926,7 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const
     ImplControlValue aControlValue;
     Rectangle aRect( Point( 0, 0 ), aSize );
     Rectangle aContent, aBound;
-    if( const_cast<Edit*>(this)->GetNativeControlRegion(
+    if( GetNativeControlRegion(
                    eCtrlType, PART_ENTIRE_CONTROL,
                    aRect, 0, aControlValue, OUString(), aBound, aContent) )
     {
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 4b5c1a4..abd4f23 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1256,8 +1256,8 @@ Size ListBox::CalcMinimumSize() const
         Rectangle aContent, aBound;
         Size aTestSize( 100, 20 );
         Rectangle aArea( aPoint, aTestSize );
-        if( const_cast<ListBox*>(this)->GetNativeControlRegion(
-                       CTRL_LISTBOX, PART_SUB_EDIT, aArea, 0, aControlValue, OUString(), aBound, aContent) )
+        if( GetNativeControlRegion( CTRL_LISTBOX, PART_SUB_EDIT, aArea, 0,
+                    aControlValue, OUString(), aBound, aContent) )
         {
             // use the themes drop down size
             aSz.Width() += aTestSize.Width() - aContent.GetWidth();
@@ -1273,8 +1273,8 @@ Size ListBox::CalcMinimumSize() const
         ImplControlValue aControlValue;
         Rectangle aRect( Point( 0, 0 ), aSz );
         Rectangle aContent, aBound;
-        if( const_cast<ListBox*>(this)->GetNativeControlRegion(
-                       CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, OUString(), aBound, aContent) )
+        if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, 0,
+                    aControlValue, OUString(), aBound, aContent) )
         {
             if( aBound.GetHeight() > aSz.Height() )
                 aSz.Height() = aBound.GetHeight();
diff --git a/vcl/source/gdi/outdevnative.cxx b/vcl/source/gdi/outdevnative.cxx
index 4727ba6..fe0ed27 100644
--- a/vcl/source/gdi/outdevnative.cxx
+++ b/vcl/source/gdi/outdevnative.cxx
@@ -147,7 +147,7 @@ PushButtonValue* PushButtonValue::clone() const
 
 // -----------------------------------------------------------------------
 
-sal_Bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPart )
+sal_Bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPart ) const
 {
     if( !lcl_enableNativeWidget( *this ) )
         return sal_False;
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 78705c7..7ec6fd7 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -1602,9 +1602,9 @@ Size StatusBar::CalcWindowSizePixel() const
         ImplControlValue aValue;
         Rectangle aControlRegion( (const Point&)Point(), Size( nCalcWidth, nMinHeight ) );
         Rectangle aNativeControlRegion, aNativeContentRegion;
-        if( pThis->GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
-                                           CTRL_STATE_ENABLED, aValue, OUString(),
-                                           aNativeControlRegion, aNativeContentRegion ) )
+        if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL,
+                    aControlRegion, CTRL_STATE_ENABLED, aValue, OUString(),
+                    aNativeControlRegion, aNativeContentRegion ) )
         {
             nProgressHeight = aNativeControlRegion.GetHeight();
         }
@@ -1616,8 +1616,8 @@ Size StatusBar::CalcWindowSizePixel() const
         ImplControlValue aControlValue( FRAME_DRAW_NODRAW );
         Rectangle aBound, aContent;
         Rectangle aNatRgn( Point( 0, 0 ), Size( 150, 50 ) );
-        if( pThis->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
-            aNatRgn, 0, aControlValue, OUString(), aBound, aContent) )
+        if( GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
+                    aNatRgn, 0, aControlValue, OUString(), aBound, aContent) )
         {
             mpImplData->mnItemBorderWidth =
                 ( aBound.GetHeight() - aContent.GetHeight() ) / 2;
commit c08a20b6480cceca4827bdc8796610d8a395b37a
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Sat Jun 29 15:01:11 2013 +0400

    reduce indentation level
    
    Change-Id: I4411ffaa3c8bc73891fc854894cca9d5ab1a1dc5

diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index d283daf..1b39450 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -498,59 +498,60 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
     ScrollbarValue scrValue;
 
     sal_Bool bNativeOK = IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
-    if( bNativeOK )
-    {
-        bool bHorz = (GetStyle() & WB_HORZ ? true : false);
+    if( !bNativeOK )
+        return sal_False;
 
-        // Draw the entire background if the control supports it
-        if( IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT) )
-        {
-            ControlState        nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 );
-
-            scrValue.mnMin = mnMinRange;
-            scrValue.mnMax = mnMaxRange;
-            scrValue.mnCur = mnThumbPos;
-            scrValue.mnVisibleSize = mnVisibleSize;
-            scrValue.maThumbRect = maThumbRect;
-            scrValue.maButton1Rect = maBtn1Rect;
-            scrValue.maButton2Rect = maBtn2Rect;
-            scrValue.mnButton1State = ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? CTRL_STATE_PRESSED : 0) |
-                                ((!(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)) ? CTRL_STATE_ENABLED : 0);
-            scrValue.mnButton2State = ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? CTRL_STATE_PRESSED : 0) |
-                                ((!(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)) ? CTRL_STATE_ENABLED : 0);
-            scrValue.mnThumbState = nState | ((mnStateFlags & SCRBAR_STATE_THUMB_DOWN) ? CTRL_STATE_PRESSED : 0);
-            scrValue.mnPage1State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? CTRL_STATE_PRESSED : 0);
-            scrValue.mnPage2State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? CTRL_STATE_PRESSED : 0);
+    bool bHorz = (GetStyle() & WB_HORZ ? true : false);
 
-            if( IsMouseOver() )
+    // Draw the entire background if the control supports it
+    if( IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT) )
+    {
+        ControlState        nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 );
+
+        scrValue.mnMin = mnMinRange;
+        scrValue.mnMax = mnMaxRange;
+        scrValue.mnCur = mnThumbPos;
+        scrValue.mnVisibleSize = mnVisibleSize;
+        scrValue.maThumbRect = maThumbRect;
+        scrValue.maButton1Rect = maBtn1Rect;
+        scrValue.maButton2Rect = maBtn2Rect;
+        scrValue.mnButton1State = ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? CTRL_STATE_PRESSED : 0) |
+                            ((!(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)) ? CTRL_STATE_ENABLED : 0);
+        scrValue.mnButton2State = ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? CTRL_STATE_PRESSED : 0) |
+                            ((!(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)) ? CTRL_STATE_ENABLED : 0);
+        scrValue.mnThumbState = nState | ((mnStateFlags & SCRBAR_STATE_THUMB_DOWN) ? CTRL_STATE_PRESSED : 0);
+        scrValue.mnPage1State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? CTRL_STATE_PRESSED : 0);
+        scrValue.mnPage2State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? CTRL_STATE_PRESSED : 0);
+
+        if( IsMouseOver() )
+        {
+            Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
+            if( pRect )
             {
-                Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
-                if( pRect )
-                {
-                    if( pRect == &maThumbRect )
-                        scrValue.mnThumbState |= CTRL_STATE_ROLLOVER;
-                    else if( pRect == &maBtn1Rect )
-                        scrValue.mnButton1State |= CTRL_STATE_ROLLOVER;
-                    else if( pRect == &maBtn2Rect )
-                        scrValue.mnButton2State |= CTRL_STATE_ROLLOVER;
-                    else if( pRect == &maPage1Rect )
-                        scrValue.mnPage1State |= CTRL_STATE_ROLLOVER;
-                    else if( pRect == &maPage2Rect )
-                        scrValue.mnPage2State |= CTRL_STATE_ROLLOVER;
-                }
+                if( pRect == &maThumbRect )
+                    scrValue.mnThumbState |= CTRL_STATE_ROLLOVER;
+                else if( pRect == &maBtn1Rect )
+                    scrValue.mnButton1State |= CTRL_STATE_ROLLOVER;
+                else if( pRect == &maBtn2Rect )
+                    scrValue.mnButton2State |= CTRL_STATE_ROLLOVER;
+                else if( pRect == &maPage1Rect )
+                    scrValue.mnPage1State |= CTRL_STATE_ROLLOVER;
+                else if( pRect == &maPage2Rect )
+                    scrValue.mnPage2State |= CTRL_STATE_ROLLOVER;
             }
-
-            Rectangle aCtrlRegion;
-            aCtrlRegion.Union( maBtn1Rect );
-            aCtrlRegion.Union( maBtn2Rect );
-            aCtrlRegion.Union( maPage1Rect );
-            aCtrlRegion.Union( maPage2Rect );
-            aCtrlRegion.Union( maThumbRect );
-            bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
-                            aCtrlRegion, nState, scrValue, OUString() );
         }
-        else
-      {
+
+        Rectangle aCtrlRegion;
+        aCtrlRegion.Union( maBtn1Rect );
+        aCtrlRegion.Union( maBtn2Rect );
+        aCtrlRegion.Union( maPage1Rect );
+        aCtrlRegion.Union( maPage2Rect );
+        aCtrlRegion.Union( maThumbRect );
+        bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
+                        aCtrlRegion, nState, scrValue, OUString() );
+    }
+    else
+    {
         if ( (nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2) )
         {
             sal_uInt32  part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
@@ -649,7 +650,6 @@ sal_Bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
             bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
                     aCtrlRegion, nState, scrValue, OUString() );
         }
-      }
     }
     return bNativeOK;
 }


More information about the Libreoffice-commits mailing list