Changeset 174 for trunk/src/widgets


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).

Location:
trunk/src/widgets
Files:
8 edited

Legend:

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

    r2 r174  
    13391339    arrowRect.setHeight( QMAX(  height() - (2 * arrowRect.y()), arrowRect.height() ) );
    13401340
    1341     if ( count() && ( !editable() || arrowRect.contains( e->pos() ) ) ) {
     1341    bool dropDown;
     1342    int gs = style().styleHint(QStyle::SH_GUIStyle);
     1343    if ( gs == QStyle::PMStyle )
     1344        dropDown = count() && arrowRect.contains( e->pos() );
     1345    else
     1346        dropDown = count() && ( !editable() || arrowRect.contains( e->pos() ) );
     1347
     1348    if ( dropDown ) {
    13421349        d->arrowPressed = FALSE;
    13431350
     
    13581365        QTimer::singleShot( 200, this, SLOT(internalClickTimeout()));
    13591366        d->shortClick = TRUE;
     1367    }
     1368    else if ( gs == QStyle::PMStyle ) {
     1369        setFocus();
    13601370    }
    13611371}
  • trunk/src/widgets/qdatetimeedit.cpp

    r2 r174  
    10811081    QFontMetrics fm( font() );
    10821082    int fw = style().pixelMetric( QStyle::PM_DefaultFrameWidth, this );
    1083     int h = QMAX( fm.lineSpacing(), 14 ) + 2;
     1083    int h = QMAX( fm.lineSpacing(), 14 );
     1084    if ( style().styleHint( QStyle::SH_GUIStyle ) != QStyle::PMStyle )
     1085        h += 2;
    10841086    int w = 2 + fm.width( '9' ) * 8 + fm.width( d->ed->separator() ) * 2 + d->controls->upRect().width() + fw * 4;
    10851087
    1086     return QSize( w, QMAX(h + fw * 2,20) ).expandedTo( QApplication::globalStrut() );
     1088    return QSize( w, QMAX(h + fw * 2, 20) ).expandedTo( QApplication::globalStrut() );
    10871089}
    10881090
     
    25262528    QFontMetrics fm( font() );
    25272529    int fw = style().pixelMetric( QStyle::PM_DefaultFrameWidth, this );
    2528     int h = fm.lineSpacing() + 2;
     2530    int h = fm.lineSpacing();
     2531    if ( style().styleHint( QStyle::SH_GUIStyle ) != QStyle::PMStyle )
     2532        h += 2;
    25292533    int w = 2 + fm.width( '9' ) * 6 + fm.width( d->ed->separator() ) * 2 +
    25302534        d->controls->upRect().width() + fw * 4;
     
    25362540    }
    25372541
    2538     return QSize( w, QMAX(h + fw * 2,20) ).expandedTo( QApplication::globalStrut() );
     2542    return QSize( w, QMAX(h + fw * 2, 20) ).expandedTo( QApplication::globalStrut() );
    25392543}
    25402544
  • 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}
  • trunk/src/widgets/qlistview.cpp

    r2 r174  
    15741574        for ( uint i = 0; i < lv->d->column.size(); ++i ) {
    15751575            if ( pixmap( i ) )
     1576            {
     1577                if ( lv->style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     1578                    ph = QMAX( ph, pixmap( i )->height() + 4 );
     1579                else
    15761580                ph = QMAX( ph, pixmap( i )->height() );
     1581        }
    15771582        }
    15781583
     
    25962601    d->vci = 0;
    25972602    d->timer = new QTimer( this );
     2603    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     2604        d->levelWidth = 24;
     2605    else
    25982606    d->levelWidth = 20;
    25992607    d->r = 0;
     
    26132621    d->sortcolumn = 0;
    26142622    d->ascending = TRUE;
     2623    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     2624        d->allColumnsShowFocus = TRUE;
     2625    else
    26152626    d->allColumnsShowFocus = FALSE;
    26162627    d->fontMetricsHeight = fontMetrics().height();
     
    80778088    if ( d->h->iconSet( col ) )
    80788089        w += d->h->iconSet( col )->pixmap().width();
     8090    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     8091        w = QMAX( w, 24 );
     8092    else
    80798093    w = QMAX( w, 20 );
    80808094    QFontMetrics fm( fontMetrics() );
  • trunk/src/widgets/qmenubar.cpp

    r2 r174  
    295295    int h = 2*motifBarVMargin + fm.height() + motifItemVMargin + 2*frameWidth() + 2*motifItemFrame;
    296296
     297    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     298        h++;
     299
    297300    setGeometry( 0, 0, width(), h );
    298301
     
    483486void QMenuBar::languageChange()
    484487{
    485     menuContentsChanged(); 
     488    menuContentsChanged();
    486489}
    487490
     
    729732    bool reverse = QApplication::reverseLayout();
    730733    const int yoffset = 1; //(style().styleHint( QStyle::SH_GUIStyle ) == QStyle::WindowsStyle) ? 4 : 1; ### this breaks designer mainwindow editing
    731     QPoint pos = r.bottomLeft() + QPoint(0,yoffset);
     734    // Warp4style: popup menus are displaced by 4
     735    const int xoffset = ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle ) ? -4 : 0;
     736    QPoint pos = r.bottomLeft() + QPoint( xoffset, yoffset );
    732737    if( reverse ) {
    733         pos = r.bottomRight() + QPoint(0,yoffset);
     738        pos = r.bottomRight() + QPoint( -xoffset, yoffset );
    734739        pos.rx() -= popup->sizeHint().width();
    735740    }
     
    913918        x += 2;
    914919        y += 2;
     920    } else if ( gs == PMStyle ) {
     921        x += 4;
    915922    }
    916923    if ( reverse )
     
    976983                    x += motifBarHMargin;
    977984                    y += motifBarVMargin;
     985                } else if ( gs == PMStyle ) {
     986                    x += 5;
    978987                }
    979988                if ( reverse )
  • trunk/src/widgets/qscrollbar.cpp

    r2 r174  
    941941        flags |= QStyle::Style_Horizontal;
    942942
     943    // For the Warp4 style we need to always check also the "add line" and "sub line"
     944    // buttons (they could be activated/deactivated!), so we include them here
     945    // for every drawing operation
     946    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     947        controls = controls |
     948                   QStyle::SC_ScrollBarSubLine |
     949                   QStyle::SC_ScrollBarAddLine;
     950
    943951    style().drawComplexControl(QStyle::CC_ScrollBar, p, this, rect(), colorGroup(),
    944952                               flags, (QStyle::SubControl) controls,
  • trunk/src/widgets/qslider.cpp

    r2 r174  
    183183    ticks = NoMarks;
    184184    tickInt = 0;
     185
     186    if ( style().styleHint( QStyle::SH_GUIStyle ) == QStyle::PMStyle )
     187        setFocusPolicy( StrongFocus );
     188    else
    185189    setFocusPolicy( TabFocus  );
    186190    initTicks();
  • trunk/src/widgets/qspinwidget.cpp

    r2 r174  
    136136
    137137    uint oldButtonDown = d->buttonDown;
    138 
     138    d->buttonDown = 0;
     139
     140    // With Warp, the up and down buttons are diagonally separated,
     141    // so we are disabling the down button entirely and have to find
     142    // out the position of the click within the up button in order
     143    // to find out what the user wants!
     144    int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     145    if ( guiStyle == QStyle::PMStyle ) {
     146        if ( d->up.contains( e->pos() ) ) {
     147            QPoint rp = e->pos() - d->up.topLeft();
     148            if ( d->up.width() > (rp.x() + rp.y()) ) {
     149                if ( d->upEnabled )
     150                    d->buttonDown = 2;
     151            } else {
     152                if ( d->downEnabled )
     153                    d->buttonDown = 1;
     154            }
     155        }
     156    } else {
    139157    if ( d->down.contains( e->pos() ) && d->downEnabled )
    140158        d->buttonDown = 1;
    141159    else if ( d->up.contains( e->pos() ) && d->upEnabled )
    142160        d->buttonDown = 2;
    143     else
    144         d->buttonDown = 0;
     161    }
    145162
    146163    d->theButton = d->buttonDown;
     
    149166            repaint( d->down.unite( d->up ), FALSE );
    150167        } else if ( d->buttonDown & 1 ) {
     168            // do all with the "up" button in PM style - see note above
     169            if ( guiStyle == QStyle::PMStyle )
     170                repaint( d->up, FALSE );
     171            else
    151172            repaint( d->down, FALSE );
    152173            stepDown();
     174            if ( guiStyle == QStyle::PMStyle )
     175                d->startTimer( TRUE, 300 );
     176            else
    153177            d->startTimer( FALSE, 300 );
    154178        } else if ( d->buttonDown & 2 ) {
     
    245269    d->theButton = 0;
    246270    if ( oldButtonDown != d->theButton ) {
    247         if ( oldButtonDown & 1 )
     271        // do all with the "up" button in PM style -
     272        // see note in mousePressEvent
     273        int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     274        if ( guiStyle == QStyle::PMStyle )
     275            repaint( d->up, FALSE );
     276        else if ( oldButtonDown & 1 )
    248277            repaint( d->down, FALSE );
    249278        else if ( oldButtonDown & 2 )
     
    264293        return;
    265294
     295    // do all with the "up" button in PM style -
     296    // see note in mousePressEvent
     297    int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     298    uint clickButton = 0;
     299    if ( guiStyle == QStyle::PMStyle ) {
     300        if( d->up.contains( e->pos() ) ) {
     301            QPoint rp = e->pos() - d->up.topLeft();
     302            if ( d->up.width() > (rp.x() + rp.y()) )
     303                clickButton = 2;
     304            else
     305                clickButton = 1;
     306        }
     307    } else {
     308        if ( d->down.contains(e->pos()) )
     309            clickButton = 1;
     310        else if ( d->up.contains(e->pos()) )
     311            clickButton = 2;
     312    }
     313
    266314    uint oldButtonDown = d->theButton;
    267     if ( oldButtonDown & 1 && !d->down.contains( e->pos() ) ) {
     315    if ( (oldButtonDown & 1) && !(clickButton & 1) ) {
     316    //if ( oldButtonDown & 1 && !d->down.contains( e->pos() ) ) {
    268317        d->stopTimer();
    269318        d->theButton = 0;
     319        if ( guiStyle == QStyle::PMStyle )
     320            repaint( d->up, FALSE );
     321        else
    270322        repaint( d->down, FALSE );
    271     } else if ( oldButtonDown & 2 && !d->up.contains( e->pos() ) ) {
     323    } else if( (oldButtonDown & 2) && !(clickButton & 2) ) {
     324    //} else if ( oldButtonDown & 2 && !d->up.contains( e->pos() ) ) {
    272325        d->stopTimer();
    273326        d->theButton = 0;
    274327        repaint( d->up, FALSE );
    275     } else if ( !oldButtonDown && d->up.contains( e->pos() ) && d->buttonDown & 2 ) {
     328    } else if ( !oldButtonDown && (clickButton & 2) && (d->buttonDown & 2) ) {
     329    //} else if ( !oldButtonDown && d->up.contains( e->pos() ) && d->buttonDown & 2 ) {
    276330        d->startTimer( 500 );
    277331        d->theButton = 2;
    278332        repaint( d->up, FALSE );
    279     } else if ( !oldButtonDown && d->down.contains( e->pos() ) && d->buttonDown & 1 ) {
     333    } else if(!oldButtonDown && (clickButton & 1) && (d->buttonDown & 1)) {
     334    //} else if ( !oldButtonDown && d->down.contains( e->pos() ) && d->buttonDown & 1 ) {
    280335        d->startTimer( 500 );
    281336        d->theButton = 1;
     337        if ( guiStyle == QStyle::PMStyle )
     338            repaint( d->up, FALSE );
     339        else
    282340        repaint( d->down, FALSE );
    283341    }
Note: See TracChangeset for help on using the changeset viewer.