summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-03-06 18:42:14 +0100
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-03-12 13:02:45 -0500
commit8f805c57aadab54de421b0f961d0cbda9fa6d386 (patch)
tree7d1a87b42d237a772950bc07e3d735df0e65cb82 /sw
parent52cb1085edc66995393d5be5a55cb45b73a95292 (diff)
hidpi: Make many places Hi-DPI aware.
This also introduces a getter for the mnDPIScaleFactor variable. Change-Id: I02ba6858fb1842f911d62976f4c54afc3bfa337f Reviewed-on: https://gerrit.libreoffice.org/8517 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/utlui/content.cxx16
-rw-r--r--sw/source/ui/utlui/viewlayoutctrl.cxx45
2 files changed, 51 insertions, 10 deletions
diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx
index 20fb60fd832b..cd1fa45708ea 100644
--- a/sw/source/ui/utlui/content.cxx
+++ b/sw/source/ui/utlui/content.cxx
@@ -1333,6 +1333,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
@@ -3112,8 +3125,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 )