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 /sw | |
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 'sw')
-rw-r--r-- | sw/source/ui/utlui/content.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/utlui/viewlayoutctrl.cxx | 45 |
2 files changed, 51 insertions, 10 deletions
diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index df288d45b88f..71d4a518c298 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -1561,6 +1561,19 @@ void SwContentTree::Display( bool bActive ) if(!bIsImageListInitialized) { aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP)); + + if ( GetDPIScaleFactor() > 1 ) + { + for (short i = 0; i < aEntryImages.GetImageCount(); i++) + { + OUString rImageName = aEntryImages.GetImageName(i); + BitmapEx b = aEntryImages.GetImage(rImageName).GetBitmapEx(); + //Use Lanczos because it looks better with circles / diagonals + b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_LANCZOS); + aEntryImages.ReplaceImage(rImageName, Image(b)); + } + } + bIsImageListInitialized = true; } // First read the selected entry to select it later again if necessary @@ -3478,8 +3491,9 @@ void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt ) if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) { - aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP)); FindActiveTypeAndRemoveUserData(); + + bIsImageListInitialized = false; Display(true); } SvTreeListBox::DataChanged( rDCEvt ); diff --git a/sw/source/ui/utlui/viewlayoutctrl.cxx b/sw/source/ui/utlui/viewlayoutctrl.cxx index 01a8985c6961..00d409e6c115 100644 --- a/sw/source/ui/utlui/viewlayoutctrl.cxx +++ b/sw/source/ui/utlui/viewlayoutctrl.cxx @@ -28,12 +28,6 @@ SFX_IMPL_STATUSBAR_CONTROL( SwViewLayoutControl, SvxViewLayoutItem ); -const long nImageWidthSingle = 14; -const long nImageWidthAuto = 24; -const long nImageWidthBook = 22; -const long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; -const long nImageHeight = 10; - struct SwViewLayoutControl::SwViewLayoutControl_Impl { sal_uInt16 mnState; // 0 = single, 1 = auto, 2 = book, 3 = none @@ -57,6 +51,30 @@ SwViewLayoutControl::SwViewLayoutControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, mpImpl->maImageAutomatic_Active = Image( SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE) ); mpImpl->maImageBookMode = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE) ); mpImpl->maImageBookMode_Active = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE_ACTIVE) ); + + if ( rStb.GetDPIScaleFactor() > 1) + { + Image arr[6] = {mpImpl->maImageSingleColumn, mpImpl->maImageSingleColumn_Active, + mpImpl->maImageAutomatic, mpImpl->maImageAutomatic_Active, + mpImpl->maImageBookMode, mpImpl->maImageBookMode_Active}; + + for (int i = 0; i < 6; i++) + { + BitmapEx b = arr[i].GetBitmapEx(); + //Don't scale width, no space. + b.Scale(1.0, rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + arr[i] = Image(b); + } + + mpImpl->maImageSingleColumn = arr[0]; + mpImpl->maImageSingleColumn_Active = arr[1]; + + mpImpl->maImageAutomatic = arr[2]; + mpImpl->maImageAutomatic_Active = arr[3]; + + mpImpl->maImageBookMode = arr[4]; + mpImpl->maImageBookMode_Active = arr[5]; + } } SwViewLayoutControl::~SwViewLayoutControl() @@ -102,8 +120,12 @@ void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) const bool bAutomatic = 1 == mpImpl->mnState; const bool bBookMode = 2 == mpImpl->mnState; + const long nImageWidthSum = mpImpl->maImageSingleColumn.GetSizePixel().Width() + + mpImpl->maImageAutomatic.GetSizePixel().Width() + + mpImpl->maImageBookMode.GetSizePixel().Width(); + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; - const long nYOffset = (aControlRect.GetHeight() - nImageHeight)/2; + const long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height())/2; aRect.Left() = aRect.Left() + nXOffset; aRect.Top() = aRect.Top() + nYOffset; @@ -112,11 +134,11 @@ void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn ); // draw automatic image: - aRect.Left() += nImageWidthSingle; + aRect.Left() += mpImpl->maImageSingleColumn.GetSizePixel().Width(); pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic ); // draw bookmode image: - aRect.Left() += nImageWidthAuto; + aRect.Left() += mpImpl->maImageAutomatic.GetSizePixel().Width(); pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode ); } @@ -129,6 +151,11 @@ sal_Bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt ) sal_uInt16 nColumns = 1; bool bBookMode = false; + const long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); + const long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); + const long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); + const long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; if ( nXDiff < nXOffset + nImageWidthSingle ) |