int c[2][4] = { qRed( rgb1 ), qGreen( rgb1 ), qBlue( rgb1 ), qAlpha( rgb1 ),\r
qRed( rgb2 ), qGreen( rgb2 ), qBlue( rgb2 ), qAlpha( rgb2 ) };\r
for( int i=0; i<4; i++ )\r
- c[0][i] = c[0][i] * (1-t) + c[1][i] * t;\r
+ c[0][i] = (int)( c[0][i] * (1-t) + c[1][i] * t );\r
\r
rgb1 = qRgba( c[0][0], c[0][1], c[0][2], qAlpha( rgb1 ) );\r
}\r
QRgb* colorline = ( QRgb* ) line;\r
for( int x=0; x<w; x++ )\r
{\r
- int gray = k*qGray( colorline[ x ] );\r
- if( gray>255 )\r
+ int gray = (int)( k * qGray( colorline[ x ] ) );\r
+ if ( gray>255 )\r
gray = 255;\r
else if( gray<0 )\r
gray = 0;\r
}\r
\r
void SalomeStyle::drawPrimitive( PrimitiveElement pe, QPainter* p, const QRect& r,\r
- const QColorGroup& cg, SFlags flags, const QStyleOption& opt ) const\r
+ const QColorGroup& cg, SFlags flags, const QStyleOption& opt ) const\r
{\r
switch ( pe )\r
{\r
activeWidget = activeWidget->parent();\r
}\r
\r
- bool act = wnd == activeWnd, horiz = flags & Style_Horizontal;\r
+ bool act = wnd == activeWnd, horiz = flags & Style_Horizontal;\r
\r
QPixmap hole( (const char**)hole_xpm );\r
\r
{\r
drawGradient( p, r, cg.light(), cg.background(), horiz ? UpToDown : LeftToRight, linear );\r
\r
- int c = 4, i; double d = ( horiz ? r.height() : r.width() ) / (c+1);\r
+ int c = 4, i; double d = ( horiz ? r.height() : r.width() ) / ( c + 1 );\r
QBrush fill = cg.brush( QColorGroup::Dark );\r
p->setPen( Qt::red );\r
for ( i = 0; i < c; i++ )\r
{\r
if ( horiz )\r
- p->drawPixmap( r.x()+r.width()/2-1, r.y()+(i+1)*d-1, hole );\r
+ p->drawPixmap( r.x() + r.width() / 2 - 1, (int)( r.y() + ( i + 1 ) * d - 1 ), hole );\r
else\r
- p->drawPixmap( r.x()+(i+1)*d-1, r.y()+r.height()/2-1, hole );\r
+ p->drawPixmap( (int) ( r.x() + ( i + 1 ) * d - 1 ), r.y() + r.height() / 2 - 1, hole );\r
}\r
\r
int dd = (int(d)/2) + (int(d)%2);\r
for ( i = 0; i < c - 1; i++ )\r
{\r
if ( horiz )\r
- p->drawPixmap( r.x()+r.width()/2+2, r.y()+dd+(i+1)*d-1, hole );\r
+ p->drawPixmap( r.x() + r.width() / 2 + 2, (int)( r.y() + dd + ( i + 1 ) * d - 1 ), hole );\r
else\r
- p->drawPixmap( r.x()+dd+(i+1)*d-1, r.y()+r.height()/2+2, hole );\r
+ p->drawPixmap( (int)( r.x() + dd + ( i + 1 ) * d - 1 ), r.y() + r.height() / 2 + 2, hole );\r
}\r
}\r
else\r
\r
drawGradient( p, rr, act ? cg.highlight() : cg.dark(), col,\r
horiz ? LeftToRight : UpToDown, linear );\r
+\r
+ int txtW = flags & Style_Horizontal ? r.height() : r.width();\r
+ int txtH = flags & Style_Horizontal ? r.width() : r.height();\r
+\r
+ QString title = titleText( wnd->caption(), txtW, p->fontMetrics() );\r
+\r
+ p->save();\r
+ if ( flags & Style_Horizontal )\r
+ {\r
+ p->rotate( 270 );\r
+ p->translate( -r.height() - r.y(), r.width() - r.x() );\r
+ p->drawText( 0, 0, txtW, txtH, Qt::AlignCenter, title );\r
+ }\r
+ else\r
+ p->drawText( r, Qt::AlignCenter, title );\r
+ p->restore();\r
}\r
break;\r
}\r
return ret;\r
}\r
\r
+QString SalomeStyle::titleText( const QString& txt, const int W, const QFontMetrics& fm ) const\r
+{\r
+ QString res = txt.stripWhiteSpace();\r
+\r
+ if ( fm.width( res ) > W )\r
+ {\r
+ QString end( "..." );\r
+ while ( !res.isEmpty() && fm.width( res + end ) > W )\r
+ res.remove( res.length() - 1, 1 );\r
+\r
+ if ( !res.isEmpty() )\r
+ res += end;\r
+ }\r
+\r
+ return res;\r
+}\r
+\r
/*!\r
Class: SalomeStylePlugin [Internal]\r
Descr: Plugin for Qt style mechanism\r
\r
QStringList SalomeStylePlugin::keys() const\r
{\r
- printf( "SalomeStylePlugin::keys()\n" );\r
-\r
return QStringList() << "salome";\r
}\r
\r
#endif\r
#endif\r
\r
+class QFontMetrics;\r
+\r
class SALOMESTYLE_EXPORT SalomeStyle : public PARENT_STYLE\r
{\r
public:\r
SalomeStyle();\r
virtual ~SalomeStyle();\r
\r
- virtual void polish( QWidget* );\r
+ virtual void polish( QWidget* );\r
\r
- virtual bool eventFilter( QObject*, QEvent* );\r
+ virtual bool eventFilter( QObject*, QEvent* );\r
\r
- static void mix( const double, QRgb&, const QRgb& );\r
- static void mix( const double, QPixmap&, const QColor& );\r
- static void mix( const double, const QColor&, const QColor&, QColor& );\r
+ static void mix( const double, QRgb&, const QRgb& );\r
+ static void mix( const double, QPixmap&, const QColor& );\r
+ static void mix( const double, const QColor&, const QColor&, QColor& );\r
\r
- static void toGrayscale( QPixmap&, double = 1.0 );\r
+ static void toGrayscale( QPixmap&, double = 1.0 );\r
\r
- virtual void drawPrimitive( PrimitiveElement, QPainter*, const QRect&,\r
- const QColorGroup&, SFlags = Style_Default,\r
- const QStyleOption& = QStyleOption::Default ) const;\r
+ virtual void drawPrimitive( PrimitiveElement, QPainter*, const QRect&,\r
+ const QColorGroup&, SFlags = Style_Default,\r
+ const QStyleOption& = QStyleOption::Default ) const;\r
\r
- virtual void drawControl( ControlElement, QPainter*, const QWidget*,\r
- const QRect&, const QColorGroup&, SFlags = Style_Default,\r
- const QStyleOption& = QStyleOption::Default ) const; \r
+ virtual void drawControl( ControlElement, QPainter*, const QWidget*,\r
+ const QRect&, const QColorGroup&, SFlags = Style_Default,\r
+ const QStyleOption& = QStyleOption::Default ) const; \r
\r
- virtual QRect subRect( SubRect, const QWidget* ) const;\r
+ virtual QRect subRect( SubRect, const QWidget* ) const;\r
\r
- virtual void drawComplexControl( ComplexControl, QPainter*, const QWidget*,\r
- const QRect&, const QColorGroup&, SFlags = Style_Default,\r
- SCFlags = SC_All, SCFlags = SC_None,\r
- const QStyleOption& = QStyleOption::Default ) const;\r
+ virtual void drawComplexControl( ComplexControl, QPainter*, const QWidget*,\r
+ const QRect&, const QColorGroup&, SFlags = Style_Default,\r
+ SCFlags = SC_All, SCFlags = SC_None,\r
+ const QStyleOption& = QStyleOption::Default ) const;\r
\r
- virtual QPixmap stylePixmap( StylePixmap, const QWidget* = 0,\r
- const QStyleOption& = QStyleOption::Default ) const;\r
+ virtual QPixmap stylePixmap( StylePixmap, const QWidget* = 0,\r
+ const QStyleOption& = QStyleOption::Default ) const;\r
\r
- virtual int pixelMetric( PixelMetric, const QWidget* widget = 0 ) const;\r
+ virtual int pixelMetric( PixelMetric, const QWidget* widget = 0 ) const;\r
\r
protected:\r
typedef enum { LeftToRight, RightToLeft, UpToDown, DownToUp } Direction;\r
\r
typedef double (*gradient_func)( double );\r
\r
- void drawGradient( QPainter*, const QRect&,\r
- const QColor&, const QColor&,\r
- const Direction, gradient_func ) const;\r
+ void drawGradient( QPainter*, const QRect&, const QColor&,\r
+ const QColor&, const Direction, gradient_func ) const;\r
+\r
+ QString titleText( const QString&, const int, const QFontMetrics& ) const;\r
\r
private:\r
- QWidget* myTitleParent;\r
+ QWidget* myTitleParent;\r
};\r
\r
class SalomeStylePlugin : public QStylePlugin\r