summaryrefslogtreecommitdiff
path: root/vcl/source
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 /vcl/source
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 'vcl/source')
-rw-r--r--vcl/source/gdi/image.cxx9
-rw-r--r--vcl/source/window/msgbox.cxx15
-rw-r--r--vcl/source/window/toolbox.cxx56
-rw-r--r--vcl/source/window/toolbox2.cxx20
4 files changed, 69 insertions, 31 deletions
diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx
index 33fd9192dcea..da65932ecaa9 100644
--- a/vcl/source/gdi/image.cxx
+++ b/vcl/source/gdi/image.cxx
@@ -537,11 +537,10 @@ void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
if( nId )
{
- RemoveImage( nId );
-
- if( !mpImplData )
- ImplInit( 0, rImage.GetSizePixel() );
- mpImplData->AddImage( rImageName, nId, rImage.GetBitmapEx());
+ //Just replace the bitmap rather than doing RemoveImage / AddImage
+ //which breaks index-based iteration.
+ ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
+ pImg->maBitmapEx = rImage.GetBitmapEx();
}
}
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index 82e216ade356..c733c03d6d67 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -249,12 +249,14 @@ void MessBox::ImplPosControls()
mpCheckBox = NULL;
}
- // Message-Text um Tabs bereinigen
+ // Clean up message text with tabs
OUString aMessText(maMessText.replaceAll("\t", " "));
- // Wenn Fenster zu schmall, machen wir Dialog auch breiter
+ //If window too small, we make dialog box be wider
if ( mpWindowImpl->mbFrame )
- nMaxWidth = 630;
+ {
+ nMaxWidth = 630 * GetDPIScaleFactor();
+ }
else if ( nMaxWidth < 120 )
nMaxWidth = 120;
@@ -286,18 +288,21 @@ void MessBox::ImplPosControls()
else
aTextPos.X() += IMPL_MSGBOX_OFFSET_EXTRA_X;
- // Maximale Zeilenlaenge ohne Wordbreak ermitteln
+ // Determine maximum line length without wordbreak
aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
nMaxLineWidth = aFormatRect.GetWidth();
nTextStyle |= TEXT_DRAW_WORDBREAK;
- // Breite fuer Textformatierung ermitteln
+ // Determine the width for text formatting
if ( nMaxLineWidth > 450 )
nWidth = 450;
else if ( nMaxLineWidth > 300 )
nWidth = nMaxLineWidth+5;
else
nWidth = 300;
+
+ nWidth *= GetDPIScaleFactor();
+
if ( nButtonSize > nWidth )
nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET);
if ( nWidth > nMaxWidth )
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 7a3e0a45ad52..0d7bf8a2c356 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2764,7 +2764,6 @@ IMPL_LINK_NOARG(ToolBox, ImplUpdateHdl)
}
// -----------------------------------------------------------------------
-
static void ImplDrawMoreIndicator( ToolBox *pBox, const Rectangle& rRect, sal_Bool bSetColor, sal_Bool bRotate )
{
Color aOldFillColor = pBox->GetFillColor();
@@ -2779,38 +2778,55 @@ static void ImplDrawMoreIndicator( ToolBox *pBox, const Rectangle& rRect, sal_Bo
pBox->SetFillColor( Color( COL_BLACK ) );
}
+ int linewidth = 1 * pBox->GetDPIScaleFactor();
+ int space = 4 * pBox->GetDPIScaleFactor();
+
if( !bRotate )
{
- long width = 8;
- long height = 5;
+ long width = 8 * pBox->GetDPIScaleFactor();
+ long height = 5 * pBox->GetDPIScaleFactor();
+
+ //Keep odd b/c drawing code works better
+ if ( height % 2 == 0 )
+ height--;
+
+ long heightOrig = height;
+
long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1;
long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1;
while( height >= 1)
{
- pBox->DrawRect( Rectangle( x, y, x+1, y ) );
- x+=4;
- pBox->DrawRect( Rectangle( x, y, x+1, y ) );
- x-=4;
+ pBox->DrawRect( Rectangle( x, y, x + linewidth, y ) );
+ x += space;
+ pBox->DrawRect( Rectangle( x, y, x + linewidth, y ) );
+ x -= space;
y++;
- if( height <= 3) x--;
+ if( height <= heightOrig / 2 + 1) x--;
else x++;
height--;
}
}
else
{
- long width = 5;
- long height = 8;
+ long width = 5 * pBox->GetDPIScaleFactor();
+ long height = 8 * pBox->GetDPIScaleFactor();
+
+ //Keep odd b/c drawing code works better
+ if (width % 2 == 0)
+ width--;
+
+ long widthOrig = width;
+
long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1;
long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1;
while( width >= 1)
{
- pBox->DrawRect( Rectangle( x, y, x, y+1 ) );
- y+=4;
- pBox->DrawRect( Rectangle( x, y, x, y+1 ) );
- y-=4;
+ pBox->DrawRect( Rectangle( x, y, x, y + linewidth ) );
+ y += space;
+ pBox->DrawRect( Rectangle( x, y, x, y + linewidth ) );
+ y -= space;
x++;
- if( width <= 3) y--;
+ if( width <= widthOrig / 2 + 1) y--;
else y++;
width--;
}
@@ -2838,8 +2854,9 @@ static void ImplDrawDropdownArrow( ToolBox *pBox, const Rectangle& rDropDownRect
if( !bRotate )
{
- long width = 5;
- long height = 3;
+ long width = 5 * pBox->GetDPIScaleFactor();
+ long height = 3 * pBox->GetDPIScaleFactor();
+
long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
while( width >= 1)
@@ -2851,8 +2868,9 @@ static void ImplDrawDropdownArrow( ToolBox *pBox, const Rectangle& rDropDownRect
}
else
{
- long width = 3;
- long height = 5;
+ long width = 3 * pBox->GetDPIScaleFactor();
+ long height = 5 * pBox->GetDPIScaleFactor();
+
long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
while( height >= 1)
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 683ce97c11b2..a0ae265b7719 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1020,6 +1020,7 @@ const Size& ToolBox::GetDefaultImageSize(bool bLarge)
aLargeButtonSize = Size( TB_LARGEIMAGESIZE, TB_LARGEIMAGESIZE );
}
}
+
return bLarge ? aLargeButtonSize : aSmallButtonSize;
}
@@ -1348,19 +1349,34 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
if ( nPos != TOOLBOX_ITEM_NOTFOUND )
{
+ Image aImage(rImage);
+
+ if ( GetDPIScaleFactor() > 1)
+ {
+ BitmapEx aBitmap(aImage.GetBitmapEx());
+
+ // Some code calls this twice, so add a sanity check
+ // FIXME find out what that code is & fix accordingly
+ if (aBitmap.GetSizePixel().Width() < 32)
+ {
+ aBitmap.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST);
+ aImage = Image(aBitmap);
+ }
+ }
+
ImplToolItem* pItem = &mpData->m_aItems[nPos];
// Nur wenn alles berechnet ist, mehr Aufwand treiben
if ( !mbCalc )
{
Size aOldSize = pItem->maImage.GetSizePixel();
- pItem->maImage = rImage;
+ pItem->maImage = aImage;
if ( aOldSize != pItem->maImage.GetSizePixel() )
ImplInvalidate( sal_True );
else
ImplUpdateItem( nPos );
}
else
- pItem->maImage = rImage;
+ pItem->maImage = aImage;
}
}