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.cpp1445
1 files changed, 983 insertions, 462 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
index 6e89845..e46f264 100644
--- a/src/styles/qcommonstyle.cpp
+++ b/src/styles/qcommonstyle.cpp
@@ -49,9 +49,11 @@
#include "qpixmap.h"
#include "qpushbutton.h"
#include "qtabbar.h"
+#include "qlineedit.h"
#include "qscrollbar.h"
#include "qtoolbutton.h"
#include "qtoolbar.h"
+#include "qcombobox.h"
#include "qdockarea.h"
#include "qheader.h"
#include "qspinbox.h"
@@ -135,6 +137,405 @@ static const char * const check_list_controller_xpm[] = {
" ",
" "};
+#include <nqmetaobject.h>
+
+QStringList getObjectTypeListForObject(const QObject* object) {
+ QStringList objectTypes;
+
+ if (object) {
+ QMetaObject* objectMetaObject = object->metaObject();
+ const char* name;
+
+ while (objectMetaObject) {
+ name = objectMetaObject->className();
+ objectTypes.append(QString(name));
+ objectMetaObject = objectMetaObject->superClass();
+ }
+ }
+
+ return objectTypes;
+}
+
+QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields) {
+ QStyle::ControlElementFlags cef = (QStyle::ControlElementFlags)0;
+
+ if (object) {
+ if (objectTypeList.contains("QPushButton")) {
+ const QPushButton *button = dynamic_cast<const QPushButton*>(object);
+ if (button) {
+ if (button->isDefault()) cef = cef | QStyle::CEF_IsDefault;
+ if (button->autoDefault()) cef = cef | QStyle::CEF_AutoDefault;
+ if (button->isMenuButton()) cef = cef | QStyle::CEF_IsMenuWidget;
+ if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState;
+ if (button->isFlat()) cef = cef | QStyle::CEF_IsFlat;
+ }
+ }
+ if (objectTypeList.contains("QToolButton")) {
+ const QToolButton *button = dynamic_cast<const QToolButton*>(object);
+ if (button) {
+ if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState;
+ if (button->usesTextLabel()) cef = cef | QStyle::CEF_UsesTextLabel;
+ if (button->usesBigPixmap()) cef = cef | QStyle::CEF_UsesBigPixmap;
+ if (button->popup()) cef = cef | QStyle::CEF_HasPopupMenu;
+ }
+ }
+ if (objectTypeList.contains("QButton")) {
+ const QButton *button = dynamic_cast<const QButton*>(object);
+ 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;
+ }
+ }
+ if (objectTypeList.contains("QTabBar")) {
+ const QTabBar *tb = dynamic_cast<const QTabBar*>(object);
+ QTab * t = opt.tab();
+ if ((t) && (tb)) {
+ if (t->identifier() == tb->currentTab()) cef = cef | QStyle::CEF_IsActive;
+ }
+ }
+ if (objectTypeList.contains("QToolBox")) {
+ const QToolBox *tb = dynamic_cast<const QToolBox*>(object);
+ if (tb) {
+ if (!tb->currentItem()) cef = cef | QStyle::CEF_IsContainerEmpty;
+ }
+ }
+ if (objectTypeList.contains("QProgressBar")) {
+ const QProgressBar *pb = dynamic_cast<const QProgressBar*>(object);
+ if (pb) {
+ if (pb->centerIndicator()) cef = cef | QStyle::CEF_CenterIndicator;
+ if (pb->indicatorFollowsStyle()) cef = cef | QStyle::CEF_IndicatorFollowsStyle;
+ }
+ }
+ if (objectTypeList.contains("QPopupMenu")) {
+ const QPopupMenu *pm = dynamic_cast<const QPopupMenu*>(object);
+ if (pm) {
+ if (pm->isCheckable()) cef = cef | QStyle::CEF_IsCheckable;
+ }
+ }
+ if (objectTypeList.contains("QComboBox")) {
+ const QComboBox *cb = dynamic_cast<const QComboBox*>(object);
+ if (cb) {
+ if (cb->editable()) cef = cef | QStyle::CEF_IsEditable;
+ }
+ }
+ // Generic flags
+ const QWidget* widget = dynamic_cast<const QWidget*>(object);
+ if (widget) {
+ if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget;
+ if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy;
+ if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus;
+ if (populateReliantFields) {
+ if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow;
+ if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel;
+ if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible;
+ }
+ }
+ }
+ else {
+ cef = cef | QStyle::CEF_UseGenericParameters;
+ }
+
+ return cef;
+}
+
+QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields) {
+ QStyleControlElementData ceData;
+
+ if (widget) {
+ ceData.widgetObjectTypes = getObjectTypeListForObject(widget);
+ ceData.allDataPopulated = populateReliantFields;
+ const QPixmap* erasePixmap = widget->backgroundPixmap();
+ if (erasePixmap) {
+ ceData.bgPixmap = *erasePixmap;
+ }
+ if (populateReliantFields) {
+ ceData.bgBrush = widget->backgroundBrush();
+ }
+ ceData.wflags = widget->getWFlags();
+ ceData.bgColor = widget->eraseColor();
+ ceData.bgOffset = widget->backgroundOffset();
+ ceData.backgroundMode = widget->backgroundMode();
+ if (populateReliantFields) {
+ ceData.fgColor = widget->foregroundColor();
+ ceData.colorGroup = widget->colorGroup();
+ }
+ ceData.geometry = widget->geometry();
+ ceData.rect = widget->rect();
+ ceData.pos = widget->pos();
+ const QPixmap* icon = widget->icon();
+ if (icon) {
+ ceData.icon = *icon;
+ }
+ ceData.palette = widget->palette();
+ ceData.font = widget->font();
+ if (ceData.widgetObjectTypes.contains("QPushButton")) {
+ const QPushButton *button = dynamic_cast<const QPushButton*>(widget);
+ if (button) {
+ QIconSet* iconSet = 0;
+ const QPixmap* fgPixmap = 0;
+ iconSet = button->iconSet();
+ fgPixmap = button->pixmap();
+ if (iconSet) {
+ ceData.iconSet = *iconSet;
+ }
+ if (fgPixmap) {
+ ceData.fgPixmap = *fgPixmap;
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QToolButton")) {
+ const QToolButton *button = dynamic_cast<const QToolButton*>(widget);
+ if (button) {
+ const QPixmap* fgPixmap = 0;
+ ceData.iconSet = button->iconSet();
+ fgPixmap = button->pixmap();
+ if (fgPixmap) {
+ ceData.fgPixmap = *fgPixmap;
+ }
+ ceData.textLabel = button->textLabel();
+ ceData.toolButtonTextPosition = button->textPosition();
+ ceData.popupDelay = button->popupDelay();
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QCheckBox")) {
+ const QCheckBox *button = dynamic_cast<const QCheckBox*>(widget);
+ if (button) {
+ const QPixmap* fgPixmap = 0;
+ fgPixmap = button->pixmap();
+ if (fgPixmap) {
+ ceData.fgPixmap = *fgPixmap;
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QRadioButton")) {
+ const QRadioButton *button = dynamic_cast<const QRadioButton*>(widget);
+ if (button) {
+ const QPixmap* fgPixmap = 0;
+ fgPixmap = button->pixmap();
+ if (fgPixmap) {
+ ceData.fgPixmap = *fgPixmap;
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QButton")) {
+ const QButton *button = dynamic_cast<const QButton*>(widget);
+ if (button) {
+ ceData.text = button->text();
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QTabBar")) {
+ const QTabBar *tb = dynamic_cast<const QTabBar*>(widget);
+ if (tb) {
+ ceData.tabBarData.tabCount = tb->count();
+ ceData.tabBarData.shape = tb->shape();
+ ceData.tabBarData.identIndexMap.clear();
+ const QTab* currentTab;
+ for (int i=0; i<tb->count(); ++i) {
+ currentTab = tb->tabAt(i);
+ if (currentTab) {
+ ceData.tabBarData.identIndexMap[currentTab->identifier()] = tb->indexOf(currentTab->identifier());
+ }
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QToolBox")) {
+ const QToolBox *tb = dynamic_cast<const QToolBox*>(widget);
+ if (tb) {
+ const QWidget* currentItem = tb->currentItem();
+ if (currentItem) {
+ ceData.activeItemPaletteBgColor = currentItem->paletteBackgroundColor();
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QProgressBar")) {
+ const QProgressBar *pb = dynamic_cast<const QProgressBar*>(widget);
+ if (pb) {
+ ceData.currentStep = pb->progress();
+ ceData.totalSteps = pb->totalSteps();
+ ceData.progressText = pb->progressString();
+ ceData.percentageVisible = pb->percentageVisible();
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QHeader")) {
+ const QHeader *header = dynamic_cast<const QHeader*>(widget);
+ if (header) {
+ int section = opt.headerSection();
+ QIconSet* iconSet = 0;
+ iconSet = header->iconSet(section);
+ ceData.textLabel = header->label(section);
+ if (iconSet) {
+ ceData.iconSet = *iconSet;
+ }
+ }
+ }
+ // Complex Controls
+ if (ceData.widgetObjectTypes.contains("QScrollBar")) {
+ const QScrollBar *sb = dynamic_cast<const QScrollBar*>(widget);
+ if (sb) {
+ ceData.orientation = sb->orientation();
+ ceData.minSteps = sb->minValue();
+ ceData.maxSteps = sb->maxValue();
+ ceData.currentStep = sb->value();
+ ceData.startStep = sb->sliderStart();
+ ceData.lineStep = sb->lineStep();
+ ceData.pageStep = sb->pageStep();
+ if (populateReliantFields) {
+ ceData.sliderRect = sb->sliderRect();
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QSlider")) {
+ const QSlider *sl = dynamic_cast<const QSlider*>(widget);
+ if (sl) {
+ ceData.orientation = sl->orientation();
+ ceData.tickMarkSetting = sl->tickmarks();
+ ceData.tickInterval = sl->tickInterval();
+ ceData.currentStep = sl->value();
+ ceData.startStep = sl->sliderStart();
+ ceData.lineStep = sl->lineStep();
+ ceData.pageStep = sl->pageStep();
+ if (populateReliantFields) {
+ ceData.sliderRect = sl->sliderRect();
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QDialogButtons")) {
+ const QDialogButtons *dlgbtns = dynamic_cast<const QDialogButtons*>(widget);
+ if (dlgbtns) {
+ ceData.orientation = dlgbtns->orientation();
+ ceData.dlgVisibleButtons = dlgbtns->visibleButtons();
+ QDialogButtons::Button btns[] = { QDialogButtons::All, QDialogButtons::Reject, QDialogButtons::Accept, QDialogButtons::Apply, QDialogButtons::Retry, QDialogButtons::Ignore, QDialogButtons::Abort, QDialogButtons::Help };
+ for(unsigned int i = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
+ if (ceData.dlgVisibleButtons & btns[i]) {
+ ceData.dlgVisibleSizeHints[btns[i]] = dlgbtns->sizeHint(btns[i]);
+ }
+ }
+
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QTitleBar")) {
+ 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) {
+ ceData.titleBarData.usesActiveColor = tb->usesActiveColor();
+ }
+ ceData.titleBarData.visibleText = tb->visibleText();
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QSpinWidget")) {
+ const QSpinWidget *sw = dynamic_cast<const QSpinWidget*>(widget);
+ if (sw) {
+ ceData.spinWidgetData.buttonSymbols = sw->buttonSymbols();
+ ceData.spinWidgetData.upRect = sw->upRect();
+ ceData.spinWidgetData.downRect = sw->downRect();
+ ceData.spinWidgetData.upEnabled = sw->isUpEnabled();
+ ceData.spinWidgetData.downEnabled = sw->isDownEnabled();
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QListView")) {
+ const QListView *lv = dynamic_cast<const QListView*>(widget);
+ if (lv) {
+ ceData.listViewData.rootDecorated = lv->rootIsDecorated();
+ ceData.listViewData.itemMargin = lv->itemMargin();
+ QWidget* viewport = lv->viewport();
+ if (viewport) {
+ ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport);
+ ceData.viewportData.allDataPopulated = populateReliantFields;
+ const QPixmap* erasePixmap = viewport->backgroundPixmap();
+ if (erasePixmap) {
+ ceData.viewportData.bgPixmap = *erasePixmap;
+ }
+ if (populateReliantFields) {
+ ceData.viewportData.bgBrush = viewport->backgroundBrush();
+ }
+ ceData.viewportData.wflags = viewport->getWFlags();
+ ceData.viewportData.bgColor = viewport->eraseColor();
+ ceData.viewportData.bgOffset = viewport->backgroundOffset();
+ ceData.viewportData.backgroundMode = viewport->backgroundMode();
+ if (populateReliantFields) {
+ ceData.viewportData.fgColor = viewport->foregroundColor();
+ ceData.viewportData.colorGroup = viewport->colorGroup();
+ }
+ ceData.viewportData.geometry = viewport->geometry();
+ ceData.viewportData.rect = viewport->rect();
+ ceData.viewportData.pos = viewport->pos();
+ const QPixmap* icon = viewport->icon();
+ if (icon) {
+ ceData.viewportData.icon = *icon;
+ }
+ ceData.viewportData.palette = viewport->palette();
+ ceData.viewportData.font = viewport->font();
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QComboBox")) {
+ const QComboBox *cb = dynamic_cast<const QComboBox*>(widget);
+ if (cb) {
+ const QLineEdit* lineEdit = cb->lineEdit();
+ if (lineEdit) {
+ ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, QStyleOption::Default);
+ }
+ }
+ }
+ if (ceData.widgetObjectTypes.contains("QFrame")) {
+ const QFrame *frame = dynamic_cast<const QFrame*>(widget);
+ if (frame) {
+ ceData.frameStyle = frame->frameStyle();
+ }
+ }
+
+ const QWidget* parentWidget = widget->parentWidget();
+ if (parentWidget) {
+ ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget);
+ ceData.parentWidgetData.allDataPopulated = populateReliantFields;
+ const QPixmap* erasePixmap = parentWidget->backgroundPixmap();
+ if (erasePixmap) {
+ ceData.parentWidgetData.bgPixmap = *erasePixmap;
+ }
+ if (populateReliantFields) {
+ ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush();
+ }
+ ceData.parentWidgetData.wflags = parentWidget->getWFlags();
+ ceData.parentWidgetData.bgColor = parentWidget->eraseColor();
+ ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset();
+ ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode();
+ if (populateReliantFields) {
+ ceData.parentWidgetData.fgColor = parentWidget->foregroundColor();
+ ceData.parentWidgetData.colorGroup = parentWidget->colorGroup();
+ }
+ ceData.parentWidgetData.geometry = parentWidget->geometry();
+ ceData.parentWidgetData.rect = parentWidget->rect();
+ ceData.parentWidgetData.pos = parentWidget->pos();
+ const QPixmap* icon = parentWidget->icon();
+ if (icon) {
+ ceData.parentWidgetData.icon = *icon;
+ }
+ ceData.parentWidgetData.palette = parentWidget->palette();
+ ceData.parentWidgetData.font = parentWidget->font();
+
+ const QDockWindow * dw = dynamic_cast<const QDockWindow*>(parentWidget);
+ if (dw) {
+ if (dw->area()) {
+ ceData.dwData.hasDockArea = true;
+ ceData.dwData.areaOrientation = dw->area()->orientation();
+ }
+ else {
+ ceData.dwData.hasDockArea = false;
+ }
+ ceData.dwData.closeEnabled = dw->isCloseEnabled();
+ }
+ }
+ }
+
+ return ceData;
+}
+
/*! \reimp */
void QCommonStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,
@@ -143,6 +544,32 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
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);
+ }
+ }
+
+ QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
+ drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt);
+}
+
+/*! \reimp */
+void QCommonStyle::drawPrimitive( PrimitiveElement pe,
+ QPainter *p,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
+ const QRect &r,
+ const QColorGroup &cg,
+ SFlags flags,
+ const QStyleOption& opt ) const
+{
activePainter = p;
switch (pe) {
@@ -152,7 +579,6 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
break; }
case PE_CheckListExclusiveIndicator: {
QCheckListItem *item = opt.checkListItem();
- QListView *lv = item->listView();
if(!item)
return;
int x = r.x(), y = r.y();
@@ -174,7 +600,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
if ( flags & Style_Enabled )
p->setPen( cg.text() );
else
- p->setPen( QPen( lv->palette().color( QPalette::Disabled, QColorGroup::Text ) ) );
+ p->setPen( QPen( ceData.palette.color( QPalette::Disabled, QColorGroup::Text ) ) );
QPointArray a( QCOORDARRLEN(pts1), pts1 );
a.translate( x, y );
//p->setPen( cg.dark() );
@@ -205,21 +631,20 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
break; }
case PE_CheckListIndicator: {
QCheckListItem *item = opt.checkListItem();
- QListView *lv = item->listView();
if(!item)
return;
- int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = lv->itemMargin();
+ int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = ceData.listViewData.itemMargin;
if ( flags & Style_Enabled )
p->setPen( QPen( cg.text(), 2 ) );
else
- p->setPen( QPen( lv->palette().color( QPalette::Disabled, QColorGroup::Text ),
+ 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 && !lv->rootIsDecorated() && !parentControl ) {
+ if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !parentControl ) {
p->fillRect( 0, 0, x + marg + w + 4, item->height(),
cg.brush( QColorGroup::Highlight ) );
if ( item->isEnabled() )
@@ -322,7 +747,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
case PE_SpinWidgetPlus:
case PE_SpinWidgetMinus: {
p->save();
- int fw = pixelMetric( PM_DefaultFrameWidth, 0 );
+ int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, 0 );
QRect br;
br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
r.height() - fw*2 );
@@ -353,7 +778,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
case PE_SpinWidgetUp:
case PE_SpinWidgetDown: {
- int fw = pixelMetric( PM_DefaultFrameWidth, 0 );
+ int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, 0 );
QRect br;
br.setRect( r.x() + fw, r.y() + fw, r.width() - fw*2,
r.height() - fw*2 );
@@ -378,8 +803,8 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
int bsx = 0;
int bsy = 0;
if ( flags & Style_Sunken ) {
- bsx = pixelMetric(PM_ButtonShiftHorizontal);
- bsy = pixelMetric(PM_ButtonShiftVertical);
+ bsx = pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags);
+ bsy = pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags);
}
p->save();
p->translate( sx + bsx, sy + bsy );
@@ -464,21 +889,21 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
case PE_Panel:
case PE_PanelPopup: {
- int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
+ int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, (flags & Style_Sunken), lw);
break; }
case PE_PanelDockWindow: {
- int lw = opt.isDefault() ? pixelMetric(PM_DockWindowFrameWidth)
+ int lw = opt.isDefault() ? pixelMetric(PM_DockWindowFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, FALSE, lw);
break; }
case PE_PanelMenuBar: {
- int lw = opt.isDefault() ? pixelMetric(PM_MenuBarFrameWidth)
+ int lw = opt.isDefault() ? pixelMetric(PM_MenuBarFrameWidth, ceData, elementFlags)
: opt.lineWidth();
qDrawShadePanel(p, r, cg, FALSE, lw, &cg.brush(QColorGroup::Button));
@@ -565,7 +990,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
break; }
case PE_PanelGroupBox: //We really do not need PE_GroupBoxFrame anymore, nasty holdover ###
- drawPrimitive( PE_GroupBoxFrame, p, r, cg, flags, opt );
+ drawPrimitive( PE_GroupBoxFrame, p, ceData, elementFlags, r, cg, flags, opt );
break;
case PE_GroupBoxFrame: {
#ifndef QT_NO_FRAME
@@ -587,11 +1012,11 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
case PE_PanelLineEdit:
case PE_PanelTabWidget:
case PE_WindowFrame:
- drawPrimitive( PE_Panel, p, r, cg, flags, opt );
+ drawPrimitive( PE_Panel, p, ceData, elementFlags, r, cg, flags, opt );
break;
case PE_RubberBand:
- drawPrimitive(PE_FocusRect, p, r, cg, flags, opt);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, opt);
break;
default:
break;
@@ -600,6 +1025,25 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
activePainter = 0;
}
+void qt_style_erase_region(QPainter* p, const QRegion& region, QStyleControlElementData ceData) {
+ QRegion reg = region;
+
+ QPoint offset = ceData.bgOffset;
+ int ox = offset.x();
+ int oy = offset.y();
+
+ QRegion origcr = p->clipRegion();
+ p->setClipRegion(region);
+ if (!ceData.bgPixmap.isNull()) {
+ p->drawTiledPixmap(0, 0, ceData.geometry.width(), ceData.geometry.height(), ceData.bgPixmap, ox, oy);
+ }
+ else {
+ p->fillRect(ceData.rect, ceData.bgColor);
+ }
+ p->setClipRegion(origcr);
+ return;
+}
+
/*! \reimp */
void QCommonStyle::drawControl( ControlElement element,
QPainter *p,
@@ -610,12 +1054,27 @@ void QCommonStyle::drawControl( ControlElement element,
const QStyleOption& opt ) const
{
#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::drawControl: widget parameter cannot be zero!");
- return;
- }
+ 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,
+ const QColorGroup &cg,
+ SFlags flags,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
activePainter = p;
switch (element) {
@@ -625,18 +1084,18 @@ void QCommonStyle::drawControl( ControlElement element,
reg = p->clipRegion();
else
reg = r;
- ((QWidget *)widget)->erase( reg );
+ qt_style_erase_region(p, reg, ceData);
break; }
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())
- drawPrimitive(PE_ButtonDefault, p, br, cg, flags);
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
+ if (elementFlags & CEF_IsDefault) {
+ drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, br, cg, flags);
+ }
br.setCoords(br.left() + dbi,
br.top() + dbi,
@@ -645,9 +1104,9 @@ void QCommonStyle::drawControl( ControlElement element,
}
p->save();
- p->setBrushOrigin( -widget->backgroundOffset().x(),
- -widget->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;
@@ -656,43 +1115,42 @@ void QCommonStyle::drawControl( ControlElement element,
case CE_PushButtonLabel:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
QRect ir = r;
- if (button->isDown() || button->isOn()) {
+ if ((elementFlags & CEF_IsDown) || (elementFlags & CEF_IsOn)) {
flags |= Style_Sunken;
- ir.moveBy(pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget));
+ ir.moveBy(pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget));
}
- if (button->isMenuButton()) {
- int mbi = pixelMetric(PM_MenuButtonIndicator, widget);
+ if (elementFlags & CEF_IsMenuWidget) {
+ int mbi = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget);
QRect ar(ir.right() - mbi, ir.y() + 2, mbi - 4, ir.height() - 4);
- drawPrimitive(PE_ArrowDown, p, ar, cg, flags, opt);
+ drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, ar, cg, flags, opt);
ir.setWidth(ir.width() - mbi);
}
int tf=AlignVCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
tf |= NoAccel;
#ifndef QT_NO_ICONSET
- if ( button->iconSet() && ! button->iconSet()->isNull() ) {
+ if ( !ceData.iconSet.isNull() ) {
QIconSet::Mode mode =
- button->isEnabled() ? QIconSet::Normal : QIconSet::Disabled;
- if ( mode == QIconSet::Normal && button->hasFocus() )
+ (elementFlags & CEF_IsEnabled) ? QIconSet::Normal : QIconSet::Disabled;
+ if ( mode == QIconSet::Normal && (elementFlags & CEF_HasFocus) )
mode = QIconSet::Active;
QIconSet::State state = QIconSet::Off;
- if ( button->isToggleButton() && button->isOn() )
+ if ( (elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn) )
state = QIconSet::On;
- QPixmap pixmap = button->iconSet()->pixmap( QIconSet::Small, mode, state );
+ QPixmap pixmap = ceData.iconSet.pixmap( QIconSet::Small, mode, state );
int pixw = pixmap.width();
int pixh = pixmap.height();
//Center the icon if there is neither text nor pixmap
- if ( button->text().isEmpty() && !button->pixmap() )
+ if ( ceData.text.isEmpty() && ceData.fgPixmap.isNull() )
p->drawPixmap( ir.x() + ir.width() / 2 - pixw / 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
else
p->drawPixmap( ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2, pixmap );
@@ -700,66 +1158,62 @@ void QCommonStyle::drawControl( ControlElement element,
ir.moveBy(pixw + 4, 0);
ir.setWidth(ir.width() - (pixw + 4));
// left-align text if there is
- if (!button->text().isEmpty())
+ if (!ceData.text.isEmpty())
tf |= AlignLeft;
- else if (button->pixmap())
+ else if (!ceData.fgPixmap.isNull())
tf |= AlignHCenter;
} else
#endif //QT_NO_ICONSET
tf |= AlignHCenter;
drawItem(p, ir, tf, cg,
- flags & Style_Enabled, button->pixmap(), button->text(),
- button->text().length(), &(cg.buttonText()) );
+ flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text,
+ ceData.text.length(), &(cg.buttonText()) );
if (flags & Style_HasFocus)
- drawPrimitive(PE_FocusRect, p, subRect(SR_PushButtonFocusRect, widget),
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, subRect(SR_PushButtonFocusRect, ceData, elementFlags, widget),
cg, flags);
#endif
break;
}
case CE_CheckBox:
- drawPrimitive(PE_Indicator, p, r, cg, flags, opt);
+ drawPrimitive(PE_Indicator, p, ceData, elementFlags, r, cg, flags, opt);
break;
case CE_CheckBoxLabel:
{
#ifndef QT_NO_CHECKBOX
- const QCheckBox *checkbox = (const QCheckBox *) widget;
-
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
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 (flags & Style_HasFocus) {
- QRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget);
- drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ QRect fr = visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
}
case CE_RadioButton:
- drawPrimitive(PE_ExclusiveIndicator, p, r, cg, flags, opt);
+ drawPrimitive(PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags, opt);
break;
case CE_RadioButtonLabel:
{
#ifndef QT_NO_RADIOBUTTON
- const QRadioButton *radiobutton = (const QRadioButton *) widget;
-
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
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 (flags & Style_HasFocus) {
- QRect fr = visualRect(subRect(SR_RadioButtonFocusRect, widget), widget);
- drawPrimitive(PE_FocusRect, p, fr, cg, flags);
+ QRect fr = visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags);
}
#endif
break;
@@ -768,10 +1222,8 @@ void QCommonStyle::drawControl( ControlElement element,
#ifndef QT_NO_TABBAR
case CE_TabBarTab:
{
- const QTabBar * tb = (const QTabBar *) widget;
-
- if ( tb->shape() == QTabBar::TriangularAbove ||
- tb->shape() == QTabBar::TriangularBelow ) {
+ if ( ceData.tabBarData.shape == QTabBar::TriangularAbove ||
+ ceData.tabBarData.shape == QTabBar::TriangularBelow ) {
// triangular, above or below
int y;
int x;
@@ -790,7 +1242,7 @@ void QCommonStyle::drawControl( ControlElement element,
for ( i = 0; i < 5; i++ )
a.setPoint( 9-i, right - a.point( i ).x(), a.point( i ).y() );
- if ( tb->shape() == QTabBar::TriangularAbove )
+ if ( ceData.tabBarData.shape == QTabBar::TriangularAbove )
for ( i = 0; i < 10; i++ )
a.setPoint( i, a.point(i).x(),
r.height() - 1 - a.point( i ).y() );
@@ -813,22 +1265,21 @@ void QCommonStyle::drawControl( ControlElement element,
if ( opt.isDefault() )
break;
- const QTabBar * tb = (const QTabBar *) widget;
QTab * t = opt.tab();
QRect tr = r;
- if ( t->identifier() == tb->currentTab() )
+ if (elementFlags & CEF_IsActive)
tr.setBottom( tr.bottom() -
- pixelMetric( QStyle::PM_DefaultFrameWidth, tb ) );
+ pixelMetric( QStyle::PM_DefaultFrameWidth, ceData, elementFlags, widget ) );
int alignment = AlignCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, tr, alignment, cg,
flags & Style_Enabled, 0, t->text() );
if ( (flags & Style_HasFocus) && !t->text().isEmpty() )
- drawPrimitive( PE_FocusRect, p, r, cg );
+ drawPrimitive( PE_FocusRect, p, ceData, elementFlags, r, cg );
break;
}
#endif // QT_NO_TABBAR
@@ -845,10 +1296,8 @@ void QCommonStyle::drawControl( ControlElement element,
a.setPoint( 5, r.width() - 1, r.height() + 1 );
a.setPoint( 6, -1, r.height() + 1 );
- const QToolBox *tb = (const QToolBox*)widget;
-
- if ( flags & Style_Selected && tb->currentItem() )
- p->setBrush( tb->currentItem()->paletteBackgroundColor() );
+ if ( flags & Style_Selected && !(elementFlags & CEF_IsContainerEmpty) )
+ p->setBrush( ceData.activeItemPaletteBgColor );
else
p->setBrush( cg.brush(QColorGroup::Background) );
@@ -869,32 +1318,31 @@ void QCommonStyle::drawControl( ControlElement element,
#ifndef QT_NO_PROGRESSBAR
case CE_ProgressBarContents:
{
- const QProgressBar *progressbar = (const QProgressBar *) widget;
// Correct the highlight color if same as background,
// or else we cannot see the progress...
QColorGroup cgh = cg;
if ( cgh.highlight() == cgh.background() )
- cgh.setColor( QColorGroup::Highlight, progressbar->palette().active().highlight() );
+ cgh.setColor( QColorGroup::Highlight, ceData.palette.active().highlight() );
bool reverse = QApplication::reverseLayout();
int fw = 2;
int w = r.width() - 2*fw;
- if ( !progressbar->totalSteps() ) {
+ if ( !ceData.totalSteps ) {
// draw busy indicator
- int x = progressbar->progress() % (w * 2);
+ int x = ceData.currentStep % (w * 2);
if (x > w)
x = 2 * w - x;
x = reverse ? r.right() - x : x + r.x();
p->setPen( QPen(cgh.highlight(), 4) );
p->drawLine(x, r.y() + 1, x, r.height() - fw);
} else {
- const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, widget);
+ const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, ceData, elementFlags, widget);
int u;
if ( unit_width > 1 )
u = (r.width()+unit_width/3) / unit_width;
else
u = w / unit_width;
- int p_v = progressbar->progress();
- int t_s = progressbar->totalSteps() ? progressbar->totalSteps() : 1;
+ int p_v = ceData.currentStep;
+ int t_s = ceData.totalSteps ? ceData.totalSteps : 1;
if ( u > 0 && p_v >= INT_MAX / u && t_s >= u ) {
// scale down to something usable.
@@ -917,7 +1365,7 @@ void QCommonStyle::drawControl( ControlElement element,
int x0 = reverse ? r.right() - ((unit_width > 1) ?
unit_width : fw) : r.x() + fw;
for (int i=0; i<nu; i++) {
- drawPrimitive( PE_ProgressBarChunk, p,
+ drawPrimitive( PE_ProgressBarChunk, p, ceData, elementFlags,
QRect( x0+x, r.y(), unit_width, r.height() ),
cgh, Style_Default, opt );
x += reverse ? -unit_width: unit_width;
@@ -928,7 +1376,7 @@ void QCommonStyle::drawControl( ControlElement element,
if (nu < tnu) {
int pixels_left = w - (nu*unit_width);
int offset = reverse ? x0+x+unit_width-pixels_left : x0+x;
- drawPrimitive( PE_ProgressBarChunk, p,
+ drawPrimitive( PE_ProgressBarChunk, p, ceData, elementFlags,
QRect( offset, r.y(), pixels_left,
r.height() ), cgh, Style_Default,
opt );
@@ -939,14 +1387,13 @@ void QCommonStyle::drawControl( ControlElement element,
case CE_ProgressBarLabel:
{
- const QProgressBar *progressbar = (const QProgressBar *) widget;
QColor penColor = cg.highlightedText();
QColor *pcolor = 0;
- if ( progressbar->centerIndicator() && !progressbar->indicatorFollowsStyle() &&
- progressbar->progress()*2 >= progressbar->totalSteps() )
+ if ( (elementFlags & CEF_CenterIndicator) && !(elementFlags & CEF_IndicatorFollowsStyle) &&
+ ceData.currentStep*2 >= ceData.totalSteps )
pcolor = &penColor;
drawItem(p, r, AlignCenter | SingleLine, cg, flags & Style_Enabled, 0,
- progressbar->progressString(), -1, pcolor );
+ ceData.progressText, -1, pcolor );
}
break;
#endif // QT_NO_PROGRESSBAR
@@ -959,7 +1406,7 @@ void QCommonStyle::drawControl( ControlElement element,
QMenuItem *mi = opt.menuItem();
int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, r, alignment, cg,
flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
@@ -971,7 +1418,6 @@ void QCommonStyle::drawControl( ControlElement element,
#ifndef QT_NO_TOOLBUTTON
case CE_ToolButtonLabel:
{
- const QToolButton *toolbutton = (const QToolButton *) widget;
QRect rect = r;
Qt::ArrowType arrowType = opt.isDefault()
? Qt::DownArrow : opt.arrowType();
@@ -979,8 +1425,8 @@ void QCommonStyle::drawControl( ControlElement element,
int shiftX = 0;
int shiftY = 0;
if (flags & (Style_Down | Style_On)) {
- shiftX = pixelMetric(PM_ButtonShiftHorizontal, widget);
- shiftY = pixelMetric(PM_ButtonShiftVertical, widget);
+ shiftX = pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget);
+ shiftY = pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget);
}
if (!opt.isDefault()) {
@@ -994,45 +1440,45 @@ void QCommonStyle::drawControl( ControlElement element,
}
rect.moveBy(shiftX, shiftY);
- drawPrimitive(pe, p, rect, cg, flags, opt);
+ drawPrimitive(pe, p, ceData, elementFlags, rect, cg, flags, opt);
} else {
- QColor btext = toolbutton->paletteForegroundColor();
+ QColor btext = ceData.fgColor;
- if (toolbutton->iconSet().isNull() &&
- ! toolbutton->text().isNull() &&
- ! toolbutton->usesTextLabel()) {
+ if (ceData.iconSet.isNull() &&
+ ! ceData.text.isNull() &&
+ ! (elementFlags & CEF_UsesTextLabel)) {
int alignment = AlignCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
rect.moveBy(shiftX, shiftY);
drawItem(p, rect, alignment, cg,
- flags & Style_Enabled, 0, toolbutton->text(),
- toolbutton->text().length(), &btext);
+ flags & Style_Enabled, 0, ceData.text,
+ ceData.text.length(), &btext);
} else {
QPixmap pm;
QIconSet::Size size =
- toolbutton->usesBigPixmap() ? QIconSet::Large : QIconSet::Small;
+ (elementFlags & CEF_UsesBigPixmap) ? QIconSet::Large : QIconSet::Small;
QIconSet::State state =
- toolbutton->isOn() ? QIconSet::On : QIconSet::Off;
+ (elementFlags & CEF_IsOn) ? QIconSet::On : QIconSet::Off;
QIconSet::Mode mode;
- if (! toolbutton->isEnabled())
+ if (! (elementFlags & CEF_IsEnabled))
mode = QIconSet::Disabled;
else if (flags & (Style_Down | Style_On) ||
((flags & Style_Raised) && (flags & Style_AutoRaise)))
mode = QIconSet::Active;
else
mode = QIconSet::Normal;
- pm = toolbutton->iconSet().pixmap( size, mode, state );
+ pm = ceData.iconSet.pixmap( size, mode, state );
- if ( toolbutton->usesTextLabel() ) {
- p->setFont( toolbutton->font() );
+ if (elementFlags & CEF_UsesTextLabel) {
+ p->setFont( ceData.font );
QRect pr = rect, tr = rect;
int alignment = ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
- if ( toolbutton->textPosition() == QToolButton::Under ) {
+ if ( ceData.toolButtonTextPosition == QToolButton::Under ) {
int fh = p->fontMetrics().height();
pr.addCoords( 0, 1, 0, -fh-3 );
tr.addCoords( 0, pr.bottom(), 0, -3 );
@@ -1050,8 +1496,8 @@ void QCommonStyle::drawControl( ControlElement element,
tr.moveBy(shiftX, shiftY);
drawItem( p, tr, alignment, cg,
- flags & Style_Enabled, 0, toolbutton->textLabel(),
- toolbutton->textLabel().length(), &btext);
+ flags & Style_Enabled, 0, ceData.textLabel,
+ ceData.textLabel.length(), &btext);
} else {
rect.moveBy(shiftX, shiftY);
drawItem( p, rect, AlignCenter, cg, TRUE, &pm, QString::null );
@@ -1066,10 +1512,8 @@ void QCommonStyle::drawControl( ControlElement element,
case CE_HeaderLabel:
{
QRect rect = r;
- const QHeader* header = (const QHeader *) widget;
- int section = opt.headerSection();
- QIconSet* icon = header->iconSet( section );
+ QIconSet* icon = &ceData.iconSet;
if ( icon ) {
QPixmap pixmap = icon->pixmap( QIconSet::Small,
flags & Style_Enabled ?
@@ -1090,7 +1534,7 @@ void QCommonStyle::drawControl( ControlElement element,
if (rect.isValid())
drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled,
- 0, header->label( section ), -1, &(cg.buttonText()) );
+ 0, ceData.textLabel, -1, &(cg.buttonText()) );
}
#endif // QT_NO_HEADER
default:
@@ -1100,13 +1544,27 @@ void QCommonStyle::drawControl( ControlElement element,
activePainter = 0;
}
-/*! \reimp */
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,
+ QStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
+ const QRect &r,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
+ Q_UNUSED(ceData);
+ Q_UNUSED(elementFlags);
Q_UNUSED(widget);
activePainter = p;
@@ -1115,15 +1573,15 @@ void QCommonStyle::drawControlMask( ControlElement control,
switch (control) {
case CE_PushButton:
- drawPrimitive(PE_ButtonCommand, p, r, cg, Style_Default, opt);
+ drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
case CE_CheckBox:
- drawPrimitive(PE_IndicatorMask, p, r, cg, Style_Default, opt);
+ drawPrimitive(PE_IndicatorMask, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
case CE_RadioButton:
- drawPrimitive(PE_ExclusiveIndicatorMask, p, r, cg, Style_Default, opt);
+ drawPrimitive(PE_ExclusiveIndicatorMask, p, ceData, elementFlags, r, cg, Style_Default, opt);
break;
default:
@@ -1138,13 +1596,20 @@ void QCommonStyle::drawControlMask( ControlElement control,
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();
- }
+ if (! widget) {
+ qWarning("QCommonStyle::subRect: widget parameter cannot be zero!");
+ return QRect();
+ }
#endif
- QRect rect, wrect(widget->rect());
+ 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);
switch (r) {
#ifndef QT_NO_DIALOGBUTTONS
@@ -1175,22 +1640,21 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
else if(r == SR_DialogButtonAbort)
srch = QDialogButtons::Abort;
- const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, widget),
- bheight = pixelMetric(PM_DialogButtonsButtonHeight, widget),
- bspace = pixelMetric(PM_DialogButtonsSeparator, widget),
- fw = pixelMetric(PM_DefaultFrameWidth, widget);
- const QDialogButtons *dbtns = (const QDialogButtons *) widget;
+ const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, ceData, elementFlags, widget),
+ bheight = pixelMetric(PM_DialogButtonsButtonHeight, ceData, elementFlags, widget),
+ bspace = pixelMetric(PM_DialogButtonsSeparator, ceData, elementFlags, widget),
+ fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget);
int start = fw;
- if(dbtns->orientation() == Horizontal)
+ if(ceData.orientation == Horizontal)
start = wrect.right() - fw;
QDialogButtons::Button btns[] = { QDialogButtons::All, QDialogButtons::Reject, QDialogButtons::Accept, //reverse order (right to left)
QDialogButtons::Apply, QDialogButtons::Retry, QDialogButtons::Ignore, QDialogButtons::Abort,
QDialogButtons::Help };
for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
- if(dbtns->isButtonVisible(btns[i])) {
- QSize szH = dbtns->sizeHint(btns[i]);
+ if (ceData.dlgVisibleButtons & btns[i]) {
+ QSize szH = ceData.dlgVisibleSizeHints[btns[i]];
int mwidth = QMAX(bwidth, szH.width()), mheight = QMAX(bheight, szH.height());
- if(dbtns->orientation() == Horizontal) {
+ if(ceData.orientation == Horizontal) {
start -= mwidth;
if(cnt)
start -= bspace;
@@ -1200,7 +1664,7 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
}
cnt++;
if(btns[i] == srch) {
- if(dbtns->orientation() == Horizontal)
+ if(ceData.orientation == Horizontal)
return QRect(start, wrect.bottom() - fw - mheight, mwidth, mheight);
else
return QRect(fw, start, mwidth, mheight);
@@ -1208,7 +1672,7 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
}
}
if(r == SR_DialogButtonCustom) {
- if(dbtns->orientation() == Horizontal)
+ if(ceData.orientation == Horizontal)
return QRect(fw, fw, start - fw - bspace, wrect.height() - (fw*2));
else
return QRect(fw, start, wrect.width() - (fw*2), wrect.height() - start - (fw*2));
@@ -1218,12 +1682,11 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_PushButtonContents:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
int dx1, dx2;
- dx1 = pixelMetric(PM_DefaultFrameWidth, widget);
- if (button->isDefault() || button->autoDefault())
- dx1 += pixelMetric(PM_ButtonDefaultIndicator, widget);
+ dx1 = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget);
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault))
+ dx1 += pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dx2 = dx1 * 2;
rect.setRect(wrect.x() + dx1,
@@ -1237,14 +1700,13 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_PushButtonFocusRect:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
int dbw1 = 0, dbw2 = 0;
- if (button->isDefault() || button->autoDefault()) {
- dbw1 = pixelMetric(PM_ButtonDefaultIndicator, widget);
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
+ dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dbw2 = dbw1 * 2;
}
- int dfw1 = pixelMetric(PM_DefaultFrameWidth, widget) * 2,
+ int dfw1 = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2,
dfw2 = dfw1 * 2;
rect.setRect(wrect.x() + dfw1 + dbw1,
@@ -1257,16 +1719,16 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_CheckBoxIndicator:
{
- int h = pixelMetric( PM_IndicatorHeight, widget );
+ int h = pixelMetric( PM_IndicatorHeight, ceData, elementFlags, widget );
rect.setRect(0, ( wrect.height() - h ) / 2,
- pixelMetric( PM_IndicatorWidth, widget ), h );
+ pixelMetric( PM_IndicatorWidth, ceData, elementFlags, widget ), h );
break;
}
case SR_CheckBoxContents:
{
#ifndef QT_NO_CHECKBOX
- QRect ir = subRect(SR_CheckBoxIndicator, widget);
+ QRect ir = subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget);
rect.setRect(ir.right() + 6, wrect.y(),
wrect.width() - ir.width() - 6, wrect.height());
#endif
@@ -1276,23 +1738,22 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_CheckBoxFocusRect:
{
#ifndef QT_NO_CHECKBOX
- const QCheckBox *checkbox = (const QCheckBox *) widget;
- if ( !checkbox->pixmap() && checkbox->text().isEmpty() ) {
- rect = subRect( SR_CheckBoxIndicator, widget );
+ if ( ceData.fgPixmap.isNull() && ceData.text.isEmpty() ) {
+ rect = subRect( SR_CheckBoxIndicator, ceData, elementFlags, widget );
rect.addCoords( 1, 1, -1, -1 );
break;
}
- QRect cr = subRect(SR_CheckBoxContents, widget);
+ QRect cr = subRect(SR_CheckBoxContents, ceData, elementFlags, widget);
// don't create a painter if we have an active one
QPainter *p = 0;
if (! activePainter)
- p = new QPainter(checkbox);
+ p = new QPainter(widget);
rect = itemRect((activePainter ? activePainter : p),
cr, AlignLeft | AlignVCenter | ShowPrefix,
- checkbox->isEnabled(),
- checkbox->pixmap(),
- checkbox->text());
+ (elementFlags & CEF_IsEnabled),
+ (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap,
+ ceData.text);
delete p;
@@ -1304,15 +1765,15 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_RadioButtonIndicator:
{
- int h = pixelMetric( PM_ExclusiveIndicatorHeight, widget );
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight, ceData, elementFlags, widget );
rect.setRect(0, ( wrect.height() - h ) / 2,
- pixelMetric( PM_ExclusiveIndicatorWidth, widget ), h );
+ pixelMetric( PM_ExclusiveIndicatorWidth, ceData, elementFlags, widget ), h );
break;
}
case SR_RadioButtonContents:
{
- QRect ir = subRect(SR_RadioButtonIndicator, widget);
+ QRect ir = subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget);
rect.setRect(ir.right() + 6, wrect.y(),
wrect.width() - ir.width() - 6, wrect.height());
break;
@@ -1321,23 +1782,22 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_RadioButtonFocusRect:
{
#ifndef QT_NO_RADIOBUTTON
- const QRadioButton *radiobutton = (const QRadioButton *) widget;
- if ( !radiobutton->pixmap() && radiobutton->text().isEmpty() ) {
- rect = subRect( SR_RadioButtonIndicator, widget );
+ if ( ceData.fgPixmap.isNull() && ceData.text.isEmpty() ) {
+ rect = subRect( SR_RadioButtonIndicator, ceData, elementFlags, widget );
rect.addCoords( 1, 1, -1, -1 );
break;
}
- QRect cr = subRect(SR_RadioButtonContents, widget);
+ QRect cr = subRect(SR_RadioButtonContents, ceData, elementFlags, widget);
// don't create a painter if we have an active one
QPainter *p = 0;
if (! activePainter)
- p = new QPainter(radiobutton);
+ p = new QPainter(widget);
rect = itemRect((activePainter ? activePainter : p),
cr, AlignLeft | AlignVCenter | ShowPrefix,
- radiobutton->isEnabled(),
- radiobutton->pixmap(),
- radiobutton->text());
+ (elementFlags & CEF_IsEnabled),
+ (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap,
+ ceData.text);
delete p;
rect.addCoords( -3, -2, 3, 2 );
@@ -1347,21 +1807,20 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
}
case SR_ComboBoxFocusRect:
- rect.setRect(3, 3, widget->width()-6-16, widget->height()-6);
+ rect.setRect(3, 3, ceData.rect.width()-6-16, ceData.rect.height()-6);
break;
#ifndef QT_NO_SLIDER
case SR_SliderFocusRect:
{
- const QSlider * sl = (const QSlider *) widget;
- int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
- int thickness = pixelMetric( PM_SliderControlThickness, sl );
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
- if ( sl->orientation() == Horizontal )
- rect.setRect( 0, tickOffset-1, sl->width(), thickness+2 );
+ if ( ceData.orientation == Horizontal )
+ rect.setRect( 0, tickOffset-1, ceData.rect.width(), thickness+2 );
else
- rect.setRect( tickOffset-1, 0, thickness+2, sl->height() );
- rect = rect.intersect( sl->rect() ); // ## is this really necessary?
+ rect.setRect( tickOffset-1, 0, thickness+2, ceData.rect.height() );
+ rect = rect.intersect( ceData.rect ); // ## is this really necessary?
break;
}
#endif // QT_NO_SLIDER
@@ -1369,18 +1828,16 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
#ifndef QT_NO_MAINWINDOW
case SR_DockWindowHandleRect:
{
- if (! widget->parentWidget())
+ if (!(elementFlags & CEF_HasParentWidget))
break;
- const QDockWindow * dw = (const QDockWindow *) widget->parentWidget();
-
- if ( !dw->area() || !dw->isCloseEnabled() )
- rect.setRect( 0, 0, widget->width(), widget->height() );
+ if ( !ceData.dwData.hasDockArea || !ceData.dwData.closeEnabled )
+ rect.setRect( 0, 0, ceData.rect.width(), ceData.rect.height() );
else {
- if ( dw->area()->orientation() == Horizontal )
- rect.setRect(0, 15, widget->width(), widget->height() - 15);
+ if ( ceData.dwData.areaOrientation == Horizontal )
+ rect.setRect(0, 15, ceData.rect.width(), ceData.rect.height() - 15);
else
- rect.setRect(0, 1, widget->width() - 15, widget->height() - 1);
+ rect.setRect(0, 1, ceData.rect.width() - 15, ceData.rect.height() - 1);
}
break;
}
@@ -1390,15 +1847,14 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_ProgressBarContents:
{
#ifndef QT_NO_PROGRESSBAR
- QFontMetrics fm( ( widget ? widget->fontMetrics() :
+ QFontMetrics fm( ( (!(elementFlags & CEF_UseGenericParameters)) ? QFontMetrics(ceData.font) :
QApplication::fontMetrics() ) );
- const QProgressBar *progressbar = (const QProgressBar *) widget;
int textw = 0;
- if (progressbar->percentageVisible())
+ if (ceData.percentageVisible)
textw = fm.width("100%") + 6;
- if (progressbar->indicatorFollowsStyle() ||
- ! progressbar->centerIndicator())
+ if ((elementFlags & CEF_IndicatorFollowsStyle) ||
+ ! (elementFlags & CEF_CenterIndicator))
rect.setCoords(wrect.left(), wrect.top(),
wrect.right() - textw, wrect.bottom());
else
@@ -1410,15 +1866,14 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
case SR_ProgressBarLabel:
{
#ifndef QT_NO_PROGRESSBAR
- QFontMetrics fm( ( widget ? widget->fontMetrics() :
+ QFontMetrics fm( ( (!(elementFlags & CEF_UseGenericParameters)) ? QFontMetrics(ceData.font) :
QApplication::fontMetrics() ) );
- const QProgressBar *progressbar = (const QProgressBar *) widget;
int textw = 0;
- if (progressbar->percentageVisible())
+ if (ceData.percentageVisible)
textw = fm.width("100%") + 6;
- if (progressbar->indicatorFollowsStyle() ||
- ! progressbar->centerIndicator())
+ if ((elementFlags & CEF_IndicatorFollowsStyle) ||
+ ! (elementFlags & CEF_CenterIndicator))
rect.setCoords(wrect.right() - textw, wrect.top(),
wrect.right(), wrect.bottom());
else
@@ -1428,7 +1883,7 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
}
case SR_ToolButtonContents:
- rect = querySubControlMetrics(CC_ToolButton, widget, SC_ToolButton);
+ rect = querySubControlMetrics(CC_ToolButton, ceData, elementFlags, SC_ToolButton, QStyleOption::Default, widget);
break;
case SR_ToolBoxTabContents:
@@ -1448,17 +1903,17 @@ QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const
/*
I really need this and I don't want to expose it in QRangeControl..
*/
-static int qPositionFromValue( const QRangeControl * rc, int logical_val,
+static int qPositionFromValue( QStyleControlElementData ceData, int logical_val,
int span )
{
- if ( span <= 0 || logical_val < rc->minValue() ||
- rc->maxValue() <= rc->minValue() )
+ if ( span <= 0 || logical_val < ceData.minSteps ||
+ ceData.maxSteps <= ceData.minSteps )
return 0;
- if ( logical_val > rc->maxValue() )
+ if ( logical_val > ceData.maxSteps )
return span;
- uint range = rc->maxValue() - rc->minValue();
- uint p = logical_val - rc->minValue();
+ uint range = ceData.maxSteps - ceData.minSteps;
+ uint p = logical_val - ceData.minSteps;
if ( range > (uint)INT_MAX/4096 ) {
const int scale = 4096*2;
@@ -1490,85 +1945,101 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
const QStyleOption& opt ) const
{
#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::drawComplexControl: widget parameter cannot be zero!");
- return;
- }
+ 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,
+ const QColorGroup &cg,
+ SFlags flags,
+ SCFlags controls,
+ SCFlags active,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
activePainter = p;
switch (control) {
#ifndef QT_NO_SCROLLBAR
case CC_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);
if ((controls & SC_ScrollBarSubLine) && subline.isValid())
- drawPrimitive(PE_ScrollBarSubLine, p, subline, cg,
+ drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : 0));
if ((controls & SC_ScrollBarAddLine) && addline.isValid())
- drawPrimitive(PE_ScrollBarAddLine, p, addline, cg,
+ drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddLine) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : 0));
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 : 0));
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 : 0));
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 : 0));
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 : 0));
if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
- drawPrimitive(PE_ScrollBarSlider, p, slider, cg,
+ drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarSlider) ?
Style_Down : Style_Default) |
- ((scrollbar->orientation() == Qt::Horizontal) ?
+ ((ceData.orientation == Qt::Horizontal) ?
Style_Horizontal : 0));
// ### 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);
}
}
@@ -1579,15 +2050,13 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
#ifndef QT_NO_TOOLBUTTON
case CC_ToolButton:
{
- const QToolButton *toolbutton = (const QToolButton *) widget;
-
QColorGroup c = cg;
- if ( toolbutton->backgroundMode() != PaletteButton )
+ if ( ceData.backgroundMode != PaletteButton )
c.setBrush( QColorGroup::Button,
- toolbutton->paletteBackgroundColor() );
+ ceData.bgColor );
QRect button, menuarea;
- button = visualRect( querySubControlMetrics(control, widget, SC_ToolButton, opt), widget );
- menuarea = visualRect( querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt), widget );
+ button = visualRect( querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget), ceData, elementFlags );
+ menuarea = visualRect( querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget), ceData, elementFlags );
SFlags bflags = flags,
mflags = flags;
@@ -1599,27 +2068,26 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
if (controls & SC_ToolButton) {
if (bflags & (Style_Down | Style_On | Style_Raised)) {
- drawPrimitive(PE_ButtonTool, p, button, c, bflags, opt);
- } else if ( toolbutton->parentWidget() &&
- toolbutton->parentWidget()->backgroundPixmap() &&
- ! toolbutton->parentWidget()->backgroundPixmap()->isNull() ) {
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, c, bflags, opt);
+ } else if ( (elementFlags & CEF_HasParentWidget) &&
+ ! ceData.parentWidgetData.bgPixmap.isNull() ) {
QPixmap pixmap =
- *(toolbutton->parentWidget()->backgroundPixmap());
+ ceData.parentWidgetData.bgPixmap;
- p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
+ p->drawTiledPixmap( r, pixmap, ceData.pos );
}
}
if (controls & SC_ToolButtonMenu) {
if (mflags & (Style_Down | Style_On | Style_Raised))
- drawPrimitive(PE_ButtonDropDown, p, menuarea, c, mflags, opt);
- drawPrimitive(PE_ArrowDown, p, menuarea, c, mflags, opt);
+ drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, c, mflags, opt);
+ drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, c, mflags, opt);
}
- if (toolbutton->hasFocus() && !toolbutton->focusProxy()) {
- QRect fr = toolbutton->rect();
+ if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
+ QRect fr = ceData.rect;
fr.addCoords(3, 3, -3, -3);
- drawPrimitive(PE_FocusRect, p, fr, c);
+ drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, c);
}
break;
@@ -1629,10 +2097,9 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
#ifndef QT_NO_TITLEBAR
case CC_TitleBar:
{
- const QTitleBar *titlebar = (const QTitleBar *) widget;
if ( controls & SC_TitleBarLabel ) {
- QColorGroup cgroup = titlebar->usesActiveColor() ?
- titlebar->palette().active() : titlebar->palette().inactive();
+ QColorGroup cgroup = (ceData.titleBarData.usesActiveColor) ?
+ ceData.palette.active() : ceData.palette.inactive();
QColor left = cgroup.highlight();
QColor right = cgroup.base();
@@ -1642,27 +2109,27 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
double gS = left.green();
double bS = left.blue();
- const double rD = double(right.red() - rS) / titlebar->width();
- const double gD = double(right.green() - gS) / titlebar->width();
- const double bD = double(right.blue() - bS) / titlebar->width();
+ const double rD = double(right.red() - rS) / ceData.rect.width();
+ const double gD = double(right.green() - gS) / ceData.rect.width();
+ const double bD = double(right.blue() - bS) / ceData.rect.width();
- const int w = titlebar->width();
+ const int w = ceData.rect.width();
for ( int sx = 0; sx < w; sx++ ) {
rS+=rD;
gS+=gD;
bS+=bD;
p->setPen( QColor( (int)rS, (int)gS, (int)bS ) );
- p->drawLine( sx, 0, sx, titlebar->height() );
+ p->drawLine( sx, 0, sx, ceData.rect.height() );
}
} else {
- p->fillRect( titlebar->rect(), left );
+ p->fillRect( ceData.rect, left );
}
- QRect ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarLabel ), widget );
+ QRect ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarLabel, QStyleOption::Default, widget ), ceData, elementFlags );
p->setPen( cgroup.highlightedText() );
p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(),
- AlignAuto | AlignVCenter | SingleLine, titlebar->visibleText() );
+ AlignAuto | AlignVCenter | SingleLine, ceData.titleBarData.visibleText );
}
QRect ir;
@@ -1670,46 +2137,46 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
QPixmap pm;
if ( controls & SC_TitleBarCloseButton ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarCloseButton ), widget );
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarCloseButton, QStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarCloseButton;
if ( widget->testWFlags( WStyle_Tool )
#ifndef QT_NO_MAINWINDOW
|| ::qt_cast<QDockWindow*>(widget)
#endif
)
- pm = stylePixmap(SP_DockWindowCloseButton, widget);
+ pm = stylePixmap(SP_DockWindowCloseButton, ceData, elementFlags, QStyleOption::Default, widget);
else
- pm = stylePixmap(SP_TitleBarCloseButton, widget);
- drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ pm = stylePixmap(SP_TitleBarCloseButton, ceData, elementFlags, QStyleOption::Default, widget);
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
- p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget) );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, QString::null );
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, QString::null );
p->restore();
}
- if ( titlebar->window() ) {
+ if ( ceData.titleBarData.hasWindow ) {
if ( controls & SC_TitleBarMaxButton ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMaxButton ), widget );
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMaxButton, QStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarMaxButton;
- pm = QPixmap(stylePixmap(SP_TitleBarMaxButton, widget));
- drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ pm = QPixmap(stylePixmap(SP_TitleBarMaxButton, ceData, elementFlags, QStyleOption::Default, widget));
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
- p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget) );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, QString::null );
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, QString::null );
p->restore();
}
if ( controls & SC_TitleBarNormalButton || controls & SC_TitleBarMinButton ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarMinButton ), widget );
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMinButton, QStyleOption::Default, widget ), ceData, elementFlags );
QStyle::SubControl ctrl = (controls & SC_TitleBarNormalButton ?
SC_TitleBarNormalButton :
SC_TitleBarMinButton);
@@ -1717,53 +2184,53 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
SP_TitleBarNormalButton :
SP_TitleBarMinButton);
down = active & ctrl;
- pm = QPixmap(stylePixmap(spixmap, widget));
- drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ pm = QPixmap(stylePixmap(spixmap, ceData, elementFlags, QStyleOption::Default, widget));
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
- p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget) );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, QString::null );
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, QString::null );
p->restore();
}
if ( controls & SC_TitleBarShadeButton ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarShadeButton ), widget );
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarShadeButton, QStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarShadeButton;
- pm = QPixmap(stylePixmap(SP_TitleBarShadeButton, widget));
- drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ pm = QPixmap(stylePixmap(SP_TitleBarShadeButton, ceData, elementFlags, QStyleOption::Default, widget));
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
- p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget) );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, QString::null );
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, QString::null );
p->restore();
}
if ( controls & SC_TitleBarUnshadeButton ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarUnshadeButton ), widget );
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarUnshadeButton, QStyleOption::Default, widget ), ceData, elementFlags );
down = active & SC_TitleBarUnshadeButton;
- pm = QPixmap(stylePixmap(SP_TitleBarUnshadeButton, widget));
- drawPrimitive(PE_ButtonTool, p, ir, titlebar->colorGroup(),
+ pm = QPixmap(stylePixmap(SP_TitleBarUnshadeButton, ceData, elementFlags, QStyleOption::Default, widget));
+ drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, ceData.colorGroup,
down ? Style_Down : Style_Raised);
p->save();
if( down )
- p->translate( pixelMetric(PM_ButtonShiftHorizontal, widget),
- pixelMetric(PM_ButtonShiftVertical, widget) );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, &pm, QString::null );
+ p->translate( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget),
+ pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, &pm, QString::null );
p->restore();
}
}
#ifndef QT_NO_WIDGET_TOPEXTRA
if ( controls & SC_TitleBarSysMenu ) {
- if ( titlebar->icon() ) {
- ir = visualRect( querySubControlMetrics( CC_TitleBar, widget, SC_TitleBarSysMenu ), widget );
- drawItem( p, ir, AlignCenter, titlebar->colorGroup(), TRUE, titlebar->icon(), QString::null );
+ if ( !ceData.icon.isNull() ) {
+ ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarSysMenu, QStyleOption::Default, widget ), ceData, elementFlags );
+ drawItem( p, ir, AlignCenter, ceData.colorGroup, TRUE, (ceData.icon.isNull())?NULL:&ceData.icon, QString::null );
}
}
#endif
@@ -1773,7 +2240,6 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
case CC_SpinWidget: {
#ifndef QT_NO_SPINWIDGET
- const QSpinWidget * sw = (const QSpinWidget *) widget;
SFlags flags;
PrimitiveElement pe;
@@ -1787,15 +2253,15 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
flags |= Style_Sunken;
} else
flags |= Style_Raised;
- 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_ButtonBevel, p, re, ucg, flags);
- drawPrimitive(pe, p, re, ucg, flags);
+ QRect re = ceData.spinWidgetData.upRect;
+ QColorGroup ucg = ceData.spinWidgetData.upEnabled ? cg : ceData.palette.disabled();
+ drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, re, ucg, flags);
+ drawPrimitive(pe, p, ceData, elementFlags, re, ucg, flags);
}
if ( controls & SC_SpinWidgetDown ) {
@@ -1805,15 +2271,15 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
flags |= Style_Sunken;
} else
flags |= Style_Raised;
- 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_ButtonBevel, p, re, dcg, flags);
- drawPrimitive(pe, p, re, dcg, flags);
+ QRect re = ceData.spinWidgetData.downRect;
+ QColorGroup dcg = ceData.spinWidgetData.downEnabled ? cg : ceData.palette.disabled();
+ drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, re, dcg, flags);
+ drawPrimitive(pe, p, ceData, elementFlags, re, dcg, flags);
}
#endif
break; }
@@ -1822,19 +2288,18 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
case CC_Slider:
switch ( controls ) {
case SC_SliderTickmarks: {
- const QSlider * sl = (const QSlider *) widget;
- int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
- int ticks = sl->tickmarks();
- int thickness = pixelMetric( PM_SliderControlThickness, sl );
- int len = pixelMetric( PM_SliderLength, sl );
- int available = pixelMetric( PM_SliderSpaceAvailable, sl );
- int interval = sl->tickInterval();
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
+ int ticks = ceData.tickMarkSetting;
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
+ int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
+ int available = pixelMetric( PM_SliderSpaceAvailable, ceData, elementFlags, widget );
+ int interval = ceData.tickInterval;
if ( interval <= 0 ) {
- interval = sl->lineStep();
- if ( qPositionFromValue( sl, interval, available ) -
- qPositionFromValue( sl, 0, available ) < 3 )
- interval = sl->pageStep();
+ interval = ceData.lineStep;
+ if ( qPositionFromValue( ceData, interval, available ) -
+ qPositionFromValue( ceData, 0, available ) < 3 )
+ interval = ceData.pageStep;
}
int fudge = len / 2;
@@ -1842,12 +2307,12 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
if ( ticks & QSlider::Above ) {
p->setPen( cg.foreground() );
- int v = sl->minValue();
+ int v = ceData.minSteps;
if ( !interval )
interval = 1;
- while ( v <= sl->maxValue() + 1 ) {
- pos = qPositionFromValue( sl, v, available ) + fudge;
- if ( sl->orientation() == Horizontal )
+ while ( v <= ceData.maxSteps + 1 ) {
+ pos = qPositionFromValue( ceData, v, available ) + fudge;
+ if ( ceData.orientation == Horizontal )
p->drawLine( pos, 0, pos, tickOffset-2 );
else
p->drawLine( 0, pos, tickOffset-2, pos );
@@ -1857,12 +2322,12 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
if ( ticks & QSlider::Below ) {
p->setPen( cg.foreground() );
- int v = sl->minValue();
+ int v = ceData.minSteps;
if ( !interval )
interval = 1;
- while ( v <= sl->maxValue() + 1 ) {
- pos = qPositionFromValue( sl, v, available ) + fudge;
- if ( sl->orientation() == Horizontal )
+ while ( v <= ceData.maxSteps + 1 ) {
+ pos = qPositionFromValue( ceData, v, available ) + fudge;
+ if ( ceData.orientation == Horizontal )
p->drawLine( pos, tickOffset+thickness+1, pos,
tickOffset+thickness+1 + available-2 );
else
@@ -1881,8 +2346,7 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
#ifndef QT_NO_LISTVIEW
case CC_ListView:
if ( controls & SC_ListView ) {
- QListView *listview = (QListView*)widget;
- p->fillRect( r, listview->viewport()->backgroundBrush() );
+ p->fillRect( r, ceData.viewportData.bgBrush );
}
break;
#endif //QT_NO_LISTVIEW
@@ -1893,7 +2357,6 @@ void QCommonStyle::drawComplexControl( ComplexControl control,
activePainter = 0;
}
-
/*! \reimp */
void QCommonStyle::drawComplexControlMask( ComplexControl control,
QPainter *p,
@@ -1901,14 +2364,28 @@ void QCommonStyle::drawComplexControlMask( ComplexControl control,
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,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
Q_UNUSED(control);
+ Q_UNUSED(ceData);
+ Q_UNUSED(elementFlags);
Q_UNUSED(widget);
Q_UNUSED(opt);
p->fillRect(r, color1);
}
-
/*! \reimp */
QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
const QWidget *widget,
@@ -1916,24 +2393,36 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
const QStyleOption &opt ) const
{
#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::querySubControlMetrics: widget parameter cannot be zero!");
- return QRect();
- }
+ 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,
+ const QStyleOption &opt,
+ const QWidget *widget ) const
+{
switch ( control ) {
case CC_SpinWidget: {
- int fw = pixelMetric( PM_SpinBoxFrameWidth, widget);
+ int fw = pixelMetric( PM_SpinBoxFrameWidth, ceData, elementFlags, widget);
QSize bs;
- bs.setHeight( widget->height()/2 - fw );
+ bs.setHeight( ceData.rect.height()/2 - fw );
if ( bs.height() < 8 )
bs.setHeight( 8 );
- bs.setWidth( QMIN( bs.height() * 8 / 5, widget->width() / 4 ) ); // 1.6 -approximate golden mean
+ bs.setWidth( QMIN( bs.height() * 8 / 5, ceData.rect.width() / 4 ) ); // 1.6 -approximate golden mean
bs = bs.expandedTo( QApplication::globalStrut() );
int y = fw;
int x, lx, rx;
- x = widget->width() - y - bs.width();
+ x = ceData.rect.width() - y - bs.width();
lx = fw;
rx = x - fw;
switch ( sc ) {
@@ -1942,24 +2431,24 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
case SC_SpinWidgetDown:
return QRect(x, y + bs.height(), bs.width(), bs.height());
case SC_SpinWidgetButtonField:
- return QRect(x, y, bs.width(), widget->height() - 2*fw);
+ return QRect(x, y, bs.width(), ceData.rect.height() - 2*fw);
case SC_SpinWidgetEditField:
- return QRect(lx, fw, rx, widget->height() - 2*fw);
+ return QRect(lx, fw, rx, ceData.rect.height() - 2*fw);
case SC_SpinWidgetFrame:
- return widget->rect();
+ return ceData.rect;
default:
break;
}
break; }
case CC_ComboBox: {
- int x = 0, y = 0, wi = widget->width(), he = widget->height();
+ int x = 0, y = 0, wi = ceData.rect.width(), he = ceData.rect.height();
int xpos = x;
xpos += wi - 2 - 16;
switch ( sc ) {
case SC_ComboBoxFrame:
- return widget->rect();
+ return ceData.rect;
case SC_ComboBoxArrow:
return QRect(xpos, y+2, 16, he-4);
case SC_ComboBoxEditField:
@@ -1973,21 +2462,20 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar: {
- const QScrollBar *scrollbar = (const QScrollBar *) widget;
int sliderstart = 0;
- int sbextent = pixelMetric(PM_ScrollBarExtent, widget);
- int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ?
- scrollbar->width() : scrollbar->height()) - (sbextent * 2);
+ int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
+ int maxlen = ((ceData.orientation == Qt::Horizontal) ?
+ ceData.rect.width() : ceData.rect.height()) - (sbextent * 2);
int sliderlen;
- sliderstart = scrollbar->sliderStart();
+ sliderstart = ceData.startStep;
// calculate slider length
- if (scrollbar->maxValue() != scrollbar->minValue()) {
- uint range = scrollbar->maxValue() - scrollbar->minValue();
- sliderlen = (Q_LLONG(scrollbar->pageStep()) * maxlen) / (range + scrollbar->pageStep());
+ if (ceData.maxSteps != ceData.minSteps) {
+ uint range = ceData.maxSteps - ceData.minSteps;
+ sliderlen = (Q_LLONG(ceData.pageStep) * maxlen) / (range + ceData.pageStep);
- int slidermin = pixelMetric( PM_ScrollBarSliderMin, widget );
+ int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
if ( sliderlen < slidermin || range > INT_MAX / 2 )
sliderlen = slidermin;
if ( sliderlen > maxlen )
@@ -1997,44 +2485,44 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
switch (sc) {
case SC_ScrollBarSubLine: // top/left button
- if (scrollbar->orientation() == Qt::Horizontal) {
- int buttonWidth = QMIN(scrollbar->width()/2, sbextent);
+ if (ceData.orientation == Qt::Horizontal) {
+ int buttonWidth = QMIN(ceData.rect.width()/2, sbextent);
return QRect( 0, 0, buttonWidth, sbextent );
} else {
- int buttonHeight = QMIN(scrollbar->height()/2, sbextent);
+ int buttonHeight = QMIN(ceData.rect.height()/2, sbextent);
return QRect( 0, 0, sbextent, buttonHeight );
}
case SC_ScrollBarAddLine: // bottom/right button
- if (scrollbar->orientation() == Qt::Horizontal) {
- int buttonWidth = QMIN(scrollbar->width()/2, sbextent);
- return QRect( scrollbar->width() - buttonWidth, 0, buttonWidth, sbextent );
+ if (ceData.orientation == Qt::Horizontal) {
+ int buttonWidth = QMIN(ceData.rect.width()/2, sbextent);
+ return QRect( ceData.rect.width() - buttonWidth, 0, buttonWidth, sbextent );
} else {
- int buttonHeight = QMIN(scrollbar->height()/2, sbextent);
- return QRect( 0, scrollbar->height() - buttonHeight, sbextent, buttonHeight );
+ int buttonHeight = QMIN(ceData.rect.height()/2, sbextent);
+ return QRect( 0, ceData.rect.height() - buttonHeight, sbextent, buttonHeight );
}
case SC_ScrollBarSubPage: // between top/left button and slider
- if (scrollbar->orientation() == Qt::Horizontal)
+ if (ceData.orientation == Qt::Horizontal)
return QRect(sbextent, 0, sliderstart - sbextent, sbextent);
return QRect(0, sbextent, sbextent, sliderstart - sbextent);
case SC_ScrollBarAddPage: // between bottom/right button and slider
- if (scrollbar->orientation() == Qt::Horizontal)
+ if (ceData.orientation == Qt::Horizontal)
return QRect(sliderstart + sliderlen, 0,
maxlen - sliderstart - sliderlen + sbextent, sbextent);
return QRect(0, sliderstart + sliderlen,
sbextent, maxlen - sliderstart - sliderlen + sbextent);
case SC_ScrollBarGroove:
- if (scrollbar->orientation() == Qt::Horizontal)
- return QRect(sbextent, 0, scrollbar->width() - sbextent * 2,
- scrollbar->height());
- return QRect(0, sbextent, scrollbar->width(),
- scrollbar->height() - sbextent * 2);
+ if (ceData.orientation == Qt::Horizontal)
+ return QRect(sbextent, 0, ceData.rect.width() - sbextent * 2,
+ ceData.rect.height());
+ return QRect(0, sbextent, ceData.rect.width(),
+ ceData.rect.height() - sbextent * 2);
case SC_ScrollBarSlider:
- if (scrollbar->orientation() == Qt::Horizontal)
+ if (ceData.orientation == Qt::Horizontal)
return QRect(sliderstart, 0, sliderlen, sbextent);
return QRect(0, sliderstart, sbextent, sliderlen);
@@ -2046,24 +2534,23 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
#ifndef QT_NO_SLIDER
case CC_Slider: {
- const QSlider * sl = (const QSlider *) widget;
- int tickOffset = pixelMetric( PM_SliderTickmarkOffset, sl );
- int thickness = pixelMetric( PM_SliderControlThickness, sl );
+ int tickOffset = pixelMetric( PM_SliderTickmarkOffset, ceData, elementFlags, widget );
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
switch ( sc ) {
case SC_SliderHandle: {
int sliderPos = 0;
- int len = pixelMetric( PM_SliderLength, sl );
+ int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
- sliderPos = sl->sliderStart();
+ sliderPos = ceData.startStep;
- if ( sl->orientation() == Horizontal )
+ if ( ceData.orientation == Horizontal )
return QRect( sliderPos, tickOffset, len, thickness );
return QRect( tickOffset, sliderPos, thickness, len ); }
case SC_SliderGroove: {
- if ( sl->orientation() == Horizontal )
- return QRect( 0, tickOffset, sl->width(), thickness );
- return QRect( tickOffset, 0, thickness, sl->height() ); }
+ if ( ceData.orientation == Horizontal )
+ return QRect( 0, tickOffset, ceData.rect.width(), thickness );
+ return QRect( tickOffset, 0, thickness, ceData.rect.height() ); }
default:
break;
@@ -2073,18 +2560,17 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
#if !defined(QT_NO_TOOLBUTTON) && !defined(QT_NO_POPUPMENU)
case CC_ToolButton: {
- const QToolButton *toolbutton = (const QToolButton *) widget;
- int mbi = pixelMetric(PM_MenuButtonIndicator, widget);
+ int mbi = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget);
- QRect rect = toolbutton->rect();
+ QRect rect = ceData.rect;
switch (sc) {
case SC_ToolButton:
- if (toolbutton->popup() && ! toolbutton->popupDelay())
+ if ((elementFlags & CEF_HasPopupMenu) && ! ceData.popupDelay)
rect.addCoords(0, 0, -mbi, 0);
return rect;
case SC_ToolButtonMenu:
- if (toolbutton->popup() && ! toolbutton->popupDelay())
+ if ((elementFlags & CEF_HasPopupMenu) && ! ceData.popupDelay)
rect.addCoords(rect.width() - mbi, 0, 0, 0);
return rect;
@@ -2096,47 +2582,45 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
#ifndef QT_NO_TITLEBAR
case CC_TitleBar: {
- const QTitleBar *titlebar = (const QTitleBar *) widget;
const int controlTop = 2;
- const int controlHeight = widget->height() - controlTop * 2;
+ const int controlHeight = ceData.rect.height() - controlTop * 2;
switch (sc) {
case SC_TitleBarLabel: {
- const QTitleBar *titlebar = (QTitleBar*)widget;
- QRect ir( 0, 0, titlebar->width(), titlebar->height() );
- if ( titlebar->testWFlags( WStyle_Tool ) ) {
- if ( titlebar->testWFlags( WStyle_SysMenu ) )
+ QRect ir( 0, 0, ceData.rect.width(), ceData.rect.height() );
+ if ( ceData.wflags & WStyle_Tool ) {
+ if ( ceData.wflags & WStyle_SysMenu )
ir.addCoords( 0, 0, -controlHeight-3, 0 );
- if ( titlebar->testWFlags( WStyle_MinMax ) )
+ if ( ceData.wflags & WStyle_MinMax )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
} else {
- if ( titlebar->testWFlags( WStyle_SysMenu ) )
+ if ( ceData.wflags & WStyle_SysMenu )
ir.addCoords( controlHeight+3, 0, -controlHeight-3, 0 );
- if ( titlebar->testWFlags( WStyle_Minimize ) )
+ if ( ceData.wflags & WStyle_Minimize )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
- if ( titlebar->testWFlags( WStyle_Maximize ) )
+ if ( ceData.wflags & WStyle_Maximize )
ir.addCoords( 0, 0, -controlHeight-2, 0 );
}
return ir; }
case SC_TitleBarCloseButton:
- return QRect( titlebar->width() - ( controlHeight + controlTop ),
+ return QRect( ceData.rect.width() - ( controlHeight + controlTop ),
controlTop, controlHeight, controlHeight );
case SC_TitleBarMaxButton:
case SC_TitleBarShadeButton:
case SC_TitleBarUnshadeButton:
- return QRect( titlebar->width() - ( ( controlHeight + controlTop ) * 2 ),
+ return QRect( ceData.rect.width() - ( ( controlHeight + controlTop ) * 2 ),
controlTop, controlHeight, controlHeight );
case SC_TitleBarMinButton:
case SC_TitleBarNormalButton: {
int offset = controlHeight + controlTop;
- if ( !titlebar->testWFlags( WStyle_Maximize ) )
+ if ( !( ceData.wflags & WStyle_Maximize ) )
offset *= 2;
else
offset *= 3;
- return QRect( titlebar->width() - offset, controlTop, controlHeight, controlHeight );
+ return QRect( ceData.rect.width() - offset, controlTop, controlHeight, controlHeight );
}
case SC_TitleBarSysMenu:
@@ -2160,6 +2644,18 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
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,
+ ControlElementFlags elementFlags,
+ const QPoint &pos,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
SubControl ret = SC_None;
switch (control) {
@@ -2180,8 +2676,8 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
// we can do this because subcontrols were designed to be masks as well...
while (ret == SC_None && ctrl <= SC_ScrollBarGroove) {
- r = querySubControlMetrics(control, widget,
- (QStyle::SubControl) ctrl, opt);
+ r = querySubControlMetrics(control, ceData, elementFlags,
+ (QStyle::SubControl) ctrl, opt, widget);
if (r.isValid() && r.contains(pos))
ret = (QStyle::SubControl) ctrl;
@@ -2194,27 +2690,26 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
case CC_TitleBar:
{
#ifndef QT_NO_TITLEBAR
- const QTitleBar *titlebar = (QTitleBar*)widget;
QRect r;
uint ctrl = SC_TitleBarLabel;
// we can do this because subcontrols were designed to be masks as well...
while (ret == SC_None && ctrl <= SC_TitleBarUnshadeButton) {
- r = visualRect( querySubControlMetrics( control, widget, (QStyle::SubControl) ctrl, opt ), widget );
+ r = visualRect( querySubControlMetrics( control, ceData, elementFlags, (QStyle::SubControl) ctrl, opt, widget ), ceData, elementFlags );
if (r.isValid() && r.contains(pos))
ret = (QStyle::SubControl) ctrl;
ctrl <<= 1;
}
- if ( titlebar->window() ) {
- if (titlebar->testWFlags( WStyle_Tool )) {
+ if ( ceData.titleBarData.hasWindow ) {
+ if ( ceData.wflags & WStyle_Tool ) {
if ( ret == SC_TitleBarMinButton || ret == SC_TitleBarMaxButton ) {
- if ( titlebar->window()->isMinimized() )
+ if ( ceData.titleBarData.windowState & WindowMinimized )
ret = SC_TitleBarUnshadeButton;
else
ret = SC_TitleBarShadeButton;
}
- } else if ( ret == SC_TitleBarMinButton && titlebar->window()->isMinimized() ) {
+ } else if ( ret == SC_TitleBarMinButton && (ceData.titleBarData.windowState & WindowMinimized) ) {
ret = QStyle::SC_TitleBarNormalButton;
}
}
@@ -2233,6 +2728,13 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control,
/*! \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
+{
int ret;
switch (m) {
@@ -2250,20 +2752,17 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
ret = 16;
break;
case PM_TitleBarHeight: {
- if ( widget ) {
- if ( widget->testWFlags( WStyle_Tool ) ) {
- ret = QMAX( widget->fontMetrics().lineSpacing(), 16 );
+ if ( !(elementFlags & CEF_UseGenericParameters) ) {
+ if ( ceData.wflags & WStyle_Tool ) {
+ ret = QMAX( QFontMetrics(ceData.font).lineSpacing(), 16 );
#ifndef QT_NO_MAINWINDOW
- } else if ( ::qt_cast<QDockWindow*>(widget) ) {
- ret = QMAX( widget->fontMetrics().lineSpacing(), 13 );
+ } else if ( ceData.widgetObjectTypes.contains("QDockWindow") ) {
+ ret = QMAX( QFontMetrics(ceData.font).lineSpacing(), 13 );
#endif
} else {
- ret = QMAX( widget->fontMetrics().lineSpacing(), 18 );
+ ret = QMAX( QFontMetrics(ceData.font).lineSpacing(), 18 );
}
- } else {
- ret = 0;
}
-
break; }
case PM_ScrollBarSliderMin:
ret = 9;
@@ -2278,10 +2777,10 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
break;
case PM_MenuButtonIndicator:
- if (! widget)
+ if ( elementFlags & CEF_UseGenericParameters )
ret = 12;
else
- ret = QMAX(12, (widget->height() - 4) / 3);
+ ret = QMAX(12, (ceData.rect.height() - 4) / 3);
break;
case PM_ButtonShiftHorizontal:
@@ -2304,11 +2803,10 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
#ifndef QT_NO_SCROLLBAR
case PM_ScrollBarExtent:
- if ( !widget ) {
+ if ( elementFlags & CEF_UseGenericParameters ) {
ret = 16;
} else {
- const QScrollBar *bar = (const QScrollBar*)widget;
- int s = bar->orientation() == Qt::Horizontal ?
+ int s = ceData.orientation == Qt::Horizontal ?
QApplication::globalStrut().height()
: QApplication::globalStrut().width();
ret = QMAX( 16, s );
@@ -2326,16 +2824,15 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
case PM_SliderTickmarkOffset:
{
- if (! widget) {
+ if ( elementFlags & CEF_UseGenericParameters ) {
ret = 0;
break;
}
- const QSlider * sl = (const QSlider *) widget;
- int space = (sl->orientation() == Horizontal) ? sl->height() :
- sl->width();
- int thickness = pixelMetric( PM_SliderControlThickness, sl );
- int ticks = sl->tickmarks();
+ int space = (ceData.orientation == Horizontal) ? ceData.rect.height() :
+ ceData.rect.width();
+ int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
+ int ticks = ceData.tickMarkSetting;
if ( ticks == QSlider::Both )
ret = (space - thickness) / 2;
@@ -2348,11 +2845,10 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
case PM_SliderSpaceAvailable:
{
- const QSlider * sl = (const QSlider *) widget;
- if ( sl->orientation() == Horizontal )
- ret = sl->width() - pixelMetric( PM_SliderLength, sl );
+ if ( ceData.orientation == Horizontal )
+ ret = ceData.rect.width() - pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
else
- ret = sl->height() - pixelMetric( PM_SliderLength, sl );
+ ret = ceData.rect.height() - pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
break;
}
#endif // QT_NO_SLIDER
@@ -2402,9 +2898,8 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
#ifndef QT_NO_TABBAR
case PM_TabBarTabVSpace:
{
- const QTabBar * tb = (const QTabBar *) widget;
- if ( tb && ( tb->shape() == QTabBar::RoundedAbove ||
- tb->shape() == QTabBar::RoundedBelow ) )
+ if ( ceData.widgetObjectTypes.contains("QTabBar") && ( ceData.tabBarData.shape == QTabBar::RoundedAbove ||
+ ceData.tabBarData.shape == QTabBar::RoundedBelow ) )
ret = 10;
else
ret = 0;
@@ -2457,31 +2952,43 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
return ret;
}
-
/*! \reimp */
QSize QCommonStyle::sizeFromContents(ContentsType contents,
const QWidget *widget,
const QSize &contentsSize,
const QStyleOption& opt ) const
{
- QSize sz(contentsSize);
+ QSize sz(contentsSize);
#if defined(QT_CHECK_STATE)
- if (! widget) {
- qWarning("QCommonStyle::sizeFromContents: widget parameter cannot be zero!");
- return sz;
- }
+ 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,
+ const QStyleOption& opt,
+ const QWidget *widget ) const
+{
+ QSize sz(contentsSize);
+
switch (contents) {
#ifndef QT_NO_DIALOGBUTTONS
case CT_DialogButtons: {
- const QDialogButtons *dbtns = (const QDialogButtons *)widget;
int w = contentsSize.width(), h = contentsSize.height();
- const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, widget),
- bspace = pixelMetric(PM_DialogButtonsSeparator, widget),
- bheight = pixelMetric(PM_DialogButtonsButtonHeight, widget);
- if(dbtns->orientation() == Horizontal) {
+ const int bwidth = pixelMetric(PM_DialogButtonsButtonWidth, ceData, elementFlags, widget),
+ bspace = pixelMetric(PM_DialogButtonsSeparator, ceData, elementFlags, widget),
+ bheight = pixelMetric(PM_DialogButtonsButtonHeight, ceData, elementFlags, widget);
+ if(ceData.orientation == Horizontal) {
if(!w)
w = bwidth;
} else {
@@ -2492,10 +2999,10 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
QDialogButtons::Apply, QDialogButtons::Retry, QDialogButtons::Ignore, QDialogButtons::Abort,
QDialogButtons::Help };
for(unsigned int i = 0, cnt = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) {
- if(dbtns->isButtonVisible(btns[i])) {
- QSize szH = dbtns->sizeHint(btns[i]);
+ if (ceData.dlgVisibleButtons & btns[i]) {
+ QSize szH = ceData.dlgVisibleSizeHints[btns[i]];
int mwidth = QMAX(bwidth, szH.width()), mheight = QMAX(bheight, szH.height());
- if(dbtns->orientation() == Horizontal)
+ if(ceData.orientation == Horizontal)
h = QMAX(h, mheight);
else
w = QMAX(w, mwidth);
@@ -2503,30 +3010,29 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
if(cnt)
w += bspace;
cnt++;
- if(dbtns->orientation() == Horizontal)
+ if(ceData.orientation == Horizontal)
w += mwidth;
else
h += mheight;
}
}
- const int fw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ const int fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
sz = QSize(w + fw, h + fw);
break; }
#endif //QT_NO_DIALOGBUTTONS
case CT_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
- const QPushButton *button = (const QPushButton *) widget;
int w = contentsSize.width(),
h = contentsSize.height(),
- bm = pixelMetric(PM_ButtonMargin, widget),
- fw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ bm = pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget),
+ fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
w += bm + fw;
h += bm + fw;
- if (button->isDefault() || button->autoDefault()) {
- int dbw = pixelMetric(PM_ButtonDefaultIndicator, widget) * 2;
+ if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
+ int dbw = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget) * 2;
w += dbw;
h += dbw;
}
@@ -2539,10 +3045,9 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
case CT_CheckBox:
{
#ifndef QT_NO_CHECKBOX
- const QCheckBox *checkbox = (const QCheckBox *) widget;
- QRect irect = subRect(SR_CheckBoxIndicator, widget);
- int h = pixelMetric( PM_IndicatorHeight, widget );
- int margins = (!checkbox->pixmap() && checkbox->text().isEmpty()) ? 0 : 10;
+ QRect irect = subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget);
+ int h = pixelMetric( PM_IndicatorHeight, ceData, elementFlags, widget );
+ int margins = (ceData.fgPixmap.isNull() && ceData.text.isEmpty()) ? 0 : 10;
sz += QSize(irect.right() + margins, 4 );
sz.setHeight( QMAX( sz.height(), h ) );
#endif
@@ -2552,10 +3057,9 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
case CT_RadioButton:
{
#ifndef QT_NO_RADIOBUTTON
- const QRadioButton *radiobutton = (const QRadioButton *) widget;
- QRect irect = subRect(SR_RadioButtonIndicator, widget);
- int h = pixelMetric( PM_ExclusiveIndicatorHeight, widget );
- int margins = (!radiobutton->pixmap() && radiobutton->text().isEmpty()) ? 0 : 10;
+ QRect irect = subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget);
+ int h = pixelMetric( PM_ExclusiveIndicatorHeight, ceData, elementFlags, widget );
+ int margins = (ceData.fgPixmap.isNull() && ceData.text.isEmpty()) ? 0 : 10;
sz += QSize(irect.right() + margins, 4 );
sz.setHeight( QMAX( sz.height(), h ) );
#endif
@@ -2570,7 +3074,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
case CT_ComboBox:
{
- int dfw = pixelMetric(PM_DefaultFrameWidth, widget) * 2;
+ int dfw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2;
sz = QSize(sz.width() + dfw + 21, sz.height() + dfw );
break;
}
@@ -2581,8 +3085,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
if (opt.isDefault())
break;
- const QPopupMenu *popup = (const QPopupMenu *) widget;
- bool checkable = popup->isCheckable();
+ bool checkable = (elementFlags & CEF_IsCheckable);
QMenuItem *mi = opt.menuItem();
int maxpmw = opt.maxIconWidth();
int w = sz.width(), h = sz.height();
@@ -2600,7 +3103,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
if (mi->pixmap())
h = QMAX(h, mi->pixmap()->height() + 4);
else
- h = QMAX(h, popup->fontMetrics().height() + 8);
+ h = QMAX(h, QFontMetrics(ceData.font).height() + 8);
if (mi->iconSet() != 0)
h = QMAX(h, mi->iconSet()->pixmap(QIconSet::Small,
@@ -2639,10 +3142,18 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
return sz;
}
+/*! \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, const QWidget * w, const QStyleOption &, QStyleHintReturn *) const
+int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const
{
+ Q_UNUSED(w);
+
int ret;
switch (sh) {
@@ -2656,7 +3167,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption
break;
case SH_GroupBox_TextLabelColor:
- ret = (int) ( w ? w->paletteForegroundColor().rgb() : 0 );
+ ret = (int) ( (!(elementFlags & CEF_UseGenericParameters)) ? ceData.fgColor.rgb() : 0 );
break;
case SH_ListViewExpand_SelectMouseType:
@@ -2709,6 +3220,10 @@ int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption
ret = 1;
break;
+ case SH_HideUnderlineAcceleratorWhenAltUp:
+ ret = 0;
+ break;
+
default:
ret = 0;
break;
@@ -2718,10 +3233,16 @@ int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption
}
/*! \reimp */
-QPixmap QCommonStyle::stylePixmap(StylePixmap, const QWidget *, const QStyleOption&) const
+QPixmap QCommonStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const
{
- return QPixmap();
+ 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();
+}
#endif // QT_NO_STYLE