Ignore:
Timestamp:
Nov 6, 2007, 11:27:57 PM (18 years ago)
Author:
dmik
Message:

Styles: Implemented the first version of the Warp4 style (contributed by Cornelis Bockemuehl).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/widgets/qdial.cpp

    r2 r174  
    261261    p.begin( this );
    262262
     263    // note: drawing dial controls is NOT AT ALL using the QStyle drawing
     264    // concept, so we have to draw the Warp4 dial here explicitly in
     265    // the widget code!
     266    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle ) {
     267        QRect rr(rect());
     268
     269        // erase the background
     270        QBrush br( paletteBackgroundColor() );
     271        p.setPen( QPen::NoPen );
     272        p.fillRect( rr, br );
     273
     274        // centered quadratic rectangle
     275        if ( rr.width() > rr.height() ) {
     276            rr.setWidth( rr.height() );
     277            rr.moveBy( (width() - rr.width()) / 2, 0 );
     278        } else {
     279            rr.setHeight( rr.width() );
     280            rr.moveBy( 0, (height() - rr.height()) / 2 );
     281        }
     282
     283        // draw the ticks ("notches")
     284        if ( d->showNotches ) {
     285            calcLines();
     286            p.setPen( colorGroup().foreground() );
     287            p.drawLineSegments( d->lines );
     288        }
     289
     290        // draw dial (circle with shadow)
     291        int bigLineSize = calcBigLineSize();
     292        int dist = 6;
     293        rr.setLeft( rr.left() + bigLineSize + dist );
     294        rr.setTop( rr.top() + bigLineSize + dist );
     295        rr.setRight( rr.right() - bigLineSize - dist );
     296        rr.setBottom( rr.bottom() - bigLineSize - dist );
     297        p.setPen( QPen( colorGroup().shadow(), 2) );
     298        p.drawEllipse( rr );
     299        rr.setLeft( rr.left() + 2 );
     300        rr.setTop( rr.top() + 2 );
     301        rr.setRight( rr.right() - 2 );
     302        rr.setBottom( rr.bottom() - 2 );
     303        QPointArray pa;
     304        pa.putPoints( 0, 3,
     305                      rr.left() - 2, rr.top() - 2,
     306                      rr.right() + 2, rr.top() - 2,
     307                      rr.left() - 2, rr.bottom() + 2 );
     308        p.setClipRegion( QRegion( pa ) );
     309        p.setPen( QPen( colorGroup().light(), 2 ) );
     310        p.drawEllipse( rr );
     311        pa.resize( 0 );
     312        pa.putPoints( 0, 3,
     313                      rr.right() + 2, rr.top() - 2,
     314                      rr.right() + 2, rr.bottom() + 2,
     315                      rr.left() - 2, rr.bottom() + 2 );
     316        p.setClipRegion( QRegion( pa ) );
     317        p.setPen( QPen( colorGroup().dark(), 2 ) );
     318        p.drawEllipse( rr );
     319        p.setClipping( false );
     320
     321        // draw pointer (triangle)
     322        double a;
     323        calcArrow( a );
     324        double s = sin( a ),
     325               c = cos( a );
     326        int r = rr.width() / 2 - 9;
     327        double xtr = ((double)rr.left() + rr.right()) * .5 + r * c,
     328               ytr = ((double)rr.top() + rr.bottom()) * .5 - r * s;
     329        QPointArray ar;
     330        ar.putPoints( 0, 3,
     331                      (int)(xtr + 3.5 * c), (int)(ytr - 3.5 * s),
     332                      (int)(xtr + 4 * cos(a - 2.0944)), (int)(ytr - 4 * sin(a - 2.0944)),
     333                      (int)(xtr + 4 * cos(a + 2.0944)), (int)(ytr - 4 * sin(a + 2.0944)) );
     334        p.setBrush( colorGroup().foreground() );
     335        p.setPen( QPen::NoPen );
     336        p.drawPolygon( ar );
     337
     338        if( hasFocus() )
     339            style().drawPrimitive( QStyle::PE_FocusRect, &p, rect(), colorGroup() );
     340    }
     341
     342    // all non-PM styles
     343    else
     344    {
    263345    bool resetClipping = FALSE;
    264346
     
    385467        style().drawPrimitive( QStyle::PE_FocusRect, &p, br, colorGroup());
    386468    }
     469    }
     470
    387471    p.end();
    388472}
Note: See TracChangeset for help on using the changeset viewer.