diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-01-08 17:29:30 +0100 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-01-08 17:29:30 +0100 |
commit | 381b25700787c4530dc28f548a38d224c074bd12 (patch) | |
tree | cb2e069df15c8fd1b315d6555589c8653419caf0 /vcl/source/control/slider.cxx | |
parent | 51d977e00c8481d89cb682a05536e88cdf2fffa4 (diff) |
vcl109: #i33688# NWF slider implementation (mac)
Diffstat (limited to 'vcl/source/control/slider.cxx')
-rw-r--r-- | vcl/source/control/slider.cxx | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 2923c382bbdd..52a927d27d95 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -171,6 +171,7 @@ void Slider::ImplInitSettings() void Slider::ImplUpdateRects( BOOL bUpdate ) { Rectangle aOldThumbRect = maThumbRect; + bool bInvalidateAll = false; if ( mnThumbPixRange ) { @@ -196,6 +197,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) } else maChannel2Rect.SetEmpty(); + + const Region aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) ); + Region aThumbBounds, aThumbContent; + if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ, + aControlRegion, 0, ImplControlValue(), rtl::OUString(), + aThumbBounds, aThumbContent ) ) + { + Rectangle aRect( aThumbBounds.GetBoundRect() ); + maThumbRect.Left() = mnThumbPixPos - aRect.GetWidth()/2; + maThumbRect.Right() = maThumbRect.Left() + aRect.GetWidth() - 1; + bInvalidateAll = true; + } } else { @@ -219,6 +232,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) } else maChannel2Rect.SetEmpty(); + + const Region aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) ); + Region aThumbBounds, aThumbContent; + if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT, + aControlRegion, 0, ImplControlValue(), rtl::OUString(), + aThumbBounds, aThumbContent ) ) + { + Rectangle aRect( aThumbBounds.GetBoundRect() ); + maThumbRect.Top() = mnThumbPixPos - aRect.GetHeight()/2; + maThumbRect.Bottom() = maThumbRect.Top() + aRect.GetHeight() - 1; + bInvalidateAll = true; + } } } else @@ -232,17 +257,22 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) { if ( aOldThumbRect != maThumbRect ) { - Region aInvalidRegion( aOldThumbRect ); - aInvalidRegion.Union( maThumbRect ); - - if( !IsBackground() && GetParent() ) + if( bInvalidateAll ) + Invalidate(); + else { - const Point aPos( GetPosPixel() ); - aInvalidRegion.Move( aPos.X(), aPos.Y() ); - GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE ); + Region aInvalidRegion( aOldThumbRect ); + aInvalidRegion.Union( maThumbRect ); + + if( !IsBackground() && GetParent() ) + { + const Point aPos( GetPosPixel() ); + aInvalidRegion.Move( aPos.X(), aPos.Y() ); + GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE ); + } + else + Invalidate( aInvalidRegion ); } - else - Invalidate( aInvalidRegion ); } } } @@ -360,6 +390,29 @@ void Slider::ImplDraw( USHORT nDrawFlags ) if ( mbCalcSize ) ImplCalc( FALSE ); + ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA; + ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + ControlState nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 ); + SliderValue sldValue; + + sldValue.mnMin = mnMinRange; + sldValue.mnMax = mnMaxRange; + sldValue.mnCur = mnThumbPos; + sldValue.maThumbRect = maThumbRect; + + if( IsMouseOver() ) + { + if( maThumbRect.IsInside( GetPointerPosPixel() ) ) + sldValue.mnThumbState |= CTRL_STATE_ROLLOVER; + } + aControlValue.setOptionalVal( (void *)(&sldValue) ); + + const Region aCtrlRegion( Rectangle( Point(0,0), GetOutputSizePixel() ) ); + bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart, + aCtrlRegion, nState, aControlValue, rtl::OUString() ); + if( bNativeOK ) + return; + if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() ) { long nRectSize; |