diff options
author | Darrell Anderson <[email protected]> | 2012-10-31 18:47:07 -0500 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-10-31 18:47:07 -0500 |
commit | 0a232e5b3c2875e68d97be690beec7da1ccc65ba (patch) | |
tree | ec5222b67db7ba6aad8fa337d0e25153d8fe5062 /src | |
parent | 95354d1b5116fa9e96534bef9a2f65c1976d4c12 (diff) | |
parent | 289363b959ac4720ee604f1dfba54c624f0098c0 (diff) | |
download | qt3-0a232e5b3c2875e68d97be690beec7da1ccc65ba.tar.gz qt3-0a232e5b3c2875e68d97be690beec7da1ccc65ba.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/qapplication.cpp | 31 | ||||
-rw-r--r-- | src/kernel/qapplication.h | 1 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 15 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/styles/qcompactstyle.cpp | 111 | ||||
-rw-r--r-- | src/styles/qcompactstyle.h | 11 | ||||
-rw-r--r-- | src/styles/qmotifplusstyle.cpp | 81 | ||||
-rw-r--r-- | src/styles/qmotifstyle.cpp | 90 | ||||
-rw-r--r-- | src/styles/qsgistyle.cpp | 98 | ||||
-rw-r--r-- | src/styles/qsgistyle.h | 2 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 118 | ||||
-rw-r--r-- | src/widgets/qmenudata.h | 14 |
12 files changed, 484 insertions, 91 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 0478cf1..51aa247 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -1847,6 +1847,37 @@ QPalette QApplication::palette(const QWidget* w) return *app_pal; } +QPalette QApplication::palette(QStringList objectTypeList) +{ +#if defined(QT_CHECK_STATE) + if ( !qApp ) + qWarning( "QApplication::palette: This function can only be " + "called after the QApplication object has been created" ); +#endif + if ( !app_pal ) { + if ( !qt_std_pal ) + qt_create_std_palette(); + app_pal = new QPalette( *qt_std_pal ); + qt_fix_tooltips(); + } + + if ( (objectTypeList.count() > 0) && app_palettes ) { + QPalette* wp = app_palettes->find( objectTypeList[objectTypeList.count()-1] ); + if ( wp ) { + return *wp; + } + QAsciiDictIterator<QPalette> it( *app_palettes ); + const char* name; + while ( (name=it.currentKey()) != 0 ) { + if ( objectTypeList.contains(name) ) { + return *it.current(); + } + ++it; + } + } + return *app_pal; +} + /*! Changes the default application palette to \a palette. If \a informWidgets is TRUE, then existing widgets are informed about the diff --git a/src/kernel/qapplication.h b/src/kernel/qapplication.h index 39f7858..c34ff45 100644 --- a/src/kernel/qapplication.h +++ b/src/kernel/qapplication.h @@ -113,6 +113,7 @@ public: static void setGlobalMouseTracking( bool enable ); #ifndef QT_NO_PALETTE static QPalette palette( const QWidget* = 0 ); + static QPalette palette( QStringList ); static void setPalette( const QPalette &, bool informWidgets=FALSE, const char* className = 0 ); #endif diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 27dbb07..341473e 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -458,6 +458,11 @@ public: PE_HeaderSectionMenu, + PE_PanelScrollBar, + PE_MenuItemIndicatorFrame, + PE_MenuItemIndicatorIconFrame, + PE_MenuItemIndicatorCheck, + // do not add any values below/greater this PE_CustomBase = 0xf000000 }; @@ -830,6 +835,13 @@ public: PM_MenuBarItemSpacing, PM_ToolBarItemSpacing, + PM_MenuIndicatorFrameHBorder, + PM_MenuIndicatorFrameVBorder, + PM_MenuIconIndicatorFrameHBorder, + PM_MenuIconIndicatorFrameVBorder, + + PM_ArrowSize, + // do not add any values below/greater than this PM_CustomBase = 0xf0000000 }; @@ -1029,6 +1041,9 @@ public: // bool - hide underlined accelerators uless Alt key is currently down SH_HideUnderlineAcceleratorWhenAltUp, + // int - width of menu check column + SH_MenuIndicatorColumnWidth, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 2614bbf..3a1a8d8 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -2870,6 +2870,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co case PM_TabBarScrollButtonWidth: ret = 16; break; + case PM_ArrowSize: + ret = 7; + break; default: ret = 0; break; diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp index 7c7e0f5..63c5be5 100644 --- a/src/styles/qcompactstyle.cpp +++ b/src/styles/qcompactstyle.cpp @@ -67,6 +67,12 @@ int QCompactStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceD case PM_MaximumDragDistance: ret = -1; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 0; + break; default: ret = QWindowsStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -189,13 +195,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont return; if ( mi->isChecked() ) { - if ( act && !dis ) { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Button ) ); - } else { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); - } + drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } else if ( !act ) { p->fillRect(x, y, checkcol , h, g.brush( QColorGroup::Button )); @@ -214,7 +214,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont int pixh = pixmap.height(); if ( act && !dis ) { if ( !mi->isChecked() ) - qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); + drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } QRect cr( x, y, checkcol, h ); QRect pmr( 0, 0, pixw, pixh ); @@ -226,18 +226,8 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont g.brush( QColorGroup::Button ); p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); } else if ( checkable ) { // just "checking"... - int mw = checkcol + motifItemFrame; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, - mw, mh), itemg, cflags, opt ); + drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, itemg, flags, opt ); } } @@ -319,4 +309,87 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont } } +/*! \reimp */ +void QCompactStyle::drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + switch (pe) { + case PE_MenuItemIndicatorFrame: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + if ( act && !dis ) { + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } else { + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + } + } + break; + case PE_MenuItemIndicatorIconFrame: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + qDrawShadePanel( p, x, y, checkcol, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + case PE_MenuItemIndicatorCheck: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int mw = checkcol + motifItemFrame; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) { + cflags |= Style_Enabled; + } + if (act) { + cflags |= Style_On; + } + + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, mw, mh), cg, cflags, opt ); + } + break; + default: + break; + } +} + +/*! \reimp */ +int QCompactStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks + + ret = maxpmw; + } + break; + default: + ret = QWindowsStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif diff --git a/src/styles/qcompactstyle.h b/src/styles/qcompactstyle.h index 2f9748b..6002055 100644 --- a/src/styles/qcompactstyle.h +++ b/src/styles/qcompactstyle.h @@ -60,9 +60,20 @@ public: int pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget = 0 ); + void drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags = Style_Default, + const QStyleOption& = QStyleOption::Default ) const; + void drawControl( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default, const QWidget *w = 0 ); + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + private: // Disabled copy constructor and operator= #if defined(Q_DISABLE_COPY) QCompactStyle( const QCompactStyle & ); diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 72e28a8..113716c 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -263,6 +263,13 @@ int QMotifPlusStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ce ret = 11; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 2; + break; + default: ret = QMotifStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -282,6 +289,9 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch (pe) { case PE_HeaderSection: @@ -638,6 +648,47 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, break; } + case PE_PanelScrollBar: + { + drawMotifPlusShade(p, r, cg, TRUE, FALSE, &cg.brush(QColorGroup::Mid)); + break; + } + + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); + + qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + break; + } + default: QMotifStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); break; @@ -795,8 +846,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(vrect, @@ -828,13 +878,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, } else if (checkable) { if (mi->isChecked()) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1147,8 +1191,12 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control, if (controls == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - drawMotifPlusShade(p, widget->rect(), cg, TRUE, FALSE, - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((maxedOut) ? Style_Default : Style_Enabled) | + ((active == SC_ScrollBarLast) ? + Style_Down : Style_Default) | + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); if ((controls & SC_ScrollBarSubLine) && subline.isValid()) drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, @@ -1559,6 +1607,17 @@ int QMotifPlusStyle::styleHint(StyleHint hint, case SH_PopupMenu_MouseTracking: ret = 1; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if (checkable) + maxpmw = QMAX(maxpmw, 15); + + ret = maxpmw; + break; + } default: ret = QMotifStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index e91e0d0..826cd16 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -211,6 +211,9 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch( pe ) { #ifndef QT_NO_LISTVIEW case PE_CheckListExclusiveIndicator: { @@ -761,6 +764,52 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, r.height() - 4, cg.brush(QColorGroup::Highlight)); break; + case PE_PanelScrollBar: + qDrawShadePanel(p, r, cg, TRUE, + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags), + &cg.brush(QColorGroup::Mid)); + break; + + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + int mw = checkcol; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, QRect(xvis, y+motifItemFrame, mw, mh), cg, cflags); + break; + } + default: QCommonStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -1050,8 +1099,7 @@ void QMotifStyle::drawControl( ControlElement element, int xvis = vrect.x(); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, @@ -1076,18 +1124,8 @@ void QMotifStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else if ( checkable ) { // just "checking"... - int mw = checkcol; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - QRect(xvis, y+motifItemFrame, mw, mh), - cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1339,9 +1377,10 @@ void QMotifStyle::drawComplexControl( ComplexControl control, if (sub == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - qDrawShadePanel(p, ceData.rect, cg, TRUE, - pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget), - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); + QCommonStyle::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget); break; @@ -1538,6 +1577,13 @@ int QMotifStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceDat ret = 13; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = motifItemFrame; + break; + default: ret = QCommonStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -2346,6 +2392,18 @@ int QMotifStyle::styleHint(StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, motifCheckMarkSpace ); + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index a66fcda..eb59d11 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -398,6 +398,14 @@ int QSGIStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, case PM_SplitterWidth: return QMAX( 10, QApplication::globalStrut().width() ); + case PM_MenuIndicatorFrameHBorder: + return (sgiItemFrame+2); + case PM_MenuIndicatorFrameVBorder: + return (sgiItemFrame+4); + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return sgiItemFrame; + default: break; } @@ -567,6 +575,9 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags ); bool hot = ( flags & Style_MouseOver ) && ( flags & Style_Enabled ); + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch ( pe ) { case PE_ButtonCommand: { @@ -878,6 +889,51 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); + er.addCoords( 0, 1, 1, 1 ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + } + break; + default: QMotifStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -990,8 +1046,7 @@ void QSGIStyle::drawControl( ControlElement element, if ( mi->isChecked() ) { if ( mi->iconSet() ) { - drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else { if ( !act ) @@ -1018,20 +1073,9 @@ void QSGIStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else { if ( checkable ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - if ( mi->isChecked() ) { - QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, - pixelMetric(PM_IndicatorWidth, ceData, elementFlags), - pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); - er.addCoords( 1, 1, -1, -1 ); - drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); - er.addCoords( 0, 1, 1, 1 ); - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } } @@ -1467,4 +1511,28 @@ QRect QSGIStyle::querySubControlMetrics( ComplexControl control, return QMotifStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); } +/*! \reimp */ +int QSGIStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) + maxpmw = QMAX( maxpmw, sgiCheckMarkSpace ); + ret = maxpmw; + } + break; + default: + ret = QMotifStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif // QT_NO_STYLE_SGI diff --git a/src/styles/qsgistyle.h b/src/styles/qsgistyle.h index 0afacd6..17bdb05 100644 --- a/src/styles/qsgistyle.h +++ b/src/styles/qsgistyle.h @@ -124,6 +124,8 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 4bdb421..f93e31a 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -225,6 +225,9 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + QRect rr( r ); switch (pe) { case PE_ButtonCommand: @@ -568,6 +571,63 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); + int xvis = vrect.x(); + + if ( act && !dis ) { + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } + else { + QBrush fill( cg.light(), Dense4Pattern ); + // set the brush origin for the hash pattern to the x/y coordinate + // of the menu item's checkmark... this way, the check marks have + // a consistent look + QPoint origin = p->brushOrigin(); + p->setBrushOrigin( xvis, y ); + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill ); + // restore the previous brush origin + p->setBrushOrigin( origin ); + } + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int xp = x + windowsItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, checkcol - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); + } + break; + default: if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) { QPointArray a; @@ -809,21 +869,7 @@ void QWindowsStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r ); int xvis = vrect.x(); if ( mi->isChecked() ) { - if ( act && !dis ) - qDrawShadePanel( p, xvis, y, checkcol, h, - cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); - else { - QBrush fill( cg.light(), Dense4Pattern ); - // set the brush origin for the hash pattern to the x/y coordinate - // of the menu item's checkmark... this way, the check marks have - // a consistent look - QPoint origin = p->brushOrigin(); - p->setBrushOrigin( xvis, y ); - qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, - &fill ); - // restore the previous brush origin - p->setBrushOrigin( origin ); - } + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); } else if (! act) p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button )); @@ -839,8 +885,7 @@ void QWindowsStyle::drawControl( ControlElement element, int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis && !mi->isChecked() ) - qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1, - &cg.brush( QColorGroup::Button ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); QRect pmr( 0, 0, pixw, pixh ); pmr.moveCenter( vrect.center() ); p->setPen( cg.text() ); @@ -851,20 +896,9 @@ void QWindowsStyle::drawControl( ControlElement element, cg.brush( QColorGroup::Button )); int xp = xpos + checkcol + 1; p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill); - } else if ( checkable ) { // just "checking"... + } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - int xp = xpos + windowsItemFrame; - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - visualRect( QRect(xp, y + windowsItemFrame, - checkcol - 2*windowsItemFrame, - h - 2*windowsItemFrame), r ), cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1042,6 +1076,13 @@ int QWindowsStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ceDa ret = QMAX( 6, QApplication::globalStrut().width() ); break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = windowsItemFrame; + break; + default: ret = QCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -1965,6 +2006,23 @@ int QWindowsStyle::styleHint( StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) { + // space for the checkmarks + if (use2000style) + maxpmw = QMAX( maxpmw, 20 ); + else + maxpmw = QMAX( maxpmw, 12 ); + } + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/widgets/qmenudata.h b/src/widgets/qmenudata.h index 13f26c3..ee6f9f9 100644 --- a/src/widgets/qmenudata.h +++ b/src/widgets/qmenudata.h @@ -90,6 +90,20 @@ public: void setVisible( bool visible ) { is_visible = visible; } void setWhatsThis( const QString &text ) { whatsthis_data = text; } + // Do not use these methods unless you know exactly what you are doing! + void setSeparator( bool separator ) { is_separator = separator; } + void setEnabled( bool enabled ) { is_enabled = enabled; } + void setChecked( bool checked ) { is_checked = checked; } + void setIdent( int identifier ) { ident = identifier; } + void setIconSet( QIconSet* iconset ) { iconset_data = iconset; } + void setPixmap( QPixmap* pixmap ) { pixmap_data = pixmap; } + void setPopup( QPopupMenu* popup ) { popup_menu = popup; } + void setWidget( QWidget* widget ) { widget_item = widget; } +#ifndef QT_NO_ACCEL + void setKey( QKeySequence key ) { accel_key = key; } +#endif + void setSignal( QSignal* signal ) { signal_data = signal; } + private: int ident; // item identifier QIconSet *iconset_data; // icons |