bool ScrollbarThemeQt::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect) { if (graphicsContext->updatingControlTints()) { scrollbar->invalidateRect(damageRect); return false; } StylePainter p(graphicsContext); if (!p.isValid()) return true; p.painter->save(); QStyleOptionSlider* opt = styleOptionSlider(scrollbar); p.painter->setClipRect(opt->rect.intersected(damageRect)); #ifdef Q_WS_MAC p.drawComplexControl(QStyle::CC_ScrollBar, *opt); #else const QPoint topLeft = opt->rect.topLeft(); p.painter->translate(topLeft); opt->rect.moveTo(QPoint(0, 0)); // The QStyle expects the background to be already filled p.painter->fillRect(opt->rect, opt->palette.background()); p.drawComplexControl(QStyle::CC_ScrollBar, *opt); opt->rect.moveTo(topLeft); #endif p.painter->restore(); return true; }
ScrollbarPart ScrollbarThemeQt::hitTest(Scrollbar* scrollbar, const PlatformMouseEvent& evt) { QStyleOptionSlider* opt = styleOptionSlider(scrollbar); const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos()); opt->rect.moveTo(QPoint(0, 0)); QStyle::SubControl sc = QApplication::style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0); return scrollbarPart(sc); }
bool ScrollbarThemeQStyle::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& dirtyRect) { if (graphicsContext->updatingControlTints()) { scrollbar->invalidateRect(dirtyRect); return false; } StylePainterQStyle p(this, graphicsContext); if (!p.isValid()) return true; p.painter->save(); QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget); p.painter->setClipRect(opt->rect.intersected(dirtyRect), Qt::IntersectClip); #ifdef Q_WS_MAC // FIXME: We also need to check the widget style but today ScrollbarTheme is not aware of the page so we // can't get the widget. if (qobject_cast<QMacStyle*>(style())) p.drawComplexControl(QStyle::CC_ScrollBar, *opt); else #endif { // The QStyle expects the background to be already filled. p.painter->fillRect(opt->rect, opt->palette.background()); const QPoint topLeft = opt->rect.topLeft(); p.painter->translate(topLeft); opt->rect.moveTo(QPoint(0, 0)); p.drawComplexControl(QStyle::CC_ScrollBar, *opt); opt->rect.moveTo(topLeft); } p.painter->restore(); return true; }
int ScrollbarThemeQt::trackLength(Scrollbar* scrollbar) { QStyleOptionSlider* opt = styleOptionSlider(scrollbar); IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height(); }
int ScrollbarThemeQStyle::trackPosition(ScrollbarThemeClient* scrollbar) { QStyleOptionSlider* opt = styleOptionSlider(scrollbar); IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0); return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y(); }
int ScrollbarThemeQStyle::thumbLength(ScrollbarThemeClient* scrollbar) { QStyleOptionSlider* opt = styleOptionSlider(scrollbar); IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0); return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height(); }