summaryrefslogtreecommitdiffstats
path: root/src/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/styles/qcommonstyle.cpp')
-rw-r--r--src/styles/qcommonstyle.cpp208
1 files changed, 26 insertions, 182 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
index e46f264..b81018e 100644
--- a/src/styles/qcommonstyle.cpp
+++ b/src/styles/qcommonstyle.cpp
@@ -184,7 +184,6 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
if (button) {
if (button->isDown()) cef = cef | QStyle::CEF_IsDown;
if (button->isOn()) cef = cef | QStyle::CEF_IsOn;
- if (button->isEnabled()) cef = cef | QStyle::CEF_IsEnabled;
if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState;
}
}
@@ -223,6 +222,7 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
// Generic flags
const QWidget* widget = dynamic_cast<const QWidget*>(object);
if (widget) {
+ if (widget->isEnabled()) cef = cef | QStyle::CEF_IsEnabled;
if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget;
if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy;
if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus;
@@ -254,6 +254,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.bgBrush = widget->backgroundBrush();
}
ceData.wflags = widget->getWFlags();
+ if (populateReliantFields) {
+ ceData.windowState = (Qt::WindowState)(widget->windowState());
+ }
ceData.bgColor = widget->eraseColor();
ceData.bgOffset = widget->backgroundOffset();
ceData.backgroundMode = widget->backgroundMode();
@@ -419,10 +422,10 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
const QTitleBar *tb = dynamic_cast<const QTitleBar*>(widget);
if (tb) {
ceData.titleBarData.hasWindow = !!(tb->window());
- if (ceData.titleBarData.hasWindow) {
- ceData.titleBarData.windowState = tb->window()->windowState();
- }
if (populateReliantFields) {
+ if (ceData.titleBarData.hasWindow) {
+ ceData.titleBarData.windowState = (Qt::WindowState)(tb->window()->windowState());
+ }
ceData.titleBarData.usesActiveColor = tb->usesActiveColor();
}
ceData.titleBarData.visibleText = tb->visibleText();
@@ -455,6 +458,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.viewportData.bgBrush = viewport->backgroundBrush();
}
ceData.viewportData.wflags = viewport->getWFlags();
+ if (populateReliantFields) {
+ ceData.viewportData.windowState = (Qt::WindowState)(widget->windowState());
+ }
ceData.viewportData.bgColor = viewport->eraseColor();
ceData.viewportData.bgOffset = viewport->backgroundOffset();
ceData.viewportData.backgroundMode = viewport->backgroundMode();
@@ -502,6 +508,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush();
}
ceData.parentWidgetData.wflags = parentWidget->getWFlags();
+ if (populateReliantFields) {
+ ceData.parentWidgetData.windowState = (Qt::WindowState)(widget->windowState());
+ }
ceData.parentWidgetData.bgColor = parentWidget->eraseColor();
ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset();
ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode();
@@ -531,33 +540,20 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.dwData.closeEnabled = dw->isCloseEnabled();
}
}
- }
- return ceData;
-}
-
-/*! \reimp */
-void QCommonStyle::drawPrimitive( PrimitiveElement pe,
- QPainter *p,
- const QRect &r,
- const QColorGroup &cg,
- SFlags flags,
- const QStyleOption& opt ) const
-{
- const QWidget* widget = 0;
-
- // Determine if the request needs widget information and set widget appropriately
- // FIXME
- if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) {
QCheckListItem *item = opt.checkListItem();
if (item) {
- QListView *lv = item->listView();
- widget = dynamic_cast<QWidget*>(lv);
+ ceData.checkListItemData.dataValid = true;
+ ceData.checkListItemData.enabled = item->isEnabled();
+ ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((QCheckListItem*) item->parent())->type() == QCheckListItem::Controller) );
+ ceData.checkListItemData.height = item->height();
+ }
+ else {
+ ceData.checkListItemData.dataValid = false;
}
}
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt);
+ return ceData;
}
/*! \reimp */
@@ -578,8 +574,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
p->drawPixmap(r, QPixmap((const char **)check_list_controller_xpm));
break; }
case PE_CheckListExclusiveIndicator: {
- QCheckListItem *item = opt.checkListItem();
- if(!item)
+ if(!ceData.checkListItemData.dataValid)
return;
int x = r.x(), y = r.y();
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
@@ -630,8 +625,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
}
break; }
case PE_CheckListIndicator: {
- QCheckListItem *item = opt.checkListItem();
- if(!item)
+ if(!ceData.checkListItemData.dataValid)
return;
int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = ceData.listViewData.itemMargin;
@@ -640,14 +634,10 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
else
p->setPen( QPen( ceData.palette.color( QPalette::Disabled, QColorGroup::Text ),
2 ) );
- bool parentControl = FALSE;
- if ( item->parent() && item->parent()->rtti() == 1 &&
- ((QCheckListItem*) item->parent())->type() == QCheckListItem::Controller )
- parentControl = TRUE;
- if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !parentControl ) {
- p->fillRect( 0, 0, x + marg + w + 4, item->height(),
+ if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !ceData.checkListItemData.hasParent ) {
+ p->fillRect( 0, 0, x + marg + w + 4, ceData.checkListItemData.height,
cg.brush( QColorGroup::Highlight ) );
- if ( item->isEnabled() )
+ if ( ceData.checkListItemData.enabled )
p->setPen( QPen( cg.highlightedText(), 2 ) );
}
@@ -1047,26 +1037,6 @@ void qt_style_erase_region(QPainter* p, const QRegion& region, QStyleControlElem
/*! \reimp */
void QCommonStyle::drawControl( ControlElement element,
QPainter *p,
- const QWidget *widget,
- const QRect &r,
- const QColorGroup &cg,
- SFlags flags,
- const QStyleOption& opt ) const
-{
-#if defined(QT_CHECK_STATE)
- if (!widget) {
- qWarning("QCommonStyle::drawControl: widget parameter cannot be zero!");
- return;
- }
-#endif
-
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt);
- drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget);
-}
-
-/*! \reimp */
-void QCommonStyle::drawControl( ControlElement element,
- QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
@@ -1544,16 +1514,6 @@ void QCommonStyle::drawControl( ControlElement element,
activePainter = 0;
}
-void QCommonStyle::drawControlMask( ControlElement control,
- QPainter *p,
- const QWidget *widget,
- const QRect &r,
- const QStyleOption& opt ) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt);
- drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget);
-}
-
/*! \reimp */
void QCommonStyle::drawControlMask( ControlElement control,
QPainter *p,
@@ -1593,20 +1553,6 @@ void QCommonStyle::drawControlMask( ControlElement control,
}
/*! \reimp */
-QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
-{
-#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::subRect: widget parameter cannot be zero!");
- return QRect();
- }
-#endif
-
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget);
-}
-
-/*! \reimp */
QRect QCommonStyle::subRect(SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget) const
{
QRect rect, wrect(ceData.rect);
@@ -1936,28 +1882,6 @@ static int qPositionFromValue( QStyleControlElementData ceData, int logical_val,
/*! \reimp */
void QCommonStyle::drawComplexControl( ComplexControl control,
QPainter *p,
- const QWidget *widget,
- const QRect &r,
- const QColorGroup &cg,
- SFlags flags,
- SCFlags controls,
- SCFlags active,
- const QStyleOption& opt ) const
-{
-#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::drawComplexControl: widget parameter cannot be zero!");
- return;
- }
-#endif
-
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, controls, active, opt, widget);
-}
-
-/*! \reimp */
-void QCommonStyle::drawComplexControl( ComplexControl control,
- QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
@@ -2360,17 +2284,6 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
/*! \reimp */
void QCommonStyle::drawComplexControlMask( ComplexControl control,
QPainter *p,
- const QWidget *widget,
- const QRect &r,
- const QStyleOption& opt ) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, opt, widget);
-}
-
-/*! \reimp */
-void QCommonStyle::drawComplexControlMask( ComplexControl control,
- QPainter *p,
const QStyleControlElementData ceData,
const ControlElementFlags elementFlags,
const QRect &r,
@@ -2388,23 +2301,6 @@ void QCommonStyle::drawComplexControlMask( ComplexControl control,
/*! \reimp */
QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
- const QWidget *widget,
- SubControl sc,
- const QStyleOption &opt ) const
-{
-#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::querySubControlMetrics: widget parameter cannot be zero!");
- return QRect();
- }
-#endif
-
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false);
- return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget);
-}
-
-/*! \reimp */
-QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
SubControl sc,
@@ -2637,17 +2533,6 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
return QRect();
}
-
-/*! \reimp */
-QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
- const QWidget *widget,
- const QPoint &pos,
- const QStyleOption& opt ) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt);
- return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget);
-}
-
/*! \reimp */
QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
QStyleControlElementData ceData,
@@ -2724,14 +2609,6 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
return ret;
}
-
-/*! \reimp */
-int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget);
-}
-
/*! \reimp */
int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget) const
{
@@ -2954,25 +2831,6 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co
/*! \reimp */
QSize QCommonStyle::sizeFromContents(ContentsType contents,
- const QWidget *widget,
- const QSize &contentsSize,
- const QStyleOption& opt ) const
-{
- QSize sz(contentsSize);
-
-#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::sizeFromContents: widget parameter cannot be zero!");
- return sz;
- }
-#endif
-
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
- return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), contentsSize, opt, widget);
-}
-
-/*! \reimp */
-QSize QCommonStyle::sizeFromContents(ContentsType contents,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QSize &contentsSize,
@@ -3143,13 +3001,6 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
}
/*! \reimp */
-int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption(), false);
- return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w);
-}
-
-/*! \reimp */
int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const
{
Q_UNUSED(w);
@@ -3233,13 +3084,6 @@ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, Contr
}
/*! \reimp */
-QPixmap QCommonStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const
-{
- QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption());
- return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, w);
-}
-
-/*! \reimp */
QPixmap QCommonStyle::stylePixmap(StylePixmap, QStyleControlElementData, ControlElementFlags, const QStyleOption&, const QWidget *) const
{
return QPixmap();