+ break;
+ }
+
+ case PE_DockWindowSeparator:
+ {
+ bool horiz = ( flags & Style_Horizontal );
+ QWidget* w = ( QWidget* )p->device();
+ if( w->inherits( "QToolBarSeparator" ) )
+ {
+ drawGradient( p, r, cg.light(), cg.background(), horiz ? UpToDown : LeftToRight, linear );
+ int w = r.width(), h = r.height();
+ int part = 8;
+
+ p->setPen( cg.dark() );
+ if( horiz )
+ p->drawLine( r.x() + w/2, r.y() + h/part, r.x() + w/2, r.y() + (part-1)*h/part );
+ else
+ p->drawLine( r.x() + w/part, r.y() + h/2, r.x() + (part-1)*w/part, r.y() + h/2 );
+
+ p->setPen( cg.light() );
+ if( horiz )
+ p->drawLine( r.x() + w/2 + 1, r.y() + h/part + 1, r.x() + w/2 + 1, r.y() + (part-1)*h/part + 1 );
+ else
+ p->drawLine( r.x() + w/part + 1, r.y() + h/2 + 1, r.x() + (part-1)*w/part + 1, r.y() + h/2 + 1 );
+ }
+ else
+ PARENT_STYLE::drawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+
+ case PE_PanelDockWindow:
+ {
+ QWidget* w = ( QWidget* )p->device();
+
+ int offset = pixelMetric( PM_DockWindowHandleExtent, w );
+ if ( w->inherits( "QToolBar" ) )
+ {
+ bool vert = ( ( QToolBar* )w )->orientation() == Qt::Vertical;
+ if ( vert )
+ drawGradient( p, QRect( r.x(), r.y()+offset, r.x()+r.width(), r.y()+offset ),
+ cg.light(), cg.background(), LeftToRight, linear );
+ else
+ drawGradient( p, QRect( r.x()+offset, r.y(), r.x()+offset, r.y()+r.height() ),
+ cg.light(), cg.background(), UpToDown, linear );
+
+ p->setPen( QPen( cg.light(), 1 ) );
+ p->drawRect( r );
+ }
+ else
+ {
+ p->setPen( QPen( cg.dark(), 1 ) );
+ p->setBrush( cg.light() );
+ p->drawRect( r );
+ }
+
+ break;
+ }
+
+ case PE_PanelPopup:
+ p->setPen( QPen( cg.dark(), 1 ) );
+ p->setBrush( cg.light() );
+ p->drawRect( r );
+ break;
+
+ case PE_HeaderSection:
+ {
+ QColor col; mix( 0.2, cg.light(), Qt::black, col );
+ drawGradient( p, r, cg.light(), col, DownToUp, linear );
+ drawGradient( p, QRect( r.x(), r.y(), 1, r.height() ), cg.light(), cg.dark(), DownToUp, linear );
+ p->setPen( cg.dark() );
+ p->drawLine( r.x(), r.y()+r.height()-1, r.x()+r.width(), r.y()+r.height()-1 );
+ break;
+ }
+
+ case PE_Splitter:
+ p->fillRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, cg.dark() );
+ p->fillRect( r.x() + 2, r.y() + 2, r.width() - 4, r.height() - 4, cg.midlight() );
+ break;
+
+ case PE_ButtonBevel:
+ PARENT_STYLE::drawPrimitive( PE_ButtonDropDown, p, r, cg, flags, opt );
+ break;
+
+ case PE_ButtonCommand:
+ {
+ QColorGroup cGrp( cg );
+ if ( flags & Style_MouseOver )
+ cGrp.setColor( QColorGroup::Button, cGrp.midlight() );
+
+ if ( flags & Style_MouseOver )
+ PARENT_STYLE::drawPrimitive( PE_ButtonDropDown, p, r, cGrp, flags, opt );
+ else
+ PARENT_STYLE::drawPrimitive( flags & Style_Raised ? PE_ButtonDropDown : pe, p, r, cGrp, flags, opt );
+ }
+ break;
+
+ default:
+ PARENT_STYLE::drawPrimitive( pe, p, r, cg, flags, opt );
+ break;
+ }
+}
+
+void SalomeStyle::drawControl( ControlElement element, QPainter* p, const QWidget* widget, const QRect& r,
+ const QColorGroup& cg, SFlags flags, const QStyleOption& opt ) const
+{
+ switch( element )
+ {
+ case CE_PopupMenuItem:
+ {
+ if(! widget || opt.isDefault())
+ break;
+
+ const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
+ QMenuItem *mi = opt.menuItem();
+ if( !mi )
+ break;
+
+ int tab = opt.tabWidth();
+ int maxpmw = opt.maxIconWidth();
+ bool dis = !( flags & Style_Enabled );
+ bool checkable = popupmenu->isCheckable();
+ bool act = flags & Style_Active;
+ bool use2000style = true;
+ int x, y, w, h;
+
+ int windowsItemFrame = 2,
+ windowsItemHMargin = 5,
+ windowsItemVMargin = 1,
+ windowsRightBorder = 2,
+ windowsArrowHMargin = 2;
+
+ r.rect(&x, &y, &w, &h);
+
+ if ( checkable )
+ {
+ // space for the checkmarks
+ if (use2000style)
+ maxpmw = QMAX( maxpmw, 20 );
+ else
+ maxpmw = QMAX( maxpmw, 12 );
+ }
+
+ int checkcol = maxpmw;
+
+ if ( mi && mi->isSeparator() )
+ {
+ p->setPen( cg.dark() );
+ p->drawLine( x+3*checkcol/2, y, x+w, y );
+ //p->setPen( cg.light() );
+ //p->drawLine( x, y+1, x+w, y+1 );
+ return;
+ }
+
+ QBrush fill = ( act && !dis ?
+ cg.brush( QColorGroup::Highlight ) :
+ cg.brush( QColorGroup::Light ) );
+ p->fillRect( x, y, w, h, fill );
+
+ if( !mi )
+ return;
+
+ int xpos = x;
+ QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r );
+ int xvis = vrect.x();
+
+ if( mi->isChecked() )
+ {
+ if( act && !dis )
+ qDrawShadePanel( p, xvis, y, checkcol, h,
+ cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
+ else
+ {
+ QBrush fill( cg.light(), Dense4Pattern );
+ // set the brush origin for the hash pattern to the x/y coordinate
+ // of the menu item's checkmark... this way, the check marks have
+ // a consistent look
+ QPoint origin = p->brushOrigin();
+ p->setBrushOrigin( xvis, y );
+ qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill );
+ // restore the previous brush origin
+ p->setBrushOrigin( origin );
+ }
+ }
+ else if( !act )
+ p->fillRect(x+checkcol, y, w-checkcol , h, cg.brush( QColorGroup::Light ));
+
+ if( !( act && !dis ) && !mi->isChecked() )
+ {
+ QColor col; mix( 0.5, cg.mid(), Qt::white, col );
+ drawGradient( p, QRect( xvis, y, checkcol, h+1 ), cg.light(), col, LeftToRight, linear );
+ }
+
+ if( mi->iconSet() )
+ { // draw iconset
+ QIconSet::Mode mode = dis ? QIconSet::Active : QIconSet::Normal;
+ if(act && !dis )
+ mode = QIconSet::Active;
+ QPixmap pixmap;
+ if( checkable && mi->isChecked() )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
+ else
+ pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ if( dis )
+ toGrayscale( pixmap, 1.1 );
+
+ //if( act && !dis && !mi->isChecked() )
+ // qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) );
+
+ QRect pmr( 0, 0, pixw, pixh );
+ pmr.moveCenter( vrect.center() );
+ p->setPen( cg.text() );
+ p->drawPixmap( pmr.topLeft(), pixmap );
+
+ QBrush fill = ( act ? cg.brush( QColorGroup::Highlight ) : cg.brush( QColorGroup::Light ));
+ int xp = xpos + checkcol + 1;
+ if( !dis )
+ p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill);
+ }
+ else if( checkable )
+ { // just "checking"...
+ if( mi->isChecked() )
+ {
+ int xp = xpos + windowsItemFrame;
+
+ SFlags cflags = Style_Default;
+ if( !dis )
+ cflags |= Style_Enabled;
+ if( act )
+ cflags |= Style_On;
+
+ drawPrimitive( PE_CheckMark, p,
+ visualRect( QRect( xp, y + windowsItemFrame,
+ checkcol - 2*windowsItemFrame,
+ h - 2*windowsItemFrame), r ), cg, cflags, opt );
+ }
+ }
+
+ p->setPen( act ? cg.highlightedText() : cg.buttonText() );
+
+ QColor discol;
+ if( dis )
+ {
+ discol = cg.text();
+ p->setPen( discol );
+ }
+
+ int xm = windowsItemFrame + checkcol + windowsItemHMargin;
+ xpos += xm;
+
+ vrect = visualRect( QRect( xpos, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin ), r );
+ xvis = vrect.x();
+ if( mi->custom() )
+ {
+ p->save();
+ if ( dis && !act )
+ {
+ p->setPen( cg.light() );
+ mi->custom()->paint( p, cg, act, !dis,
+ xvis+1, y+windowsItemVMargin+1,
+ w-xm-tab+1, h-2*windowsItemVMargin );
+ p->setPen( discol );
+ }
+ mi->custom()->paint( p, cg, act, !dis, xvis, y+windowsItemVMargin,
+ w-xm-tab+1, h-2*windowsItemVMargin );
+ p->restore();
+ }
+ QString s = mi->text();
+ if( !s.isNull() )
+ { // draw text
+ int t = s.find( '\t' );
+ int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
+ if( !styleHint( SH_UnderlineAccelerator, widget ) )
+ text_flags |= NoAccel;
+ text_flags |= (QApplication::reverseLayout() ? AlignRight : AlignLeft );
+ if( t >= 0 )
+ { // draw tab text
+ int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
+ if( use2000style )
+ xp -= 20;
+ else
+ xp -= windowsRightBorder;
+ int xoff = visualRect( QRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
+ if( dis && !act )
+ {
+ p->setPen( cg.light() );
+ p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
+ p->setPen( discol );
+ }
+ p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
+ s = s.left( t );
+ }
+ if( dis && !act )
+ {
+ p->setPen( cg.light() );
+ p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
+ p->setPen( discol );
+ }
+ p->drawText( xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
+ }
+ else if( mi->pixmap() )
+ { // draw pixmap
+ QPixmap *pixmap = mi->pixmap();
+ if( pixmap->depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+ p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
+ if( pixmap->depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ if( mi->popup() )
+ { // draw sub menu arrow
+ int dim = (h-2*windowsItemFrame) / 2;
+ PrimitiveElement arrow;
+ arrow = ( QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
+ xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
+ vrect = visualRect( QRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
+ if( act )
+ {
+ QColorGroup g2 = cg;
+ g2.setColor( QColorGroup::ButtonText, g2.highlightedText() );
+ drawPrimitive( arrow, p, vrect, g2, dis ? Style_Default : Style_Enabled, opt );
+ }
+ else
+ {
+ drawPrimitive( arrow, p, vrect, cg, dis ? Style_Default : Style_Enabled, opt );
+ }
+ }
+
+ if( act && !dis )
+ {
+ p->setPen( cg.dark() );
+ p->drawRect( r );
+ }
+ break;
+ }
+
+ case CE_MenuBarItem:
+ {
+ bool active = flags & Style_Active;
+ bool down = flags & Style_Down;
+ QRect pr = r;
+
+ p->save();
+ if( active && down )
+ {
+ //QColor col; mix( 0.5, cg.mid(), Qt::white, col );
+ //drawGradient( p, r, col, cg.light(), UpToDown, linear );
+ p->setPen( cg.light() );
+ p->setBrush( cg.light() );
+ p->drawRect( r );
+
+ p->setPen( cg.dark() );
+ int w = r.width()-1, h = r.height();
+ p->drawLine( r.x(), r.y(), r.x()+w, r.y() );
+ p->drawLine( r.x(), r.y(), r.x(), r.y()+h );
+ p->drawLine( r.x()+w, r.y(), r.x()+w, r.y()+h );
+
+ p->translate( 1, 1 );
+ }
+ else
+ drawGradient( p, r, cg.light(), cg.background(), active ? DownToUp : UpToDown, linear );
+
+ QCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt);
+ p->restore();
+ break;
+ }
+
+ case CE_MenuBarEmptyArea:
+ {
+ drawGradient( p, r, cg.light(), cg.background(), UpToDown, linear );
+ break;
+ }
+
+ case CE_ToolButtonLabel:
+ {
+ const QToolButton *toolbutton = (const QToolButton *) widget;
+ QObject* parent = toolbutton->parent();
+
+ QToolBar* tb = NULL;
+ while( parent )
+ if( parent->inherits( "QToolBar" ) )
+ {
+ tb = ( QToolBar* )parent;
+ break;
+ }
+ else
+ parent = parent->parent();
+ parent = toolbutton->parent();
+
+ int horiz = -1;
+ if( tb )
+ {
+ if( tb->orientation()==Qt::Horizontal )
+ horiz = 1;
+ else
+ horiz = 0;
+ drawGradient( p, r, cg.light(), cg.background(), horiz ? UpToDown : LeftToRight, linear );
+ }
+ else if( parent->inherits( "QDockWindowHandle" ) )
+ {
+ QWidget* w = ( QWidget* ) parent;
+ QDockWindow* wnd = ( QDockWindow* )w->parent();
+ if( !wnd->orientation()==Qt::Horizontal )
+ horiz=1;
+ else
+ horiz=0;
+
+ QPoint pp( r.x(), r.y() ),
+ qq = toolbutton->mapToParent( pp );
+
+ bitBlt( p->device(), r.x(), r.y(), w, horiz ? qq.x()-r.width() : qq.x(),
+ horiz ? qq.y() : qq.y()+r.height(),
+ r.width(), r.height(), Qt::CopyROP, true );
+ }
+
+ bool highlight = ( flags & Style_MouseOver ),
+ down = ( flags & ( Style_Down | Style_On ) ),
+ en = toolbutton->isEnabled();
+
+ if( down )
+ if( horiz>=0 )
+ {
+ drawGradient( p, r, cg.light(), cg.background(), horiz==1 ? DownToUp : RightToLeft, linear );
+ p->setPen( cg.background() );
+ p->drawRect( r );
+ }
+ else
+ {
+ p->setPen( cg.dark() );
+ p->setBrush( cg.light() );
+ p->drawRect( r );
+ }
+ if( highlight )
+ {
+ p->setPen( cg.dark() );
+ QColor col; mix( 0.05, cg.background(), Qt::black, col );
+ p->setBrush( col );
+ p->drawRect( r );
+ }
+
+
+ QRect rect = r;
+ Qt::ArrowType arrowType = opt.isDefault() ? Qt::DownArrow : opt.arrowType();
+
+ int shiftX = 0, shiftY = 0;
+ if( flags & ( Style_Down | Style_On ) )
+ {
+ shiftX = pixelMetric(PM_ButtonShiftHorizontal, widget);
+ shiftY = pixelMetric(PM_ButtonShiftVertical, widget);
+ }
+
+ if (!opt.isDefault())
+ {
+ PrimitiveElement pe;
+ switch (arrowType)
+ {
+ case Qt::LeftArrow: pe = PE_ArrowLeft; break;
+ case Qt::RightArrow: pe = PE_ArrowRight; break;
+ case Qt::UpArrow: pe = PE_ArrowUp; break;
+ default:
+ case Qt::DownArrow: pe = PE_ArrowDown; break;
+ }
+
+ rect.moveBy(shiftX, shiftY);
+ drawPrimitive(pe, p, rect, cg, flags, opt);
+ }
+ else
+ {
+ QColor btext = toolbutton->paletteForegroundColor();
+
+ if (toolbutton->iconSet().isNull() &&
+ ! toolbutton->text().isNull() &&
+ ! toolbutton->usesTextLabel())
+ {
+ int alignment = AlignCenter | ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ alignment |= NoAccel;
+
+ rect.moveBy(shiftX, shiftY);
+ drawItem( p, rect, alignment, cg, flags & Style_Enabled, 0, toolbutton->text(),
+ toolbutton->text().length(), &btext);
+ }
+ else
+ {
+ QPixmap pm;
+ QIconSet::Size size =
+ toolbutton->usesBigPixmap() ? QIconSet::Large : QIconSet::Small;
+ QIconSet::State state = toolbutton->isOn() ? QIconSet::On : QIconSet::Off;
+ QIconSet::Mode mode;
+ if( !toolbutton->isEnabled() )
+ mode = QIconSet::Active; //QIconSet::Disabled;
+ else if( flags & (Style_Down | Style_On ) || ( flags & Style_Raised ) && (flags & Style_AutoRaise))
+ mode = QIconSet::Active;
+ else
+ mode = QIconSet::Normal;
+ pm = toolbutton->iconSet().pixmap( size, mode, state );
+
+ if( toolbutton->usesTextLabel() )
+ {
+ p->setFont( toolbutton->font() );
+ QRect pr = rect, tr = rect;
+ int alignment = ShowPrefix;
+ if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ alignment |= NoAccel;
+
+ if( toolbutton->textPosition() == QToolButton::Under )
+ {
+ int fh = p->fontMetrics().height();
+ pr.addCoords( 0, 1, 0, -fh-3 );
+ tr.addCoords( 0, pr.bottom(), 0, -3 );
+ pr.moveBy(shiftX, shiftY);
+ drawItem( p, pr, AlignCenter, cg, TRUE, &pm, QString::null );
+ alignment |= AlignCenter;
+ }
+ else
+ {
+ pr.setWidth( pm.width() + 8 );
+ tr.addCoords( pr.right(), 0, 0, 0 );
+ pr.moveBy(shiftX, shiftY);
+
+ drawItem( p, pr, AlignCenter, cg, TRUE, &pm, QString::null );
+ alignment |= AlignLeft | AlignVCenter;
+ }
+
+ tr.moveBy(shiftX, shiftY);
+ drawItem( p, tr, alignment, cg, flags & Style_Enabled, 0, toolbutton->textLabel(),
+ toolbutton->textLabel().length(), &btext);
+ }
+ else
+ {
+ /*if( en && !highlight )
+ mix( 0.6, pm, cg.background() );
+ else*/ if( !en )
+ {
+ toGrayscale( pm, 1.1 );
+ mix( 0.8, pm, cg.background() );
+ }
+
+ rect.moveBy(shiftX, shiftY);
+ drawItem( p, rect, AlignCenter, cg, true, &pm, QString::null );
+ }
+ }
+ }
+ }
+ break;
+
+ case CE_TabBarTab:
+ {
+ QPen oldPen = p->pen();
+
+ QRect r2( r );
+ bool selected = flags & Style_Selected;
+
+ p->setPen( cg.midlight() );
+ p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
+
+ if ( !selected )
+ r2.setRect( r2.left(), r2.top() + 1, r2.width(), r2.height() - 1 );
+ else
+ r2.setRect( r2.left(), r2.top(), r2.width() - 2, r2.height() - 1 );
+
+ p->setPen( cg.foreground() );
+ drawGradient( p, QRect( r2.left(), r2.top(), r2.width(), r2.height() - 1 ),\r
+ selected ? cg.highlight() : cg.dark(), cg.background(), UpToDown, linear );\r
+
+// p->fillRect( r2.left(), r2.top(), r2.width(), r2.height() - 1, selected ? cg.highlight() : cg.background() );\r
+ p->drawRect( r2.left(), r2.top(), r2.width(), r2.height() - 1 );
+
+ if ( selected )
+ {
+ p->setPen( cg.shadow() );
+ p->drawLine( r2.left() + 1, r2.bottom(), r2.right() + 1, r2.bottom() );
+ p->drawLine( r2.right() + 1, r2.top() + 1, r2.right() + 1, r2.bottom() );
+ }
+
+ break;
+ }
+\r
+ case CE_TabBarLabel:\r