text color.
*/
QMotifStyle::QMotifStyle(bool useHighlightCols)
- : QCommonStyle(*new QMotifStylePrivate),
- focus(0),
- highlightCols(useHighlightCols)
+ : QCommonStyle(*new QMotifStylePrivate(useHighlightCols))
{
setObjectName(QLatin1String("Motif"));
}
/*!
\internal
*/
-QMotifStyle::QMotifStyle(QMotifStylePrivate &dd, bool useHighlightCols)
- : QCommonStyle(dd),
- focus(0),
- highlightCols(useHighlightCols)
+QMotifStyle::QMotifStyle(QMotifStylePrivate &dd)
+ : QCommonStyle(dd)
{
setObjectName(QLatin1String("Motif"));
}
-
-/*!
- \overload
-
- Destroys the style.
-*/
-QMotifStyle::~QMotifStyle()
-{
- delete focus;
-}
-
/*!
\internal
Animate indeterminate progress bars only when visible
QCommonStyle::timerEvent(event);
}
-
-QMotifStylePrivate::QMotifStylePrivate()
+QMotifStylePrivate::QMotifStylePrivate(bool useHighlightCols)
+ : QCommonStylePrivate(),
+ focus(Q_NULLPTR),
+ highlightCols(useHighlightCols),
#ifndef QT_NO_PROGRESSBAR
- : animationFps(25), animateTimer(0), animateStep(0)
+ animationFps(25), animateTimer(0), animateStep(0)
#endif
{
}
+QMotifStylePrivate::~QMotifStylePrivate()
+{
+ delete focus;
+}
+
/*!
If \a arg is false, the style will polish the application's color
palette to emulate the Motif way of highlighting, which is a
*/
void QMotifStyle::setUseHighlightColors(bool arg)
{
- highlightCols = arg;
+ Q_D(QMotifStyle);
+ d->highlightCols = arg;
}
/*!
*/
bool QMotifStyle::useHighlightColors() const
{
- return highlightCols;
+ Q_D(const QMotifStyle);
+ return d->highlightCols;
}
/*! \reimp */
void QMotifStyle::polish(QPalette& pal)
{
+ Q_D(const QMotifStyle);
if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) {
QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
pal.setColor(QPalette::Active, QPalette::Light, nlight) ;
pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ;
}
- if (highlightCols)
+ if (d->highlightCols)
return;
// force the ugly motif way of highlighting *sigh*
void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
+ Q_D(const QMotifStyle);
switch(pe) {
case PE_FrameTabWidget:
break;
case PE_FrameFocusRect:
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
- if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
+ if ((fropt->state & State_HasFocus) && d->focus && d->focus->isVisible()
&& !(fropt->state & QStyle::State_Item))
break;
QCommonStyle::drawPrimitive(pe, opt, p, w);
void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
const QWidget *widget) const
{
+ Q_D(const QMotifStyle);
switch(element) {
case CE_Splitter: {
QStyleOption handleOpt = *opt;
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
: SE_CheckBoxContents, btn, widget);
proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
- if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*btn);
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
- if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*btn);
fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
const QWidget *widget) const
{
+ Q_D(const QMotifStyle);
switch (cc) {
case CC_ToolButton:
if (const QStyleOptionToolButton *toolbutton
}
}
- if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ if ((toolbutton->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
QStyleOptionFocusRect fr;
fr.QStyleOption::operator=(*toolbutton);
fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
&opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
- if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ if ((opt->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
QStyleOption focusOpt = *opt;
focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
- if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOptionFocusRect focus;
- focus.QStyleOption::operator=(*opt);
- focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
- focus.backgroundColor = opt->palette.button().color();
- proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
+ if ((cb->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
+ QStyleOptionFocusRect focusRect;
+ focusRect.QStyleOption::operator=(*opt);
+ focusRect.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
+ focusRect.backgroundColor = opt->palette.button().color();
+ proxy()->drawPrimitive(PE_FrameFocusRect, &focusRect, p, widget);
}
}
/*! \reimp */
bool QMotifStyle::event(QEvent *e)
{
+ Q_D(QMotifStyle);
if(e->type() == QEvent::FocusIn) {
if (QWidget *focusWidget = QApplication::focusWidget()) {
#ifndef QT_NO_GRAPHICSVIEW
}
}
#endif
- if(!focus)
- focus = new QFocusFrame(focusWidget);
- focus->setWidget(focusWidget);
+ if (!d->focus)
+ d->focus = new QFocusFrame(focusWidget);
+ d->focus->setWidget(focusWidget);
} else {
- if(focus)
- focus->setWidget(0);
+ if (d->focus)
+ d->focus->setWidget(0);
}
- } else if(e->type() == QEvent::FocusOut) {
- if(focus)
- focus->setWidget(0);
+ } else if (e->type() == QEvent::FocusOut && d->focus) {
+ d->focus->setWidget(0);
}
return QCommonStyle::event(e);
}