diff options
author | Eike Rathke <erack@redhat.com> | 2017-11-20 23:30:50 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-11-21 11:19:24 +0100 |
commit | 77ee31f4f89a4db50064040d026feecbbfb7b20b (patch) | |
tree | 847c446f62f0c2778e279cacfc2a1f76abedde54 | |
parent | f63ecb5cd6d60fd8f2c096b4dbf04511590c1870 (diff) |
Render lock symbol with sheet name, tdf#95880 follow-up
Visually somewhat cleaner, plus may have benefits in RTL context
or could be easier adapted.
Change-Id: Iec75879e05c9c6bb602d3a368fb8eba59d1c8a13
Reviewed-on: https://gerrit.libreoffice.org/45012
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | svtools/source/control/tabbar.cxx | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index c25b7c07c536..cb9ee3fe007c 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -126,17 +126,6 @@ public: mrRenderContext.DrawCtrlText(aPos, aText, 0, aText.getLength(), (DrawTextFlags::Disable | DrawTextFlags::Mnemonic)); } - void drawProtectionSymbol(const OUString &aProtectionSymbol) - { - tools::Rectangle aRect = maRect; - long nSymbolHeight = mrRenderContext.GetTextHeight(); - Point aPos = aRect.TopLeft(); - aPos.X() += 2; - aPos.Y() += (aRect.getHeight() - nSymbolHeight) / 2; - - mrRenderContext.DrawText(aPos, aProtectionSymbol); - } - void drawOverTopBorder() { Point aTopLeft = maRect.TopLeft() + Point(1, 0); @@ -242,6 +231,18 @@ struct ImplTabBarItem { return mbSelect || (pCurItem == this); } + + OUString GetRenderText() const + { + if (!mbProtect) + return maText; + else + { + constexpr sal_uInt32 cLockChar[] = { 0x1F512, 0x2002 }; // Lock + EN SPACE + const OUString aLockSymbol( cLockChar, SAL_N_ELEMENTS(cLockChar)); + return aLockSymbol + maText; + } + } }; class ImplTabButton : public PushButton @@ -676,7 +677,7 @@ bool TabBar::ImplCalcWidth() bool bChanged = false; for (ImplTabBarItem* pItem : mpImpl->mpItemList) { - long nNewWidth = GetTextWidth(pItem->maText); + long nNewWidth = GetTextWidth(pItem->GetRenderText()); if (mnCurMaxWidth && (nNewWidth > mnCurMaxWidth)) { pItem->mbShort = true; @@ -1187,7 +1188,9 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r bool bSelected = pItem->IsSelected(pCurItem); // We disable custom background color in high contrast mode. bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode(); - OUString aText = pItem->mbShort ? rRenderContext.GetEllipsisString(pItem->maText, mnCurMaxWidth) : pItem->maText; + OUString aText = pItem->mbShort ? + rRenderContext.GetEllipsisString(pItem->GetRenderText(), mnCurMaxWidth) : + pItem->GetRenderText(); aDrawer.setRect(aRect); aDrawer.setSelected(bSelected); @@ -1232,13 +1235,6 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r aDrawer.drawText(aText); - if (pItem->mbProtect) - { - constexpr sal_uInt32 cLockChar = 0x1F512; - OUString aLockSymbol( &cLockChar, 1); - aDrawer.drawProtectionSymbol(aLockSymbol); - } - if (bCurrent) { rRenderContext.SetLineColor(); @@ -2064,8 +2060,15 @@ void TabBar::SetProtectionSymbol(sal_uInt16 nPageId, bool bProtection) sal_uInt16 nPos = GetPagePos(nPageId); if (nPos != PAGE_NOT_FOUND) { - mpImpl->mpItemList[nPos]->mbProtect = bProtection; - Invalidate(mpImpl->mpItemList[nPos]->maRect); + if (mpImpl->mpItemList[nPos]->mbProtect != bProtection) + { + mpImpl->mpItemList[nPos]->mbProtect = bProtection; + mbSizeFormat = true; // render text width changes, thus bar width + + // redraw bar + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); + } } } |