summaryrefslogtreecommitdiff
path: root/src/gui/styles/qgtkstyle.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2009-10-08 21:10:01 +0200
committerJens Bache-Wiig <jbache@trolltech.com>2009-10-08 21:21:53 +0200
commit8c4edbd04f350294462fd689748de2dd7cc84d47 (patch)
tree0040c308fe3a5751ec04c27367a8110c5954912c /src/gui/styles/qgtkstyle.cpp
parent9551b8c349ce4e15a57c24a2408ee1b73c2b7510 (diff)
downloadqt4-tools-8c4edbd04f350294462fd689748de2dd7cc84d47.tar.gz
Fix tab widget painting in QGtkStyle with reverse
This also adds QStyleOptionTabWidgetFrameV2 so that we do not have to do ugly hacks in the style to obtain it. Task-number: QTBUG-5187 Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/styles/qgtkstyle.cpp')
-rw-r--r--src/gui/styles/qgtkstyle.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index d315c9846c..a7c291b287 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -1004,32 +1004,27 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.setAlphaSupport(false);
GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
- if (const QTabWidget *tabwidget = qobject_cast<const QTabWidget*>(widget)) {
- // We should introduce QStyleOptionTabWidgetFrameV2 to obtain this information
- // No gap if we do not show the actual tabs
- QTabBar *tabBar = tabwidget->findChild<QTabBar*>();
- if (tabwidget->count() > 0 && tabBar->isVisible()) {
- QRect tabRect = tabBar->tabRect(tabBar->currentIndex());
- int begin = 0, size = 0;
- GtkPositionType frameType = GTK_POS_TOP;
- QTabBar::Shape shape = frame->shape;
- if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
- begin = option->direction == Qt::LeftToRight ?
- frame->leftCornerWidgetSize.width() + tabRect.left() :
- frame->rect.width() - frame->tabBarSize.width() + tabRect.left()
- - frame->rightCornerWidgetSize.width();
- size = tabRect.width();
- frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
- } else {
- begin = frame->leftCornerWidgetSize.height() + tabRect.top();
- size = tabRect.height();
- frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
- }
- gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
- begin, size, style);
- break; // done
+ bool reverse = (option->direction == Qt::RightToLeft);
+ QGtk::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
+ GtkPositionType frameType = GTK_POS_TOP;
+ QTabBar::Shape shape = frame->shape;
+ int gapStart = 0;
+ int gapSize = 0;
+ if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
+ frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
+ gapStart = tabframe->selectedTabRect.left();
+ gapSize = tabframe->selectedTabRect.width();
+ } else {
+ frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
+ gapStart = tabframe->selectedTabRect.y();
+ gapSize = tabframe->selectedTabRect.height();
}
+ gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
+ gapStart, gapSize, style);
+ break; // done
}
+
// Note this is only the fallback option
gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
}