diff options
Diffstat (limited to 'src/kernel/qstyle.cpp')
-rw-r--r-- | src/kernel/qstyle.cpp | 192 |
1 files changed, 191 insertions, 1 deletions
diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index fc4daa2..1d085f3 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -46,6 +46,8 @@ #include "qpixmapcache.h" #include "qframe.h" #include "qlayout.h" +#include "qlistview.h" +#include "qpopupmenu.h" #include "qobjectlist.h" #include "qwidgetlist.h" @@ -592,7 +594,18 @@ void QStyle::polish( QPalette&) (\l{QPopupMenu::setMouseTracking()}) and whether the menu is checkable by default (\l{QPopupMenu::setCheckable()}). */ -void QStyle::polishPopupMenu( QPopupMenu *) +void QStyle::polishPopupMenu( QPopupMenu *pm ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(pm, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(pm, ceData.widgetObjectTypes, QStyleOption()), pm); +} + +/*! + Polishes the popup menu according to the GUI style. This usually + means setting the mouse tracking + (\l{QPopupMenu::setMouseTracking()}) and whether the menu is + checkable by default (\l{QPopupMenu::setCheckable()}). +*/ +void QStyle::polishPopupMenu( QStyleControlElementData, ControlElementFlags, void * ) { } @@ -2204,6 +2217,18 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen else if (request == WAR_DisableMouseTracking) { widget->setMouseTracking(FALSE); } + else if (request == WAR_SetCheckable) { + QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget); + if (pm) { + pm->setCheckable(TRUE); + } + } + else if (request == WAR_UnSetCheckable) { + QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget); + if (pm) { + pm->setCheckable(FALSE); + } + } else if (request == WAR_FrameSetStyle) { QFrame* frame = dynamic_cast<QFrame*>(widget); if (frame) { @@ -2265,6 +2290,10 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen } void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) { + // RAJA FIXME + // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the QWindowsStyle::styleHint overridden method + // Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { QWidget *widget = dynamic_cast<QWidget*>(o); if (widget) { @@ -2324,6 +2353,167 @@ QStyleWidgetActionRequestData::~QStyleWidgetActionRequestData() { // } +// ============================================================================================ +// Interface methods +// ============================================================================================ + +void QStyle::drawPrimitive( PrimitiveElement pe, + QPainter *p, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ + const QWidget* widget = 0; + + // Determine if the request needs widget information and set widget appropriately + // FIXME + if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { + QCheckListItem *item = opt.checkListItem(); + if (item) { + QListView *lv = item->listView(); + widget = dynamic_cast<QWidget*>(lv); + } + } + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt); +} + +void QStyle::drawControl( ControlElement element, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (!widget) { + qWarning("QStyle::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); +} + +void QStyle::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); +} + +QRect QStyle::subRect(SubRect r, const QWidget *widget) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::subRect: widget parameter cannot be zero!"); + return QRect(); + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +void QStyle::drawComplexControl( ComplexControl control, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + SCFlags controls, + SCFlags active, + const QStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::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); +} + +void QStyle::drawComplexControlMask( ComplexControl control, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QStyleOption& opt ) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, opt, widget); +} + +QRect QStyle::querySubControlMetrics( ComplexControl control, + const QWidget *widget, + SubControl sc, + const QStyleOption &opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::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); +} + +QStyle::SubControl QStyle::querySubControl(ComplexControl control, + const QWidget *widget, + const QPoint &pos, + const QStyleOption& opt ) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); +} + +int QStyle::pixelMetric(PixelMetric m, const QWidget *widget) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +QSize QStyle::sizeFromContents(ContentsType contents, + const QWidget *widget, + const QSize &contentsSize, + const QStyleOption& opt ) const +{ + QSize sz(contentsSize); + +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::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); +} + +int QStyle::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); +} + +QPixmap QStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption()); + return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, w); +} + /*! \fn int QStyle::defaultFrameWidth() const \obsolete |