Anonymous avatar Anonymous committed 23fb3bf

vcl116: #i97830# new ellipsis text style for menus

Comments (0)

Files changed (3)

vcl/inc/vcl/outdev.hxx

 #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)
 
 
     /** 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 n 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,

vcl/source/gdi/outdev3.cxx

 
     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 )

vcl/source/window/menu.cxx

 {
     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 )
     {
                     }
                     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 );
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.