diff options
author | Keith Curtis <keithcu@gmail.com> | 2013-12-20 14:19:19 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2013-12-20 14:23:35 +0100 |
commit | 7347482cc360ad3dc9ed77047441c2e30476fed3 (patch) | |
tree | 7f56a9063dea777562d797ae720cd58d2b4e7de4 /svx/source/stbctrls | |
parent | a130de7e00bb426b15ec3b0ffc6bffc652d174ab (diff) |
hidpi: Make many places Hi-DPI aware.
This also introduces a getter for the mnDPIScaleFactor variable.
Change-Id: I02ba6858fb1842f911d62976f4c54afc3bfa337f
Diffstat (limited to 'svx/source/stbctrls')
-rw-r--r-- | svx/source/stbctrls/modctrl.cxx | 14 | ||||
-rw-r--r-- | svx/source/stbctrls/pszctrl.cxx | 11 | ||||
-rw-r--r-- | svx/source/stbctrls/selctrl.cxx | 7 | ||||
-rw-r--r-- | svx/source/stbctrls/xmlsecctrl.cxx | 25 | ||||
-rw-r--r-- | svx/source/stbctrls/zoomsliderctrl.cxx | 39 |
5 files changed, 82 insertions, 14 deletions
diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx index da2d40f44688..5f0168794769 100644 --- a/svx/source/stbctrls/modctrl.cxx +++ b/svx/source/stbctrls/modctrl.cxx @@ -64,6 +64,7 @@ struct SvxModifyControl::ImplData maImages[MODIFICATION_STATE_NO] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO)); maImages[MODIFICATION_STATE_YES] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES)); maImages[MODIFICATION_STATE_FEEDBACK] = Image(SVX_RES(RID_SVXBMP_DOC_MODIFIED_FEEDBACK)); + maTimer.SetTimeout(_FEEDBACK_TIMEOUT); } }; @@ -75,6 +76,19 @@ SvxModifyControl::SvxModifyControl( sal_uInt16 _nSlotId, SfxStatusBarControl( _nSlotId, _nId, rStb ), mpImpl(new ImplData) { + printf ("SvxModifyControl SF %d\n", rStb.GetDPIScaleFactor()); + printf ("SvxModifyControl DPIY %d\n", rStb.ImplGetDPIY()); + + if ( rStb.GetDPIScaleFactor() > 1 ) + { + for (int i = 0; i < mpImpl->MODIFICATION_STATE_SIZE; i++) + { + BitmapEx b = mpImpl->maImages[i].GetBitmapEx(); + b.Scale(rStb.GetDPIScaleFactor(), rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + mpImpl->maImages[i] = Image(b); + } + } + mpImpl->maTimer.SetTimeoutHdl( LINK(this, SvxModifyControl, OnTimer) ); } diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx index 89b9c19ede4b..733b8e7221a4 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -177,6 +177,17 @@ SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( sal_uInt16 _nSlotId, pImp->aPosImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); pImp->aSizeImage = Image( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) ); + if ( rStb.GetDPIScaleFactor() > 1) + { + BitmapEx b = pImp->aPosImage.GetBitmapEx(); + b.Scale(rStb.GetDPIScaleFactor(), rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + pImp->aPosImage = Image(b); + + b = pImp->aSizeImage.GetBitmapEx(); + b.Scale(rStb.GetDPIScaleFactor(), rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + pImp->aSizeImage = Image(b); + } + addStatusListener( OUString( STR_POSITION )); // SID_ATTR_POSITION addStatusListener( OUString( STR_TABLECELL )); // SID_TABLE_CELL addStatusListener( OUString( STR_FUNC )); // SID_PSZ_FUNCTION diff --git a/svx/source/stbctrls/selctrl.cxx b/svx/source/stbctrls/selctrl.cxx index e54760d3a9b6..9b77972d74de 100644 --- a/svx/source/stbctrls/selctrl.cxx +++ b/svx/source/stbctrls/selctrl.cxx @@ -80,6 +80,13 @@ SvxSelectionModeControl::SvxSelectionModeControl( sal_uInt16 _nSlotId, mnState( 0 ), maImage( SVX_RES( RID_SVXBMP_SELECTION ) ) { + if ( GetStatusBar().GetDPIScaleFactor() > 1 ) + { + BitmapEx b = maImage.GetBitmapEx(); + b.Scale(GetStatusBar().GetDPIScaleFactor(), GetStatusBar().GetDPIScaleFactor(), BMP_SCALE_FAST); + maImage = Image(b); + } + GetStatusBar().SetItemText( GetId(), "" ); } diff --git a/svx/source/stbctrls/xmlsecctrl.cxx b/svx/source/stbctrls/xmlsecctrl.cxx index b2e2eb9a0b89..46ea35b8b167 100644 --- a/svx/source/stbctrls/xmlsecctrl.cxx +++ b/svx/source/stbctrls/xmlsecctrl.cxx @@ -60,6 +60,23 @@ XmlSecStatusBarControl::XmlSecStatusBarControl( sal_uInt16 _nSlotId, sal_uInt16 mpImpl->maImage = Image( SVX_RES( RID_SVXBMP_SIGNET ) ); mpImpl->maImageBroken = Image( SVX_RES( RID_SVXBMP_SIGNET_BROKEN ) ); mpImpl->maImageNotValidated = Image( SVX_RES( RID_SVXBMP_SIGNET_NOTVALIDATED ) ); + + if (_rStb.GetDPIScaleFactor() > 1) + { + Image arr[3] = {mpImpl->maImage, mpImpl->maImageBroken, mpImpl->maImageNotValidated}; + + for (int i = 0; i < 3; i++) + { + BitmapEx b = arr[i].GetBitmapEx(); + b.Scale(_rStb.GetDPIScaleFactor(), _rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + arr[i] = Image(b); + } + + mpImpl->maImage = arr[0]; + mpImpl->maImageBroken = arr[1]; + mpImpl->maImageNotValidated = arr[2]; + } + } XmlSecStatusBarControl::~XmlSecStatusBarControl() @@ -135,20 +152,22 @@ void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) pDev->SetLineColor(); pDev->SetFillColor( pDev->GetBackground().GetColor() ); + long yOffset = (aRect.GetHeight() - mpImpl->maImage.GetSizePixel().Height()) / 2; + if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK ) { - ++aRect.Top(); + aRect.Top() += yOffset; pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage ); } else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN ) { - ++aRect.Top(); + aRect.Top() += yOffset; pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken ); } else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) { - ++aRect.Top(); + aRect.Top() += yOffset; pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated ); } else diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx index fc72cb621f8c..638a8505fb9a 100644 --- a/svx/source/stbctrls/zoomsliderctrl.cxx +++ b/svx/source/stbctrls/zoomsliderctrl.cxx @@ -66,12 +66,6 @@ struct SvxZoomSliderControl::SvxZoomSliderControl_Impl // ----------------------------------------------------------------------- -const long nButtonWidth = 10; -const long nButtonHeight = 10; -const long nIncDecWidth = 10; -const long nIncDecHeight = 10; -const long nSliderHeight = 2; -const long nSnappingHeight = 4; const long nSliderXOffset = 20; const long nSnappingEpsilon = 5; // snapping epsilon in pixels const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points @@ -175,6 +169,23 @@ SvxZoomSliderControl::SvxZoomSliderControl( sal_uInt16 _nSlotId, sal_uInt16 _nI mpImpl->maSliderButton = Image( SVX_RES( RID_SVXBMP_SLIDERBUTTON ) ); mpImpl->maIncreaseButton = Image( SVX_RES( RID_SVXBMP_SLIDERINCREASE ) ); mpImpl->maDecreaseButton = Image( SVX_RES( RID_SVXBMP_SLIDERDECREASE ) ); + + if ( _rStb.GetDPIScaleFactor() > 1) + { + Image arr[3] = {mpImpl->maSliderButton, mpImpl->maIncreaseButton, mpImpl->maDecreaseButton}; + + for (int i = 0; i < 3; i++) + { + BitmapEx b = arr[i].GetBitmapEx(); + //Use Lanczos scaling for the slider button because it does a better job with circles + b.Scale(_rStb.GetDPIScaleFactor(), _rStb.GetDPIScaleFactor(), i == 0 ? BMP_SCALE_LANCZOS : BMP_SCALE_FAST); + arr[i] = Image(b); + } + + mpImpl->maSliderButton = arr[0]; + mpImpl->maIncreaseButton = arr[1]; + mpImpl->maDecreaseButton = arr[2]; + } } // ----------------------------------------------------------------------- @@ -258,6 +269,9 @@ void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt ) Rectangle aRect = rUsrEvt.GetRect(); Rectangle aSlider = aRect; + long nSliderHeight = 2 * pDev->GetDPIScaleFactor(); + long nSnappingHeight = 4 * pDev->GetDPIScaleFactor(); + aSlider.Top() += (aControlRect.GetHeight() - nSliderHeight)/2; aSlider.Bottom() = aSlider.Top() + nSliderHeight - 1; aSlider.Left() += nSliderXOffset; @@ -270,6 +284,7 @@ void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt ) pDev->SetLineColor( rStyleSettings.GetShadowColor() ); pDev->SetFillColor( rStyleSettings.GetShadowColor() ); + // draw snapping points: std::vector< long >::iterator aSnappingPointIter; for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin(); @@ -288,18 +303,18 @@ void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt ) // draw slider button Point aImagePoint = aRect.TopLeft(); aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom ); - aImagePoint.X() -= nButtonWidth/2; - aImagePoint.Y() += (aControlRect.GetHeight() - nButtonHeight)/2; + aImagePoint.X() -= mpImpl->maSliderButton.GetSizePixel().Width()/2; + aImagePoint.Y() += (aControlRect.GetHeight() - mpImpl->maSliderButton.GetSizePixel().Height())/2; pDev->DrawImage( aImagePoint, mpImpl->maSliderButton ); // draw decrease button aImagePoint = aRect.TopLeft(); - aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2; - aImagePoint.Y() += (aControlRect.GetHeight() - nIncDecHeight)/2; + aImagePoint.X() += (nSliderXOffset - mpImpl->maDecreaseButton.GetSizePixel().Width())/2; + aImagePoint.Y() += (aControlRect.GetHeight() - mpImpl->maDecreaseButton.GetSizePixel().Height())/2; pDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton ); // draw increase button - aImagePoint.X() = aRect.TopLeft().X() + aControlRect.GetWidth() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2; + aImagePoint.X() = aRect.TopLeft().X() + aControlRect.GetWidth() - mpImpl->maIncreaseButton.GetSizePixel().Width() - (nSliderXOffset - mpImpl->maIncreaseButton.GetSizePixel().Height())/2; pDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton ); pDev->SetLineColor( aOldLineColor ); @@ -317,6 +332,8 @@ sal_Bool SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt ) const Point aPoint = rEvt.GetPosPixel(); const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left(); + long nIncDecWidth = mpImpl->maIncreaseButton.GetSizePixel().Width(); + const long nButtonLeftOffset = (nSliderXOffset - nIncDecWidth)/2; const long nButtonRightOffset = (nSliderXOffset + nIncDecWidth)/2; |