summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launchertab.cpp24
-rw-r--r--core/settings/launcher/menusettings.cpp44
-rw-r--r--libopie2/opieui/otabbar.cpp50
-rw-r--r--libopie2/opieui/otabbar.h46
-rw-r--r--libopie2/opieui/otabwidget.cpp1
-rw-r--r--noncore/styles/flat/flat.cpp18
-rw-r--r--noncore/styles/fresh/fresh.cpp18
-rw-r--r--noncore/styles/liquid/liquid.cpp129
-rw-r--r--noncore/styles/phase/phasestyle.cpp14
-rw-r--r--noncore/styles/theme/othemestyle.cpp53
-rw-r--r--noncore/styles/web/webstyle.cpp126
-rw-r--r--noncore/styles/web/webstyle.h2
12 files changed, 338 insertions, 187 deletions
diff --git a/core/launcher/launchertab.cpp b/core/launcher/launchertab.cpp
index 710f259..72ebf59 100644
--- a/core/launcher/launchertab.cpp
+++ b/core/launcher/launchertab.cpp
@@ -76,101 +76,101 @@ void LauncherTabBar::layoutTabs()
76 return; 76 return;
77 77
78 int available = width()-1; 78 int available = width()-1;
79 79
80 QFontMetrics fm = fontMetrics(); 80 QFontMetrics fm = fontMetrics();
81 int hiddenTabWidth = -12; 81 int hiddenTabWidth = -12;
82 LauncherTab *current = currentLauncherTab(); 82 LauncherTab *current = currentLauncherTab();
83 int hframe, vframe, overlap; 83 int hframe, vframe, overlap;
84 style().tabbarMetrics( this, hframe, vframe, overlap ); 84 style().tabbarMetrics( this, hframe, vframe, overlap );
85 int x = 0; 85 int x = 0;
86 QRect r; 86 QRect r;
87 LauncherTab *t; 87 LauncherTab *t;
88 QListIterator< LauncherTab > it( items ); 88 QListIterator< LauncherTab > it( items );
89 int required = 0; 89 int required = 0;
90 int eventabwidth = (width()-1)/count(); 90 int eventabwidth = (width()-1)/count();
91 enum Mode { HideBackText, Pack, Even } mode=Even; 91 enum Mode { HideBackText, Pack, Even } mode=Even;
92 for (it.toFirst(); it.current(); ++it ) { 92 for (it.toFirst(); it.current(); ++it ) {
93 t = it.current(); 93 t = it.current();
94 if ( !t ) 94 if ( !t )
95 continue; 95 continue;
96 int iw = fm.width( t->text() ) + hframe - overlap; 96 int iw = fm.width( t->text() ) + hframe - overlap;
97 if ( t != current ) { 97 if ( t != current ) {
98 available -= hiddenTabWidth + hframe - overlap; 98 available -= hiddenTabWidth + hframe - overlap;
99 if ( t->iconSet() != 0 ) 99 if ( t->iconSet() != 0 )
100 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 100 available -= t->iconSet()->pixmap().width();
101 } 101 }
102 if ( t->iconSet() != 0 ) 102 if ( t->iconSet() != 0 )
103 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 103 iw += t->iconSet()->pixmap().width();
104 required += iw; 104 required += iw;
105 // As space gets tight, packed looks better than even. "10" must be at least 0. 105 // As space gets tight, packed looks better than even. "10" must be at least 0.
106 if ( iw >= eventabwidth-10 ) 106 if ( iw >= eventabwidth-10 )
107 mode = Pack; 107 mode = Pack;
108 } 108 }
109 if ( mode == Pack && required > width()-1 ) 109 if ( mode == Pack && required > width()-1 )
110 mode = HideBackText; 110 mode = HideBackText;
111 for ( it.toFirst(); it.current(); ++it ) { 111 for ( it.toFirst(); it.current(); ++it ) {
112 t = it.current(); 112 t = it.current();
113 if ( !t ) 113 if ( !t )
114 continue; 114 continue;
115 if ( mode != HideBackText ) { 115 if ( mode != HideBackText ) {
116 int w = fm.width( t->text() ); 116 int w = fm.width( t->text() );
117 int ih = 0; 117 int ih = 0;
118 if ( t->iconSet() != 0 ) { 118 if ( t->iconSet() != 0 ) {
119 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 119 w += t->iconSet()->pixmap().width();
120 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 120 ih = t->iconSet()->pixmap().height();
121 } 121 }
122 int h = QMAX( fm.height(), ih ); 122 int h = QMAX( fm.height(), ih );
123 h = QMAX( h, QApplication::globalStrut().height() ); 123 h = QMAX( h, QApplication::globalStrut().height() );
124 124
125 h += vframe; 125 h += vframe;
126 w += hframe; 126 w += hframe;
127 127
128 QRect totr(x, 0, 128 QRect totr(x, 0,
129 mode == Even ? eventabwidth : w * (width()-1)/required, h); 129 mode == Even ? eventabwidth : w * (width()-1)/required, h);
130 t->setRect(totr); 130 t->setRect(totr);
131 x += totr.width() - overlap; 131 x += totr.width() - overlap;
132 r = r.unite(totr); 132 r = r.unite(totr);
133 } else if ( t != current ) { 133 } else if ( t != current ) {
134 int w = hiddenTabWidth; 134 int w = hiddenTabWidth;
135 int ih = 0; 135 int ih = 0;
136 if ( t->iconSet() != 0 ) { 136 if ( t->iconSet() != 0 ) {
137 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 137 w += t->iconSet()->pixmap().width();
138 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 138 ih = t->iconSet()->pixmap().height();
139 } 139 }
140 int h = QMAX( fm.height(), ih ); 140 int h = QMAX( fm.height(), ih );
141 h = QMAX( h, QApplication::globalStrut().height() ); 141 h = QMAX( h, QApplication::globalStrut().height() );
142 142
143 h += vframe; 143 h += vframe;
144 w += hframe; 144 w += hframe;
145 145
146 t->setRect( QRect(x, 0, w, h) ); 146 t->setRect( QRect(x, 0, w, h) );
147 x += t->rect().width() - overlap; 147 x += t->rect().width() - overlap;
148 r = r.unite( t->rect() ); 148 r = r.unite( t->rect() );
149 } else { 149 } else {
150 int ih = 0; 150 int ih = 0;
151 if ( t->iconSet() != 0 ) { 151 if ( t->iconSet() != 0 ) {
152 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 152 ih = t->iconSet()->pixmap().height();
153 } 153 }
154 int h = QMAX( fm.height(), ih ); 154 int h = QMAX( fm.height(), ih );
155 h = QMAX( h, QApplication::globalStrut().height() ); 155 h = QMAX( h, QApplication::globalStrut().height() );
156 156
157 h += vframe; 157 h += vframe;
158 158
159 t->setRect( QRect(x, 0, available, h) ); 159 t->setRect( QRect(x, 0, available, h) );
160 x += t->rect().width() - overlap; 160 x += t->rect().width() - overlap;
161 r = r.unite( t->rect() ); 161 r = r.unite( t->rect() );
162 } 162 }
163 } 163 }
164 164
165 t = it.toLast(); 165 t = it.toLast();
166 if (t) { 166 if (t) {
167 QRect rr = t->rect(); 167 QRect rr = t->rect();
168 rr.setRight(width()-1); 168 rr.setRight(width()-1);
169 t->setRect( rr ); 169 t->setRect( rr );
170 } 170 }
171 171
172 for (it.toFirst(); it.current(); ++it ) { 172 for (it.toFirst(); it.current(); ++it ) {
173 t = it.current(); 173 t = it.current();
174 QRect tr = t->rect(); 174 QRect tr = t->rect();
175 tr.setHeight( r.height() ); 175 tr.setHeight( r.height() );
176 t->setRect( tr ); 176 t->setRect( tr );
@@ -199,80 +199,84 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const
199 if ( selected ) 199 if ( selected )
200 flags |= QStyle::Style_Selected; 200 flags |= QStyle::Style_Selected;
201 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 201 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
202 colorGroup(), flags, QStyleOption(t) ); 202 colorGroup(), flags, QStyleOption(t) );
203#else 203#else
204 style().drawTab( p, this, t, selected ); 204 style().drawTab( p, this, t, selected );
205#endif 205#endif
206 206
207 QRect r( t->rect() ); 207 QRect r( t->rect() );
208 QFont f( font() ); 208 QFont f( font() );
209 if ( selected ) 209 if ( selected )
210 f.setBold( TRUE ); 210 f.setBold( TRUE );
211 p->setFont( f ); 211 p->setFont( f );
212 212
213 if ( ct->fgColor.isValid() ) { 213 if ( ct->fgColor.isValid() ) {
214 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 214 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
215 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 215 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
216 that->setUpdatesEnabled( FALSE ); 216 that->setUpdatesEnabled( FALSE );
217 that->setPalette( pal ); 217 that->setPalette( pal );
218 setPal = TRUE; 218 setPal = TRUE;
219 } 219 }
220 int iw = 0; 220 int iw = 0;
221 int ih = 0; 221 int ih = 0;
222 if ( t->iconSet() != 0 ) { 222 if ( t->iconSet() != 0 ) {
223 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 223 iw = t->iconSet()->pixmap().width() + 2;
224 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 224 ih = t->iconSet()->pixmap().height();
225 } 225 }
226 int w = iw + p->fontMetrics().width( t->text() ) + 4; 226 int w = iw + p->fontMetrics().width( t->text() ) + 4;
227 int h = QMAX(p->fontMetrics().height() + 4, ih ); 227 int h = QMAX(p->fontMetrics().height() + 4, ih );
228 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 228 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
229 r.top() + (r.height()-h)/2, w, h ), t, 229 r.top() + (r.height()-h)/2, w, h ), t,
230#if QT_VERSION >= 0x030000 230#if QT_VERSION >= 0x030000
231 t->identifier() == keyboardFocusTab() 231 t->identifier() == keyboardFocusTab()
232#else 232#else
233 t->identitifer() == keyboardFocusTab() 233 t->identitifer() == keyboardFocusTab()
234#endif 234#endif
235 ); 235 );
236 if ( setPal ) { 236 if ( setPal ) {
237 that->unsetPalette(); 237 that->unsetPalette();
238 that->setUpdatesEnabled( TRUE ); 238 that->setUpdatesEnabled( TRUE );
239 } 239 }
240} 240}
241 241
242void LauncherTabBar::paintLabel( QPainter* p, const QRect&, 242void LauncherTabBar::paintLabel( QPainter* p, const QRect&,
243 QTab* t, bool has_focus ) const 243 QTab* t, bool has_focus ) const
244{ 244{
245 QRect r = t->rect(); 245 QRect r = t->rect();
246 // if ( t->id != currentTab() ) 246 // if ( t->id != currentTab() )
247 //r.moveBy( 1, 1 ); 247 //r.moveBy( 1, 1 );
248 // 248 //
249 if ( t->iconSet() ) { 249 if ( t->iconSet() ) {
250 // the tab has an iconset, draw it in the right mode 250 // the tab has an iconset, draw it in the right mode
251 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 251 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
252 if ( mode == QIconSet::Normal && has_focus ) 252 if ( mode == QIconSet::Normal && has_focus )
253 mode = QIconSet::Active; 253 mode = QIconSet::Active;
254 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 254 QPixmap pixmap;
255 if ( mode == QIconSet::Disabled )
256 pixmap = t->iconSet()->pixmap( QIconSet::Automatic, mode );
257 else
258 pixmap = t->iconSet()->pixmap();
255 int pixw = pixmap.width(); 259 int pixw = pixmap.width();
256 int pixh = pixmap.height(); 260 int pixh = pixmap.height();
257 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 261 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
258 r.setLeft( r.left() + pixw + 5 ); 262 r.setLeft( r.left() + pixw + 5 );
259 } 263 }
260 264
261 QRect tr = r; 265 QRect tr = r;
262 266
263 if ( r.width() < 20 ) 267 if ( r.width() < 20 )
264 return; 268 return;
265 269
266 if ( t->isEnabled() && isEnabled() ) { 270 if ( t->isEnabled() && isEnabled() ) {
267#if defined(_WS_WIN32_) 271#if defined(_WS_WIN32_)
268 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 272 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
269 p->setPen( colorGroup().buttonText() ); 273 p->setPen( colorGroup().buttonText() );
270 else 274 else
271 p->setPen( colorGroup().foreground() ); 275 p->setPen( colorGroup().foreground() );
272#else 276#else
273 p->setPen( colorGroup().foreground() ); 277 p->setPen( colorGroup().foreground() );
274#endif 278#endif
275 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 279 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
276 } else { 280 } else {
277 p->setPen( palette().disabled().foreground() ); 281 p->setPen( palette().disabled().foreground() );
278 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 282 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 55bf358..29ce841 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,47 +1,47 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4 .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "menusettings.h" 29#include "menusettings.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qlibrary.h> 32#include <qpe/qlibrary.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qlistview.h> 38#include <qlistview.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qheader.h> 40#include <qheader.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qwhatsthis.h> 43#include <qwhatsthis.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47 47
@@ -84,49 +84,49 @@ void MenuSettings::init ( )
84 QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; 84 QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
85#ifdef Q_OS_MACX 85#ifdef Q_OS_MACX
86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
87#else 87#else
88 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 88 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
89#endif /* Q_OS_MACX */ 89#endif /* Q_OS_MACX */
90 90
91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
92 QString name; 92 QString name;
93 QPixmap icon; 93 QPixmap icon;
94 MenuAppletInterface *iface = 0; 94 MenuAppletInterface *iface = 0;
95 95
96 QLibrary *lib = new QLibrary ( path + "/" + *it ); 96 QLibrary *lib = new QLibrary ( path + "/" + *it );
97 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); 97 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface );
98 if ( iface ) { 98 if ( iface ) {
99 QString lang = getenv( "LANG" ); 99 QString lang = getenv( "LANG" );
100 QTranslator *trans = new QTranslator ( qApp ); 100 QTranslator *trans = new QTranslator ( qApp );
101 QString type = (*it). left ((*it). find (".")); 101 QString type = (*it). left ((*it). find ("."));
102 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; 102 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
103 if ( trans-> load ( tfn )) 103 if ( trans-> load ( tfn ))
104 qApp-> installTranslator ( trans ); 104 qApp-> installTranslator ( trans );
105 else 105 else
106 delete trans; 106 delete trans;
107 name = iface-> name ( ); 107 name = iface-> name ( );
108 icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); 108 icon = iface-> icon ( ). pixmap ();
109 iface-> release ( ); 109 iface-> release ( );
110 lib-> unload ( ); 110 lib-> unload ( );
111 111
112 QCheckListItem *item; 112 QCheckListItem *item;
113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
114 if ( !icon. isNull ( )) 114 if ( !icon. isNull ( ))
115 item-> setPixmap ( 0, icon ); 115 item-> setPixmap ( 0, icon );
116 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 116 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
117 m_applets [*it] = item; 117 m_applets [*it] = item;
118 } else { 118 } else {
119 delete lib; 119 delete lib;
120 } 120 }
121 } 121 }
122 122
123 cfg. setGroup ( "Menu" ); 123 cfg. setGroup ( "Menu" );
124 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); 124 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) );
125 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); 125 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) );
126 m_menusubpopup->setEnabled( m_menutabs->isChecked() ); 126 m_menusubpopup->setEnabled( m_menutabs->isChecked() );
127 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); 127 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) );
128 128
129} 129}
130 130
131void MenuSettings::appletChanged() 131void MenuSettings::appletChanged()
132{ 132{
diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp
index a62e18b..dc5df42 100644
--- a/libopie2/opieui/otabbar.cpp
+++ b/libopie2/opieui/otabbar.cpp
@@ -1,75 +1,79 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4 Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7 .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14    .%`+i>       _;_. 14 .%`+i> _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++=   -.     .`     .: details. 21++= -. .` .: details.
22 :     =  ...= . :.=- 22: = ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/otabbar.h> 32#include <opie2/otabbar.h>
33 33
34#include <qpe/applnk.h>
35
36#include <stdio.h>
37
34using namespace Opie::Ui; 38using namespace Opie::Ui;
35 39
36OTabBar::OTabBar( QWidget *parent , const char *name ) 40OTabBar::OTabBar( QWidget *parent , const char *name )
37 :QTabBar( parent, name ) 41 :QTabBar( parent, name )
38{} 42{}
39 43
40void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const 44void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
41{ 45{
42 46
43 QRect r = br; 47 QRect r = br;
44 if ( t->iconset) 48 if ( t->iconset)
45 { 49 {
46 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 50 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
47 if ( mode == QIconSet::Normal && has_focus ) 51 if ( mode == QIconSet::Normal && has_focus )
48 { 52 {
49 mode = QIconSet::Active; 53 mode = QIconSet::Active;
50 } 54 }
51 QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode ); 55 QPixmap pixmap = t->iconset->pixmap();
52 int pixw = pixmap.width(); 56 int pixw = pixmap.width();
53 int pixh = pixmap.height(); 57 int pixh = pixmap.height();
54 r.setLeft( r.left() + pixw + 2 ); 58 r.setLeft( r.left() + pixw + 2 );
55 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); 59 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
56 } 60 }
57 61
58 QRect tr = r; 62 QRect tr = r;
59 if ( t->id == currentTab() ) 63 if ( t->id == currentTab() )
60 { 64 {
61 tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); 65 tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
62 } 66 }
63 67
64 if ( t->enabled && isEnabled() ) 68 if ( t->enabled && isEnabled() )
65 { 69 {
66 p->setPen( colorGroup().foreground() ); 70 p->setPen( colorGroup().foreground() );
67 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 71 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
68 } 72 }
69 else if ( style() == MotifStyle ) 73 else if ( style() == MotifStyle )
70 { 74 {
71 p->setPen( palette().disabled().foreground() ); 75 p->setPen( palette().disabled().foreground() );
72 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 76 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
73 } 77 }
74 else 78 else
75 { 79 {
diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h
index 925ae96..1044bdd 100644
--- a/libopie2/opieui/otabbar.h
+++ b/libopie2/opieui/otabbar.h
@@ -1,53 +1,53 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4 Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7 .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14    .%`+i>       _;_. 14 .%`+i> _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++=   -.     .`     .: details. 21++= -. .` .: details.
22 :     =  ...= . :.=- 22: = ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTABBAR_H 32#ifndef OTABBAR_H
33#define OTABBAR_H 33#define OTABBAR_H
34 34
35/* QT */ 35/* QT */
36#include <qtabbar.h> 36#include <qtabbar.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Ui { 39namespace Ui {
40 40
41/** 41/**
42 * @class OTabBar 42 * @class OTabBar
43 * @brief The OTabBar class is a derivative of QTabBar. 43 * @brief The OTabBar class is a derivative of QTabBar.
44 * 44 *
45 * OTabBar is a derivation of TrollTech's QTabBar which provides 45 * OTabBar is a derivation of TrollTech's QTabBar which provides
46 * a row of tabs for selection. The only difference between this 46 * a row of tabs for selection. The only difference between this
47 * class and QTabBar is that there is no dotted line box around 47 * class and QTabBar is that there is no dotted line box around
48 * the label of the tab with the current focus. 48 * the label of the tab with the current focus.
49 */ 49 */
50class OTabBar : public QTabBar 50class OTabBar : public QTabBar
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index 7333f5e..d617a9c 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -13,49 +13,48 @@
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <opie2/otabwidget.h> 31#include <opie2/otabwidget.h>
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oresource.h> 34#include <opie2/oresource.h>
35#include <opie2/otabbar.h> 35#include <opie2/otabbar.h>
36 36
37#include <qpe/applnk.h>
38#include <qpe/config.h> 37#include <qpe/config.h>
39 38
40/* QT */ 39/* QT */
41#include <qcombobox.h> 40#include <qcombobox.h>
42#include <qwidgetstack.h> 41#include <qwidgetstack.h>
43 42
44using namespace Opie::Ui; 43using namespace Opie::Ui;
45 44
46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 45OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
47 : QWidget( parent, name ) 46 : QWidget( parent, name )
48 , m_currTab( 0l ) 47 , m_currTab( 0l )
49 , m_tabBarStyle( Global ) 48 , m_tabBarStyle( Global )
50 , m_tabBarPosition( Top ) 49 , m_tabBarPosition( Top )
51 , m_usingTabs( true ) 50 , m_usingTabs( true )
52 , m_tabBar( 0l ) 51 , m_tabBar( 0l )
53 , m_tabList( 0l ) 52 , m_tabList( 0l )
54{ 53{
55 if ( s == Global ) 54 if ( s == Global )
56 { 55 {
57 // Read Opie global settings for style and position 56 // Read Opie global settings for style and position
58 Config config( "qpe" ); 57 Config config( "qpe" );
59 config.setGroup( "Appearance" ); 58 config.setGroup( "Appearance" );
60 59
61 // Style 60 // Style
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp
index f3bacf9..c164ecc 100644
--- a/noncore/styles/flat/flat.cpp
+++ b/noncore/styles/flat/flat.cpp
@@ -352,68 +352,68 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p )
352void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) 352void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
353{ 353{
354 QRect r = pushButtonContentsRect( btn ); 354 QRect r = pushButtonContentsRect( btn );
355 int x, y, w, h; 355 int x, y, w, h;
356 r.rect( &x, &y, &w, &h ); 356 r.rect( &x, &y, &w, &h );
357 QColorGroup cg = btn->colorGroup(); 357 QColorGroup cg = btn->colorGroup();
358 if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() ) 358 if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() )
359 cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() ); 359 cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() );
360 else if ( btn->isDown() || btn->isOn() ) 360 else if ( btn->isDown() || btn->isOn() )
361 cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() ); 361 cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() );
362 if ( btn->isMenuButton() ) { 362 if ( btn->isMenuButton() ) {
363 int dx = menuButtonIndicatorWidth( btn->height() ); 363 int dx = menuButtonIndicatorWidth( btn->height() );
364 drawArrow( p, DownArrow, FALSE, 364 drawArrow( p, DownArrow, FALSE,
365 x+w-dx, y+2, dx-4, h-4, 365 x+w-dx, y+2, dx-4, h-4,
366 cg, 366 cg,
367 btn->isEnabled() ); 367 btn->isEnabled() );
368 w -= dx; 368 w -= dx;
369 } 369 }
370 370
371 if ( btn->iconSet() && !btn->iconSet()->isNull() ) { 371 if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
372 QIconSet::Mode mode = btn->isEnabled() 372 QIconSet::Mode mode = btn->isEnabled()
373 ? QIconSet::Normal : QIconSet::Disabled; 373 ? QIconSet::Normal : QIconSet::Disabled;
374 if ( mode == QIconSet::Normal && btn->hasFocus() ) 374 if ( mode == QIconSet::Normal && btn->hasFocus() )
375 mode = QIconSet::Active; 375 mode = QIconSet::Active;
376 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); 376 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
377 int pixw = pixmap.width(); 377 int pixw = pixmap.width();
378 int pixh = pixmap.height(); 378 int pixh = pixmap.height();
379 p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); 379 p->drawPixmap( x+2, y+h/2-pixh/2, pixmap );
380 x += pixw + 4; 380 x += pixw + 4;
381 w -= pixw + 4; 381 w -= pixw + 4;
382 } 382 }
383 drawItem( p, x, y, w, h, 383 drawItem( p, x, y, w, h,
384 AlignCenter | ShowPrefix, 384 AlignCenter | ShowPrefix,
385 cg, btn->isEnabled(), 385 cg, btn->isEnabled(),
386 btn->pixmap(), btn->text(), -1, &cg.buttonText() ); 386 btn->pixmap(), btn->text(), -1, &cg.buttonText() );
387 387
388} 388}
389 389
390QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) 390QRect FlatStyle::comboButtonRect( int x, int y, int w, int h)
391{ 391{
392 return QRect(x+2, y+2, w-4-13, h-4); 392 return QRect(x+2, y+2, w-4-13, h-4);
393} 393}
394 394
395 395
396QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) 396QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h)
397{ 397{
398 return QRect(x+2, y+2, w-4-14, h-4); 398 return QRect(x+2, y+2, w-4-14, h-4);
399} 399}
400 400
401void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 401void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
402 const QColorGroup &g, bool sunken, 402 const QColorGroup &g, bool sunken,
403 bool /*editable*/, 403 bool /*editable*/,
404 bool enabled, 404 bool enabled,
405 const QBrush * /*fill*/ ) 405 const QBrush * /*fill*/ )
406{ 406{
407 x++; y++; 407 x++; y++;
408 w-=2; h-=2; 408 w-=2; h-=2;
409 p->setPen( g.foreground() ); 409 p->setPen( g.foreground() );
410 p->setBrush( QBrush(NoBrush) ); 410 p->setBrush( QBrush(NoBrush) );
411 p->drawRect( x, y, w, h ); 411 p->drawRect( x, y, w, h );
412 p->setPen( g.background() ); 412 p->setPen( g.background() );
413 p->drawRect( x+1, y+1, w-14, h-2 ); 413 p->drawRect( x+1, y+1, w-14, h-2 );
414 p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) ); 414 p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) );
415 QColorGroup cg( g ); 415 QColorGroup cg( g );
416 if ( sunken ) { 416 if ( sunken ) {
417 cg.setColor( QColorGroup::ButtonText, g.button() ); 417 cg.setColor( QColorGroup::ButtonText, g.button() );
418 cg.setColor( QColorGroup::Button, g.buttonText() ); 418 cg.setColor( QColorGroup::Button, g.buttonText() );
419 } 419 }
@@ -871,111 +871,115 @@ int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* m
871 } 871 }
872 872
873 if ( maxpmw ) { // we have iconsets 873 if ( maxpmw ) { // we have iconsets
874 w += maxpmw; 874 w += maxpmw;
875 w += 6; // add a little extra border around the iconset 875 w += 6; // add a little extra border around the iconset
876 } 876 }
877 877
878 if ( checkable && maxpmw < windowsCheckMarkWidth ) { 878 if ( checkable && maxpmw < windowsCheckMarkWidth ) {
879 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks 879 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
880 } 880 }
881 881
882 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) 882 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
883 w += motifCheckMarkHMargin; // add space to separate the columns 883 w += motifCheckMarkHMargin; // add space to separate the columns
884 884
885 w += windowsRightBorder; // windows has a strange wide border on the right side 885 w += windowsRightBorder; // windows has a strange wide border on the right side
886 886
887 return w; 887 return w;
888#endif 888#endif
889} 889}
890 890
891/*! \reimp 891/*! \reimp
892*/ 892*/
893int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) 893int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
894{ 894{
895#ifndef QT_NO_MENUDATA 895#ifndef QT_NO_MENUDATA
896 int h = 0; 896 int h = 0;
897 if ( mi->isSeparator() ) // separator height 897 if ( mi->isSeparator() ) // separator height
898 h = motifSepHeight; 898 h = motifSepHeight;
899 else if ( mi->pixmap() ) // pixmap height 899 else if ( mi->pixmap() ) // pixmap height
900 h = mi->pixmap()->height() + 2*motifItemFrame; 900 h = mi->pixmap()->height() + 2*motifItemFrame;
901 else // text height 901 else // text height
902 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; 902 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
903 903
904 if ( !mi->isSeparator() && mi->iconSet() != 0 ) { 904 if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
905 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); 905 h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
906 } 906 }
907 if ( mi->custom() ) 907 if ( mi->custom() )
908 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; 908 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
909 return h; 909 return h;
910#endif 910#endif
911} 911}
912 912
913void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 913void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
914 const QPalette& pal, 914 const QPalette& pal,
915 bool act, bool enabled, int x, int y, int w, int h) 915 bool act, bool enabled, int x, int y, int w, int h)
916{ 916{
917#ifndef QT_NO_MENUDATA 917#ifndef QT_NO_MENUDATA
918 const QColorGroup & g = pal.active(); 918 const QColorGroup & g = pal.active();
919 bool dis = !enabled; 919 bool dis = !enabled;
920 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 920 QColorGroup itemg = dis ? pal.disabled() : pal.active();
921 921
922 if ( checkable ) 922 if ( checkable )
923 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks 923 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
924 924
925 int checkcol = maxpmw; 925 int checkcol = maxpmw;
926 926
927 if ( mi && mi->isSeparator() ) { // draw separator 927 if ( mi && mi->isSeparator() ) { // draw separator
928 p->setPen( g.dark() ); 928 p->setPen( g.dark() );
929 p->drawLine( x, y, x+w, y ); 929 p->drawLine( x, y, x+w, y );
930 return; 930 return;
931 } 931 }
932 932
933 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 933 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
934 g.brush( QColorGroup::Button ); 934 g.brush( QColorGroup::Button );
935 p->fillRect( x, y, w, h, fill); 935 p->fillRect( x, y, w, h, fill);
936 936
937 if ( !mi ) 937 if ( !mi )
938 return; 938 return;
939 939
940 if ( mi->isChecked() ) { 940 if ( mi->isChecked() ) {
941 if ( act && !dis ) { 941 if ( act && !dis ) {
942 qDrawShadePanel( p, x, y, checkcol, h, 942 qDrawShadePanel( p, x, y, checkcol, h,
943 g, TRUE, 1, &g.brush( QColorGroup::Button ) ); 943 g, TRUE, 1, &g.brush( QColorGroup::Button ) );
944 } else { 944 } else {
945 qDrawShadePanel( p, x, y, checkcol, h, 945 qDrawShadePanel( p, x, y, checkcol, h,
946 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); 946 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
947 } 947 }
948 } else if ( !act ) { 948 } else if ( !act ) {
949 p->fillRect(x, y, checkcol , h, 949 p->fillRect(x, y, checkcol , h,
950 g.brush( QColorGroup::Button )); 950 g.brush( QColorGroup::Button ));
951 } 951 }
952 952
953 if ( mi->iconSet() ) { // draw iconset 953 if ( mi->iconSet() ) { // draw iconset
954 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 954 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
955 if (act && !dis ) 955 if (act && !dis )
956 mode = QIconSet::Active; 956 mode = QIconSet::Active;
957 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); 957 QPixmap pixmap;
958 if ( mode == QIconSet::Disabled )
959 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
960 else
961 pixmap = mi->iconSet()->pixmap();
958 int pixw = pixmap.width(); 962 int pixw = pixmap.width();
959 int pixh = pixmap.height(); 963 int pixh = pixmap.height();
960 if ( act && !dis ) { 964 if ( act && !dis ) {
961 if ( !mi->isChecked() ) 965 if ( !mi->isChecked() )
962 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); 966 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
963 } 967 }
964 QRect cr( x, y, checkcol, h ); 968 QRect cr( x, y, checkcol, h );
965 QRect pmr( 0, 0, pixw, pixh ); 969 QRect pmr( 0, 0, pixw, pixh );
966 pmr.moveCenter( cr.center() ); 970 pmr.moveCenter( cr.center() );
967 p->setPen( itemg.text() ); 971 p->setPen( itemg.text() );
968 p->drawPixmap( pmr.topLeft(), pixmap ); 972 p->drawPixmap( pmr.topLeft(), pixmap );
969 973
970 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 974 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
971 g.brush( QColorGroup::Button ); 975 g.brush( QColorGroup::Button );
972 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); 976 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
973 } else if ( checkable ) {// just "checking"... 977 } else if ( checkable ) {// just "checking"...
974 int mw = checkcol + motifItemFrame; 978 int mw = checkcol + motifItemFrame;
975 int mh = h - 2*motifItemFrame; 979 int mh = h - 2*motifItemFrame;
976 if ( mi->isChecked() ) { 980 if ( mi->isChecked() ) {
977 drawCheckMark( p, x + motifItemFrame + 2, 981 drawCheckMark( p, x + motifItemFrame + 2,
978 y+motifItemFrame, mw, mh, itemg, act, dis ); 982 y+motifItemFrame, mw, mh, itemg, act, dis );
979 } 983 }
980 } 984 }
981 985
diff --git a/noncore/styles/fresh/fresh.cpp b/noncore/styles/fresh/fresh.cpp
index 831b620..856f68b 100644
--- a/noncore/styles/fresh/fresh.cpp
+++ b/noncore/styles/fresh/fresh.cpp
@@ -126,50 +126,50 @@ void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h,
126 126
127 if ( !sunken ) { 127 if ( !sunken ) {
128 p->setPen( white ); 128 p->setPen( white );
129 p->drawLine( x2-1, y+1, x2-1, y2-1 ); 129 p->drawLine( x2-1, y+1, x2-1, y2-1 );
130 p->drawLine( x+1, y2-1, x2-1, y2-1 ); 130 p->drawLine( x+1, y2-1, x2-1, y2-1 );
131 } 131 }
132 p->setPen( oldPen ); 132 p->setPen( oldPen );
133} 133}
134 134
135void FreshStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) 135void FreshStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
136{ 136{
137 p->fillRect( x, y, w, h, color1 ); 137 p->fillRect( x, y, w, h, color1 );
138} 138}
139 139
140void FreshStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 140void FreshStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
141 const QColorGroup &g, bool sunken, const QBrush* fill ) 141 const QColorGroup &g, bool sunken, const QBrush* fill )
142{ 142{
143 drawButton( p, x, y, w, h, g, sunken, fill ); 143 drawButton( p, x, y, w, h, g, sunken, fill );
144} 144}
145 145
146QRect FreshStyle::comboButtonRect( int x, int y, int w, int h) 146QRect FreshStyle::comboButtonRect( int x, int y, int w, int h)
147{ 147{
148 return QRect(x+1, y+1, w-2-14, h-2); 148 return QRect(x+1, y+1, w-2-14, h-2);
149} 149}
150 150
151 151
152QRect FreshStyle::comboButtonFocusRect( int x, int y, int w, int h) 152QRect FreshStyle::comboButtonFocusRect( int x, int y, int w, int h)
153{ 153{
154 return QRect(x+2, y+2, w-4-14, h-4); 154 return QRect(x+2, y+2, w-4-14, h-4);
155} 155}
156 156
157void FreshStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 157void FreshStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
158 const QColorGroup &g, bool sunken, 158 const QColorGroup &g, bool sunken,
159 bool /*editable*/, 159 bool /*editable*/,
160 bool enabled, 160 bool enabled,
161 const QBrush *fill ) 161 const QBrush *fill )
162{ 162{
163 drawBevelButton( p, x, y, w, h, g, FALSE, fill ); 163 drawBevelButton( p, x, y, w, h, g, FALSE, fill );
164 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill ); 164 drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
165 drawArrow( p, QStyle::DownArrow, sunken, 165 drawArrow( p, QStyle::DownArrow, sunken,
166 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled, 166 x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
167 &g.brush( QColorGroup::Button ) ); 167 &g.brush( QColorGroup::Button ) );
168 168
169} 169}
170 170
171 171
172void FreshStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, 172void FreshStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
173 int h, const QColorGroup &cg, bool on, bool down, bool enabled ) 173 int h, const QColorGroup &cg, bool on, bool down, bool enabled )
174{ 174{
175 static const QCOORD pts1[] = { // dark lines 175 static const QCOORD pts1[] = { // dark lines
@@ -507,49 +507,49 @@ void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected
507 if ( tb->shape() == QTabBar::RoundedAbove ) { 507 if ( tb->shape() == QTabBar::RoundedAbove ) {
508 p->setPen( tb->colorGroup().light() ); 508 p->setPen( tb->colorGroup().light() );
509 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 509 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
510 if ( r.left() == 0 ) 510 if ( r.left() == 0 )
511 p->drawPoint( tb->rect().bottomLeft() ); 511 p->drawPoint( tb->rect().bottomLeft() );
512 else { 512 else {
513 p->setPen( tb->colorGroup().light() ); 513 p->setPen( tb->colorGroup().light() );
514 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 514 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
515 } 515 }
516 516
517 if ( selected ) { 517 if ( selected ) {
518 p->setPen( tb->colorGroup().background() ); 518 p->setPen( tb->colorGroup().background() );
519 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 519 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
520 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), 520 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
521 tb->colorGroup().brush( QColorGroup::Background )); 521 tb->colorGroup().brush( QColorGroup::Background ));
522 } else { 522 } else {
523 r.setRect( r.left() + 2, r.top() + 2, 523 r.setRect( r.left() + 2, r.top() + 2,
524 r.width() - 4, r.height() - 2 ); 524 r.width() - 4, r.height() - 2 );
525 p->setPen( tb->colorGroup().button() ); 525 p->setPen( tb->colorGroup().button() );
526 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 526 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
527 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), 527 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
528 tb->colorGroup().brush( QColorGroup::Button )); 528 tb->colorGroup().brush( QColorGroup::Button ));
529 529
530 //do shading; will not work for pixmap brushes 530 //do shading; will not work for pixmap brushes
531 QColor bg = tb->colorGroup().button(); 531 QColor bg = tb->colorGroup().button();
532 // int h,s,v; 532 // int h,s,v;
533 // bg.hsv( &h, &s, &v ); 533 // bg.hsv( &h, &s, &v );
534 int n = r.height()/2; 534 int n = r.height()/2;
535 int dark = 100; 535 int dark = 100;
536 for ( int i = 1; i < n; i++ ) { 536 for ( int i = 1; i < n; i++ ) {
537 dark = (dark * (100+(i*15)/n) )/100; 537 dark = (dark * (100+(i*15)/n) )/100;
538 p->setPen( bg.dark( dark ) ); 538 p->setPen( bg.dark( dark ) );
539 int y = r.bottom()-n+i; 539 int y = r.bottom()-n+i;
540 int x1 = r.left()+1; 540 int x1 = r.left()+1;
541 int x2 = r.right()-1; 541 int x2 = r.right()-1;
542 p->drawLine( x1, y, x2, y ); 542 p->drawLine( x1, y, x2, y );
543 } 543 }
544 } 544 }
545 545
546 p->setPen( tb->colorGroup().light() ); 546 p->setPen( tb->colorGroup().light() );
547 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); 547 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
548 p->drawPoint( r.left()+1, r.top() + 1 ); 548 p->drawPoint( r.left()+1, r.top() + 1 );
549 p->drawLine( r.left()+2, r.top(), 549 p->drawLine( r.left()+2, r.top(),
550 r.right() - 2, r.top() ); 550 r.right() - 2, r.top() );
551 551
552 p->setPen( tb->colorGroup().dark() ); 552 p->setPen( tb->colorGroup().dark() );
553 p->drawPoint( r.right() - 1, r.top() + 1 ); 553 p->drawPoint( r.right() - 1, r.top() + 1 );
554 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); 554 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
555 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 555 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
@@ -617,113 +617,117 @@ int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*
617 } 617 }
618 618
619 if ( maxpmw ) { // we have iconsets 619 if ( maxpmw ) { // we have iconsets
620 w += maxpmw; 620 w += maxpmw;
621 w += 6; // add a little extra border around the iconset 621 w += 6; // add a little extra border around the iconset
622 } 622 }
623 623
624 if ( checkable && maxpmw < windowsCheckMarkWidth ) { 624 if ( checkable && maxpmw < windowsCheckMarkWidth ) {
625 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks 625 w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
626 } 626 }
627 627
628 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) 628 if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
629 w += motifCheckMarkHMargin; // add space to separate the columns 629 w += motifCheckMarkHMargin; // add space to separate the columns
630 630
631 w += windowsRightBorder; // windows has a strange wide border on the right side 631 w += windowsRightBorder; // windows has a strange wide border on the right side
632 632
633 return w; 633 return w;
634#endif 634#endif
635} 635}
636 636
637/*! \reimp 637/*! \reimp
638*/ 638*/
639int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) 639int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
640{ 640{
641#ifndef QT_NO_MENUDATA 641#ifndef QT_NO_MENUDATA
642 int h = 0; 642 int h = 0;
643 if ( mi->isSeparator() ) // separator height 643 if ( mi->isSeparator() ) // separator height
644 h = motifSepHeight; 644 h = motifSepHeight;
645 else if ( mi->pixmap() ) // pixmap height 645 else if ( mi->pixmap() ) // pixmap height
646 h = mi->pixmap()->height() + 2*motifItemFrame; 646 h = mi->pixmap()->height() + 2*motifItemFrame;
647 else // text height 647 else // text height
648 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; 648 h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
649 649
650 if ( !mi->isSeparator() && mi->iconSet() != 0 ) { 650 if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
651 h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); 651 h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
652 } 652 }
653 if ( mi->custom() ) 653 if ( mi->custom() )
654 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; 654 h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
655 return h; 655 return h;
656#endif 656#endif
657} 657}
658 658
659void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, 659void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
660 const QPalette& pal, 660 const QPalette& pal,
661 bool act, bool enabled, int x, int y, int w, int h) 661 bool act, bool enabled, int x, int y, int w, int h)
662{ 662{
663#ifndef QT_NO_MENUDATA 663#ifndef QT_NO_MENUDATA
664 const QColorGroup & g = pal.active(); 664 const QColorGroup & g = pal.active();
665 bool dis = !enabled; 665 bool dis = !enabled;
666 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 666 QColorGroup itemg = dis ? pal.disabled() : pal.active();
667 667
668 if ( checkable ) 668 if ( checkable )
669 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks 669 maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
670 670
671 int checkcol = maxpmw; 671 int checkcol = maxpmw;
672 672
673 if ( mi && mi->isSeparator() ) { // draw separator 673 if ( mi && mi->isSeparator() ) { // draw separator
674 p->setPen( g.dark() ); 674 p->setPen( g.dark() );
675 p->drawLine( x, y, x+w, y ); 675 p->drawLine( x, y, x+w, y );
676 p->setPen( g.light() ); 676 p->setPen( g.light() );
677 p->drawLine( x, y+1, x+w, y+1 ); 677 p->drawLine( x, y+1, x+w, y+1 );
678 return; 678 return;
679 } 679 }
680 680
681 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 681 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
682 g.brush( QColorGroup::Button ); 682 g.brush( QColorGroup::Button );
683 p->fillRect( x, y, w, h, fill); 683 p->fillRect( x, y, w, h, fill);
684 684
685 if ( !mi ) 685 if ( !mi )
686 return; 686 return;
687 687
688 if ( mi->isChecked() ) { 688 if ( mi->isChecked() ) {
689 if ( act && !dis ) { 689 if ( act && !dis ) {
690 qDrawShadePanel( p, x, y, checkcol, h, 690 qDrawShadePanel( p, x, y, checkcol, h,
691 g, TRUE, 1, &g.brush( QColorGroup::Button ) ); 691 g, TRUE, 1, &g.brush( QColorGroup::Button ) );
692 } else { 692 } else {
693 qDrawShadePanel( p, x, y, checkcol, h, 693 qDrawShadePanel( p, x, y, checkcol, h,
694 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); 694 g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
695 } 695 }
696 } else if ( !act ) { 696 } else if ( !act ) {
697 p->fillRect(x, y, checkcol , h, 697 p->fillRect(x, y, checkcol , h,
698 g.brush( QColorGroup::Button )); 698 g.brush( QColorGroup::Button ));
699 } 699 }
700 700
701 if ( mi->iconSet() ) { // draw iconset 701 if ( mi->iconSet() ) { // draw iconset
702 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 702 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
703 if (act && !dis ) 703 if (act && !dis )
704 mode = QIconSet::Active; 704 mode = QIconSet::Active;
705 QPixmap pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode ); 705 QPixmap pixmap;
706 if ( mode == QIconSet::Disabled )
707 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
708 else
709 pixmap = mi->iconSet()->pixmap();
706 int pixw = pixmap.width(); 710 int pixw = pixmap.width();
707 int pixh = pixmap.height(); 711 int pixh = pixmap.height();
708 if ( act && !dis ) { 712 if ( act && !dis ) {
709 if ( !mi->isChecked() ) 713 if ( !mi->isChecked() )
710 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); 714 qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
711 } 715 }
712 QRect cr( x, y, checkcol, h ); 716 QRect cr( x, y, checkcol, h );
713 QRect pmr( 0, 0, pixw, pixh ); 717 QRect pmr( 0, 0, pixw, pixh );
714 pmr.moveCenter( cr.center() ); 718 pmr.moveCenter( cr.center() );
715 p->setPen( itemg.text() ); 719 p->setPen( itemg.text() );
716 p->drawPixmap( pmr.topLeft(), pixmap ); 720 p->drawPixmap( pmr.topLeft(), pixmap );
717 721
718 QBrush fill = act? g.brush( QColorGroup::Highlight ) : 722 QBrush fill = act? g.brush( QColorGroup::Highlight ) :
719 g.brush( QColorGroup::Button ); 723 g.brush( QColorGroup::Button );
720 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); 724 p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
721 } else if ( checkable ) {// just "checking"... 725 } else if ( checkable ) {// just "checking"...
722 int mw = checkcol + motifItemFrame; 726 int mw = checkcol + motifItemFrame;
723 int mh = h - 2*motifItemFrame; 727 int mh = h - 2*motifItemFrame;
724 if ( mi->isChecked() ) { 728 if ( mi->isChecked() ) {
725 drawCheckMark( p, x + motifItemFrame + 2, 729 drawCheckMark( p, x + motifItemFrame + 2,
726 y+motifItemFrame, mw, mh, itemg, act, dis ); 730 y+motifItemFrame, mw, mh, itemg, act, dis );
727 } 731 }
728 } 732 }
729 733
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 51814e7..77cf198 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,39 +1,39 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5// 5//
6// (c) 2002 Robert 'sandman' Griebl 6// (c) 2002 Robert 'sandman' Griebl
7// 7//
8 8
9 9
10#ifndef INCLUDE_MENUITEM_DEF 10#ifndef INCLUDE_MENUITEM_DEF
11#define INCLUDE_MENUITEM_DEF 11#define INCLUDE_MENUITEM_DEF
12#endif 12#endif
13 13
14#include "liquid.h" 14#include "liquid.h"
15#include "effects.h" 15#include "effects.h"
16#include "htmlmasks.h" 16#include "htmlmasks.h"
17#include "embeddata.h" 17#include "embeddata.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qmenudata.h> 25#include <qmenudata.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qpalette.h> 27#include <qpalette.h>
28#include <qbitmap.h> 28#include <qbitmap.h>
29#include <qtabbar.h> 29#include <qtabbar.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qobjectlist.h> 31#include <qobjectlist.h>
32#include <qimage.h> 32#include <qimage.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qpixmapcache.h> 34#include <qpixmapcache.h>
35#include <qradiobutton.h> 35#include <qradiobutton.h>
36#include <qcombobox.h> 36#include <qcombobox.h>
37#include <qdrawutil.h> 37#include <qdrawutil.h>
38#include <qwidgetlist.h> 38#include <qwidgetlist.h>
39#include <qtoolbutton.h> 39#include <qtoolbutton.h>
@@ -78,123 +78,123 @@ void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
78} 78}
79 79
80TransMenuHandler::TransMenuHandler(QObject *parent) 80TransMenuHandler::TransMenuHandler(QObject *parent)
81 : QObject(parent) 81 : QObject(parent)
82{ 82{
83 pixDict.setAutoDelete(true); 83 pixDict.setAutoDelete(true);
84 reloadSettings(); 84 reloadSettings();
85} 85}
86 86
87void TransMenuHandler::reloadSettings() 87void TransMenuHandler::reloadSettings()
88{ 88{
89 pixDict.clear(); 89 pixDict.clear();
90 90
91 Config config ( "qpe" ); 91 Config config ( "qpe" );
92 config. setGroup ( "Liquid-Style" ); 92 config. setGroup ( "Liquid-Style" );
93 93
94 type = config. readNumEntry("Type", TransStippleBg); 94 type = config. readNumEntry("Type", TransStippleBg);
95 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 95 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
96 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 96 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
97 opacity = config. readNumEntry("Opacity", 10); 97 opacity = config. readNumEntry("Opacity", 10);
98 if ( opacity < -20 ) 98 if ( opacity < -20 )
99 opacity = 20; 99 opacity = 20;
100 else if ( opacity > 20 ) 100 else if ( opacity > 20 )
101 opacity = 20; 101 opacity = 20;
102 102
103 shadowText = config. readBoolEntry("ShadowText", true); 103 shadowText = config. readBoolEntry("ShadowText", true);
104} 104}
105 105
106bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 106bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
107{ 107{
108 QWidget *p = (QWidget *)obj; 108 QWidget *p = (QWidget *)obj;
109 109
110 if(ev->type() == QEvent::Show){ 110 if(ev->type() == QEvent::Show){
111 if(type == TransStippleBg || type == TransStippleBtn || 111 if(type == TransStippleBg || type == TransStippleBtn ||
112 type == Custom){ 112 type == Custom){
113 QApplication::syncX(); 113 QApplication::syncX();
114 QPixmap *pix = new QPixmap; 114 QPixmap *pix = new QPixmap;
115 if(p->testWFlags(Qt::WType_Popup)){ 115 if(p->testWFlags(Qt::WType_Popup)){
116 QRect r(p->x(), p->y(), p->width(), p->height()); 116 QRect r(p->x(), p->y(), p->width(), p->height());
117 QRect deskR = QApplication::desktop()->rect(); 117 QRect deskR = QApplication::desktop()->rect();
118 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 118 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
119 r.setBottom(deskR.bottom()); 119 r.setBottom(deskR.bottom());
120 r.setRight(deskR.right()); 120 r.setRight(deskR.right());
121 } 121 }
122 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 122 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
123 r.width(), r.height()); 123 r.width(), r.height());
124 } 124 }
125 else{ // tear off menu 125 else{ // tear off menu
126 pix->resize(p->width(), p->height()); 126 pix->resize(p->width(), p->height());
127 pix->fill(Qt::black.rgb()); 127 pix->fill(Qt::black.rgb());
128 } 128 }
129 if(type == TransStippleBg){ 129 if(type == TransStippleBg){
130 stripePixmap(*pix, p->colorGroup().background()); 130 stripePixmap(*pix, p->colorGroup().background());
131 } 131 }
132 else if(type == TransStippleBtn){ 132 else if(type == TransStippleBtn){
133 stripePixmap(*pix, p->colorGroup().button()); 133 stripePixmap(*pix, p->colorGroup().button());
134 } 134 }
135 else{ 135 else{
136 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 136 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
137 } 137 }
138 138
139 pixDict.insert(p->winId(), pix); 139 pixDict.insert(p->winId(), pix);
140 140
141 if ( !p->inherits("QPopupMenu")) 141 if ( !p->inherits("QPopupMenu"))
142 p->setBackgroundPixmap(*pix); 142 p->setBackgroundPixmap(*pix);
143 143
144 QObjectList *ol = p-> queryList("QWidget"); 144 QObjectList *ol = p-> queryList("QWidget");
145 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 145 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
146 QWidget *wid = (QWidget *) it.current ( ); 146 QWidget *wid = (QWidget *) it.current ( );
147 147
148 wid-> setBackgroundPixmap(*pix); 148 wid-> setBackgroundPixmap(*pix);
149 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 149 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
150 } 150 }
151 delete ol; 151 delete ol;
152 } 152 }
153 } 153 }
154 else if(ev->type() == QEvent::Hide){ 154 else if(ev->type() == QEvent::Hide){
155 if(type == TransStippleBg || type == TransStippleBtn || 155 if(type == TransStippleBg || type == TransStippleBtn ||
156 type == Custom){ 156 type == Custom){
157// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl; 157// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
158 158
159 pixDict.remove(p->winId()); 159 pixDict.remove(p->winId());
160 if ( !p->inherits("QPopupMenu")) 160 if ( !p->inherits("QPopupMenu"))
161 p->setBackgroundMode(QWidget::PaletteBackground); 161 p->setBackgroundMode(QWidget::PaletteBackground);
162 162
163 QObjectList *ol = p-> queryList("QWidget"); 163 QObjectList *ol = p-> queryList("QWidget");
164 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 164 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
165 QWidget *wid = (QWidget *) it.current ( ); 165 QWidget *wid = (QWidget *) it.current ( );
166 166
167 wid-> setBackgroundMode( QWidget::PaletteBackground ); 167 wid-> setBackgroundMode( QWidget::PaletteBackground );
168 } 168 }
169 delete ol; 169 delete ol;
170 } 170 }
171 } 171 }
172 return(false); 172 return(false);
173} 173}
174 174
175 175
176 176
177 177
178LiquidStyle::LiquidStyle() 178LiquidStyle::LiquidStyle()
179 :QWindowsStyle() 179 :QWindowsStyle()
180{ 180{
181 setName ( "LiquidStyle" ); 181 setName ( "LiquidStyle" );
182 182
183 flatTBButtons = false; 183 flatTBButtons = false;
184 currentHeader = 0; 184 currentHeader = 0;
185 185
186 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 186 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
187 btnMaskBmp.setMask(btnMaskBmp); 187 btnMaskBmp.setMask(btnMaskBmp);
188 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 188 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
189 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 189 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
190 headerHoverID = -1; 190 headerHoverID = -1;
191 highlightWidget = NULL; 191 highlightWidget = NULL;
192 setButtonDefaultIndicatorWidth(0); 192 setButtonDefaultIndicatorWidth(0);
193 btnDict.setAutoDelete(true); 193 btnDict.setAutoDelete(true);
194 bevelFillDict.setAutoDelete(true); 194 bevelFillDict.setAutoDelete(true);
195 smallBevelFillDict.setAutoDelete(true); 195 smallBevelFillDict.setAutoDelete(true);
196 196
197 rMatrix.rotate(270.0); 197 rMatrix.rotate(270.0);
198 btnBorderPix = new QPixmap; 198 btnBorderPix = new QPixmap;
199 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 199 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
200 btnBlendPix = new QPixmap; 200 btnBlendPix = new QPixmap;
@@ -478,49 +478,49 @@ void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
478 /*if(autoDefault){ 478 /*if(autoDefault){
479 if(supportPushDown && pushedDown){ 479 if(supportPushDown && pushedDown){
480 painter->drawPixmap(x+3, y+3, tmpPix); 480 painter->drawPixmap(x+3, y+3, tmpPix);
481 } 481 }
482 else{ 482 else{
483 painter->drawPixmap(x+2, y+2, tmpPix); 483 painter->drawPixmap(x+2, y+2, tmpPix);
484 } 484 }
485 } 485 }
486 else */if(supportPushDown && pushedDown) 486 else */if(supportPushDown && pushedDown)
487 painter->drawPixmap(x+1, y+1, tmpPix); 487 painter->drawPixmap(x+1, y+1, tmpPix);
488 else 488 else
489 painter->drawPixmap(x, y, tmpPix); 489 painter->drawPixmap(x, y, tmpPix);
490 490
491 491
492 492
493} 493}
494 494
495 495
496QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, 496QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
497 bool blend) 497 bool blend)
498{ 498{
499 QImage img(qembed_findImage(label)); 499 QImage img(qembed_findImage(label));
500 img.detach(); 500 img.detach();
501 if(img.isNull()){ // shouldn't happen, been tested 501 if(img.isNull()){ // shouldn't happen, been tested
502 owarn << "Invalid embedded label " << label << "" << oendl; 502 owarn << "Invalid embedded label " << label << "" << oendl;
503 return(NULL); 503 return(NULL);
504 } 504 }
505 if(img.depth() != 32) 505 if(img.depth() != 32)
506 img = img.convertDepth(32); 506 img = img.convertDepth(32);
507 unsigned int *data = (unsigned int *)img.bits(); 507 unsigned int *data = (unsigned int *)img.bits();
508 int total = img.width()*img.height(); 508 int total = img.width()*img.height();
509 int current; 509 int current;
510 QColor c; 510 QColor c;
511 int oldH, oldS, oldV; 511 int oldH, oldS, oldV;
512 int alpha; 512 int alpha;
513 if(v < 235) 513 if(v < 235)
514 v += 20; 514 v += 20;
515 else 515 else
516 v = 255; 516 v = 255;
517 float intensity = v/255.0; 517 float intensity = v/255.0;
518 518
519 for(current=0; current<total; ++current){ 519 for(current=0; current<total; ++current){
520 alpha = qAlpha(data[current]); 520 alpha = qAlpha(data[current]);
521 c.setRgb(data[current]); 521 c.setRgb(data[current]);
522 c.hsv(&oldH, &oldS, &oldV); 522 c.hsv(&oldH, &oldS, &oldV);
523 oldV = (int)(oldV*intensity); 523 oldV = (int)(oldV*intensity);
524 c.setHsv(h, s, oldV); 524 c.setHsv(h, s, oldV);
525 if(blend && alpha != 255 && alpha != 0){ 525 if(blend && alpha != 255 && alpha != 0){
526 float srcPercent = ((float)alpha)/255.0; 526 float srcPercent = ((float)alpha)/255.0;
@@ -578,52 +578,52 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
578 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 578 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
579 break; 579 break;
580 case HTMLRadioDownHover: 580 case HTMLRadioDownHover:
581 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV); 581 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV);
582 break; 582 break;
583 583
584 case RadioOff: 584 case RadioOff:
585 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/); 585 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/);
586 break; 586 break;
587 case RadioOffHover: 587 case RadioOffHover:
588 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/); 588 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/);
589 break; 589 break;
590 case RadioOn: 590 case RadioOn:
591 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/); 591 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
592 break; 592 break;
593 case RadioOnHover: 593 case RadioOnHover:
594 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/); 594 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
595 break; 595 break;
596 596
597 case Tab: 597 case Tab:
598 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/); 598 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
599 break; 599 break;
600 case TabDown: 600 case TabDown:
601 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/); 601 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
602 break; 602 break;
603 case TabFocus: 603 case TabFocus:
604 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/); 604 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
605 break; 605 break;
606 606
607 case CB: 607 case CB:
608 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); 608 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
609 break; 609 break;
610 case CBHover: 610 case CBHover:
611 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/); 611 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
612 break; 612 break;
613 case CBDown: 613 case CBDown:
614 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/); 614 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
615 break; 615 break;
616 case CBDownHover: 616 case CBDownHover:
617 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/); 617 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
618 break; 618 break;
619 619
620 case VSlider: 620 case VSlider:
621 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true ); 621 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true );
622 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 622 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
623 break; 623 break;
624 case VSBSliderTop: 624 case VSBSliderTop:
625 case VSBSliderTopHover: 625 case VSBSliderTopHover:
626 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/); 626 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/);
627 break; 627 break;
628 case VSBSliderBtm: 628 case VSBSliderBtm:
629 case VSBSliderBtmHover: 629 case VSBSliderBtmHover:
@@ -780,58 +780,58 @@ void LiquidStyle::polish(QPalette &appPal)
780 painter.drawLine(0, i+1, 32, i+1); 780 painter.drawLine(0, i+1, 32, i+1);
781 }; 781 };
782 painter.end(); 782 painter.end();
783 bgBrush.setColor(c); 783 bgBrush.setColor(c);
784 bgBrush.setPixmap(wallPaper); 784 bgBrush.setPixmap(wallPaper);
785 appPal.setBrush(QColorGroup::Background, bgBrush); 785 appPal.setBrush(QColorGroup::Background, bgBrush);
786} 786}
787 787
788void LiquidStyle::polish(QWidget *w) 788void LiquidStyle::polish(QWidget *w)
789{ 789{
790 if(w->inherits("QMenuBar")){ 790 if(w->inherits("QMenuBar")){
791 //((QFrame*)w)->setLineWidth(0); 791 //((QFrame*)w)->setLineWidth(0);
792 w->setBackgroundMode(QWidget::PaletteBackground); 792 w->setBackgroundMode(QWidget::PaletteBackground);
793 w->setBackgroundOrigin(QWidget::ParentOrigin); 793 w->setBackgroundOrigin(QWidget::ParentOrigin);
794 return; 794 return;
795 } 795 }
796 if(w->inherits("QToolBar")){ 796 if(w->inherits("QToolBar")){
797 w->installEventFilter(this); 797 w->installEventFilter(this);
798 w->setBackgroundMode(QWidget::PaletteBackground); 798 w->setBackgroundMode(QWidget::PaletteBackground);
799 w->setBackgroundOrigin(QWidget::WidgetOrigin); 799 w->setBackgroundOrigin(QWidget::WidgetOrigin);
800 return; 800 return;
801 } 801 }
802 if(w->inherits("QPopupMenu")) 802 if(w->inherits("QPopupMenu"))
803 w->setBackgroundMode(QWidget::NoBackground); 803 w->setBackgroundMode(QWidget::NoBackground);
804 else if(w-> testWFlags(Qt::WType_Popup) && 804 else if(w-> testWFlags(Qt::WType_Popup) &&
805 !w->inherits("QListBox") && 805 !w->inherits("QListBox") &&
806 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 806 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
807 w->installEventFilter(menuHandler); 807 w->installEventFilter(menuHandler);
808 } 808 }
809 809
810 if(w->isTopLevel()){ 810 if(w->isTopLevel()){
811 return; 811 return;
812 } 812 }
813 813
814 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 814 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
815 w->installEventFilter(this); 815 w->installEventFilter(this);
816 } 816 }
817 817
818 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 818 if(w->inherits("QButton") || w-> inherits("QComboBox")){
819 w-> setBackgroundMode ( QWidget::PaletteBackground ); 819 w-> setBackgroundMode ( QWidget::PaletteBackground );
820 w->setBackgroundOrigin ( QWidget::ParentOrigin); 820 w->setBackgroundOrigin ( QWidget::ParentOrigin);
821 } 821 }
822 822
823 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 823 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
824 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 824 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
825 bool isViewportChild = w->parent() && 825 bool isViewportChild = w->parent() &&
826 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 826 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
827 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 827 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
828 828
829 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 829 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
830 w->setBackgroundMode(QWidget::X11ParentRelative); 830 w->setBackgroundMode(QWidget::X11ParentRelative);
831 return; 831 return;
832 } 832 }
833 if(isViewportChild){ 833 if(isViewportChild){
834 if(w->inherits("QButton") || w->inherits("QComboBox")){ 834 if(w->inherits("QButton") || w->inherits("QComboBox")){
835 if(w->parent()){ // heh, only way to test for KHTML children ;-) 835 if(w->parent()){ // heh, only way to test for KHTML children ;-)
836 if(w->parent()->parent()){ 836 if(w->parent()->parent()){
837 if(w->parent()->parent()->parent() && 837 if(w->parent()->parent()->parent() &&
@@ -844,81 +844,81 @@ void LiquidStyle::polish(QWidget *w)
844 return; 844 return;
845 } 845 }
846 } 846 }
847 if(w->inherits("QHeader")){ 847 if(w->inherits("QHeader")){
848 w->setMouseTracking(true); 848 w->setMouseTracking(true);
849 w->installEventFilter(this); 849 w->installEventFilter(this);
850 } 850 }
851 if(w-> inherits("QToolButton")) { 851 if(w-> inherits("QToolButton")) {
852 if (w->parent()->inherits("QToolBar")) { 852 if (w->parent()->inherits("QToolBar")) {
853 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 853 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
854 if ( flatTBButtons ) 854 if ( flatTBButtons )
855 w->setBackgroundOrigin(QWidget::ParentOrigin); 855 w->setBackgroundOrigin(QWidget::ParentOrigin);
856 } 856 }
857 w-> installEventFilter ( this ); 857 w-> installEventFilter ( this );
858 } 858 }
859 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { 859 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
860 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); 860 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
861 } 861 }
862 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 862 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
863 return; 863 return;
864 } 864 }
865 865
866 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 866 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
867 palette().active().brush(QColorGroup::Background).pixmap()){ 867 palette().active().brush(QColorGroup::Background).pixmap()){
868 owarn << "No parent pixmap for child widget " << w->className() << "" << oendl; 868 owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
869 return; 869 return;
870 } 870 }
871 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 871 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
872 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 872 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
873 if(w->backgroundMode() == QWidget::PaletteBackground || 873 if(w->backgroundMode() == QWidget::PaletteBackground ||
874 w->backgroundMode() == QWidget::PaletteButton){ 874 w->backgroundMode() == QWidget::PaletteButton){
875 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); 875 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
876 w->setBackgroundOrigin(QWidget::ParentOrigin); 876 w->setBackgroundOrigin(QWidget::ParentOrigin);
877 // w->setBackgroundMode(QWidget::NoBackground); 877 // w->setBackgroundMode(QWidget::NoBackground);
878 } 878 }
879 } 879 }
880 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 880 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
881 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 881 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
882 else if ( w-> inherits("QFrame") ) 882 else if ( w-> inherits("QFrame") )
883 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 883 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
884 884
885 if ( w->parentWidget()->inherits ( "QWidgetStack" )) { 885 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
886 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 886 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
887 } 887 }
888} 888}
889 889
890void LiquidStyle::unPolish(QWidget *w) 890void LiquidStyle::unPolish(QWidget *w)
891{ 891{
892 if(w->inherits("QMenuBar")){ 892 if(w->inherits("QMenuBar")){
893 ((QFrame *)w)->setLineWidth(1); 893 ((QFrame *)w)->setLineWidth(1);
894 w->setBackgroundMode(QWidget::PaletteBackground); 894 w->setBackgroundMode(QWidget::PaletteBackground);
895 return; 895 return;
896 } 896 }
897 897
898 if(w->inherits("QPopupMenu")) 898 if(w->inherits("QPopupMenu"))
899 w->setBackgroundMode(QWidget::PaletteButton); 899 w->setBackgroundMode(QWidget::PaletteButton);
900 else if(w-> testWFlags(Qt::WType_Popup) && 900 else if(w-> testWFlags(Qt::WType_Popup) &&
901 !w->inherits("QListBox") && 901 !w->inherits("QListBox") &&
902 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 902 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
903 w->removeEventFilter(menuHandler); 903 w->removeEventFilter(menuHandler);
904 } 904 }
905 905
906 if(w->isTopLevel()) 906 if(w->isTopLevel())
907 return; 907 return;
908 908
909 // for viewport children, don't just check for NoBackground.... 909 // for viewport children, don't just check for NoBackground....
910 bool isViewportChild = w->parent() && 910 bool isViewportChild = w->parent() &&
911 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 911 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
912 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 912 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
913 913
914 w->unsetPalette(); 914 w->unsetPalette();
915 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 915 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
916 if(w->inherits("QPushButton")) 916 if(w->inherits("QPushButton"))
917 w->setBackgroundMode(QWidget::PaletteButton); 917 w->setBackgroundMode(QWidget::PaletteButton);
918 else 918 else
919 w->setBackgroundMode(QWidget::PaletteBackground); 919 w->setBackgroundMode(QWidget::PaletteBackground);
920 } 920 }
921 921
922 if(isViewportChild) 922 if(isViewportChild)
923 w->setAutoMask(false); 923 w->setAutoMask(false);
924 924
@@ -938,228 +938,228 @@ void LiquidStyle::unPolish(QWidget *w)
938 if(w-> inherits("QToolButton")) { 938 if(w-> inherits("QToolButton")) {
939 w-> removeEventFilter ( this ); 939 w-> removeEventFilter ( this );
940 } 940 }
941 if(w->inherits("QToolBar")){ 941 if(w->inherits("QToolBar")){
942 w->removeEventFilter(this); 942 w->removeEventFilter(this);
943 w->setBackgroundMode(QWidget::PaletteBackground); 943 w->setBackgroundMode(QWidget::PaletteBackground);
944 return; 944 return;
945 } 945 }
946 if(w->inherits("QHeader")){ 946 if(w->inherits("QHeader")){
947 w->setMouseTracking(false); 947 w->setMouseTracking(false);
948 w->removeEventFilter(this); 948 w->removeEventFilter(this);
949 } 949 }
950} 950}
951 951
952void LiquidStyle::polish(QApplication *app) 952void LiquidStyle::polish(QApplication *app)
953{ 953{
954 954
955 QWindowsStyle::polish(app); 955 QWindowsStyle::polish(app);
956 menuAni = app->isEffectEnabled(UI_AnimateMenu); 956 menuAni = app->isEffectEnabled(UI_AnimateMenu);
957 menuFade = app->isEffectEnabled(UI_FadeMenu); 957 menuFade = app->isEffectEnabled(UI_FadeMenu);
958 if(menuAni) 958 if(menuAni)
959 app->setEffectEnabled(UI_AnimateMenu, false); 959 app->setEffectEnabled(UI_AnimateMenu, false);
960 if(menuFade) 960 if(menuFade)
961 app->setEffectEnabled(UI_FadeMenu, false); 961 app->setEffectEnabled(UI_FadeMenu, false);
962 962
963 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 963 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
964 964
965 Config config ( "qpe" ); 965 Config config ( "qpe" );
966 config. setGroup ( "Liquid-Style" ); 966 config. setGroup ( "Liquid-Style" );
967 967
968 // if ( config. readBoolEntry ( "WinDecoration", true )) 968// if ( config. readBoolEntry ( "WinDecoration", true ))
969 // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); 969 // QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
970 970
971 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); 971 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
972} 972}
973 973
974void LiquidStyle::unPolish(QApplication *app) 974void LiquidStyle::unPolish(QApplication *app)
975{ 975{
976 QWindowsStyle::unPolish(app); 976 QWindowsStyle::unPolish(app);
977 app->setEffectEnabled(UI_AnimateMenu, menuAni); 977 app->setEffectEnabled(UI_AnimateMenu, menuAni);
978 app->setEffectEnabled(UI_FadeMenu, menuFade); 978 app->setEffectEnabled(UI_FadeMenu, menuFade);
979 979
980 qt_set_draw_menu_bar_impl ( 0 ); 980 qt_set_draw_menu_bar_impl ( 0 );
981 981
982// QApplication::qwsSetDecoration ( new QPEDecoration ( )); 982// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
983} 983}
984 984
985 985
986/* !! HACK !! Beware 986/* !! HACK !! Beware
987 * 987 *
988 * TT forgot to make the QProgressBar widget styleable in Qt 2.x 988 * TT forgot to make the QProgressBar widget styleable in Qt 2.x
989 * So the only way to customize the drawing, is to intercept the 989 * So the only way to customize the drawing, is to intercept the
990 * paint event - since we have to use protected functions, we need 990 * paint event - since we have to use protected functions, we need
991 * to derive a "hack" class from QProgressBar and do the painting 991 * to derive a "hack" class from QProgressBar and do the painting
992 * in there. 992 * in there.
993 * 993 *
994 * - sandman 994 * - sandman
995 */ 995 */
996 996
997class HackProgressBar : public QProgressBar { 997class HackProgressBar : public QProgressBar {
998public: 998public:
999 HackProgressBar ( ); 999 HackProgressBar ( );
1000 1000
1001 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) 1001 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix )
1002 { 1002 {
1003 QPainter p( this ); 1003 QPainter p( this );
1004 1004
1005 if ( !contentsRect().contains( event->rect() ) ) { 1005 if ( !contentsRect().contains( event->rect() ) ) {
1006 p.save(); 1006 p.save();
1007 p.setClipRegion( event->region().intersect(frameRect()) ); 1007 p.setClipRegion( event->region().intersect(frameRect()) );
1008 drawFrame( &p); 1008 drawFrame( &p);
1009 p.restore(); 1009 p.restore();
1010 } 1010 }
1011 if ( event->rect().intersects( contentsRect() )) { 1011 if ( event->rect().intersects( contentsRect() )) {
1012 p.setClipRegion( event->region().intersect( contentsRect() ) ); 1012 p.setClipRegion( event->region().intersect( contentsRect() ) );
1013 1013
1014 int x, y, w, h; 1014 int x, y, w, h;
1015 contentsRect ( ). rect ( &x, &y, &w, &h ); 1015 contentsRect ( ). rect ( &x, &y, &w, &h );
1016 1016
1017 int prog = progress ( ); 1017 int prog = progress ( );
1018 int total = totalSteps ( ); 1018 int total = totalSteps ( );
1019 if ( prog < 0 ) 1019 if ( prog < 0 )
1020 prog = 0; 1020 prog = 0;
1021 if ( total <= 0 ) 1021 if ( total <= 0 )
1022 total = 1; 1022 total = 1;
1023 int bw = w * prog / total; 1023 int bw = w * prog / total;
1024 if ( bw > w ) 1024 if ( bw > w )
1025 bw = w; 1025 bw = w;
1026 1026
1027 p.setPen(g.button().dark(130)); 1027 p.setPen(g.button().dark(130));
1028 p.drawRect(x, y, bw, h); 1028 p.drawRect(x, y, bw, h);
1029 p.setPen(g.button().light(120)); 1029 p.setPen(g.button().light(120));
1030 p.drawRect(x+1, y+1, bw-2, h-2); 1030 p.drawRect(x+1, y+1, bw-2, h-2);
1031 1031
1032 if(bw >= 4 && h >= 4 && pix) 1032 if(bw >= 4 && h >= 4 && pix)
1033 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); 1033 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
1034 1034
1035 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { 1035 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
1036 QString pstr; 1036 QString pstr;
1037 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); 1037 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
1038 p. setPen ( g.text());//g.highlightedText ( )); 1038 p. setPen ( g.text());//g.highlightedText ( ));
1039 p. drawText (x,y,w-1,h-1,AlignCenter,pstr); 1039 p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
1040 } 1040 }
1041 } 1041 }
1042 } 1042 }
1043}; 1043};
1044 1044
1045 1045
1046/* 1046/*
1047 * The same for QToolButton: 1047 * The same for QToolButton:
1048 * TT hardcoded the drawing of the focus rect ... 1048 * TT hardcoded the drawing of the focus rect ...
1049 * 1049 *
1050 * - sandman 1050 * - sandman
1051 */ 1051 */
1052 1052
1053 1053
1054class HackToolButton : public QToolButton { 1054class HackToolButton : public QToolButton {
1055public: 1055public:
1056 HackToolButton ( ); 1056 HackToolButton ( );
1057 1057
1058 void paint ( QPaintEvent *ev ) 1058 void paint ( QPaintEvent *ev )
1059 { 1059 {
1060 erase ( ev-> region ( )); 1060 erase ( ev-> region ( ));
1061 QPainter p ( this ); 1061 QPainter p ( this );
1062 style ( ). drawToolButton ( this, &p ); 1062 style ( ). drawToolButton ( this, &p );
1063 drawButtonLabel ( &p ); 1063 drawButtonLabel ( &p );
1064 } 1064 }
1065}; 1065};
1066 1066
1067/* 1067/*
1068 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1068 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1069 * force everything to erase and repaint on resize. This is going away, I'm 1069 * force everything to erase and repaint on resize. This is going away, I'm
1070 * trying to get shaped widgets to work right without masking. QPushButton, 1070 * trying to get shaped widgets to work right without masking. QPushButton,
1071 * QComboBox, and Panel applet handles capture mouse enter and leaves in order 1071 * QComboBox, and Panel applet handles capture mouse enter and leaves in order
1072 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and 1072 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
1073 * RadioButtons need to do this differently. Qt buffers these in pixmaps and 1073 * RadioButtons need to do this differently. Qt buffers these in pixmaps and
1074 * caches them in QPixmapCache, which is bad for doing things like hover 1074 * caches them in QPixmapCache, which is bad for doing things like hover
1075 * because the style methods aren't called in paintEvents if everything 1075 * because the style methods aren't called in paintEvents if everything
1076 * is cached. We use our own Paint event handler instead. Taskbuttons and 1076 * is cached. We use our own Paint event handler instead. Taskbuttons and
1077 * pager buttons draw into a pixmap buffer, so we handle those with palette 1077 * pager buttons draw into a pixmap buffer, so we handle those with palette
1078 * modifications. For QHeader, different header items are actually one widget 1078 * modifications. For QHeader, different header items are actually one widget
1079 * that draws multiple items, so we need to check which ID is hightlighted 1079 * that draws multiple items, so we need to check which ID is hightlighted
1080 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1080 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1081 * since if it's inside a combobox we want to highlight the combobox during 1081 * since if it's inside a combobox we want to highlight the combobox during
1082 * hovering in the edit. 1082 * hovering in the edit.
1083 */ 1083 */
1084bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1084bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1085{ 1085{
1086 if(obj->inherits("QToolBar")){ 1086 if(obj->inherits("QToolBar")){
1087 if(ev->type() == QEvent::Resize){ 1087 if(ev->type() == QEvent::Resize){
1088 const QObjectList *tbChildList = obj->children(); 1088 const QObjectList *tbChildList = obj->children();
1089 QObjectListIt it(*tbChildList); 1089 QObjectListIt it(*tbChildList);
1090 QObject *child; 1090 QObject *child;
1091 while((child = it.current()) != NULL){ 1091 while((child = it.current()) != NULL){
1092 ++it; 1092 ++it;
1093 if(child->isWidgetType()) 1093 if(child->isWidgetType())
1094 ((QWidget *)child)->repaint(true); 1094 ((QWidget *)child)->repaint(true);
1095 } 1095 }
1096 1096
1097 } 1097 }
1098 } 1098 }
1099 else if(obj->inherits("QToolButton")){ 1099 else if(obj->inherits("QToolButton")){
1100 QToolButton *btn = (QToolButton *)obj; 1100 QToolButton *btn = (QToolButton *)obj;
1101 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () 1101 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
1102 if(btn->isEnabled()){ 1102 if(btn->isEnabled()){
1103 highlightWidget = btn; 1103 highlightWidget = btn;
1104 btn->repaint(false); 1104 btn->repaint(false);
1105 } 1105 }
1106 } 1106 }
1107 else if(ev->type() == QEvent::FocusOut ){ 1107 else if(ev->type() == QEvent::FocusOut ){
1108 if(btn == highlightWidget){ 1108 if(btn == highlightWidget){
1109 highlightWidget = NULL; 1109 highlightWidget = NULL;
1110 btn->repaint(false); 1110 btn->repaint(false);
1111 } 1111 }
1112 } 1112 }
1113 else if(ev->type() == QEvent::Paint) { 1113 else if(ev->type() == QEvent::Paint) {
1114 (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); 1114 (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev );
1115 return true; 1115 return true;
1116 } 1116 }
1117 } 1117 }
1118 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ 1118 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
1119 QButton *btn = (QButton *)obj; 1119 QButton *btn = (QButton *)obj;
1120 bool isRadio = obj->inherits("QRadioButton"); 1120 bool isRadio = obj->inherits("QRadioButton");
1121 if(ev->type() == QEvent::Paint){ 1121 if(ev->type() == QEvent::Paint){
1122 //if(btn->autoMask()) 1122 //if(btn->autoMask())
1123 btn->erase(); 1123 btn->erase();
1124 QPainter p; 1124 QPainter p;
1125 p.begin(btn); 1125 p.begin(btn);
1126 QFontMetrics fm = btn->fontMetrics(); 1126 QFontMetrics fm = btn->fontMetrics();
1127 QSize lsz = fm.size(ShowPrefix, btn->text()); 1127 QSize lsz = fm.size(ShowPrefix, btn->text());
1128 QSize sz = isRadio ? exclusiveIndicatorSize() 1128 QSize sz = isRadio ? exclusiveIndicatorSize()
1129 : indicatorSize(); 1129 : indicatorSize();
1130 1130
1131/* 1131/*
1132 if(btn->hasFocus()){ 1132 if(btn->hasFocus()){
1133 QRect r = QRect(0, 0, btn->width(), btn->height()); 1133 QRect r = QRect(0, 0, btn->width(), btn->height());
1134 p.setPen(btn->colorGroup().button().dark(140)); 1134 p.setPen(btn->colorGroup().button().dark(140));
1135 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1135 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1136 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1136 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1137 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1137 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1138 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1138 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1139 } 1139 }
1140*/ 1140*/
1141 int x = 0; 1141 int x = 0;
1142 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1142 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1143 if(isRadio) 1143 if(isRadio)
1144 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1144 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1145 btn->colorGroup(), btn->isOn(), 1145 btn->colorGroup(), btn->isOn(),
1146 btn->isDown(), btn->isEnabled()); 1146 btn->isDown(), btn->isEnabled());
1147 else 1147 else
1148 drawIndicator(&p, x, y, sz.width(), sz.height(), 1148 drawIndicator(&p, x, y, sz.width(), sz.height(),
1149 btn->colorGroup(), btn->state(), btn->isDown(), 1149 btn->colorGroup(), btn->state(), btn->isDown(),
1150 btn->isEnabled()); 1150 btn->isEnabled());
1151 x = sz.width() + 6; 1151 x = sz.width() + 6;
1152 y = 0; 1152 y = 0;
1153 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), 1153 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
1154 btn->height(), AlignLeft|AlignVCenter|ShowPrefix, 1154 btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
1155 btn->colorGroup(), btn->isEnabled(), 1155 btn->colorGroup(), btn->isEnabled(),
1156 btn->pixmap(), btn->text()); 1156 btn->pixmap(), btn->text());
1157 p.end(); 1157 p.end();
1158 return(true); 1158 return(true);
1159 } 1159 }
1160 } 1160 }
1161 else if(obj->inherits("QHeader")){ 1161 else if(obj->inherits("QHeader")){
1162 QHeader *hw = (QHeader *)obj; 1162 QHeader *hw = (QHeader *)obj;
1163 if(ev->type() == QEvent::Enter){ 1163 if(ev->type() == QEvent::Enter){
1164 currentHeader = hw; 1164 currentHeader = hw;
1165 headerHoverID = -1; 1165 headerHoverID = -1;
@@ -1172,61 +1172,61 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1172 } 1172 }
1173 headerHoverID = -1; 1173 headerHoverID = -1;
1174 } 1174 }
1175 else if(ev->type() == QEvent::MouseMove){ 1175 else if(ev->type() == QEvent::MouseMove){
1176 QMouseEvent *me = (QMouseEvent *)ev; 1176 QMouseEvent *me = (QMouseEvent *)ev;
1177 int oldHeader = headerHoverID; 1177 int oldHeader = headerHoverID;
1178 headerHoverID = hw->sectionAt(me->x()); 1178 headerHoverID = hw->sectionAt(me->x());
1179 if(oldHeader != headerHoverID){ 1179 if(oldHeader != headerHoverID){
1180 // reset old header 1180 // reset old header
1181 if(oldHeader != -1){ 1181 if(oldHeader != -1){
1182 hw->repaint(hw->sectionPos(oldHeader), 0, 1182 hw->repaint(hw->sectionPos(oldHeader), 0,
1183 hw->sectionSize(oldHeader), hw->height()); 1183 hw->sectionSize(oldHeader), hw->height());
1184 } 1184 }
1185 if(headerHoverID != -1){ 1185 if(headerHoverID != -1){
1186 hw->repaint(hw->sectionPos(headerHoverID), 0, 1186 hw->repaint(hw->sectionPos(headerHoverID), 0,
1187 hw->sectionSize(headerHoverID), hw->height()); 1187 hw->sectionSize(headerHoverID), hw->height());
1188 } 1188 }
1189 } 1189 }
1190 } 1190 }
1191 } 1191 }
1192 else if (obj-> inherits( "QProgressBar" )) { 1192 else if (obj-> inherits( "QProgressBar" )) {
1193 if ( ev->type() == QEvent::Paint ) { 1193 if ( ev->type() == QEvent::Paint ) {
1194 HackProgressBar *p = (HackProgressBar *) obj; 1194 HackProgressBar *p = (HackProgressBar *) obj;
1195 const QColorGroup &g = p-> colorGroup ( ); 1195 const QColorGroup &g = p-> colorGroup ( );
1196 1196
1197 QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); 1197 QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb());
1198 if(!pix){ 1198 if(!pix){
1199 int h, s, v; 1199 int h, s, v;
1200 g.button().dark(120).hsv(&h, &s, &v); 1200 g.button().dark(120).hsv(&h, &s, &v);
1201 pix = new QPixmap(*bevelFillPix); 1201 pix = new QPixmap(*bevelFillPix);
1202 adjustHSV(*pix, h, s, v); 1202 adjustHSV(*pix, h, s, v);
1203 bevelFillDict.insert(g.button().dark(120).rgb(), pix); 1203 bevelFillDict.insert(g.button().dark(120).rgb(), pix);
1204 } 1204 }
1205 p-> paint ((QPaintEvent *) ev, g, pix ); 1205 p-> paint ((QPaintEvent *) ev, g, pix );
1206 return true; 1206 return true;
1207 } 1207 }
1208 } 1208 }
1209 return false ; 1209 return false ;
1210} 1210}
1211 1211
1212void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, 1212void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
1213 const QColorGroup &g, bool sunken, 1213 const QColorGroup &g, bool sunken,
1214 const QBrush *) 1214 const QBrush *)
1215{ 1215{
1216 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), 1216 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
1217 x, y, w, h); 1217 x, y, w, h);
1218} 1218}
1219 1219
1220void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, 1220void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
1221 const QColorGroup &g, bool sunken, 1221 const QColorGroup &g, bool sunken,
1222 const QBrush *) 1222 const QBrush *)
1223{ 1223{
1224 if(p->device()->devType() != QInternal::Widget){ 1224 if(p->device()->devType() != QInternal::Widget){
1225 // drawing into a temp pixmap, don't use mask 1225 // drawing into a temp pixmap, don't use mask
1226 QColor c = sunken ? g.button() : g.background(); 1226 QColor c = sunken ? g.button() : g.background();
1227 p->setPen(c.dark(130)); 1227 p->setPen(c.dark(130));
1228 p->drawRect(x, y, w, h); 1228 p->drawRect(x, y, w, h);
1229 p->setPen(c.light(105)); 1229 p->setPen(c.light(105));
1230 p->drawRect(x+1, y+1, w-2, h-2); 1230 p->drawRect(x+1, y+1, w-2, h-2);
1231 1231
1232 1232
@@ -1282,57 +1282,61 @@ void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
1282 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), 1282 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
1283 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), 1283 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
1284 btn->autoMask()); 1284 btn->autoMask());
1285} 1285}
1286 1286
1287void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) 1287void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
1288{ 1288{
1289 int x1, y1, x2, y2, w, h; 1289 int x1, y1, x2, y2, w, h;
1290 btn->rect().coords(&x1, &y1, &x2, &y2); 1290 btn->rect().coords(&x1, &y1, &x2, &y2);
1291 w = btn->width(); 1291 w = btn->width();
1292 h = btn->height(); 1292 h = btn->height();
1293 1293
1294 bool act = btn->isOn() || btn->isDown(); 1294 bool act = btn->isOn() || btn->isDown();
1295 if(act){ 1295 if(act){
1296 ++x1, ++y1; 1296 ++x1, ++y1;
1297 } 1297 }
1298 1298
1299 // Draw iconset first, if any 1299 // Draw iconset first, if any
1300 if ( btn->iconSet() && !btn->iconSet()->isNull() ) 1300 if ( btn->iconSet() && !btn->iconSet()->isNull() )
1301 { 1301 {
1302 QIconSet::Mode mode = btn->isEnabled() 1302 QIconSet::Mode mode = btn->isEnabled()
1303 ? QIconSet::Normal : QIconSet::Disabled; 1303 ? QIconSet::Normal : QIconSet::Disabled;
1304 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1304 if ( mode == QIconSet::Normal && btn->hasFocus() )
1305 mode = QIconSet::Active; 1305 mode = QIconSet::Active;
1306 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); 1306 QPixmap pixmap;
1307 if ( mode == QIconSet::Disabled )
1308 pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
1309 else
1310 pixmap = btn->iconSet()->pixmap();
1307 int pixw = pixmap.width(); 1311 int pixw = pixmap.width();
1308 int pixh = pixmap.height(); 1312 int pixh = pixmap.height();
1309 1313
1310 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); 1314 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
1311 x1 += pixw + 8; 1315 x1 += pixw + 8;
1312 w -= pixw + 8; 1316 w -= pixw + 8;
1313 } 1317 }
1314 1318
1315 if(act){ 1319 if(act){
1316 QFont font = btn->font(); 1320 QFont font = btn->font();
1317 font.setBold(true); 1321 font.setBold(true);
1318 p->setFont(font); 1322 p->setFont(font);
1319 QColor shadow(btn->colorGroup().button().dark(130)); 1323 QColor shadow(btn->colorGroup().button().dark(130));
1320 drawItem( p, x1+1, y1+1, w, h, 1324 drawItem( p, x1+1, y1+1, w, h,
1321 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1325 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1322 btn->pixmap(), btn->text(), -1, 1326 btn->pixmap(), btn->text(), -1,
1323 &shadow); 1327 &shadow);
1324 1328
1325 drawItem( p, x1, y1, w, h, 1329 drawItem( p, x1, y1, w, h,
1326 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1330 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1327 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); 1331 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
1328 } 1332 }
1329 else{ 1333 else{
1330 /* Too blurry 1334 /* Too blurry
1331 drawItem( p, x1+1, y1+1, w, h, 1335 drawItem( p, x1+1, y1+1, w, h,
1332 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1336 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1333 btn->pixmap(), btn->text(), -1, 1337 btn->pixmap(), btn->text(), -1,
1334 &btn->colorGroup().button().dark(115)); 1338 &btn->colorGroup().button().dark(115));
1335 */ 1339 */
1336 drawItem( p, x1, y1, w, h, 1340 drawItem( p, x1, y1, w, h,
1337 AlignCenter | ShowPrefix, 1341 AlignCenter | ShowPrefix,
1338 btn->colorGroup(), btn->isEnabled(), 1342 btn->colorGroup(), btn->isEnabled(),
@@ -1384,61 +1388,61 @@ void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
1384 drawClearBevel(p, x, y, w, h, sunken ? 1388 drawClearBevel(p, x, y, w, h, sunken ?
1385 g.button() : isHeaderHover ? g.button().light(110) : 1389 g.button() : isHeaderHover ? g.button().light(110) :
1386 g.background(), g.background()); 1390 g.background(), g.background());
1387 } 1391 }
1388 else 1392 else
1389 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), 1393 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
1390 g.background()); 1394 g.background());
1391} 1395}
1392 1396
1393QRect LiquidStyle::buttonRect(int x, int y, int w, int h) 1397QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
1394{ 1398{
1395 return(QRect(x+5, y+5, w-10, h-10)); 1399 return(QRect(x+5, y+5, w-10, h-10));
1396} 1400}
1397 1401
1398void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, 1402void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1399 const QColorGroup &g, bool sunken, 1403 const QColorGroup &g, bool sunken,
1400 bool edit, bool, const QBrush *) 1404 bool edit, bool, const QBrush *)
1401{ 1405{
1402 bool isActive = false; 1406 bool isActive = false;
1403 if (( painter->device()->devType() == QInternal::Widget ) && 1407 if (( painter->device()->devType() == QInternal::Widget ) &&
1404 ( 1408 (
1405 ( qApp-> focusWidget ( ) == painter-> device ( )) || 1409 ( qApp-> focusWidget ( ) == painter-> device ( )) ||
1406 ( 1410 (
1407 edit && 1411 edit &&
1408 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && 1412 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
1409 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) || 1413 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
1410 qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( )) 1414 qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
1411 ) 1415 )
1412 ) 1416 )
1413 ) { 1417 ) {
1414 isActive = true; 1418 isActive = true;
1415 } 1419 }
1416 1420
1417 bool isMasked = false; 1421 bool isMasked = false;
1418 if(painter->device()->devType() == QInternal::Widget) 1422 if(painter->device()->devType() == QInternal::Widget)
1419 isMasked = ((QWidget*)painter->device())->autoMask(); 1423 isMasked = ((QWidget*)painter->device())->autoMask();
1420 // TODO: Do custom code, don't just call drawRoundButton into a pixmap 1424 // TODO: Do custom code, don't just call drawRoundButton into a pixmap
1421 QPixmap tmpPix(w, h); 1425 QPixmap tmpPix(w, h);
1422 QPainter p(&tmpPix); 1426 QPainter p(&tmpPix);
1423 1427
1424 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, 1428 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
1425 sunken, false, isMasked); 1429 sunken, false, isMasked);
1426 if(!isActive){ 1430 if(!isActive){
1427 p.setClipRect(0, 0, w-17, h); 1431 p.setClipRect(0, 0, w-17, h);
1428 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, 1432 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
1429 sunken, false, isMasked); 1433 sunken, false, isMasked);
1430 } 1434 }
1431 p.end(); 1435 p.end();
1432 int x2 = x+w-1; 1436 int x2 = x+w-1;
1433 int y2 = y+h-1; 1437 int y2 = y+h-1;
1434 int bx2 = btnMaskBmp.width()-1; 1438 int bx2 = btnMaskBmp.width()-1;
1435 int by2 = btnMaskBmp.height()-1; 1439 int by2 = btnMaskBmp.height()-1;
1436 QBitmap btnMask(w, h); 1440 QBitmap btnMask(w, h);
1437 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 1441 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
1438 p.begin(&btnMask); 1442 p.begin(&btnMask);
1439 p.fillRect(0, 0, w, h, Qt::color0); 1443 p.fillRect(0, 0, w, h, Qt::color0);
1440 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 1444 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
1441 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 1445 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
1442 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 1446 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
1443 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 1447 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
1444 // fills 1448 // fills
@@ -1457,49 +1461,49 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1457 painter->setPen(g.mid()); 1461 painter->setPen(g.mid());
1458 painter->drawRect(x+8, y+2, w-25, h-4); 1462 painter->drawRect(x+8, y+2, w-25, h-4);
1459 } 1463 }
1460 int arrow_h = h / 3; 1464 int arrow_h = h / 3;
1461 int arrow_w = arrow_h; 1465 int arrow_w = arrow_h;
1462 int arrow_x = w - arrow_w - 6; 1466 int arrow_x = w - arrow_w - 6;
1463 int arrow_y = (h - arrow_h) / 2; 1467 int arrow_y = (h - arrow_h) / 2;
1464 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); 1468 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true);
1465} 1469}
1466 1470
1467void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) 1471void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
1468{ 1472{
1469 drawButtonMask(p, x, y, w, h); 1473 drawButtonMask(p, x, y, w, h);
1470} 1474}
1471 1475
1472QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) 1476QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
1473{ 1477{
1474 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); 1478 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
1475 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); 1479 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
1476} 1480}
1477 1481
1478QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/) 1482QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
1479{ 1483{
1480 return QRect ( ); 1484 return QRect ( );
1481 1485
1482// return(QRect(x+5, y+3, w-(h/3)-13, h-5)); 1486// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
1483} 1487}
1484 1488
1485void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, 1489void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1486 int sliderStart, uint controls, 1490 int sliderStart, uint controls,
1487 uint activeControl) 1491 uint activeControl)
1488{ 1492{
1489 int sliderMin, sliderMax, sliderLength, buttonDim; 1493 int sliderMin, sliderMax, sliderLength, buttonDim;
1490 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1494 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1491 1495
1492 if (sliderStart > sliderMax) 1496 if (sliderStart > sliderMax)
1493 sliderStart = sliderMax; 1497 sliderStart = sliderMax;
1494 1498
1495 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1499 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1496 QColorGroup g = sb->colorGroup(); 1500 QColorGroup g = sb->colorGroup();
1497 QRect addB, subHC, subB; 1501 QRect addB, subHC, subB;
1498 QRect addPageR, subPageR, sliderR; 1502 QRect addPageR, subPageR, sliderR;
1499 int addX, addY, subX, subY; 1503 int addX, addY, subX, subY;
1500 int len = horiz ? sb->width() : sb->height(); 1504 int len = horiz ? sb->width() : sb->height();
1501 int extent = horiz ? sb->height() : sb->width(); 1505 int extent = horiz ? sb->height() : sb->width();
1502 1506
1503 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar 1507 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
1504 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. 1508 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
1505 bool brokenApp; 1509 bool brokenApp;
@@ -1612,64 +1616,64 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1612 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); 1616 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
1613 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, 1617 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
1614 13, *getPixmap(HSBSliderMidBg)); 1618 13, *getPixmap(HSBSliderMidBg));
1615 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, 1619 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
1616 0, 0, 8, 13); 1620 0, 0, 8, 13);
1617 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); 1621 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
1618 } 1622 }
1619 else{ 1623 else{
1620 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, 1624 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
1621 *getPixmap(HSBSliderMidBg)); 1625 *getPixmap(HSBSliderMidBg));
1622 painter.setPen(g.background().dark(210)); 1626 painter.setPen(g.background().dark(210));
1623 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); 1627 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
1624 painter.setPen(g.mid()); 1628 painter.setPen(g.mid());
1625 painter.drawPoint(bgR.x(), bgR.y()+1); 1629 painter.drawPoint(bgR.x(), bgR.y()+1);
1626 painter.drawPoint(bgR.x(), bgR.bottom()-1); 1630 painter.drawPoint(bgR.x(), bgR.bottom()-1);
1627 painter.drawPoint(bgR.right()-1, bgR.y()+1); 1631 painter.drawPoint(bgR.right()-1, bgR.y()+1);
1628 painter.drawPoint(bgR.right()-1, bgR.bottom()-1); 1632 painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
1629 } 1633 }
1630 if(controls & Slider){ 1634 if(controls & Slider){
1631 if(sliderR.width() >= 16){ 1635 if(sliderR.width() >= 16){
1632 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1636 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1633 *getPixmap(HSBSliderTop)); 1637 *getPixmap(HSBSliderTop));
1634 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 1638 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
1635 13, *getPixmap(HSBSliderMid)); 1639 13, *getPixmap(HSBSliderMid));
1636 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, 1640 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1637 *getPixmap(HSBSliderBtm)); 1641 *getPixmap(HSBSliderBtm));
1638 } 1642 }
1639 else if(sliderR.width() >= 8){ 1643 else if(sliderR.width() >= 8){
1640 int m = sliderR.width()/2; 1644 int m = sliderR.width()/2;
1641 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1645 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1642 *getPixmap(HSBSliderTop), 0, 0, m, 13); 1646 *getPixmap(HSBSliderTop), 0, 0, m, 13);
1643 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, 1647 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
1644 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); 1648 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
1645 } 1649 }
1646 else{ 1650 else{
1647 painter.setPen(g.button().dark(210)); 1651 painter.setPen(g.button().dark(210));
1648 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, 1652 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
1649 sliderR.width(), 13); 1653 sliderR.width(), 13);
1650 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1654 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1651 sliderR.width()-2, 11, 1655 sliderR.width()-2, 11,
1652 *getPixmap(HSBSliderMid), 0, 1); 1656 *getPixmap(HSBSliderMid), 0, 1);
1653 } 1657 }
1654 } 1658 }
1655 painter.setPen(g.mid()); 1659 painter.setPen(g.mid());
1656 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); 1660 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
1657 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); 1661 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
1658 if(brokenApp && (controls & Slider)){ 1662 if(brokenApp && (controls & Slider)){
1659 painter.setPen(g.background()); 1663 painter.setPen(g.background());
1660 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), 1664 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
1661 bgR.bottom()-1); 1665 bgR.bottom()-1);
1662 } 1666 }
1663 painter.end(); 1667 painter.end();
1664 } 1668 }
1665 1669
1666 if ( controls & AddLine ) { 1670 if ( controls & AddLine ) {
1667 drawSBButton(p, addB, g, activeControl == AddLine); 1671 drawSBButton(p, addB, g, activeControl == AddLine);
1668 drawArrow( p, horiz ? RightArrow : DownArrow, 1672 drawArrow( p, horiz ? RightArrow : DownArrow,
1669 false, addB.x()+4, addB.y()+4, 1673 false, addB.x()+4, addB.y()+4,
1670 addB.width()-8, addB.height()-8, g, !maxed); 1674 addB.width()-8, addB.height()-8, g, !maxed);
1671 } 1675 }
1672 if ( controls & SubLine ) { 1676 if ( controls & SubLine ) {
1673 // drawSBButton(p, subB, g, activeControl == SubLine); 1677 // drawSBButton(p, subB, g, activeControl == SubLine);
1674 // drawArrow( p, horiz ? LeftArrow : UpArrow, 1678 // drawArrow( p, horiz ? LeftArrow : UpArrow,
1675 // false, subB.x()+4, subB.y()+4, 1679 // false, subB.x()+4, subB.y()+4,
@@ -1955,72 +1959,72 @@ void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
1955 1959
1956 QPointArray a; 1960 QPointArray a;
1957 switch(type){ 1961 switch(type){
1958 case Qt::UpArrow: 1962 case Qt::UpArrow:
1959 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); 1963 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow);
1960 break; 1964 break;
1961 case Qt::DownArrow: 1965 case Qt::DownArrow:
1962 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); 1966 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow);
1963 break; 1967 break;
1964 case Qt::LeftArrow: 1968 case Qt::LeftArrow:
1965 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); 1969 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow);
1966 break; 1970 break;
1967 default: 1971 default:
1968 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); 1972 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
1969 break; 1973 break;
1970 } 1974 }
1971 1975
1972 a.translate(x, y); 1976 a.translate(x, y);
1973 p->drawLineSegments(a); 1977 p->drawLineSegments(a);
1974} 1978}
1975 1979
1976 1980
1977void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, 1981void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
1978 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) 1982 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
1979 { 1983{
1980 if(active){ 1984 if(active){
1981 x -= 2; // Bug in Qt/E 1985 x -= 2; // Bug in Qt/E
1982 y -= 2; 1986 y -= 2;
1983 w += 2; 1987 w += 2;
1984 h += 2; 1988 h += 2;
1985 } 1989 }
1986 1990
1987 QWidget *parent = (QWidget *)p->device(); 1991 QWidget *parent = (QWidget *)p->device();
1988 p->setBrushOrigin(parent->pos()); 1992 p->setBrushOrigin(parent->pos());
1989 parent->erase(x, y, w, h); 1993 parent->erase(x, y, w, h);
1990 1994
1991 if(menuHandler->useShadowText()){ 1995 if(menuHandler->useShadowText()){
1992 QColor shadow; 1996 QColor shadow;
1993 if(p->device() && p->device()->devType() == QInternal::Widget && 1997 if(p->device() && p->device()->devType() == QInternal::Widget &&
1994 ((QWidget *)p->device())->inherits("QMenuBar")){ 1998 ((QWidget *)p->device())->inherits("QMenuBar")){
1995 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : 1999 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
1996 g.background().dark(130); 2000 g.background().dark(130);
1997 } 2001 }
1998 else 2002 else
1999 shadow = g.background().dark(130); 2003 shadow = g.background().dark(130);
2000 2004
2001 QPixmap *dummy = 0; 2005 QPixmap *dummy = 0;
2002 2006
2003 if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) { 2007 if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) {
2004 dummy = new QPixmap ( mi-> pixmap ( )-> size ( )); 2008 dummy = new QPixmap ( mi-> pixmap ( )-> size ( ));
2005 QBitmap dummy_mask ( dummy-> size ( )); 2009 QBitmap dummy_mask ( dummy-> size ( ));
2006 dummy_mask. fill ( color1 ); 2010 dummy_mask. fill ( color1 );
2007 dummy-> setMask ( dummy_mask ); 2011 dummy-> setMask ( dummy_mask );
2008 } 2012 }
2009 2013
2010 if(active){ 2014 if(active){
2011 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2015 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2012 QApplication::style().drawItem(p, x+1, y+1, w, h, 2016 QApplication::style().drawItem(p, x+1, y+1, w, h,
2013 AlignCenter|ShowPrefix|DontClip|SingleLine, 2017 AlignCenter|ShowPrefix|DontClip|SingleLine,
2014 g, mi->isEnabled(), dummy, mi->text(), 2018 g, mi->isEnabled(), dummy, mi->text(),
2015 -1, &shadow); 2019 -1, &shadow);
2016 QApplication::style().drawItem(p, x, y, w, h, 2020 QApplication::style().drawItem(p, x, y, w, h,
2017 AlignCenter|ShowPrefix|DontClip|SingleLine, 2021 AlignCenter|ShowPrefix|DontClip|SingleLine,
2018 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), 2022 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
2019 -1, &g.text()); 2023 -1, &g.text());
2020 } 2024 }
2021 else{ 2025 else{
2022 QApplication::style().drawItem(p, x+1, y+1, w, h, 2026 QApplication::style().drawItem(p, x+1, y+1, w, h,
2023 AlignCenter|ShowPrefix|DontClip|SingleLine, 2027 AlignCenter|ShowPrefix|DontClip|SingleLine,
2024 g, mi->isEnabled(), dummy, mi->text(), 2028 g, mi->isEnabled(), dummy, mi->text(),
2025 -1, &shadow); 2029 -1, &shadow);
2026 QApplication::style().drawItem(p, x, y, w, h, 2030 QApplication::style().drawItem(p, x, y, w, h,
@@ -2134,49 +2138,53 @@ static const int windowsRightBorder = 12;
2134 QColor c; 2138 QColor c;
2135 switch(menuHandler->transType()){ 2139 switch(menuHandler->transType()){
2136 case None: 2140 case None:
2137 case StippledBg: 2141 case StippledBg:
2138 case TransStippleBg: 2142 case TransStippleBg:
2139 c = QApplication::palette().active().background(); 2143 c = QApplication::palette().active().background();
2140 break; 2144 break;
2141 case StippledBtn: 2145 case StippledBtn:
2142 case TransStippleBtn: 2146 case TransStippleBtn:
2143 c = QApplication::palette().active().button(); 2147 c = QApplication::palette().active().button();
2144 break; 2148 break;
2145 default: 2149 default:
2146 c = menuHandler->bgColor(); 2150 c = menuHandler->bgColor();
2147 } 2151 }
2148 p->setPen(c.dark(140)); 2152 p->setPen(c.dark(140));
2149 p->drawLine(x, y, x+w, y ); 2153 p->drawLine(x, y, x+w, y );
2150 p->setPen(c.light(115)); 2154 p->setPen(c.light(115));
2151 p->drawLine(x, y+1, x+w, y+1 ); 2155 p->drawLine(x, y+1, x+w, y+1 );
2152 return; 2156 return;
2153 } 2157 }
2154 if(mi->iconSet()) { 2158 if(mi->iconSet()) {
2155 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; 2159 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
2156 if (!dis) 2160 if (!dis)
2157 mode = QIconSet::Active; 2161 mode = QIconSet::Active;
2158 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); 2162 QPixmap pixmap;
2163 if ( mode == QIconSet::Disabled )
2164 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
2165 else
2166 pixmap = mi->iconSet()->pixmap();
2159 int pixw = pixmap.width(); 2167 int pixw = pixmap.width();
2160 int pixh = pixmap.height(); 2168 int pixh = pixmap.height();
2161 QRect cr(x, y, checkcol, h); 2169 QRect cr(x, y, checkcol, h);
2162 QRect pmr(0, 0, pixw, pixh); 2170 QRect pmr(0, 0, pixw, pixh);
2163 pmr.moveCenter( cr.center() ); 2171 pmr.moveCenter( cr.center() );
2164 p->setPen(itemg.highlightedText()); 2172 p->setPen(itemg.highlightedText());
2165 p->drawPixmap(pmr.topLeft(), pixmap ); 2173 p->drawPixmap(pmr.topLeft(), pixmap );
2166 2174
2167 } 2175 }
2168 else if(checkable) { 2176 else if(checkable) {
2169 int mw = checkcol + motifItemFrame; 2177 int mw = checkcol + motifItemFrame;
2170 int mh = h - 2*motifItemFrame; 2178 int mh = h - 2*motifItemFrame;
2171 if (mi->isChecked()){ 2179 if (mi->isChecked()){
2172 drawCheckMark( p, x + motifItemFrame, 2180 drawCheckMark( p, x + motifItemFrame,
2173 y+motifItemFrame, mw, mh, cg2, act, dis ); 2181 y+motifItemFrame, mw, mh, cg2, act, dis );
2174 } 2182 }
2175 } 2183 }
2176 if(menuHandler->transType() == Custom) 2184 if(menuHandler->transType() == Custom)
2177 p->setPen(menuHandler->textColor()); 2185 p->setPen(menuHandler->textColor());
2178 else 2186 else
2179 p->setPen(itemg.text()); 2187 p->setPen(itemg.text());
2180 2188
2181 2189
2182 int xm = motifItemFrame + checkcol + motifItemHMargin; 2190 int xm = motifItemFrame + checkcol + motifItemHMargin;
@@ -2215,50 +2223,49 @@ static const int windowsRightBorder = 12;
2215 p->setBackgroundMode(OpaqueMode); 2223 p->setBackgroundMode(OpaqueMode);
2216 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); 2224 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap);
2217 if (pixmap->depth() == 1) 2225 if (pixmap->depth() == 1)
2218 p->setBackgroundMode(TransparentMode); 2226 p->setBackgroundMode(TransparentMode);
2219 } 2227 }
2220 if (mi->popup()) { 2228 if (mi->popup()) {
2221 int dim = (h-2*motifItemFrame) / 2; 2229 int dim = (h-2*motifItemFrame) / 2;
2222 drawArrow(p, RightArrow, true, 2230 drawArrow(p, RightArrow, true,
2223 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 2231 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
2224 dim, dim, cg2, TRUE); 2232 dim, dim, cg2, TRUE);
2225 } 2233 }
2226} 2234}
2227 2235
2228int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, 2236int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
2229 const QFontMetrics &fm) 2237 const QFontMetrics &fm)
2230{ 2238{
2231 if (mi->isSeparator()) 2239 if (mi->isSeparator())
2232 return 2; 2240 return 2;
2233 2241
2234 int h = 0; 2242 int h = 0;
2235 if (mi->pixmap()) 2243 if (mi->pixmap())
2236 h = mi->pixmap()->height(); 2244 h = mi->pixmap()->height();
2237 2245
2238 if (mi->iconSet()) 2246 if (mi->iconSet())
2239 h = QMAX(mi->iconSet()-> 2247 h = QMAX(mi->iconSet()->pixmap().height(), h);
2240 pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
2241 2248
2242 h = QMAX(fm.height() + 4, h); 2249 h = QMAX(fm.height() + 4, h);
2243 2250
2244 // we want a minimum size of 18 2251 // we want a minimum size of 18
2245 h = QMAX(h, 18); 2252 h = QMAX(h, 18);
2246 2253
2247 return h; 2254 return h;
2248} 2255}
2249 2256
2250 2257
2251void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, 2258void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
2252 const QColorGroup &g, const QColor *c, 2259 const QColorGroup &g, const QColor *c,
2253 bool atBorder) 2260 bool atBorder)
2254{ 2261{
2255 // are we painting a widget? 2262 // are we painting a widget?
2256 if(p->device()->devType() == QInternal::Widget){ 2263 if(p->device()->devType() == QInternal::Widget){
2257 // if so does it use a special focus rectangle? 2264 // if so does it use a special focus rectangle?
2258 QWidget *w = (QWidget *)p->device(); 2265 QWidget *w = (QWidget *)p->device();
2259 if(w->inherits("QPushButton") || w->inherits("QSlider") || w->inherits("QComboBox") || w->inherits("QToolButton" )){ 2266 if(w->inherits("QPushButton") || w->inherits("QSlider") || w->inherits("QComboBox") || w->inherits("QToolButton" )){
2260 return; 2267 return;
2261 } 2268 }
2262 else{ 2269 else{
2263 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); 2270 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
2264 } 2271 }
@@ -2409,49 +2416,49 @@ void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
2409 int lineWidth, const QBrush *fill) 2416 int lineWidth, const QBrush *fill)
2410{ 2417{
2411 if(p->device()->devType() == QInternal::Widget && 2418 if(p->device()->devType() == QInternal::Widget &&
2412 ((QWidget *)p->device())->inherits("QLineEdit")){ 2419 ((QWidget *)p->device())->inherits("QLineEdit")){
2413 int x2 = x+w-1; 2420 int x2 = x+w-1;
2414 int y2 = y+h-1; 2421 int y2 = y+h-1;
2415 p->setPen(g.dark()); 2422 p->setPen(g.dark());
2416 p->drawRect(x, y, w, h); 2423 p->drawRect(x, y, w, h);
2417 p->setPen(g.mid()); 2424 p->setPen(g.mid());
2418 p->drawLine(x+1, y+1, x2-2, y+1); 2425 p->drawLine(x+1, y+1, x2-2, y+1);
2419 p->drawLine(x+1, y+1, x+1, y2-1); 2426 p->drawLine(x+1, y+1, x+1, y2-1);
2420 } 2427 }
2421 else if(lineWidth != 2 || !sunken) 2428 else if(lineWidth != 2 || !sunken)
2422 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); 2429 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill);
2423 else{ 2430 else{
2424 QPen oldPen = p->pen(); 2431 QPen oldPen = p->pen();
2425 int x2 = x+w-1; 2432 int x2 = x+w-1;
2426 int y2 = y+h-1; 2433 int y2 = y+h-1;
2427 p->setPen(g.light()); 2434 p->setPen(g.light());
2428 p->drawLine(x, y2, x2, y2); 2435 p->drawLine(x, y2, x2, y2);
2429 p->drawLine(x2, y, x2, y2); 2436 p->drawLine(x2, y, x2, y2);
2430 p->setPen(g.mid()); 2437 p->setPen(g.mid());
2431 p->drawLine(x, y, x2, y); 2438 p->drawLine(x, y, x2, y);
2432 p->drawLine(x, y, x, y2); 2439 p->drawLine(x, y, x, y2);
2433 2440
2434 p->setPen(g.midlight()); 2441 p->setPen(g.midlight());
2435 p->drawLine(x+1, y2-1, x2-1, y2-1); 2442 p->drawLine(x+1, y2-1, x2-1, y2-1);
2436 p->drawLine(x2-1, y+1, x2-1, y2-1); 2443 p->drawLine(x2-1, y+1, x2-1, y2-1);
2437 p->setPen(g.dark()); 2444 p->setPen(g.dark());
2438 p->drawLine(x+1, y+1, x2-1, y+1); 2445 p->drawLine(x+1, y+1, x2-1, y+1);
2439 p->drawLine(x+1, y+1, x+1, y2-1); 2446 p->drawLine(x+1, y+1, x+1, y2-1);
2440 p->setPen(oldPen); 2447 p->setPen(oldPen);
2441 if(fill){ 2448 if(fill){
2442 // I believe here we are only supposed to fill if there is a 2449 // I believe here we are only supposed to fill if there is a
2443 // specified fill brush... 2450 // specified fill brush...
2444 p->fillRect(x+2, y+2, w-4, h-4, *fill); 2451 p->fillRect(x+2, y+2, w-4, h-4, *fill);
2445 } 2452 }
2446 } 2453 }
2447} 2454}
2448 2455
2449 2456
2450void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) 2457void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
2451{ 2458{
2452 QBitmap *maskBmp = NULL; 2459 QBitmap *maskBmp = NULL;
2453 if(pix.mask()) 2460 if(pix.mask())
2454 maskBmp = new QBitmap(*pix.mask()); 2461 maskBmp = new QBitmap(*pix.mask());
2455 QImage img = pix.convertToImage(); 2462 QImage img = pix.convertToImage();
2456 if(img.depth() != 32) 2463 if(img.depth() != 32)
2457 img = img.convertDepth(32); 2464 img = img.convertDepth(32);
@@ -2467,70 +2474,70 @@ void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
2467 float intensity = v/255.0; 2474 float intensity = v/255.0;
2468 2475
2469 for(current=0; current<total; ++current){ 2476 for(current=0; current<total; ++current){
2470 c.setRgb(data[current]); 2477 c.setRgb(data[current]);
2471 c.hsv(&oldH, &oldS, &oldV); 2478 c.hsv(&oldH, &oldS, &oldV);
2472 oldV = (int)(oldV*intensity); 2479 oldV = (int)(oldV*intensity);
2473 c.setHsv(h, s, oldV); 2480 c.setHsv(h, s, oldV);
2474 data[current] = c.rgb(); 2481 data[current] = c.rgb();
2475 } 2482 }
2476 pix.convertFromImage(img); 2483 pix.convertFromImage(img);
2477 if(maskBmp) 2484 if(maskBmp)
2478 pix.setMask(*maskBmp); 2485 pix.setMask(*maskBmp);
2479} 2486}
2480 2487
2481void LiquidStyle::intensity(QPixmap &pix, float percent) 2488void LiquidStyle::intensity(QPixmap &pix, float percent)
2482{ 2489{
2483 QImage image = pix.convertToImage(); 2490 QImage image = pix.convertToImage();
2484 int i, tmp, r, g, b; 2491 int i, tmp, r, g, b;
2485 int segColors = image.depth() > 8 ? 256 : image.numColors(); 2492 int segColors = image.depth() > 8 ? 256 : image.numColors();
2486 unsigned char *segTbl = new unsigned char[segColors]; 2493 unsigned char *segTbl = new unsigned char[segColors];
2487 int pixels = image.depth() > 8 ? image.width()*image.height() : 2494 int pixels = image.depth() > 8 ? image.width()*image.height() :
2488 image.numColors(); 2495 image.numColors();
2489 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 2496 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
2490 (unsigned int *)image.colorTable(); 2497 (unsigned int *)image.colorTable();
2491 2498
2492 bool brighten = (percent >= 0); 2499 bool brighten = (percent >= 0);
2493 if(percent < 0) 2500 if(percent < 0)
2494 percent = -percent; 2501 percent = -percent;
2495 2502
2496 if(brighten){ // keep overflow check out of loops 2503 if(brighten){ // keep overflow check out of loops
2497 for(i=0; i < segColors; ++i){ 2504 for(i=0; i < segColors; ++i){
2498 tmp = (int)(i*percent); 2505 tmp = (int)(i*percent);
2499 if(tmp > 255) 2506 if(tmp > 255)
2500 tmp = 255; 2507 tmp = 255;
2501 segTbl[i] = tmp; 2508 segTbl[i] = tmp;
2502 } 2509 }
2503 } 2510 }
2504 else{ 2511 else{
2505 for(i=0; i < segColors; ++i){ 2512 for(i=0; i < segColors; ++i){
2506 tmp = (int)(i*percent); 2513 tmp = (int)(i*percent);
2507 if(tmp < 0) 2514 if(tmp < 0)
2508 tmp = 0; 2515 tmp = 0;
2509 segTbl[i] = tmp; 2516 segTbl[i] = tmp;
2510 } 2517 }
2511 } 2518 }
2512 2519
2513 if(brighten){ // same here 2520 if(brighten){ // same here
2514 for(i=0; i < pixels; ++i){ 2521 for(i=0; i < pixels; ++i){
2515 r = qRed(data[i]); 2522 r = qRed(data[i]);
2516 g = qGreen(data[i]); 2523 g = qGreen(data[i]);
2517 b = qBlue(data[i]); 2524 b = qBlue(data[i]);
2518 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 2525 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
2519 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 2526 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
2520 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 2527 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
2521 data[i] = qRgb(r, g, b); 2528 data[i] = qRgb(r, g, b);
2522 } 2529 }
2523 } 2530 }
2524 else{ 2531 else{
2525 for(i=0; i < pixels; ++i){ 2532 for(i=0; i < pixels; ++i){
2526 r = qRed(data[i]); 2533 r = qRed(data[i]);
2527 g = qGreen(data[i]); 2534 g = qGreen(data[i]);
2528 b = qBlue(data[i]); 2535 b = qBlue(data[i]);
2529 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; 2536 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
2530 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; 2537 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
2531 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; 2538 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
2532 data[i] = qRgb(r, g, b); 2539 data[i] = qRgb(r, g, b);
2533 } 2540 }
2534 } 2541 }
2535 delete [] segTbl; 2542 delete [] segTbl;
2536 pix.convertFromImage(image); 2543 pix.convertFromImage(image);
diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp
index 746354e..c2b9de8 100644
--- a/noncore/styles/phase/phasestyle.cpp
+++ b/noncore/styles/phase/phasestyle.cpp
@@ -369,49 +369,52 @@ void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
369 drawArrow(painter, Qt::DownArrow, active, 369 drawArrow(painter, Qt::DownArrow, active,
370 x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() ); 370 x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() );
371 w -= dx; 371 w -= dx;
372 } 372 }
373 373
374 if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon 374 if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon
375 if (button->isEnabled()) { 375 if (button->isEnabled()) {
376 if (button->hasFocus()) { 376 if (button->hasFocus()) {
377 mode = QIconSet::Active; 377 mode = QIconSet::Active;
378 } else { 378 } else {
379 mode = QIconSet::Normal; 379 mode = QIconSet::Normal;
380 } 380 }
381 } else { 381 } else {
382 mode = QIconSet::Disabled; 382 mode = QIconSet::Disabled;
383 } 383 }
384 384
385#if 0 385#if 0
386 if (button->isToggleButton() && button->isOn()) { 386 if (button->isToggleButton() && button->isOn()) {
387 state = true; 387 state = true;
388 } else { 388 } else {
389 state = false; 389 state = false;
390 } 390 }
391#endif 391#endif
392 392
393 pixmap = button->iconSet()->pixmap(QIconSet::Small, mode); 393 if ( mode == QIconSet::Disabled )
394 pixmap = button->iconSet()->pixmap( QIconSet::Automatic, mode );
395 else
396 pixmap = button->iconSet()->pixmap();
394 if (button->text().isEmpty() && !button->pixmap()) { 397 if (button->text().isEmpty() && !button->pixmap()) {
395 painter->drawPixmap(x+w/2 - pixmap.width()/2, 398 painter->drawPixmap(x+w/2 - pixmap.width()/2,
396 y+h/2 - pixmap.height()/2, pixmap); 399 y+h/2 - pixmap.height()/2, pixmap);
397 } else { 400 } else {
398 painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap); 401 painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
399 } 402 }
400 x += pixmap.width() + 4; 403 x += pixmap.width() + 4;
401 w -= pixmap.width() + 4; 404 w -= pixmap.width() + 4;
402 } 405 }
403 406
404 if (active || button->isDefault()) { // default button 407 if (active || button->isDefault()) { // default button
405 for(int n=0; n<2; n++) { 408 for(int n=0; n<2; n++) {
406 drawItem(painter, x+n, y, w, h, 409 drawItem(painter, x+n, y, w, h,
407 AlignCenter | ShowPrefix, 410 AlignCenter | ShowPrefix,
408 button->colorGroup(), 411 button->colorGroup(),
409 button->isEnabled(), 412 button->isEnabled(),
410 button->pixmap(), 413 button->pixmap(),
411 button->text(), -1, 414 button->text(), -1,
412 (button->isEnabled()) ? 415 (button->isEnabled()) ?
413 &button->colorGroup().buttonText() : 416 &button->colorGroup().buttonText() :
414 &button->colorGroup().mid()); 417 &button->colorGroup().mid());
415 } 418 }
416 } else { // normal button 419 } else { // normal button
417 drawItem(painter, x, y, w, h, 420 drawItem(painter, x, y, w, h,
@@ -548,50 +551,49 @@ void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int
548 551
549int PhaseStyle::defaultFrameWidth()const { 552int PhaseStyle::defaultFrameWidth()const {
550 return 1; 553 return 1;
551} 554}
552 555
553int PhaseStyle::popupMenuItemHeight ( bool , 556int PhaseStyle::popupMenuItemHeight ( bool ,
554 QMenuItem * mi, 557 QMenuItem * mi,
555 const QFontMetrics & fm ) { 558 const QFontMetrics & fm ) {
556 int h = 0; 559 int h = 0;
557 if (mi->custom() ) { 560 if (mi->custom() ) {
558 h = mi->custom()->sizeHint().height(); 561 h = mi->custom()->sizeHint().height();
559 if (!mi->custom()->fullSpan() ) 562 if (!mi->custom()->fullSpan() )
560 h += ITEMVMARGIN*2 + ITEMFRAME*2; 563 h += ITEMVMARGIN*2 + ITEMFRAME*2;
561 }else if (mi->isSeparator() ) { 564 }else if (mi->isSeparator() ) {
562 h = 1; 565 h = 1;
563 }else { 566 }else {
564 if ( mi->pixmap() ) { 567 if ( mi->pixmap() ) {
565 h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2); 568 h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2);
566 }else { 569 }else {
567 h = QMAX(h, MINICONSIZE+ITEMFRAME*2 ); 570 h = QMAX(h, MINICONSIZE+ITEMFRAME*2 );
568 h = QMAX(h, fm.height() 571 h = QMAX(h, fm.height()
569 + ITEMVMARGIN*2 + ITEMFRAME*2 ); 572 + ITEMVMARGIN*2 + ITEMFRAME*2 );
570 } 573 }
571 if ( mi->iconSet() ) 574 if ( mi->iconSet() )
572 h = QMAX(h, mi->iconSet()-> 575 h = QMAX(h, mi->iconSet()->pixmap().height()
573 pixmap(QIconSet::Small, QIconSet::Normal ).height()
574 + ITEMFRAME*2 ); 576 + ITEMFRAME*2 );
575 } 577 }
576 578
577 579
578 return h; 580 return h;
579} 581}
580 582
581int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw, 583int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw,
582 QMenuItem* mi, const QFontMetrics& ) { 584 QMenuItem* mi, const QFontMetrics& ) {
583 int w = 0; 585 int w = 0;
584 if (mi->isSeparator() ) 586 if (mi->isSeparator() )
585 return 3; 587 return 3;
586 588
587 else if ( mi->pixmap() ) 589 else if ( mi->pixmap() )
588 w = mi->pixmap()->width(); 590 w = mi->pixmap()->width();
589 591
590 if (!mi->text().isNull() && 592 if (!mi->text().isNull() &&
591 mi->text().find('\t' ) >= 0 ) 593 mi->text().find('\t' ) >= 0 )
592 w += 12; 594 w += 12;
593 else if ( mi->popup() ) 595 else if ( mi->popup() )
594 w += 2*ARROWMARGIN; 596 w += 2*ARROWMARGIN;
595 597
596 if ( maxpmw ) 598 if ( maxpmw )
597 w += maxpmw +4; 599 w += maxpmw +4;
@@ -640,49 +642,53 @@ void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
640 p->fillRect(x, y, w, h, g.background() ); 642 p->fillRect(x, y, w, h, g.background() );
641 643
642 // draw seperator 644 // draw seperator
643 if (mi->isSeparator() ) { 645 if (mi->isSeparator() ) {
644 p->setPen( g.dark() ); 646 p->setPen( g.dark() );
645 p->drawLine( x+8, y+1, x+w-8, y+1 ); 647 p->drawLine( x+8, y+1, x+w-8, y+1 );
646 648
647 p->setPen( g.mid() ); 649 p->setPen( g.mid() );
648 p->drawLine( x+8, y, x+w-8, y ); 650 p->drawLine( x+8, y, x+w-8, y );
649 p->drawPoint(x+w,y+1); 651 p->drawPoint(x+w,y+1);
650 652
651 p->setPen( g.midlight() ); 653 p->setPen( g.midlight() );
652 p->drawLine( x+8, y-1, x+w-8, y-1 ); 654 p->drawLine( x+8, y-1, x+w-8, y-1 );
653 p->drawPoint(x+8, y ); 655 p->drawPoint(x+8, y );
654 return; 656 return;
655 } 657 }
656 658
657 // draw icon 659 // draw icon
658 QIconSet::Mode mode; 660 QIconSet::Mode mode;
659 if ( mi->iconSet() && !mi->isChecked() ) { 661 if ( mi->iconSet() && !mi->isChecked() ) {
660 if ( act ) 662 if ( act )
661 mode = enabled ? QIconSet::Active : QIconSet::Disabled; 663 mode = enabled ? QIconSet::Active : QIconSet::Disabled;
662 else 664 else
663 mode = enabled ? QIconSet::Normal : QIconSet::Disabled; 665 mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
664 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode ); 666 QPixmap pixmap;
667 if ( mode == QIconSet::Disabled )
668 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
669 else
670 pixmap = mi->iconSet()->pixmap();
665 QRect pmrect(0, 0, pixmap.width(), pixmap.height() ); 671 QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
666 QRect cr(x, y, maxpmw, h ); 672 QRect cr(x, y, maxpmw, h );
667 pmrect.moveCenter( cr.center() ); 673 pmrect.moveCenter( cr.center() );
668 p->drawPixmap(pmrect.topLeft(), pixmap); 674 p->drawPixmap(pmrect.topLeft(), pixmap);
669 } 675 }
670 676
671 // draw check 677 // draw check
672 if(mi->isChecked() ) { 678 if(mi->isChecked() ) {
673 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled ); 679 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
674 } 680 }
675 681
676 682
677 // draw text 683 // draw text
678 int xm = maxpmw + 2; 684 int xm = maxpmw + 2;
679 int xp = x + xm; 685 int xp = x + xm;
680 int tw = w -xm - 2; 686 int tw = w -xm - 2;
681 687
682 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) : 688 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
683 g.mid() ); 689 g.mid() );
684 690
685 691
686 if ( mi->custom() ) { 692 if ( mi->custom() ) {
687 p->save(); 693 p->save();
688 mi->custom()->paint(p, g, act, enabled, 694 mi->custom()->paint(p, g, act, enabled,
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 98e7253..106d206 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -16,147 +16,147 @@
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#include "othemestyle.h" 19#include "othemestyle.h"
20#include "othemebase.h" 20#include "othemebase.h"
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qbitmap.h> 22#include <qbitmap.h>
23#define INCLUDE_MENUITEM_DEF 23#define INCLUDE_MENUITEM_DEF
24#include <qmenudata.h> 24#include <qmenudata.h>
25#include <qpopupmenu.h> 25#include <qpopupmenu.h>
26#include <qtabbar.h> 26#include <qtabbar.h>
27#include <qglobal.h> 27#include <qglobal.h>
28#include <qprogressbar.h> 28#include <qprogressbar.h>
29 29
30#include <limits.h> 30#include <limits.h>
31#include <stdio.h> 31#include <stdio.h>
32 32
33typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 33typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
34 QColorGroup &, bool, bool); 34 QColorGroup &, bool, bool);
35 35
36QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 36QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
37 37
38 38
39/* !! HACK !! Beware 39/* !! HACK !! Beware
40 * 40 *
41 * TT forgot to make the QProgressBar widget styleable in Qt 2.x 41 * TT forgot to make the QProgressBar widget styleable in Qt 2.x
42 * So the only way to customize the drawing, is to intercept the 42 * So the only way to customize the drawing, is to intercept the
43 * paint event - since we have to use protected functions, we need 43 * paint event - since we have to use protected functions, we need
44 * to derive a "hack" class from QProgressBar and do the painting 44 * to derive a "hack" class from QProgressBar and do the painting
45 * in there. 45 * in there.
46 * 46 *
47 * - sandman 47 * - sandman
48 */ 48 */
49 49
50class HackProgressBar : public QProgressBar { 50class HackProgressBar : public QProgressBar {
51public: 51public:
52 HackProgressBar ( ); 52 HackProgressBar ( );
53 53
54 void paint ( QPaintEvent *event, OThemeStyle *style ) 54 void paint ( QPaintEvent *event, OThemeStyle *style )
55 { 55 {
56 QPainter p( this ); 56 QPainter p( this );
57 57
58 if ( !contentsRect().contains( event->rect() ) ) { 58 if ( !contentsRect().contains( event->rect() ) ) {
59 p.save(); 59 p.save();
60 p.setClipRegion( event->region().intersect(frameRect()) ); 60 p.setClipRegion( event->region().intersect(frameRect()) );
61 drawFrame( &p); 61 drawFrame( &p);
62 p.restore(); 62 p.restore();
63 } 63 }
64 if ( event->rect().intersects( contentsRect() )) { 64 if ( event->rect().intersects( contentsRect() )) {
65 p.setClipRegion( event->region().intersect( contentsRect() ) ); 65 p.setClipRegion( event->region().intersect( contentsRect() ) );
66 66
67 int x, y, w, h; 67 int x, y, w, h;
68 contentsRect ( ). rect ( &x, &y, &w, &h ); 68 contentsRect ( ). rect ( &x, &y, &w, &h );
69 69
70 int prog = progress ( ); 70 int prog = progress ( );
71 int total = totalSteps ( ); 71 int total = totalSteps ( );
72 if ( prog < 0 ) 72 if ( prog < 0 )
73 prog = 0; 73 prog = 0;
74 if ( total <= 0 ) 74 if ( total <= 0 )
75 total = 1; 75 total = 1;
76 int perc = prog * 100 / total; 76 int perc = prog * 100 / total;
77 77
78 style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc ); 78 style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc );
79 79
80 if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) { 80 if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) {
81 QString pstr; 81 QString pstr;
82 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); 82 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
83 p. setPen ( colorGroup().text());//g.highlightedText ( )); 83 p. setPen ( colorGroup().text());//g.highlightedText ( ));
84 p. drawText (x,y,w-1,h-1,AlignCenter,pstr); 84 p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
85 } 85 }
86 } 86 }
87 } 87 }
88}; 88};
89 89
90 90
91#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 91#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
92 92
93OThemeStyle::OThemeStyle( const QString &configFile ) 93OThemeStyle::OThemeStyle( const QString &configFile )
94 : OThemeBase( configFile ) 94 : OThemeBase( configFile )
95{ 95{
96 setScrollBarExtent( getSBExtent(), getSBExtent() ); 96 setScrollBarExtent( getSBExtent(), getSBExtent() );
97 setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! 97 setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below!
98} 98}
99 99
100OThemeStyle::~OThemeStyle() 100OThemeStyle::~OThemeStyle()
101{} 101{}
102 102
103void OThemeStyle::polish( QApplication * /*app*/ ) 103void OThemeStyle::polish( QApplication * /*app*/ )
104{ 104{
105 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem); 105 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem);
106} 106}
107 107
108 108
109void OThemeStyle::polish( QPalette &p ) 109void OThemeStyle::polish( QPalette &p )
110{ 110{
111 oldPalette = p; 111 oldPalette = p;
112 112
113 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); 113 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background );
114 114
115 if ( bgcolor. isValid ( )) 115 if ( bgcolor. isValid ( ))
116 bg = bgcolor; 116 bg = bgcolor;
117 117
118 if ( isColor ( Background )) 118 if ( isColor ( Background ))
119 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); 119 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( );
120 120
121 p = QPalette ( bg, bg ); 121 p = QPalette ( bg, bg );
122 122
123 if ( isPixmap( Background ) ) 123 if ( isPixmap( Background ) )
124 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); 124 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background )));
125 125
126 if ( fgcolor. isValid ( )) { 126 if ( fgcolor. isValid ( )) {
127 p. setColor ( QColorGroup::Foreground, fgcolor ); 127 p. setColor ( QColorGroup::Foreground, fgcolor );
128 p. setColor ( QColorGroup::ButtonText, fgcolor ); 128 p. setColor ( QColorGroup::ButtonText, fgcolor );
129 } 129 }
130 if ( selfgcolor. isValid ( )) 130 if ( selfgcolor. isValid ( ))
131 p. setColor ( QColorGroup::HighlightedText, selfgcolor ); 131 p. setColor ( QColorGroup::HighlightedText, selfgcolor );
132 if ( selbgcolor. isValid ( )) 132 if ( selbgcolor. isValid ( ))
133 p. setColor ( QColorGroup::Highlight, selbgcolor ); 133 p. setColor ( QColorGroup::Highlight, selbgcolor );
134 if ( winfgcolor. isValid ( )) 134 if ( winfgcolor. isValid ( ))
135 p. setColor ( QColorGroup::Text, winfgcolor ); 135 p. setColor ( QColorGroup::Text, winfgcolor );
136 if ( winbgcolor. isValid ( )) 136 if ( winbgcolor. isValid ( ))
137 p. setColor ( QColorGroup::Base, winbgcolor ); 137 p. setColor ( QColorGroup::Base, winbgcolor );
138 138
139} 139}
140 140
141 141
142void OThemeStyle::unPolish( QApplication *app ) 142void OThemeStyle::unPolish( QApplication *app )
143{ 143{
144 qt_set_draw_menu_bar_impl ( 0 ); 144 qt_set_draw_menu_bar_impl ( 0 );
145 app->setPalette( oldPalette, true ); 145 app->setPalette( oldPalette, true );
146} 146}
147 147
148void OThemeStyle::polish( QWidget *w ) 148void OThemeStyle::polish( QWidget *w )
149{ 149{
150 if ( !w->isTopLevel() ) { 150 if ( !w->isTopLevel() ) {
151 if ( w->inherits( "QGroupBox" ) 151 if ( w->inherits( "QGroupBox" )
152 || w->inherits( "QTabWidget" ) ) { 152 || w->inherits( "QTabWidget" ) ) {
153 w->setAutoMask( TRUE ); 153 w->setAutoMask( TRUE );
154 return ; 154 return ;
155 } 155 }
156 if ( w->inherits( "QLabel" ) 156 if ( w->inherits( "QLabel" )
157 || w->inherits( "QSlider" ) 157 || w->inherits( "QSlider" )
158 || w->inherits( "QButton" ) 158 || w->inherits( "QButton" )
159 || w->inherits( "QProgressBar" ) 159 || w->inherits( "QProgressBar" )
160 ) { 160 ) {
161 w->setBackgroundOrigin( QWidget::ParentOrigin ); 161 w->setBackgroundOrigin( QWidget::ParentOrigin );
162 } 162 }
@@ -1162,49 +1162,49 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
1162 int yy = y - 3; 1162 int yy = y - 3;
1163 int hh = h + 6; 1163 int hh = h + 6;
1164 1164
1165 if ( !act ) { 1165 if ( !act ) {
1166 p->setPen( g.light() ); 1166 p->setPen( g.light() );
1167 p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); 1167 p->drawLine( xx, yy + 3, xx, yy + hh - 4 );
1168 } 1168 }
1169 else { 1169 else {
1170 p->setPen( g.button() ); 1170 p->setPen( g.button() );
1171 p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); 1171 p->drawLine( xx, yy + 4, xx, yy + hh - 4 );
1172 } 1172 }
1173 drawArrow( p, DownArrow, FALSE, 1173 drawArrow( p, DownArrow, FALSE,
1174 x + w - dx - 2, y + 2, dx, h - 4, 1174 x + w - dx - 2, y + 2, dx, h - 4,
1175 btn->colorGroup(), 1175 btn->colorGroup(),
1176 btn->isEnabled() ); 1176 btn->isEnabled() );
1177 w -= dx; 1177 w -= dx;
1178 } 1178 }
1179 1179
1180 // Next, draw iconset, if any 1180 // Next, draw iconset, if any
1181 if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { 1181 if ( btn->iconSet() && !btn->iconSet() ->isNull() ) {
1182 QIconSet::Mode mode = btn->isEnabled() 1182 QIconSet::Mode mode = btn->isEnabled()
1183 ? QIconSet::Normal : QIconSet::Disabled; 1183 ? QIconSet::Normal : QIconSet::Disabled;
1184 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1184 if ( mode == QIconSet::Normal && btn->hasFocus() )
1185 mode = QIconSet::Active; 1185 mode = QIconSet::Active;
1186 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); 1186 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Automatic, mode );
1187 int pixw = pixmap.width(); 1187 int pixw = pixmap.width();
1188 int pixh = pixmap.height(); 1188 int pixh = pixmap.height();
1189 1189
1190 p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); 1190 p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap );
1191 x += pixw + 8; 1191 x += pixw + 8;
1192 w -= pixw + 8; 1192 w -= pixw + 8;
1193 } 1193 }
1194 1194
1195 if ( widget == PushButtonDown ) { 1195 if ( widget == PushButtonDown ) {
1196 drawItem( p, x + buttonXShift(), y + buttonYShift(), 1196 drawItem( p, x + buttonXShift(), y + buttonYShift(),
1197 w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), 1197 w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(),
1198 btn->pixmap(), btn->text(), -1, &cg->buttonText() ); 1198 btn->pixmap(), btn->text(), -1, &cg->buttonText() );
1199 } 1199 }
1200 else { 1200 else {
1201 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, 1201 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg,
1202 btn->isEnabled(), btn->pixmap(), btn->text(), -1, 1202 btn->isEnabled(), btn->pixmap(), btn->text(), -1,
1203 &cg->buttonText() ); 1203 &cg->buttonText() );
1204 } 1204 }
1205} 1205}
1206 1206
1207int OThemeStyle::splitterWidth() const 1207int OThemeStyle::splitterWidth() const
1208{ 1208{
1209 return ( splitWidth() ); 1209 return ( splitWidth() );
1210} 1210}
@@ -1225,50 +1225,49 @@ void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h,
1225 y + ( h - uncached( CheckMark ) ->height() ) / 2, 1225 y + ( h - uncached( CheckMark ) ->height() ) / 2,
1226 *uncached( CheckMark ) ); 1226 *uncached( CheckMark ) );
1227 } 1227 }
1228 else 1228 else
1229 QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), 1229 QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ),
1230 act, dis ); 1230 act, dis );
1231} 1231}
1232 1232
1233int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, 1233int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
1234 const QFontMetrics &fm ) 1234 const QFontMetrics &fm )
1235{ 1235{
1236 int h2, h = 0; 1236 int h2, h = 0;
1237 int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; 1237 int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4;
1238 1238
1239 if ( mi->isSeparator() ) 1239 if ( mi->isSeparator() )
1240 return ( 2 ); 1240 return ( 2 );
1241 if ( mi->isChecked() ) 1241 if ( mi->isChecked() )
1242 h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : 1242 h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset :
1243 offset + 16; 1243 offset + 16;
1244 if ( mi->pixmap() ) { 1244 if ( mi->pixmap() ) {
1245 h2 = mi->pixmap() ->height() + offset; 1245 h2 = mi->pixmap() ->height() + offset;
1246 h = h2 > h ? h2 : h; 1246 h = h2 > h ? h2 : h;
1247 } 1247 }
1248 if ( mi->iconSet() ) { 1248 if ( mi->iconSet() ) {
1249 h2 = mi->iconSet() -> 1249 h2 = mi->iconSet() ->pixmap().height() + offset;
1250 pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset;
1251 h = h2 > h ? h2 : h; 1250 h = h2 > h ? h2 : h;
1252 } 1251 }
1253 h2 = fm.height() + offset; 1252 h2 = fm.height() + offset;
1254 h = h2 > h ? h2 : h; 1253 h = h2 > h ? h2 : h;
1255 return ( h ); 1254 return ( h );
1256} 1255}
1257 1256
1258void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 1257void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
1259 int tab, QMenuItem* mi, 1258 int tab, QMenuItem* mi,
1260 const QPalette& pal, bool act, 1259 const QPalette& pal, bool act,
1261 bool enabled, int x, int y, int w, int h ) 1260 bool enabled, int x, int y, int w, int h )
1262{ 1261{
1263 // I changed the following method to be based from Qt's instead of my own 1262 // I changed the following method to be based from Qt's instead of my own
1264 // wacky code. Works much better now :P (mosfet) 1263 // wacky code. Works much better now :P (mosfet)
1265 static const int motifItemFrame = 2; // menu item frame width 1264 static const int motifItemFrame = 2; // menu item frame width
1266 static const int motifItemHMargin = 5; // menu item hor text margin 1265 static const int motifItemHMargin = 5; // menu item hor text margin
1267 static const int motifItemVMargin = 4; // menu item ver text margin 1266 static const int motifItemVMargin = 4; // menu item ver text margin
1268 1267
1269 static const int motifArrowHMargin = 6; // arrow horizontal margin 1268 static const int motifArrowHMargin = 6; // arrow horizontal margin
1270 static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows 1269 static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows
1271 bool dis = !enabled; 1270 bool dis = !enabled;
1272 const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : 1271 const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) :
1273 *colorGroup( pal.normal(), MenuItemDown ); 1272 *colorGroup( pal.normal(), MenuItemDown );
1274 1273
@@ -1304,49 +1303,53 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
1304 p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap 1303 p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap
1305 (w, ((QWidget *)p->device())->height(), MenuItem), 1304 (w, ((QWidget *)p->device())->height(), MenuItem),
1306 //( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E 1305 //( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E
1307 x, y ); 1306 x, y );
1308 } 1307 }
1309 1308
1310 if ( checkable && mi && mi->isChecked() ) { 1309 if ( checkable && mi && mi->isChecked() ) {
1311 // draw 'pressed' border around checkable items 1310 // draw 'pressed' border around checkable items
1312 // This is extremely important for items that have an iconset 1311 // This is extremely important for items that have an iconset
1313 // because the checkmark isn't drawn in that case 1312 // because the checkmark isn't drawn in that case
1314 // An alternative would be superimposing the checkmark over 1313 // An alternative would be superimposing the checkmark over
1315 // the iconset instead or not drawing the iconset at all. 1314 // the iconset instead or not drawing the iconset at all.
1316 int mw = checkcol + motifItemFrame; 1315 int mw = checkcol + motifItemFrame;
1317 drawShade( p, x, y, mw, h, g, true, false, 1316 drawShade( p, x, y, mw, h, g, true, false,
1318 highlightWidth( MenuItemDown ), 1317 highlightWidth( MenuItemDown ),
1319 borderWidth( MenuItemDown ), shade() ); 1318 borderWidth( MenuItemDown ), shade() );
1320 } 1319 }
1321 } 1320 }
1322 if ( !mi ) 1321 if ( !mi )
1323 return ; 1322 return ;
1324 if ( mi->iconSet() ) { 1323 if ( mi->iconSet() ) {
1325 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1324 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1326 if ( act && !dis ) 1325 if ( act && !dis )
1327 mode = QIconSet::Active; 1326 mode = QIconSet::Active;
1328 QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); 1327 QPixmap pixmap;
1328 if ( mode == QIconSet::Disabled )
1329 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
1330 else
1331 pixmap = mi->iconSet()->pixmap();
1329 int pixw = pixmap.width(); 1332 int pixw = pixmap.width();
1330 int pixh = pixmap.height(); 1333 int pixh = pixmap.height();
1331 QRect cr( x, y, checkcol, h ); 1334 QRect cr( x, y, checkcol, h );
1332 QRect pmr( 0, 0, pixw, pixh ); 1335 QRect pmr( 0, 0, pixw, pixh );
1333 pmr.moveCenter( cr.center() ); 1336 pmr.moveCenter( cr.center() );
1334 p->setPen( itemg.text() ); 1337 p->setPen( itemg.text() );
1335 p->drawPixmap( pmr.topLeft(), pixmap ); 1338 p->drawPixmap( pmr.topLeft(), pixmap );
1336 1339
1337 } 1340 }
1338 else if ( checkable ) { 1341 else if ( checkable ) {
1339 int mw = checkcol + motifItemFrame; 1342 int mw = checkcol + motifItemFrame;
1340 int mh = h - 2 * motifItemFrame; 1343 int mh = h - 2 * motifItemFrame;
1341 if ( mi->isChecked() ) { 1344 if ( mi->isChecked() ) {
1342 drawCheckMark( p, x + motifItemFrame, 1345 drawCheckMark( p, x + motifItemFrame,
1343 y + motifItemFrame, mw, mh, itemg, act, dis ); 1346 y + motifItemFrame, mw, mh, itemg, act, dis );
1344 } 1347 }
1345 } 1348 }
1346 1349
1347 p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); 1350 p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() );
1348 1351
1349 QColor discol; 1352 QColor discol;
1350 if ( dis ) { 1353 if ( dis ) {
1351 discol = itemg.text(); 1354 discol = itemg.text();
1352 p->setPen( discol ); 1355 p->setPen( discol );
@@ -1413,83 +1416,83 @@ void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r,
1413{ 1416{
1414 p->setPen( g.dark() ); 1417 p->setPen( g.dark() );
1415 if ( !is3DFocus() ) 1418 if ( !is3DFocus() )
1416 QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); 1419 QWindowsStyle::drawFocusRect( p, r, g, c, atBorder );
1417 else { 1420 else {
1418 int i = focusOffset(); 1421 int i = focusOffset();
1419 p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); 1422 p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i );
1420 p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); 1423 p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i );
1421 p->setPen( g.light() ); 1424 p->setPen( g.light() );
1422 p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); 1425 p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i );
1423 p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); 1426 p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i );
1424 } 1427 }
1425} 1428}
1426 1429
1427#if 0 1430#if 0
1428void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, 1431void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h,
1429 const QColorGroup &g, bool, QBrush * ) 1432 const QColorGroup &g, bool, QBrush * )
1430{ 1433{
1431 drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, 1434 drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false,
1432 MenuBar ); 1435 MenuBar );
1433} 1436}
1434#endif 1437#endif
1435 1438
1436void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h, 1439void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
1437 QMenuItem *mi, const QColorGroup &g, 1440 QMenuItem *mi, const QColorGroup &g,
1438 bool /*enabled*/, bool active ) 1441 bool /*enabled*/, bool active )
1439{ 1442{
1440 if(active){ 1443 if(active){
1441 x -= 2; // Bug in Qt/E 1444 x -= 2; // Bug in Qt/E
1442 y -= 2; 1445 y -= 2;
1443 w += 2; 1446 w += 2;
1444 h += 2; 1447 h += 2;
1445 } 1448 }
1446 1449
1447 const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); 1450 const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar );
1448 QColor btext = cg->buttonText(); 1451 QColor btext = cg->buttonText();
1449 if ( active ) 1452 if ( active )
1450 drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); 1453 drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem );
1451 //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); 1454 //qDrawShadePanel(p, x, y, w, h, *cg, false, 1);
1452 1455
1453 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, 1456 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine,
1454 *cg, mi-> isEnabled ( ), mi->pixmap(), mi->text(), 1457 *cg, mi-> isEnabled ( ), mi->pixmap(), mi->text(),
1455 -1, &btext ); 1458 -1, &btext );
1456} 1459}
1457 1460
1458 1461
1459 1462
1460void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int percent ) 1463void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int percent )
1461{ 1464{
1462 const QColorGroup * cg = colorGroup( g, ProgressBg ); 1465 const QColorGroup * cg = colorGroup( g, ProgressBg );
1463 QBrush bg; 1466 QBrush bg;
1464 bg.setColor( cg->color( QColorGroup::Background ) ); 1467 bg.setColor( cg->color( QColorGroup::Background ) );
1465 if ( isPixmap( ProgressBg ) ) 1468 if ( isPixmap( ProgressBg ) )
1466 bg.setPixmap( *uncached( ProgressBg ) ); 1469 bg.setPixmap( *uncached( ProgressBg ) );
1467 1470
1468 int pw = w * percent / 100; 1471 int pw = w * percent / 100;
1469 1472
1470 p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO 1473 p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO
1471 1474
1472 drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar ); 1475 drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar );
1473} 1476}
1474 1477
1475#if 0 1478#if 0
1476 1479
1477void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, 1480void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h,
1478 const QColorGroup &g, QBrush * ) 1481 const QColorGroup &g, QBrush * )
1479{ 1482{
1480 drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, 1483 drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false,
1481 ProgressBar ); 1484 ProgressBar );
1482} 1485}
1483 1486
1484void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) 1487void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg )
1485{ 1488{
1486 const QColorGroup * cg = colorGroup( g, ProgressBg ); 1489 const QColorGroup * cg = colorGroup( g, ProgressBg );
1487 bg.setColor( cg->color( QColorGroup::Background ) ); 1490 bg.setColor( cg->color( QColorGroup::Background ) );
1488 if ( isPixmap( ProgressBg ) ) 1491 if ( isPixmap( ProgressBg ) )
1489 bg.setPixmap( *uncached( ProgressBg ) ); 1492 bg.setPixmap( *uncached( ProgressBg ) );
1490} 1493}
1491#endif 1494#endif
1492 1495
1493void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) 1496void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap )
1494{ 1497{
1495 QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); 1498 QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap );
diff --git a/noncore/styles/web/webstyle.cpp b/noncore/styles/web/webstyle.cpp
index cd3cf08..7b58d89 100644
--- a/noncore/styles/web/webstyle.cpp
+++ b/noncore/styles/web/webstyle.cpp
@@ -22,48 +22,57 @@
22#endif 22#endif
23 23
24#include <qmenudata.h> 24#include <qmenudata.h>
25#include <qpalette.h> 25#include <qpalette.h>
26#include <qbitmap.h> 26#include <qbitmap.h>
27#include <qtabbar.h> 27#include <qtabbar.h>
28#include <qpointarray.h> 28#include <qpointarray.h>
29#include <qscrollbar.h> 29#include <qscrollbar.h>
30#include <qframe.h> 30#include <qframe.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qdrawutil.h> 32#include <qdrawutil.h>
33#include <qpainter.h> 33#include <qpainter.h>
34 34
35#include "webstyle.h" 35#include "webstyle.h"
36 36
37static const int _indicatorSize = 9; 37static const int _indicatorSize = 9;
38static QButton * _highlightedButton = 0; 38static QButton * _highlightedButton = 0;
39static const int _scrollBarExtent = 12; 39static const int _scrollBarExtent = 12;
40 40
41static QFrame * _currentFrame = 0; 41static QFrame * _currentFrame = 0;
42static int _savedFrameLineWidth; 42static int _savedFrameLineWidth;
43static int _savedFrameMidLineWidth; 43static int _savedFrameMidLineWidth;
44static ulong _savedFrameStyle; 44static ulong _savedFrameStyle;
45 45
46static const int ITEMFRAME = 1; // menu stuff
47static const int ITEMHMARGIN = 3;
48static const int ITEMVMARGIN = 0;
49
50static const int ARROWMARGIN = 6;
51static const int RIGHTBORDER = 10;
52static const int MINICONSIZE = 12;
53
54
46static QColor contrastingForeground(const QColor & fg, const QColor & bg) 55static QColor contrastingForeground(const QColor & fg, const QColor & bg)
47{ 56{
48 int h, s, vbg, vfg; 57 int h, s, vbg, vfg;
49 58
50 bg.hsv(&h, &s, &vbg); 59 bg.hsv(&h, &s, &vbg);
51 fg.hsv(&h, &s, &vfg); 60 fg.hsv(&h, &s, &vfg);
52 61
53 int diff(vbg - vfg); 62 int diff(vbg - vfg);
54 63
55 if ((diff > -72) && (diff < 72)) 64 if ((diff > -72) && (diff < 72))
56 { 65 {
57 return (vbg < 128) ? Qt::white : Qt::black; 66 return (vbg < 128) ? Qt::white : Qt::black;
58 } 67 }
59 else 68 else
60 { 69 {
61 return fg; 70 return fg;
62 } 71 }
63} 72}
64 73
65// Gotta keep it separated. 74// Gotta keep it separated.
66 75
67 static void 76 static void
68scrollBarControlsMetrics 77scrollBarControlsMetrics
69( 78(
@@ -948,61 +957,172 @@ WebStyle::drawSlider
948{ 957{
949 p->save(); 958 p->save();
950 959
951 p->fillRect(x + 1, y + 1, w - 2, h - 2, g.background()); 960 p->fillRect(x + 1, y + 1, w - 2, h - 2, g.background());
952 p->setPen(g.dark()); 961 p->setPen(g.dark());
953 p->setBrush(g.light()); 962 p->setBrush(g.light());
954 963
955 int sl = sliderLength(); 964 int sl = sliderLength();
956 965
957 if( o == Qt::Horizontal ) 966 if( o == Qt::Horizontal )
958 p->drawEllipse(x, y + h / 2 - sl / 2, sl, sl); 967 p->drawEllipse(x, y + h / 2 - sl / 2, sl, sl);
959 else 968 else
960 if( o == Qt::Vertical ) 969 if( o == Qt::Vertical )
961 p->drawEllipse(x + w / 2 - sl / 2, y, sl, sl); 970 p->drawEllipse(x + w / 2 - sl / 2, y, sl, sl);
962 971
963 p->restore(); 972 p->restore();
964} 973}
965 974
966 void 975 void
967WebStyle::drawPopupMenuItem 976WebStyle::drawPopupMenuItem
968( 977(
969 QPainter * p, 978 QPainter * p,
970 bool checkable, 979 bool checkable,
971 int maxpmw, 980 int maxpmw,
972 int tab, 981 int tabwidth,
973 QMenuItem * mi, 982 QMenuItem * mi,
974 const QPalette & pal, 983 const QPalette & pal,
975 bool act, 984 bool act,
976 bool enabled, 985 bool enabled,
977 int x, 986 int x,
978 int y, 987 int y,
979 int w, 988 int w,
980 int h 989 int h
981) 990)
982{ 991{
983 // TODO 992 // TODO
984 QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); 993 //QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
994 if ( !mi )
995 return;
996
997 QRect rect(x, y, w, h );
998 int x2, y2;
999 x2 = rect.right();
1000 y2 = rect.bottom();
1001 const QColorGroup& g = pal.active();
1002 QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
1003
1004 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
1005
1006 if (act && enabled )
1007 p->fillRect(x, y, w, h, g.highlight() );
1008 else
1009 p->fillRect(x, y, w, h, g.background() );
1010
1011 // draw seperator
1012 if (mi->isSeparator() ) {
1013 p->setPen( g.dark() );
1014 p->drawLine( x+8, y+1, x+w-8, y+1 );
1015
1016 p->setPen( g.mid() );
1017 p->drawLine( x+8, y, x+w-8, y );
1018 p->drawPoint(x+w,y+1);
1019
1020 p->setPen( g.midlight() );
1021 p->drawLine( x+8, y-1, x+w-8, y-1 );
1022 p->drawPoint(x+8, y );
1023 return;
1024 }
1025
1026 // draw icon
1027 QIconSet::Mode mode;
1028 if ( mi->iconSet() && !mi->isChecked() ) {
1029 if ( act )
1030 mode = enabled ? QIconSet::Active : QIconSet::Disabled;
1031 else
1032 mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
1033 QPixmap pixmap;
1034 if ( mode == QIconSet::Disabled )
1035 pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
1036 else
1037 pixmap = mi->iconSet()->pixmap();
1038 QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
1039 QRect cr(x, y, maxpmw, h );
1040 pmrect.moveCenter( cr.center() );
1041 p->drawPixmap(pmrect.topLeft(), pixmap);
1042 }
1043
1044 // draw check
1045 if(mi->isChecked() ) {
1046 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
1047 }
1048
1049
1050 // draw text
1051 int xm = maxpmw + 2;
1052 int xp = x + xm;
1053 int tw = w -xm - 2;
1054
1055 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
1056 g.mid() );
1057
1058
1059 if ( mi->custom() ) {
1060 p->save();
1061 mi->custom()->paint(p, g, act, enabled,
1062 xp, y+1, tw, h-2 );
1063 p->restore();
1064 }else { // draw label
1065 QString text = mi->text();
1066 if (!text.isNull() ) {
1067 int t = text.find('\t');
1068 const int tflags = AlignVCenter | DontClip |
1069 ShowPrefix | SingleLine |
1070 AlignLeft;
1071
1072 if (t >= 0) {
1073 int tabx = x + w - tabwidth - RIGHTBORDER -
1074 ITEMHMARGIN - ITEMFRAME;
1075 p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
1076 h-2*ITEMVMARGIN, tflags,
1077 text.mid(t+1) );
1078 text = text.left(t );
1079 }
1080
1081 // draw left label
1082 p->drawText(xp, y+ITEMVMARGIN,
1083 tw, h-2*ITEMVMARGIN,
1084 tflags, text, t);
1085 }else if ( mi->pixmap() ) { // pixmap as label
1086 QPixmap pixmap = *mi->pixmap();
1087 if ( pixmap.depth() == 1 )
1088 p->setBackgroundMode( OpaqueMode );
1089
1090 int dx = ((w-pixmap.width() ) /2 ) +
1091 ((w - pixmap.width()) %2 );
1092 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
1093
1094 if ( pixmap.depth() == 1 )
1095 p->setBackgroundMode( TransparentMode );
1096 }
1097 }
1098
1099 if ( mi->popup() ) { // draw submenu arrow
1100 int dim = (h-2*ITEMFRAME) / 2;
1101 drawArrow( p, RightArrow, false,
1102 x+w-ARROWMARGIN-ITEMFRAME-dim,
1103 y+h/2-dim/2, dim, dim, g, enabled );
1104 }
985} 1105}
986 1106
987 void 1107 void
988WebStyle::drawFocusRect 1108WebStyle::drawFocusRect
989( 1109(
990 QPainter * p, 1110 QPainter * p,
991 const QRect & r, 1111 const QRect & r,
992 const QColorGroup & g, 1112 const QColorGroup & g,
993 const QColor * pen, 1113 const QColor * pen,
994 bool atBorder 1114 bool atBorder
995) 1115)
996{ 1116{
997 p->save(); 1117 p->save();
998 1118
999 if (0 != pen) 1119 if (0 != pen)
1000 p->setPen(0 == pen ? g.foreground() : *pen); 1120 p->setPen(0 == pen ? g.foreground() : *pen);
1001 p->setBrush(NoBrush); 1121 p->setBrush(NoBrush);
1002 1122
1003 if (atBorder) 1123 if (atBorder)
1004 { 1124 {
1005 p->drawRect(QRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2)); 1125 p->drawRect(QRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2));
1006 } 1126 }
1007 else 1127 else
1008 { 1128 {
@@ -1147,37 +1267,37 @@ WebStyle::drawTabMask
1147 bool 1267 bool
1148) 1268)
1149{ 1269{
1150 p->fillRect(tab->rect(), Qt::color1); 1270 p->fillRect(tab->rect(), Qt::color1);
1151} 1271}
1152 1272
1153 1273
1154 int 1274 int
1155WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm) 1275WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm)
1156{ 1276{
1157 if (i->isSeparator()) 1277 if (i->isSeparator())
1158 return 1; 1278 return 1;
1159 1279
1160 int h = 0; 1280 int h = 0;
1161 1281
1162 if (0 != i->pixmap()) 1282 if (0 != i->pixmap())
1163 { 1283 {
1164 h = i->pixmap()->height(); 1284 h = i->pixmap()->height();
1165 } 1285 }
1166 1286
1167 if (0 != i->iconSet()) 1287 if (0 != i->iconSet())
1168 { 1288 {
1169 h = QMAX 1289 h = QMAX
1170 ( 1290 (
1171 i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(), 1291 i->iconSet()->pixmap().height(),
1172 h 1292 h
1173 ); 1293 );
1174 } 1294 }
1175 1295
1176 h = QMAX(fm.height() + 4, h); 1296 h = QMAX(fm.height() + 4, h);
1177 1297
1178 h = QMAX(18, h); 1298 h = QMAX(18, h);
1179 1299
1180 return h; 1300 return h;
1181 1301
1182} 1302}
1183 1303
diff --git a/noncore/styles/web/webstyle.h b/noncore/styles/web/webstyle.h
index 83ab784..d6f153b 100644
--- a/noncore/styles/web/webstyle.h
+++ b/noncore/styles/web/webstyle.h
@@ -194,49 +194,49 @@ class WebStyle : public QWindowsStyle {
194 int h, 194 int h,
195 const QColorGroup &, 195 const QColorGroup &,
196 bool enabled = true, 196 bool enabled = true,
197 const QBrush * fill = 0 197 const QBrush * fill = 0
198 ); 198 );
199 199
200 void drawSlider 200 void drawSlider
201 ( 201 (
202 QPainter *, 202 QPainter *,
203 int x, 203 int x,
204 int y, 204 int y,
205 int w, 205 int w,
206 int h, 206 int h,
207 const QColorGroup &, 207 const QColorGroup &,
208 Orientation, 208 Orientation,
209 bool tickAbove, 209 bool tickAbove,
210 bool tickBelow 210 bool tickBelow
211 ); 211 );
212 212
213 void drawPopupMenuItem 213 void drawPopupMenuItem
214 ( 214 (
215 QPainter *, 215 QPainter *,
216 bool checkable, 216 bool checkable,
217 int maxpmw, 217 int maxpmw,
218 int tab, 218 int tabwidth,
219 QMenuItem *, 219 QMenuItem *,
220 const QPalette &, 220 const QPalette &,
221 bool act, 221 bool act,
222 bool enabled, 222 bool enabled,
223 int x, 223 int x,
224 int y, 224 int y,
225 int w, 225 int w,
226 int h 226 int h
227 ); 227 );
228 228
229 void drawFocusRect 229 void drawFocusRect
230 ( 230 (
231 QPainter *, 231 QPainter *,
232 const QRect &, 232 const QRect &,
233 const QColorGroup &, 233 const QColorGroup &,
234 const QColor * pen, 234 const QColor * pen,
235 bool atBorder 235 bool atBorder
236 ); 236 );
237 237
238 void drawPanel 238 void drawPanel
239 ( 239 (
240 QPainter *, 240 QPainter *,
241 int x, 241 int x,
242 int y, 242 int y,