[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kstyles/keramik
From:       Maks Orlovich <maksim () kde ! org>
Date:       2004-06-14 23:29:42
Message-ID: 20040614232942.66304996F () office ! kde ! org
[Download RAW message or body]

CVS commit by orlovich: 

Rework how we layout icon + text layout, to fix icons getting positioned to close to \
bevel.(#83341) On the flip side, we now do things differently from other styles.

Also fix a rather obscure bug which occur if apps use an icon + pixmap combination. \
Hopefully no apps actually do

CCMAIL:83341-done@bugs.kde.org


  M +27 -13    keramik.cpp   1.127


--- kdelibs/kstyles/keramik/keramik.cpp  #1.126:1.127
@@ -1391,20 +1391,36 @@ void KeramikStyle::drawControl( ControlE
                                         state = QIconSet::On;
 
-                                QPixmap pixmap = button->iconSet()->pixmap( \
QIconSet::Small, mode, state ); +                                QPixmap icon = \
button->iconSet()->pixmap( QIconSet::Small, mode, state );  
-                                if (button->text().isEmpty() && !button->pixmap())
-                                        p->drawPixmap( x + w/2 - pixmap.width()/2, y \
                + h / 2 - pixmap.height() / 2,
-                                                                        pixmap );
+                                if (!button->text().isEmpty())
+                                {
+                                        //Center text + icon w/margin in between..
+                                        
+                                        //Calculate length of both.
+                                        int length = icon.width() + 4 + \
p->fontMetrics().size(ShowPrefix, button->text()).width(); +                          \
 +                                        //Calculate offset.
+                                        int offset = (w - length)/2;
+                                        
+                                        //draw icon
+                                        p->drawPixmap( x + offset, y + h / 2 - \
icon.height() / 2, icon ); +                                        
+                                        //new bounding rect for the text
+                                        x += offset + icon.width() + 4;
+                                        w =  length - icon.width() - 4;
+                                }
                                 else
-                                        p->drawPixmap( x + 4, y + h / 2 - \
pixmap.height() / 2, pixmap ); +                                {
+                                        //Icon only. Center it. 
+                                        if (!button->pixmap())
+                                                p->drawPixmap( x + w/2 - \
icon.width()/2, y + h / 2 - icon.height() / 2, +                                      \
icon ); +                                        else  //icon + pixmap. Ugh. 
+                                                p->drawPixmap( x + \
button->isDefault() ? 8 : 4 , y + h / 2 - icon.height() / 2, icon ); +                \
}  
                                 if (cornArrow) //Draw over the icon
                                         drawPrimitive( PE_ArrowDown, p, visualRect( \
                QRect(x + w - 6, x + h - 6, 7, 7), r ),
                                                            cg, flags, opt );
-
-
-                                int  pw = pixmap.width();
-                                x += pw + 4;
-                                w -= pw + 4;
                         }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic