summaryrefslogtreecommitdiffstats
path: root/src/styles/qmotifplusstyle.cpp
diff options
context:
space:
mode:
authorDarrell Anderson <humanreadable@yahoo.com>2012-08-08 15:38:38 -0500
committerDarrell Anderson <humanreadable@yahoo.com>2012-08-08 15:38:38 -0500
commita236ea2ad383387255621fc8eaddc3c5d17f1e30 (patch)
treeecacdf1f8c9c02f545e06f8a430a145998fe11ea /src/styles/qmotifplusstyle.cpp
parent92b8aca467ad650f9b77a5b6a0f56c27ecbfe80a (diff)
parent47132557a4c58d4ad69bc2898bb2bd9c424b3b64 (diff)
downloadqt3-a236ea2ad383387255621fc8eaddc3c5d17f1e30.tar.gz
qt3-a236ea2ad383387255621fc8eaddc3c5d17f1e30.zip
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src/styles/qmotifplusstyle.cpp')
-rw-r--r--src/styles/qmotifplusstyle.cpp389
1 files changed, 196 insertions, 193 deletions
diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp
index 6cf56f3..86a2558 100644
--- a/src/styles/qmotifplusstyle.cpp
+++ b/src/styles/qmotifplusstyle.cpp
@@ -69,7 +69,9 @@ struct QMotifPlusStylePrivate
scrollbarElement(0), lastElement(0), ref(1)
{ ; }
- QGuardedPtr<QWidget> hoverWidget;
+ void* hoverWidget;
+ QStyleControlElementData hoverWidgetData;
+ QStyle::ControlElementFlags hoverWidgetFlags;
bool hovering, sliderActive, mousePressed;
int scrollbarElement, lastElement, ref;
QPoint mousePos;
@@ -176,58 +178,64 @@ void QMotifPlusStyle::polish(QPalette &)
/*! \reimp */
-void QMotifPlusStyle::polish(QWidget *widget)
+void QMotifPlusStyle::polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
+ if (ceData.widgetObjectTypes.contains("QWidget")) {
#ifndef QT_NO_FRAME
- if (::qt_cast<QFrame*>(widget) && ((QFrame *) widget)->frameStyle() == QFrame::Panel)
- ((QFrame *) widget)->setFrameStyle(QFrame::WinPanel);
+ if ((ceData.widgetObjectTypes.contains("QFrame")) && (ceData.frameStyle == QFrame::Panel)) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::WinPanel));
+ }
#endif
#ifndef QT_NO_MENUBAR
- if (::qt_cast<QMenuBar*>(widget) && ((QMenuBar *) widget)->frameStyle() != QFrame::NoFrame)
- ((QMenuBar *) widget)->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
+ if ((ceData.widgetObjectTypes.contains("QMenuBar")) && (ceData.frameStyle != QFrame::NoFrame)) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::StyledPanel | QFrame::Raised));
+ }
#endif
#ifndef QT_NO_TOOLBAR
- if (::qt_cast<QToolBar*>(widget))
- widget->layout()->setMargin(2);
+ if (ceData.widgetObjectTypes.contains("QToolBar")) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetLayoutMargin, QStyleWidgetActionRequestData(2));
+ }
#endif
+ }
if (useHoveringHighlight) {
- if (::qt_cast<QButton*>(widget) || ::qt_cast<QComboBox*>(widget))
- widget->installEventFilter(this);
+ if ((ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QComboBox"))) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
- if (::qt_cast<QScrollBar*>(widget) || ::qt_cast<QSlider*>(widget)) {
- widget->setMouseTracking(TRUE);
- widget->installEventFilter(this);
+ if ((ceData.widgetObjectTypes.contains("QScrollBar")) || (ceData.widgetObjectTypes.contains("QSlider"))) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking);
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
}
}
- QMotifStyle::polish(widget);
+ QMotifStyle::polish(ceData, elementFlags, ptr);
}
/*! \reimp */
-void QMotifPlusStyle::unPolish(QWidget *widget)
+void QMotifPlusStyle::unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- widget->removeEventFilter(this);
- QMotifStyle::unPolish(widget);
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ QMotifStyle::unPolish(ceData, elementFlags, ptr);
}
/*! \reimp */
-void QMotifPlusStyle::polish(QApplication *)
+void QMotifPlusStyle::applicationPolish(QStyleControlElementData, ControlElementFlags, void *)
{
}
/*! \reimp */
-void QMotifPlusStyle::unPolish(QApplication *)
+void QMotifPlusStyle::applicationUnPolish(QStyleControlElementData, ControlElementFlags, void *)
{
}
/*! \reimp */
-int QMotifPlusStyle::pixelMetric(PixelMetric metric, const QWidget *widget) const
+int QMotifPlusStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget) const
{
int ret;
@@ -259,7 +267,7 @@ int QMotifPlusStyle::pixelMetric(PixelMetric metric, const QWidget *widget) cons
break;
default:
- ret = QMotifStyle::pixelMetric(metric, widget);
+ ret = QMotifStyle::pixelMetric(metric, ceData, elementFlags, widget);
break;
}
@@ -270,6 +278,8 @@ int QMotifPlusStyle::pixelMetric(PixelMetric metric, const QWidget *widget) cons
/*! \reimp */
void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags,
@@ -303,11 +313,11 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe,
break;
case PE_SpinWidgetUp:
- drawPrimitive(PE_ArrowUp, p, r, cg, flags, opt);
+ drawPrimitive(PE_ArrowUp, p, ceData, elementFlags, r, cg, flags, opt);
break;
case PE_SpinWidgetDown:
- drawPrimitive(PE_ArrowDown, p, r, cg, flags, opt);
+ drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, r, cg, flags, opt);
break;
case PE_Indicator:
@@ -632,7 +642,7 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe,
}
default:
- QMotifStyle::drawPrimitive(pe, p, r, cg, flags, opt);
+ QMotifStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt);
break;
}
}
@@ -642,11 +652,13 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe,
*/
void QMotifPlusStyle::drawControl( ControlElement element,
QPainter *p,
- const QWidget *widget,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags,
- const QStyleOption& opt ) const
+ const QStyleOption& opt,
+ const QWidget *widget) const
{
if (widget == singleton->hoverWidget)
flags |= Style_MouseOver;
@@ -655,12 +667,11 @@ void QMotifPlusStyle::drawControl( ControlElement element,
case CE_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
QRect br = r;
- int dbi = pixelMetric(PM_ButtonDefaultIndicator, widget);
+ int dbi = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
- if (button->isDefault() || button->autoDefault()) {
- if (button->isDefault())
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
+ if (elementFlags & CEF_IsDefault)
drawMotifPlusShade(p, br, cg, TRUE, FALSE,
&cg.brush(QColorGroup::Background));
@@ -673,9 +684,9 @@ void QMotifPlusStyle::drawControl( ControlElement element,
if (flags & Style_HasFocus)
br.addCoords(1, 1, -1, -1);
p->save();
- p->setBrushOrigin( -button->backgroundOffset().x(),
- -button->backgroundOffset().y() );
- drawPrimitive(PE_ButtonCommand, p, br, cg, flags);
+ p->setBrushOrigin( -ceData.bgOffset.x(),
+ -ceData.bgOffset.y() );
+ drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags);
p->restore();
#endif
break;
@@ -684,23 +695,21 @@ void QMotifPlusStyle::drawControl( ControlElement element,
case CE_CheckBoxLabel:
{
#ifndef QT_NO_CHECKBOX
- const QCheckBox *checkbox = (const QCheckBox *) widget;
-
if (flags & Style_MouseOver) {
- QRegion r(checkbox->rect());
- r -= visualRect(subRect(SR_CheckBoxIndicator, widget), widget);
+ QRegion r(ceData.rect);
+ r -= visualRect(subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget), ceData, elementFlags);
p->setClipRegion(r);
- p->fillRect(checkbox->rect(), cg.brush(QColorGroup::Midlight));
+ p->fillRect(ceData.rect, cg.brush(QColorGroup::Midlight));
p->setClipping(FALSE);
}
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
- flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
+ flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text);
- if (checkbox->hasFocus()) {
- QRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
- drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ if (elementFlags & CEF_HasFocus) {
+ QRect fr = visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
@@ -709,23 +718,21 @@ void QMotifPlusStyle::drawControl( ControlElement element,
case CE_RadioButtonLabel:
{
#ifndef QT_NO_RADIOBUTTON
- const QRadioButton *radiobutton = (const QRadioButton *) widget;
-
if (flags & Style_MouseOver) {
- QRegion r(radiobutton->rect());
- r -= visualRect(subRect(SR_RadioButtonIndicator, widget), widget);
+ QRegion r(ceData.rect);
+ r -= visualRect(subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget), ceData, elementFlags);
p->setClipRegion(r);
- p->fillRect(radiobutton->rect(), cg.brush(QColorGroup::Midlight));
+ p->fillRect(ceData.rect, cg.brush(QColorGroup::Midlight));
p->setClipping(FALSE);
}
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
- flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text());
+ flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text);
- if (radiobutton->hasFocus()) {
- QRect fr = visualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
- drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ if (elementFlags & CEF_HasFocus) {
+ QRect fr = visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
@@ -757,7 +764,6 @@ void QMotifPlusStyle::drawControl( ControlElement element,
if (! widget || opt.isDefault())
break;
- QPopupMenu *popupmenu = (QPopupMenu *) widget;
QMenuItem *mi = opt.menuItem();
if ( !mi )
break;
@@ -765,7 +771,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
int tab = opt.tabWidth();
int maxpmw = opt.maxIconWidth();
bool dis = ! (flags & Style_Enabled);
- bool checkable = popupmenu->isCheckable();
+ bool checkable = (elementFlags & CEF_IsCheckable);
bool act = flags & Style_Active;
int x, y, w, h;
@@ -834,7 +840,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
if (act)
cflags |= Style_On;
- drawPrimitive(PE_CheckMark, p, vrect, cg, cflags);
+ drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags);
}
}
@@ -883,6 +889,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
QStyle::PrimitiveElement arrow = (QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight);
vrect = visualRect( QRect(x + w - hh - 6, y + (hh / 2), hh, hh), r );
drawPrimitive(arrow, p,
+ ceData, elementFlags,
vrect, cg,
((act && !dis) ?
Style_Down : Style_Default) |
@@ -895,16 +902,15 @@ void QMotifPlusStyle::drawControl( ControlElement element,
case CE_TabBarTab:
{
#ifndef QT_NO_TABBAR
- const QTabBar *tabbar = (const QTabBar *) widget;
bool selected = flags & Style_Selected;
- QColorGroup g = tabbar->colorGroup();
+ QColorGroup g = ceData.colorGroup;
QPen oldpen = p->pen();
QRect fr(r);
if (! selected) {
- if (tabbar->shape() == QTabBar::RoundedAbove ||
- tabbar->shape() == QTabBar::TriangularAbove) {
+ if (ceData.tabBarData.shape == QTabBar::RoundedAbove ||
+ ceData.tabBarData.shape == QTabBar::TriangularAbove) {
fr.setTop(fr.top() + 2);
} else {
fr.setBottom(fr.bottom() - 2);
@@ -917,7 +923,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
(selected) ? cg.brush(QColorGroup::Button)
: cg.brush(QColorGroup::Mid));
- if (tabbar->shape() == QTabBar::RoundedAbove) {
+ if (ceData.tabBarData.shape == QTabBar::RoundedAbove) {
// "rounded" tabs on top
fr.setBottom(fr.bottom() - 1);
@@ -941,7 +947,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
p->setPen(black);
p->drawLine(fr.right(), fr.top() + 1,
fr.right(), fr.bottom() - 1);
- } else if (tabbar->shape() == QTabBar::RoundedBelow) {
+ } else if (ceData.tabBarData.shape == QTabBar::RoundedBelow) {
// "rounded" tabs on bottom
fr.setTop(fr.top() + 1);
@@ -987,7 +993,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
}
} else
// triangular drawing code
- QMotifStyle::drawControl(element, p, widget, r, cg, flags, opt);
+ QMotifStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
p->setPen(oldpen);
#endif
@@ -995,7 +1001,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
}
default:
- QMotifStyle::drawControl(element, p, widget, r, cg, flags, opt);
+ QMotifStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
break;
}
}
@@ -1003,7 +1009,7 @@ void QMotifPlusStyle::drawControl( ControlElement element,
/*! \reimp
*/
-QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
+QRect QMotifPlusStyle::subRect(SubRect r, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget) const
{
QRect rect;
@@ -1011,11 +1017,10 @@ QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
case SR_PushButtonFocusRect:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
- int dfi = pixelMetric(PM_ButtonDefaultIndicator, widget);
+ int dfi = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
- rect = button->rect();
- if (button->isDefault() || button->autoDefault())
+ rect = ceData.rect;
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault))
rect.addCoords(dfi, dfi, -dfi, -dfi);
#endif
break;
@@ -1023,38 +1028,36 @@ QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
case SR_CheckBoxIndicator:
{
- int h = pixelMetric( PM_IndicatorHeight );
- rect.setRect(( widget->rect().height() - h ) / 2,
- ( widget->rect().height() - h ) / 2,
- pixelMetric( PM_IndicatorWidth ), h );
+ int h = pixelMetric( PM_IndicatorHeight, ceData, elementFlags );
+ rect.setRect(( ceData.rect.height() - h ) / 2,
+ ( ceData.rect.height() - h ) / 2,
+ pixelMetric( PM_IndicatorWidth, ceData, elementFlags ), h );
break;
}
case SR_RadioButtonIndicator:
{
- int h = pixelMetric( PM_ExclusiveIndicatorHeight );
- rect.setRect( ( widget->rect().height() - h ) / 2,
- ( widget->rect().height() - h ) / 2,
- pixelMetric( PM_ExclusiveIndicatorWidth ), h );
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight, ceData, elementFlags );
+ rect.setRect( ( ceData.rect.height() - h ) / 2,
+ ( ceData.rect.height() - h ) / 2,
+ pixelMetric( PM_ExclusiveIndicatorWidth, ceData, elementFlags ), h );
break;
}
case SR_CheckBoxFocusRect:
case SR_RadioButtonFocusRect:
- rect = widget->rect();
+ rect = ceData.rect;
break;
case SR_ComboBoxFocusRect:
{
#ifndef QT_NO_COMBOBOX
- const QComboBox *combobox = (const QComboBox *) widget;
-
- if (combobox->editable()) {
- rect = querySubControlMetrics(CC_ComboBox, widget,
- SC_ComboBoxEditField);
+ if (elementFlags & CEF_IsEditable) {
+ rect = querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
+ SC_ComboBoxEditField, QStyleOption::Default, widget);
rect.addCoords(-3, -3, 3, 3);
} else
- rect = combobox->rect();
+ rect = ceData.rect;
#endif
break;
}
@@ -1062,21 +1065,20 @@ QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
case SR_SliderFocusRect:
{
#ifndef QT_NO_SLIDER
- const QSlider *slider = (const QSlider *) widget;
- int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget );
- int thickness = pixelMetric( PM_SliderControlThickness, widget );
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
int x, y, wi, he;
- if ( slider->orientation() == Horizontal ) {
+ if ( ceData.orientation == Horizontal ) {
x = 0;
y = tickOffset;
- wi = slider->width();
+ wi = ceData.rect.width();
he = thickness;
} else {
x = tickOffset;
y = 0;
wi = thickness;
- he = slider->height();
+ he = ceData.rect.height();
}
rect.setRect(x, y, wi, he);
@@ -1085,7 +1087,7 @@ QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
}
default:
- rect = QMotifStyle::subRect(r, widget);
+ rect = QMotifStyle::subRect(r, ceData, elementFlags, widget);
break;
}
@@ -1096,13 +1098,15 @@ QRect QMotifPlusStyle::subRect(SubRect r, const QWidget *widget) const
/*! \reimp */
void QMotifPlusStyle::drawComplexControl(ComplexControl control,
QPainter *p,
- const QWidget *widget,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags,
SCFlags controls,
SCFlags active,
- const QStyleOption& opt ) const
+ const QStyleOption& opt,
+ const QWidget *widget ) const
{
if (widget == singleton->hoverWidget)
flags |= Style_MouseOver;
@@ -1111,17 +1115,16 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
case CC_ScrollBar:
{
#ifndef QT_NO_SCROLLBAR
- const QScrollBar *scrollbar = (const QScrollBar *) widget;
QRect addline, subline, addpage, subpage, slider, first, last;
- bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue());
+ bool maxedOut = (ceData.minSteps == ceData.maxSteps);
- subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt);
- addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt);
- subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt);
- addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt);
- slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt);
- first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt);
- last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt);
+ subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, opt, widget);
+ addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, opt, widget);
+ subpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget);
+ addpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget);
+ slider = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSlider, opt, widget);
+ first = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarFirst, opt, widget);
+ last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, opt, widget);
bool skipUpdate = FALSE;
if (singleton->hovering) {
@@ -1157,67 +1160,67 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
&cg.brush(QColorGroup::Mid));
if ((controls & SC_ScrollBarSubLine) && subline.isValid())
- drawPrimitive(PE_ScrollBarSubLine, p, subline, cg,
+ drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
((active == SC_ScrollBarSubLine ||
singleton->scrollbarElement == SC_ScrollBarSubLine) ?
Style_MouseOver: Style_Default) |
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarAddLine) && addline.isValid())
- drawPrimitive(PE_ScrollBarAddLine, p, addline, cg,
+ drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
((active == SC_ScrollBarAddLine ||
singleton->scrollbarElement == SC_ScrollBarAddLine) ?
Style_MouseOver: Style_Default) |
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddLine) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
- drawPrimitive(PE_ScrollBarSubPage, p, subpage, cg,
+ drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSubPage) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
- drawPrimitive(PE_ScrollBarAddPage, p, addpage, cg,
+ drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddPage) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarFirst) && first.isValid())
- drawPrimitive(PE_ScrollBarFirst, p, first, cg,
+ drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarFirst) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarLast) && last.isValid())
- drawPrimitive(PE_ScrollBarLast, p, last, cg,
+ drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarLast) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
- drawPrimitive(PE_ScrollBarSlider, p, slider, cg,
+ drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
((active == SC_ScrollBarSlider ||
singleton->scrollbarElement == SC_ScrollBarSlider) ?
Style_MouseOver: Style_Default) |
((maxedOut) ? Style_Default : Style_Enabled) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : Style_Default));
// ### perhaps this should not be able to accept focus if maxedOut?
- if (scrollbar->hasFocus()) {
+ if (elementFlags & CEF_HasFocus) {
QRect fr(slider.x() + 2, slider.y() + 2,
slider.width() - 5, slider.height() - 5);
- drawPrimitive(PE_FocusRect, p, fr, cg, Style_Default);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default);
}
}
#endif
@@ -1227,27 +1230,25 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
case CC_ComboBox:
{
#ifndef QT_NO_COMBOBOX
- const QComboBox *combobox = (const QComboBox *) widget;
-
QRect editfield, arrow;
editfield =
visualRect(querySubControlMetrics(CC_ComboBox,
- combobox,
+ ceData, elementFlags,
SC_ComboBoxEditField,
- opt), widget);
+ opt, widget), ceData, elementFlags);
arrow =
visualRect(querySubControlMetrics(CC_ComboBox,
- combobox,
+ ceData, elementFlags,
SC_ComboBoxArrow,
- opt), widget);
+ opt, widget), ceData, elementFlags);
- if (combobox->editable()) {
+ if (elementFlags & CEF_IsEditable) {
if (controls & SC_ComboBoxEditField && editfield.isValid()) {
editfield.addCoords(-3, -3, 3, 3);
- if (combobox->hasFocus())
+ if (elementFlags & CEF_HasFocus)
editfield.addCoords(1, 1, -1, -1);
drawMotifPlusShade(p, editfield, cg, TRUE, FALSE,
- (widget->isEnabled() ?
+ ((elementFlags & CEF_IsEnabled) ?
&cg.brush(QColorGroup::Base) :
&cg.brush(QColorGroup::Background)));
}
@@ -1261,12 +1262,12 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
if (active == SC_ComboBoxArrow)
flags |= Style_Sunken;
- drawPrimitive(PE_ArrowDown, p, arrow, cg, flags);
+ drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, arrow, cg, flags);
}
} else {
if (controls & SC_ComboBoxEditField && editfield.isValid()) {
editfield.addCoords(-3, -3, 3, 3);
- if (combobox->hasFocus())
+ if (elementFlags & CEF_HasFocus)
editfield.addCoords(1, 1, -1, -1);
drawMotifPlusShade(p, editfield, cg, FALSE,
(flags & Style_MouseOver));
@@ -1276,10 +1277,10 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
drawMotifPlusShade(p, arrow, cg, FALSE, (flags & Style_MouseOver));
}
- if (combobox->hasFocus() ||
- (combobox->editable() && combobox->lineEdit()->hasFocus())) {
- QRect fr = visualRect(subRect(SR_ComboBoxFocusRect, widget), widget);
- drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ if ((elementFlags & CEF_HasFocus) ||
+ ((elementFlags & CEF_IsEditable) && (ceData.comboBoxLineEditFlags & CEF_HasFocus))) {
+ QRect fr = visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
@@ -1288,7 +1289,6 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
case CC_SpinWidget:
{
#ifndef QT_NO_SPINWIDGET
- const QSpinWidget * sw = (const QSpinWidget *) widget;
SFlags flags = Style_Default;
if (controls & SC_SpinWidgetFrame)
@@ -1300,14 +1300,14 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
flags |= Style_Down;
PrimitiveElement pe;
- if ( sw->buttonSymbols() == QSpinWidget::PlusMinus )
+ if ( ceData.spinWidgetData.buttonSymbols == QSpinWidget::PlusMinus )
pe = PE_SpinWidgetPlus;
else
pe = PE_SpinWidgetUp;
- QRect re = sw->upRect();
- QColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
- drawPrimitive(pe, p, re, ucg, flags);
+ QRect re = ceData.spinWidgetData.upRect;
+ QColorGroup ucg = ceData.spinWidgetData.upEnabled ? cg : ceData.palette.disabled();
+ drawPrimitive(pe, p, ceData, elementFlags, re, ucg, flags);
}
if (controls & SC_SpinWidgetDown) {
@@ -1316,14 +1316,14 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
flags |= Style_Down;
PrimitiveElement pe;
- if ( sw->buttonSymbols() == QSpinWidget::PlusMinus )
+ if ( ceData.spinWidgetData.buttonSymbols == QSpinWidget::PlusMinus )
pe = PE_SpinWidgetMinus;
else
pe = PE_SpinWidgetDown;
- QRect re = sw->downRect();
- QColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
- drawPrimitive(pe, p, re, dcg, flags);
+ QRect re = ceData.spinWidgetData.downRect;
+ QColorGroup dcg = ceData.spinWidgetData.downEnabled ? cg : ceData.palette.disabled();
+ drawPrimitive(pe, p, ceData, elementFlags, re, dcg, flags);
}
#endif
break;
@@ -1332,21 +1332,20 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
case CC_Slider:
{
#ifndef QT_NO_SLIDER
- const QSlider *slider = (const QSlider *) widget;
bool mouseover = (flags & Style_MouseOver);
- QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
- opt),
- handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
- opt);
+ QRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove,
+ opt, widget),
+ handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle,
+ opt, widget);
if ((controls & SC_SliderGroove) && groove.isValid()) {
drawMotifPlusShade(p, groove, cg, TRUE, FALSE,
&cg.brush(QColorGroup::Mid));
if ( flags & Style_HasFocus ) {
- QRect fr = subRect( SR_SliderFocusRect, widget );
- drawPrimitive( PE_FocusRect, p, fr, cg, flags );
+ QRect fr = subRect( SR_SliderFocusRect, ceData, elementFlags, widget );
+ drawPrimitive( PE_FocusRect, p, ceData, elementFlags, fr, cg, flags );
}
}
@@ -1356,9 +1355,9 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
flags |= Style_MouseOver;
else
flags &= ~Style_MouseOver;
- drawPrimitive(PE_ButtonBevel, p, handle, cg, flags | Style_Raised);
+ drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, handle, cg, flags | Style_Raised);
- if ( slider->orientation() == Horizontal ) {
+ if ( ceData.orientation == Horizontal ) {
QCOORD mid = handle.x() + handle.width() / 2;
qDrawShadeLine( p, mid, handle.y() + 1, mid ,
handle.y() + handle.height() - 3,
@@ -1372,15 +1371,15 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
}
if (controls & SC_SliderTickmarks)
- QMotifStyle::drawComplexControl(control, p, widget, r, cg, flags,
- SC_SliderTickmarks, active, opt);
+ QMotifStyle::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags,
+ SC_SliderTickmarks, active, opt, widget);
#endif
break;
}
default:
- QMotifStyle::drawComplexControl(control, p, widget, r, cg, flags,
- controls, active, opt);
+ QMotifStyle::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags,
+ controls, active, opt, widget);
}
}
@@ -1388,22 +1387,24 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control,
/*! \reimp
*/
QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control,
- const QWidget *widget,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
SubControl subcontrol,
- const QStyleOption& opt) const
+ const QStyleOption& opt,
+ const QWidget *widget) const
{
switch (control) {
case CC_SpinWidget: {
- int fw = pixelMetric( PM_SpinBoxFrameWidth, 0 );
+ int fw = pixelMetric( PM_SpinBoxFrameWidth, ceData, elementFlags, 0 );
QSize bs;
- bs.setHeight( (widget->height() + 1)/2 );
+ bs.setHeight( (ceData.rect.height() + 1)/2 );
if ( bs.height() < 10 )
bs.setHeight( 10 );
bs.setWidth( bs.height() ); // 1.6 -approximate golden mean
bs = bs.expandedTo( QApplication::globalStrut() );
int y = 0;
int x, lx, rx, h;
- x = widget->width() - y - bs.width();
+ x = ceData.rect.width() - y - bs.width();
lx = fw;
rx = x - fw * 2;
h = bs.height() * 2;
@@ -1418,7 +1419,7 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control,
case SC_SpinWidgetEditField:
return QRect(lx, fw, rx, h - 2*fw);
case SC_SpinWidgetFrame:
- return QRect( 0, 0, widget->width() - bs.width(), h);
+ return QRect( 0, 0, ceData.rect.width() - bs.width(), h);
default:
break;
}
@@ -1426,34 +1427,33 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control,
#ifndef QT_NO_COMBOBOX
case CC_ComboBox: {
- const QComboBox *combobox = (const QComboBox *) widget;
- if (combobox->editable()) {
- int space = (combobox->height() - 13) / 2;
+ if (elementFlags & CEF_IsEditable) {
+ int space = (ceData.rect.height() - 13) / 2;
switch (subcontrol) {
case SC_ComboBoxFrame:
return QRect();
case SC_ComboBoxEditField: {
- QRect rect = widget->rect();
+ QRect rect = ceData.rect;
rect.setWidth(rect.width() - 13 - space * 2);
rect.addCoords(3, 3, -3, -3);
return rect; }
case SC_ComboBoxArrow:
- return QRect(combobox->width() - 13 - space * 2, 0,
- 13 + space * 2, combobox->height());
+ return QRect(ceData.rect.width() - 13 - space * 2, 0,
+ 13 + space * 2, ceData.rect.height());
default: break; // shouldn't get here
}
} else {
- int space = (combobox->height() - 7) / 2;
+ int space = (ceData.rect.height() - 7) / 2;
switch (subcontrol) {
case SC_ComboBoxFrame:
return QRect();
case SC_ComboBoxEditField: {
- QRect rect = widget->rect();
+ QRect rect = ceData.rect;
rect.addCoords(3, 3, -3, -3);
return rect; }
case SC_ComboBoxArrow: // 12 wide, 7 tall
- return QRect(combobox->width() - 12 - space, space, 12, 7);
+ return QRect(ceData.rect.width() - 12 - space, space, 12, 7);
default: break; // shouldn't get here
}
}
@@ -1464,14 +1464,13 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control,
case CC_Slider: {
if (subcontrol == SC_SliderHandle) {
- const QSlider *slider = (const QSlider *) widget;
- int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget );
- int thickness = pixelMetric( PM_SliderControlThickness, widget );
- int len = pixelMetric( PM_SliderLength, widget ) + 2;
- int sliderPos = slider->sliderStart();
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
+ int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ) + 2;
+ int sliderPos = ceData.startStep;
int motifBorder = 2;
- if ( slider->orientation() == Horizontal )
+ if ( ceData.orientation == Horizontal )
return QRect( sliderPos + motifBorder, tickOffset + motifBorder, len,
thickness - 2*motifBorder );
return QRect( tickOffset + motifBorder, sliderPos + motifBorder,
@@ -1481,19 +1480,19 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control,
#endif
default: break;
}
- return QMotifStyle::querySubControlMetrics(control, widget, subcontrol, opt);
+ return QMotifStyle::querySubControlMetrics(control, ceData, elementFlags, subcontrol, opt, widget);
}
/*! \reimp */
-bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event)
+bool QMotifPlusStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *event )
{
switch(event->type()) {
case QEvent::MouseButtonPress:
{
singleton->mousePressed = TRUE;
- if (!::qt_cast<QSlider*>(object))
+ if (!ceData.widgetObjectTypes.contains("QSlider"))
break;
singleton->sliderActive = TRUE;
@@ -1504,50 +1503,52 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event)
{
singleton->mousePressed = FALSE;
- if (!::qt_cast<QSlider*>(object))
+ if (!ceData.widgetObjectTypes.contains("QSlider"))
break;
singleton->sliderActive = FALSE;
- ((QWidget *) object)->repaint(FALSE);
+ widgetActionRequest(ceData, elementFlags, source, WAR_Repaint);
break;
}
case QEvent::Enter:
{
- if (! object->isWidgetType())
+ if (!ceData.widgetObjectTypes.contains("QWidget"))
break;
- singleton->hoverWidget = (QWidget *) object;
- if (! singleton->hoverWidget->isEnabled()) {
+ singleton->hoverWidget = source;
+ singleton->hoverWidgetData = ceData;
+ singleton->hoverWidgetFlags = elementFlags;
+ if (!(singleton->hoverWidgetFlags & CEF_IsEnabled)) {
singleton->hoverWidget = 0;
break;
}
- singleton->hoverWidget->repaint(FALSE);
+ widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint);
break;
}
case QEvent::Leave:
{
- if (object != singleton->hoverWidget)
+ if (source != singleton->hoverWidget)
break;
- QWidget *w = singleton->hoverWidget;
+ void *w = singleton->hoverWidget;
singleton->hoverWidget = 0;
- w->repaint(FALSE);
+ widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, w, WAR_Repaint);
break;
}
case QEvent::MouseMove:
{
- if (! object->isWidgetType() || object != singleton->hoverWidget)
+ if ((!ceData.widgetObjectTypes.contains("QWidget")) || source != singleton->hoverWidget)
break;
- if (!::qt_cast<QScrollBar*>(object) && ! ::qt_cast<QSlider*>(object))
+ if ((!ceData.widgetObjectTypes.contains("QScrollBar")) && (!ceData.widgetObjectTypes.contains("QSlider")))
break;
singleton->mousePos = ((QMouseEvent *) event)->pos();
if (! singleton->mousePressed) {
singleton->hovering = TRUE;
- singleton->hoverWidget->repaint(FALSE);
+ widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint);
singleton->hovering = FALSE;
}
@@ -1558,15 +1559,17 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event)
break;
}
- return QMotifStyle::eventFilter(object, event);
+ return QMotifStyle::objectEventHandler(ceData, elementFlags, source, event);
}
/*! \reimp */
int QMotifPlusStyle::styleHint(StyleHint hint,
- const QWidget *widget,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const QStyleOption &opt,
- QStyleHintReturn *returnData) const
+ QStyleHintReturn *returnData,
+ const QWidget *widget) const
{
int ret;
switch (hint) {
@@ -1574,7 +1577,7 @@ int QMotifPlusStyle::styleHint(StyleHint hint,
ret = 1;
break;
default:
- ret = QMotifStyle::styleHint(hint, widget, opt, returnData);
+ ret = QMotifStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget);
break;
}
return ret;