src/gui/widgets/qtabbar.cpp
changeset 25 e24348a560a6
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
23:89e065397ea6 25:e24348a560a6
    65 #ifdef Q_WS_MAC
    65 #ifdef Q_WS_MAC
    66 #include <private/qt_mac_p.h>
    66 #include <private/qt_mac_p.h>
    67 #include <private/qt_cocoa_helpers_mac_p.h>
    67 #include <private/qt_cocoa_helpers_mac_p.h>
    68 #endif
    68 #endif
    69 
    69 
       
    70 #ifndef QT_NO_STYLE_S60
       
    71 #include "qs60style.h"
       
    72 #endif
       
    73 
    70 QT_BEGIN_NAMESPACE
    74 QT_BEGIN_NAMESPACE
    71 
    75 
    72 inline static bool verticalTabs(QTabBar::Shape shape)
    76 inline static bool verticalTabs(QTabBar::Shape shape)
    73 {
    77 {
    74     return shape == QTabBar::RoundedWest
    78     return shape == QTabBar::RoundedWest
   476             tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
   480             tabList[i].rect.setRect(0, lstruct.pos, maxExtent, lstruct.size);
   477     }
   481     }
   478 
   482 
   479     if (useScrollButtons && tabList.count() && last > available) {
   483     if (useScrollButtons && tabList.count() && last > available) {
   480         int extra = extraWidth();
   484         int extra = extraWidth();
       
   485 #ifndef QT_NO_STYLE_S60
       
   486         QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style());
       
   487 #endif
   481         if (!vertTabs) {
   488         if (!vertTabs) {
   482             Qt::LayoutDirection ld = q->layoutDirection();
   489             Qt::LayoutDirection ld = q->layoutDirection();
   483             QRect arrows = QStyle::visualRect(ld, q->rect(),
   490             QRect arrows = QStyle::visualRect(ld, q->rect(),
   484                                               QRect(available - extra, 0, extra, size.height()));
   491                                               QRect(available - extra, 0, extra, size.height()));
   485             int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q);
   492             int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q);
   486 
   493 
   487             if (ld == Qt::LeftToRight) {
   494             if (ld == Qt::LeftToRight) {
       
   495 // In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar.
       
   496 #ifndef QT_NO_STYLE_S60
       
   497                 if (s60Style) {
       
   498                     rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
       
   499                     leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
       
   500                 } else {
       
   501 #endif
   488                 leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
   502                 leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
   489                 rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
   503                 rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
   490                                     extra/2, arrows.height());
   504                                     extra/2, arrows.height());
       
   505 #ifndef QT_NO_STYLE_S60
       
   506                 }
       
   507 #endif
   491                 leftB->setArrowType(Qt::LeftArrow);
   508                 leftB->setArrowType(Qt::LeftArrow);
   492                 rightB->setArrowType(Qt::RightArrow);
   509                 rightB->setArrowType(Qt::RightArrow);
   493             } else {
   510             } else {
       
   511 #ifndef QT_NO_STYLE_S60
       
   512                 if (s60Style) {
       
   513                     rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height());
       
   514                     leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height());
       
   515                 } else {
       
   516 #endif
   494                 rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
   517                 rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height());
   495                 leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
   518                 leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(),
   496                                     extra/2, arrows.height());
   519                                     extra/2, arrows.height());
       
   520 #ifndef QT_NO_STYLE_S60
       
   521                 }
       
   522 #endif
   497                 rightB->setArrowType(Qt::LeftArrow);
   523                 rightB->setArrowType(Qt::LeftArrow);
   498                 leftB->setArrowType(Qt::RightArrow);
   524                 leftB->setArrowType(Qt::RightArrow);
   499             }
   525             }
   500         } else {
   526         } else {
       
   527 #ifndef QT_NO_STYLE_S60
       
   528             if (s60Style) {
       
   529                 QRect arrows = QRect(0, 0, size.width(), available );
       
   530                 leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2);
       
   531                 leftB->setArrowType(Qt::UpArrow);
       
   532                 rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1,
       
   533                                     arrows.width(), extra / 2);
       
   534                 rightB->setArrowType(Qt::DownArrow);
       
   535             } else {
       
   536 #endif
   501             QRect arrows = QRect(0, available - extra, size.width(), extra );
   537             QRect arrows = QRect(0, available - extra, size.width(), extra );
   502             leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2);
   538             leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2);
   503             leftB->setArrowType(Qt::UpArrow);
   539             leftB->setArrowType(Qt::UpArrow);
   504             rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1,
   540             rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1,
   505                                 arrows.width(), extra/2);
   541                                 arrows.width(), extra/2);
   506             rightB->setArrowType(Qt::DownArrow);
   542             rightB->setArrowType(Qt::DownArrow);
       
   543 #ifndef QT_NO_STYLE_S60
       
   544             }
       
   545 #endif
   507         }
   546         }
   508         leftB->setEnabled(scrollOffset > 0);
   547         leftB->setEnabled(scrollOffset > 0);
   509         rightB->setEnabled(last - scrollOffset >= available - extra);
   548         rightB->setEnabled(last - scrollOffset >= available - extra);
   510         leftB->show();
   549         leftB->show();
   511         rightB->show();
   550         rightB->show();