summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-10-29 18:59:15 +0200
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-10-29 18:59:15 +0200
commit62a759ce1ee86124eb62cdabf86e226aab470a0a (patch)
tree36f3430556bff7bb26a5e9072af8ebc3af1c58d1 /vcl
parentedab85623d2fa18a5ba030c2eb2c6cc8260f162d (diff)
vcl116: #i97830# new ellipsis text style for menus
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/outdev.hxx5
-rw-r--r--vcl/source/gdi/outdev3.cxx15
-rw-r--r--vcl/source/window/menu.cxx4
3 files changed, 20 insertions, 4 deletions
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index f787df3692ce..12c4202af144 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -185,6 +185,9 @@ struct KerningPair
#define TEXT_DRAW_MULTILINE ((USHORT)0x1000)
#define TEXT_DRAW_WORDBREAK ((USHORT)0x2000)
#define TEXT_DRAW_NEWSELLIPSIS ((USHORT)0x4000)
+// in the long run we should make text style flags longer
+// but at the moment we can get away with this 2 bit field for ellipsis style
+#define TEXT_DRAW_CENTERELLIPSIS (TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_PATHELLIPSIS)
#define TEXT_DRAW_WORDBREAK_HYPHENATION (((USHORT)0x8000) | TEXT_DRAW_WORDBREAK)
@@ -1114,7 +1117,7 @@ public:
/** Added return value to see if EPS could be painted directly.
Theoreticaly, handing over a matrix would be needed to handle
- painting rotated EPS files (e.g. contained mn Metafiles). This
+ painting rotated EPS files (e.g. contained in Metafiles). This
would then need to be supported for Mac and PS printers, but
that's too much for now, wrote #i107046# for this */
bool DrawEPS( const Point& rPt, const Size& rSz,
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 05b8022118ed..f4ea98484c33 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -6841,7 +6841,20 @@ String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, c
if ( nIndex != STRING_LEN )
{
- if ( nStyle & TEXT_DRAW_ENDELLIPSIS )
+ if( (nStyle & TEXT_DRAW_CENTERELLIPSIS) == TEXT_DRAW_CENTERELLIPSIS )
+ {
+ String aTmpStr( aStr );
+ xub_StrLen nEraseChars = 4;
+ while( nEraseChars < aStr.Len() && _rLayout.GetTextWidth( aTmpStr, 0, aTmpStr.Len() ) > nMaxWidth )
+ {
+ aTmpStr = aStr;
+ xub_StrLen i = (aTmpStr.Len() - nEraseChars)/2;
+ aTmpStr.Erase( i, nEraseChars++ );
+ aTmpStr.InsertAscii( "...", i );
+ }
+ aStr = aTmpStr;
+ }
+ else if ( nStyle & TEXT_DRAW_ENDELLIPSIS )
{
aStr.Erase( nIndex );
if ( nIndex > 1 )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index ceb9f12242c0..76bfd63036a0 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2587,7 +2587,7 @@ static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_
{
xub_StrLen nPos = STRING_NOTFOUND;
String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
- aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth );
+ aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS );
// re-insert mnemonic
if( nPos != STRING_NOTFOUND )
{
@@ -2802,7 +2802,7 @@ void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData*
}
if( !bIsMenuBar && pData->pSubMenu )
{
- nMaxItemTextWidth -= nFontHeight + nExtra;
+ nMaxItemTextWidth -= nFontHeight - nExtra;
}
String aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) );
pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.Len(), nStyle, pVector, pDisplayText );