summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-10-28 18:30:47 +0200
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-10-28 18:30:47 +0200
commitedab85623d2fa18a5ba030c2eb2c6cc8260f162d (patch)
tree013cca1c55c714cede3371df6e5a4388489e4b37 /vcl
parent78b10685ef7c732c6b781bdef36754a2ebe8c485 (diff)
vcl116: #i97830# take accelerator sign (tilde) into account when checking for ellipsis string
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menu.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 446c541826a5..ceb9f12242c0 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2583,6 +2583,26 @@ static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRec
}
}
+static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_nMaxWidth )
+{
+ xub_StrLen nPos = STRING_NOTFOUND;
+ String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
+ aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth );
+ // re-insert mnemonic
+ if( nPos != STRING_NOTFOUND )
+ {
+ if( nPos < aNonMnem.Len() && i_rLong.GetChar(nPos+1) == aNonMnem.GetChar(nPos) )
+ {
+ rtl::OUStringBuffer aBuf( i_rLong.Len() );
+ aBuf.append( aNonMnem.GetBuffer(), nPos );
+ aBuf.append( sal_Unicode('~') );
+ aBuf.append( aNonMnem.GetBuffer()+nPos );
+ aNonMnem = aBuf.makeStringAndClear();
+ }
+ }
+ return aNonMnem;
+}
+
void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData* pThisItemOnly, BOOL bHighlighted, bool bLayout ) const
{
// Fuer Symbole: nFontHeight x nFontHeight
@@ -2778,13 +2798,13 @@ void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData*
if( !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() )
{
XubString aAccText = pData->aAccelKey.GetName();
- nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 4*nExtra;
+ nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 3*nExtra;
}
if( !bIsMenuBar && pData->pSubMenu )
{
nMaxItemTextWidth -= nFontHeight + nExtra;
}
- String aItemText( pWin->GetEllipsisString( pData->aText, nMaxItemTextWidth ) );
+ String aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) );
pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.Len(), nStyle, pVector, pDisplayText );
if( bSetTmpBackground )
pWin->SetBackground();