Index: trunk/src/styles/qwarp4style.cpp
===================================================================
--- trunk/src/styles/qwarp4style.cpp	(revision 177)
+++ trunk/src/styles/qwarp4style.cpp	(revision 178)
@@ -1746,5 +1746,5 @@
   at the same time an accelerator key (string after \t (tab)) and a
   submenu arrow displayed!
- 
+
   btw., the Windows style solves that problem by always having some space left
   for the arrow, and Motiv overpaints the arrow over the accelerator string,
@@ -1884,12 +1884,12 @@
 
 /*! \reimp */
-void QWarp4Style::drawPrimitive(PrimitiveElement pe,
-                                QPainter* p,
-                                QRect const& r,
-                                QColorGroup const& cg,
-                                SFlags flags,
-                                QStyleOption const& opt) const
-{
-    QRect rr(r);
+void QWarp4Style::drawPrimitive (PrimitiveElement pe,
+                                 QPainter *p,
+                                 const QRect &r,
+                                 const QColorGroup &cg,
+                                 SFlags flags,
+                                 const QStyleOption &opt) const
+{
+    QRect rr (r);
 
     switch (pe)
@@ -1898,10 +1898,11 @@
         case PE_ButtonTool:
         {
-            bool sunken = flags & (Style_Sunken | Style_Down | Style_On),
-                 def = flags & Style_ButtonDefault;
-            qDrawWarpDefFrame(p, rr, cg, def);
-            QBrush fill = cg.brush(QColorGroup::Button);
-            rr.addCoords(1, 1, -1, -1);
-            qDrawWarpFilledRect(p, rr, cg.dark(), cg.light(), &fill, 2, sunken);
+            bool def = flags & Style_ButtonDefault;
+            qDrawWarpDefFrame (p, rr, cg, def);
+            rr.addCoords (1, 1, -1, -1);
+
+            bool sunken = flags & (Style_Sunken | Style_Down | Style_On);
+            QBrush fill = cg.brush (QColorGroup::Button);
+            qDrawWarpFilledRect (p, rr, cg.dark(), cg.light(), &fill, 2, sunken);
             break;
         }
@@ -2614,5 +2615,5 @@
     switch (element)
     {
-        #ifndef QT_NO_TABBAR
+#ifndef QT_NO_TABBAR
             case CE_TabBarTab:
             {
@@ -2721,5 +2722,5 @@
                 break;
             }
-        #endif // QT_NO_TABBAR
+#endif // QT_NO_TABBAR
 
         case CE_ToolBoxTab:
@@ -2743,5 +2744,5 @@
         }
 
-        #ifndef QT_NO_PROGRESSBAR
+#ifndef QT_NO_PROGRESSBAR
             case CE_ProgressBarContents:
             {
@@ -2837,7 +2838,7 @@
                 break;
             }
-        #endif
-
-        #ifndef QT_NO_POPUPMENU
+#endif // QT_NO_PROGRESSBAR
+
+#ifndef QT_NO_POPUPMENU
             case CE_PopupMenuItem:
             {
@@ -2979,5 +2980,5 @@
                 break;
             }
-        #endif
+#endif // QT_NO_POPUPMENU
 
         case CE_MenuBarItem:
@@ -3018,9 +3019,9 @@
         }
 
-        #ifndef QT_NO_TOOLBUTTON
+#ifndef QT_NO_TOOLBUTTON
             case CE_ToolButtonLabel:
             {
-                if((QString("qt_left_btn") == widget->name()) ||
-                   (QString("qt_right_btn") == widget->name()))
+                if (!qstrcmp (widget->name(), "qt_left_btn") ||
+                    !qstrcmp (widget->name(), "qt_right_btn"))
                 {
                     // do nothing in this case!
@@ -3028,18 +3029,14 @@
                 else
                 {
-                    QToolButton const* toolbutton = (QToolButton const*)widget;
+                    QToolButton const *toolbutton = (QToolButton const *) widget;
                     QRect rect = r;
-                    // the following line is the only difference to the "commonstyle":
-                    // it makes sure that the bitmap and/or label does not overpaint
-                    // the button frame
-                    rect.addCoords(3, 3, -3, -3);
                     Qt::ArrowType arrowType = opt.isDefault() ?
                                               Qt::DownArrow : opt.arrowType();
 
-                    if(flags & (Style_Down | Style_On))
-                        rect.moveBy(pixelMetric(PM_ButtonShiftHorizontal, widget),
-                                    pixelMetric(PM_ButtonShiftVertical, widget));
-
-                    if(!opt.isDefault())
+                    if (flags & (Style_Down | Style_On))
+                        rect.moveBy (pixelMetric(PM_ButtonShiftHorizontal, widget),
+                                     pixelMetric(PM_ButtonShiftVertical, widget));
+
+                    if (!opt.isDefault())
                     {
                         PrimitiveElement pe;
@@ -3061,26 +3058,24 @@
                         }
 
-                        drawPrimitive(pe, p, rect, cg, flags, opt);
+                        drawPrimitive (pe, p, rect, cg, flags, opt);
                     }
-
                     else
                     {
                         QColor btext = toolbutton->paletteForegroundColor();
 
-                        if(toolbutton->iconSet().isNull() &&
-                           !toolbutton->text().isNull() &&
-                           !toolbutton->usesTextLabel())
+                        if (toolbutton->iconSet().isNull() &&
+                            !toolbutton->text().isNull() &&
+                            !toolbutton->usesTextLabel())
                         {
                             int alignment = AlignCenter | AlignVCenter | ShowPrefix;
 
-                            if(!styleHint(SH_UnderlineAccelerator, widget,
-                                          QStyleOption::Default, 0))
+                            if (!styleHint (SH_UnderlineAccelerator, widget,
+                                            QStyleOption::Default, 0))
                                 alignment |= NoAccel;
 
-                            drawItem(p, rect, alignment, cg,
-                                     flags & Style_Enabled, 0, toolbutton->text(),
-                                     toolbutton->text().length(), &btext);
+                            drawItem (p, rect, alignment, cg,
+                                      flags & Style_Enabled, 0, toolbutton->text(),
+                                      toolbutton->text().length(), &btext);
                         }
-
                         else
                         {
@@ -3094,7 +3089,7 @@
 
                             QIconSet::Mode mode;
-                            if(!toolbutton->isEnabled())
+                            if (!toolbutton->isEnabled())
                                 mode = QIconSet::Disabled;
-                            else if(flags & (Style_Down | Style_On | Style_Raised))
+                            else if (flags & (Style_Down | Style_On | Style_Raised))
                                 mode = QIconSet::Active;
                             else
@@ -3103,7 +3098,7 @@
                             pm = toolbutton->iconSet().pixmap(size, mode, state);
 
-                            if(toolbutton->usesTextLabel())
+                            if (toolbutton->usesTextLabel())
                             {
-                                if(toolbutton->textPosition() == QToolButton::Under)
+                                if (toolbutton->textPosition() == QToolButton::Under)
                                 {
                                     p->setFont(toolbutton->font());
@@ -3111,37 +3106,37 @@
                                     QRect pr = rect, tr = rect;
                                     int fh = p->fontMetrics().height();
-                                    pr.addCoords(0, 1, 0, -fh - 3);
-                                    tr.addCoords(0, pr.bottom(), 0, -3);
-                                    drawItem(p, pr, AlignCenter, cg, TRUE, &pm, QString::null);
+                                    pr.addCoords (0, 1, 0, -fh - 3);
+                                    tr.addCoords (0, pr.bottom(), 0, -3);
+                                    drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null);
                                     int alignment = AlignCenter | ShowPrefix;
 
-                                    if(!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+                                    if (!styleHint (SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
                                         alignment |= NoAccel;
 
-                                    drawItem(p, tr, alignment, cg,
-                                             flags & Style_Enabled, 0, toolbutton->textLabel(),
-                                             toolbutton->textLabel().length(), &btext);
+                                    drawItem (p, tr, alignment, cg,
+                                              flags & Style_Enabled, 0, toolbutton->textLabel(),
+                                              toolbutton->textLabel().length(), &btext);
                                 }
                                 else
                                 {
-                                    p->setFont(toolbutton->font());
+                                    p->setFont (toolbutton->font());
 
                                     QRect pr = rect, tr = rect;
-                                    pr.setWidth(pm.width() + 8);
-                                    tr.addCoords(pr.right(), 0, 0, 0);
-                                    drawItem(p, pr, AlignCenter, cg, TRUE, &pm, QString::null);
+                                    pr.setWidth (pm.width() + 8);
+                                    tr.addCoords (pr.right(), 0, 0, 0);
+                                    drawItem (p, pr, AlignCenter, cg, TRUE, &pm, QString::null);
                                     int alignment = AlignLeft | AlignVCenter | ShowPrefix;
 
-                                    if(!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
+                                    if (!styleHint(SH_UnderlineAccelerator, widget, QStyleOption::Default, 0))
                                         alignment |= NoAccel;
 
-                                    drawItem(p, tr, alignment, cg,
-                                             flags & Style_Enabled, 0, toolbutton->textLabel(),
-                                             toolbutton->textLabel().length(), &btext);
+                                    drawItem (p, tr, alignment, cg,
+                                              flags & Style_Enabled, 0, toolbutton->textLabel(),
+                                              toolbutton->textLabel().length(), &btext);
                                 }
                             }
                             else
                             {
-                                drawItem(p, rect, AlignCenter, cg, TRUE, &pm, QString::null);
+                                drawItem (p, rect, AlignCenter, cg, TRUE, &pm, QString::null);
                             }
                         }
@@ -3151,5 +3146,5 @@
                 break;
             }
-        #endif
+#endif // QT_NO_TOOLBUTTON
 
         default:
@@ -3377,5 +3372,5 @@
         case CT_PushButton:
         {
-            #ifndef QT_NO_PUSHBUTTON
+#ifndef QT_NO_PUSHBUTTON
                 const QPushButton* button = (const QPushButton*)widget;
                 sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
@@ -3392,5 +3387,5 @@
 
                 sz = QSize(w, h);
-            #endif
+#endif // QT_NO_PUSHBUTTON
 
             break;
@@ -3399,5 +3394,7 @@
         case CT_ToolButton:
         {
-            sz = QSize(sz.width() + 6, sz.height() + 5);
+            // this includes 3px margin drawn for PE_ButtonTool + 1px spacing
+            // around contents + 1px extra width/height for pressed icon shift
+            sz = QSize (sz.width() + 9, sz.height() + 9);
             break;
         }
@@ -3405,5 +3402,5 @@
         case CT_PopupMenuItem:
         {
-            #ifndef QT_NO_POPUPMENU
+#ifndef QT_NO_POPUPMENU
                 if(! widget || opt.isDefault())
                     break;
@@ -3459,5 +3456,5 @@
 
                 sz = QSize(w, h);
-            #endif
+#endif // QT_NO_POPUPMENU
 
             break;
