]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PAL12492 - if the font of dockwindow title is greater than height of title, than...
authorasl <asl@opencascade.com>
Fri, 22 Sep 2006 06:08:02 +0000 (06:08 +0000)
committerasl <asl@opencascade.com>
Fri, 22 Sep 2006 06:08:02 +0000 (06:08 +0000)
src/Style/SalomeStyle.cxx
src/Style/SalomeStyle.h

index d35196cf5c83a68f6d43be00787aa0aa1d50572f..724bf32fbb0f242d36720d1c8495a983f0175898 100644 (file)
@@ -483,22 +483,25 @@ void SalomeStyle::drawPrimitive( PrimitiveElement pe, QPainter* p, const QRect&
         int textW = flags & Style_Horizontal ? rt.height() : rt.width();
         int textH = flags & Style_Horizontal ? rt.width() : rt.height();
 
-        QString title = titleText( wnd->caption(), textW, p->fontMetrics() );
-
-                   if ( wnd )
+       QFont old_font = p->font(), f = old_font;
+       
+        QString title = titleText( wnd->caption(), textW, textH, f );
+       p->setFont( f );
+       if ( wnd )
         {
-                     QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();
-                     p->setPen( cgroup.highlightedText() );
+         QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();
+         p->setPen( cgroup.highlightedText() );
 
-                     if ( flags & Style_Horizontal )
+         if ( flags & Style_Horizontal )
           {
-                       p->rotate( 270.0 );
-                       p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );
-                       p->drawText( 0, 0, title );
-                     }
+           p->rotate( 270.0 );
+           p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );
+           p->drawText( 0, 0, title );
+         }
           else
-                       p->drawText( 2, 2, textW, textH, AlignLeft, title );
-             }
+           p->drawText( 2, 2, textW, textH, AlignLeft, title );
+       }
+       p->setFont( old_font );
       }
       break;
     }
@@ -1279,10 +1282,17 @@ int SalomeStyle::pixelMetric( PixelMetric pm, const QWidget* widget ) const
   \param w - possible width
   \param fm - font metrics
 */
-QString SalomeStyle::titleText( const QString& txt, const int W, const QFontMetrics& fm ) const
+QString SalomeStyle::titleText( const QString& txt, const int W, const int H, QFont& f ) const
 {
   QString res = txt.stripWhiteSpace();
 
+  QFontMetrics fm( f );
+  while( fm.height() > H )
+  {
+    f.setPointSize( f.pointSize()-1 );
+    fm = QFontMetrics( f );
+  }
+
   if ( fm.width( res ) > W )
   {
     QString end( "..." );
index e6cdd5807d07440e632170e2805cd7e0e4808c75..e87ebf16d714f166fce36605bf33c675642a8462 100644 (file)
@@ -92,7 +92,7 @@ protected:
   void               drawGradient( QPainter*, const QRect&, const QColor&,
                                   const QColor&, const Direction, gradient_func ) const;
 
-  QString            titleText( const QString&, const int, const QFontMetrics& ) const;
+  QString            titleText( const QString&, const int, const int, QFont& f ) const;
 
 private:
   QWidget*           myTitleParent;