diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-08 12:33:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-24 13:04:21 +0200 |
commit | faa4ebb2cdc99505e9be7e1cbed83b19acfd3c4a (patch) | |
tree | 0d6ee926ac5cc5b12262ecc9f47e2e40cc5d3e8d /vcl/source | |
parent | 808da2c918e662c19618c9f4035e8c9a802bb887 (diff) |
tdf#127411 improve sizing of status items in the status bar
Change-Id: I6ea3fbb893d0141010ee1abd1720d6cdad97b528
Reviewed-on: https://gerrit.libreoffice.org/80440
Tested-by: Xisco Faulí <xiscofauli@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/status.cxx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 03b9b41e62a2..92fb94d66587 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -19,6 +19,7 @@ #include <sal/log.hxx> +#include <comphelper/string.hxx> #include <vcl/event.hxx> #include <vcl/decoview.hxx> #include <vcl/svapp.hxx> @@ -1126,7 +1127,7 @@ long StatusBar::GetItemOffset( sal_uInt16 nItemId ) const return 0; } -void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText ) +void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCharsWidth ) { sal_uInt16 nPos = GetItemPos( nItemId ); @@ -1141,12 +1142,22 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText ) // adjust item width - see also DataChanged() long nFudge = GetTextHeight()/4; - std::unique_ptr<SalLayout> pSalLayout = ImplLayout(pItem->maText,0,-1); - const SalLayoutGlyphs* pGlyphs = pSalLayout ? pSalLayout->GetGlyphs() : nullptr; - long nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pGlyphs ) + nFudge; - - // Store the calculated layout. - pItem->mxLayoutCache = std::move(pSalLayout); + long nWidth; + if (nCharsWidth != -1) + { + std::unique_ptr<SalLayout> pSalLayout = ImplLayout("0",0,-1); + const SalLayoutGlyphs* pGlyphs = pSalLayout ? pSalLayout->GetGlyphs() : nullptr; + nWidth = GetTextWidth("0",0,-1,nullptr,pGlyphs ); + nWidth = nWidth * nCharsWidth + nFudge; + } + else + { + std::unique_ptr<SalLayout> pSalLayout = ImplLayout(pItem->maText,0,-1); + const SalLayoutGlyphs* pGlyphs = pSalLayout ? pSalLayout->GetGlyphs() : nullptr; + nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pGlyphs ) + nFudge; + // Store the calculated layout. + pItem->mxLayoutCache = std::move(pSalLayout); + } if( (nWidth > pItem->mnWidth + STATUSBAR_OFFSET) || ((nWidth < pItem->mnWidth) && (mnDX - STATUSBAR_OFFSET) < mnItemsWidth )) |