65 #include <QtGui/QToolButton> |
65 #include <QtGui/QToolButton> |
66 #include <QtGui/QGroupBox> |
66 #include <QtGui/QGroupBox> |
67 #include <QtGui/QRadioButton> |
67 #include <QtGui/QRadioButton> |
68 #include <QtGui/QCheckBox> |
68 #include <QtGui/QCheckBox> |
69 #include <QtGui/QTreeView> |
69 #include <QtGui/QTreeView> |
|
70 #include <QtGui/QStyledItemDelegate> |
70 #include <qpixmapcache.h> |
71 #include <qpixmapcache.h> |
71 #undef signals // Collides with GTK stymbols |
72 #undef signals // Collides with GTK stymbols |
72 #include <private/qgtkpainter_p.h> |
73 #include <private/qgtkpainter_p.h> |
73 #include <private/qstylehelper_p.h> |
74 #include <private/qstylehelper_p.h> |
74 #include <private/qgtkstyle_p.h> |
75 #include <private/qgtkstyle_p.h> |
688 // Drawing the entire itemview frame is very expensive, especially on the native X11 engine |
691 // Drawing the entire itemview frame is very expensive, especially on the native X11 engine |
689 // Instead we cheat a bit and draw a border image without the center part, hence only scaling |
692 // Instead we cheat a bit and draw a border image without the center part, hence only scaling |
690 // thin rectangular images |
693 // thin rectangular images |
691 const int pmSize = 64; |
694 const int pmSize = 64; |
692 const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
695 const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
693 const QString pmKey = QString(QLS("windowframe %0")).arg(option->state); |
696 const QString pmKey = QLatin1Literal("windowframe") % HexString<uint>(option->state); |
694 |
697 |
695 QPixmap pixmap; |
698 QPixmap pixmap; |
696 QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); |
699 QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); |
697 |
700 |
698 // Only draw through style once |
701 // Only draw through style once |
813 |
816 |
814 gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state, |
817 gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state, |
815 option->state & State_Open ? openState : closedState , gtkTreeView->style); |
818 option->state & State_Open ? openState : closedState , gtkTreeView->style); |
816 } |
819 } |
817 break; |
820 break; |
|
821 |
|
822 case PE_PanelItemViewRow: |
|
823 // This primitive is only used to draw selection behind selected expander arrows. |
|
824 // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate |
|
825 // The reason for this is that a lot of code that relies on custom item delegates will look odd having |
|
826 // a gradient on the branch but a flat shaded color on the item itself. |
|
827 QCommonStyle::drawPrimitive(element, option, painter, widget); |
|
828 if (!option->state & State_Selected) { |
|
829 break; |
|
830 } else { |
|
831 if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) { |
|
832 if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate())) |
|
833 break; |
|
834 } |
|
835 } // fall through |
|
836 |
818 case PE_PanelItemViewItem: |
837 case PE_PanelItemViewItem: |
819 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
838 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
820 if (vopt->state & State_Selected) { |
839 if (vopt->backgroundBrush.style() != Qt::NoBrush) { |
821 QLinearGradient gradient; |
840 QPointF oldBO = painter->brushOrigin(); |
822 gradient.setStart(option->rect.left(), option->rect.top()); |
841 painter->setBrushOrigin(vopt->rect.topLeft()); |
823 gradient.setFinalStop(option->rect.left(), option->rect.bottom()); |
842 painter->fillRect(vopt->rect, vopt->backgroundBrush); |
824 gradient.setColorAt(0, option->palette.highlight().color().lighter(105)); |
843 painter->setBrushOrigin(oldBO); |
825 gradient.setColorAt(0.5, option->palette.highlight().color().lighter(101)); |
844 if (!(option->state & State_Selected)) |
826 gradient.setColorAt(0.51, option->palette.highlight().color().darker(101)); |
845 break; |
827 gradient.setColorAt(1, option->palette.highlight().color().darker(105)); |
846 } |
828 painter->fillRect(option->rect, gradient); |
847 if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) { |
829 } else { |
848 const char *detail = "cell_even_ruled"; |
830 if (vopt->backgroundBrush.style() != Qt::NoBrush) { |
849 if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate) |
831 QPointF oldBO = painter->brushOrigin(); |
850 detail = "cell_odd_ruled"; |
832 painter->setBrushOrigin(vopt->rect.topLeft()); |
851 bool isActive = option->state & State_Active; |
833 painter->fillRect(vopt->rect, vopt->backgroundBrush); |
852 QString key; |
834 painter->setBrushOrigin(oldBO); |
853 if (isActive ) { |
|
854 // Required for active/non-active window appearance |
|
855 key = QLS("a"); |
|
856 GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS); |
835 } |
857 } |
|
858 bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled)); |
|
859 gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect, |
|
860 option->state & State_Selected ? GTK_STATE_SELECTED : |
|
861 isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, |
|
862 GTK_SHADOW_OUT, gtkTreeView->style, key); |
|
863 if (isActive ) |
|
864 GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS); |
836 } |
865 } |
837 } |
866 } |
838 break; |
867 break; |
839 case PE_IndicatorToolBarSeparator: |
868 case PE_IndicatorToolBarSeparator: |
840 { |
869 { |