18 #include <qdrawutil.h>
20 #include <qstyleoption.h>
27 const QColor&
color,
const QRect& pipeRect,
const QRect& liquidRect,
28 Qt::Orientation orientation )
30 painter->setPen(
color );
31 if ( orientation == Qt::Horizontal )
33 if ( pos >= liquidRect.left() && pos < liquidRect.right() )
34 painter->drawLine( pos, pipeRect.top(), pos, pipeRect.bottom() );
38 if ( pos >= liquidRect.top() && pos < liquidRect.bottom() )
39 painter->drawLine( pipeRect.left(), pos, pipeRect.right(), pos );
50 if ( upperLimit < lowerLimit )
51 qSwap( lowerLimit, upperLimit );
60 for (
int i = 0; i < ticks.count(); i++ )
62 const double v = ticks[i];
63 if ( v > lowerLimit && v < upperLimit )
126 QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
130 setSizePolicy( policy );
132 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
237 QPainter painter(
this );
238 painter.setClipRegion( event->region() );
242 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
246 if ( !tRect.contains( event->rect() ) )
254 const QBrush brush = palette().brush( QPalette::Base );
255 qDrawShadePanel( &painter,
256 tRect.adjusted( -bw, -bw, bw, bw ),
279 switch( event->type() )
281 case QEvent::StyleChange:
282 case QEvent::FontChange:
374 if ( update_geometry )
392 mbd = qMax( d1, d2 );
395 const int scaleOff = bw + mbd;
397 const QRect cr = contentsRect();
402 pipeRect.adjust( scaleOff, 0, -scaleOff, 0 );
413 pipeRect.adjust( 0, scaleOff, 0, -scaleOff );
439 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
441 QSizePolicy sp = sizePolicy();
445 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
522 if ( testAttribute( Qt::WA_WState_Polished ) )
547 QPainter* painter,
const QRect& pipeRect )
const
550 painter->setClipRect(
pipeRect, Qt::IntersectClip );
551 painter->setPen( Qt::NoPen );
567 std::sort( values.begin(), values.end(), std::greater< double >() );
569 std::sort( values.begin(), values.end(), std::less< double >() );
572 if ( !values.isEmpty() )
580 for (
int i = 1; i < values.size(); i++ )
584 for (
int pos = from + 1; pos < to; pos++ )
607 painter->fillRect( r, palette().brush( QPalette::Highlight ) );
608 liquidRect = QRegion( liquidRect ).subtracted( r ).boundingRect();
612 painter->fillRect( liquidRect, palette().brush( QPalette::ButtonText ) );
722 QPalette pal = palette();
723 pal.setBrush( QPalette::ButtonText, brush );
733 return palette().brush( QPalette::ButtonText );
749 QPalette pal = palette();
750 pal.setBrush( QPalette::Highlight, brush );
763 return palette().brush( QPalette::Highlight );
882 const QMargins m = contentsMargins();
883 w += m.left() + m.right();
884 h += m.top() + m.bottom();
886 return QSize( w, h );
975 v2 = qMin( v2, increasing ?
fillRect.right() : valuePos );
980 v1 = qMax( v1, increasing ?
fillRect.left() : valuePos );
993 v1 = qMax( v1, increasing ?
fillRect.top() : valuePos );
1002 v2 = qMin( v2, increasing ?
fillRect.bottom() : valuePos );
1011 #include "moc_qwt_thermo.cpp"