Changeset 178 for trunk/src/styles/qwarp4style.cpp
- Timestamp:
- Feb 25, 2008, 11:07:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/styles/qwarp4style.cpp
r175 r178 1746 1746 at the same time an accelerator key (string after \t (tab)) and a 1747 1747 submenu arrow displayed! 1748 1748 1749 1749 btw., the Windows style solves that problem by always having some space left 1750 1750 for the arrow, and Motiv overpaints the arrow over the accelerator string, … … 1884 1884 1885 1885 /*! \reimp */ 1886 void QWarp4Style::drawPrimitive (PrimitiveElement pe,1887 QPainter*p,1888 QRect const&r,1889 QColorGroup const&cg,1890 SFlags flags,1891 QStyleOption const&opt) const1892 { 1893 QRect rr (r);1886 void QWarp4Style::drawPrimitive (PrimitiveElement pe, 1887 QPainter *p, 1888 const QRect &r, 1889 const QColorGroup &cg, 1890 SFlags flags, 1891 const QStyleOption &opt) const 1892 { 1893 QRect rr (r); 1894 1894 1895 1895 switch (pe) … … 1898 1898 case PE_ButtonTool: 1899 1899 { 1900 bool sunken = flags & (Style_Sunken | Style_Down | Style_On), 1901 def = flags & Style_ButtonDefault; 1902 qDrawWarpDefFrame(p, rr, cg, def); 1903 QBrush fill = cg.brush(QColorGroup::Button); 1904 rr.addCoords(1, 1, -1, -1); 1905 qDrawWarpFilledRect(p, rr, cg.dark(), cg.light(), &fill, 2, sunken); 1900 bool def = flags & Style_ButtonDefault; 1901 qDrawWarpDefFrame (p, rr, cg, def); 1902 rr.addCoords (1, 1, -1, -1); 1903 1904 bool sunken = flags & (Style_Sunken | Style_Down | Style_On); 1905 QBrush fill = cg.brush (QColorGroup::Button); 1906 qDrawWarpFilledRect (p, rr, cg.dark(), cg.light(), &fill, 2, sunken); 1906 1907 break; 1907 1908 } … … 2614 2615 switch (element) 2615 2616 { 2616 2617 #ifndef QT_NO_TABBAR 2617 2618 case CE_TabBarTab: 2618 2619 { … … 2721 2722 break; 2722 2723 } 2723 2724 #endif // QT_NO_TABBAR 2724 2725 2725 2726 case CE_ToolBoxTab: … … 2743 2744 } 2744 2745 2745 2746 #ifndef QT_NO_PROGRESSBAR 2746 2747 case CE_ProgressBarContents: 2747 2748 { … … 2837 2838 break; 2838 2839 } 2839 #endif 2840 2841 2840 #endif // QT_NO_PROGRESSBAR 2841 2842 #ifndef QT_NO_POPUPMENU 2842 2843 case CE_PopupMenuItem: 2843 2844 { … … 2979 2980 break; 2980 2981 } 2981 #endif 2982 #endif // QT_NO_POPUPMENU 2982 2983 2983 2984 case CE_MenuBarItem: … … 3018 3019 } 3019 3020 3020 3021 #ifndef QT_NO_TOOLBUTTON 3021 3022 case CE_ToolButtonLabel: 3022 3023 { 3023 if ((QString("qt_left_btn") == widget->name()) ||3024 (QString("qt_right_btn") == widget->name()))3024 if (!qstrcmp (widget->name(), "qt_left_btn") || 3025 !qstrcmp (widget->name(), "qt_right_btn")) 3025 3026 { 3026 3027 // do nothing in this case! … … 3028 3029 else 3029 3030 { 3030 QToolButton const * toolbutton = (QToolButton const*)widget;3031 QToolButton const *toolbutton = (QToolButton const *) widget; 3031 3032 QRect rect = r; 3032 // the following line is the only difference to the "commonstyle":3033 // it makes sure that the bitmap and/or label does not overpaint3034 // the button frame3035 rect.addCoords(3, 3, -3, -3);3036 3033 Qt::ArrowType arrowType = opt.isDefault() ? 3037 3034 Qt::DownArrow : opt.arrowType(); 3038 3035 3039 if (flags & (Style_Down | Style_On))3040 rect.moveBy (pixelMetric(PM_ButtonShiftHorizontal, widget),3041 pixelMetric(PM_ButtonShiftVertical, widget));3042 3043 if (!opt.isDefault())3036 if (flags & (Style_Down | Style_On)) 3037 rect.moveBy (pixelMetric(PM_ButtonShiftHorizontal, widget), 3038 pixelMetric(PM_ButtonShiftVertical, widget)); 3039 3040 if (!opt.isDefault()) 3044 3041 { 3045 3042 PrimitiveElement pe; … … 3061 3058 } 3062 3059 3063 drawPrimitive (pe, p, rect, cg, flags, opt);3060 drawPrimitive (pe, p, rect, cg, flags, opt); 3064 3061 } 3065 3066 3062 else 3067 3063 { 3068 3064 QColor btext = toolbutton->paletteForegroundColor(); 3069 3065 3070 if (toolbutton->iconSet().isNull() &&3071 !toolbutton->text().isNull() &&3072 !toolbutton->usesTextLabel())3066 if (toolbutton->iconSet().isNull() && 3067 !toolbutton->text().isNull() && 3068 !toolbutton->usesTextLabel()) 3073 3069 { 3074 3070 int alignment = AlignCenter | AlignVCenter | ShowPrefix; 3075 3071 3076 if (!styleHint(SH_UnderlineAccelerator, widget,3077 QStyleOption::Default, 0))3072 if (!styleHint (SH_UnderlineAccelerator, widget, 3073 QStyleOption::Default, 0)) 3078 3074 alignment |= NoAccel; 3079 3075 3080 drawItem (p, rect, alignment, cg,3081 flags & Style_Enabled, 0, toolbutton->text(),3082 toolbutton->text().length(), &btext);3076 drawItem (p, rect, alignment, cg, 3077 flags & Style_Enabled, 0, toolbutton->text(), 3078 toolbutton->text().length(), &btext); 3083 3079 } 3084 3085 3080 else 3086 3081 { … … 3094 3089 3095 3090 QIconSet::Mode mode; 3096 if (!toolbutton->isEnabled())3091 if (!toolbutton->isEnabled()) 3097 3092 mode = QIconSet::Disabled; 3098 else if (flags & (Style_Down | Style_On | Style_Raised))3093 else if (flags & (Style_Down | Style_On | Style_Raised)) 3099 3094 mode = QIconSet::Active; 3100 3095 else … … 3103 3098 pm = toolbutton->iconSet().pixmap(size, mode, state); 3104 3099 3105 if (toolbutton->usesTextLabel())3100 if (toolbutton->usesTextLabel()) 3106 3101 { 3107 if (toolbutton->textPosition() == QToolButton::Under)3102 if (toolbutton->textPosition() == QToolButton::Under) 3108 3103 { 3109 3104 p->setFont(toolbutton->font()); … … 3111 3106 QRect pr = rect, tr = rect; 3112 3107 int fh = p->fontMetrics().height(); 3113 pr.addCoords (0, 1, 0, -fh - 3);3114 tr.addCoords (0, pr.bottom(), 0, -3);3115 drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null);3108 pr.addCoords (0, 1, 0, -fh - 3); 3109 tr.addCoords (0, pr.bottom(), 0, -3); 3110 drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null); 3116 3111 int alignment = AlignCenter | ShowPrefix; 3117 3112 3118 if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))3113 if (!styleHint (SH_UnderlineAccelerator, widget, QStyleOption::Default, 0)) 3119 3114 alignment |= NoAccel; 3120 3115 3121 drawItem (p, tr, alignment, cg,3122 flags & Style_Enabled, 0, toolbutton->textLabel(),3123 toolbutton->textLabel().length(), &btext);3116 drawItem (p, tr, alignment, cg, 3117 flags & Style_Enabled, 0, toolbutton->textLabel(), 3118 toolbutton->textLabel().length(), &btext); 3124 3119 } 3125 3120 else 3126 3121 { 3127 p->setFont (toolbutton->font());3122 p->setFont (toolbutton->font()); 3128 3123 3129 3124 QRect pr = rect, tr = rect; 3130 pr.setWidth (pm.width() + 8);3131 tr.addCoords (pr.right(), 0, 0, 0);3132 drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null);3125 pr.setWidth (pm.width() + 8); 3126 tr.addCoords (pr.right(), 0, 0, 0); 3127 drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null); 3133 3128 int alignment = AlignLeft | AlignVCenter | ShowPrefix; 3134 3129 3135 if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))3130 if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0)) 3136 3131 alignment |= NoAccel; 3137 3132 3138 drawItem (p, tr, alignment, cg,3139 flags & Style_Enabled, 0, toolbutton->textLabel(),3140 toolbutton->textLabel().length(), &btext);3133 drawItem (p, tr, alignment, cg, 3134 flags & Style_Enabled, 0, toolbutton->textLabel(), 3135 toolbutton->textLabel().length(), &btext); 3141 3136 } 3142 3137 } 3143 3138 else 3144 3139 { 3145 drawItem (p, rect, AlignCenter, cg, TRUE, &pm, QString::null);3140 drawItem (p, rect, AlignCenter, cg, TRUE, &pm, QString::null); 3146 3141 } 3147 3142 } … … 3151 3146 break; 3152 3147 } 3153 #endif 3148 #endif // QT_NO_TOOLBUTTON 3154 3149 3155 3150 default: … … 3377 3372 case CT_PushButton: 3378 3373 { 3379 3374 #ifndef QT_NO_PUSHBUTTON 3380 3375 const QPushButton* button = (const QPushButton*)widget; 3381 3376 sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt); … … 3392 3387 3393 3388 sz = QSize(w, h); 3394 #endif 3389 #endif // QT_NO_PUSHBUTTON 3395 3390 3396 3391 break; … … 3399 3394 case CT_ToolButton: 3400 3395 { 3401 sz = QSize(sz.width() + 6, sz.height() + 5); 3396 // this includes 3px margin drawn for PE_ButtonTool + 1px spacing 3397 // around contents + 1px extra width/height for pressed icon shift 3398 sz = QSize (sz.width() + 9, sz.height() + 9); 3402 3399 break; 3403 3400 } … … 3405 3402 case CT_PopupMenuItem: 3406 3403 { 3407 3404 #ifndef QT_NO_POPUPMENU 3408 3405 if(! widget || opt.isDefault()) 3409 3406 break; … … 3459 3456 3460 3457 sz = QSize(w, h); 3461 #endif 3458 #endif // QT_NO_POPUPMENU 3462 3459 3463 3460 break;
Note:
See TracChangeset
for help on using the changeset viewer.