diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-03-06 18:42:14 +0100 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-12 13:02:45 -0500 |
commit | 8f805c57aadab54de421b0f961d0cbda9fa6d386 (patch) | |
tree | 7d1a87b42d237a772950bc07e3d735df0e65cb82 | |
parent | 52cb1085edc66995393d5be5a55cb45b73a95292 (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>
-rw-r--r-- | cui/source/tabpages/align.cxx | 12 | ||||
-rw-r--r-- | cui/source/tabpages/border.cxx | 22 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.cxx | 3 | ||||
-rw-r--r-- | sd/uiconfig/sdraw/statusbar/statusbar.xml | 2 | ||||
-rw-r--r-- | sd/uiconfig/simpress/statusbar/statusbar.xml | 2 | ||||
-rw-r--r-- | svx/source/dialog/dialcontrol.cxx | 5 | ||||
-rw-r--r-- | svx/source/stbctrls/modctrl.cxx | 16 | ||||
-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 | ||||
-rw-r--r-- | svx/source/tbxctrls/layctrl.cxx | 81 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.src | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/utlui/content.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/utlui/viewlayoutctrl.cxx | 45 | ||||
-rw-r--r-- | vcl/source/gdi/image.cxx | 9 | ||||
-rw-r--r-- | vcl/source/window/msgbox.cxx | 15 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 56 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 20 |
21 files changed, 291 insertions, 101 deletions
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx index 9aa47e8566dc..5ba830af9521 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -322,6 +322,18 @@ void AlignmentTabPage::InitVsRefEgde() ResId aResId( IL_LOCK_BMPS, CUI_MGR() ); ImageList aImageList( aResId ); + + if( GetDPIScaleFactor() > 1 ) + { + for (short i = 0; i < aImageList.GetImageCount(); i++) + { + OUString rImageName = aImageList.GetImageName(i); + BitmapEx b = aImageList.GetImage(rImageName).GetBitmapEx(); + b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST); + aImageList.ReplaceImage(rImageName, Image(b)); + } + } + Size aItemSize( aImageList.GetImage( IID_BOTTOMLOCK ).GetSizePixel() ); m_pVsRefEdge->Clear(); diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index d2d12ac14355..8c436233f3c1 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -88,9 +88,6 @@ SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs , - - - aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)), aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)), nMinValue(0), @@ -132,6 +129,25 @@ SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs get(m_pMergeWithNextCB, "mergewithnext"); get(m_pMergeAdjacentBordersCB, "mergeadjacent"); + if ( GetDPIScaleFactor() > 1 ) + { + for (short i = 0; i < aBorderImgLst.GetImageCount(); i++) + { + OUString rImageName = aBorderImgLst.GetImageName(i); + BitmapEx b = aBorderImgLst.GetImage(rImageName).GetBitmapEx(); + b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST); + aBorderImgLst.ReplaceImage(rImageName, Image(b)); + } + + for (short i = 0; i < aShadowImgLst.GetImageCount(); i++) + { + OUString rImageName = aShadowImgLst.GetImageName(i); + BitmapEx b = aShadowImgLst.GetImage(rImageName).GetBitmapEx(); + b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST); + aShadowImgLst.ReplaceImage(rImageName, Image(b)); + } + } + // this page needs ExchangeSupport SetExchangeSupport(); diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 1bd07a271e36..d7e2bf48a4e6 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -563,6 +563,8 @@ public: */ bool supportsOperation( OutDevSupportType ) const; + sal_Int32 GetDPIScaleFactor() const { return mnDPIScaleFactor; } + vcl::PDFWriterImpl* GetPDFWriter() const { return mpPDFWriter; } void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; } diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index 11138d9c8ea8..5abb05ca0f5e 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -650,6 +650,9 @@ void LayoutMenu::Fill (void) { BitmapEx aBmp(SdResId(pInfo->mnBmpResId)); + if (GetDPIScaleFactor() > 1) + aBmp.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST); + if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode)) aBmp.Mirror (BMP_MIRROR_HORZ); diff --git a/sd/uiconfig/sdraw/statusbar/statusbar.xml b/sd/uiconfig/sdraw/statusbar/statusbar.xml index 81eb908cdd6a..24224fe3cadb 100644 --- a/sd/uiconfig/sdraw/statusbar/statusbar.xml +++ b/sd/uiconfig/sdraw/statusbar/statusbar.xml @@ -19,7 +19,7 @@ --> <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> <statusbar:statusbaritem xlink:href=".uno:Context" statusbar:align="left" statusbar:autosize="true" statusbar:width="184"/> - <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="208"/> + <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="400"/> <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:PageStatus" statusbar:align="left" statusbar:width="124"/> diff --git a/sd/uiconfig/simpress/statusbar/statusbar.xml b/sd/uiconfig/simpress/statusbar/statusbar.xml index 81eb908cdd6a..24224fe3cadb 100644 --- a/sd/uiconfig/simpress/statusbar/statusbar.xml +++ b/sd/uiconfig/simpress/statusbar/statusbar.xml @@ -19,7 +19,7 @@ --> <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> <statusbar:statusbaritem xlink:href=".uno:Context" statusbar:align="left" statusbar:autosize="true" statusbar:width="184"/> - <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="208"/> + <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="400"/> <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:PageStatus" statusbar:align="left" statusbar:width="124"/> diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx index 42e4e6f43d4e..4a780a6cf411 100644 --- a/svx/source/dialog/dialcontrol.cxx +++ b/svx/source/dialog/dialcontrol.cxx @@ -449,8 +449,13 @@ void DialControl::Init( const Size& rWinSize, const Font& rWinFont ) void DialControl::Init( const Size& rWinSize ) { + //hidpi TODO: GetDefaultFont() picks a font size too small, so fix it here. + Font aDefaultSize = GetFont(); + Font aFont( OutputDevice::GetDefaultFont( DEFAULTFONT_UI_SANS, Application::GetSettings().GetUILanguageTag().getLanguageType(), DEFAULTFONT_FLAGS_ONLYONE ) ); + + aFont.SetHeight(aDefaultSize.GetHeight()); Init( rWinSize, aFont ); } diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx index da2d40f44688..db94f49bad12 100644 --- a/svx/source/stbctrls/modctrl.cxx +++ b/svx/source/stbctrls/modctrl.cxx @@ -64,17 +64,25 @@ 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); } }; -SvxModifyControl::SvxModifyControl( sal_uInt16 _nSlotId, - sal_uInt16 _nId, - StatusBar& rStb ) : - +SvxModifyControl::SvxModifyControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : SfxStatusBarControl( _nSlotId, _nId, rStb ), mpImpl(new ImplData) { + 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 ad9c22b99286..4a56334f1ad9 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -178,6 +178,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; diff --git a/svx/source/tbxctrls/layctrl.cxx b/svx/source/tbxctrls/layctrl.cxx index f004fe310e1d..2c2b1e2e7f41 100644 --- a/svx/source/tbxctrls/layctrl.cxx +++ b/svx/source/tbxctrls/layctrl.cxx @@ -43,18 +43,6 @@ SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl,SfxUInt16Item); // class TableWindow ----------------------------------------------------- -const long TABLE_CELL_WIDTH = 15; -const long TABLE_CELL_HEIGHT = 15; - -const long TABLE_CELLS_HORIZ = 10; -const long TABLE_CELLS_VERT = 15; - -const long TABLE_POS_X = 2; -const long TABLE_POS_Y = 2; - -const long TABLE_WIDTH = TABLE_POS_X + TABLE_CELLS_HORIZ*TABLE_CELL_WIDTH; -const long TABLE_HEIGHT = TABLE_POS_Y + TABLE_CELLS_VERT*TABLE_CELL_HEIGHT; - class TableWindow : public SfxPopupWindow { private: @@ -71,6 +59,18 @@ private: Reference< XFrame > mxFrame; OUString maCommand; + static const long TABLE_CELLS_HORIZ; + static const long TABLE_CELLS_VERT; + + long mnTableCellWidth; + long mnTableCellHeight; + + long mnTablePosX; + long mnTablePosY; + + long mnTableWidth; + long mnTableHeight; + DECL_LINK( SelectHdl, void * ); public: @@ -94,6 +94,9 @@ private: void CloseAndShowTableDialog(); }; +const long TableWindow::TABLE_CELLS_HORIZ = 10; +const long TableWindow::TABLE_CELLS_VERT = 15; + // ----------------------------------------------------------------------- IMPL_LINK_NOARG(TableWindow, SelectHdl) @@ -111,8 +114,16 @@ TableWindow::TableWindow( sal_uInt16 nSlotId, const OUString& rCmd, const OUStri nLine( 0 ), rTbx(rParentTbx), mxFrame( rFrame ), - maCommand( rCmd ) + maCommand( rCmd ), + mnTablePosX(2), + mnTablePosY(2) { + mnTableCellWidth = 15 * GetDPIScaleFactor(); + mnTableCellHeight = 15 * GetDPIScaleFactor(); + + mnTableWidth = mnTablePosX + TABLE_CELLS_HORIZ*mnTableCellWidth; + mnTableHeight = mnTablePosY + TABLE_CELLS_VERT*mnTableCellHeight; + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); svtools::ColorConfig aColorConfig; @@ -130,13 +141,13 @@ TableWindow::TableWindow( sal_uInt16 nSlotId, const OUString& rCmd, const OUStri SetText( rText ); - aTableButton.SetPosSizePixel( Point( TABLE_POS_X + TABLE_CELL_WIDTH, TABLE_HEIGHT + 5 ), - Size( TABLE_WIDTH - TABLE_POS_X - 2*TABLE_CELL_WIDTH, 24 ) ); + aTableButton.SetPosSizePixel( Point( mnTablePosX + mnTableCellWidth, mnTableHeight + 5 ), + Size( mnTableWidth - mnTablePosX - 2*mnTableCellWidth, 24 ) ); aTableButton.SetText( SVX_RESSTR( RID_SVXSTR_MORE ) ); aTableButton.SetClickHdl( LINK( this, TableWindow, SelectHdl ) ); aTableButton.Show(); - SetOutputSizePixel( Size( TABLE_WIDTH + 3, TABLE_HEIGHT + 33 ) ); + SetOutputSizePixel( Size( mnTableWidth + 3, mnTableHeight + 33 ) ); } // ----------------------------------------------------------------------- @@ -160,8 +171,8 @@ void TableWindow::MouseMove( const MouseEvent& rMEvt ) Point aPos = rMEvt.GetPosPixel(); Point aMousePos( aPos ); - long nNewCol = ( aMousePos.X() - TABLE_POS_X + TABLE_CELL_WIDTH ) / TABLE_CELL_WIDTH; - long nNewLine = ( aMousePos.Y() - TABLE_POS_Y + TABLE_CELL_HEIGHT ) / TABLE_CELL_HEIGHT; + long nNewCol = ( aMousePos.X() - mnTablePosX + mnTableCellWidth ) / mnTableCellWidth; + long nNewLine = ( aMousePos.Y() - mnTablePosY + mnTableCellHeight ) / mnTableCellHeight; Update( nNewCol, nNewLine ); } @@ -252,33 +263,33 @@ void TableWindow::MouseButtonUp( const MouseEvent& rMEvt ) void TableWindow::Paint( const Rectangle& ) { - const long nSelectionWidth = TABLE_POS_X + nCol*TABLE_CELL_WIDTH; - const long nSelectionHeight = TABLE_POS_Y + nLine*TABLE_CELL_HEIGHT; + const long nSelectionWidth = mnTablePosX + nCol*mnTableCellWidth; + const long nSelectionHeight = mnTablePosY + nLine*mnTableCellHeight; // the non-selected parts of the table SetLineColor( aLineColor ); SetFillColor( aFillColor ); - DrawRect( Rectangle( nSelectionWidth, TABLE_POS_Y, TABLE_WIDTH, nSelectionHeight ) ); - DrawRect( Rectangle( TABLE_POS_X, nSelectionHeight, nSelectionWidth, TABLE_HEIGHT ) ); - DrawRect( Rectangle( nSelectionWidth, nSelectionHeight, TABLE_WIDTH, TABLE_HEIGHT ) ); + DrawRect( Rectangle( nSelectionWidth, mnTablePosY, mnTableWidth, nSelectionHeight ) ); + DrawRect( Rectangle( mnTablePosX, nSelectionHeight, nSelectionWidth, mnTableHeight ) ); + DrawRect( Rectangle( nSelectionWidth, nSelectionHeight, mnTableWidth, mnTableHeight ) ); // the selection if ( nCol > 0 && nLine > 0 ) { SetFillColor( aHighlightFillColor ); - DrawRect( Rectangle( TABLE_POS_X, TABLE_POS_Y, + DrawRect( Rectangle( mnTablePosX, mnTablePosY, nSelectionWidth, nSelectionHeight ) ); } // lines inside of the table SetLineColor( aLineColor ); for ( long i = 1; i < TABLE_CELLS_VERT; ++i ) - DrawLine( Point( TABLE_POS_X, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ), - Point( TABLE_WIDTH, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ) ); + DrawLine( Point( mnTablePosX, mnTablePosY + i*mnTableCellHeight ), + Point( mnTableWidth, mnTablePosY + i*mnTableCellHeight ) ); for ( long i = 1; i < TABLE_CELLS_HORIZ; ++i ) - DrawLine( Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_POS_Y ), - Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_HEIGHT ) ); + DrawLine( Point( mnTablePosX + i*mnTableCellWidth, mnTablePosY ), + Point( mnTablePosX + i*mnTableCellWidth, mnTableHeight ) ); // the text near the mouse cursor telling the table dimensions if ( nCol && nLine ) @@ -295,15 +306,15 @@ void TableWindow::Paint( const Rectangle& ) Size aTextSize( GetTextWidth( aText ), GetTextHeight() ); - long nTextX = nSelectionWidth + TABLE_CELL_WIDTH; - long nTextY = nSelectionHeight + TABLE_CELL_HEIGHT; + long nTextX = nSelectionWidth + mnTableCellWidth; + long nTextY = nSelectionHeight + mnTableCellHeight; const long nTipBorder = 2; - if ( aTextSize.Width() + TABLE_POS_X + TABLE_CELL_WIDTH + 2*nTipBorder < nSelectionWidth ) - nTextX = nSelectionWidth - TABLE_CELL_WIDTH - aTextSize.Width(); + if ( aTextSize.Width() + mnTablePosX + mnTableCellWidth + 2*nTipBorder < nSelectionWidth ) + nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.Width(); - if ( aTextSize.Height() + TABLE_POS_Y + TABLE_CELL_HEIGHT + 2*nTipBorder < nSelectionHeight ) - nTextY = nSelectionHeight - TABLE_CELL_HEIGHT - aTextSize.Height(); + if ( aTextSize.Height() + mnTablePosY + mnTableCellHeight + 2*nTipBorder < nSelectionHeight ) + nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height(); SetLineColor( aLineColor ); SetFillColor( aBackgroundColor ); @@ -350,7 +361,7 @@ void TableWindow::Update( long nNewCol, long nNewLine ) { nCol = nNewCol; nLine = nNewLine; - Invalidate( Rectangle( TABLE_POS_X, TABLE_POS_Y, TABLE_WIDTH, TABLE_HEIGHT ) ); + Invalidate( Rectangle( mnTablePosX, mnTablePosY, mnTableWidth, mnTableHeight ) ); } } diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src index 4d2cfbc13a73..665f0fa5c2af 100644 --- a/svx/source/tbxctrls/tbcontrl.src +++ b/svx/source/tbxctrls/tbcontrl.src @@ -74,7 +74,7 @@ String RID_SVXSTR_FRAME_COLOR ComboBox RID_SVXTBX_STYLE { HelpId = HID_STYLE_LISTBOX ; - Size = MAP_APPFONT ( 67 , 86 ) ; + Size = MAP_APPFONT ( 50 , 86 ) ; DropDown = TRUE ; Sort = TRUE ; AutoHScroll = TRUE ; diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index 36e257e5d876..c34384466b6e 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -85,7 +85,7 @@ SvxFontSizeBox_Impl::SvxFontSizeBox_Impl( FontSizeBox( _pParent, WinBits( WB_DROPDOWN ) ), m_pCtrl ( &_rCtrl ), - m_aLogicalSize ( 30,100 ), + m_aLogicalSize ( 20,100 ), m_bRelease ( true ), m_xDispatchProvider ( _rDispatchProvider ), m_xFrame ( _xFrame ) 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 ) 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; } } |