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
@@ -1,281 +1,285 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "launchertab.h" 20#include "launchertab.h"
21#include <qapplication.h> 21#include <qapplication.h>
22 22
23 23
24LauncherTabBar::LauncherTabBar( QWidget *parent, const char *name ) 24LauncherTabBar::LauncherTabBar( QWidget *parent, const char *name )
25 : QTabBar( parent, name ) 25 : QTabBar( parent, name )
26{ 26{
27 setFocusPolicy( NoFocus ); 27 setFocusPolicy( NoFocus );
28 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 28 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
29} 29}
30 30
31LauncherTabBar::~LauncherTabBar() 31LauncherTabBar::~LauncherTabBar()
32{ 32{
33} 33}
34 34
35void LauncherTabBar::insertTab( LauncherTab *t, int index ) 35void LauncherTabBar::insertTab( LauncherTab *t, int index )
36{ 36{
37 if ( index < 0 ) 37 if ( index < 0 )
38 items.append( t ); 38 items.append( t );
39 else 39 else
40 items.insert( (uint)index, t ); 40 items.insert( (uint)index, t );
41 tabs.insert( t->type, t ); 41 tabs.insert( t->type, t );
42 QTabBar::insertTab( t, index ); 42 QTabBar::insertTab( t, index );
43} 43}
44 44
45void LauncherTabBar::removeTab( QTab *tab ) 45void LauncherTabBar::removeTab( QTab *tab )
46{ 46{
47 LauncherTab *t = (LauncherTab *)tab; 47 LauncherTab *t = (LauncherTab *)tab;
48 tabs.remove( t->type ); 48 tabs.remove( t->type );
49 items.remove( t ); 49 items.remove( t );
50 QTabBar::removeTab( t ); 50 QTabBar::removeTab( t );
51} 51}
52 52
53void LauncherTabBar::prevTab() 53void LauncherTabBar::prevTab()
54{ 54{
55 int n = count(); 55 int n = count();
56 int tab = currentTab(); 56 int tab = currentTab();
57 if ( tab >= 0 ) 57 if ( tab >= 0 )
58 setCurrentTab( (tab - 1 + n)%n ); 58 setCurrentTab( (tab - 1 + n)%n );
59} 59}
60 60
61void LauncherTabBar::nextTab() 61void LauncherTabBar::nextTab()
62{ 62{
63 int n = count(); 63 int n = count();
64 int tab = currentTab(); 64 int tab = currentTab();
65 setCurrentTab( (tab + 1)%n ); 65 setCurrentTab( (tab + 1)%n );
66} 66}
67 67
68void LauncherTabBar::showTab( const QString& id ) 68void LauncherTabBar::showTab( const QString& id )
69{ 69{
70 setCurrentTab( tabs[id] ); 70 setCurrentTab( tabs[id] );
71} 71}
72 72
73void LauncherTabBar::layoutTabs() 73void LauncherTabBar::layoutTabs()
74{ 74{
75 if ( !count() ) 75 if ( !count() )
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 );
177 } 177 }
178 178
179 update(); 179 update();
180} 180}
181 181
182void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const 182void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const
183{ 183{
184 LauncherTabBar *that = (LauncherTabBar *) this; 184 LauncherTabBar *that = (LauncherTabBar *) this;
185 LauncherTab *ct = (LauncherTab *)t; 185 LauncherTab *ct = (LauncherTab *)t;
186 QPalette pal = palette(); 186 QPalette pal = palette();
187 bool setPal = FALSE; 187 bool setPal = FALSE;
188 if ( ct->bgColor.isValid() ) { 188 if ( ct->bgColor.isValid() ) {
189 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 189 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
190 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 190 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
191 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 191 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
192 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 192 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
193 that->setUpdatesEnabled( FALSE ); 193 that->setUpdatesEnabled( FALSE );
194 that->setPalette( pal ); 194 that->setPalette( pal );
195 setPal = TRUE; 195 setPal = TRUE;
196 } 196 }
197#if QT_VERSION >= 0x030000 197#if QT_VERSION >= 0x030000
198 QStyle::SFlags flags = QStyle::Style_Default; 198 QStyle::SFlags flags = QStyle::Style_Default;
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() );
279 } 283 }
280} 284}
281 285
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,178 +1,178 @@
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
48MenuSettings::MenuSettings ( QWidget *parent, const char *name ) 48MenuSettings::MenuSettings ( QWidget *parent, const char *name )
49 : QWidget ( parent, name ) 49 : QWidget ( parent, name )
50{ 50{
51 m_applets_changed = false; 51 m_applets_changed = false;
52 52
53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
54 54
55 QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this ); 55 QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this );
56 lay-> addWidget ( l ); 56 lay-> addWidget ( l );
57 57
58 m_list = new QListView ( this ); 58 m_list = new QListView ( this );
59 m_list-> addColumn ( "foobar" ); 59 m_list-> addColumn ( "foobar" );
60 m_list-> header ( )-> hide ( ); 60 m_list-> header ( )-> hide ( );
61 61
62 lay-> addWidget ( m_list ); 62 lay-> addWidget ( m_list );
63 63
64 m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); 64 m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
65 lay-> addWidget ( m_menutabs ); 65 lay-> addWidget ( m_menutabs );
66 66
67 m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); 67 m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this );
68 lay-> addWidget ( m_menusubpopup ); 68 lay-> addWidget ( m_menusubpopup );
69 69
70 QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); 70 QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." ));
71 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); 71 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." ));
72 72
73 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); 73 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
74 74
75 init ( ); 75 init ( );
76} 76}
77 77
78void MenuSettings::init ( ) 78void MenuSettings::init ( )
79{ 79{
80 Config cfg ( "StartMenu" ); 80 Config cfg ( "StartMenu" );
81 cfg. setGroup ( "Applets" ); 81 cfg. setGroup ( "Applets" );
82 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 82 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
83 83
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{
133 m_applets_changed = true; 133 m_applets_changed = true;
134} 134}
135 135
136void MenuSettings::accept ( ) 136void MenuSettings::accept ( )
137{ 137{
138 bool apps_changed = false; 138 bool apps_changed = false;
139 139
140 Config cfg ( "StartMenu" ); 140 Config cfg ( "StartMenu" );
141 cfg. setGroup ( "Applets" ); 141 cfg. setGroup ( "Applets" );
142 if ( m_applets_changed ) { 142 if ( m_applets_changed ) {
143 QStringList exclude; 143 QStringList exclude;
144 QMap <QString, QCheckListItem *>::Iterator it; 144 QMap <QString, QCheckListItem *>::Iterator it;
145 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { 145 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
146 if ( !(*it)-> isOn ( )) 146 if ( !(*it)-> isOn ( ))
147 exclude << it. key ( ); 147 exclude << it. key ( );
148 } 148 }
149 cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); 149 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
150 } 150 }
151 cfg. writeEntry ( "SafeMode", false ); 151 cfg. writeEntry ( "SafeMode", false );
152 152
153 cfg. setGroup ( "Menu" ); 153 cfg. setGroup ( "Menu" );
154 154
155 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { 155 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
156 apps_changed = true; 156 apps_changed = true;
157 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); 157 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
158 } 158 }
159 159
160 if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { 160 if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) {
161 apps_changed = true; 161 apps_changed = true;
162 cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); 162 cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( ));
163 } 163 }
164 164
165 cfg. write ( ); 165 cfg. write ( );
166 166
167 if ( m_applets_changed ) { 167 if ( m_applets_changed ) {
168 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); 168 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
169 m_applets_changed = false; 169 m_applets_changed = false;
170 } 170 }
171 if ( apps_changed ) { 171 if ( apps_changed ) {
172 // currently use reloadApplets() since reloadApps is now used exclusive for server 172 // currently use reloadApplets() since reloadApps is now used exclusive for server
173 // to refresh the tabs. But what we want here is also a refresh of the startmenu entries 173 // to refresh the tabs. But what we want here is also a refresh of the startmenu entries
174 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); 174 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
175 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); 175 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
176 } 176 }
177} 177}
178 178
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,83 +1,87 @@
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 {
76 p->setPen( colorGroup().light() ); 80 p->setPen( colorGroup().light() );
77 QRect wr = tr; 81 QRect wr = tr;
78 wr.moveBy( 1, 1 ); 82 wr.moveBy( 1, 1 );
79 p->drawText( wr, AlignCenter | ShowPrefix, t->label ); 83 p->drawText( wr, AlignCenter | ShowPrefix, t->label );
80 p->setPen( palette().disabled().foreground() ); 84 p->setPen( palette().disabled().foreground() );
81 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 85 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
82 } 86 }
83} 87}
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,86 +1,86 @@
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
54public: 54public:
55 /** 55 /**
56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) 56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
57 * @brief Object constructor. 57 * @brief Object constructor.
58 * 58 *
59 * @param parent Pointer to parent of this control. 59 * @param parent Pointer to parent of this control.
60 * @param name Name of control. 60 * @param name Name of control.
61 * 61 *
62 * Constructs a new OTabBar control with parent and name. 62 * Constructs a new OTabBar control with parent and name.
63 */ 63 */
64 OTabBar( QWidget * = 0, const char * = 0 ); 64 OTabBar( QWidget * = 0, const char * = 0 );
65 65
66protected: 66protected:
67 /** 67 /**
68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const 68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const
69 * @brief Internal function to draw a tab's label. 69 * @brief Internal function to draw a tab's label.
70 * 70 *
71 * @param p Pointer to QPainter used for drawing. 71 * @param p Pointer to QPainter used for drawing.
72 * @param br QRect providing region to draw label in. 72 * @param br QRect providing region to draw label in.
73 * @param t Tab to draw label for. 73 * @param t Tab to draw label for.
74 * @param has_focus Boolean value not used, retained for compatibility reasons. 74 * @param has_focus Boolean value not used, retained for compatibility reasons.
75 */ 75 */
76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; 76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
77 77
78private: 78private:
79 class Private; 79 class Private;
80 Private *d; 80 Private *d;
81}; 81};
82 82
83} 83}
84} 84}
85 85
86#endif 86#endif
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
@@ -1,476 +1,475 @@
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, 2005 Dan Williams <drw@handhelds.org> 4 Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.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#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
62 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 61 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
63 if ( s <= Global || s > IconList) 62 if ( s <= Global || s > IconList)
64 s = IconTab; 63 s = IconTab;
65 64
66 // Position 65 // Position
67 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom 66 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
68 : p = Top; 67 : p = Top;
69 } 68 }
70 69
71 // Initialize widget stack for tab widgets 70 // Initialize widget stack for tab widgets
72 m_widgetStack = new QWidgetStack( this ); 71 m_widgetStack = new QWidgetStack( this );
73 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 72 m_widgetStack->setFrameStyle( QFrame::NoFrame );
74 m_widgetStack->setLineWidth( style().defaultFrameWidth() ); 73 m_widgetStack->setLineWidth( style().defaultFrameWidth() );
75 74
76 // Set initial selector control style and position 75 // Set initial selector control style and position
77 setTabStyle( s ); 76 setTabStyle( s );
78 setTabPosition( p ); 77 setTabPosition( p );
79} 78}
80 79
81OTabWidget::~OTabWidget() 80OTabWidget::~OTabWidget()
82{ 81{
83 m_tabs.setAutoDelete( true ); 82 m_tabs.setAutoDelete( true );
84 m_tabs.clear(); 83 m_tabs.clear();
85} 84}
86 85
87void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 86void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
88{ 87{
89 int tabid = -1; 88 int tabid = -1;
90 89
91 if ( m_usingTabs ) 90 if ( m_usingTabs )
92 { 91 {
93 // Create new tab in tab bar 92 // Create new tab in tab bar
94 QTab *tab = new QTab(); 93 QTab *tab = new QTab();
95 94
96 // Set label (and icon if necessary) 95 // Set label (and icon if necessary)
97 if ( m_tabBarStyle == IconTab ) 96 if ( m_tabBarStyle == IconTab )
98 { 97 {
99 tab->label = QString::null; 98 tab->label = QString::null;
100 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ); 99 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
101 } 100 }
102 else 101 else
103 tab->label = label; 102 tab->label = label;
104 103
105 tabid = m_tabBar->addTab( tab ); 104 tabid = m_tabBar->addTab( tab );
106 } 105 }
107 else 106 else
108 { 107 {
109 // Insert entry (with icon if necessary) into drop down list 108 // Insert entry (with icon if necessary) into drop down list
110 if ( m_tabBarStyle == IconList ) 109 if ( m_tabBarStyle == IconList )
111 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 ); 110 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 );
112 else 111 else
113 m_tabList->insertItem( label ); 112 m_tabList->insertItem( label );
114 } 113 }
115 114
116 // Add widget to stack 115 // Add widget to stack
117 m_widgetStack->addWidget( child, tabid ); 116 m_widgetStack->addWidget( child, tabid );
118 m_widgetStack->raiseWidget( child ); 117 m_widgetStack->raiseWidget( child );
119 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 118 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
120 119
121 // Keep track of tab information 120 // Keep track of tab information
122 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 121 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
123 m_tabs.append( tabinfo ); 122 m_tabs.append( tabinfo );
124 123
125 // Make newly added tab the current one displayed 124 // Make newly added tab the current one displayed
126 selectTab( tabinfo ); 125 selectTab( tabinfo );
127} 126}
128 127
129void OTabWidget::removePage( QWidget *childwidget ) 128void OTabWidget::removePage( QWidget *childwidget )
130{ 129{
131 if ( childwidget ) 130 if ( childwidget )
132 { 131 {
133 // Find tab information for desired widget 132 // Find tab information for desired widget
134 OTabInfo *tab = m_tabs.first(); 133 OTabInfo *tab = m_tabs.first();
135 while ( tab && tab->control() != childwidget ) 134 while ( tab && tab->control() != childwidget )
136 tab = m_tabs.next(); 135 tab = m_tabs.next();
137 136
138 if ( tab && tab->control() == childwidget ) 137 if ( tab && tab->control() == childwidget )
139 { 138 {
140 if ( m_usingTabs ) 139 if ( m_usingTabs )
141 { 140 {
142 // Remove tab from tab bar 141 // Remove tab from tab bar
143 m_tabBar->setTabEnabled( tab->id(), false ); 142 m_tabBar->setTabEnabled( tab->id(), false );
144 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) ); 143 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
145 } 144 }
146 else 145 else
147 { 146 {
148 // Remove entry from drop down list 147 // Remove entry from drop down list
149 int i = 0; 148 int i = 0;
150 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() ) 149 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
151 i++; 150 i++;
152 if ( m_tabList->text( i ) == tab->label() ) 151 if ( m_tabList->text( i ) == tab->label() )
153 m_tabList->removeItem( i ); 152 m_tabList->removeItem( i );
154 } 153 }
155 154
156 // Remove widget from stack 155 // Remove widget from stack
157 m_widgetStack->removeWidget( childwidget ); 156 m_widgetStack->removeWidget( childwidget );
158 157
159 // Get rid of tab information 158 // Get rid of tab information
160 m_tabs.remove( tab ); 159 m_tabs.remove( tab );
161 delete tab; 160 delete tab;
162 161
163 // Reset current tab 162 // Reset current tab
164 m_currTab = m_tabs.current(); 163 m_currTab = m_tabs.current();
165 if ( !m_currTab ) 164 if ( !m_currTab )
166 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 165 m_widgetStack->setFrameStyle( QFrame::NoFrame );
167 166
168 // Redraw widget 167 // Redraw widget
169 setUpLayout(); 168 setUpLayout();
170 } 169 }
171 } 170 }
172} 171}
173 172
174void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 173void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
175{ 174{
176 // Find tab information for desired widget 175 // Find tab information for desired widget
177 OTabInfo *currtab = m_tabs.first(); 176 OTabInfo *currtab = m_tabs.first();
178 while ( currtab && currtab->control() != widget ) 177 while ( currtab && currtab->control() != widget )
179 currtab = m_tabs.next(); 178 currtab = m_tabs.next();
180 179
181 if ( currtab && currtab->control() == widget ) 180 if ( currtab && currtab->control() == widget )
182 { 181 {
183 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) ); 182 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) );
184 183
185 if ( m_usingTabs ) 184 if ( m_usingTabs )
186 { 185 {
187 // Update tab label and icon (if necessary) 186 // Update tab label and icon (if necessary)
188 QTab *tab = m_tabBar->tab( currtab->id() ); 187 QTab *tab = m_tabBar->tab( currtab->id() );
189 tab->setText( label ); 188 tab->setText( label );
190 if ( m_tabBarStyle == IconTab ) 189 if ( m_tabBarStyle == IconTab )
191 tab->setIconSet( icon ); 190 tab->setIconSet( icon );
192 } 191 }
193 else 192 else
194 { 193 {
195 // Update entry label and icon (if necessary) 194 // Update entry label and icon (if necessary)
196 int i = 0; 195 int i = 0;
197 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() ) 196 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() )
198 i++; 197 i++;
199 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() ) 198 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() )
200 { 199 {
201 if ( m_tabBarStyle == IconList ) 200 if ( m_tabBarStyle == IconList )
202 m_tabList->changeItem( icon, label, i ); 201 m_tabList->changeItem( icon, label, i );
203 else 202 else
204 m_tabList->changeItem( label, i ); 203 m_tabList->changeItem( label, i );
205 } 204 }
206 } 205 }
207 206
208 // Update tab information 207 // Update tab information
209 currtab->setLabel( label ); 208 currtab->setLabel( label );
210 currtab->setIcon( iconset ); 209 currtab->setIcon( iconset );
211 210
212 // Redraw widget 211 // Redraw widget
213 setUpLayout(); 212 setUpLayout();
214 } 213 }
215} 214}
216 215
217void OTabWidget::setCurrentTab( QWidget *childwidget ) 216void OTabWidget::setCurrentTab( QWidget *childwidget )
218{ 217{
219 OTabInfo *currtab = m_tabs.first(); 218 OTabInfo *currtab = m_tabs.first();
220 while ( currtab && currtab->control() != childwidget ) 219 while ( currtab && currtab->control() != childwidget )
221 { 220 {
222 currtab = m_tabs.next(); 221 currtab = m_tabs.next();
223 } 222 }
224 if ( currtab && currtab->control() == childwidget ) 223 if ( currtab && currtab->control() == childwidget )
225 { 224 {
226 selectTab( currtab ); 225 selectTab( currtab );
227 } 226 }
228} 227}
229 228
230void OTabWidget::setCurrentTab( const QString &tabname ) 229void OTabWidget::setCurrentTab( const QString &tabname )
231{ 230{
232 OTabInfo *newtab = m_tabs.first(); 231 OTabInfo *newtab = m_tabs.first();
233 while ( newtab && newtab->label() != tabname ) 232 while ( newtab && newtab->label() != tabname )
234 { 233 {
235 newtab = m_tabs.next(); 234 newtab = m_tabs.next();
236 } 235 }
237 if ( newtab && newtab->label() == tabname ) 236 if ( newtab && newtab->label() == tabname )
238 { 237 {
239 selectTab( newtab ); 238 selectTab( newtab );
240 } 239 }
241} 240}
242 241
243void OTabWidget::setCurrentTab(int tabindex) 242void OTabWidget::setCurrentTab(int tabindex)
244{ 243{
245 OTabInfo *newtab = m_tabs.first(); 244 OTabInfo *newtab = m_tabs.first();
246 while ( newtab && newtab->id() != tabindex ) 245 while ( newtab && newtab->id() != tabindex )
247 { 246 {
248 newtab = m_tabs.next(); 247 newtab = m_tabs.next();
249 } 248 }
250 if ( newtab && newtab->id() == tabindex ) 249 if ( newtab && newtab->id() == tabindex )
251 { 250 {
252 selectTab( newtab ); 251 selectTab( newtab );
253 } 252 }
254} 253}
255 254
256 255
257OTabWidget::TabStyle OTabWidget::tabStyle() const 256OTabWidget::TabStyle OTabWidget::tabStyle() const
258{ 257{
259 return m_tabBarStyle; 258 return m_tabBarStyle;
260} 259}
261 260
262void OTabWidget::setTabStyle( TabStyle s ) 261void OTabWidget::setTabStyle( TabStyle s )
263{ 262{
264 // Get out if new and current styles are the same 263 // Get out if new and current styles are the same
265 if ( s == m_tabBarStyle ) 264 if ( s == m_tabBarStyle )
266 return; 265 return;
267 266
268 // Delete current selector control 267 // Delete current selector control
269 if ( m_usingTabs ) 268 if ( m_usingTabs )
270 { 269 {
271 delete m_tabBar; 270 delete m_tabBar;
272 m_tabBar = 0l; 271 m_tabBar = 0l;
273 } 272 }
274 else 273 else
275 { 274 {
276 delete m_tabList; 275 delete m_tabList;
277 m_tabList = 0l; 276 m_tabList = 0l;
278 } 277 }
279 278
280 // Set new style information 279 // Set new style information
281 m_tabBarStyle = s; 280 m_tabBarStyle = s;
282 m_usingTabs = ( m_tabBarStyle == TextTab || m_tabBarStyle == IconTab ); 281 m_usingTabs = ( m_tabBarStyle == TextTab || m_tabBarStyle == IconTab );
283 282
284 // Create new selector control and populate with tab information 283 // Create new selector control and populate with tab information
285 if ( m_usingTabs ) 284 if ( m_usingTabs )
286 { 285 {
287 // Create new tab bar selector 286 // Create new tab bar selector
288 m_tabBar = new OTabBar( this ); 287 m_tabBar = new OTabBar( this );
289 connect( m_tabBar, SIGNAL(selected(int)), this, SLOT(slotTabBarSelected(int)) ); 288 connect( m_tabBar, SIGNAL(selected(int)), this, SLOT(slotTabBarSelected(int)) );
290 289
291 // Add all current tabs to tab bar 290 // Add all current tabs to tab bar
292 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() ) 291 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
293 { 292 {
294 // Create new tab in tab bar 293 // Create new tab in tab bar
295 QTab *tab = new QTab(); 294 QTab *tab = new QTab();
296 295
297 // Set label (and icon if necessary) 296 // Set label (and icon if necessary)
298 if ( m_tabBarStyle == IconTab ) 297 if ( m_tabBarStyle == IconTab )
299 { 298 {
300 tab->label = QString::null; 299 tab->label = QString::null;
301 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ) ); 300 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ) );
302 } 301 }
303 else 302 else
304 tab->label = tabinfo->label(); 303 tab->label = tabinfo->label();
305 304
306 // Add tab and save its Id 305 // Add tab and save its Id
307 int tabid = m_tabBar->addTab( tab ); 306 int tabid = m_tabBar->addTab( tab );
308 tabinfo->setId( tabid ); 307 tabinfo->setId( tabid );
309 } 308 }
310 } 309 }
311 else 310 else
312 { 311 {
313 // Create new drop down list selector 312 // Create new drop down list selector
314 m_tabList = new QComboBox( false, this ); 313 m_tabList = new QComboBox( false, this );
315 connect( m_tabList, SIGNAL(activated(int)), this, SLOT(slotTabListSelected(int)) ); 314 connect( m_tabList, SIGNAL(activated(int)), this, SLOT(slotTabListSelected(int)) );
316 315
317 // Add all current tabs to drop down list 316 // Add all current tabs to drop down list
318 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() ) 317 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
319 { 318 {
320 if ( m_tabBarStyle == IconList ) 319 if ( m_tabBarStyle == IconList )
321 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ), 320 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ),
322 tabinfo->label() ); 321 tabinfo->label() );
323 else 322 else
324 m_tabList->insertItem( tabinfo->label() ); 323 m_tabList->insertItem( tabinfo->label() );
325 } 324 }
326 } 325 }
327 326
328 // Redraw widget 327 // Redraw widget
329 setUpLayout(); 328 setUpLayout();
330} 329}
331 330
332OTabWidget::TabPosition OTabWidget::tabPosition() const 331OTabWidget::TabPosition OTabWidget::tabPosition() const
333{ 332{
334 return m_tabBarPosition; 333 return m_tabBarPosition;
335} 334}
336 335
337void OTabWidget::setTabPosition( TabPosition p ) 336void OTabWidget::setTabPosition( TabPosition p )
338{ 337{
339 m_tabBarPosition = p; 338 m_tabBarPosition = p;
340 339
341 // If using the tab bar selector, set its shape 340 // If using the tab bar selector, set its shape
342 if ( m_usingTabs ) 341 if ( m_usingTabs )
343 { 342 {
344 ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove ) 343 ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove )
345 : m_tabBar->setShape( QTabBar::RoundedBelow ); 344 : m_tabBar->setShape( QTabBar::RoundedBelow );
346 } 345 }
347 346
348 // Redraw widget 347 // Redraw widget
349 setUpLayout(); 348 setUpLayout();
350} 349}
351 350
352void OTabWidget::slotTabBarSelected( int id ) 351void OTabWidget::slotTabBarSelected( int id )
353{ 352{
354 OTabInfo *newtab = m_tabs.first(); 353 OTabInfo *newtab = m_tabs.first();
355 while ( newtab && newtab->id() != id ) 354 while ( newtab && newtab->id() != id )
356 newtab = m_tabs.next(); 355 newtab = m_tabs.next();
357 356
358 if ( newtab && newtab->id() == id ) 357 if ( newtab && newtab->id() == id )
359 selectTab( newtab ); 358 selectTab( newtab );
360} 359}
361 360
362void OTabWidget::slotTabListSelected( int index ) 361void OTabWidget::slotTabListSelected( int index )
363{ 362{
364 OTabInfo *newtab = m_tabs.at( index ); 363 OTabInfo *newtab = m_tabs.at( index );
365 if ( newtab ) 364 if ( newtab )
366 selectTab( newtab ); 365 selectTab( newtab );
367} 366}
368 367
369void OTabWidget::selectTab( OTabInfo *tab ) 368void OTabWidget::selectTab( OTabInfo *tab )
370{ 369{
371 if ( m_tabBarStyle == IconTab ) 370 if ( m_tabBarStyle == IconTab )
372 { 371 {
373 // Remove text label from currently selected tab 372 // Remove text label from currently selected tab
374 if ( m_currTab ) 373 if ( m_currTab )
375 { 374 {
376 m_tabBar->tab( m_currTab->id() )->setText( QString::null ); 375 m_tabBar->tab( m_currTab->id() )->setText( QString::null );
377 //setUpLayout(); 376 //setUpLayout();
378 } 377 }
379 378
380 // Set text label for newly selected tab 379 // Set text label for newly selected tab
381 m_tabBar->tab( tab->id() )->setText( tab->label() ); 380 m_tabBar->tab( tab->id() )->setText( tab->label() );
382 m_tabBar->setCurrentTab( tab->id() ); 381 m_tabBar->setCurrentTab( tab->id() );
383 382
384 setUpLayout(); 383 setUpLayout();
385 384
386 QSize t; 385 QSize t;
387 386
388 t = m_tabBar->sizeHint(); 387 t = m_tabBar->sizeHint();
389 if ( t.width() > width() ) 388 if ( t.width() > width() )
390 t.setWidth( width() ); 389 t.setWidth( width() );
391 int lw = m_widgetStack->lineWidth(); 390 int lw = m_widgetStack->lineWidth();
392 if ( m_tabBarPosition == Bottom ) 391 if ( m_tabBarPosition == Bottom )
393 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 392 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
394 else 393 else
395 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 394 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
396 } 395 }
397 else if ( m_tabBarStyle == TextTab ) 396 else if ( m_tabBarStyle == TextTab )
398 { 397 {
399 m_tabBar->setCurrentTab( tab->id() ); 398 m_tabBar->setCurrentTab( tab->id() );
400 } 399 }
401 400
402 m_widgetStack->raiseWidget( tab->control() ); 401 m_widgetStack->raiseWidget( tab->control() );
403 402
404 emit currentChanged( tab->control() ); 403 emit currentChanged( tab->control() );
405 404
406 m_currTab = tab; 405 m_currTab = tab;
407} 406}
408 407
409void OTabWidget::setUpLayout() 408void OTabWidget::setUpLayout()
410{ 409{
411 if ( m_usingTabs ) 410 if ( m_usingTabs )
412 { 411 {
413 m_tabBar->update(); 412 m_tabBar->update();
414 m_tabBar->layoutTabs(); 413 m_tabBar->layoutTabs();
415 } 414 }
416} 415}
417 416
418void OTabWidget::resizeEvent( QResizeEvent * ) 417void OTabWidget::resizeEvent( QResizeEvent * )
419{ 418{
420 QSize t; 419 QSize t;
421 420
422 if ( m_usingTabs ) 421 if ( m_usingTabs )
423 { 422 {
424 m_tabBar->layoutTabs(); 423 m_tabBar->layoutTabs();
425 t = m_tabBar->sizeHint(); 424 t = m_tabBar->sizeHint();
426 if ( t.width() > width() ) 425 if ( t.width() > width() )
427 t.setWidth( width() ); 426 t.setWidth( width() );
428 } 427 }
429 else 428 else
430 { 429 {
431 t = m_tabList->sizeHint(); 430 t = m_tabList->sizeHint();
432 t.setWidth( width() ); 431 t.setWidth( width() );
433 } 432 }
434 433
435 int lw = m_widgetStack->lineWidth(); 434 int lw = m_widgetStack->lineWidth();
436 if ( m_tabBarPosition == Bottom ) 435 if ( m_tabBarPosition == Bottom )
437 { 436 {
438 if ( m_usingTabs ) 437 if ( m_usingTabs )
439 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 438 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
440 else 439 else
441 m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 440 m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
442 441
443 m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); 442 m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
444 } 443 }
445 else 444 else
446 { 445 {
447 if ( m_usingTabs ) 446 if ( m_usingTabs )
448 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 447 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
449 else 448 else
450 m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 449 m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
451 450
452 m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); 451 m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) );
453 } 452 }
454 453
455 if ( autoMask() ) 454 if ( autoMask() )
456 updateMask(); 455 updateMask();
457} 456}
458 457
459int OTabWidget::currentTab() 458int OTabWidget::currentTab()
460{ 459{
461 if ( m_currTab ) 460 if ( m_currTab )
462 { 461 {
463 return m_currTab->id(); 462 return m_currTab->id();
464 } 463 }
465 return -1; 464 return -1;
466} 465}
467 466
468QWidget* OTabWidget::currentWidget()const 467QWidget* OTabWidget::currentWidget()const
469{ 468{
470 if ( m_currTab ) 469 if ( m_currTab )
471 { 470 {
472 return m_currTab->control(); 471 return m_currTab->control();
473 } 472 }
474 473
475 return 0; 474 return 0;
476} 475}
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
@@ -1,1102 +1,1106 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qtopia/qpeapplication.h> 21#include <qtopia/qpeapplication.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qtoolbutton.h> 23#include <qtoolbutton.h>
24#include <qpainter.h> 24#include <qpainter.h>
25#include <qfontmetrics.h> 25#include <qfontmetrics.h>
26#include <qpalette.h> 26#include <qpalette.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qscrollbar.h> 28#include <qscrollbar.h>
29#include <qbutton.h> 29#include <qbutton.h>
30#include <qframe.h> 30#include <qframe.h>
31#include <qtabbar.h> 31#include <qtabbar.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qmap.h> 34#include <qmap.h>
35 35
36#define INCLUDE_MENUITEM_DEF 36#define INCLUDE_MENUITEM_DEF
37#include <qmenudata.h> 37#include <qmenudata.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39 39
40#include "flat.h" 40#include "flat.h"
41 41
42#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 42#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
43 43
44class SpinBoxHack : public QSpinBox 44class SpinBoxHack : public QSpinBox
45{ 45{
46public: 46public:
47 void setFlatButtons( bool f ) { 47 void setFlatButtons( bool f ) {
48 upButton()->setFlat( f ); 48 upButton()->setFlat( f );
49 downButton()->setFlat( f ); 49 downButton()->setFlat( f );
50 } 50 }
51}; 51};
52 52
53class FlatStylePrivate : public QObject 53class FlatStylePrivate : public QObject
54{ 54{
55 Q_OBJECT 55 Q_OBJECT
56public: 56public:
57 FlatStylePrivate() : QObject() {} 57 FlatStylePrivate() : QObject() {}
58 58
59 bool eventFilter( QObject *o, QEvent *e ) { 59 bool eventFilter( QObject *o, QEvent *e ) {
60 if ( e->type() == QEvent::ParentPaletteChange ) { 60 if ( e->type() == QEvent::ParentPaletteChange ) {
61 if ( o->inherits( "QMenuBar" ) ) { 61 if ( o->inherits( "QMenuBar" ) ) {
62 QWidget *w = (QWidget *)o; 62 QWidget *w = (QWidget *)o;
63 if ( w->parentWidget() ) { 63 if ( w->parentWidget() ) {
64 QPalette p = w->parentWidget()->palette(); 64 QPalette p = w->parentWidget()->palette();
65 QColorGroup a = p.active(); 65 QColorGroup a = p.active();
66 a.setColor( QColorGroup::Light, a.foreground() ); 66 a.setColor( QColorGroup::Light, a.foreground() );
67 a.setColor( QColorGroup::Dark, a.foreground() ); 67 a.setColor( QColorGroup::Dark, a.foreground() );
68 p.setActive( a ); 68 p.setActive( a );
69 p.setInactive( a ); 69 p.setInactive( a );
70 w->setPalette( p ); 70 w->setPalette( p );
71 } 71 }
72 } else if ( o->inherits( "QHeader" ) ) { 72 } else if ( o->inherits( "QHeader" ) ) {
73 QWidget *w = (QWidget *)o; 73 QWidget *w = (QWidget *)o;
74 if ( w->parentWidget() ) { 74 if ( w->parentWidget() ) {
75 QPalette p = w->parentWidget()->palette(); 75 QPalette p = w->parentWidget()->palette();
76 QColorGroup a = p.active(); 76 QColorGroup a = p.active();
77 a.setColor( QColorGroup::Light, a.button() ); 77 a.setColor( QColorGroup::Light, a.button() );
78 p.setActive( a ); 78 p.setActive( a );
79 p.setInactive( a ); 79 p.setInactive( a );
80 w->setPalette( p ); 80 w->setPalette( p );
81 } 81 }
82 } 82 }
83 } 83 }
84 return FALSE; 84 return FALSE;
85 } 85 }
86 86
87 QMap<QFrame *,int> frameStyles; 87 QMap<QFrame *,int> frameStyles;
88}; 88};
89 89
90FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE) 90FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE)
91{ 91{
92 setButtonMargin(3); 92 setButtonMargin(3);
93 setScrollBarExtent(13,13); 93 setScrollBarExtent(13,13);
94 setButtonDefaultIndicatorWidth(0); 94 setButtonDefaultIndicatorWidth(0);
95 d = new FlatStylePrivate; 95 d = new FlatStylePrivate;
96} 96}
97 97
98FlatStyle::~FlatStyle() 98FlatStyle::~FlatStyle()
99{ 99{
100 delete d; 100 delete d;
101} 101}
102 102
103int FlatStyle::buttonMargin() const 103int FlatStyle::buttonMargin() const
104{ 104{
105 return 3; 105 return 3;
106} 106}
107 107
108QSize FlatStyle::scrollBarExtent() const 108QSize FlatStyle::scrollBarExtent() const
109{ 109{
110 return QSize(13,13); 110 return QSize(13,13);
111} 111}
112 112
113void FlatStyle::polish ( QPalette & ) 113void FlatStyle::polish ( QPalette & )
114{ 114{
115} 115}
116 116
117void FlatStyle::polish( QWidget *w ) 117void FlatStyle::polish( QWidget *w )
118{ 118{
119 if ( w->inherits( "QFrame" ) ) { 119 if ( w->inherits( "QFrame" ) ) {
120 QFrame *f = (QFrame *)w; 120 QFrame *f = (QFrame *)w;
121 if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) 121 if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine )
122 f->setFrameShadow( QFrame::Plain ); 122 f->setFrameShadow( QFrame::Plain );
123 else if ( f->frameShape() != QFrame::NoFrame ) 123 else if ( f->frameShape() != QFrame::NoFrame )
124 f->setFrameShape( QFrame::StyledPanel ); 124 f->setFrameShape( QFrame::StyledPanel );
125 f->setLineWidth( 1 ); 125 f->setLineWidth( 1 );
126 } 126 }
127 if ( w->inherits( "QSpinBox" ) ) 127 if ( w->inherits( "QSpinBox" ) )
128 ((SpinBoxHack*)w)->setFlatButtons( TRUE ); 128 ((SpinBoxHack*)w)->setFlatButtons( TRUE );
129 if ( w->inherits( "QMenuBar" ) ) { 129 if ( w->inherits( "QMenuBar" ) ) {
130 // make selected item look flat 130 // make selected item look flat
131 QPalette p = w->palette(); 131 QPalette p = w->palette();
132 QColorGroup a = p.active(); 132 QColorGroup a = p.active();
133 a.setColor( QColorGroup::Light, a.foreground() ); 133 a.setColor( QColorGroup::Light, a.foreground() );
134 a.setColor( QColorGroup::Dark, a.foreground() ); 134 a.setColor( QColorGroup::Dark, a.foreground() );
135 p.setActive( a ); 135 p.setActive( a );
136 p.setInactive( a ); 136 p.setInactive( a );
137 w->setPalette( p ); 137 w->setPalette( p );
138 w->installEventFilter( d ); 138 w->installEventFilter( d );
139 } else if ( w->inherits( "QHeader" ) ) { 139 } else if ( w->inherits( "QHeader" ) ) {
140 // make headers look flat 140 // make headers look flat
141 QPalette p = w->palette(); 141 QPalette p = w->palette();
142 QColorGroup a = p.active(); 142 QColorGroup a = p.active();
143 a.setColor( QColorGroup::Light, a.button() ); 143 a.setColor( QColorGroup::Light, a.button() );
144 p.setActive( a ); 144 p.setActive( a );
145 p.setInactive( a ); 145 p.setInactive( a );
146 w->setPalette( p ); 146 w->setPalette( p );
147 w->installEventFilter( d ); 147 w->installEventFilter( d );
148 } 148 }
149} 149}
150 150
151void FlatStyle::unPolish( QWidget *w ) 151void FlatStyle::unPolish( QWidget *w )
152{ 152{
153 if ( w->inherits("QFrame") ) { 153 if ( w->inherits("QFrame") ) {
154 QFrame *f = (QFrame *)w; 154 QFrame *f = (QFrame *)w;
155 if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) { 155 if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) {
156 f->setFrameShadow( QFrame::Sunken ); 156 f->setFrameShadow( QFrame::Sunken );
157 } else if ( f->frameShape() != QFrame::NoFrame ) { 157 } else if ( f->frameShape() != QFrame::NoFrame ) {
158 f->setFrameShape( QFrame::StyledPanel ); 158 f->setFrameShape( QFrame::StyledPanel );
159 f->setLineWidth( 2 ); 159 f->setLineWidth( 2 );
160 } 160 }
161 } 161 }
162 if ( w->inherits("QSpinBox") ) 162 if ( w->inherits("QSpinBox") )
163 ((SpinBoxHack*)w)->setFlatButtons( FALSE ); 163 ((SpinBoxHack*)w)->setFlatButtons( FALSE );
164 if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) { 164 if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) {
165 w->unsetPalette(); 165 w->unsetPalette();
166 w->removeEventFilter( d ); 166 w->removeEventFilter( d );
167 } 167 }
168} 168}
169 169
170int FlatStyle::defaultFrameWidth() const 170int FlatStyle::defaultFrameWidth() const
171{ 171{
172 return 2; 172 return 2;
173} 173}
174 174
175void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h, 175void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h,
176 int flags, const QColorGroup &g, bool enabled, 176 int flags, const QColorGroup &g, bool enabled,
177 const QPixmap *pixmap, const QString& text, int len, 177 const QPixmap *pixmap, const QString& text, int len,
178 const QColor* penColor ) 178 const QColor* penColor )
179{ 179{
180 QColor pc( penColor ? *penColor : g.foreground() ); 180 QColor pc( penColor ? *penColor : g.foreground() );
181 QColorGroup cg( g ); 181 QColorGroup cg( g );
182 if ( !enabled ) 182 if ( !enabled )
183 cg.setColor( QColorGroup::Light, cg.background() ); 183 cg.setColor( QColorGroup::Light, cg.background() );
184 if ( revItem ) { 184 if ( revItem ) {
185 pc = cg.button(); 185 pc = cg.button();
186 revItem = FALSE; 186 revItem = FALSE;
187 } 187 }
188 QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc ); 188 QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc );
189} 189}
190 190
191void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, 191void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
192 const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill ) 192 const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill )
193{ 193{
194 if ( fill ) 194 if ( fill )
195 p->setBrush( *fill ); 195 p->setBrush( *fill );
196 p->setPen( QPen(g.foreground(), lineWidth) ); 196 p->setPen( QPen(g.foreground(), lineWidth) );
197 p->drawRect( x, y, w, h ); 197 p->drawRect( x, y, w, h );
198} 198}
199 199
200void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, 200void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h,
201 const QColorGroup &cg, bool /*sunken*/, const QBrush* fill ) 201 const QColorGroup &cg, bool /*sunken*/, const QBrush* fill )
202{ 202{
203 QPen oldPen = p->pen(); 203 QPen oldPen = p->pen();
204 204
205 int x2 = x+w-1; 205 int x2 = x+w-1;
206 int y2 = y+h-1; 206 int y2 = y+h-1;
207 207
208 if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) { 208 if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) {
209 p->setPen( btnBg ); 209 p->setPen( btnBg );
210 p->drawLine( x, y, x2, y ); 210 p->drawLine( x, y, x2, y );
211 p->drawLine( x, y2, x2, y2 ); 211 p->drawLine( x, y2, x2, y2 );
212 p->drawLine( x, y+1, x, y2-1 ); 212 p->drawLine( x, y+1, x, y2-1 );
213 p->drawLine( x2, y+1, x2, y2-1 ); 213 p->drawLine( x2, y+1, x2, y2-1 );
214 p->fillRect( x+1, y+1, 3, 3, btnBg ); 214 p->fillRect( x+1, y+1, 3, 3, btnBg );
215 p->fillRect( x+1, y2-3, 3, 3, btnBg ); 215 p->fillRect( x+1, y2-3, 3, 3, btnBg );
216 p->fillRect( x2-3, y2-3, 3, 3, btnBg ); 216 p->fillRect( x2-3, y2-3, 3, 3, btnBg );
217 p->fillRect( x2-3, y+1, 3, 3, btnBg ); 217 p->fillRect( x2-3, y+1, 3, 3, btnBg );
218 p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) ); 218 p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) );
219 } else { 219 } else {
220 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); 220 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) );
221 } 221 }
222 222
223 if ( h >= 10 ) { 223 if ( h >= 10 ) {
224 x++; y++; 224 x++; y++;
225 x2--; y2--; 225 x2--; y2--;
226 w -= 2; h -= 2; 226 w -= 2; h -= 2;
227 } 227 }
228 228
229 p->setPen( cg.foreground() ); 229 p->setPen( cg.foreground() );
230 230
231 if ( h < 10 ) { 231 if ( h < 10 ) {
232 p->setBrush( NoBrush ); 232 p->setBrush( NoBrush );
233 p->drawRect( x, y, w, h ); 233 p->drawRect( x, y, w, h );
234 } else { 234 } else {
235 p->drawLine( x+3, y, x2-3, y ); 235 p->drawLine( x+3, y, x2-3, y );
236 p->drawLine( x+3, y2, x2-3, y2 ); 236 p->drawLine( x+3, y2, x2-3, y2 );
237 p->drawLine( x, y+3, x, y2-3 ); 237 p->drawLine( x, y+3, x, y2-3 );
238 p->drawLine( x2, y+3, x2, y2-3 ); 238 p->drawLine( x2, y+3, x2, y2-3 );
239 239
240 p->drawLine( x+1, y+1, x+2, y+1 ); 240 p->drawLine( x+1, y+1, x+2, y+1 );
241 p->drawPoint( x+1, y+2 ); 241 p->drawPoint( x+1, y+2 );
242 p->drawLine( x2-2, y+1, x2-1, y+1 ); 242 p->drawLine( x2-2, y+1, x2-1, y+1 );
243 p->drawPoint( x2-1, y+2 ); 243 p->drawPoint( x2-1, y+2 );
244 244
245 p->drawLine( x+1, y2-1, x+2, y2-1 ); 245 p->drawLine( x+1, y2-1, x+2, y2-1 );
246 p->drawPoint( x+1, y2-2 ); 246 p->drawPoint( x+1, y2-2 );
247 p->drawLine( x2-2, y2-1, x2-1, y2-1 ); 247 p->drawLine( x2-2, y2-1, x2-1, y2-1 );
248 p->drawPoint( x2-1, y2-2 ); 248 p->drawPoint( x2-1, y2-2 );
249 } 249 }
250 250
251 p->setPen( oldPen ); 251 p->setPen( oldPen );
252} 252}
253 253
254void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) 254void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
255{ 255{
256 x++; y++; 256 x++; y++;
257 x-=2; y-=2; 257 x-=2; y-=2;
258 p->fillRect( x, y, w, h, color1 ); 258 p->fillRect( x, y, w, h, color1 );
259} 259}
260 260
261void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 261void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
262 const QColorGroup &g, bool /*sunken*/, const QBrush* fill ) 262 const QColorGroup &g, bool /*sunken*/, const QBrush* fill )
263{ 263{
264 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); 264 p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
265 p->setPen( g.foreground() ); 265 p->setPen( g.foreground() );
266 p->setBrush( NoBrush ); 266 p->setBrush( NoBrush );
267 p->drawRect( x, y, w, h ); 267 p->drawRect( x, y, w, h );
268} 268}
269 269
270void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, 270void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
271 const QColorGroup &g, bool sunken, const QBrush* fill ) 271 const QColorGroup &g, bool sunken, const QBrush* fill )
272{ 272{
273 if ( p->device()->devType() == QInternal::Widget ) { 273 if ( p->device()->devType() == QInternal::Widget ) {
274 QWidget *w = (QWidget *)p->device(); 274 QWidget *w = (QWidget *)p->device();
275 if ( w->isA("QToolButton") ) { 275 if ( w->isA("QToolButton") ) {
276 QToolButton *btn = (QToolButton *)w; 276 QToolButton *btn = (QToolButton *)w;
277 if ( btn->parentWidget() ) { 277 if ( btn->parentWidget() ) {
278 btnBg = btn->parentWidget()->backgroundColor(); 278 btnBg = btn->parentWidget()->backgroundColor();
279 fillBtnBorder = TRUE; 279 fillBtnBorder = TRUE;
280 } 280 }
281 } 281 }
282 } 282 }
283 QBrush fb( fill ? *fill : g.button() ); 283 QBrush fb( fill ? *fill : g.button() );
284 if ( sunken && fb == g.brush( QColorGroup::Button ) ) { 284 if ( sunken && fb == g.brush( QColorGroup::Button ) ) {
285 fb = g.buttonText(); 285 fb = g.buttonText();
286 revItem = TRUE;// ugh 286 revItem = TRUE;// ugh
287 } 287 }
288 drawButton( p, x, y, w, h, g, sunken, &fb ); 288 drawButton( p, x, y, w, h, g, sunken, &fb );
289 fillBtnBorder = FALSE; 289 fillBtnBorder = FALSE;
290} 290}
291 291
292void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) 292void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p )
293{ 293{
294 QColorGroup g = btn->colorGroup(); 294 QColorGroup g = btn->colorGroup();
295 int x1, y1, x2, y2; 295 int x1, y1, x2, y2;
296 296
297 btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates 297 btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates
298 298
299 p->setPen( g.foreground() ); 299 p->setPen( g.foreground() );
300 p->setBrush( QBrush(g.button(),NoBrush) ); 300 p->setBrush( QBrush(g.button(),NoBrush) );
301 301
302// int diw = buttonDefaultIndicatorWidth(); 302// int diw = buttonDefaultIndicatorWidth();
303 /* 303 /*
304 if ( btn->isDefault() || btn->autoDefault() ) { 304 if ( btn->isDefault() || btn->autoDefault() ) {
305 if ( btn->isDefault() ) { 305 if ( btn->isDefault() ) {
306 p->setPen( g.shadow() ); 306 p->setPen( g.shadow() );
307 p->drawRect( x1, y1, x2-x1+1, y2-y1+1 ); 307 p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
308 } 308 }
309 x1 += diw; 309 x1 += diw;
310 y1 += diw; 310 y1 += diw;
311 x2 -= diw; 311 x2 -= diw;
312 y2 -= diw; 312 y2 -= diw;
313 } 313 }
314 */ 314 */
315 315
316 if ( btn->parentWidget() ) { 316 if ( btn->parentWidget() ) {
317 btnBg = btn->parentWidget()->backgroundColor(); 317 btnBg = btn->parentWidget()->backgroundColor();
318 fillBtnBorder = TRUE; 318 fillBtnBorder = TRUE;
319 } 319 }
320 320
321 bool clearButton = TRUE; 321 bool clearButton = TRUE;
322 if ( btn->isDown() ) { 322 if ( btn->isDown() ) {
323 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, 323 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE,
324 &g.brush( QColorGroup::Text ) ); 324 &g.brush( QColorGroup::Text ) );
325 } else { 325 } else {
326 if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) { 326 if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) {
327 QBrush fill(g.light(), Dense4Pattern ); 327 QBrush fill(g.light(), Dense4Pattern );
328 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill ); 328 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill );
329 clearButton = FALSE; 329 clearButton = FALSE;
330 } else { 330 } else {
331 if ( !btn->isFlat() ) 331 if ( !btn->isFlat() )
332 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(), 332 drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(),
333 &g.brush( QColorGroup::Button ) ); 333 &g.brush( QColorGroup::Button ) );
334 } 334 }
335 } 335 }
336 /* 336 /*
337 if ( clearButton ) { 337 if ( clearButton ) {
338 if (btn->isDown()) 338 if (btn->isDown())
339 p->setBrushOrigin(p->brushOrigin() + QPoint(1,1)); 339 p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
340 p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3, 340 p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3,
341 g.brush( QColorGroup::Button ) ); 341 g.brush( QColorGroup::Button ) );
342 if (btn->isDown()) 342 if (btn->isDown())
343 p->setBrushOrigin(p->brushOrigin() - QPoint(1,1)); 343 p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
344 } 344 }
345 */ 345 */
346 346
347 fillBtnBorder = FALSE; 347 fillBtnBorder = FALSE;
348 if ( p->brush().style() != NoBrush ) 348 if ( p->brush().style() != NoBrush )
349 p->setBrush( NoBrush ); 349 p->setBrush( NoBrush );
350} 350}
351 351
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 }
420 drawArrow( p, QStyle::DownArrow, FALSE, 420 drawArrow( p, QStyle::DownArrow, FALSE,
421 x+w-13, y+1, 12, h-2, cg, enabled, 421 x+w-13, y+1, 12, h-2, cg, enabled,
422 &cg.brush( QColorGroup::Button ) ); 422 &cg.brush( QColorGroup::Button ) );
423 423
424} 424}
425 425
426 426
427void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, 427void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
428 int h, const QColorGroup &cg, bool on, bool down, bool enabled ) 428 int h, const QColorGroup &cg, bool on, bool down, bool enabled )
429{ 429{
430 static const QCOORD pts1[] = { // dark lines 430 static const QCOORD pts1[] = { // dark lines
431 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 431 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
432 static const QCOORD pts4[] = { // white lines 432 static const QCOORD pts4[] = { // white lines
433 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 433 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
434 11,4, 10,3, 10,2 }; 434 11,4, 10,3, 10,2 };
435 static const QCOORD pts5[] = { // inner fill 435 static const QCOORD pts5[] = { // inner fill
436 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 436 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
437 437
438 p->eraseRect( x, y, w, h ); 438 p->eraseRect( x, y, w, h );
439 QPointArray a( QCOORDARRLEN(pts1), pts4 ); 439 QPointArray a( QCOORDARRLEN(pts1), pts4 );
440 a.translate( x, y ); 440 a.translate( x, y );
441 p->setPen( cg.foreground() ); 441 p->setPen( cg.foreground() );
442 p->drawPolyline( a ); 442 p->drawPolyline( a );
443 a.setPoints( QCOORDARRLEN(pts4), pts1 ); 443 a.setPoints( QCOORDARRLEN(pts4), pts1 );
444 a.translate( x, y ); 444 a.translate( x, y );
445 p->setPen( cg.foreground() ); 445 p->setPen( cg.foreground() );
446 p->drawPolyline( a ); 446 p->drawPolyline( a );
447 a.setPoints( QCOORDARRLEN(pts5), pts5 ); 447 a.setPoints( QCOORDARRLEN(pts5), pts5 );
448 a.translate( x, y ); 448 a.translate( x, y );
449 QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base(); 449 QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
450 p->setPen( fillColor ); 450 p->setPen( fillColor );
451 p->setBrush( fillColor ) ; 451 p->setBrush( fillColor ) ;
452 p->drawPolygon( a ); 452 p->drawPolygon( a );
453 if ( on ) { 453 if ( on ) {
454 p->setPen( NoPen ); 454 p->setPen( NoPen );
455 p->setBrush( cg.text() ); 455 p->setBrush( cg.text() );
456 p->drawRect( x+5, y+4, 2, 4 ); 456 p->drawRect( x+5, y+4, 2, 4 );
457 p->drawRect( x+4, y+5, 4, 2 ); 457 p->drawRect( x+4, y+5, 4, 2 );
458 } 458 }
459} 459}
460 460
461void FlatStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h, 461void FlatStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
462 const QColorGroup &cg, int state, bool down, bool enabled ) 462 const QColorGroup &cg, int state, bool down, bool enabled )
463{ 463{
464 QColorGroup mycg( cg ); 464 QColorGroup mycg( cg );
465 mycg.setBrush( QColorGroup::Button, QBrush() ); 465 mycg.setBrush( QColorGroup::Button, QBrush() );
466 QBrush fill; 466 QBrush fill;
467 drawButton( p, x, y, w, h, mycg, TRUE, 0 ); 467 drawButton( p, x, y, w, h, mycg, TRUE, 0 );
468 if ( down ) 468 if ( down )
469 fill = cg.brush( QColorGroup::Button ); 469 fill = cg.brush( QColorGroup::Button );
470 else 470 else
471 fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); 471 fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
472 mycg.setBrush( QColorGroup::Button, fill ); 472 mycg.setBrush( QColorGroup::Button, fill );
473 p->fillRect( x+1, y+1, w-2, h-2, fill ); 473 p->fillRect( x+1, y+1, w-2, h-2, fill );
474 if ( state != QButton::Off ) { 474 if ( state != QButton::Off ) {
475 QPointArray a( 7*2 ); 475 QPointArray a( 7*2 );
476 int i, xx, yy; 476 int i, xx, yy;
477 xx = x+3; 477 xx = x+3;
478 yy = y+5; 478 yy = y+5;
479 for ( i=0; i<3; i++ ) { 479 for ( i=0; i<3; i++ ) {
480 a.setPoint( 2*i, xx, yy ); 480 a.setPoint( 2*i, xx, yy );
481 a.setPoint( 2*i+1, xx, yy+2 ); 481 a.setPoint( 2*i+1, xx, yy+2 );
482 xx++; yy++; 482 xx++; yy++;
483 } 483 }
484 yy -= 2; 484 yy -= 2;
485 for ( i=3; i<7; i++ ) { 485 for ( i=3; i<7; i++ ) {
486 a.setPoint( 2*i, xx, yy ); 486 a.setPoint( 2*i, xx, yy );
487 a.setPoint( 2*i+1, xx, yy+2 ); 487 a.setPoint( 2*i+1, xx, yy+2 );
488 xx++; yy--; 488 xx++; yy--;
489 } 489 }
490 if ( state == QButton::NoChange ) { 490 if ( state == QButton::NoChange ) {
491 p->setPen( mycg.dark() ); 491 p->setPen( mycg.dark() );
492 } else { 492 } else {
493 p->setPen( mycg.text() ); 493 p->setPen( mycg.text() );
494 } 494 }
495 p->drawLineSegments( a ); 495 p->drawLineSegments( a );
496 } 496 }
497} 497}
498 498
499 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal) 499 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal)
500 #define VERTICAL!HORIZONTAL 500 #define VERTICAL!HORIZONTAL
501 #define MOTIF_BORDER2 501 #define MOTIF_BORDER2
502 #define SLIDER_MIN9 // ### motif says 6 but that's too small 502 #define SLIDER_MIN9 // ### motif says 6 but that's too small
503 503
504/*! \reimp */ 504/*! \reimp */
505 505
506void FlatStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim ) 506void FlatStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim )
507{ 507{
508 int maxLength; 508 int maxLength;
509 int length = HORIZONTAL ? sb->width() : sb->height(); 509 int length = HORIZONTAL ? sb->width() : sb->height();
510 int extent = HORIZONTAL ? sb->height() : sb->width(); 510 int extent = HORIZONTAL ? sb->height() : sb->width();
511 511
512 if ( length > (extent - 1)*2 ) 512 if ( length > (extent - 1)*2 )
513 buttonDim = extent; 513 buttonDim = extent;
514 else 514 else
515 buttonDim = length/2 - 1; 515 buttonDim = length/2 - 1;
516 516
517 sliderMin = 0; 517 sliderMin = 0;
518 maxLength = length - buttonDim*2 + 2; 518 maxLength = length - buttonDim*2 + 2;
519 519
520 if ( sb->maxValue() == sb->minValue() ) { 520 if ( sb->maxValue() == sb->minValue() ) {
521 sliderLength = maxLength; 521 sliderLength = maxLength;
522 } else { 522 } else {
523 sliderLength = (sb->pageStep()*maxLength)/ 523 sliderLength = (sb->pageStep()*maxLength)/
524 (sb->maxValue()-sb->minValue()+sb->pageStep()); 524 (sb->maxValue()-sb->minValue()+sb->pageStep());
525 uint range = sb->maxValue()-sb->minValue(); 525 uint range = sb->maxValue()-sb->minValue();
526 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 ) 526 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
527 sliderLength = SLIDER_MIN; 527 sliderLength = SLIDER_MIN;
528 if ( sliderLength > maxLength ) 528 if ( sliderLength > maxLength )
529 sliderLength = maxLength; 529 sliderLength = maxLength;
530 } 530 }
531 531
532 sliderMax = sliderMin + maxLength - sliderLength; 532 sliderMax = sliderMin + maxLength - sliderLength;
533} 533}
534 534
535/*!\reimp 535/*!\reimp
536 */ 536 */
537QStyle::ScrollControl FlatStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ) 537QStyle::ScrollControl FlatStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p )
538{ 538{
539 if ( !sb->rect().contains( p ) ) 539 if ( !sb->rect().contains( p ) )
540 return NoScroll; 540 return NoScroll;
541 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 541 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
542 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 542 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
543 543
544 if (sb->orientation() == QScrollBar::Horizontal) 544 if (sb->orientation() == QScrollBar::Horizontal)
545 pos = p.x(); 545 pos = p.x();
546 else 546 else
547 pos = p.y(); 547 pos = p.y();
548 548
549 if (pos < sliderStart) 549 if (pos < sliderStart)
550 return SubPage; 550 return SubPage;
551 if (pos < sliderStart + sliderLength) 551 if (pos < sliderStart + sliderLength)
552 return Slider; 552 return Slider;
553 if (pos < sliderMax + sliderLength) 553 if (pos < sliderMax + sliderLength)
554 return AddPage; 554 return AddPage;
555 if (pos < sliderMax + sliderLength + buttonDim) 555 if (pos < sliderMax + sliderLength + buttonDim)
556 return SubLine; 556 return SubLine;
557 return AddLine; 557 return AddLine;
558} 558}
559 559
560/*! \reimp */ 560/*! \reimp */
561 561
562void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) 562void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
563{ 563{
564#define ADD_LINE_ACTIVE ( activeControl == AddLine ) 564#define ADD_LINE_ACTIVE ( activeControl == AddLine )
565#define SUB_LINE_ACTIVE ( activeControl == SubLine ) 565#define SUB_LINE_ACTIVE ( activeControl == SubLine )
566 QColorGroup g = sb->colorGroup(); 566 QColorGroup g = sb->colorGroup();
567 567
568 int sliderMin, sliderMax, sliderLength, buttonDim; 568 int sliderMin, sliderMax, sliderLength, buttonDim;
569 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 569 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
570 570
571 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) { 571 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) {
572 p->setPen( g.foreground() ); 572 p->setPen( g.foreground() );
573 p->setBrush( g.brush( QColorGroup::Mid ) ); 573 p->setBrush( g.brush( QColorGroup::Mid ) );
574 p->drawRect( 0, 0, sb->width(), sb->height() ); 574 p->drawRect( 0, 0, sb->width(), sb->height() );
575 } 575 }
576 576
577 if (sliderStart > sliderMax) { // sanity check 577 if (sliderStart > sliderMax) { // sanity check
578 sliderStart = sliderMax; 578 sliderStart = sliderMax;
579 } 579 }
580 580
581 int dimB = buttonDim; 581 int dimB = buttonDim;
582 QRect addB; 582 QRect addB;
583 QRect subB; 583 QRect subB;
584 QRect addPageR; 584 QRect addPageR;
585 QRect subPageR; 585 QRect subPageR;
586 QRect sliderR; 586 QRect sliderR;
587 int addX, addY, subX, subY; 587 int addX, addY, subX, subY;
588 int length = HORIZONTAL ? sb->width() : sb->height(); 588 int length = HORIZONTAL ? sb->width() : sb->height();
589 int extent = HORIZONTAL ? sb->height() : sb->width(); 589 int extent = HORIZONTAL ? sb->height() : sb->width();
590 590
591 if ( HORIZONTAL ) { 591 if ( HORIZONTAL ) {
592 subY = addY = ( extent - dimB ) / 2; 592 subY = addY = ( extent - dimB ) / 2;
593 subX = length - dimB - dimB + 1; 593 subX = length - dimB - dimB + 1;
594 addX = length - dimB; 594 addX = length - dimB;
595 } else { 595 } else {
596 subX = addX = ( extent - dimB ) / 2; 596 subX = addX = ( extent - dimB ) / 2;
597 subY = length - dimB - dimB + 1; 597 subY = length - dimB - dimB + 1;
598 addY = length - dimB; 598 addY = length - dimB;
599 } 599 }
600 600
601 int sliderEnd = sliderStart + sliderLength; 601 int sliderEnd = sliderStart + sliderLength;
602 int sliderW = extent; 602 int sliderW = extent;
603 if ( HORIZONTAL ) { 603 if ( HORIZONTAL ) {
604 subB.setRect( subX,subY,dimB,dimB ); 604 subB.setRect( subX,subY,dimB,dimB );
605 addB.setRect( addX,addY,dimB,dimB ); 605 addB.setRect( addX,addY,dimB,dimB );
606 subPageR.setRect( 0, 0, sliderStart+1, sliderW ); 606 subPageR.setRect( 0, 0, sliderStart+1, sliderW );
607 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW ); 607 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW );
608 sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); 608 sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
609 609
610 } else { 610 } else {
611 subB.setRect( subX,subY,dimB,dimB ); 611 subB.setRect( subX,subY,dimB,dimB );
612 addB.setRect( addX,addY,dimB,dimB ); 612 addB.setRect( addX,addY,dimB,dimB );
613 subPageR.setRect( 0, 0, sliderW, sliderStart+1 ); 613 subPageR.setRect( 0, 0, sliderW, sliderStart+1 );
614 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 ); 614 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 );
615 sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); 615 sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
616 } 616 }
617 617
618 bool maxedOut = (sb->maxValue() == sb->minValue()); 618 bool maxedOut = (sb->maxValue() == sb->minValue());
619 p->setPen( g.foreground() ); 619 p->setPen( g.foreground() );
620 if ( controls & AddLine ) { 620 if ( controls & AddLine ) {
621 p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() ); 621 p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() );
622 p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() ); 622 p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() );
623 p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() ); 623 p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() );
624 QColorGroup cg( g ); 624 QColorGroup cg( g );
625 if ( maxedOut ) 625 if ( maxedOut )
626 cg.setColor( QColorGroup::ButtonText, g.mid() ); 626 cg.setColor( QColorGroup::ButtonText, g.mid() );
627 else if ( ADD_LINE_ACTIVE ) 627 else if ( ADD_LINE_ACTIVE )
628 cg.setColor( QColorGroup::ButtonText, g.button() ); 628 cg.setColor( QColorGroup::ButtonText, g.button() );
629 int xo = VERTICAL ? 1 : 0; 629 int xo = VERTICAL ? 1 : 0;
630 drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE, 630 drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE,
631 addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4, 631 addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4,
632 cg, TRUE, &p->brush() ); 632 cg, TRUE, &p->brush() );
633 } 633 }
634 if ( controls & SubLine ) { 634 if ( controls & SubLine ) {
635 p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() ); 635 p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() );
636 p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() ); 636 p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() );
637 p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() ); 637 p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() );
638 QColorGroup cg( g ); 638 QColorGroup cg( g );
639 if ( maxedOut ) 639 if ( maxedOut )
640 cg.setColor( QColorGroup::ButtonText, g.mid() ); 640 cg.setColor( QColorGroup::ButtonText, g.mid() );
641 else if ( SUB_LINE_ACTIVE ) 641 else if ( SUB_LINE_ACTIVE )
642 cg.setColor( QColorGroup::ButtonText, g.button() ); 642 cg.setColor( QColorGroup::ButtonText, g.button() );
643 int xo = VERTICAL ? 1 : 0; 643 int xo = VERTICAL ? 1 : 0;
644 drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE, 644 drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE,
645 subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4, 645 subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4,
646 cg, TRUE, &p->brush() ); 646 cg, TRUE, &p->brush() );
647 } 647 }
648 648
649 649
650 p->setPen( g.foreground() ); 650 p->setPen( g.foreground() );
651 p->setBrush( g.brush( QColorGroup::Mid ) ); 651 p->setBrush( g.brush( QColorGroup::Mid ) );
652 if ( controls & SubPage ) 652 if ( controls & SubPage )
653 p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); 653 p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() );
654 if ( controls & AddPage && addPageR.y() < addPageR.bottom() && 654 if ( controls & AddPage && addPageR.y() < addPageR.bottom() &&
655 addPageR.x() < addPageR.right() ) 655 addPageR.x() < addPageR.right() )
656 p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); 656 p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() );
657 if ( controls & Slider ) { 657 if ( controls & Slider ) {
658 QPoint bo = p->brushOrigin(); 658 QPoint bo = p->brushOrigin();
659 p->setBrushOrigin(sliderR.topLeft()); 659 p->setBrushOrigin(sliderR.topLeft());
660 p->setPen( g.foreground() ); 660 p->setPen( g.foreground() );
661 p->setBrush( g.button() ); 661 p->setBrush( g.button() );
662 p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() ); 662 p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() );
663 p->setBrushOrigin(bo); 663 p->setBrushOrigin(bo);
664 QColorGroup cg( g ); 664 QColorGroup cg( g );
665 if ( maxedOut ) 665 if ( maxedOut )
666 cg.setColor( QColorGroup::ButtonText, g.mid() ); 666 cg.setColor( QColorGroup::ButtonText, g.mid() );
667 drawRiffles( p, sliderR.x(), sliderR.y(), 667 drawRiffles( p, sliderR.x(), sliderR.y(),
668 sliderR.width(), sliderR.height(), cg, HORIZONTAL ); 668 sliderR.width(), sliderR.height(), cg, HORIZONTAL );
669 } 669 }
670 670
671 // ### perhaps this should not be able to accept focus if maxedOut? 671 // ### perhaps this should not be able to accept focus if maxedOut?
672 if ( sb->hasFocus() && (controls & Slider) ) 672 if ( sb->hasFocus() && (controls & Slider) )
673 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, 673 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
674 sliderR.width()-5, sliderR.height()-5, 674 sliderR.width()-5, sliderR.height()-5,
675 sb->backgroundColor() ); 675 sb->backgroundColor() );
676 676
677} 677}
678 678
679void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, 679void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
680 const QColorGroup &g, bool horizontal ) 680 const QColorGroup &g, bool horizontal )
681{ 681{
682 if (!horizontal) { 682 if (!horizontal) {
683 if (h > 20) { 683 if (h > 20) {
684 y += (h-20)/2 ; 684 y += (h-20)/2 ;
685 h = 20; 685 h = 20;
686 } 686 }
687 if (h > 12) { 687 if (h > 12) {
688 int n = 3; 688 int n = 3;
689 int my = y+h/2-2; 689 int my = y+h/2-2;
690 int i ; 690 int i ;
691 p->setPen(g.buttonText()); 691 p->setPen(g.buttonText());
692 for (i=0; i<n; i++) { 692 for (i=0; i<n; i++) {
693 p->drawLine(x+4, my+3*i, x+w-5, my+3*i); 693 p->drawLine(x+4, my+3*i, x+w-5, my+3*i);
694 } 694 }
695 } 695 }
696 } else { 696 } else {
697 if (w > 20) { 697 if (w > 20) {
698 x += (w-20)/2 ; 698 x += (w-20)/2 ;
699 w = 20; 699 w = 20;
700 } 700 }
701 if (w > 12) { 701 if (w > 12) {
702 int n = 3; 702 int n = 3;
703 int mx = x+w/2-4; 703 int mx = x+w/2-4;
704 int i ; 704 int i ;
705 p->setPen(g.buttonText()); 705 p->setPen(g.buttonText());
706 for (i=0; i<n; i++) { 706 for (i=0; i<n; i++) {
707 p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5); 707 p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5);
708 } 708 }
709 } 709 }
710 } 710 }
711} 711}
712 712
713int FlatStyle::sliderLength() const 713int FlatStyle::sliderLength() const
714{ 714{
715 return 12; 715 return 12;
716} 716}
717 717
718void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h, 718void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
719 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) 719 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
720{ 720{
721 int a = tickAbove ? 3 : 0; 721 int a = tickAbove ? 3 : 0;
722 int b = tickBelow ? 3 : 0; 722 int b = tickBelow ? 3 : 0;
723 723
724 p->setPen( g.foreground() ); 724 p->setPen( g.foreground() );
725 p->setBrush( g.button() ); 725 p->setBrush( g.button() );
726 if ( o == Horizontal ) { 726 if ( o == Horizontal ) {
727 p->drawRect( x, y+a, w, h-a-b ); 727 p->drawRect( x, y+a, w, h-a-b );
728 int xp = x + w/2; 728 int xp = x + w/2;
729 p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 ); 729 p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 );
730 p->drawLine( xp, y+a+3, xp, y+h-b-4 ); 730 p->drawLine( xp, y+a+3, xp, y+h-b-4 );
731 } else { 731 } else {
732 p->drawRect( x+a, y, w-a-b, h ); 732 p->drawRect( x+a, y, w-a-b, h );
733 int yp = y + h/2; 733 int yp = y + h/2;
734 p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 ); 734 p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 );
735 p->drawLine( x+a+3, yp, x+w-b-4, yp ); 735 p->drawLine( x+a+3, yp, x+w-b-4, yp );
736 } 736 }
737} 737}
738 738
739void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, 739void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
740 Orientation o, bool tickAbove, bool tickBelow ) 740 Orientation o, bool tickAbove, bool tickBelow )
741{ 741{
742 int a = tickAbove ? 3 : 0; 742 int a = tickAbove ? 3 : 0;
743 int b = tickBelow ? 3 : 0; 743 int b = tickBelow ? 3 : 0;
744 if ( o == Horizontal ) 744 if ( o == Horizontal )
745 p->fillRect( x, y+a, w, h-a-b, color1 ); 745 p->fillRect( x, y+a, w, h-a-b, color1 );
746 else 746 else
747 p->fillRect( x+a, y, w-a-b, h, color1 ); 747 p->fillRect( x+a, y, w-a-b, h, color1 );
748} 748}
749 749
750/*!\reimp 750/*!\reimp
751 */ 751 */
752void FlatStyle::drawSliderGrooveMask( QPainter *p, 752void FlatStyle::drawSliderGrooveMask( QPainter *p,
753 int x, int y, int w, int h, 753 int x, int y, int w, int h,
754 const QColorGroup& , QCOORD c, 754 const QColorGroup& , QCOORD c,
755 Orientation orient ) 755 Orientation orient )
756{ 756{
757 if ( orient == Horizontal ) 757 if ( orient == Horizontal )
758 p->fillRect( x, y + c - 2, w, 4, color1 ); 758 p->fillRect( x, y + c - 2, w, 4, color1 );
759 else 759 else
760 p->fillRect( x + c - 2, y, 4, h, color1 ); 760 p->fillRect( x + c - 2, y, 4, h, color1 );
761} 761}
762 762
763void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient ) 763void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient )
764{ 764{
765 if ( orient == Horizontal ) 765 if ( orient == Horizontal )
766 p->fillRect( x, y + c - 2, w, 4, g.foreground() ); 766 p->fillRect( x, y + c - 2, w, 4, g.foreground() );
767 else 767 else
768 p->fillRect( x + c - 2, y, 4, h, g.foreground() ); 768 p->fillRect( x + c - 2, y, 4, h, g.foreground() );
769} 769}
770 770
771void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) 771void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
772{ 772{
773 QRect r( t->rect() ); 773 QRect r( t->rect() );
774 if ( tb->shape() == QTabBar::RoundedAbove ) { 774 if ( tb->shape() == QTabBar::RoundedAbove ) {
775 p->setPen( tb->colorGroup().foreground() ); 775 p->setPen( tb->colorGroup().foreground() );
776 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 776 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
777 if ( r.left() == 0 ) 777 if ( r.left() == 0 )
778 p->drawPoint( tb->rect().bottomLeft() ); 778 p->drawPoint( tb->rect().bottomLeft() );
779 else 779 else
780 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); 780 p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
781 781
782 if ( selected ) { 782 if ( selected ) {
783 p->setPen( tb->colorGroup().background() ); 783 p->setPen( tb->colorGroup().background() );
784 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 784 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
785 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), 785 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2),
786 tb->colorGroup().brush( QColorGroup::Background )); 786 tb->colorGroup().brush( QColorGroup::Background ));
787 } else { 787 } else {
788 r.setRect( r.left() + 2, r.top() + 2, 788 r.setRect( r.left() + 2, r.top() + 2,
789 r.width() - 4, r.height() - 2 ); 789 r.width() - 4, r.height() - 2 );
790 p->setPen( tb->colorGroup().button() ); 790 p->setPen( tb->colorGroup().button() );
791 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); 791 p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
792 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), 792 p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
793 tb->colorGroup().brush( QColorGroup::Button )); 793 tb->colorGroup().brush( QColorGroup::Button ));
794 } 794 }
795 795
796 p->setPen( tb->colorGroup().foreground() ); 796 p->setPen( tb->colorGroup().foreground() );
797 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); 797 p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
798 p->drawPoint( r.left()+1, r.top() + 1 ); 798 p->drawPoint( r.left()+1, r.top() + 1 );
799 p->drawLine( r.left()+2, r.top(), 799 p->drawLine( r.left()+2, r.top(),
800 r.right() - 2, r.top() ); 800 r.right() - 2, r.top() );
801 801
802 p->drawPoint( r.right() - 1, r.top() + 1 ); 802 p->drawPoint( r.right() - 1, r.top() + 1 );
803 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); 803 p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
804 } else if ( tb->shape() == QTabBar::RoundedBelow ) { 804 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
805 if ( selected ) { 805 if ( selected ) {
806 p->setPen( tb->colorGroup().background() ); 806 p->setPen( tb->colorGroup().background() );
807 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 807 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
808 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), 808 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
809 tb->palette().normal().brush( QColorGroup::Background )); 809 tb->palette().normal().brush( QColorGroup::Background ));
810 } else { 810 } else {
811 p->setPen( tb->colorGroup().foreground() ); 811 p->setPen( tb->colorGroup().foreground() );
812 p->drawLine( r.left(), r.top(), 812 p->drawLine( r.left(), r.top(),
813 r.right(), r.top() ); 813 r.right(), r.top() );
814 r.setRect( r.left() + 2, r.top(), 814 r.setRect( r.left() + 2, r.top(),
815 r.width() - 4, r.height() - 2 ); 815 r.width() - 4, r.height() - 2 );
816 p->setPen( tb->colorGroup().button() ); 816 p->setPen( tb->colorGroup().button() );
817 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 817 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
818 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), 818 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
819 tb->palette().normal().brush( QColorGroup::Button )); 819 tb->palette().normal().brush( QColorGroup::Button ));
820 } 820 }
821 821
822 p->setPen( tb->colorGroup().foreground() ); 822 p->setPen( tb->colorGroup().foreground() );
823 p->drawLine( r.right(), r.top(), 823 p->drawLine( r.right(), r.top(),
824 r.right(), r.bottom() - 2 ); 824 r.right(), r.bottom() - 2 );
825 p->drawPoint( r.right() - 1, r.bottom() - 1 ); 825 p->drawPoint( r.right() - 1, r.bottom() - 1 );
826 p->drawLine( r.right() - 2, r.bottom(), 826 p->drawLine( r.right() - 2, r.bottom(),
827 r.left() + 2, r.bottom() ); 827 r.left() + 2, r.bottom() );
828 828
829 p->drawLine( r.left(), r.top()+1, 829 p->drawLine( r.left(), r.top()+1,
830 r.left(), r.bottom() - 2 ); 830 r.left(), r.bottom() - 2 );
831 p->drawPoint( r.left() + 1, r.bottom() - 1 ); 831 p->drawPoint( r.left() + 1, r.bottom() - 1 );
832 if ( r.left() == 0 ) 832 if ( r.left() == 0 )
833 p->drawPoint( tb->rect().topLeft() ); 833 p->drawPoint( tb->rect().topLeft() );
834 834
835 } else { 835 } else {
836 QCommonStyle::drawTab( p, tb, t, selected ); 836 QCommonStyle::drawTab( p, tb, t, selected );
837 } 837 }
838} 838}
839 839
840 static const int motifItemFrame = 0;// menu item frame width 840 static const int motifItemFrame = 0;// menu item frame width
841 static const int motifSepHeight = 2;// separator item height 841 static const int motifSepHeight = 2;// separator item height
842 static const int motifItemHMargin = 1;// menu item hor text margin 842 static const int motifItemHMargin = 1;// menu item hor text margin
843 static const int motifItemVMargin = 2;// menu item ver text margin 843 static const int motifItemVMargin = 2;// menu item ver text margin
844 static const int motifArrowHMargin = 0;// arrow horizontal margin 844 static const int motifArrowHMargin = 0;// arrow horizontal margin
845 static const int motifTabSpacing = 12;// space between text and tab 845 static const int motifTabSpacing = 12;// space between text and tab
846 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark 846 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark
847 static const int windowsRightBorder= 8; // right border on windows 847 static const int windowsRightBorder= 8; // right border on windows
848static const int windowsCheckMarkWidth = 2; // checkmarks width on windows 848static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
849 849
850void FlatStyle::polishPopupMenu ( QPopupMenu *m ) 850void FlatStyle::polishPopupMenu ( QPopupMenu *m )
851{ 851{
852 QWindowsStyle::polishPopupMenu( m ); 852 QWindowsStyle::polishPopupMenu( m );
853 m->setLineWidth( 1 ); 853 m->setLineWidth( 1 );
854} 854}
855 855
856/*! \reimp 856/*! \reimp
857*/ 857*/
858int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) 858int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
859{ 859{
860#ifndef QT_NO_MENUDATA 860#ifndef QT_NO_MENUDATA
861 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm 861 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
862 862
863 if ( mi->isSeparator() ) 863 if ( mi->isSeparator() )
864 return 10; // arbitrary 864 return 10; // arbitrary
865 else if ( mi->pixmap() ) 865 else if ( mi->pixmap() )
866 w += mi->pixmap()->width();// pixmap only 866 w += mi->pixmap()->width();// pixmap only
867 867
868 if ( !mi->text().isNull() ) { 868 if ( !mi->text().isNull() ) {
869 if ( mi->text().find('\t') >= 0 )// string contains tab 869 if ( mi->text().find('\t') >= 0 )// string contains tab
870 w += motifTabSpacing; 870 w += motifTabSpacing;
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
982 p->setPen( act ? g.highlightedText() : g.buttonText() ); 986 p->setPen( act ? g.highlightedText() : g.buttonText() );
983 987
984 QColor discol; 988 QColor discol;
985 if ( dis ) { 989 if ( dis ) {
986 discol = itemg.text(); 990 discol = itemg.text();
987 p->setPen( discol ); 991 p->setPen( discol );
988 } 992 }
989 993
990 int xm = motifItemFrame + checkcol + motifItemHMargin; 994 int xm = motifItemFrame + checkcol + motifItemHMargin;
991 995
992 if ( mi->custom() ) { 996 if ( mi->custom() ) {
993 int m = motifItemVMargin; 997 int m = motifItemVMargin;
994 p->save(); 998 p->save();
995 if ( dis && !act ) { 999 if ( dis && !act ) {
996 p->setPen( g.light() ); 1000 p->setPen( g.light() );
997 mi->custom()->paint( p, itemg, act, enabled, 1001 mi->custom()->paint( p, itemg, act, enabled,
998 x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); 1002 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
999 p->setPen( discol ); 1003 p->setPen( discol );
1000 } 1004 }
1001 mi->custom()->paint( p, itemg, act, enabled, 1005 mi->custom()->paint( p, itemg, act, enabled,
1002 x+xm, y+m, w-xm-tab+1, h-2*m ); 1006 x+xm, y+m, w-xm-tab+1, h-2*m );
1003 p->restore(); 1007 p->restore();
1004 } 1008 }
1005 QString s = mi->text(); 1009 QString s = mi->text();
1006 if ( !s.isNull() ) { // draw text 1010 if ( !s.isNull() ) { // draw text
1007 int t = s.find( '\t' ); 1011 int t = s.find( '\t' );
1008 int m = motifItemVMargin; 1012 int m = motifItemVMargin;
1009 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 1013 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
1010 if ( t >= 0 ) { // draw tab text 1014 if ( t >= 0 ) { // draw tab text
1011 if ( dis && !act ) { 1015 if ( dis && !act ) {
1012 p->setPen( g.light() ); 1016 p->setPen( g.light() );
1013 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 1017 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
1014 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 1018 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
1015 p->setPen( discol ); 1019 p->setPen( discol );
1016 } 1020 }
1017 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, 1021 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
1018 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); 1022 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
1019 } 1023 }
1020 if ( dis && !act ) 1024 if ( dis && !act )
1021 p->setPen( discol ); 1025 p->setPen( discol );
1022 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); 1026 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
1023 } else if ( mi->pixmap() ) { // draw pixmap 1027 } else if ( mi->pixmap() ) { // draw pixmap
1024 QPixmap *pixmap = mi->pixmap(); 1028 QPixmap *pixmap = mi->pixmap();
1025 if ( pixmap->depth() == 1 ) 1029 if ( pixmap->depth() == 1 )
1026 p->setBackgroundMode( OpaqueMode ); 1030 p->setBackgroundMode( OpaqueMode );
1027 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); 1031 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
1028 if ( pixmap->depth() == 1 ) 1032 if ( pixmap->depth() == 1 )
1029 p->setBackgroundMode( TransparentMode ); 1033 p->setBackgroundMode( TransparentMode );
1030 } 1034 }
1031 if ( mi->popup() ) { // draw sub menu arrow 1035 if ( mi->popup() ) { // draw sub menu arrow
1032 int dim = (h-2*motifItemFrame) / 2; 1036 int dim = (h-2*motifItemFrame) / 2;
1033 if ( act ) { 1037 if ( act ) {
1034 if ( !dis ) 1038 if ( !dis )
1035 discol = white; 1039 discol = white;
1036 QColorGroup g2( discol, g.highlight(), 1040 QColorGroup g2( discol, g.highlight(),
1037 white, white, 1041 white, white,
1038 dis ? discol : white, 1042 dis ? discol : white,
1039 discol, white ); 1043 discol, white );
1040 drawArrow( p, RightArrow, FALSE, 1044 drawArrow( p, RightArrow, FALSE,
1041 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1045 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1042 dim, dim, g2, TRUE ); 1046 dim, dim, g2, TRUE );
1043 } else { 1047 } else {
1044 drawArrow( p, RightArrow, 1048 drawArrow( p, RightArrow,
1045 FALSE, 1049 FALSE,
1046 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 1050 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
1047 dim, dim, g, mi->isEnabled() ); 1051 dim, dim, g, mi->isEnabled() );
1048 } 1052 }
1049 } 1053 }
1050#endif 1054#endif
1051} 1055}
1052 1056
1053void FlatStyle::getButtonShift( int &x, int &y ) 1057void FlatStyle::getButtonShift( int &x, int &y )
1054{ 1058{
1055 x = 0; y = 0; 1059 x = 0; y = 0;
1056} 1060}
1057 1061
1058//=========================================================================== 1062//===========================================================================
1059 1063
1060FlatStyleImpl::FlatStyleImpl() 1064FlatStyleImpl::FlatStyleImpl()
1061 : flat(0) 1065 : flat(0)
1062{ 1066{
1063} 1067}
1064 1068
1065FlatStyleImpl::~FlatStyleImpl() 1069FlatStyleImpl::~FlatStyleImpl()
1066{ 1070{
1067 // We do not delete the style because Qt does that when a new style 1071 // We do not delete the style because Qt does that when a new style
1068 // is set. 1072 // is set.
1069} 1073}
1070 1074
1071QStyle *FlatStyleImpl::style() 1075QStyle *FlatStyleImpl::style()
1072{ 1076{
1073 if ( !flat ) 1077 if ( !flat )
1074 flat = new FlatStyle(); 1078 flat = new FlatStyle();
1075 return flat; 1079 return flat;
1076} 1080}
1077 1081
1078QString FlatStyleImpl::name() const 1082QString FlatStyleImpl::name() const
1079{ 1083{
1080 return qApp->translate("FlatStyle", "Flat", "Name of the style Flat"); 1084 return qApp->translate("FlatStyle", "Flat", "Name of the style Flat");
1081} 1085}
1082 1086
1083QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 1087QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
1084{ 1088{
1085 *iface = 0; 1089 *iface = 0;
1086 if ( uuid == IID_QUnknown ) 1090 if ( uuid == IID_QUnknown )
1087 *iface = this; 1091 *iface = this;
1088 else if ( uuid == IID_Style ) 1092 else if ( uuid == IID_Style )
1089 *iface = this; 1093 *iface = this;
1090 else 1094 else
1091 return QS_FALSE; 1095 return QS_FALSE;
1092 1096
1093 (*iface)->addRef(); 1097 (*iface)->addRef();
1094 return QS_OK; 1098 return QS_OK;
1095} 1099}
1096 1100
1097Q_EXPORT_INTERFACE() 1101Q_EXPORT_INTERFACE()
1098{ 1102{
1099 Q_CREATE_INSTANCE( FlatStyleImpl ) 1103 Q_CREATE_INSTANCE( FlatStyleImpl )
1100} 1104}
1101 1105
1102#include "flat.moc" 1106#include "flat.moc"
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
@@ -1,848 +1,852 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "fresh.h" 21#include "fresh.h"
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qpainter.h> 24#include <qpainter.h>
25#include <qfontmetrics.h> 25#include <qfontmetrics.h>
26#include <qpalette.h> 26#include <qpalette.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qscrollbar.h> 28#include <qscrollbar.h>
29#include <qbutton.h> 29#include <qbutton.h>
30#include <qframe.h> 30#include <qframe.h>
31#include <qtabbar.h> 31#include <qtabbar.h>
32 32
33#define INCLUDE_MENUITEM_DEF 33#define INCLUDE_MENUITEM_DEF
34#include <qmenudata.h> 34#include <qmenudata.h>
35 35
36#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 36#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
37 37
38FreshStyle::FreshStyle() 38FreshStyle::FreshStyle()
39{ 39{
40 setButtonMargin(2); 40 setButtonMargin(2);
41 setScrollBarExtent(13,13); 41 setScrollBarExtent(13,13);
42} 42}
43 43
44FreshStyle::~FreshStyle() 44FreshStyle::~FreshStyle()
45{ 45{
46} 46}
47 47
48int FreshStyle::buttonMargin() const 48int FreshStyle::buttonMargin() const
49{ 49{
50 return 2; 50 return 2;
51} 51}
52 52
53QSize FreshStyle::scrollBarExtent() const 53QSize FreshStyle::scrollBarExtent() const
54{ 54{
55 return QSize(13,13); 55 return QSize(13,13);
56} 56}
57 57
58void FreshStyle::polish ( QPalette & ) 58void FreshStyle::polish ( QPalette & )
59{ 59{
60} 60}
61 61
62void FreshStyle::polish( QWidget *w ) 62void FreshStyle::polish( QWidget *w )
63{ 63{
64 if ( w->inherits( "QListBox" ) || 64 if ( w->inherits( "QListBox" ) ||
65 w->inherits( "QListView" ) || 65 w->inherits( "QListView" ) ||
66 w->inherits( "QPopupMenu" ) || 66 w->inherits( "QPopupMenu" ) ||
67 w->inherits( "QSpinBox" ) ) { 67 w->inherits( "QSpinBox" ) ) {
68 QFrame *f = (QFrame *)w; 68 QFrame *f = (QFrame *)w;
69 f->setFrameShape( QFrame::StyledPanel ); 69 f->setFrameShape( QFrame::StyledPanel );
70 f->setLineWidth( 1 ); 70 f->setLineWidth( 1 );
71 } 71 }
72} 72}
73 73
74void FreshStyle::unPolish( QWidget *w ) 74void FreshStyle::unPolish( QWidget *w )
75{ 75{
76 if ( w->inherits( "QListBox" ) || 76 if ( w->inherits( "QListBox" ) ||
77 w->inherits( "QListView" ) || 77 w->inherits( "QListView" ) ||
78 w->inherits( "QPopupMenu" ) || 78 w->inherits( "QPopupMenu" ) ||
79 w->inherits( "QSpinBox" ) ) { 79 w->inherits( "QSpinBox" ) ) {
80 QFrame *f = (QFrame *)w; 80 QFrame *f = (QFrame *)w;
81 f->setFrameShape( QFrame::StyledPanel ); 81 f->setFrameShape( QFrame::StyledPanel );
82 f->setLineWidth( 2 ); 82 f->setLineWidth( 2 );
83 } 83 }
84} 84}
85 85
86int FreshStyle::defaultFrameWidth() const 86int FreshStyle::defaultFrameWidth() const
87{ 87{
88 return 1; 88 return 1;
89} 89}
90 90
91void FreshStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, 91void FreshStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
92 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill ) 92 const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill )
93{ 93{
94 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill ); 94 qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill );
95} 95}
96 96
97void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h, 97void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h,
98 const QColorGroup &cg, bool sunken, const QBrush* fill ) 98 const QColorGroup &cg, bool sunken, const QBrush* fill )
99{ 99{
100 QPen oldPen = p->pen(); 100 QPen oldPen = p->pen();
101 int off = sunken ? 1 : 0; 101 int off = sunken ? 1 : 0;
102 p->fillRect( x+1+off, y+1+off, w-3, h-3, fill?(*fill):cg.brush(QColorGroup::Button) ); 102 p->fillRect( x+1+off, y+1+off, w-3, h-3, fill?(*fill):cg.brush(QColorGroup::Button) );
103 103
104 int x2 = x+w-1; 104 int x2 = x+w-1;
105 int y2 = y+h-1; 105 int y2 = y+h-1;
106 106
107 if ( sunken ) 107 if ( sunken )
108 p->setPen( cg.dark() ); 108 p->setPen( cg.dark() );
109 else 109 else
110 p->setPen( cg.light() ); 110 p->setPen( cg.light() );
111 p->drawLine( x, y, x, y2-1 ); 111 p->drawLine( x, y, x, y2-1 );
112 p->drawLine( x, y, x2, y ); 112 p->drawLine( x, y, x2, y );
113 113
114 if ( sunken ) { 114 if ( sunken ) {
115 p->setPen( white ); 115 p->setPen( white );
116 p->drawLine( x+1, y+1, x+1, y2-2 ); 116 p->drawLine( x+1, y+1, x+1, y2-2 );
117 p->drawLine( x+1, y+1, x2-2, y+1 ); 117 p->drawLine( x+1, y+1, x2-2, y+1 );
118 } 118 }
119 119
120 if ( sunken ) 120 if ( sunken )
121 p->setPen( cg.light() ); 121 p->setPen( cg.light() );
122 else 122 else
123 p->setPen( cg.dark() ); 123 p->setPen( cg.dark() );
124 p->drawLine( x2, y+1, x2, y2 ); 124 p->drawLine( x2, y+1, x2, y2 );
125 p->drawLine( x, y2, x2, y2 ); 125 p->drawLine( x, y2, x2, y2 );
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
176 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 176 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
177 static const QCOORD pts4[] = { // white lines 177 static const QCOORD pts4[] = { // white lines
178 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 178 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
179 11,4, 10,3, 10,2 }; 179 11,4, 10,3, 10,2 };
180 static const QCOORD pts5[] = { // inner fill 180 static const QCOORD pts5[] = { // inner fill
181 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 181 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
182 182
183 p->eraseRect( x, y, w, h ); 183 p->eraseRect( x, y, w, h );
184 QPointArray a( QCOORDARRLEN(pts1), pts4 ); 184 QPointArray a( QCOORDARRLEN(pts1), pts4 );
185 a.translate( x, y ); 185 a.translate( x, y );
186 p->setPen( cg.dark() ); 186 p->setPen( cg.dark() );
187 p->drawPolyline( a ); 187 p->drawPolyline( a );
188 a.setPoints( QCOORDARRLEN(pts4), pts1 ); 188 a.setPoints( QCOORDARRLEN(pts4), pts1 );
189 a.translate( x, y ); 189 a.translate( x, y );
190 p->setPen( cg.light() ); 190 p->setPen( cg.light() );
191 p->drawPolyline( a ); 191 p->drawPolyline( a );
192 a.setPoints( QCOORDARRLEN(pts5), pts5 ); 192 a.setPoints( QCOORDARRLEN(pts5), pts5 );
193 a.translate( x, y ); 193 a.translate( x, y );
194 QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base(); 194 QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
195 p->setPen( fillColor ); 195 p->setPen( fillColor );
196 p->setBrush( fillColor ) ; 196 p->setBrush( fillColor ) ;
197 p->drawPolygon( a ); 197 p->drawPolygon( a );
198 if ( on ) { 198 if ( on ) {
199 p->setPen( NoPen ); 199 p->setPen( NoPen );
200 p->setBrush( cg.text() ); 200 p->setBrush( cg.text() );
201 p->drawRect( x+5, y+4, 2, 4 ); 201 p->drawRect( x+5, y+4, 2, 4 );
202 p->drawRect( x+4, y+5, 4, 2 ); 202 p->drawRect( x+4, y+5, 4, 2 );
203 } 203 }
204} 204}
205 205
206void FreshStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h, 206void FreshStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
207 const QColorGroup &cg, int state, bool down, bool enabled ) 207 const QColorGroup &cg, int state, bool down, bool enabled )
208{ 208{
209 QColorGroup mycg( cg ); 209 QColorGroup mycg( cg );
210 mycg.setBrush( QColorGroup::Button, QBrush() ); 210 mycg.setBrush( QColorGroup::Button, QBrush() );
211 QBrush fill; 211 QBrush fill;
212 drawButton( p, x, y, w, h, mycg, TRUE, 0 ); 212 drawButton( p, x, y, w, h, mycg, TRUE, 0 );
213 if ( down ) 213 if ( down )
214 fill = cg.brush( QColorGroup::Button ); 214 fill = cg.brush( QColorGroup::Button );
215 else 215 else
216 fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); 216 fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
217 mycg.setBrush( QColorGroup::Button, fill ); 217 mycg.setBrush( QColorGroup::Button, fill );
218 p->fillRect( x+1, y+1, w-2, h-2, fill ); 218 p->fillRect( x+1, y+1, w-2, h-2, fill );
219 if ( state != QButton::Off ) { 219 if ( state != QButton::Off ) {
220 QPointArray a( 7*2 ); 220 QPointArray a( 7*2 );
221 int i, xx, yy; 221 int i, xx, yy;
222 xx = x+3; 222 xx = x+3;
223 yy = y+5; 223 yy = y+5;
224 for ( i=0; i<3; i++ ) { 224 for ( i=0; i<3; i++ ) {
225 a.setPoint( 2*i, xx, yy ); 225 a.setPoint( 2*i, xx, yy );
226 a.setPoint( 2*i+1, xx, yy+2 ); 226 a.setPoint( 2*i+1, xx, yy+2 );
227 xx++; yy++; 227 xx++; yy++;
228 } 228 }
229 yy -= 2; 229 yy -= 2;
230 for ( i=3; i<7; i++ ) { 230 for ( i=3; i<7; i++ ) {
231 a.setPoint( 2*i, xx, yy ); 231 a.setPoint( 2*i, xx, yy );
232 a.setPoint( 2*i+1, xx, yy+2 ); 232 a.setPoint( 2*i+1, xx, yy+2 );
233 xx++; yy--; 233 xx++; yy--;
234 } 234 }
235 if ( state == QButton::NoChange ) { 235 if ( state == QButton::NoChange ) {
236 p->setPen( mycg.dark() ); 236 p->setPen( mycg.dark() );
237 } else { 237 } else {
238 p->setPen( mycg.text() ); 238 p->setPen( mycg.text() );
239 } 239 }
240 p->drawLineSegments( a ); 240 p->drawLineSegments( a );
241 } 241 }
242} 242}
243 243
244 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal) 244 #define HORIZONTAL(sb->orientation() == QScrollBar::Horizontal)
245 #define VERTICAL!HORIZONTAL 245 #define VERTICAL!HORIZONTAL
246 #define MOTIF_BORDER2 246 #define MOTIF_BORDER2
247 #define SLIDER_MIN9 // ### motif says 6 but that's too small 247 #define SLIDER_MIN9 // ### motif says 6 but that's too small
248 248
249/*! \reimp */ 249/*! \reimp */
250 250
251void FreshStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim ) 251void FreshStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim )
252{ 252{
253 int maxLength; 253 int maxLength;
254 int length = HORIZONTAL ? sb->width() : sb->height(); 254 int length = HORIZONTAL ? sb->width() : sb->height();
255 int extent = HORIZONTAL ? sb->height() : sb->width(); 255 int extent = HORIZONTAL ? sb->height() : sb->width();
256 256
257 if ( length > (extent - 1)*2 ) 257 if ( length > (extent - 1)*2 )
258 buttonDim = extent; 258 buttonDim = extent;
259 else 259 else
260 buttonDim = length/2 - 1; 260 buttonDim = length/2 - 1;
261 261
262 sliderMin = 0; 262 sliderMin = 0;
263 maxLength = length - buttonDim*2; 263 maxLength = length - buttonDim*2;
264 264
265 if ( sb->maxValue() == sb->minValue() ) { 265 if ( sb->maxValue() == sb->minValue() ) {
266 sliderLength = maxLength; 266 sliderLength = maxLength;
267 } else { 267 } else {
268 sliderLength = (sb->pageStep()*maxLength)/ 268 sliderLength = (sb->pageStep()*maxLength)/
269 (sb->maxValue()-sb->minValue()+sb->pageStep()); 269 (sb->maxValue()-sb->minValue()+sb->pageStep());
270 uint range = sb->maxValue()-sb->minValue(); 270 uint range = sb->maxValue()-sb->minValue();
271 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 ) 271 if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
272 sliderLength = SLIDER_MIN; 272 sliderLength = SLIDER_MIN;
273 if ( sliderLength > maxLength ) 273 if ( sliderLength > maxLength )
274 sliderLength = maxLength; 274 sliderLength = maxLength;
275 } 275 }
276 276
277 sliderMax = sliderMin + maxLength - sliderLength; 277 sliderMax = sliderMin + maxLength - sliderLength;
278} 278}
279 279
280/*!\reimp 280/*!\reimp
281 */ 281 */
282QStyle::ScrollControl FreshStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ) 282QStyle::ScrollControl FreshStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p )
283{ 283{
284 if ( !sb->rect().contains( p ) ) 284 if ( !sb->rect().contains( p ) )
285 return NoScroll; 285 return NoScroll;
286 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 286 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
287 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 287 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
288 288
289 if (sb->orientation() == QScrollBar::Horizontal) 289 if (sb->orientation() == QScrollBar::Horizontal)
290 pos = p.x(); 290 pos = p.x();
291 else 291 else
292 pos = p.y(); 292 pos = p.y();
293 293
294 if (pos < sliderStart) 294 if (pos < sliderStart)
295 return SubPage; 295 return SubPage;
296 if (pos < sliderStart + sliderLength) 296 if (pos < sliderStart + sliderLength)
297 return Slider; 297 return Slider;
298 if (pos < sliderMax + sliderLength) 298 if (pos < sliderMax + sliderLength)
299 return AddPage; 299 return AddPage;
300 if (pos < sliderMax + sliderLength + buttonDim) 300 if (pos < sliderMax + sliderLength + buttonDim)
301 return SubLine; 301 return SubLine;
302 return AddLine; 302 return AddLine;
303} 303}
304 304
305/*! \reimp */ 305/*! \reimp */
306 306
307void FreshStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) 307void FreshStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
308{ 308{
309#define ADD_LINE_ACTIVE ( activeControl == AddLine ) 309#define ADD_LINE_ACTIVE ( activeControl == AddLine )
310#define SUB_LINE_ACTIVE ( activeControl == SubLine ) 310#define SUB_LINE_ACTIVE ( activeControl == SubLine )
311 QColorGroup g = sb->colorGroup(); 311 QColorGroup g = sb->colorGroup();
312 312
313 int sliderMin, sliderMax, sliderLength, buttonDim; 313 int sliderMin, sliderMax, sliderLength, buttonDim;
314 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 314 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
315 315
316 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) 316 if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) )
317 p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid )); 317 p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid ));
318 318
319 if (sliderStart > sliderMax) { // sanity check 319 if (sliderStart > sliderMax) { // sanity check
320 sliderStart = sliderMax; 320 sliderStart = sliderMax;
321 } 321 }
322 322
323 int dimB = buttonDim; 323 int dimB = buttonDim;
324 QRect addB; 324 QRect addB;
325 QRect subB; 325 QRect subB;
326 QRect addPageR; 326 QRect addPageR;
327 QRect subPageR; 327 QRect subPageR;
328 QRect sliderR; 328 QRect sliderR;
329 int addX, addY, subX, subY; 329 int addX, addY, subX, subY;
330 int length = HORIZONTAL ? sb->width() : sb->height(); 330 int length = HORIZONTAL ? sb->width() : sb->height();
331 int extent = HORIZONTAL ? sb->height() : sb->width(); 331 int extent = HORIZONTAL ? sb->height() : sb->width();
332 332
333 if ( HORIZONTAL ) { 333 if ( HORIZONTAL ) {
334 subY = addY = ( extent - dimB ) / 2; 334 subY = addY = ( extent - dimB ) / 2;
335 subX = length - dimB - dimB; 335 subX = length - dimB - dimB;
336 addX = length - dimB; 336 addX = length - dimB;
337 } else { 337 } else {
338 subX = addX = ( extent - dimB ) / 2; 338 subX = addX = ( extent - dimB ) / 2;
339 subY = length - dimB - dimB; 339 subY = length - dimB - dimB;
340 addY = length - dimB; 340 addY = length - dimB;
341 } 341 }
342 342
343 int sliderEnd = sliderStart + sliderLength; 343 int sliderEnd = sliderStart + sliderLength;
344 int sliderW = extent; 344 int sliderW = extent;
345 if ( HORIZONTAL ) { 345 if ( HORIZONTAL ) {
346 subB.setRect( subX,subY+1,dimB,dimB-1 ); 346 subB.setRect( subX,subY+1,dimB,dimB-1 );
347 addB.setRect( addX,addY+1,dimB,dimB-1 ); 347 addB.setRect( addX,addY+1,dimB,dimB-1 );
348 348
349 subPageR.setRect( 0, 0, 349 subPageR.setRect( 0, 0,
350 sliderStart+1, sliderW ); 350 sliderStart+1, sliderW );
351 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW ); 351 addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW );
352 sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 ); 352 sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 );
353 353
354 } else { 354 } else {
355 subB.setRect( subX+1,subY,dimB-1,dimB ); 355 subB.setRect( subX+1,subY,dimB-1,dimB );
356 addB.setRect( addX+1,addY,dimB-1,dimB ); 356 addB.setRect( addX+1,addY,dimB-1,dimB );
357 357
358 subPageR.setRect( 0, 0, sliderW, 358 subPageR.setRect( 0, 0, sliderW,
359 sliderStart+1 ); 359 sliderStart+1 );
360 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 ); 360 addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 );
361 sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength ); 361 sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength );
362 } 362 }
363 363
364 bool maxedOut = (sb->maxValue() == sb->minValue()); 364 bool maxedOut = (sb->maxValue() == sb->minValue());
365 if ( controls & AddLine ) { 365 if ( controls & AddLine ) {
366 drawBevelButton( p, addB.x(), addB.y(), 366 drawBevelButton( p, addB.x(), addB.y(),
367 addB.width(), addB.height(), g, 367 addB.width(), addB.height(), g,
368 ADD_LINE_ACTIVE); 368 ADD_LINE_ACTIVE);
369 p->setPen(g.shadow()); 369 p->setPen(g.shadow());
370 drawArrow( p, VERTICAL ? DownArrow : RightArrow, 370 drawArrow( p, VERTICAL ? DownArrow : RightArrow,
371 FALSE, addB.x()+2, addB.y()+2, 371 FALSE, addB.x()+2, addB.y()+2,
372 addB.width()-4, addB.height()-4, g, !maxedOut, 372 addB.width()-4, addB.height()-4, g, !maxedOut,
373 &g.brush( QColorGroup::Button )); 373 &g.brush( QColorGroup::Button ));
374 } 374 }
375 if ( controls & SubLine ) { 375 if ( controls & SubLine ) {
376 drawBevelButton( p, subB.x(), subB.y(), 376 drawBevelButton( p, subB.x(), subB.y(),
377 subB.width(), subB.height(), g, 377 subB.width(), subB.height(), g,
378 SUB_LINE_ACTIVE ); 378 SUB_LINE_ACTIVE );
379 p->setPen(g.shadow()); 379 p->setPen(g.shadow());
380 drawArrow( p, VERTICAL ? UpArrow : LeftArrow, 380 drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
381 FALSE, subB.x()+2, subB.y()+2, 381 FALSE, subB.x()+2, subB.y()+2,
382 subB.width()-4, subB.height()-4, g, !maxedOut, 382 subB.width()-4, subB.height()-4, g, !maxedOut,
383 &g.brush( QColorGroup::Button )); 383 &g.brush( QColorGroup::Button ));
384 } 384 }
385 385
386 386
387 if ( controls & SubPage ) 387 if ( controls & SubPage )
388 p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(), 388 p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(),
389 subPageR.height(), g.brush( QColorGroup::Mid )); 389 subPageR.height(), g.brush( QColorGroup::Mid ));
390 if ( controls & AddPage ) 390 if ( controls & AddPage )
391 p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(), 391 p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(),
392 addPageR.height(), g.brush( QColorGroup::Mid )); 392 addPageR.height(), g.brush( QColorGroup::Mid ));
393 if ( controls & Slider ) { 393 if ( controls & Slider ) {
394 QPoint bo = p->brushOrigin(); 394 QPoint bo = p->brushOrigin();
395 p->setBrushOrigin(sliderR.topLeft()); 395 p->setBrushOrigin(sliderR.topLeft());
396 drawBevelButton( p, sliderR.x(), sliderR.y(), 396 drawBevelButton( p, sliderR.x(), sliderR.y(),
397 sliderR.width(), sliderR.height(), g, 397 sliderR.width(), sliderR.height(), g,
398 FALSE, &g.brush( QColorGroup::Button ) ); 398 FALSE, &g.brush( QColorGroup::Button ) );
399 p->setBrushOrigin(bo); 399 p->setBrushOrigin(bo);
400 drawRiffles( p, sliderR.x(), sliderR.y(), 400 drawRiffles( p, sliderR.x(), sliderR.y(),
401 sliderR.width(), sliderR.height(), g, HORIZONTAL ); 401 sliderR.width(), sliderR.height(), g, HORIZONTAL );
402 } 402 }
403 403
404 // ### perhaps this should not be able to accept focus if maxedOut? 404 // ### perhaps this should not be able to accept focus if maxedOut?
405 if ( sb->hasFocus() && (controls & Slider) ) 405 if ( sb->hasFocus() && (controls & Slider) )
406 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, 406 p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
407 sliderR.width()-5, sliderR.height()-5, 407 sliderR.width()-5, sliderR.height()-5,
408 sb->backgroundColor() ); 408 sb->backgroundColor() );
409 409
410} 410}
411 411
412void FreshStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, 412void FreshStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
413 const QColorGroup &g, bool horizontal ) 413 const QColorGroup &g, bool horizontal )
414{ 414{
415 return; 415 return;
416 if (!horizontal) { 416 if (!horizontal) {
417 if (h > 20) { 417 if (h > 20) {
418 y += (h-20)/2 ; 418 y += (h-20)/2 ;
419 h = 20; 419 h = 20;
420 } 420 }
421 if (h > 12) { 421 if (h > 12) {
422 int n = 3; 422 int n = 3;
423 int my = y+h/2-4; 423 int my = y+h/2-4;
424 int i ; 424 int i ;
425 p->setPen(g.light()); 425 p->setPen(g.light());
426 for (i=0; i<n; i++) { 426 for (i=0; i<n; i++) {
427 p->drawLine(x+2, my+3*i, x+w-4, my+3*i); 427 p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
428 } 428 }
429 p->setPen(g.dark()); 429 p->setPen(g.dark());
430 my++; 430 my++;
431 for (i=0; i<n; i++) { 431 for (i=0; i<n; i++) {
432 p->drawLine(x+2, my+3*i, x+w-4, my+3*i); 432 p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
433 } 433 }
434 } 434 }
435 } 435 }
436 else { 436 else {
437 if (w > 20) { 437 if (w > 20) {
438 x += (w-20)/2 ; 438 x += (w-20)/2 ;
439 w = 20; 439 w = 20;
440 } 440 }
441 if (w > 12) { 441 if (w > 12) {
442 int n = 3; 442 int n = 3;
443 int mx = x+w/2-4; 443 int mx = x+w/2-4;
444 int i ; 444 int i ;
445 p->setPen(g.light()); 445 p->setPen(g.light());
446 for (i=0; i<n; i++) { 446 for (i=0; i<n; i++) {
447 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4); 447 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
448 } 448 }
449 p->setPen(g.dark()); 449 p->setPen(g.dark());
450 mx++; 450 mx++;
451 for (i=0; i<n; i++) { 451 for (i=0; i<n; i++) {
452 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4); 452 p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
453 } 453 }
454 } 454 }
455 } 455 }
456} 456}
457 457
458int FreshStyle::sliderLength() const 458int FreshStyle::sliderLength() const
459{ 459{
460 return 12; 460 return 12;
461} 461}
462 462
463void FreshStyle::drawSlider( QPainter *p, int x, int y, int w, int h, 463void FreshStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
464 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) 464 const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
465{ 465{
466 int a = tickAbove ? 3 : 0; 466 int a = tickAbove ? 3 : 0;
467 int b = tickBelow ? 3 : 0; 467 int b = tickBelow ? 3 : 0;
468 468
469 if ( o == Horizontal ) { 469 if ( o == Horizontal ) {
470 drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) ); 470 drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) );
471 int xp = x + w/2; 471 int xp = x + w/2;
472 qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g ); 472 qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g );
473 } else { 473 } else {
474 drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) ); 474 drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) );
475 int yp = y + h/2; 475 int yp = y + h/2;
476 qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g ); 476 qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g );
477 } 477 }
478} 478}
479 479
480void FreshStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, 480void FreshStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
481 Orientation o, bool tickAbove, bool tickBelow ) 481 Orientation o, bool tickAbove, bool tickBelow )
482{ 482{
483 int a = tickAbove ? 3 : 0; 483 int a = tickAbove ? 3 : 0;
484 int b = tickBelow ? 3 : 0; 484 int b = tickBelow ? 3 : 0;
485 if ( o == Horizontal ) 485 if ( o == Horizontal )
486 p->fillRect( x, y+a, w, h-a-b, color1 ); 486 p->fillRect( x, y+a, w, h-a-b, color1 );
487 else 487 else
488 p->fillRect( x+a, y, w-a-b, h, color1 ); 488 p->fillRect( x+a, y, w-a-b, h, color1 );
489} 489}
490 490
491/*!\reimp 491/*!\reimp
492 */ 492 */
493void FreshStyle::drawSliderGrooveMask( QPainter *p, 493void FreshStyle::drawSliderGrooveMask( QPainter *p,
494 int x, int y, int w, int h, 494 int x, int y, int w, int h,
495 const QColorGroup& , QCOORD c, 495 const QColorGroup& , QCOORD c,
496 Orientation orient ) 496 Orientation orient )
497{ 497{
498 if ( orient == Horizontal ) 498 if ( orient == Horizontal )
499 p->fillRect( x, y + c - 2, w, 4, color1 ); 499 p->fillRect( x, y + c - 2, w, 4, color1 );
500 else 500 else
501 p->fillRect( x + c - 2, y, 4, h, color1 ); 501 p->fillRect( x + c - 2, y, 4, h, color1 );
502} 502}
503 503
504void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) 504void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
505{ 505{
506 QRect r( t->rect() ); 506 QRect r( t->rect() );
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 ) {
556 if ( selected ) { 556 if ( selected ) {
557 p->setPen( tb->colorGroup().background() ); 557 p->setPen( tb->colorGroup().background() );
558 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 558 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
559 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), 559 p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
560 tb->palette().normal().brush( QColorGroup::Background )); 560 tb->palette().normal().brush( QColorGroup::Background ));
561 } else { 561 } else {
562 p->setPen( tb->colorGroup().dark() ); 562 p->setPen( tb->colorGroup().dark() );
563 p->drawLine( r.left(), r.top(), 563 p->drawLine( r.left(), r.top(),
564 r.right(), r.top() ); 564 r.right(), r.top() );
565 r.setRect( r.left() + 2, r.top(), 565 r.setRect( r.left() + 2, r.top(),
566 r.width() - 4, r.height() - 2 ); 566 r.width() - 4, r.height() - 2 );
567 p->setPen( tb->colorGroup().button() ); 567 p->setPen( tb->colorGroup().button() );
568 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); 568 p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
569 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), 569 p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
570 tb->palette().normal().brush( QColorGroup::Button )); 570 tb->palette().normal().brush( QColorGroup::Button ));
571 } 571 }
572 572
573 p->setPen( tb->colorGroup().dark() ); 573 p->setPen( tb->colorGroup().dark() );
574 p->drawLine( r.right(), r.top(), 574 p->drawLine( r.right(), r.top(),
575 r.right(), r.bottom() - 2 ); 575 r.right(), r.bottom() - 2 );
576 p->drawPoint( r.right() - 1, r.bottom() - 1 ); 576 p->drawPoint( r.right() - 1, r.bottom() - 1 );
577 p->drawLine( r.right() - 2, r.bottom(), 577 p->drawLine( r.right() - 2, r.bottom(),
578 r.left() + 2, r.bottom() ); 578 r.left() + 2, r.bottom() );
579 579
580 p->setPen( tb->colorGroup().light() ); 580 p->setPen( tb->colorGroup().light() );
581 p->drawLine( r.left(), r.top()+1, 581 p->drawLine( r.left(), r.top()+1,
582 r.left(), r.bottom() - 2 ); 582 r.left(), r.bottom() - 2 );
583 p->drawPoint( r.left() + 1, r.bottom() - 1 ); 583 p->drawPoint( r.left() + 1, r.bottom() - 1 );
584 if ( r.left() == 0 ) 584 if ( r.left() == 0 )
585 p->drawPoint( tb->rect().topLeft() ); 585 p->drawPoint( tb->rect().topLeft() );
586 586
587 } else { 587 } else {
588 QCommonStyle::drawTab( p, tb, t, selected ); 588 QCommonStyle::drawTab( p, tb, t, selected );
589 } 589 }
590} 590}
591 591
592 static const int motifItemFrame = 0;// menu item frame width 592 static const int motifItemFrame = 0;// menu item frame width
593 static const int motifSepHeight = 2;// separator item height 593 static const int motifSepHeight = 2;// separator item height
594 static const int motifItemHMargin = 1;// menu item hor text margin 594 static const int motifItemHMargin = 1;// menu item hor text margin
595 static const int motifItemVMargin = 2;// menu item ver text margin 595 static const int motifItemVMargin = 2;// menu item ver text margin
596 static const int motifArrowHMargin = 0;// arrow horizontal margin 596 static const int motifArrowHMargin = 0;// arrow horizontal margin
597 static const int motifTabSpacing = 12;// space between text and tab 597 static const int motifTabSpacing = 12;// space between text and tab
598 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark 598 static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark
599 static const int windowsRightBorder= 8; // right border on windows 599 static const int windowsRightBorder= 8; // right border on windows
600static const int windowsCheckMarkWidth = 2; // checkmarks width on windows 600static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
601 601
602/*! \reimp 602/*! \reimp
603*/ 603*/
604int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) 604int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
605{ 605{
606#ifndef QT_NO_MENUDATA 606#ifndef QT_NO_MENUDATA
607 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm 607 int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
608 608
609 if ( mi->isSeparator() ) 609 if ( mi->isSeparator() )
610 return 10; // arbitrary 610 return 10; // arbitrary
611 else if ( mi->pixmap() ) 611 else if ( mi->pixmap() )
612 w += mi->pixmap()->width();// pixmap only 612 w += mi->pixmap()->width();// pixmap only
613 613
614 if ( !mi->text().isNull() ) { 614 if ( !mi->text().isNull() ) {
615 if ( mi->text().find('\t') >= 0 )// string contains tab 615 if ( mi->text().find('\t') >= 0 )// string contains tab
616 w += motifTabSpacing; 616 w += motifTabSpacing;
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
730 p->setPen( act ? g.highlightedText() : g.buttonText() ); 734 p->setPen( act ? g.highlightedText() : g.buttonText() );
731 735
732 QColor discol; 736 QColor discol;
733 if ( dis ) { 737 if ( dis ) {
734 discol = itemg.text(); 738 discol = itemg.text();
735 p->setPen( discol ); 739 p->setPen( discol );
736 } 740 }
737 741
738 int xm = motifItemFrame + checkcol + motifItemHMargin; 742 int xm = motifItemFrame + checkcol + motifItemHMargin;
739 743
740 if ( mi->custom() ) { 744 if ( mi->custom() ) {
741 int m = motifItemVMargin; 745 int m = motifItemVMargin;
742 p->save(); 746 p->save();
743 if ( dis && !act ) { 747 if ( dis && !act ) {
744 p->setPen( g.light() ); 748 p->setPen( g.light() );
745 mi->custom()->paint( p, itemg, act, enabled, 749 mi->custom()->paint( p, itemg, act, enabled,
746 x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); 750 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
747 p->setPen( discol ); 751 p->setPen( discol );
748 } 752 }
749 mi->custom()->paint( p, itemg, act, enabled, 753 mi->custom()->paint( p, itemg, act, enabled,
750 x+xm, y+m, w-xm-tab+1, h-2*m ); 754 x+xm, y+m, w-xm-tab+1, h-2*m );
751 p->restore(); 755 p->restore();
752 } 756 }
753 QString s = mi->text(); 757 QString s = mi->text();
754 if ( !s.isNull() ) { // draw text 758 if ( !s.isNull() ) { // draw text
755 int t = s.find( '\t' ); 759 int t = s.find( '\t' );
756 int m = motifItemVMargin; 760 int m = motifItemVMargin;
757 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 761 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
758 if ( t >= 0 ) { // draw tab text 762 if ( t >= 0 ) { // draw tab text
759 if ( dis && !act ) { 763 if ( dis && !act ) {
760 p->setPen( g.light() ); 764 p->setPen( g.light() );
761 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 765 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
762 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 766 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
763 p->setPen( discol ); 767 p->setPen( discol );
764 } 768 }
765 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, 769 p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
766 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); 770 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
767 } 771 }
768 if ( dis && !act ) { 772 if ( dis && !act ) {
769 p->setPen( g.light() ); 773 p->setPen( g.light() );
770 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t ); 774 p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
771 p->setPen( discol ); 775 p->setPen( discol );
772 } 776 }
773 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); 777 p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
774 } else if ( mi->pixmap() ) { // draw pixmap 778 } else if ( mi->pixmap() ) { // draw pixmap
775 QPixmap *pixmap = mi->pixmap(); 779 QPixmap *pixmap = mi->pixmap();
776 if ( pixmap->depth() == 1 ) 780 if ( pixmap->depth() == 1 )
777 p->setBackgroundMode( OpaqueMode ); 781 p->setBackgroundMode( OpaqueMode );
778 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); 782 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
779 if ( pixmap->depth() == 1 ) 783 if ( pixmap->depth() == 1 )
780 p->setBackgroundMode( TransparentMode ); 784 p->setBackgroundMode( TransparentMode );
781 } 785 }
782 if ( mi->popup() ) { // draw sub menu arrow 786 if ( mi->popup() ) { // draw sub menu arrow
783 int dim = (h-2*motifItemFrame) / 2; 787 int dim = (h-2*motifItemFrame) / 2;
784 if ( act ) { 788 if ( act ) {
785 if ( !dis ) 789 if ( !dis )
786 discol = white; 790 discol = white;
787 QColorGroup g2( discol, g.highlight(), 791 QColorGroup g2( discol, g.highlight(),
788 white, white, 792 white, white,
789 dis ? discol : white, 793 dis ? discol : white,
790 discol, white ); 794 discol, white );
791 drawArrow( p, RightArrow, FALSE, 795 drawArrow( p, RightArrow, FALSE,
792 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 796 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
793 dim, dim, g2, TRUE ); 797 dim, dim, g2, TRUE );
794 } else { 798 } else {
795 drawArrow( p, RightArrow, 799 drawArrow( p, RightArrow,
796 FALSE, 800 FALSE,
797 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 801 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
798 dim, dim, g, mi->isEnabled() ); 802 dim, dim, g, mi->isEnabled() );
799 } 803 }
800 } 804 }
801#endif 805#endif
802} 806}
803 807
804//=========================================================================== 808//===========================================================================
805 809
806FreshStyleImpl::FreshStyleImpl() 810FreshStyleImpl::FreshStyleImpl()
807 : fresh(0) 811 : fresh(0)
808{ 812{
809} 813}
810 814
811FreshStyleImpl::~FreshStyleImpl() 815FreshStyleImpl::~FreshStyleImpl()
812{ 816{
813 // We do not delete the style because Qt does that when a new style 817 // We do not delete the style because Qt does that when a new style
814 // is set. 818 // is set.
815} 819}
816 820
817QStyle *FreshStyleImpl::style() 821QStyle *FreshStyleImpl::style()
818{ 822{
819 if ( !fresh ) 823 if ( !fresh )
820 fresh = new FreshStyle(); 824 fresh = new FreshStyle();
821 return fresh; 825 return fresh;
822} 826}
823 827
824QString FreshStyleImpl::name() const 828QString FreshStyleImpl::name() const
825{ 829{
826 return QString("Fresh"); 830 return QString("Fresh");
827} 831}
828 832
829QRESULT FreshStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 833QRESULT FreshStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
830{ 834{
831 *iface = 0; 835 *iface = 0;
832 if ( uuid == IID_QUnknown ) 836 if ( uuid == IID_QUnknown )
833 *iface = this; 837 *iface = this;
834 else if ( uuid == IID_Style ) 838 else if ( uuid == IID_Style )
835 *iface = this; 839 *iface = this;
836 else 840 else
837 return QS_FALSE; 841 return QS_FALSE;
838 842
839 if ( *iface ) 843 if ( *iface )
840 (*iface)->addRef(); 844 (*iface)->addRef();
841 return QS_OK; 845 return QS_OK;
842} 846}
843 847
844Q_EXPORT_INTERFACE() 848Q_EXPORT_INTERFACE()
845{ 849{
846 Q_CREATE_INSTANCE( FreshStyleImpl ) 850 Q_CREATE_INSTANCE( FreshStyleImpl )
847} 851}
848 852
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,2613 +1,2620 @@
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>
40#include <qheader.h> 40#include <qheader.h>
41#include <qmenubar.h> 41#include <qmenubar.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qlistbox.h> 44#include <qlistbox.h>
45 45
46/* STD */ 46/* STD */
47#include <unistd.h> 47#include <unistd.h>
48#include <stdio.h> 48#include <stdio.h>
49 49
50 50
51typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 51typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
52 QColorGroup &, bool, bool); 52 QColorGroup &, bool, bool);
53 53
54QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 54QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
55 55
56void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 56void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
57{ 57{
58 QImage img(pix.convertToImage()); 58 QImage img(pix.convertToImage());
59 QImageEffect::fade(img, 0.9, color); 59 QImageEffect::fade(img, 0.9, color);
60 int x, y; 60 int x, y;
61 int r, g, b; 61 int r, g, b;
62 for(y=0; y < img.height(); y+=3){ 62 for(y=0; y < img.height(); y+=3){
63 unsigned int *data = (unsigned int *) img.scanLine(y); 63 unsigned int *data = (unsigned int *) img.scanLine(y);
64 for(x=0; x < img.width(); ++x){ 64 for(x=0; x < img.width(); ++x){
65 r = qRed(data[x]); 65 r = qRed(data[x]);
66 g = qGreen(data[x]); 66 g = qGreen(data[x]);
67 b = qBlue(data[x]); 67 b = qBlue(data[x]);
68 if(r-10) 68 if(r-10)
69 r-=10; 69 r-=10;
70 if(g-10) 70 if(g-10)
71 g-=10; 71 g-=10;
72 if(b-10) 72 if(b-10)
73 b-=10; 73 b-=10;
74 data[x] = qRgb(r, g, b); 74 data[x] = qRgb(r, g, b);
75 } 75 }
76 } 76 }
77 pix.convertFromImage(img); 77 pix.convertFromImage(img);
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;
201 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 201 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
202 bevelFillPix = new QPixmap; 202 bevelFillPix = new QPixmap;
203 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 203 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
204 smallBevelFillPix = new QPixmap; 204 smallBevelFillPix = new QPixmap;
205 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 205 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
206 // new stuff 206 // new stuff
207 vsbSliderFillPix = menuPix = NULL; 207 vsbSliderFillPix = menuPix = NULL;
208 menuHandler = new TransMenuHandler(this); 208 menuHandler = new TransMenuHandler(this);
209 setScrollBarExtent(15, 15); 209 setScrollBarExtent(15, 15);
210 int i; 210 int i;
211 for(i=0; i < BITMAP_ITEMS; ++i){ 211 for(i=0; i < BITMAP_ITEMS; ++i){
212 pixmaps[i] = NULL; 212 pixmaps[i] = NULL;
213 } 213 }
214 oldSliderThickness = sliderThickness(); 214 oldSliderThickness = sliderThickness();
215 setSliderThickness(11); 215 setSliderThickness(11);
216} 216}
217 217
218LiquidStyle::~LiquidStyle() 218LiquidStyle::~LiquidStyle()
219{ 219{
220 if(btnBorderPix) 220 if(btnBorderPix)
221 delete btnBorderPix; 221 delete btnBorderPix;
222 if(btnBlendPix) 222 if(btnBlendPix)
223 delete btnBlendPix; 223 delete btnBlendPix;
224 if(bevelFillPix) 224 if(bevelFillPix)
225 delete bevelFillPix; 225 delete bevelFillPix;
226 if(smallBevelFillPix) 226 if(smallBevelFillPix)
227 delete smallBevelFillPix; 227 delete smallBevelFillPix;
228 if(vsbSliderFillPix) 228 if(vsbSliderFillPix)
229 delete vsbSliderFillPix; 229 delete vsbSliderFillPix;
230 if(menuPix) 230 if(menuPix)
231 delete menuPix; 231 delete menuPix;
232 232
233 setScrollBarExtent(16, 16); 233 setScrollBarExtent(16, 16);
234 setSliderThickness(oldSliderThickness); 234 setSliderThickness(oldSliderThickness);
235 int i; 235 int i;
236 for(i=0; i < BITMAP_ITEMS; ++i){ 236 for(i=0; i < BITMAP_ITEMS; ++i){
237 if(pixmaps[i]) 237 if(pixmaps[i])
238 delete pixmaps[i]; 238 delete pixmaps[i];
239 } 239 }
240} 240}
241 241
242void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 242void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
243 const QColor &c, const QColor &bg) 243 const QColor &c, const QColor &bg)
244{ 244{
245 245
246 QPen oldPen = p->pen(); // headers need this 246 QPen oldPen = p->pen(); // headers need this
247 int x2 = x+w-1; 247 int x2 = x+w-1;
248 int y2 = y+h-1; 248 int y2 = y+h-1;
249 // outer dark rect 249 // outer dark rect
250 p->setPen(c.dark(130)); 250 p->setPen(c.dark(130));
251 p->drawLine(x, y+2, x, y2-2); // l 251 p->drawLine(x, y+2, x, y2-2); // l
252 p->drawLine(x2, y+2, x2, y2-2); // r 252 p->drawLine(x2, y+2, x2, y2-2); // r
253 p->drawLine(x+2, y, x2-2, y); // t 253 p->drawLine(x+2, y, x2-2, y); // t
254 p->drawLine(x+2, y2, x2-2, y2); // b 254 p->drawLine(x+2, y2, x2-2, y2); // b
255 p->drawPoint(x+1, y+1); // tl 255 p->drawPoint(x+1, y+1); // tl
256 p->drawPoint(x2-1, y+1); // tr 256 p->drawPoint(x2-1, y+1); // tr
257 p->drawPoint(x+1, y2-1); // bl 257 p->drawPoint(x+1, y2-1); // bl
258 p->drawPoint(x2-1, y2-1); // br 258 p->drawPoint(x2-1, y2-1); // br
259 259
260 // inner top light lines 260 // inner top light lines
261 p->setPen(c.light(105)); 261 p->setPen(c.light(105));
262 p->drawLine(x+2, y+1, x2-2, y+1); 262 p->drawLine(x+2, y+1, x2-2, y+1);
263 p->drawLine(x+1, y+2, x2-1, y+2); 263 p->drawLine(x+1, y+2, x2-1, y+2);
264 p->drawLine(x+1, y+3, x+2, y+3); 264 p->drawLine(x+1, y+3, x+2, y+3);
265 p->drawLine(x2-2, y+3, x2-1, y+3); 265 p->drawLine(x2-2, y+3, x2-1, y+3);
266 p->drawPoint(x+1, y+4); 266 p->drawPoint(x+1, y+4);
267 p->drawPoint(x2-1, y+4); 267 p->drawPoint(x2-1, y+4);
268 268
269 // inner bottom light lines 269 // inner bottom light lines
270 p->setPen(c.light(110)); 270 p->setPen(c.light(110));
271 p->drawLine(x+2, y2-1, x2-2, y2-1); 271 p->drawLine(x+2, y2-1, x2-2, y2-1);
272 p->drawLine(x+1, y2-2, x2-1, y2-2); 272 p->drawLine(x+1, y2-2, x2-1, y2-2);
273 p->drawLine(x+1, y2-3, x+2, y2-3); 273 p->drawLine(x+1, y2-3, x+2, y2-3);
274 p->drawLine(x2-2, y2-3, x2-1, y2-3); 274 p->drawLine(x2-2, y2-3, x2-1, y2-3);
275 p->drawPoint(x+1, y2-4); 275 p->drawPoint(x+1, y2-4);
276 p->drawPoint(x2-1, y2-4); 276 p->drawPoint(x2-1, y2-4);
277 277
278 // inner left mid lines 278 // inner left mid lines
279 //p->setPen(c.light(105)); 279 //p->setPen(c.light(105));
280 p->setPen(c); 280 p->setPen(c);
281 p->drawLine(x+1, y+5, x+1, y2-5); 281 p->drawLine(x+1, y+5, x+1, y2-5);
282 p->drawLine(x+2, y+4, x+2, y2-4); 282 p->drawLine(x+2, y+4, x+2, y2-4);
283 283
284 // inner right mid lines 284 // inner right mid lines
285 p->drawLine(x2-1, y+5, x2-1, y2-5); 285 p->drawLine(x2-1, y+5, x2-1, y2-5);
286 p->drawLine(x2-2, y+4, x2-2, y2-4); 286 p->drawLine(x2-2, y+4, x2-2, y2-4);
287 287
288 // fill 288 // fill
289 QPixmap *pix; 289 QPixmap *pix;
290 if(h >= 32){ 290 if(h >= 32){
291 pix = bevelFillDict.find(c.rgb()); 291 pix = bevelFillDict.find(c.rgb());
292 if(!pix){ 292 if(!pix){
293 int h, s, v; 293 int h, s, v;
294 c.hsv(&h, &s, &v); 294 c.hsv(&h, &s, &v);
295 pix = new QPixmap(*bevelFillPix); 295 pix = new QPixmap(*bevelFillPix);
296 adjustHSV(*pix, h, s, v); 296 adjustHSV(*pix, h, s, v);
297 bevelFillDict.insert(c.rgb(), pix); 297 bevelFillDict.insert(c.rgb(), pix);
298 } 298 }
299 } 299 }
300 else{ 300 else{
301 pix = smallBevelFillDict.find(c.rgb()); 301 pix = smallBevelFillDict.find(c.rgb());
302 if(!pix){ 302 if(!pix){
303 int h, s, v; 303 int h, s, v;
304 c.hsv(&h, &s, &v); 304 c.hsv(&h, &s, &v);
305 pix = new QPixmap(*smallBevelFillPix); 305 pix = new QPixmap(*smallBevelFillPix);
306 adjustHSV(*pix, h, s, v); 306 adjustHSV(*pix, h, s, v);
307 smallBevelFillDict.insert(c.rgb(), pix); 307 smallBevelFillDict.insert(c.rgb(), pix);
308 } 308 }
309 } 309 }
310 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 310 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
311 // blend 311 // blend
312 int red, green, blue; 312 int red, green, blue;
313 QColor btnColor(c.dark(130)); 313 QColor btnColor(c.dark(130));
314 red = (btnColor.red() >> 1) + (bg.red() >> 1); 314 red = (btnColor.red() >> 1) + (bg.red() >> 1);
315 green = (btnColor.green() >> 1) + (bg.green() >> 1); 315 green = (btnColor.green() >> 1) + (bg.green() >> 1);
316 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 316 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
317 btnColor.setRgb(red, green, blue); 317 btnColor.setRgb(red, green, blue);
318 318
319 p->setPen(btnColor); 319 p->setPen(btnColor);
320 p->drawPoint(x+1, y); 320 p->drawPoint(x+1, y);
321 p->drawPoint(x, y+1); 321 p->drawPoint(x, y+1);
322 p->drawPoint(x+1, y2); 322 p->drawPoint(x+1, y2);
323 p->drawPoint(x, y2-1); 323 p->drawPoint(x, y2-1);
324 324
325 p->drawPoint(x2-1, y); 325 p->drawPoint(x2-1, y);
326 p->drawPoint(x2, y+1); 326 p->drawPoint(x2, y+1);
327 p->drawPoint(x2-1, y2); 327 p->drawPoint(x2-1, y2);
328 p->drawPoint(x2, y2-1); 328 p->drawPoint(x2, y2-1);
329 329
330 p->setPen(oldPen); 330 p->setPen(oldPen);
331 331
332} 332}
333 333
334void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 334void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
335 const QColor &back, int x, int y, int w, int h, 335 const QColor &back, int x, int y, int w, int h,
336 bool supportPushDown, bool pushedDown, 336 bool supportPushDown, bool pushedDown,
337 bool autoDefault, bool isMasked) 337 bool autoDefault, bool isMasked)
338{ 338{
339 if(w < 21 || h < 21){ 339 if(w < 21 || h < 21){
340 drawClearBevel(painter, x, y, w, h, c, back); 340 drawClearBevel(painter, x, y, w, h, c, back);
341 return; 341 return;
342 } 342 }
343 if(supportPushDown){ 343 if(supportPushDown){
344 --w, --h; 344 --w, --h;
345 } 345 }
346 /* We don't make the round buttons smaller, since they don't look as good 346 /* We don't make the round buttons smaller, since they don't look as good
347 if(autoDefault){ 347 if(autoDefault){
348 w = w-buttonDefaultIndicatorWidth()*2; 348 w = w-buttonDefaultIndicatorWidth()*2;
349 h = h-buttonDefaultIndicatorWidth()*2; 349 h = h-buttonDefaultIndicatorWidth()*2;
350 }*/ 350 }*/
351 351
352 352
353 QPixmap *pix = btnDict.find(c.rgb()); 353 QPixmap *pix = btnDict.find(c.rgb());
354 if(!pix){ 354 if(!pix){
355 int h, s, v; 355 int h, s, v;
356 c.hsv(&h, &s, &v); 356 c.hsv(&h, &s, &v);
357 pix = new QPixmap(*btnBorderPix); 357 pix = new QPixmap(*btnBorderPix);
358 adjustHSV(*pix, h, s, v); 358 adjustHSV(*pix, h, s, v);
359 btnDict.insert(c.rgb(), pix); 359 btnDict.insert(c.rgb(), pix);
360 } 360 }
361 int x2 = x+w-1; 361 int x2 = x+w-1;
362 int y2 = y+h-1; 362 int y2 = y+h-1;
363 int bx2 = pix->width()-1; 363 int bx2 = pix->width()-1;
364 int by2 = pix->height()-1; 364 int by2 = pix->height()-1;
365 365
366 QPixmap tmpPix(w, h); 366 QPixmap tmpPix(w, h);
367 QPixmap tilePix; 367 QPixmap tilePix;
368 QPainter p; 368 QPainter p;
369 p.begin(&tmpPix); 369 p.begin(&tmpPix);
370 370
371 // do the fill 371 // do the fill
372 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 372 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
373 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 373 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
374 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 374 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
375 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 375 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
376 376
377 // edges 377 // edges
378 tilePix.resize(pix->width()-20, 10); 378 tilePix.resize(pix->width()-20, 10);
379 // top 379 // top
380 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 380 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
381 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 381 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
382 // bottom 382 // bottom
383 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 383 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
384 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 384 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
385 // left 385 // left
386 tilePix.resize(10, pix->height()-20); 386 tilePix.resize(10, pix->height()-20);
387 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 387 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
388 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 388 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
389 // right 389 // right
390 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 390 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
391 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 391 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
392 392
393 // middle 393 // middle
394 tilePix.resize(pix->width()-20, pix->height()-20); 394 tilePix.resize(pix->width()-20, pix->height()-20);
395 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); 395 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20);
396 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); 396 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
397 397
398 398
399 // do the blend 399 // do the blend
400 QBitmap blendMask; 400 QBitmap blendMask;
401 if(!isMasked){ 401 if(!isMasked){
402 //QRgb bgRgb = back.rgb(); 402 //QRgb bgRgb = back.rgb();
403 //QRgb fgRgb = c.rgb(); 403 //QRgb fgRgb = c.rgb();
404 //int r, g, b; 404 //int r, g, b;
405 405
406 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); 406 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
407 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); 407 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
408 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); 408 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
409 //QColor blendColor(r, g, b); 409 //QColor blendColor(r, g, b);
410 int hue, sat, v1, v2; 410 int hue, sat, v1, v2;
411 QColor blendColor(autoDefault ? c : back); 411 QColor blendColor(autoDefault ? c : back);
412 back.hsv(&hue, &sat, &v1); 412 back.hsv(&hue, &sat, &v1);
413 blendColor.hsv(&hue, &sat, &v2); 413 blendColor.hsv(&hue, &sat, &v2);
414 if(v2 > v1) 414 if(v2 > v1)
415 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); 415 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
416 416
417 pix = btnBorderDict.find(blendColor.rgb()); 417 pix = btnBorderDict.find(blendColor.rgb());
418 if(!pix){ 418 if(!pix){
419 int h, s, v; 419 int h, s, v;
420 blendColor.hsv(&h, &s, &v); 420 blendColor.hsv(&h, &s, &v);
421 pix = new QPixmap(*btnBlendPix); 421 pix = new QPixmap(*btnBlendPix);
422 adjustHSV(*pix, h, s, v); 422 adjustHSV(*pix, h, s, v);
423 btnBorderDict.insert(blendColor.rgb(), pix); 423 btnBorderDict.insert(blendColor.rgb(), pix);
424 } 424 }
425 } 425 }
426 else{ 426 else{
427 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : 427 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) :
428 getPixmap(HTMLBtnBorder); 428 getPixmap(HTMLBtnBorder);
429 } 429 }
430 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 430 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
431 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 431 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
432 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 432 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
433 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 433 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
434 434
435 // edges 435 // edges
436 tilePix.resize(pix->width()-20, 10); 436 tilePix.resize(pix->width()-20, 10);
437 blendMask.resize(pix->width()-20, 10); 437 blendMask.resize(pix->width()-20, 10);
438 // top 438 // top
439 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 439 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
440 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); 440 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10);
441 tilePix.setMask(blendMask); 441 tilePix.setMask(blendMask);
442 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 442 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
443 // bottom 443 // bottom
444 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 444 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
445 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); 445 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20);
446 tilePix.setMask(blendMask); 446 tilePix.setMask(blendMask);
447 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 447 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
448 // left 448 // left
449 tilePix.resize(10, pix->height()-20); 449 tilePix.resize(10, pix->height()-20);
450 blendMask.resize(10, pix->height()-20); 450 blendMask.resize(10, pix->height()-20);
451 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 451 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
452 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); 452 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20);
453 tilePix.setMask(blendMask); 453 tilePix.setMask(blendMask);
454 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 454 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
455 // right 455 // right
456 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 456 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
457 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); 457 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20);
458 tilePix.setMask(blendMask); 458 tilePix.setMask(blendMask);
459 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 459 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
460 460
461 p.end(); 461 p.end();
462 462
463 // do the button mask - we don't automask buttons 463 // do the button mask - we don't automask buttons
464 QBitmap btnMask(w, h); 464 QBitmap btnMask(w, h);
465 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 465 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
466 p.begin(&btnMask); 466 p.begin(&btnMask);
467 p.fillRect(0, 0, w, h, Qt::color0); 467 p.fillRect(0, 0, w, h, Qt::color0);
468 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 468 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
469 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 469 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
470 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 470 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
471 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 471 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
472 // fills 472 // fills
473 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 473 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
474 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 474 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
475 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 475 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
476 p.end(); 476 p.end();
477 tmpPix.setMask(btnMask); 477 tmpPix.setMask(btnMask);
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;
527 float destPercent = 1.0-srcPercent; 527 float destPercent = 1.0-srcPercent;
528 oldH = (int)((srcPercent*h) + (destPercent*bH)); 528 oldH = (int)((srcPercent*h) + (destPercent*bH));
529 oldS = (int)((srcPercent*s) + (destPercent*bS)); 529 oldS = (int)((srcPercent*s) + (destPercent*bS));
530 oldV = (int)((srcPercent*oldV) + (destPercent*bV)); 530 oldV = (int)((srcPercent*oldV) + (destPercent*bV));
531 c.setHsv(oldH, oldS, oldV); 531 c.setHsv(oldH, oldS, oldV);
532 alpha = 255; 532 alpha = 255;
533 } 533 }
534 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); 534 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
535 } 535 }
536 QPixmap *pix = new QPixmap; 536 QPixmap *pix = new QPixmap;
537 pix->convertFromImage(img); 537 pix->convertFromImage(img);
538 return(pix); 538 return(pix);
539} 539}
540 540
541 541
542 542
543 543
544QPixmap* LiquidStyle::getPixmap(BitmapData item) 544QPixmap* LiquidStyle::getPixmap(BitmapData item)
545{ 545{
546 546
547 if(pixmaps[item]) 547 if(pixmaps[item])
548 return(pixmaps[item]); 548 return(pixmaps[item]);
549 549
550 switch(item){ 550 switch(item){
551 case HTMLBtnBorder: 551 case HTMLBtnBorder:
552 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); 552 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
553 break; 553 break;
554 case HTMLBtnBorderDown: 554 case HTMLBtnBorderDown:
555 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); 555 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
556 break; 556 break;
557 557
558 case HTMLCB: 558 case HTMLCB:
559 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); 559 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
560 break; 560 break;
561 case HTMLCBHover: 561 case HTMLCBHover:
562 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV); 562 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV);
563 break; 563 break;
564 case HTMLCBDown: 564 case HTMLCBDown:
565 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); 565 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
566 break; 566 break;
567 case HTMLCBDownHover: 567 case HTMLCBDownHover:
568 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV); 568 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV);
569 break; 569 break;
570 570
571 case HTMLRadio: 571 case HTMLRadio:
572 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 572 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
573 break; 573 break;
574 case HTMLRadioHover: 574 case HTMLRadioHover:
575 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV); 575 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV);
576 break; 576 break;
577 case HTMLRadioDown: 577 case HTMLRadioDown:
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:
630 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/); 630 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/);
631 break; 631 break;
632 case VSBSliderMid: 632 case VSBSliderMid:
633 case VSBSliderMidHover: 633 case VSBSliderMidHover:
634 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 634 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
635 break; 635 break;
636 case VSBSliderTopBg: 636 case VSBSliderTopBg:
637 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/); 637 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/);
638 break; 638 break;
639 case VSBSliderBtmBg: 639 case VSBSliderBtmBg:
640 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/); 640 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/);
641 break; 641 break;
642 case VSBSliderMidBg: 642 case VSBSliderMidBg:
643 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 643 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
644 break; 644 break;
645 645
646 case HSlider: 646 case HSlider:
647 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/); 647 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/);
648 break; 648 break;
649 case HSBSliderTop: 649 case HSBSliderTop:
650 case HSBSliderTopHover: 650 case HSBSliderTopHover:
651 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true ); 651 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true );
652 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 652 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
653 break; 653 break;
654 case HSBSliderBtm: 654 case HSBSliderBtm:
655 case HSBSliderBtmHover: 655 case HSBSliderBtmHover:
656 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true ); 656 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true );
657 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 657 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
658 break; 658 break;
659 case HSBSliderMid: 659 case HSBSliderMid:
660 case HSBSliderMidHover: 660 case HSBSliderMidHover:
661 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 661 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
662 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 662 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
663 break; 663 break;
664 case HSBSliderTopBg: 664 case HSBSliderTopBg:
665 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true ); 665 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true );
666 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 666 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
667 break; 667 break;
668 case HSBSliderBtmBg: 668 case HSBSliderBtmBg:
669 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true ); 669 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true );
670 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 670 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
671 break; 671 break;
672 case HSBSliderMidBg: 672 case HSBSliderMidBg:
673 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 673 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
674 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 674 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
675 break; 675 break;
676 default: 676 default:
677 break; 677 break;
678 } 678 }
679 return(pixmaps[item]); 679 return(pixmaps[item]);
680} 680}
681 681
682void LiquidStyle::polish(QPalette &appPal) 682void LiquidStyle::polish(QPalette &appPal)
683{ 683{
684 int i; 684 int i;
685 for(i=0; i < BITMAP_ITEMS; ++i){ 685 for(i=0; i < BITMAP_ITEMS; ++i){
686 if(pixmaps[i]){ 686 if(pixmaps[i]){
687 delete pixmaps[i]; 687 delete pixmaps[i];
688 pixmaps[i] = NULL; 688 pixmaps[i] = NULL;
689 } 689 }
690 } 690 }
691 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 691 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
692 btnDict.clear(); 692 btnDict.clear();
693 btnBorderDict.clear(); 693 btnBorderDict.clear();
694 bevelFillDict.clear(); 694 bevelFillDict.clear();
695 smallBevelFillDict.clear(); 695 smallBevelFillDict.clear();
696 696
697 Config config ( "qpe" ); 697 Config config ( "qpe" );
698 config. setGroup ( "Liquid-Style" ); 698 config. setGroup ( "Liquid-Style" );
699 int contrast = config. readNumEntry ( "StippleContrast", 5 ); 699 int contrast = config. readNumEntry ( "StippleContrast", 5 );
700 if ( contrast < 0 ) 700 if ( contrast < 0 )
701 contrast = 0; 701 contrast = 0;
702 else if ( contrast > 10 ) 702 else if ( contrast > 10 )
703 contrast = 10; 703 contrast = 10;
704 704
705// QPalette pal = QApplication::palette(); 705// QPalette pal = QApplication::palette();
706 706
707 // button color stuff 707 // button color stuff
708 config. setGroup ( "Appearance" ); 708 config. setGroup ( "Appearance" );
709 QColor c = appPal. color ( QPalette::Active, QColorGroup::Button ); 709 QColor c = appPal. color ( QPalette::Active, QColorGroup::Button );
710 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )) { 710 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )) {
711 // force button color to be different from background 711 // force button color to be different from background
712 QBrush btnBrush(QColor(200, 202, 228)); 712 QBrush btnBrush(QColor(200, 202, 228));
713 appPal.setBrush(QColorGroup::Button, btnBrush); 713 appPal.setBrush(QColorGroup::Button, btnBrush);
714 } 714 }
715 c.hsv(&btnH, &btnS, &btnV); 715 c.hsv(&btnH, &btnS, &btnV);
716 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 716 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
717 717
718 // menu pixmap 718 // menu pixmap
719 if(!menuPix){ 719 if(!menuPix){
720 menuPix = new QPixmap; 720 menuPix = new QPixmap;
721 menuPix->resize(64, 64); 721 menuPix->resize(64, 64);
722 } 722 }
723 QPainter painter; 723 QPainter painter;
724 menuPix->fill(c.rgb()); 724 menuPix->fill(c.rgb());
725 painter.begin(menuPix); 725 painter.begin(menuPix);
726 painter.setPen(c.dark(105)); 726 painter.setPen(c.dark(105));
727 for(i=0; i < 63; i+=4){ 727 for(i=0; i < 63; i+=4){
728 painter.drawLine(0, i, 63, i); 728 painter.drawLine(0, i, 63, i);
729 painter.drawLine(0, i+1, 63, i+1); 729 painter.drawLine(0, i+1, 63, i+1);
730 }; 730 };
731 painter.end(); 731 painter.end();
732 menuBrush.setColor(c); 732 menuBrush.setColor(c);
733 menuBrush.setPixmap(*menuPix); 733 menuBrush.setPixmap(*menuPix);
734 734
735 // pager brush 735 // pager brush
736 c = c.dark(120); 736 c = c.dark(120);
737 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 737 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
738 if(!pix){ 738 if(!pix){
739 int h, s, v; 739 int h, s, v;
740 c.hsv(&h, &s, &v); 740 c.hsv(&h, &s, &v);
741 pix = new QPixmap(*smallBevelFillPix); 741 pix = new QPixmap(*smallBevelFillPix);
742 adjustHSV(*pix, h, s, v); 742 adjustHSV(*pix, h, s, v);
743 smallBevelFillDict.insert(c.rgb(), pix); 743 smallBevelFillDict.insert(c.rgb(), pix);
744 } 744 }
745// pagerHoverBrush.setColor(c); 745// pagerHoverBrush.setColor(c);
746// pagerHoverBrush.setPixmap(*pix); 746// pagerHoverBrush.setPixmap(*pix);
747 747
748 c = c.dark(120); 748 c = c.dark(120);
749 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 749 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
750 if(!pix){ 750 if(!pix){
751 int h, s, v; 751 int h, s, v;
752 c.hsv(&h, &s, &v); 752 c.hsv(&h, &s, &v);
753 pix = new QPixmap(*smallBevelFillPix); 753 pix = new QPixmap(*smallBevelFillPix);
754 adjustHSV(*pix, h, s, v); 754 adjustHSV(*pix, h, s, v);
755 smallBevelFillDict.insert(c.rgb(), pix); 755 smallBevelFillDict.insert(c.rgb(), pix);
756 } 756 }
757// pagerBrush.setColor(c); 757// pagerBrush.setColor(c);
758// pagerBrush.setPixmap(*pix); 758// pagerBrush.setPixmap(*pix);
759 759
760 // background color stuff 760 // background color stuff
761 c = appPal. color ( QPalette::Active, QColorGroup::Background ); 761 c = appPal. color ( QPalette::Active, QColorGroup::Background );
762 762
763 c.hsv(&bH, &bS, &bV); 763 c.hsv(&bH, &bS, &bV);
764 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 764 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
765 765
766 // FIXME? 766 // FIXME?
767 if(vsbSliderFillPix) 767 if(vsbSliderFillPix)
768 delete vsbSliderFillPix; 768 delete vsbSliderFillPix;
769 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 769 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
770 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 770 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
771 771
772 // background brush 772 // background brush
773 QPixmap wallPaper(32, 32); 773 QPixmap wallPaper(32, 32);
774 wallPaper.fill(c.rgb()); 774 wallPaper.fill(c.rgb());
775 painter.begin(&wallPaper); 775 painter.begin(&wallPaper);
776 for(i=0; i < 32; i+=4){ 776 for(i=0; i < 32; i+=4){
777 painter.setPen(c.dark(100 + contrast)); 777 painter.setPen(c.dark(100 + contrast));
778 painter.drawLine(0, i, 32, i); 778 painter.drawLine(0, i, 32, i);
779 painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); 779 painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
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() &&
838 w->parent()->parent()->parent()->inherits("KHTMLView")){ 838 w->parent()->parent()->parent()->inherits("KHTMLView")){
839 w->setAutoMask(true); 839 w->setAutoMask(true);
840 w->setBackgroundMode(QWidget::NoBackground); 840 w->setBackgroundMode(QWidget::NoBackground);
841 } 841 }
842 } 842 }
843 } 843 }
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
925/* 925/*
926 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 926 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
927 w-> setBackgroundMode ( PaletteBackground ); 927 w-> setBackgroundMode ( PaletteBackground );
928 } 928 }
929*/ 929*/
930 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 930 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
931 w->removeEventFilter(this); 931 w->removeEventFilter(this);
932 } 932 }
933 if(w->inherits("QButton") || w->inherits("QComboBox")){ 933 if(w->inherits("QButton") || w->inherits("QComboBox")){
934 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 934 if(w->parent() && w->parent()->inherits("KHTMLPart")){
935 w->setAutoMask(false); 935 w->setAutoMask(false);
936 } 936 }
937 } 937 }
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;
1166 } 1166 }
1167 else if(ev->type() == QEvent::Leave){ 1167 else if(ev->type() == QEvent::Leave){
1168 currentHeader = NULL; 1168 currentHeader = NULL;
1169 if(headerHoverID != -1){ 1169 if(headerHoverID != -1){
1170 hw->repaint(hw->sectionPos(headerHoverID), 0, 1170 hw->repaint(hw->sectionPos(headerHoverID), 0,
1171 hw->sectionSize(headerHoverID), hw->height()); 1171 hw->sectionSize(headerHoverID), hw->height());
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
1233 // fill 1233 // fill
1234 QPixmap *pix = bevelFillDict.find(c.rgb()); 1234 QPixmap *pix = bevelFillDict.find(c.rgb());
1235 if(!pix){ 1235 if(!pix){
1236 int h, s, v; 1236 int h, s, v;
1237 c.hsv(&h, &s, &v); 1237 c.hsv(&h, &s, &v);
1238 pix = new QPixmap(*bevelFillPix); 1238 pix = new QPixmap(*bevelFillPix);
1239 adjustHSV(*pix, h, s, v); 1239 adjustHSV(*pix, h, s, v);
1240 bevelFillDict.insert(c.rgb(), pix); 1240 bevelFillDict.insert(c.rgb(), pix);
1241 } 1241 }
1242 1242
1243 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); 1243 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
1244 } 1244 }
1245 else{ 1245 else{
1246 drawClearBevel(p, x, y, w, h, sunken ? g.button() : 1246 drawClearBevel(p, x, y, w, h, sunken ? g.button() :
1247 highlightWidget == p->device() ? g.button().light(110) : 1247 highlightWidget == p->device() ? g.button().light(110) :
1248 g.background(), g.background()); 1248 g.background(), g.background());
1249 } 1249 }
1250} 1250}
1251 1251
1252void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) 1252void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
1253{ 1253{
1254 QRect r = btn->rect(); 1254 QRect r = btn->rect();
1255 bool sunken = btn->isOn() || btn->isDown(); 1255 bool sunken = btn->isOn() || btn->isDown();
1256 QColorGroup g = btn->colorGroup(); 1256 QColorGroup g = btn->colorGroup();
1257 1257
1258 1258
1259 //int dw = buttonDefaultIndicatorWidth(); 1259 //int dw = buttonDefaultIndicatorWidth();
1260 if(btn->hasFocus() || btn->isDefault()){ 1260 if(btn->hasFocus() || btn->isDefault()){
1261 QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); 1261 QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
1262 QPixmap *pix = bevelFillDict.find(c.rgb()); 1262 QPixmap *pix = bevelFillDict.find(c.rgb());
1263 if(!pix){ 1263 if(!pix){
1264 int h, s, v; 1264 int h, s, v;
1265 c.hsv(&h, &s, &v); 1265 c.hsv(&h, &s, &v);
1266 pix = new QPixmap(*bevelFillPix); 1266 pix = new QPixmap(*bevelFillPix);
1267 adjustHSV(*pix, h, s, v); 1267 adjustHSV(*pix, h, s, v);
1268 bevelFillDict.insert(c.rgb(), pix); 1268 bevelFillDict.insert(c.rgb(), pix);
1269 } 1269 }
1270 p->setPen(c.dark(150)); 1270 p->setPen(c.dark(150));
1271 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1271 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1272 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1272 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1273 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1273 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1274 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1274 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1275 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1275 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1276 } 1276 }
1277 1277
1278 QColor newColor = btn == highlightWidget || sunken ? 1278 QColor newColor = btn == highlightWidget || sunken ?
1279 g.button().light(120) : g.button(); 1279 g.button().light(120) : g.button();
1280 1280
1281 drawRoundButton(p, newColor, g.background(), 1281 drawRoundButton(p, newColor, g.background(),
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(),
1339 btn->pixmap(), btn->text(), -1, 1343 btn->pixmap(), btn->text(), -1,
1340 &btn->colorGroup().buttonText()); 1344 &btn->colorGroup().buttonText());
1341 } 1345 }
1342} 1346}
1343 1347
1344void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) 1348void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
1345{ 1349{
1346 int x2 = x+w-1; 1350 int x2 = x+w-1;
1347 int y2 = y+h-1; 1351 int y2 = y+h-1;
1348 1352
1349 p->setPen(Qt::color1); 1353 p->setPen(Qt::color1);
1350 p->fillRect(x, y, w, h, Qt::color0); 1354 p->fillRect(x, y, w, h, Qt::color0);
1351 if(w < 21 || h < 21){ 1355 if(w < 21 || h < 21){
1352 // outer rect 1356 // outer rect
1353 p->drawLine(x, y+2, x, y2-2); // l 1357 p->drawLine(x, y+2, x, y2-2); // l
1354 p->drawLine(x2, y+2, x2, y2-2); // r 1358 p->drawLine(x2, y+2, x2, y2-2); // r
1355 p->drawLine(x+2, y, x2-2, y); // t 1359 p->drawLine(x+2, y, x2-2, y); // t
1356 p->drawLine(x+2, y2, x2-2, y2); // b 1360 p->drawLine(x+2, y2, x2-2, y2); // b
1357 p->drawLine(x+1, y+1, x2-1, y+1); // top second line 1361 p->drawLine(x+1, y+1, x2-1, y+1); // top second line
1358 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line 1362 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line
1359 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); 1363 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1);
1360 } 1364 }
1361 else{ 1365 else{
1362 int x2 = x+w-1; 1366 int x2 = x+w-1;
1363 int y2 = y+h-1; 1367 int y2 = y+h-1;
1364 int bx2 = htmlBtnMaskBmp.width()-1; 1368 int bx2 = htmlBtnMaskBmp.width()-1;
1365 int by2 = htmlBtnMaskBmp.height()-1; 1369 int by2 = htmlBtnMaskBmp.height()-1;
1366 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl 1370 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
1367 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr 1371 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
1368 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl 1372 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
1369 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br 1373 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
1370 // fills 1374 // fills
1371 p->fillRect(10, 0, w-20, 10, Qt::color1); // top 1375 p->fillRect(10, 0, w-20, 10, Qt::color1); // top
1372 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1376 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1373 p->fillRect(0, 10, w, h-20, Qt::color1); // middle 1377 p->fillRect(0, 10, w, h-20, Qt::color1); // middle
1374 } 1378 }
1375} 1379}
1376 1380
1377void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, 1381void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
1378 const QColorGroup &g, bool sunken, 1382 const QColorGroup &g, bool sunken,
1379 const QBrush */*fill*/) 1383 const QBrush */*fill*/)
1380{ 1384{
1381 if(currentHeader && p->device() == currentHeader){ 1385 if(currentHeader && p->device() == currentHeader){
1382 int id = currentHeader->sectionAt(x); 1386 int id = currentHeader->sectionAt(x);
1383 bool isHeaderHover = id != -1 && id == headerHoverID; 1387 bool isHeaderHover = id != -1 && id == headerHoverID;
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
1445 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 1449 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
1446 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1450 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1447 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 1451 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
1448 p.end(); 1452 p.end();
1449 tmpPix.setMask(btnMask); 1453 tmpPix.setMask(btnMask);
1450 1454
1451 painter->drawPixmap(x, y, tmpPix); 1455 painter->drawPixmap(x, y, tmpPix);
1452 1456
1453 painter->setPen(g.button().dark(120)); 1457 painter->setPen(g.button().dark(120));
1454 painter->drawLine(x2-16, y+1, x2-16, y2-1); 1458 painter->drawLine(x2-16, y+1, x2-16, y2-1);
1455 1459
1456 if(edit){ 1460 if(edit){
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;
1506 if(extent == 16) 1510 if(extent == 16)
1507 brokenApp = true; 1511 brokenApp = true;
1508 else 1512 else
1509 brokenApp = false; 1513 brokenApp = false;
1510 1514
1511 if (horiz) { 1515 if (horiz) {
1512 subY = addY = ( extent - buttonDim ) / 2; 1516 subY = addY = ( extent - buttonDim ) / 2;
1513 subX = 0; 1517 subX = 0;
1514 addX = len - buttonDim; 1518 addX = len - buttonDim;
1515 if(sbBuffer.size() != sb->size()) 1519 if(sbBuffer.size() != sb->size())
1516 sbBuffer.resize(sb->size()); 1520 sbBuffer.resize(sb->size());
1517 } 1521 }
1518 else { 1522 else {
1519 subX = addX = ( extent - buttonDim ) / 2; 1523 subX = addX = ( extent - buttonDim ) / 2;
1520 subY = 0; 1524 subY = 0;
1521 addY = len - buttonDim; 1525 addY = len - buttonDim;
1522 if(sbBuffer.size() != sb->size()) 1526 if(sbBuffer.size() != sb->size())
1523 sbBuffer.resize(sb->size()); 1527 sbBuffer.resize(sb->size());
1524 } 1528 }
1525 subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); 1529 subB.setRect( subX,subY,0,0); // buttonDim,buttonDim );
1526 addB.setRect( addX,addY,buttonDim,buttonDim ); 1530 addB.setRect( addX,addY,buttonDim,buttonDim );
1527 if(horiz) 1531 if(horiz)
1528 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); 1532 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
1529 else 1533 else
1530 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); 1534 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
1531 1535
1532 int sliderEnd = sliderStart + sliderLength; 1536 int sliderEnd = sliderStart + sliderLength;
1533 int sliderW = extent; 1537 int sliderW = extent;
1534 1538
1535 if (horiz) { 1539 if (horiz) {
1536 subPageR.setRect( subB.right() + 1, 0, 1540 subPageR.setRect( subB.right() + 1, 0,
1537 sliderStart - subB.right() - 1 , sliderW ); 1541 sliderStart - subB.right() - 1 , sliderW );
1538 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); 1542 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
1539 sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); 1543 sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
1540 } 1544 }
1541 else { 1545 else {
1542 subPageR.setRect( 0, subB.bottom() + 1, sliderW, 1546 subPageR.setRect( 0, subB.bottom() + 1, sliderW,
1543 sliderStart - subB.bottom() - 1 ); 1547 sliderStart - subB.bottom() - 1 );
1544 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); 1548 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
1545 sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); 1549 sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
1546 } 1550 }
1547 1551
1548 bool maxed = sb->maxValue() == sb->minValue(); 1552 bool maxed = sb->maxValue() == sb->minValue();
1549 1553
1550 QPainter painter; 1554 QPainter painter;
1551 if(!horiz){ 1555 if(!horiz){
1552 painter.begin(&sbBuffer); 1556 painter.begin(&sbBuffer);
1553 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); 1557 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1);
1554 if(sliderR.height() >= 8){ 1558 if(sliderR.height() >= 8){
1555 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, 1559 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
1556 13, 8); 1560 13, 8);
1557 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); 1561 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
1558 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, 1562 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
1559 bgR.height()-16, *getPixmap(VSBSliderMidBg)); 1563 bgR.height()-16, *getPixmap(VSBSliderMidBg));
1560 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, 1564 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
1561 0, 0, 13, 8); 1565 0, 0, 13, 8);
1562 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); 1566 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
1563 } 1567 }
1564 else{ 1568 else{
1565 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), 1569 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
1566 *getPixmap(VSBSliderMidBg)); 1570 *getPixmap(VSBSliderMidBg));
1567 painter.setPen(g.background().dark(210)); 1571 painter.setPen(g.background().dark(210));
1568 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); 1572 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
1569 painter.setPen(g.mid()); 1573 painter.setPen(g.mid());
1570 painter.drawPoint(bgR.x()+1, bgR.y()); 1574 painter.drawPoint(bgR.x()+1, bgR.y());
1571 painter.drawPoint(bgR.x()+13, bgR.y()); 1575 painter.drawPoint(bgR.x()+13, bgR.y());
1572 painter.drawPoint(bgR.x()+1, bgR.bottom()-1); 1576 painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
1573 painter.drawPoint(bgR.x()+13, bgR.bottom()-1); 1577 painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
1574 } 1578 }
1575 if(controls & Slider){ 1579 if(controls & Slider){
1576 if(sliderR.height() >= 16){ 1580 if(sliderR.height() >= 16){
1577 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop)); 1581 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop));
1578 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, 1582 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
1579 sliderR.height()-16, *getPixmap(VSBSliderMid)); 1583 sliderR.height()-16, *getPixmap(VSBSliderMid));
1580 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm)); 1584 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm));
1581 } 1585 }
1582 else if(sliderR.height() >= 8){ 1586 else if(sliderR.height() >= 8){
1583 int m = sliderR.height()/2; 1587 int m = sliderR.height()/2;
1584 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m); 1588 painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m);
1585 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); 1589 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1586 } 1590 }
1587 else{ 1591 else{
1588 painter.setPen(g.button().dark(210)); 1592 painter.setPen(g.button().dark(210));
1589 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), 1593 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
1590 13, sliderR.height()); 1594 13, sliderR.height());
1591 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, 1595 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
1592 11, sliderR.height()-2, 1596 11, sliderR.height()-2,
1593 *getPixmap(VSBSliderMid), 1, 0); 1597 *getPixmap(VSBSliderMid), 1, 0);
1594 } 1598 }
1595 } 1599 }
1596 painter.setPen(g.mid()); 1600 painter.setPen(g.mid());
1597 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); 1601 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
1598 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); 1602 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
1599 if(brokenApp && (controls & Slider)){ 1603 if(brokenApp && (controls & Slider)){
1600 painter.setPen(g.background()); 1604 painter.setPen(g.background());
1601 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, 1605 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
1602 bgR.bottom()); 1606 bgR.bottom());
1603 } 1607 }
1604 painter.end(); 1608 painter.end();
1605 } 1609 }
1606 else{ 1610 else{
1607 painter.begin(&sbBuffer); 1611 painter.begin(&sbBuffer);
1608 QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); 1612 QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height());
1609 if(sliderR.width() >= 8){ 1613 if(sliderR.width() >= 8){
1610 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, 1614 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
1611 8, 13); 1615 8, 13);
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,
1676 // subB.width()-8, subB.height()-8, g, !maxed); 1680 // subB.width()-8, subB.height()-8, g, !maxed);
1677 drawSBButton(p, subHC, g, activeControl == SubLine); 1681 drawSBButton(p, subHC, g, activeControl == SubLine);
1678 drawArrow( p, horiz ? LeftArrow : UpArrow, 1682 drawArrow( p, horiz ? LeftArrow : UpArrow,
1679 false, subHC.x()+4, subHC.y()+4, 1683 false, subHC.x()+4, subHC.y()+4,
1680 subHC.width()-8, subHC.height()-8, g, !maxed); 1684 subHC.width()-8, subHC.height()-8, g, !maxed);
1681 } 1685 }
1682 1686
1683 if(controls & AddPage){ 1687 if(controls & AddPage){
1684 if(addPageR.width()){ 1688 if(addPageR.width()){
1685 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, 1689 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
1686 addPageR.x(), addPageR.y(), addPageR.width(), 1690 addPageR.x(), addPageR.y(), addPageR.width(),
1687 addPageR.height()); 1691 addPageR.height());
1688 } 1692 }
1689 } 1693 }
1690 if(controls & SubPage){ 1694 if(controls & SubPage){
1691 if(subPageR.height()){ 1695 if(subPageR.height()){
1692 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, 1696 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
1693 subPageR.x(), subPageR.y(), subPageR.width(), 1697 subPageR.x(), subPageR.y(), subPageR.width(),
1694 subPageR.height()); 1698 subPageR.height());
1695 } 1699 }
1696 } 1700 }
1697 if ( controls & Slider ) { 1701 if ( controls & Slider ) {
1698 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, 1702 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
1699 sliderR.x(), sliderR.y(), sliderR.width(), 1703 sliderR.x(), sliderR.y(), sliderR.width(),
1700 sliderR.height()); 1704 sliderR.height());
1701 } 1705 }
1702} 1706}
1703 1707
1704void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, 1708void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
1705 bool down, bool /*fast*/) 1709 bool down, bool /*fast*/)
1706{ 1710{
1707 p->setPen(g.mid()); 1711 p->setPen(g.mid());
1708 p->drawRect(r); 1712 p->drawRect(r);
1709 QColor c(down ? g.button() : g.background()); 1713 QColor c(down ? g.button() : g.background());
1710 QPixmap *pix = bevelFillDict.find(c.rgb()); 1714 QPixmap *pix = bevelFillDict.find(c.rgb());
1711 if(!pix){ 1715 if(!pix){
1712 int h, s, v; 1716 int h, s, v;
1713 c.hsv(&h, &s, &v); 1717 c.hsv(&h, &s, &v);
1714 pix = new QPixmap(*bevelFillPix); 1718 pix = new QPixmap(*bevelFillPix);
1715 adjustHSV(*pix, h, s, v); 1719 adjustHSV(*pix, h, s, v);
1716 bevelFillDict.insert(c.rgb(), pix); 1720 bevelFillDict.insert(c.rgb(), pix);
1717 } 1721 }
1718 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1722 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1719 1723
1720} 1724}
1721 1725
1722void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, 1726void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
1723 bool horiz) 1727 bool horiz)
1724{ 1728{
1725 if(horiz){ 1729 if(horiz){
1726 if(r.width() >= 15){ 1730 if(r.width() >= 15){
1727 int y = r.y()+3; 1731 int y = r.y()+3;
1728 int x = r.x() + (r.width()-7)/2; 1732 int x = r.x() + (r.width()-7)/2;
1729 int y2 = r.bottom()-3; 1733 int y2 = r.bottom()-3;
1730 p->setPen(g.light()); 1734 p->setPen(g.light());
1731 p->drawLine(x, y, x, y2); 1735 p->drawLine(x, y, x, y2);
1732 p->drawLine(x+3, y, x+3, y2); 1736 p->drawLine(x+3, y, x+3, y2);
1733 p->drawLine(x+6, y, x+6, y2); 1737 p->drawLine(x+6, y, x+6, y2);
1734 1738
1735 p->setPen(g.mid()); 1739 p->setPen(g.mid());
1736 p->drawLine(x+1, y, x+1, y2); 1740 p->drawLine(x+1, y, x+1, y2);
1737 p->drawLine(x+4, y, x+4, y2); 1741 p->drawLine(x+4, y, x+4, y2);
1738 p->drawLine(x+7, y, x+7, y2); 1742 p->drawLine(x+7, y, x+7, y2);
1739 } 1743 }
1740 } 1744 }
1741 else{ 1745 else{
1742 if(r.height() >= 15){ 1746 if(r.height() >= 15){
1743 int x = r.x()+3; 1747 int x = r.x()+3;
1744 int y = r.y() + (r.height()-7)/2; 1748 int y = r.y() + (r.height()-7)/2;
1745 int x2 = r.right()-3; 1749 int x2 = r.right()-3;
1746 p->setPen(g.light()); 1750 p->setPen(g.light());
1747 p->drawLine(x, y, x2, y); 1751 p->drawLine(x, y, x2, y);
1748 p->drawLine(x, y+3, x2, y+3); 1752 p->drawLine(x, y+3, x2, y+3);
1749 p->drawLine(x, y+6, x2, y+6); 1753 p->drawLine(x, y+6, x2, y+6);
1750 1754
1751 p->setPen(g.mid()); 1755 p->setPen(g.mid());
1752 p->drawLine(x, y+1, x2, y+1); 1756 p->drawLine(x, y+1, x2, y+1);
1753 p->drawLine(x, y+4, x2, y+4); 1757 p->drawLine(x, y+4, x2, y+4);
1754 p->drawLine(x, y+7, x2, y+7); 1758 p->drawLine(x, y+7, x2, y+7);
1755 } 1759 }
1756 } 1760 }
1757 1761
1758} 1762}
1759 1763
1760 1764
1761void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, 1765void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
1762 int &sliderMax, int &sliderLength, 1766 int &sliderMax, int &sliderLength,
1763 int &buttonDim) 1767 int &buttonDim)
1764{ 1768{
1765 1769
1766 int maxLength; 1770 int maxLength;
1767 int b = 0; 1771 int b = 0;
1768 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1772 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1769 int length = horiz ? sb->width() : sb->height(); 1773 int length = horiz ? sb->width() : sb->height();
1770 int extent = horiz ? sb->height() : sb->width(); 1774 int extent = horiz ? sb->height() : sb->width();
1771 1775
1772 if ( length > ( extent - b*2 - 1 )*2 + b*2 ) 1776 if ( length > ( extent - b*2 - 1 )*2 + b*2 )
1773 buttonDim = extent - b*2; 1777 buttonDim = extent - b*2;
1774 else 1778 else
1775 buttonDim = ( length - b*2 )/2 - 1; 1779 buttonDim = ( length - b*2 )/2 - 1;
1776 1780
1777 sliderMin = b + 0; // buttonDim; 1781 sliderMin = b + 0; // buttonDim;
1778 maxLength = length - b*2 - buttonDim*2; // 3; 1782 maxLength = length - b*2 - buttonDim*2; // 3;
1779 1783
1780 if ( sb->maxValue() == sb->minValue() ) { 1784 if ( sb->maxValue() == sb->minValue() ) {
1781 sliderLength = maxLength; 1785 sliderLength = maxLength;
1782 } else { 1786 } else {
1783 sliderLength = (sb->pageStep()*maxLength)/ 1787 sliderLength = (sb->pageStep()*maxLength)/
1784 (sb->maxValue()-sb->minValue()+sb->pageStep()); 1788 (sb->maxValue()-sb->minValue()+sb->pageStep());
1785 uint range = sb->maxValue()-sb->minValue(); 1789 uint range = sb->maxValue()-sb->minValue();
1786 if ( sliderLength < 9 || range > INT_MAX/2 ) 1790 if ( sliderLength < 9 || range > INT_MAX/2 )
1787 sliderLength = 9; 1791 sliderLength = 9;
1788 if ( sliderLength > maxLength ) 1792 if ( sliderLength > maxLength )
1789 sliderLength = maxLength; 1793 sliderLength = maxLength;
1790 } 1794 }
1791 sliderMax = sliderMin + maxLength - sliderLength; 1795 sliderMax = sliderMin + maxLength - sliderLength;
1792 1796
1793} 1797}
1794 1798
1795QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, 1799QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
1796 int sliderStart, 1800 int sliderStart,
1797 const QPoint &p) 1801 const QPoint &p)
1798{ 1802{
1799 if ( !sb->rect().contains( p ) ) 1803 if ( !sb->rect().contains( p ) )
1800 return NoScroll; 1804 return NoScroll;
1801 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 1805 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
1802 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1806 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1803 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); 1807 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y();
1804 if ( pos < sliderMin ) 1808 if ( pos < sliderMin )
1805 return SubLine; 1809 return SubLine;
1806 if ( pos < sliderStart ) 1810 if ( pos < sliderStart )
1807 return SubPage; 1811 return SubPage;
1808 if ( pos < sliderStart + sliderLength ) 1812 if ( pos < sliderStart + sliderLength )
1809 return Slider; 1813 return Slider;
1810 if ( pos < sliderMax + sliderLength) 1814 if ( pos < sliderMax + sliderLength)
1811 return AddPage; 1815 return AddPage;
1812 if(pos > sliderMax + sliderLength + 16) 1816 if(pos > sliderMax + sliderLength + 16)
1813 return AddLine; 1817 return AddLine;
1814 1818
1815 return SubLine; 1819 return SubLine;
1816} 1820}
1817 1821
1818#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1822#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1819 1823
1820 1824
1821QSize LiquidStyle::exclusiveIndicatorSize() const 1825QSize LiquidStyle::exclusiveIndicatorSize() const
1822{ 1826{
1823 return(QSize(16, 16)); 1827 return(QSize(16, 16));
1824} 1828}
1825 1829
1826void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, 1830void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1827 int /*h*/, const QColorGroup &/*g*/, bool on, 1831 int /*h*/, const QColorGroup &/*g*/, bool on,
1828 bool down, bool) 1832 bool down, bool)
1829{ 1833{
1830 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( )); 1834 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
1831 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1835 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1832 && ((QWidget*)p->device())->autoMask(); 1836 && ((QWidget*)p->device())->autoMask();
1833 1837
1834 if(isMasked){ 1838 if(isMasked){
1835 if(on || down){ 1839 if(on || down){
1836 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioDownHover) : 1840 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioDownHover) :
1837 *getPixmap(HTMLRadioDown)); 1841 *getPixmap(HTMLRadioDown));
1838 } 1842 }
1839 else 1843 else
1840 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioHover) : 1844 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioHover) :
1841 *getPixmap(HTMLRadio)); 1845 *getPixmap(HTMLRadio));
1842 1846
1843 } 1847 }
1844 else{ 1848 else{
1845 if(on || down){ 1849 if(on || down){
1846 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOnHover) : 1850 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOnHover) :
1847 *getPixmap(RadioOn)); 1851 *getPixmap(RadioOn));
1848 } 1852 }
1849 else 1853 else
1850 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOffHover) : 1854 p->drawPixmap(x, y, isActive ? *getPixmap(RadioOffHover) :
1851 *getPixmap(RadioOff)); 1855 *getPixmap(RadioOff));
1852 } 1856 }
1853} 1857}
1854 1858
1855void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, 1859void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w,
1856 int h, bool) 1860 int h, bool)
1857{ 1861{
1858 p->fillRect(x, y, w, h, Qt::color0); 1862 p->fillRect(x, y, w, h, Qt::color0);
1859 p->setPen(Qt::color1); 1863 p->setPen(Qt::color1);
1860 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); 1864 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask());
1861} 1865}
1862 1866
1863 1867
1864QSize LiquidStyle::indicatorSize() const 1868QSize LiquidStyle::indicatorSize() const
1865{ 1869{
1866 return(QSize(20, 22)); 1870 return(QSize(20, 22));
1867} 1871}
1868 1872
1869void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1873void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1870 const QColorGroup &/*g*/, int state, bool /*down*/, bool) 1874 const QColorGroup &/*g*/, int state, bool /*down*/, bool)
1871{ 1875{
1872 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( )); 1876 bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
1873 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1877 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1874 && ((QWidget*)p->device())->autoMask(); 1878 && ((QWidget*)p->device())->autoMask();
1875 if(isMasked){ 1879 if(isMasked){
1876 if(state != QButton::Off){ 1880 if(state != QButton::Off){
1877 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBDownHover) : 1881 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBDownHover) :
1878 *getPixmap(HTMLCBDown)); 1882 *getPixmap(HTMLCBDown));
1879 } 1883 }
1880 else 1884 else
1881 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBHover) : 1885 p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBHover) :
1882 *getPixmap(HTMLCB)); 1886 *getPixmap(HTMLCB));
1883 1887
1884 } 1888 }
1885 else{ 1889 else{
1886 if(state != QButton::Off){ 1890 if(state != QButton::Off){
1887 p->drawPixmap(x, y, isActive ? *getPixmap(CBDownHover) : 1891 p->drawPixmap(x, y, isActive ? *getPixmap(CBDownHover) :
1888 *getPixmap(CBDown)); 1892 *getPixmap(CBDown));
1889 /* Todo - tristate 1893 /* Todo - tristate
1890 if(state == QButton::On){ 1894 if(state == QButton::On){
1891 p->setPen(Qt::black); 1895 p->setPen(Qt::black);
1892 p->drawPixmap(3, 3, xBmp); 1896 p->drawPixmap(3, 3, xBmp);
1893 } 1897 }
1894 else{ 1898 else{
1895 p->setPen(g.dark()); 1899 p->setPen(g.dark());
1896 p->drawRect(x+2, y+2, w-4, h-4); 1900 p->drawRect(x+2, y+2, w-4, h-4);
1897 p->setPen(Qt::black); 1901 p->setPen(Qt::black);
1898 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); 1902 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2);
1899 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); 1903 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2);
1900 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); 1904 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2);
1901 }*/ 1905 }*/
1902 } 1906 }
1903 else 1907 else
1904 p->drawPixmap(x, y, isActive ? *getPixmap(CBHover) : *getPixmap(CB)); 1908 p->drawPixmap(x, y, isActive ? *getPixmap(CBHover) : *getPixmap(CB));
1905 } 1909 }
1906} 1910}
1907 1911
1908void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1912void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1909 int /*state*/) 1913 int /*state*/)
1910{ 1914{
1911 // needed for some reason by KHtml, even tho it's all filled ;P 1915 // needed for some reason by KHtml, even tho it's all filled ;P
1912 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); 1916 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask());
1913 1917
1914} 1918}
1915 1919
1916void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, 1920void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
1917 const QColorGroup &/*g*/, Orientation orient, 1921 const QColorGroup &/*g*/, Orientation orient,
1918 bool, bool) 1922 bool, bool)
1919{ 1923{
1920 QWidget *parent = (QWidget *)p->device(); 1924 QWidget *parent = (QWidget *)p->device();
1921 p->setBrushOrigin(parent->pos()); 1925 p->setBrushOrigin(parent->pos());
1922 parent->erase(x, y, w, h); 1926 parent->erase(x, y, w, h);
1923 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : 1927 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) :
1924 *getPixmap(VSlider)); 1928 *getPixmap(VSlider));
1925} 1929}
1926 1930
1927void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1931void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1928 Orientation orient, bool, bool) 1932 Orientation orient, bool, bool)
1929{ 1933{
1930 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : 1934 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() :
1931 *getPixmap(VSlider)->mask()); 1935 *getPixmap(VSlider)->mask());
1932} 1936}
1933 1937
1934int LiquidStyle::sliderLength() const 1938int LiquidStyle::sliderLength() const
1935{ 1939{
1936 return(10); 1940 return(10);
1937} 1941}
1938 1942
1939#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1943#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1940 1944
1941void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, 1945void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
1942 int y, int w, int h, const QColorGroup &g, 1946 int y, int w, int h, const QColorGroup &g,
1943 bool enabled, const QBrush *) 1947 bool enabled, const QBrush *)
1944{ 1948{
1945 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; 1949 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5};
1946 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; 1950 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6};
1947 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; 1951 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7};
1948 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; 1952 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4};
1949 1953
1950 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); 1954 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid());
1951 if(w > 8){ 1955 if(w > 8){
1952 x = x + (w-8)/2; 1956 x = x + (w-8)/2;
1953 y = y + (h-8)/2; 1957 y = y + (h-8)/2;
1954 } 1958 }
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,
2027 AlignCenter|ShowPrefix|DontClip|SingleLine, 2031 AlignCenter|ShowPrefix|DontClip|SingleLine,
2028 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), 2032 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
2029 -1, &g.text()); 2033 -1, &g.text());
2030 } 2034 }
2031 delete dummy; 2035 delete dummy;
2032 } 2036 }
2033 else{ 2037 else{
2034 if(active) 2038 if(active)
2035 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2039 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2036 QApplication::style().drawItem(p, x, y, w, h, 2040 QApplication::style().drawItem(p, x, y, w, h,
2037 AlignCenter|ShowPrefix|DontClip|SingleLine, 2041 AlignCenter|ShowPrefix|DontClip|SingleLine,
2038 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(), 2042 g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
2039 -1, &g.text()); 2043 -1, &g.text());
2040 } 2044 }
2041} 2045}
2042 2046
2043void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, 2047void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h,
2044 const QColorGroup &g, int /*lineWidth*/, 2048 const QColorGroup &g, int /*lineWidth*/,
2045 const QBrush * /*fill*/) 2049 const QBrush * /*fill*/)
2046{ 2050{
2047 QColor c; 2051 QColor c;
2048 switch(menuHandler->transType()){ 2052 switch(menuHandler->transType()){
2049 case None: 2053 case None:
2050 case StippledBg: 2054 case StippledBg:
2051 case TransStippleBg: 2055 case TransStippleBg:
2052 c = g.background(); 2056 c = g.background();
2053 break; 2057 break;
2054 case StippledBtn: 2058 case StippledBtn:
2055 case TransStippleBtn: 2059 case TransStippleBtn:
2056 c = g.button(); 2060 c = g.button();
2057 break; 2061 break;
2058 default: 2062 default:
2059 c = menuHandler->bgColor(); 2063 c = menuHandler->bgColor();
2060 } 2064 }
2061 p->setPen(c.dark(140)); 2065 p->setPen(c.dark(140));
2062 p->drawRect(x, y, w, h); 2066 p->drawRect(x, y, w, h);
2063 p->setPen(c.light(120)); 2067 p->setPen(c.light(120));
2064 p->drawRect(x+1, y+1, w-2, h-2); 2068 p->drawRect(x+1, y+1, w-2, h-2);
2065} 2069}
2066 2070
2067void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 2071void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
2068 int tab, QMenuItem* mi, 2072 int tab, QMenuItem* mi,
2069 const QPalette& pal, bool act, 2073 const QPalette& pal, bool act,
2070 bool enabled, int x, int y, int w, int h) 2074 bool enabled, int x, int y, int w, int h)
2071{ 2075{
2072static const int motifItemFrame = 2; 2076static const int motifItemFrame = 2;
2073static const int motifItemHMargin = 3; 2077static const int motifItemHMargin = 3;
2074static const int motifItemVMargin = 2; 2078static const int motifItemVMargin = 2;
2075static const int motifArrowHMargin = 6; 2079static const int motifArrowHMargin = 6;
2076static const int windowsRightBorder = 12; 2080static const int windowsRightBorder = 12;
2077 2081
2078 maxpmw = QMAX( maxpmw, 20 ); 2082 maxpmw = QMAX( maxpmw, 20 );
2079 2083
2080 2084
2081 bool dis = !enabled; 2085 bool dis = !enabled;
2082 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 2086 QColorGroup itemg = dis ? pal.disabled() : pal.active();
2083 2087
2084 int checkcol = maxpmw; 2088 int checkcol = maxpmw;
2085 if(act){ 2089 if(act){
2086 2090
2087 // FIXME 2091 // FIXME
2088 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); 2092 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background());
2089 } 2093 }
2090 //else if(((QWidget*)p->device())->backgroundPixmap()){ 2094 //else if(((QWidget*)p->device())->backgroundPixmap()){
2091 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), 2095 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(),
2092 // x, y, w, h); 2096 // x, y, w, h);
2093 //} 2097 //}
2094 else{ 2098 else{
2095 if(menuHandler->transType() == None){ 2099 if(menuHandler->transType() == None){
2096 p->fillRect(x, y, w, h, pal.active().background()); 2100 p->fillRect(x, y, w, h, pal.active().background());
2097 } 2101 }
2098 else if(menuHandler->transType() == StippledBg){ 2102 else if(menuHandler->transType() == StippledBg){
2099 p->fillRect(x, y, w, h, bgBrush); 2103 p->fillRect(x, y, w, h, bgBrush);
2100 } 2104 }
2101 else if(menuHandler->transType() == StippledBtn){ 2105 else if(menuHandler->transType() == StippledBtn){
2102 p->fillRect(x, y, w, h, menuBrush); 2106 p->fillRect(x, y, w, h, menuBrush);
2103 } 2107 }
2104 else{ 2108 else{
2105 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); 2109 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId());
2106 if(pix) 2110 if(pix)
2107 p->drawPixmap(x, y, *pix, x, y, w, h); 2111 p->drawPixmap(x, y, *pix, x, y, w, h);
2108 } 2112 }
2109 } 2113 }
2110 2114
2111 if(!mi) 2115 if(!mi)
2112 return; 2116 return;
2113 2117
2114 QColor discol; 2118 QColor discol;
2115 if (dis) { 2119 if (dis) {
2116 discol = itemg.mid(); 2120 discol = itemg.mid();
2117 p->setPen(discol); 2121 p->setPen(discol);
2118 } 2122 }
2119 2123
2120 QColorGroup cg2(itemg); 2124 QColorGroup cg2(itemg);
2121 2125
2122 if(menuHandler->transType() == Custom){ 2126 if(menuHandler->transType() == Custom){
2123 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); 2127 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor());
2124 cg2.setColor(QColorGroup::Text, menuHandler->textColor()); 2128 cg2.setColor(QColorGroup::Text, menuHandler->textColor());
2125 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); 2129 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120));
2126 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); 2130 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120));
2127 } 2131 }
2128 else{ 2132 else{
2129 cg2 = QColorGroup(discol, itemg.highlight(), black, black, 2133 cg2 = QColorGroup(discol, itemg.highlight(), black, black,
2130 dis ? discol : black, discol, black); 2134 dis ? discol : black, discol, black);
2131 } 2135 }
2132 2136
2133 if(mi->isSeparator()){ 2137 if(mi->isSeparator()){
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;
2183 QString s = mi->text(); 2191 QString s = mi->text();
2184 if (!s.isNull()) { 2192 if (!s.isNull()) {
2185 int t = s.find( '\t' ); 2193 int t = s.find( '\t' );
2186 int m = motifItemVMargin; 2194 int m = motifItemVMargin;
2187 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 2195 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
2188 QPen oldPen = p->pen(); 2196 QPen oldPen = p->pen();
2189 if(menuHandler->useShadowText()){ 2197 if(menuHandler->useShadowText()){
2190 if(menuHandler->transType() == Custom) 2198 if(menuHandler->transType() == Custom)
2191 p->setPen(menuHandler->bgColor().dark(130)); 2199 p->setPen(menuHandler->bgColor().dark(130));
2192 else if(menuHandler->transType() == StippledBtn || 2200 else if(menuHandler->transType() == StippledBtn ||
2193 menuHandler->transType() == TransStippleBtn) 2201 menuHandler->transType() == TransStippleBtn)
2194 p->setPen(itemg.button().dark(130)); 2202 p->setPen(itemg.button().dark(130));
2195 else 2203 else
2196 p->setPen(bgBrush.color().dark(130)); 2204 p->setPen(bgBrush.color().dark(130));
2197 2205
2198 if (t >= 0) { 2206 if (t >= 0) {
2199 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, 2207 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2,
2200 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); 2208 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 ));
2201 } 2209 }
2202 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); 2210 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t);
2203 } 2211 }
2204 p->setPen(oldPen); 2212 p->setPen(oldPen);
2205 if (t >= 0) { 2213 if (t >= 0) {
2206 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 2214 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
2207 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 2215 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
2208 } 2216 }
2209 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); 2217 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t);
2210 2218
2211 } 2219 }
2212 else if (mi->pixmap()) { 2220 else if (mi->pixmap()) {
2213 QPixmap *pixmap = mi->pixmap(); 2221 QPixmap *pixmap = mi->pixmap();
2214 if (pixmap->depth() == 1) 2222 if (pixmap->depth() == 1)
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 }
2265 } 2272 }
2266 else 2273 else
2267 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); 2274 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
2268 2275
2269} 2276}
2270 2277
2271void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) 2278void LiquidStyle::polishPopupMenu(QPopupMenu *mnu)
2272{ 2279{
2273 mnu->installEventFilter(menuHandler); 2280 mnu->installEventFilter(menuHandler);
2274 QWindowsStyle::polishPopupMenu(mnu); 2281 QWindowsStyle::polishPopupMenu(mnu);
2275} 2282}
2276 2283
2277void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, 2284void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab,
2278 bool selected) 2285 bool selected)
2279{ 2286{
2280 if(tabBar->shape() != QTabBar::RoundedAbove){ 2287 if(tabBar->shape() != QTabBar::RoundedAbove){
2281 QWindowsStyle::drawTab(p, tabBar, tab, selected); 2288 QWindowsStyle::drawTab(p, tabBar, tab, selected);
2282 return; 2289 return;
2283 } 2290 }
2284 QPixmap tilePix; 2291 QPixmap tilePix;
2285 QRect r = tab->rect(); 2292 QRect r = tab->rect();
2286 //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : 2293 //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] :
2287 // pixmaps[TabDown] : pixmaps[Tab]; 2294 // pixmaps[TabDown] : pixmaps[Tab];
2288 2295
2289 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); 2296 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
2290 p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); 2297 p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height());
2291 p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); 2298 p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height());
2292 tilePix.resize(pix->width()-18, r.height()); 2299 tilePix.resize(pix->width()-18, r.height());
2293 bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); 2300 bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height());
2294 p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); 2301 p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix);
2295 QColor c = tabBar->colorGroup().button(); 2302 QColor c = tabBar->colorGroup().button();
2296 if(!selected){ 2303 if(!selected){
2297 p->setPen(c.dark(130)); 2304 p->setPen(c.dark(130));
2298 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); 2305 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
2299 } 2306 }
2300 2307
2301 /* 2308 /*
2302 p->setPen(c.light(110)); 2309 p->setPen(c.light(110));
2303 p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); 2310 p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1);
2304 p->setPen(c); 2311 p->setPen(c);
2305 p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); 2312 p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2);
2306 p->setPen(c.light(110)); 2313 p->setPen(c.light(110));
2307 p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); 2314 p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3);
2308 p->setPen(c.light(120)); 2315 p->setPen(c.light(120));
2309 p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); 2316 p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4);
2310 */ 2317 */
2311 2318
2312 /* 2319 /*
2313 QColor c = tabBar->colorGroup().button(); 2320 QColor c = tabBar->colorGroup().button();
2314 pix = bevelFillDict.find(c.rgb()); 2321 pix = bevelFillDict.find(c.rgb());
2315 if(!pix){ 2322 if(!pix){
2316 int h, s, v; 2323 int h, s, v;
2317 c.hsv(&h, &s, &v); 2324 c.hsv(&h, &s, &v);
2318 pix = new QPixmap(*bevelFillPix); 2325 pix = new QPixmap(*bevelFillPix);
2319 adjustHSV(*pix, h, s); 2326 adjustHSV(*pix, h, s);
2320 bevelFillDict.insert(c.rgb(), pix); 2327 bevelFillDict.insert(c.rgb(), pix);
2321 }*/ 2328 }*/
2322 2329
2323 /* 2330 /*
2324 QRect r = tab->rect(); 2331 QRect r = tab->rect();
2325 QColorGroup g = tabBar->colorGroup(); 2332 QColorGroup g = tabBar->colorGroup();
2326 if(!selected){ 2333 if(!selected){
2327 r.setY(r.y()+1); 2334 r.setY(r.y()+1);
2328 p->setPen(g.dark()); 2335 p->setPen(g.dark());
2329 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); 2336 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2);
2330 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); 2337 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
2331 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); 2338 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
2332 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); 2339 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2);
2333 2340
2334 p->setPen(g.midlight()); 2341 p->setPen(g.midlight());
2335 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); 2342 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
2336 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); 2343 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
2337 p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); 2344 p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1);
2338 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); 2345 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
2339 2346
2340 p->setPen(g.mid()); 2347 p->setPen(g.mid());
2341 p->drawPoint(r.right()-1, r.y()+1); 2348 p->drawPoint(r.right()-1, r.y()+1);
2342 p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); 2349 p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2);
2343 p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); 2350 p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3);
2344 2351
2345 p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, 2352 p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6,
2346 g.brush(QColorGroup::Mid)); 2353 g.brush(QColorGroup::Mid));
2347 2354
2348 p->setPen(g.light()); 2355 p->setPen(g.light());
2349 p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); 2356 p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1);
2350 2357
2351 } 2358 }
2352 else{ 2359 else{
2353 p->setPen(g.light()); 2360 p->setPen(g.light());
2354 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); 2361 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom());
2355 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); 2362 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
2356 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); 2363 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
2357 p->setPen(g.dark()); 2364 p->setPen(g.dark());
2358 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); 2365 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom());
2359 2366
2360 p->setPen(g.midlight()); 2367 p->setPen(g.midlight());
2361 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); 2368 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
2362 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); 2369 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
2363 p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); 2370 p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1);
2364 p->setPen(g.mid()); 2371 p->setPen(g.mid());
2365 p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); 2372 p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom());
2366 }*/ 2373 }*/
2367 2374
2368} 2375}
2369 2376
2370 2377
2371 2378
2372void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, 2379void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab,
2373 bool selected) 2380 bool selected)
2374 2381
2375 2382
2376{ 2383{
2377 //p->fillRect(tab->rect(), Qt::color1); 2384 //p->fillRect(tab->rect(), Qt::color1);
2378 QRect r = tab->rect(); 2385 QRect r = tab->rect();
2379 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); 2386 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
2380 p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); 2387 p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height());
2381 p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); 2388 p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height());
2382 p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); 2389 p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1);
2383} 2390}
2384 2391
2385void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, 2392void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame,
2386 int &overlap) 2393 int &overlap)
2387{ 2394{
2388 if(t->shape() == QTabBar::RoundedAbove){ 2395 if(t->shape() == QTabBar::RoundedAbove){
2389 overlap = 1; 2396 overlap = 1;
2390 hFrame = 18; // was 24 2397 hFrame = 18; // was 24
2391 vFrame = 8; // was 10 2398 vFrame = 8; // was 10
2392 } 2399 }
2393 else 2400 else
2394 QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); 2401 QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap);
2395} 2402}
2396 2403
2397 2404
2398 2405
2399void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, 2406void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h,
2400 const QColorGroup &g, Orientation) 2407 const QColorGroup &g, Orientation)
2401{ 2408{
2402 drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? 2409 drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ?
2403 g.button().light(120) : g.button(), g.background()); 2410 g.button().light(120) : g.button(), g.background());
2404} 2411}
2405 2412
2406 2413
2407void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, 2414void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
2408 const QColorGroup &g, bool sunken, 2415 const QColorGroup &g, bool sunken,
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);
2458 unsigned int *data = (unsigned int *)img.bits(); 2465 unsigned int *data = (unsigned int *)img.bits();
2459 int total = img.width()*img.height(); 2466 int total = img.width()*img.height();
2460 int current; 2467 int current;
2461 QColor c; 2468 QColor c;
2462 int oldH, oldS, oldV; 2469 int oldH, oldS, oldV;
2463 if(v < 235) 2470 if(v < 235)
2464 v += 20; 2471 v += 20;
2465 else 2472 else
2466 v = 255; 2473 v = 255;
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);
2537} 2544}
2538 2545
2539void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) 2546void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h)
2540{ 2547{
2541 int x2 = x+w-1; 2548 int x2 = x+w-1;
2542 int y2 = y+h-1; 2549 int y2 = y+h-1;
2543 p->drawLine(x+1, y, x2-1, y); 2550 p->drawLine(x+1, y, x2-1, y);
2544 p->drawLine(x, y+1, x, y2-1); 2551 p->drawLine(x, y+1, x, y2-1);
2545 p->drawLine(x+1, y2, x2-1, y2); 2552 p->drawLine(x+1, y2, x2-1, y2);
2546 p->drawLine(x2, y+1, x2, y2-1); 2553 p->drawLine(x2, y+1, x2, y2-1);
2547} 2554}
2548 2555
2549void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, 2556void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h,
2550 const QColorGroup &g, QCOORD, 2557 const QColorGroup &g, QCOORD,
2551 Orientation orient) 2558 Orientation orient)
2552{ 2559{
2553 bool isFocus = ((QWidget *)p->device())->hasFocus(); 2560 bool isFocus = ((QWidget *)p->device())->hasFocus();
2554 QColor c = isFocus ? g.background().dark(120) : g.background(); 2561 QColor c = isFocus ? g.background().dark(120) : g.background();
2555 if(orient == Qt::Horizontal){ 2562 if(orient == Qt::Horizontal){
2556 int x2 = x+w-1; 2563 int x2 = x+w-1;
2557 y+=2; 2564 y+=2;
2558 p->setPen(c.dark(130)); 2565 p->setPen(c.dark(130));
2559 p->drawLine(x+1, y, x2-1, y); 2566 p->drawLine(x+1, y, x2-1, y);
2560 p->setPen(c.dark(150)); 2567 p->setPen(c.dark(150));
2561 p->drawLine(x, y+1, x2, y+1); 2568 p->drawLine(x, y+1, x2, y+1);
2562 p->setPen(c.dark(125)); 2569 p->setPen(c.dark(125));
2563 p->drawLine(x, y+2, x2, y+2); 2570 p->drawLine(x, y+2, x2, y+2);
2564 p->setPen(c.dark(130)); 2571 p->setPen(c.dark(130));
2565 p->drawLine(x, y+3, x2, y+3); 2572 p->drawLine(x, y+3, x2, y+3);
2566 p->setPen(c.dark(120)); 2573 p->setPen(c.dark(120));
2567 p->drawLine(x, y+4, x2, y+4); 2574 p->drawLine(x, y+4, x2, y+4);
2568 p->setPen(c.light(110)); 2575 p->setPen(c.light(110));
2569 p->drawLine(x+1, y+5, x2-1, y+5); 2576 p->drawLine(x+1, y+5, x2-1, y+5);
2570 } 2577 }
2571 else{ 2578 else{
2572 int y2 = y+h-1; 2579 int y2 = y+h-1;
2573 x+=2; 2580 x+=2;
2574 p->setPen(c.dark(130)); 2581 p->setPen(c.dark(130));
2575 p->drawLine(x, y+1, x, y2-1); 2582 p->drawLine(x, y+1, x, y2-1);
2576 p->setPen(c.dark(150)); 2583 p->setPen(c.dark(150));
2577 p->drawLine(x+1, y, x+1, y2); 2584 p->drawLine(x+1, y, x+1, y2);
2578 p->setPen(c.dark(125)); 2585 p->setPen(c.dark(125));
2579 p->drawLine(x+2, y, x+2, y2); 2586 p->drawLine(x+2, y, x+2, y2);
2580 p->setPen(c.dark(130)); 2587 p->setPen(c.dark(130));
2581 p->drawLine(x+3, y, x+3, y2); 2588 p->drawLine(x+3, y, x+3, y2);
2582 p->setPen(c.dark(120)); 2589 p->setPen(c.dark(120));
2583 p->drawLine(x+4, y, x+4, y2); 2590 p->drawLine(x+4, y, x+4, y2);
2584 p->setPen(c.light(110)); 2591 p->setPen(c.light(110));
2585 p->drawLine(x+5, y+1, x+5, y2-1); 2592 p->drawLine(x+5, y+1, x+5, y2-1);
2586 } 2593 }
2587 //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); 2594 //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient);
2588 2595
2589} 2596}
2590 2597
2591void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, 2598void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w,
2592 int h, QCOORD, Orientation orient) 2599 int h, QCOORD, Orientation orient)
2593{ 2600{
2594 p->fillRect(x, y, w, h, Qt::color0); 2601 p->fillRect(x, y, w, h, Qt::color0);
2595 p->setPen(Qt::color1); 2602 p->setPen(Qt::color1);
2596 if(orient == Qt::Horizontal){ 2603 if(orient == Qt::Horizontal){
2597 int x2 = x+w-1; 2604 int x2 = x+w-1;
2598 y+=2; 2605 y+=2;
2599 p->drawLine(x+1, y, x2-1, y); 2606 p->drawLine(x+1, y, x2-1, y);
2600 p->fillRect(x, y+1, w, 4, Qt::color1); 2607 p->fillRect(x, y+1, w, 4, Qt::color1);
2601 p->drawLine(x+1, y+5, x2-1, y+5); 2608 p->drawLine(x+1, y+5, x2-1, y+5);
2602 } 2609 }
2603 else{ 2610 else{
2604 int y2 = y+h-1; 2611 int y2 = y+h-1;
2605 x+=2; 2612 x+=2;
2606 p->drawLine(x, y+1, x, y2-1); 2613 p->drawLine(x, y+1, x, y2-1);
2607 p->fillRect(x+1, y, 4, h, Qt::color1); 2614 p->fillRect(x+1, y, 4, h, Qt::color1);
2608 p->drawLine(x+5, y+1, x+5, y2-1); 2615 p->drawLine(x+5, y+1, x+5, y2-1);
2609 } 2616 }
2610} 2617}
2611 2618
2612 2619
2613/* vim: set noet sw=8 ts=8: */ 2620/* vim: set noet sw=8 ts=8: */
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
@@ -1,1236 +1,1242 @@
1////////////////////////////////////////////////////////////////////////////// 1//////////////////////////////////////////////////////////////////////////////
2// phasestyle.h 2// phasestyle.h
3// ------------------- 3// -------------------
4// A style for KDE 4// A style for KDE
5// ------------------- 5// -------------------
6// Copyright (c) 2004 David Johnson <david@usermode.org> 6// Copyright (c) 2004 David Johnson <david@usermode.org>
7// 7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy 8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to 9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the 10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is 12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions: 13// furnished to do so, subject to the following conditions:
14// 14//
15// The above copyright notice and this permission notice shall be included in 15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software. 16// all copies or substantial portions of the Software.
17// 17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE. 24// IN THE SOFTWARE.
25////////////////////////////////////////////////////////////////////////////// 25//////////////////////////////////////////////////////////////////////////////
26 26
27#include "phasestyle.h" 27#include "phasestyle.h"
28 28
29#include "bitmaps.h" 29#include "bitmaps.h"
30 30
31#define INCLUDE_MENUITEM_DEF 31#define INCLUDE_MENUITEM_DEF
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qtoolbutton.h> 34#include <qtoolbutton.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qbrush.h> 36#include <qbrush.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qtabbar.h> 38#include <qtabbar.h>
39#include <qscrollbar.h> 39#include <qscrollbar.h>
40 40
41 41
42/* Spacing and sizeHint */ 42/* Spacing and sizeHint */
43static unsigned contrast = 110; 43static unsigned contrast = 110;
44 44
45static const int ITEMFRAME = 1; // menu stuff 45static const int ITEMFRAME = 1; // menu stuff
46static const int ITEMHMARGIN = 3; 46static const int ITEMHMARGIN = 3;
47static const int ITEMVMARGIN = 0; 47static const int ITEMVMARGIN = 0;
48 48
49static const int ARROWMARGIN = 6; 49static const int ARROWMARGIN = 6;
50static const int RIGHTBORDER = 10; 50static const int RIGHTBORDER = 10;
51static const int MINICONSIZE = 12; 51static const int MINICONSIZE = 12;
52static const int CHECKSIZE = 9; 52static const int CHECKSIZE = 9;
53static const int SCROLLBAR_EXTENT = 12; 53static const int SCROLLBAR_EXTENT = 12;
54 54
55 55
56/* 56/*
57 * Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> 57 * Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
58 * LGPLv2 from kdelibs/kdefx/kdrawutil.cpp 58 * LGPLv2 from kdelibs/kdefx/kdrawutil.cpp
59 */ 59 */
60void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y, 60void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y,
61 QBitmap *lightColor, QBitmap *midColor, 61 QBitmap *lightColor, QBitmap *midColor,
62 QBitmap *midlightColor, QBitmap *darkColor, 62 QBitmap *midlightColor, QBitmap *darkColor,
63 QBitmap *blackColor, QBitmap *whiteColor) 63 QBitmap *blackColor, QBitmap *whiteColor)
64{ 64{
65 QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor, 65 QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
66 blackColor, whiteColor}; 66 blackColor, whiteColor};
67 67
68 QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(), 68 QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
69 Qt::black, Qt::white}; 69 Qt::black, Qt::white};
70 70
71 int i; 71 int i;
72 for(i=0; i < 6; ++i){ 72 for(i=0; i < 6; ++i){
73 if(bitmaps[i]){ 73 if(bitmaps[i]){
74 if(!bitmaps[i]->mask()) 74 if(!bitmaps[i]->mask())
75 bitmaps[i]->setMask(*bitmaps[i]); 75 bitmaps[i]->setMask(*bitmaps[i]);
76 p->setPen(colors[i]); 76 p->setPen(colors[i]);
77 p->drawPixmap(x, y, *bitmaps[i]); 77 p->drawPixmap(x, y, *bitmaps[i]);
78 } 78 }
79 } 79 }
80} 80}
81 81
82 82
83/* 83/*
84 * drawMenuBarItem is not virtual 84 * drawMenuBarItem is not virtual
85 * this way we define our draw handler 85 * this way we define our draw handler
86 */ 86 */
87typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 87typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
88 QColorGroup &, bool, bool); 88 QColorGroup &, bool, bool);
89 89
90extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 90extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
91 91
92 92
93PhaseStyle::PhaseStyle() 93PhaseStyle::PhaseStyle()
94 : QWindowsStyle() 94 : QWindowsStyle()
95{ 95{
96 setName( "PhaseStyle" ); 96 setName( "PhaseStyle" );
97 97
98 /* small default sizes */ 98 /* small default sizes */
99 setButtonDefaultIndicatorWidth(1); 99 setButtonDefaultIndicatorWidth(1);
100 setScrollBarExtent(SCROLLBAR_EXTENT, SCROLLBAR_EXTENT); 100 setScrollBarExtent(SCROLLBAR_EXTENT, SCROLLBAR_EXTENT);
101 setSliderThickness(12); 101 setSliderThickness(12);
102 setButtonMargin( 1 ); 102 setButtonMargin( 1 );
103 103
104 // create bitmaps 104 // create bitmaps
105 uarrow = QBitmap(6, 6, uarrow_bits, true); 105 uarrow = QBitmap(6, 6, uarrow_bits, true);
106 uarrow.setMask(uarrow); 106 uarrow.setMask(uarrow);
107 darrow = QBitmap(6, 6, darrow_bits, true); 107 darrow = QBitmap(6, 6, darrow_bits, true);
108 darrow.setMask(darrow); 108 darrow.setMask(darrow);
109 larrow = QBitmap(6, 6, larrow_bits, true); 109 larrow = QBitmap(6, 6, larrow_bits, true);
110 larrow.setMask(larrow); 110 larrow.setMask(larrow);
111 rarrow = QBitmap(6, 6, rarrow_bits, true); 111 rarrow = QBitmap(6, 6, rarrow_bits, true);
112 rarrow.setMask(rarrow); 112 rarrow.setMask(rarrow);
113 bplus = QBitmap(6, 6, bplus_bits, true); 113 bplus = QBitmap(6, 6, bplus_bits, true);
114 bplus.setMask(bplus); 114 bplus.setMask(bplus);
115 bminus = QBitmap(6, 6, bminus_bits, true); 115 bminus = QBitmap(6, 6, bminus_bits, true);
116 bminus.setMask(bminus); 116 bminus.setMask(bminus);
117 bcheck = QBitmap(9, 9, bcheck_bits, true); 117 bcheck = QBitmap(9, 9, bcheck_bits, true);
118 bcheck.setMask(bcheck); 118 bcheck.setMask(bcheck);
119 dexpand = QBitmap(9, 9, dexpand_bits, true); 119 dexpand = QBitmap(9, 9, dexpand_bits, true);
120 dexpand.setMask(dexpand); 120 dexpand.setMask(dexpand);
121 rexpand = QBitmap(9, 9, rexpand_bits, true); 121 rexpand = QBitmap(9, 9, rexpand_bits, true);
122 rexpand.setMask(rexpand); 122 rexpand.setMask(rexpand);
123 doodad_mid = QBitmap(4, 4, doodad_mid_bits, true); 123 doodad_mid = QBitmap(4, 4, doodad_mid_bits, true);
124 doodad_light = QBitmap(4, 4, doodad_light_bits, true); 124 doodad_light = QBitmap(4, 4, doodad_light_bits, true);
125} 125}
126 126
127PhaseStyle::~PhaseStyle() { 127PhaseStyle::~PhaseStyle() {
128 /* deleted by Qt */ 128 /* deleted by Qt */
129} 129}
130 130
131void PhaseStyle::drawCheckMark ( QPainter * p, int x, int y, int w, 131void PhaseStyle::drawCheckMark ( QPainter * p, int x, int y, int w,
132 int h, const QColorGroup & g, 132 int h, const QColorGroup & g,
133 bool , bool) { 133 bool , bool) {
134 p->setPen(g.text()); 134 p->setPen(g.text());
135 p->drawPixmap(x+w/2-4, y+h/2-4, bcheck); 135 p->drawPixmap(x+w/2-4, y+h/2-4, bcheck);
136} 136}
137 137
138void PhaseStyle::drawArrow(QPainter *painter, Qt::ArrowType type, bool down, 138void PhaseStyle::drawArrow(QPainter *painter, Qt::ArrowType type, bool down,
139 int x, int y, int w, int h, const QColorGroup &group, 139 int x, int y, int w, int h, const QColorGroup &group,
140 bool enabled , const QBrush * ) { 140 bool enabled , const QBrush * ) {
141 switch( type ) { 141 switch( type ) {
142 case UpArrow: 142 case UpArrow:
143 if (enabled) 143 if (enabled)
144 painter->setPen(down ? group.midlight() : group.dark()); 144 painter->setPen(down ? group.midlight() : group.dark());
145 else painter->setPen(group.mid()); 145 else painter->setPen(group.mid());
146 painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow); 146 painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow);
147 break; 147 break;
148 case DownArrow: 148 case DownArrow:
149 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 149 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
150 else painter->setPen(group.mid()); 150 else painter->setPen(group.mid());
151 painter->drawPixmap(x+w/2-3, y+h/2-3, darrow); 151 painter->drawPixmap(x+w/2-3, y+h/2-3, darrow);
152 break; 152 break;
153 case LeftArrow: 153 case LeftArrow:
154 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 154 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
155 else painter->setPen(group.mid()); 155 else painter->setPen(group.mid());
156 painter->drawPixmap(x+w/2-3, y+h/2-3, larrow); 156 painter->drawPixmap(x+w/2-3, y+h/2-3, larrow);
157 break; 157 break;
158 case RightArrow: 158 case RightArrow:
159 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 159 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
160 else painter->setPen(group.mid()); 160 else painter->setPen(group.mid());
161 painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow); 161 painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow);
162 break; 162 break;
163 } 163 }
164} 164}
165 165
166void PhaseStyle::drawPushButton(QPushButton *btn, QPainter *painter) { 166void PhaseStyle::drawPushButton(QPushButton *btn, QPainter *painter) {
167 QRect r = btn->rect(); 167 QRect r = btn->rect();
168 int x = r.x(); 168 int x = r.x();
169 int y = r.y(); 169 int y = r.y();
170 int h = r.height(); 170 int h = r.height();
171 int w = r.width(); 171 int w = r.width();
172 bool depress = btn->isOn() || btn->isDown(); 172 bool depress = btn->isOn() || btn->isDown();
173 QColorGroup group = btn->colorGroup(); 173 QColorGroup group = btn->colorGroup();
174 QBrush brush(group.button() ); 174 QBrush brush(group.button() );
175// int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1; 175// int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1;
176 static int bd = 2; 176 static int bd = 2;
177 177
178 if (btn->isDefault() && !depress) { 178 if (btn->isDefault() && !depress) {
179 drawPanel(painter, x, y, w, h, group, 179 drawPanel(painter, x, y, w, h, group,
180 &group.brush(QColorGroup::Mid), true); 180 &group.brush(QColorGroup::Mid), true);
181 drawBevelButton(painter, x+bd, y+bd, w-bd*2, h-bd*2, group, 181 drawBevelButton(painter, x+bd, y+bd, w-bd*2, h-bd*2, group,
182 false, &brush ); 182 false, &brush );
183 } else { 183 } else {
184 drawButton(painter, x, y, w, h, group, depress, 184 drawButton(painter, x, y, w, h, group, depress,
185 &brush ); 185 &brush );
186 } 186 }
187 187
188 if (btn->hasFocus() ) { // draw focus 188 if (btn->hasFocus() ) { // draw focus
189 QColor col; 189 QColor col;
190 drawFocusRect(painter, r, group, 190 drawFocusRect(painter, r, group,
191 &col, false ); 191 &col, false );
192 } 192 }
193} 193}
194 194
195 195
196void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h, 196void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h,
197 const QColorGroup& group, bool sunken, 197 const QColorGroup& group, bool sunken,
198 int , const QBrush* fill) { 198 int , const QBrush* fill) {
199 int x2 = x + w - 1; 199 int x2 = x + w - 1;
200 int y2 = y + h - 1; 200 int y2 = y + h - 1;
201 painter->save(); 201 painter->save();
202 202
203 if (sunken) { 203 if (sunken) {
204 painter->setPen(group.dark()); 204 painter->setPen(group.dark());
205 painter->drawRect(x+1, y+1, w-2, h-2); 205 painter->drawRect(x+1, y+1, w-2, h-2);
206 painter->setPen(group.midlight()); 206 painter->setPen(group.midlight());
207 painter->drawLine(x+1, y2, x2, y2); 207 painter->drawLine(x+1, y2, x2, y2);
208 painter->drawLine(x2, y+1, x2, y2-1); 208 painter->drawLine(x2, y+1, x2, y2-1);
209 painter->setPen(group.mid()); 209 painter->setPen(group.mid());
210 painter->drawLine(x, y, x, y2-1); 210 painter->drawLine(x, y, x, y2-1);
211 painter->drawLine(x+1, y, x2-1, y); 211 painter->drawLine(x+1, y, x2-1, y);
212 painter->setPen(group.background()); 212 painter->setPen(group.background());
213 painter->drawPoint(x, y2); 213 painter->drawPoint(x, y2);
214 painter->drawPoint(x2, y); 214 painter->drawPoint(x2, y);
215 } else { 215 } else {
216 painter->setPen(group.dark()); 216 painter->setPen(group.dark());
217 painter->drawRect(x, y, w, h); 217 painter->drawRect(x, y, w, h);
218 painter->setPen(group.midlight()); 218 painter->setPen(group.midlight());
219 painter->drawLine(x+1, y+1, x2-2, y+1); 219 painter->drawLine(x+1, y+1, x2-2, y+1);
220 painter->drawLine(x+1, y+2, x+1, y2-2); 220 painter->drawLine(x+1, y+2, x+1, y2-2);
221 painter->setPen(group.mid()); 221 painter->setPen(group.mid());
222 painter->drawLine(x+2, y2-1, x2-1, y2-1); 222 painter->drawLine(x+2, y2-1, x2-1, y2-1);
223 painter->drawLine(x2-1, y+2, x2-1, y2-2); 223 painter->drawLine(x2-1, y+2, x2-1, y2-2);
224 painter->setPen(group.background()); 224 painter->setPen(group.background());
225 painter->drawPoint(x+1, y2-1); 225 painter->drawPoint(x+1, y2-1);
226 painter->drawPoint(x2-1, y+1); 226 painter->drawPoint(x2-1, y+1);
227 } 227 }
228 228
229 if (fill) { 229 if (fill) {
230 painter->fillRect(x+2, y+2, w-4, h-4, *fill ); 230 painter->fillRect(x+2, y+2, w-4, h-4, *fill );
231 } 231 }
232 painter->restore(); 232 painter->restore();
233} 233}
234 234
235 235
236 236
237void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h, 237void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h,
238 const QColorGroup &group, bool sunken , 238 const QColorGroup &group, bool sunken ,
239 const QBrush *fill ) { 239 const QBrush *fill ) {
240 int x2 = x + w - 1; 240 int x2 = x + w - 1;
241 int y2 = y + h - 1; 241 int y2 = y + h - 1;
242 242
243 p->setPen(group.midlight()); 243 p->setPen(group.midlight());
244 p->drawLine(x+1, y2, x2, y2); 244 p->drawLine(x+1, y2, x2, y2);
245 p->drawLine(x2, y+1, x2, y2-1); 245 p->drawLine(x2, y+1, x2, y2-1);
246 246
247 p->setPen(group.mid()); 247 p->setPen(group.mid());
248 p->drawLine(x, y, x2-1, y); 248 p->drawLine(x, y, x2-1, y);
249 p->drawLine(x, y+1, x, y2-1); 249 p->drawLine(x, y+1, x, y2-1);
250 250
251 p->setPen(group.button()); 251 p->setPen(group.button());
252 p->drawPoint(x, y2); 252 p->drawPoint(x, y2);
253 p->drawPoint(x2, y); 253 p->drawPoint(x2, y);
254 254
255 drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken, 255 drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken,
256 fill); 256 fill);
257} 257}
258 258
259void PhaseStyle::drawButtonMask( QPainter* p, int x, int y, 259void PhaseStyle::drawButtonMask( QPainter* p, int x, int y,
260 int w, int h ) { 260 int w, int h ) {
261 QRect rect(x, y, w, h ); 261 QRect rect(x, y, w, h );
262 p->fillRect(rect, Qt::color1); 262 p->fillRect(rect, Qt::color1);
263 p->setPen(Qt::color0); 263 p->setPen(Qt::color0);
264} 264}
265 265
266 266
267void PhaseStyle::drawBevelButton(QPainter* p, int x, int y, 267void PhaseStyle::drawBevelButton(QPainter* p, int x, int y,
268 int w, int h, const QColorGroup& group, 268 int w, int h, const QColorGroup& group,
269 bool sunken, const QBrush* fill ) { 269 bool sunken, const QBrush* fill ) {
270 int x2 = x + w - 1; 270 int x2 = x + w - 1;
271 int y2 = y + h - 1; 271 int y2 = y + h - 1;
272 p->save(); 272 p->save();
273 273
274 p->setPen(group.dark()); 274 p->setPen(group.dark());
275 p->drawRect(x, y, w, h); 275 p->drawRect(x, y, w, h);
276 276
277 p->setPen(sunken ? group.mid() : group.midlight()); 277 p->setPen(sunken ? group.mid() : group.midlight());
278 p->drawLine(x+1, y+1, x2-2, y+1); 278 p->drawLine(x+1, y+1, x2-2, y+1);
279 p->drawLine(x+1, y+2, x+1, y2-2); 279 p->drawLine(x+1, y+2, x+1, y2-2);
280 280
281 p->setPen(sunken ? group.midlight() : group.mid()); 281 p->setPen(sunken ? group.midlight() : group.mid());
282 p->drawLine(x+2, y2-1, x2-1, y2-1); 282 p->drawLine(x+2, y2-1, x2-1, y2-1);
283 p->drawLine(x2-1, y+2, x2-1, y2-2); 283 p->drawLine(x2-1, y+2, x2-1, y2-2);
284 284
285 p->setPen(group.button()); 285 p->setPen(group.button());
286 p->drawPoint(x+1, y2-1); 286 p->drawPoint(x+1, y2-1);
287 p->drawPoint(x2-1, y+1); 287 p->drawPoint(x2-1, y+1);
288 288
289 QBrush b = fill ? *fill : group.brush( QColorGroup::Button ); 289 QBrush b = fill ? *fill : group.brush( QColorGroup::Button );
290 if (sunken) { 290 if (sunken) {
291 // sunken bevels don't get gradients 291 // sunken bevels don't get gradients
292 p->fillRect(x+2, y+2, w-4, h-4, b); 292 p->fillRect(x+2, y+2, w-4, h-4, b);
293 } else 293 } else
294 drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() ); 294 drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() );
295 295
296 p->restore(); 296 p->restore();
297} 297}
298 298
299void PhaseStyle::drawPhaseGradient(QPainter* painter, 299void PhaseStyle::drawPhaseGradient(QPainter* painter,
300 const QRect& rect, 300 const QRect& rect,
301 const QColor& color )const { 301 const QColor& color )const {
302 painter->fillRect(rect, color); 302 painter->fillRect(rect, color);
303} 303}
304 304
305void PhaseStyle::polish( QWidget* widget ) { 305void PhaseStyle::polish( QWidget* widget ) {
306 QWindowsStyle::polish(widget ); 306 QWindowsStyle::polish(widget );
307 307
308#if 0 308#if 0
309 if (widget->inherits("QMenuBar") || 309 if (widget->inherits("QMenuBar") ||
310 widget->inherits("QPopupMenu" ) || 310 widget->inherits("QPopupMenu" ) ||
311 widget->inherits("QToolButton") || 311 widget->inherits("QToolButton") ||
312 widget->inherits("QHeader" ) ) { 312 widget->inherits("QHeader" ) ) {
313 widget->setBackgroundMode(QWidget::NoBackground); 313 widget->setBackgroundMode(QWidget::NoBackground);
314 } 314 }
315// else if (widget->inherits("QFrame") ) { 315// else if (widget->inherits("QFrame") ) {
316// widget->installEventFilter(this); 316// widget->installEventFilter(this);
317// } 317// }
318#endif 318#endif
319} 319}
320 320
321void PhaseStyle::unPolish( QWidget *w ) 321void PhaseStyle::unPolish( QWidget *w )
322{ 322{
323 QWindowsStyle::unPolish( w ); 323 QWindowsStyle::unPolish( w );
324} 324}
325 325
326void PhaseStyle::polish( QPalette &pal ) { 326void PhaseStyle::polish( QPalette &pal ) {
327 QWindowsStyle::polish( pal ); 327 QWindowsStyle::polish( pal );
328 // lighten up a bit, so the look is not so "crisp" 328 // lighten up a bit, so the look is not so "crisp"
329 if (QPixmap::defaultDepth() > 8) { // but not on low color displays 329 if (QPixmap::defaultDepth() > 8) { // but not on low color displays
330 pal.setColor(QPalette::Disabled, QColorGroup::Dark, 330 pal.setColor(QPalette::Disabled, QColorGroup::Dark,
331 pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast)); 331 pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast));
332 pal.setColor(QPalette::Active, QColorGroup::Dark, 332 pal.setColor(QPalette::Active, QColorGroup::Dark,
333 pal.color(QPalette::Active, QColorGroup::Dark).light(contrast)); 333 pal.color(QPalette::Active, QColorGroup::Dark).light(contrast));
334 pal.setColor(QPalette::Inactive, QColorGroup::Dark, 334 pal.setColor(QPalette::Inactive, QColorGroup::Dark,
335 pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast)); 335 pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast));
336 } 336 }
337} 337}
338 338
339void PhaseStyle::polish( QApplication* app ) { 339void PhaseStyle::polish( QApplication* app ) {
340 QWindowsStyle::polish( app ); 340 QWindowsStyle::polish( app );
341 341
342 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem); 342 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem);
343} 343}
344 344
345void PhaseStyle::unPolish( QApplication* app ) { 345void PhaseStyle::unPolish( QApplication* app ) {
346 QWindowsStyle::unPolish(app); 346 QWindowsStyle::unPolish(app);
347 qt_set_draw_menu_bar_impl ( 0 ); 347 qt_set_draw_menu_bar_impl ( 0 );
348} 348}
349 349
350void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) { 350void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
351 bool active = button->isOn() || button->isDown(); 351 bool active = button->isOn() || button->isDown();
352 QRect r = pushButtonContentsRect( button ); 352 QRect r = pushButtonContentsRect( button );
353 QColorGroup group = button->colorGroup(); 353 QColorGroup group = button->colorGroup();
354 int x, y, w, h; 354 int x, y, w, h;
355 r.rect( &x, &y, &w, &h ); 355 r.rect( &x, &y, &w, &h );
356 bool sunken = false; 356 bool sunken = false;
357 QIconSet::Mode mode; 357 QIconSet::Mode mode;
358 QPixmap pixmap; 358 QPixmap pixmap;
359 359
360 if (active) {// shift contents 360 if (active) {// shift contents
361 x++; y++; 361 x++; y++;
362 sunken = true; 362 sunken = true;
363 } 363 }
364 364
365 365
366 if (button->isMenuButton()) { // draw the indicator 366 if (button->isMenuButton()) { // draw the indicator
367 //dx = pixelMetric(PM_MenuButtonIndicator, widget); 367 //dx = pixelMetric(PM_MenuButtonIndicator, widget);
368 int dx = menuButtonIndicatorWidth( button->height() ); 368 int dx = menuButtonIndicatorWidth( button->height() );
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,
418 AlignCenter | ShowPrefix, 421 AlignCenter | ShowPrefix,
419 button->colorGroup(), 422 button->colorGroup(),
420 button->isEnabled(), 423 button->isEnabled(),
421 button->pixmap(), 424 button->pixmap(),
422 button->text(), -1, 425 button->text(), -1,
423 (button->isEnabled()) ? 426 (button->isEnabled()) ?
424 &button->colorGroup().buttonText() : 427 &button->colorGroup().buttonText() :
425 &button->colorGroup().mid()); 428 &button->colorGroup().mid());
426 } 429 }
427} 430}
428 431
429 432
430void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect, 433void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect,
431 const QColorGroup &group, 434 const QColorGroup &group,
432 const QColor *, bool atBorder) { 435 const QColor *, bool atBorder) {
433 436
434 437
435 QPen old = painter->pen(); 438 QPen old = painter->pen();
436 painter->setPen(group.highlight().dark(contrast)); 439 painter->setPen(group.highlight().dark(contrast));
437 painter->setBrush(NoBrush); 440 painter->setBrush(NoBrush);
438 441
439 if ( atBorder ) 442 if ( atBorder )
440 painter->drawRect(QRect(rect.x()+1, rect.y()+1, 443 painter->drawRect(QRect(rect.x()+1, rect.y()+1,
441 rect.width()-2, rect.height()-2 )); 444 rect.width()-2, rect.height()-2 ));
442 else 445 else
443 painter->drawRect(rect); 446 painter->drawRect(rect);
444 447
445 448
446 painter->setPen(old); 449 painter->setPen(old);
447 450
448} 451}
449 452
450void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w, 453void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w,
451 int h, const QColorGroup& group, bool, 454 int h, const QColorGroup& group, bool,
452 int , int ) { 455 int , int ) {
453 qWarning( "Seperator" ); 456 qWarning( "Seperator" );
454 QRect rect(x, y, w, h); 457 QRect rect(x, y, w, h);
455 int x2 = rect.right(); 458 int x2 = rect.right();
456 int y2 = rect.bottom(); 459 int y2 = rect.bottom();
457 460
458 painter->setPen(group.dark()); 461 painter->setPen(group.dark());
459 if (w < h) 462 if (w < h)
460 painter->drawLine(w/2, y, w/2, y2); 463 painter->drawLine(w/2, y, w/2, y2);
461 else 464 else
462 painter->drawLine(x, h/2, x2, h/2); 465 painter->drawLine(x, h/2, x2, h/2);
463} 466}
464 467
465void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h, 468void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h,
466 QMenuItem *mi, QColorGroup& g, bool enabled, 469 QMenuItem *mi, QColorGroup& g, bool enabled,
467 bool act ) { 470 bool act ) {
468 return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act); 471 return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act);
469} 472}
470 473
471 474
472void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h, 475void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h,
473 const QColorGroup &group, int state, bool, 476 const QColorGroup &group, int state, bool,
474 bool enabled ) { 477 bool enabled ) {
475 drawPanel(painter, x, y, w, h, group, true, 1, enabled ? 478 drawPanel(painter, x, y, w, h, group, true, 1, enabled ?
476 &group.brush(QColorGroup::Base) : 479 &group.brush(QColorGroup::Base) :
477 &group.brush(QColorGroup::Background)); 480 &group.brush(QColorGroup::Background));
478 481
479 if (QButton::On == state ) { 482 if (QButton::On == state ) {
480 painter->setPen(group.dark()); 483 painter->setPen(group.dark());
481 painter->drawRect(x+3, y+3, w-6, h-6); 484 painter->drawRect(x+3, y+3, w-6, h-6);
482 painter->fillRect(x+4, y+4, w-8, h-8, 485 painter->fillRect(x+4, y+4, w-8, h-8,
483 group.brush(QColorGroup::Highlight)); 486 group.brush(QColorGroup::Highlight));
484 } 487 }
485} 488}
486 489
487 490
488void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h, 491void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h,
489 const QColorGroup &group, bool on, 492 const QColorGroup &group, bool on,
490 bool /*down*/, bool enabled) { 493 bool /*down*/, bool enabled) {
491 494
492 QRect r(x, y, w, h ); 495 QRect r(x, y, w, h );
493 496
494 497
495 /* 498 /*
496 * As Polygon and Polyline are broken in Qt2 lets use 499 * As Polygon and Polyline are broken in Qt2 lets use
497 * something not that spectacilur -> ellipse 500 * something not that spectacilur -> ellipse
498 */ 501 */
499 painter->save(); 502 painter->save();
500 painter->fillRect(x, y, w, h, group.background()); 503 painter->fillRect(x, y, w, h, group.background());
501 504
502 505
503 painter->setBrush(enabled 506 painter->setBrush(enabled
504 ? group.brush(QColorGroup::Base) 507 ? group.brush(QColorGroup::Base)
505 : group.brush(QColorGroup::Background)); 508 : group.brush(QColorGroup::Background));
506 painter->setPen(group.dark()); 509 painter->setPen(group.dark());
507 510
508 if (0 == w % 2) --w; 511 if (0 == w % 2) --w;
509 if (0 == h % 2) --h; 512 if (0 == h % 2) --h;
510 painter->drawEllipse(x, y, w, h ); 513 painter->drawEllipse(x, y, w, h );
511 514
512 if(on) { 515 if(on) {
513 painter->setBrush(group.brush(QColorGroup::Highlight)); 516 painter->setBrush(group.brush(QColorGroup::Highlight));
514 painter->drawEllipse(x+3,y+3,w-6,h-6); 517 painter->drawEllipse(x+3,y+3,w-6,h-6);
515 } 518 }
516 519
517 painter->restore(); 520 painter->restore();
518} 521}
519 522
520 523
521/* 524/*
522 * Does not get called in QWS as it seems 525 * Does not get called in QWS as it seems
523 */ 526 */
524void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w, 527void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w,
525 int h, bool /*on*/ ) { 528 int h, bool /*on*/ ) {
526 return; 529 return;
527 530
528 531
529 532
530 if (0 != w%2) --w; 533 if (0 != w%2) --w;
531 if (0 != h%2) --h; 534 if (0 != h%2) --h;
532 535
533 QRect r(x, y, w, h ); 536 QRect r(x, y, w, h );
534 int x2 = r.right(); 537 int x2 = r.right();
535 int y2 = r.bottom(); 538 int y2 = r.bottom();
536 int cx = (x + x2) / 2; 539 int cx = (x + x2) / 2;
537 int cy = (y + y2) / 2; 540 int cy = (y + y2) / 2;
538 QPointArray parray; 541 QPointArray parray;
539 542
540 543
541 painter->setBrush(Qt::color1); 544 painter->setBrush(Qt::color1);
542 painter->setPen(Qt::color1); 545 painter->setPen(Qt::color1);
543 parray.putPoints(0, 8, 546 parray.putPoints(0, 8,
544 x,cy+1, x,cy, cx,y, cx+1,y, 547 x,cy+1, x,cy, cx,y, cx+1,y,
545 x2,cy, x2,cy+1, cx+1,y2, cx,y2); 548 x2,cy, x2,cy+1, cx+1,y2, cx,y2);
546 painter->drawPolygon(parray, 0, 8); 549 painter->drawPolygon(parray, 0, 8);
547} 550}
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;
598 600
599 601
600 if ( maxpmw > 0 || checkable ) 602 if ( maxpmw > 0 || checkable )
601 w += ITEMHMARGIN*2+8; 603 w += ITEMHMARGIN*2+8;
602 604
603 w += RIGHTBORDER; 605 w += RIGHTBORDER;
604 return w; 606 return w;
605} 607}
606 608
607QSize PhaseStyle::indicatorSize()const { 609QSize PhaseStyle::indicatorSize()const {
608 return QSize( 11, 11 ); 610 return QSize( 11, 11 );
609} 611}
610 612
611QSize PhaseStyle::exclusiveIndicatorSize()const { 613QSize PhaseStyle::exclusiveIndicatorSize()const {
612 return QSize( 11, 11 ); 614 return QSize( 11, 11 );
613} 615}
614 616
615void PhaseStyle::getButtonShift( int &x, int &y ) { 617void PhaseStyle::getButtonShift( int &x, int &y ) {
616 x++; 618 x++;
617 y++; 619 y++;
618} 620}
619 621
620void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable, 622void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
621 int maxpmw,int tabwidth, 623 int maxpmw,int tabwidth,
622 QMenuItem * mi, const QPalette & pal, 624 QMenuItem * mi, const QPalette & pal,
623 bool act, bool enabled, int x, 625 bool act, bool enabled, int x,
624 int y, int w, int h ) { 626 int y, int w, int h ) {
625 if ( !mi ) 627 if ( !mi )
626 return; 628 return;
627 629
628 QRect rect(x, y, w, h ); 630 QRect rect(x, y, w, h );
629 int x2, y2; 631 int x2, y2;
630 x2 = rect.right(); 632 x2 = rect.right();
631 y2 = rect.bottom(); 633 y2 = rect.bottom();
632 const QColorGroup& g = pal.active(); 634 const QColorGroup& g = pal.active();
633 QColorGroup itemg = !enabled ? pal.disabled() : pal.active(); 635 QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
634 636
635 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20); 637 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
636 638
637 if (act && enabled ) 639 if (act && enabled )
638 p->fillRect(x, y, w, h, g.highlight() ); 640 p->fillRect(x, y, w, h, g.highlight() );
639 else 641 else
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,
689 xp, y+1, tw, h-2 ); 695 xp, y+1, tw, h-2 );
690 p->restore(); 696 p->restore();
691 }else { // draw label 697 }else { // draw label
692 QString text = mi->text(); 698 QString text = mi->text();
693 if (!text.isNull() ) { 699 if (!text.isNull() ) {
694 int t = text.find('\t'); 700 int t = text.find('\t');
695 const int tflags = AlignVCenter | DontClip | 701 const int tflags = AlignVCenter | DontClip |
696 ShowPrefix | SingleLine | 702 ShowPrefix | SingleLine |
697 AlignLeft; 703 AlignLeft;
698 704
699 if (t >= 0) { 705 if (t >= 0) {
700 int tabx = x + w - tabwidth - RIGHTBORDER - 706 int tabx = x + w - tabwidth - RIGHTBORDER -
701 ITEMHMARGIN - ITEMFRAME; 707 ITEMHMARGIN - ITEMFRAME;
702 p->drawText(tabx, y+ITEMVMARGIN, tabwidth, 708 p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
703 h-2*ITEMVMARGIN, tflags, 709 h-2*ITEMVMARGIN, tflags,
704 text.mid(t+1) ); 710 text.mid(t+1) );
705 text = text.left(t ); 711 text = text.left(t );
706 } 712 }
707 713
708 // draw left label 714 // draw left label
709 p->drawText(xp, y+ITEMVMARGIN, 715 p->drawText(xp, y+ITEMVMARGIN,
710 tw, h-2*ITEMVMARGIN, 716 tw, h-2*ITEMVMARGIN,
711 tflags, text, t); 717 tflags, text, t);
712 }else if ( mi->pixmap() ) { // pixmap as label 718 }else if ( mi->pixmap() ) { // pixmap as label
713 QPixmap pixmap = *mi->pixmap(); 719 QPixmap pixmap = *mi->pixmap();
714 if ( pixmap.depth() == 1 ) 720 if ( pixmap.depth() == 1 )
715 p->setBackgroundMode( OpaqueMode ); 721 p->setBackgroundMode( OpaqueMode );
716 722
717 int dx = ((w-pixmap.width() ) /2 ) + 723 int dx = ((w-pixmap.width() ) /2 ) +
718 ((w - pixmap.width()) %2 ); 724 ((w - pixmap.width()) %2 );
719 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap ); 725 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
720 726
721 if ( pixmap.depth() == 1 ) 727 if ( pixmap.depth() == 1 )
722 p->setBackgroundMode( TransparentMode ); 728 p->setBackgroundMode( TransparentMode );
723 } 729 }
724 } 730 }
725 731
726 if ( mi->popup() ) { // draw submenu arrow 732 if ( mi->popup() ) { // draw submenu arrow
727 int dim = (h-2*ITEMFRAME) / 2; 733 int dim = (h-2*ITEMFRAME) / 2;
728 drawArrow( p, RightArrow, false, 734 drawArrow( p, RightArrow, false,
729 x+w-ARROWMARGIN-ITEMFRAME-dim, 735 x+w-ARROWMARGIN-ITEMFRAME-dim,
730 y+h/2-dim/2, dim, dim, g, enabled ); 736 y+h/2-dim/2, dim, dim, g, enabled );
731 } 737 }
732} 738}
733 739
734 740
735QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) { 741QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) {
736 return QRect(x+2, y+2, w-4-17, h-5 ); 742 return QRect(x+2, y+2, w-4-17, h-5 );
737} 743}
738 744
739void PhaseStyle::drawComboButton( QPainter * p, int x, int y, 745void PhaseStyle::drawComboButton( QPainter * p, int x, int y,
740 int w, int h, 746 int w, int h,
741 const QColorGroup & g, 747 const QColorGroup & g,
742 bool sunken, 748 bool sunken,
743 bool editable, 749 bool editable,
744 bool, 750 bool,
745 const QBrush *) { 751 const QBrush *) {
746 drawButton(p, x, y, w, h, g, 752 drawButton(p, x, y, w, h, g,
747 sunken, &g.brush(QColorGroup::Button )); 753 sunken, &g.brush(QColorGroup::Button ));
748 754
749 for ( int n = 0; n < 2; ++n ) 755 for ( int n = 0; n < 2; ++n )
750 kColorBitmaps(p, g, w-16+(6*n), y+(h/2)-2, 756 kColorBitmaps(p, g, w-16+(6*n), y+(h/2)-2,
751 0, &doodad_mid, &doodad_light, 0, 0, 0 ); 757 0, &doodad_mid, &doodad_light, 0, 0, 0 );
752 758
753 759
754 if (editable ) { 760 if (editable ) {
755 const int x2 = x+w-1; const int y2 = y+h-1; 761 const int x2 = x+w-1; const int y2 = y+h-1;
756 p->setPen(g.dark()); 762 p->setPen(g.dark());
757 p->drawLine(x2+1, y, x2+1, y2); 763 p->drawLine(x2+1, y, x2+1, y2);
758 p->setPen(g.midlight()); 764 p->setPen(g.midlight());
759 p->drawLine(x2+2, y, x2+2, y2-1); 765 p->drawLine(x2+2, y, x2+2, y2-1);
760 p->setPen(g.button()); 766 p->setPen(g.button());
761 p->drawPoint(x2+2, y2); 767 p->drawPoint(x2+2, y2);
762 } 768 }
763 769
764 p->setPen(g.buttonText() ); 770 p->setPen(g.buttonText() );
765} 771}
766 772
767void PhaseStyle::tabbarMetrics( const QTabBar* t, int &hframe, int &vframe, int& ov ) { 773void PhaseStyle::tabbarMetrics( const QTabBar* t, int &hframe, int &vframe, int& ov ) {
768 QCommonStyle::tabbarMetrics( t, hframe, vframe, ov ); 774 QCommonStyle::tabbarMetrics( t, hframe, vframe, ov );
769 hframe -= 2; 775 hframe -= 2;
770 vframe += 1; 776 vframe += 1;
771} 777}
772 778
773 779
774void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab, 780void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab,
775 bool selected ) { 781 bool selected ) {
776 bool edge = false; 782 bool edge = false;
777 int x, y, w, h; 783 int x, y, w, h;
778 QRect r = tab->rect(); 784 QRect r = tab->rect();
779 r.rect(&x,&y,&w,&h); 785 r.rect(&x,&y,&w,&h);
780 const int x2 = x+w-1; 786 const int x2 = x+w-1;
781 const int y2 = y+h-1; 787 const int y2 = y+h-1;
782 const QColorGroup &group = bar->colorGroup(); 788 const QColorGroup &group = bar->colorGroup();
783 789
784 790
785 painter->save(); 791 painter->save();
786 792
787 // what position is the tab? 793 // what position is the tab?
788 if ((bar->count() == 1 )) 794 if ((bar->count() == 1 ))
789 edge = true; 795 edge = true;
790 else 796 else
791 edge = false; 797 edge = false;
792 798
793 switch (QTabBar::Shape(bar->shape())) { 799 switch (QTabBar::Shape(bar->shape())) {
794 case QTabBar::RoundedAbove: 800 case QTabBar::RoundedAbove:
795 case QTabBar::TriangularAbove: { 801 case QTabBar::TriangularAbove: {
796 if (!selected) { // shorten 802 if (!selected) { // shorten
797 y += 2; h -= 2; 803 y += 2; h -= 2;
798 } 804 }
799 if (selected) { 805 if (selected) {
800 painter->setPen(Qt::NoPen); 806 painter->setPen(Qt::NoPen);
801 painter->fillRect(x+1, y+1, w-1, h-1, 807 painter->fillRect(x+1, y+1, w-1, h-1,
802 group.brush(QColorGroup::Background)); 808 group.brush(QColorGroup::Background));
803 } else 809 } else
804 drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2), 810 drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2),
805 group.background().dark(contrast) ); 811 group.background().dark(contrast) );
806 812
807 813
808 // draw tab 814 // draw tab
809 painter->setPen(group.dark()); 815 painter->setPen(group.dark());
810 painter->drawLine(x, y, x, y2-2); 816 painter->drawLine(x, y, x, y2-2);
811 painter->drawLine(x+1, y, x2, y); 817 painter->drawLine(x+1, y, x2, y);
812 painter->drawLine(x2, y+1, x2, y2-2); 818 painter->drawLine(x2, y+1, x2, y2-2);
813 819
814 painter->setPen(group.mid()); 820 painter->setPen(group.mid());
815 painter->drawLine(x2-1, y+2, x2-1, y2-2); 821 painter->drawLine(x2-1, y+2, x2-1, y2-2);
816 822
817 painter->setPen(group.midlight()); 823 painter->setPen(group.midlight());
818 painter->drawLine(x+1, y+1, x2-2, y+1); 824 painter->drawLine(x+1, y+1, x2-2, y+1);
819 if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2); 825 if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2);
820 826
821 // finish off bottom 827 // finish off bottom
822 if (selected) { 828 if (selected) {
823 painter->setPen(group.dark()); 829 painter->setPen(group.dark());
824 painter->drawPoint(x, y2-1); 830 painter->drawPoint(x, y2-1);
825 painter->drawPoint(x2, y2-1); 831 painter->drawPoint(x2, y2-1);
826 832
827 painter->setPen(group.midlight()); 833 painter->setPen(group.midlight());
828 painter->drawPoint(x, y2); 834 painter->drawPoint(x, y2);
829 painter->drawLine(x+1, y2-1, x+1, y2); 835 painter->drawLine(x+1, y2-1, x+1, y2);
830 painter->drawPoint(x2, y2); 836 painter->drawPoint(x2, y2);
831 837
832 painter->setPen(group.mid()); 838 painter->setPen(group.mid());
833 painter->drawPoint(x2-1, y2-1); 839 painter->drawPoint(x2-1, y2-1);
834 840
835 if (edge) { 841 if (edge) {
836 painter->setPen(group.dark()); 842 painter->setPen(group.dark());
837 painter->drawLine(x, y2-1, x, y2); 843 painter->drawLine(x, y2-1, x, y2);
838 painter->setPen(group.midlight()); 844 painter->setPen(group.midlight());
839 painter->drawPoint(x+1, y2); 845 painter->drawPoint(x+1, y2);
840 } 846 }
841 } else { 847 } else {
842 painter->setPen(group.dark()); 848 painter->setPen(group.dark());
843 painter->drawLine(x, y2-1, x2, y2-1); 849 painter->drawLine(x, y2-1, x2, y2-1);
844 850
845 painter->setPen(group.midlight()); 851 painter->setPen(group.midlight());
846 painter->drawLine(x, y2, x2, y2); 852 painter->drawLine(x, y2, x2, y2);
847 853
848 if (edge) { 854 if (edge) {
849 painter->setPen(group.dark()); 855 painter->setPen(group.dark());
850 painter->drawLine(x, y2-1, x, y2); 856 painter->drawLine(x, y2-1, x, y2);
851 } 857 }
852 } 858 }
853 break; 859 break;
854 } 860 }
855 case QTabBar::RoundedBelow: 861 case QTabBar::RoundedBelow:
856 case QTabBar::TriangularBelow: { 862 case QTabBar::TriangularBelow: {
857 painter->setBrush( group.background().dark(contrast)); 863 painter->setBrush( group.background().dark(contrast));
858 painter->setPen(Qt::NoPen); 864 painter->setPen(Qt::NoPen);
859 painter->fillRect(x+1, y+1, w-1, h-1, painter->brush()); 865 painter->fillRect(x+1, y+1, w-1, h-1, painter->brush());
860 866
861 // draw tab 867 // draw tab
862 painter->setPen(group.dark()); 868 painter->setPen(group.dark());
863 painter->drawLine(x, y+1, x, y2); 869 painter->drawLine(x, y+1, x, y2);
864 painter->drawLine(x+1, y2, x2, y2); 870 painter->drawLine(x+1, y2, x2, y2);
865 painter->drawLine(x2, y+1, x2, y2-1); 871 painter->drawLine(x2, y+1, x2, y2-1);
866 872
867 painter->setPen(group.mid()); 873 painter->setPen(group.mid());
868 painter->drawLine(x2-1, y+1, x2-1, y2-1); 874 painter->drawLine(x2-1, y+1, x2-1, y2-1);
869 painter->drawLine(x+2, y2-1, x2-1, y2-1); 875 painter->drawLine(x+2, y2-1, x2-1, y2-1);
870 painter->drawPoint(x, y); 876 painter->drawPoint(x, y);
871 painter->drawPoint(x2, y); 877 painter->drawPoint(x2, y);
872 878
873 if ((selected) || edge) { 879 if ((selected) || edge) {
874 painter->setPen(group.midlight()); 880 painter->setPen(group.midlight());
875 painter->drawLine(x+1, y+1, x+1, y2-2); 881 painter->drawLine(x+1, y+1, x+1, y2-2);
876 } 882 }
877 883
878 // finish off top 884 // finish off top
879 if (selected) { 885 if (selected) {
880 if (edge) { 886 if (edge) {
881 painter->setPen(group.dark()); 887 painter->setPen(group.dark());
882 painter->drawPoint(x, y); 888 painter->drawPoint(x, y);
883 painter->setPen(group.midlight()); 889 painter->setPen(group.midlight());
884 painter->drawPoint(x+1, y); 890 painter->drawPoint(x+1, y);
885 } 891 }
886 } else { 892 } else {
887 painter->setPen(group.dark()); 893 painter->setPen(group.dark());
888 painter->drawLine(x, y+1, x2, y+1); 894 painter->drawLine(x, y+1, x2, y+1);
889 895
890 painter->setPen(group.mid()); 896 painter->setPen(group.mid());
891 painter->drawLine(x, y, x2, y); 897 painter->drawLine(x, y, x2, y);
892 898
893 if (edge) { 899 if (edge) {
894 painter->setPen(group.dark()); 900 painter->setPen(group.dark());
895 painter->drawPoint(x, y); 901 painter->drawPoint(x, y);
896 } 902 }
897 } 903 }
898 break; 904 break;
899 } 905 }
900 } 906 }
901 907
902 painter->restore(); 908 painter->restore();
903} 909}
904 910
905void PhaseStyle::drawTabMask( QPainter* p, const QTabBar*, QTab* tab, 911void PhaseStyle::drawTabMask( QPainter* p, const QTabBar*, QTab* tab,
906 bool ) { 912 bool ) {
907 p->fillRect(tab->rect(), Qt::color1); 913 p->fillRect(tab->rect(), Qt::color1);
908} 914}
909 915
910void PhaseStyle::drawToolButton(QPainter * p, int x, int y, 916void PhaseStyle::drawToolButton(QPainter * p, int x, int y,
911 int w, int h, const QColorGroup & g, 917 int w, int h, const QColorGroup & g,
912 bool sunken, 918 bool sunken,
913 const QBrush * fill ) { 919 const QBrush * fill ) {
914 QRect r(x, y, w, h ); 920 QRect r(x, y, w, h );
915 p->fillRect(r, g.background()); 921 p->fillRect(r, g.background());
916 922
917 drawPanel(p, x, y, w, h, g, sunken, 1, 923 drawPanel(p, x, y, w, h, g, sunken, 1,
918 fill ? fill : &g.brush(QColorGroup::Button) ); 924 fill ? fill : &g.brush(QColorGroup::Button) );
919 925
920 926
921 p->setPen(g.text() ); 927 p->setPen(g.text() );
922} 928}
923 929
924 930
925/* 931/*
926 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 932 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
927 * 933 *
928 * ../web/webstyle.cpp 934 * ../web/webstyle.cpp
929 */ 935 */
930void PhaseStyle::scrollBarMetrics(const QScrollBar* sb, int& sliderMin, 936void PhaseStyle::scrollBarMetrics(const QScrollBar* sb, int& sliderMin,
931 int& sliderMax, int &sliderLength, 937 int& sliderMax, int &sliderLength,
932 int& buttonDim ) { 938 int& buttonDim ) {
933 int maxlen; 939 int maxlen;
934 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 940 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
935 int len = (horizontal) ? sb->width() : sb->height(); 941 int len = (horizontal) ? sb->width() : sb->height();
936 int extent = (horizontal) ? sb->height() : sb->width(); 942 int extent = (horizontal) ? sb->height() : sb->width();
937 943
938 if (len > (extent - 1) * 2) 944 if (len > (extent - 1) * 2)
939 buttonDim = extent; 945 buttonDim = extent;
940 else 946 else
941 buttonDim = len / 2 - 1; 947 buttonDim = len / 2 - 1;
942 948
943 if (horizontal) 949 if (horizontal)
944 sliderMin = buttonDim * 2; 950 sliderMin = buttonDim * 2;
945 else 951 else
946 sliderMin = 1; 952 sliderMin = 1;
947 953
948 maxlen = len - buttonDim * 2 - 1; 954 maxlen = len - buttonDim * 2 - 1;
949 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) ); 955 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) );
950 956
951 sliderLength = 957 sliderLength =
952 (sb->pageStep() * maxlen) / div; 958 (sb->pageStep() * maxlen) / div;
953 959
954 if (sliderLength < SCROLLBAR_EXTENT) 960 if (sliderLength < SCROLLBAR_EXTENT)
955 sliderLength = SCROLLBAR_EXTENT; 961 sliderLength = SCROLLBAR_EXTENT;
956 962
957 if (sliderLength > maxlen) 963 if (sliderLength > maxlen)
958 sliderLength = maxlen; 964 sliderLength = maxlen;
959 965
960 sliderMax = sliderMin + maxlen - sliderLength; 966 sliderMax = sliderMin + maxlen - sliderLength;
961} 967}
962 968
963void PhaseStyle::drawScrollBarControls( QPainter* p, const QScrollBar *sb, 969void PhaseStyle::drawScrollBarControls( QPainter* p, const QScrollBar *sb,
964 int sliderStart, uint controls, 970 int sliderStart, uint controls,
965 uint activeControl) { 971 uint activeControl) {
966 const bool horizontal = (sb->orientation() == Qt::Horizontal ); 972 const bool horizontal = (sb->orientation() == Qt::Horizontal );
967 int sliderMin, sliderMax, sliderLength, buttonDim; 973 int sliderMin, sliderMax, sliderLength, buttonDim;
968 const QColorGroup& g = sb->colorGroup(); 974 const QColorGroup& g = sb->colorGroup();
969 QRect sub, add, subPage, addPage, slider; 975 QRect sub, add, subPage, addPage, slider;
970 int x, y, x2, y2; 976 int x, y, x2, y2;
971 977
972 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 978 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
973 979
974 /* lets get the positions */ 980 /* lets get the positions */
975 scrollBarItemPositions(sb, horizontal, sliderStart, 981 scrollBarItemPositions(sb, horizontal, sliderStart,
976 sliderMax, sliderLength, buttonDim, 982 sliderMax, sliderLength, buttonDim,
977 sub, add, subPage, addPage, 983 sub, add, subPage, addPage,
978 slider ); 984 slider );
979 985
980 986
981 /* sanity */ 987 /* sanity */
982 if ( sliderStart > sliderMax ) 988 if ( sliderStart > sliderMax )
983 sliderStart = sliderMax; 989 sliderStart = sliderMax;
984 990
985 // addline 991 // addline
986 if ( controls & AddLine && add.isValid() ) { 992 if ( controls & AddLine && add.isValid() ) {
987 x = add.x(); y = add.y(); 993 x = add.x(); y = add.y();
988 x2 = add.width(); y2 = add.height(); 994 x2 = add.width(); y2 = add.height();
989 const bool down = (activeControl & AddLine ); 995 const bool down = (activeControl & AddLine );
990 drawBevelButton(p, x, y, x2, y2, g, down, 996 drawBevelButton(p, x, y, x2, y2, g, down,
991 &g.brush(QColorGroup::Button)); 997 &g.brush(QColorGroup::Button));
992 998
993 Qt::ArrowType arrow = horizontal ? RightArrow : DownArrow; 999 Qt::ArrowType arrow = horizontal ? RightArrow : DownArrow;
994 if (down ) { 1000 if (down ) {
995 switch (arrow ) { 1001 switch (arrow ) {
996 case DownArrow: y++; break; 1002 case DownArrow: y++; break;
997 case RightArrow: x++; break; 1003 case RightArrow: x++; break;
998 default: break; 1004 default: break;
999 } 1005 }
1000 } 1006 }
1001 drawArrow( p, arrow, down, x, y, x2, y2, g, true ); 1007 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
1002 } 1008 }
1003 1009
1004 if ( controls & SubLine && sub.isValid() ) { 1010 if ( controls & SubLine && sub.isValid() ) {
1005 x = sub.x(); y = sub.y(); 1011 x = sub.x(); y = sub.y();
1006 x2 = sub.width(); y2 = sub.height(); 1012 x2 = sub.width(); y2 = sub.height();
1007 const bool down = (activeControl & SubLine ); 1013 const bool down = (activeControl & SubLine );
1008 drawBevelButton(p, x, y, x2, y2, g, down, 1014 drawBevelButton(p, x, y, x2, y2, g, down,
1009 &g.brush(QColorGroup::Button)); 1015 &g.brush(QColorGroup::Button));
1010 1016
1011 Qt::ArrowType arrow = horizontal ? LeftArrow : UpArrow; 1017 Qt::ArrowType arrow = horizontal ? LeftArrow : UpArrow;
1012 if (down ) { 1018 if (down ) {
1013 switch (arrow ) { 1019 switch (arrow ) {
1014 case UpArrow: y--; break; 1020 case UpArrow: y--; break;
1015 case LeftArrow: x--; break; 1021 case LeftArrow: x--; break;
1016 default: break; 1022 default: break;
1017 } 1023 }
1018 } 1024 }
1019 drawArrow( p, arrow, down, x, y, x2, y2, g, true ); 1025 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
1020 } 1026 }
1021 1027
1022 if ( controls & AddPage && addPage.isValid() ) { 1028 if ( controls & AddPage && addPage.isValid() ) {
1023 x = addPage.x(); y = addPage.y(); 1029 x = addPage.x(); y = addPage.y();
1024 x2 = addPage.right(); y2 = addPage.bottom(); 1030 x2 = addPage.right(); y2 = addPage.bottom();
1025 1031
1026 p->fillRect(addPage, g.mid()); 1032 p->fillRect(addPage, g.mid());
1027 p->setPen(g.dark()); 1033 p->setPen(g.dark());
1028 if (horizontal) { // vertical 1034 if (horizontal) { // vertical
1029 p->drawLine(x, y, x2, y); 1035 p->drawLine(x, y, x2, y);
1030 p->drawLine(x, y2, x2, y2); 1036 p->drawLine(x, y2, x2, y2);
1031 } else { // horizontal 1037 } else { // horizontal
1032 p->drawLine(x, y, x, y2); 1038 p->drawLine(x, y, x, y2);
1033 p->drawLine(x2, y, x2, y2); 1039 p->drawLine(x2, y, x2, y2);
1034 } 1040 }
1035 } 1041 }
1036 1042
1037 if ( controls & SubPage && subPage.isValid() ) { 1043 if ( controls & SubPage && subPage.isValid() ) {
1038 x = subPage.x(); y = subPage.y(); 1044 x = subPage.x(); y = subPage.y();
1039 x2 = subPage.right(); y2 = subPage.bottom(); 1045 x2 = subPage.right(); y2 = subPage.bottom();
1040 1046
1041 p->fillRect(subPage, g.mid()); 1047 p->fillRect(subPage, g.mid());
1042 p->setPen(g.dark()); 1048 p->setPen(g.dark());
1043 if (horizontal) { // vertical 1049 if (horizontal) { // vertical
1044 p->drawLine(x, y, x2, y); 1050 p->drawLine(x, y, x2, y);
1045 p->drawLine(x, y2, x2, y2); 1051 p->drawLine(x, y2, x2, y2);
1046 } else { // horizontal 1052 } else { // horizontal
1047 p->drawLine(x, y, x, y2); 1053 p->drawLine(x, y, x, y2);
1048 p->drawLine(x2, y, x2, y2); 1054 p->drawLine(x2, y, x2, y2);
1049 } 1055 }
1050} 1056}
1051 1057
1052 if ( controls & Slider && slider.isValid() ) { 1058 if ( controls & Slider && slider.isValid() ) {
1053 x = slider.x(); y = slider.y(); 1059 x = slider.x(); y = slider.y();
1054 x2 = slider.width(); y2 = slider.height(); 1060 x2 = slider.width(); y2 = slider.height();
1055 const bool down = ( activeControl & Slider ); 1061 const bool down = ( activeControl & Slider );
1056 int cx = x + x2/2 -2; int cy = y + y2/2 -2; 1062 int cx = x + x2/2 -2; int cy = y + y2/2 -2;
1057 1063
1058 drawBevelButton(p, x, y, x2, y2, g, down, 1064 drawBevelButton(p, x, y, x2, y2, g, down,
1059 &g.brush(QColorGroup::Button) ); 1065 &g.brush(QColorGroup::Button) );
1060 1066
1061 if (horizontal && (x2 >=20)) { 1067 if (horizontal && (x2 >=20)) {
1062 for (int n = -5; n <= 5; n += 5) 1068 for (int n = -5; n <= 5; n += 5)
1063 kColorBitmaps(p, g, cx+n, cy, 1069 kColorBitmaps(p, g, cx+n, cy,
1064 0, &doodad_mid, &doodad_light, 0, 0, 0); 1070 0, &doodad_mid, &doodad_light, 0, 0, 0);
1065 } else if (!horizontal && (y2 >= 20)) { 1071 } else if (!horizontal && (y2 >= 20)) {
1066 for (int n = -5; n <= 5; n += 5) 1072 for (int n = -5; n <= 5; n += 5)
1067 kColorBitmaps(p, g, cx, cy+n, 1073 kColorBitmaps(p, g, cx, cy+n,
1068 0, &doodad_mid, &doodad_light, 0, 0, 0); 1074 0, &doodad_mid, &doodad_light, 0, 0, 0);
1069 } 1075 }
1070 1076
1071 if ( sb->hasFocus() && down ) { 1077 if ( sb->hasFocus() && down ) {
1072 slider = QRect(slider.x()+2, slider.y()+2, 1078 slider = QRect(slider.x()+2, slider.y()+2,
1073 slider.width()-2, slider.height()-2 ); 1079 slider.width()-2, slider.height()-2 );
1074 drawFocusRect(p, slider, g, false ); 1080 drawFocusRect(p, slider, g, false );
1075 } 1081 }
1076 1082
1077 } 1083 }
1078} 1084}
1079 1085
1080/* 1086/*
1081 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 1087 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1082 * 1088 *
1083 * ../web/webstyle.cpp 1089 * ../web/webstyle.cpp
1084 */ 1090 */
1085QStyle::ScrollControl PhaseStyle::scrollBarPointOver( const QScrollBar * sb, 1091QStyle::ScrollControl PhaseStyle::scrollBarPointOver( const QScrollBar * sb,
1086 int sliderStart, 1092 int sliderStart,
1087 const QPoint & point ) { 1093 const QPoint & point ) {
1088 if (!sb->rect().contains(point)) 1094 if (!sb->rect().contains(point))
1089 return NoScroll; 1095 return NoScroll;
1090 1096
1091 int sliderMin, sliderMax, sliderLength, buttonDim; 1097 int sliderMin, sliderMax, sliderLength, buttonDim;
1092 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 1098 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
1093 1099
1094 if (sb->orientation() == QScrollBar::Horizontal) { 1100 if (sb->orientation() == QScrollBar::Horizontal) {
1095 int x = point.x(); 1101 int x = point.x();
1096 1102
1097 if (x <= buttonDim) 1103 if (x <= buttonDim)
1098 return SubLine; 1104 return SubLine;
1099 else if (x <= buttonDim * 2) 1105 else if (x <= buttonDim * 2)
1100 return AddLine; 1106 return AddLine;
1101 else if (x < sliderStart) 1107 else if (x < sliderStart)
1102 return SubPage; 1108 return SubPage;
1103 else if (x < sliderStart+sliderLength) 1109 else if (x < sliderStart+sliderLength)
1104 return Slider; 1110 return Slider;
1105 else 1111 else
1106 return AddPage; 1112 return AddPage;
1107 } else { 1113 } else {
1108 int y = point.y(); 1114 int y = point.y();
1109 1115
1110 if (y < sliderStart) 1116 if (y < sliderStart)
1111 return SubPage; 1117 return SubPage;
1112 else if (y < sliderStart + sliderLength) 1118 else if (y < sliderStart + sliderLength)
1113 return Slider; 1119 return Slider;
1114 else if (y < sliderMax + sliderLength) 1120 else if (y < sliderMax + sliderLength)
1115 return AddPage; 1121 return AddPage;
1116 else if (y < sliderMax + sliderLength + buttonDim) 1122 else if (y < sliderMax + sliderLength + buttonDim)
1117 return SubLine; 1123 return SubLine;
1118 else 1124 else
1119 return AddLine; 1125 return AddLine;
1120 } 1126 }
1121} 1127}
1122 1128
1123/* 1129/*
1124 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 1130 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1125 * 1131 *
1126 * ../web/webstyle.cpp 1132 * ../web/webstyle.cpp
1127 * scrollBarControlsMetrics 1133 * scrollBarControlsMetrics
1128 */ 1134 */
1129void PhaseStyle::scrollBarItemPositions( const QScrollBar* sb, const bool horizontal, 1135void PhaseStyle::scrollBarItemPositions( const QScrollBar* sb, const bool horizontal,
1130 int sliderStart, int sliderMax, 1136 int sliderStart, int sliderMax,
1131 int sliderLength, int buttonDim, 1137 int sliderLength, int buttonDim,
1132 QRect &rSub, QRect& rAdd, QRect& rSubPage, 1138 QRect &rSub, QRect& rAdd, QRect& rSubPage,
1133 QRect &rAddPage, QRect& rSlider ) { 1139 QRect &rAddPage, QRect& rSlider ) {
1134 1140
1135 int len = horizontal ? sb->width() : sb->height(); 1141 int len = horizontal ? sb->width() : sb->height();
1136 int extent = horizontal ? sb->height() : sb->width(); 1142 int extent = horizontal ? sb->height() : sb->width();
1137 1143
1138 QColorGroup g = sb->colorGroup(); 1144 QColorGroup g = sb->colorGroup();
1139 1145
1140 if (sliderStart > sliderMax) 1146 if (sliderStart > sliderMax)
1141 sliderStart = sliderMax; 1147 sliderStart = sliderMax;
1142 1148
1143 int sliderEnd = sliderStart + sliderLength; 1149 int sliderEnd = sliderStart + sliderLength;
1144 1150
1145 int addX, addY; 1151 int addX, addY;
1146 int subX, subY; 1152 int subX, subY;
1147 int subPageX, subPageY, subPageW, subPageH; 1153 int subPageX, subPageY, subPageW, subPageH;
1148 int addPageX, addPageY, addPageW, addPageH; 1154 int addPageX, addPageY, addPageW, addPageH;
1149 int sliderX, sliderY, sliderW, sliderH; 1155 int sliderX, sliderY, sliderW, sliderH;
1150 1156
1151 if (horizontal){ 1157 if (horizontal){
1152 subY = 0; 1158 subY = 0;
1153 addY = 0; 1159 addY = 0;
1154 subX = 0; 1160 subX = 0;
1155 addX = buttonDim; 1161 addX = buttonDim;
1156 1162
1157 subPageX = buttonDim * 2; 1163 subPageX = buttonDim * 2;
1158 subPageY = 0; 1164 subPageY = 0;
1159 subPageW = sliderStart - 1; 1165 subPageW = sliderStart - 1;
1160 subPageH = extent; 1166 subPageH = extent;
1161 1167
1162 addPageX = sliderEnd; 1168 addPageX = sliderEnd;
1163 addPageY = 0; 1169 addPageY = 0;
1164 addPageW = len - sliderEnd; 1170 addPageW = len - sliderEnd;
1165 addPageH = extent; 1171 addPageH = extent;
1166 1172
1167 sliderX = sliderStart; 1173 sliderX = sliderStart;
1168 sliderY = 0; 1174 sliderY = 0;
1169 sliderW = sliderLength; 1175 sliderW = sliderLength;
1170 sliderH = extent; 1176 sliderH = extent;
1171 }else { 1177 }else {
1172 subX = 0; 1178 subX = 0;
1173 addX = 0; 1179 addX = 0;
1174 subY = len - buttonDim * 2; 1180 subY = len - buttonDim * 2;
1175 addY = len - buttonDim; 1181 addY = len - buttonDim;
1176 1182
1177 subPageX = 0; 1183 subPageX = 0;
1178 subPageY = 0; 1184 subPageY = 0;
1179 subPageW = extent; 1185 subPageW = extent;
1180 subPageH = sliderStart; 1186 subPageH = sliderStart;
1181 1187
1182 addPageX = 0; 1188 addPageX = 0;
1183 addPageY = sliderEnd; 1189 addPageY = sliderEnd;
1184 addPageW = extent; 1190 addPageW = extent;
1185 addPageH = subY - sliderEnd; 1191 addPageH = subY - sliderEnd;
1186 1192
1187 sliderX = 0; 1193 sliderX = 0;
1188 sliderY = sliderStart; 1194 sliderY = sliderStart;
1189 sliderW = extent; 1195 sliderW = extent;
1190 sliderH = sliderLength; 1196 sliderH = sliderLength;
1191 } 1197 }
1192 1198
1193 rSub .setRect( subX, subY, buttonDim, buttonDim); 1199 rSub .setRect( subX, subY, buttonDim, buttonDim);
1194 rAdd .setRect( addX, addY, buttonDim, buttonDim); 1200 rAdd .setRect( addX, addY, buttonDim, buttonDim);
1195 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH); 1201 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
1196 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH); 1202 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
1197 rSlider .setRect( sliderX, sliderY, sliderW, sliderH); 1203 rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
1198 1204
1199} 1205}
1200 1206
1201 1207
1202void PhaseStyle::drawSlider (QPainter * p, int x, int y, 1208void PhaseStyle::drawSlider (QPainter * p, int x, int y,
1203 int w, int h, const QColorGroup &g, 1209 int w, int h, const QColorGroup &g,
1204 Orientation o, bool, bool ) { 1210 Orientation o, bool, bool ) {
1205 int cx = x + w/2; 1211 int cx = x + w/2;
1206 int cy = y + h/2; 1212 int cy = y + h/2;
1207 QBrush brush = g.brush( QColorGroup::Button ); 1213 QBrush brush = g.brush( QColorGroup::Button );
1208 1214
1209 if ( o == Horizontal ) { 1215 if ( o == Horizontal ) {
1210 drawBevelButton(p, cx-5, y, 6, h, g, false, 1216 drawBevelButton(p, cx-5, y, 6, h, g, false,
1211 &brush ); 1217 &brush );
1212 drawBevelButton(p, cx, y, 6, h, g, false, 1218 drawBevelButton(p, cx, y, 6, h, g, false,
1213 &brush ); 1219 &brush );
1214 }else { 1220 }else {
1215 drawBevelButton(p, x, cy-5, w, 6, g, false, 1221 drawBevelButton(p, x, cy-5, w, 6, g, false,
1216 &brush ); 1222 &brush );
1217 drawBevelButton(p, x, cy, w, 6, g, false, 1223 drawBevelButton(p, x, cy, w, 6, g, false,
1218 &brush ); 1224 &brush );
1219 } 1225 }
1220} 1226}
1221 1227
1222void PhaseStyle::drawSliderGroove(QPainter* p, int x, int y, 1228void PhaseStyle::drawSliderGroove(QPainter* p, int x, int y,
1223 int w, int h, const QColorGroup& g, 1229 int w, int h, const QColorGroup& g,
1224 QCOORD , Orientation o ) { 1230 QCOORD , Orientation o ) {
1225 int cx = x + w/2; 1231 int cx = x + w/2;
1226 int cy = y + h/2; 1232 int cy = y + h/2;
1227 1233
1228 if ( o == Horizontal ) { 1234 if ( o == Horizontal ) {
1229 y = cy-3; h = 7; 1235 y = cy-3; h = 7;
1230 }else { 1236 }else {
1231 x = cx-3; w = 7; 1237 x = cx-3; w = 7;
1232 } 1238 }
1233 1239
1234 drawPanel(p, x, y, w, h, g, true, 1, 1240 drawPanel(p, x, y, w, h, g, true, 1,
1235 &g.brush(QColorGroup::Mid ) ); 1241 &g.brush(QColorGroup::Mid ) );
1236} 1242}
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
@@ -1,1651 +1,1654 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> 2 Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
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 }
163 } 163 }
164 if ( w->inherits( "QPopupMenu" ) ) { 164 if ( w->inherits( "QPopupMenu" ) ) {
165 popupPalette = w->palette(); 165 popupPalette = w->palette();
166 if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { 166 if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) {
167 QPalette newPal( w->palette() ); 167 QPalette newPal( w->palette() );
168 w->setPalettePropagation( QWidget::SamePalette ); 168 w->setPalettePropagation( QWidget::SamePalette );
169 if ( isColor( MenuItem ) ) { 169 if ( isColor( MenuItem ) ) {
170 newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); 170 newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) );
171 newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); 171 newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) );
172 } 172 }
173 if ( isColor( MenuItemDown ) ) 173 if ( isColor( MenuItemDown ) )
174 newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); 174 newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) );
175 w->setPalette( newPal ); 175 w->setPalette( newPal );
176 } 176 }
177 } 177 }
178 else if ( w->inherits( "QCheckBox" ) ) { 178 else if ( w->inherits( "QCheckBox" ) ) {
179 if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { 179 if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) {
180 QPalette newPal( w->palette() ); 180 QPalette newPal( w->palette() );
181 w->setPalettePropagation( QWidget::SamePalette ); 181 w->setPalettePropagation( QWidget::SamePalette );
182 if ( isColor( IndicatorOff ) ) { 182 if ( isColor( IndicatorOff ) ) {
183 newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); 183 newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) );
184 newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); 184 newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) );
185 } 185 }
186 if ( isColor( IndicatorOn ) ) 186 if ( isColor( IndicatorOn ) )
187 newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); 187 newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) );
188 w->setPalette( newPal ); 188 w->setPalette( newPal );
189 } 189 }
190 } 190 }
191 else if ( w->inherits( "QRadioButton" ) ) { 191 else if ( w->inherits( "QRadioButton" ) ) {
192 if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { 192 if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) {
193 QPalette newPal( w->palette() ); 193 QPalette newPal( w->palette() );
194 w->setPalettePropagation( QWidget::SamePalette ); 194 w->setPalettePropagation( QWidget::SamePalette );
195 if ( isColor( ExIndicatorOff ) ) { 195 if ( isColor( ExIndicatorOff ) ) {
196 newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); 196 newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) );
197 newPal.setDisabled( *colorGroup( newPal.normal(), 197 newPal.setDisabled( *colorGroup( newPal.normal(),
198 ExIndicatorOff ) ); 198 ExIndicatorOff ) );
199 } 199 }
200 if ( isColor( ExIndicatorOn ) ) 200 if ( isColor( ExIndicatorOn ) )
201 newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); 201 newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) );
202 w->setPalette( newPal ); 202 w->setPalette( newPal );
203 } 203 }
204 } 204 }
205 else if ( w-> inherits ( "QProgressBar" ) ) { 205 else if ( w-> inherits ( "QProgressBar" ) ) {
206 w-> installEventFilter ( this ); 206 w-> installEventFilter ( this );
207 } 207 }
208} 208}
209 209
210void OThemeStyle::unPolish( QWidget* w ) 210void OThemeStyle::unPolish( QWidget* w )
211{ 211{
212 if ( !w->isTopLevel() ) { 212 if ( !w->isTopLevel() ) {
213 if ( w->inherits( "QGroupBox" ) 213 if ( w->inherits( "QGroupBox" )
214 || w->inherits( "QTabWidget" ) ) { 214 || w->inherits( "QTabWidget" ) ) {
215 w->setAutoMask( FALSE ); 215 w->setAutoMask( FALSE );
216 return ; 216 return ;
217 } 217 }
218 if ( w->inherits( "QLabel" ) 218 if ( w->inherits( "QLabel" )
219 || w->inherits( "QSlider" ) 219 || w->inherits( "QSlider" )
220 || w->inherits( "QButton" ) 220 || w->inherits( "QButton" )
221 || w->inherits( "QProgressBar" ) 221 || w->inherits( "QProgressBar" )
222 ) { 222 ) {
223 w->setBackgroundOrigin( QWidget::WidgetOrigin ); 223 w->setBackgroundOrigin( QWidget::WidgetOrigin );
224 } 224 }
225 } 225 }
226 if ( w->inherits( "QPopupMenu" ) ) 226 if ( w->inherits( "QPopupMenu" ) )
227 w->unsetPalette(); 227 w->unsetPalette();
228 else if ( w->inherits( "QCheckBox" ) ) 228 else if ( w->inherits( "QCheckBox" ) )
229 w->unsetPalette(); 229 w->unsetPalette();
230 else if ( w->inherits( "QRadioButton" ) ) 230 else if ( w->inherits( "QRadioButton" ) )
231 w->unsetPalette(); 231 w->unsetPalette();
232 else if ( w-> inherits ( "QProgressBar" ) ) 232 else if ( w-> inherits ( "QProgressBar" ) )
233 w-> removeEventFilter ( this ); 233 w-> removeEventFilter ( this );
234} 234}
235 235
236bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev ) 236bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev )
237{ 237{
238 // only QProgressBar so far 238 // only QProgressBar so far
239 239
240 if ( ev-> type ( ) == QEvent::Paint ) { 240 if ( ev-> type ( ) == QEvent::Paint ) {
241 HackProgressBar *pb = (HackProgressBar *) obj; 241 HackProgressBar *pb = (HackProgressBar *) obj;
242 pb-> paint ((QPaintEvent *) ev, this ); 242 pb-> paint ((QPaintEvent *) ev, this );
243 return true; 243 return true;
244 } 244 }
245 return false; 245 return false;
246} 246}
247 247
248void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, 248void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h,
249 const QColorGroup &g, bool sunken, bool 249 const QColorGroup &g, bool sunken, bool
250 rounded, WidgetType type, const QBrush * ) 250 rounded, WidgetType type, const QBrush * )
251{ 251{
252 if ( w <= 0 || h <= 0 ) 252 if ( w <= 0 || h <= 0 )
253 return; 253 return;
254 254
255 int offset = borderPixmap( type ) ? 0 : decoWidth( type ); 255 int offset = borderPixmap( type ) ? 0 : decoWidth( type );
256 QPen oldPen = p->pen(); 256 QPen oldPen = p->pen();
257 257
258 // handle reverse bevel here since it uses decowidth differently 258 // handle reverse bevel here since it uses decowidth differently
259 if ( gradientHint( type ) == GrReverseBevel ) { 259 if ( gradientHint( type ) == GrReverseBevel ) {
260 int i; 260 int i;
261 bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, 261 bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h,
262 Qt::CopyROP, true ); 262 Qt::CopyROP, true );
263 p->setPen( g.text() ); 263 p->setPen( g.text() );
264 for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) 264 for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 )
265 p->drawRect( x, y, w, h ); 265 p->drawRect( x, y, w, h );
266 } 266 }
267 // same with KDE style borders 267 // same with KDE style borders
268 else if ( !borderPixmap( type ) && shade() == KDE ) { 268 else if ( !borderPixmap( type ) && shade() == KDE ) {
269 qDrawWinButton( p, x, y, w, h, g, sunken ); 269 qDrawWinButton( p, x, y, w, h, g, sunken );
270 if ( isPixmap( type ) ) 270 if ( isPixmap( type ) )
271 p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, 271 p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6,
272 *scalePixmap( w - 6, h - 6, 272 *scalePixmap( w - 6, h - 6,
273 type ) ); 273 type ) );
274 else 274 else
275 p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, 275 p->fillRect( x + 4, y + 4, w - 6, h - offset * 6,
276 g.brush( QColorGroup::Button ) ); 276 g.brush( QColorGroup::Button ) );
277 277
278 } 278 }
279 else { 279 else {
280 if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { 280 if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) {
281 if ( isPixmap( type ) ) 281 if ( isPixmap( type ) )
282 if ( rounded ) 282 if ( rounded )
283 p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); 283 p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) );
284 else 284 else
285 p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, 285 p->drawTiledPixmap( x + offset, y + offset, w - offset * 2,
286 h - offset * 2, 286 h - offset * 2,
287 *scalePixmap( w - offset * 2, h - offset * 2, 287 *scalePixmap( w - offset * 2, h - offset * 2,
288 type ) ); 288 type ) );
289 else 289 else
290 p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, 290 p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2,
291 g.brush( QColorGroup::Button ) ); 291 g.brush( QColorGroup::Button ) );
292 } 292 }
293 if ( borderPixmap( type ) ) { 293 if ( borderPixmap( type ) ) {
294 bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, 294 bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h,
295 Qt::CopyROP, false ); 295 Qt::CopyROP, false );
296 } 296 }
297 else 297 else
298 drawShade( p, x, y, w, h, g, sunken, rounded, 298 drawShade( p, x, y, w, h, g, sunken, rounded,
299 highlightWidth( type ), borderWidth( type ), shade() ); 299 highlightWidth( type ), borderWidth( type ), shade() );
300 } 300 }
301 p->setPen( oldPen ); 301 p->setPen( oldPen );
302} 302}
303 303
304void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, 304void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h,
305 const QColorGroup &g, bool sunken, 305 const QColorGroup &g, bool sunken,
306 const QBrush *fill ) 306 const QBrush *fill )
307{ 307{
308 drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? 308 drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ?
309 PushButtonDown : PushButton, fill ); 309 PushButtonDown : PushButton, fill );
310} 310}
311 311
312void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) 312void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p )
313{ 313{
314 bool sunken = btn->isOn() || btn->isDown(); 314 bool sunken = btn->isOn() || btn->isDown();
315 int diw = buttonDefaultIndicatorWidth(); 315 int diw = buttonDefaultIndicatorWidth();
316 drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, 316 drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw,
317 *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : 317 *colorGroup( btn->colorGroup(), sunken ? PushButtonDown :
318 PushButton ), sunken, roundButton(), 318 PushButton ), sunken, roundButton(),
319 sunken ? PushButtonDown : PushButton, NULL ); 319 sunken ? PushButtonDown : PushButton, NULL );
320 // TODO if diw, draw fancy default button indicator 320 // TODO if diw, draw fancy default button indicator
321} 321}
322 322
323void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, 323void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
324 bool round ) 324 bool round )
325{ 325{
326 // round edge fills 326 // round edge fills
327 static const QCOORD btm_left_fill[] = { 327 static const QCOORD btm_left_fill[] = {
328 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 328 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
329 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 329 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4
330 }; 330 };
331 331
332 static const QCOORD btm_right_fill[] = { 332 static const QCOORD btm_right_fill[] = {
333 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 333 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4,
334 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 334 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4
335 }; 335 };
336 336
337 static const QCOORD top_left_fill[] = { 337 static const QCOORD top_left_fill[] = {
338 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, 338 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3,
339 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 339 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
340 }; 340 };
341 341
342 static const QCOORD top_right_fill[] = { 342 static const QCOORD top_right_fill[] = {
343 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 343 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0,
344 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 344 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
345 }; 345 };
346 346
347 QBrush fillBrush( color1, SolidPattern ); 347 QBrush fillBrush( color1, SolidPattern );
348 p->setPen( color1 ); 348 p->setPen( color1 );
349 if ( round && w > 19 && h > 19 ) { 349 if ( round && w > 19 && h > 19 ) {
350 int x2 = x + w - 1; 350 int x2 = x + w - 1;
351 int y2 = y + h - 1; 351 int y2 = y + h - 1;
352 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); 352 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill );
353 a.translate( 1, 1 ); 353 a.translate( 1, 1 );
354 p->drawPoints( a ); 354 p->drawPoints( a );
355 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); 355 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill );
356 a.translate( 1, h - 6 ); 356 a.translate( 1, h - 6 );
357 p->drawPoints( a ); 357 p->drawPoints( a );
358 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); 358 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill );
359 a.translate( w - 6, 1 ); 359 a.translate( w - 6, 1 );
360 p->drawPoints( a ); 360 p->drawPoints( a );
361 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); 361 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill );
362 a.translate( w - 6, h - 6 ); 362 a.translate( w - 6, h - 6 );
363 p->drawPoints( a ); 363 p->drawPoints( a );
364 364
365 p->fillRect( x + 6, y, w - 12, h, fillBrush ); 365 p->fillRect( x + 6, y, w - 12, h, fillBrush );
366 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); 366 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush );
367 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); 367 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush );
368 p->drawLine( x + 6, y, x2 - 6, y ); 368 p->drawLine( x + 6, y, x2 - 6, y );
369 p->drawLine( x + 6, y2, x2 - 6, y2 ); 369 p->drawLine( x + 6, y2, x2 - 6, y2 );
370 p->drawLine( x, y + 6, x, y2 - 6 ); 370 p->drawLine( x, y + 6, x, y2 - 6 );
371 p->drawLine( x2, y + 6, x2, y2 - 6 ); 371 p->drawLine( x2, y + 6, x2, y2 - 6 );
372 372
373 } 373 }
374 else 374 else
375 p->fillRect( x, y, w, h, fillBrush ); 375 p->fillRect( x, y, w, h, fillBrush );
376} 376}
377 377
378void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) 378void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h )
379{ 379{
380 drawBaseMask( p, x, y, w, h, roundButton() ); 380 drawBaseMask( p, x, y, w, h, roundButton() );
381} 381}
382 382
383void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) 383void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h )
384{ 384{
385 drawBaseMask( p, x, y, w, h, roundComboBox() ); 385 drawBaseMask( p, x, y, w, h, roundComboBox() );
386} 386}
387 387
388void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 388void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
389 const QColorGroup &g, bool sunken, 389 const QColorGroup &g, bool sunken,
390 const QBrush * ) 390 const QBrush * )
391{ 391{
392 WidgetType type = sunken ? BevelDown : Bevel; 392 WidgetType type = sunken ? BevelDown : Bevel;
393 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); 393 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
394} 394}
395 395
396void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, 396void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
397 const QColorGroup &g, bool sunken, 397 const QColorGroup &g, bool sunken,
398 const QBrush * ) 398 const QBrush * )
399{ 399{
400 WidgetType type = sunken ? ToolButtonDown : ToolButton; 400 WidgetType type = sunken ? ToolButtonDown : ToolButton;
401 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); 401 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
402} 402}
403 403
404#if 0 404#if 0
405void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, 405void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
406 const QColorGroup &g, bool sunken, 406 const QColorGroup &g, bool sunken,
407 bool raised, bool enabled, bool popup, 407 bool raised, bool enabled, bool popup,
408 KToolButtonType type, const QString &btext, 408 KToolButtonType type, const QString &btext,
409 const QPixmap *pixmap, QFont *font, 409 const QPixmap *pixmap, QFont *font,
410 QWidget * ) 410 QWidget * )
411{ 411{
412 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); 412 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 );
413 if ( font ) 413 if ( font )
414 tmp_font = *font; 414 tmp_font = *font;
415 QFontMetrics fm( tmp_font ); 415 QFontMetrics fm( tmp_font );
416 WidgetType widget = sunken ? ToolButtonDown : ToolButton; 416 WidgetType widget = sunken ? ToolButtonDown : ToolButton;
417 417
418 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, 418 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false,
419 widget ); 419 widget );
420 int dx, dy; 420 int dx, dy;
421 if ( type == Icon ) { // icon only 421 if ( type == Icon ) { // icon only
422 if ( pixmap ) { 422 if ( pixmap ) {
423 dx = ( w - pixmap->width() ) / 2; 423 dx = ( w - pixmap->width() ) / 2;
424 dy = ( h - pixmap->height() ) / 2; 424 dy = ( h - pixmap->height() ) / 2;
425 if ( sunken ) { 425 if ( sunken ) {
426 ++dx; 426 ++dx;
427 ++dy; 427 ++dy;
428 } 428 }
429 p->drawPixmap( x + dx, y + dy, *pixmap ); 429 p->drawPixmap( x + dx, y + dy, *pixmap );
430 } 430 }
431 } 431 }
432 else if ( type == IconTextRight ) { // icon and text (if any) 432 else if ( type == IconTextRight ) { // icon and text (if any)
433 if ( pixmap ) { 433 if ( pixmap ) {
434 dx = 4; 434 dx = 4;
435 dy = ( h - pixmap->height() ) / 2; 435 dy = ( h - pixmap->height() ) / 2;
436 if ( sunken ) { 436 if ( sunken ) {
437 ++dx; 437 ++dx;
438 ++dy; 438 ++dy;
439 } 439 }
440 p->drawPixmap( x + dx, y + dy, *pixmap ); 440 p->drawPixmap( x + dx, y + dy, *pixmap );
441 } 441 }
442 if ( !btext.isNull() ) { 442 if ( !btext.isNull() ) {
443 int tf = AlignVCenter | AlignLeft; 443 int tf = AlignVCenter | AlignLeft;
444 if ( pixmap ) 444 if ( pixmap )
445 dx = 4 + pixmap->width() + 2; 445 dx = 4 + pixmap->width() + 2;
446 else 446 else
447 dx = 4; 447 dx = 4;
448 dy = 0; 448 dy = 0;
449 if ( sunken ) { 449 if ( sunken ) {
450 ++dx; 450 ++dx;
451 ++dy; 451 ++dy;
452 } 452 }
453 if ( font ) 453 if ( font )
454 p->setFont( *font ); 454 p->setFont( *font );
455 if ( raised ) 455 if ( raised )
456 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 456 p->setPen( KGlobalSettings::toolBarHighlightColor() );
457 p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); 457 p->drawText( x + dx, y + dy, w - dx, h, tf, btext );
458 } 458 }
459 } 459 }
460 else if ( type == Text ) { // only text, even if there is a icon 460 else if ( type == Text ) { // only text, even if there is a icon
461 if ( !btext.isNull() ) { 461 if ( !btext.isNull() ) {
462 int tf = AlignTop | AlignLeft; 462 int tf = AlignTop | AlignLeft;
463 if ( !enabled ) 463 if ( !enabled )
464 p->setPen( g.dark() ); 464 p->setPen( g.dark() );
465 dx = ( w - fm.width( btext ) ) / 2; 465 dx = ( w - fm.width( btext ) ) / 2;
466 dy = ( h - fm.lineSpacing() ) / 2; 466 dy = ( h - fm.lineSpacing() ) / 2;
467 if ( sunken ) { 467 if ( sunken ) {
468 ++dx; 468 ++dx;
469 ++dy; 469 ++dy;
470 } 470 }
471 if ( font ) 471 if ( font )
472 p->setFont( *font ); 472 p->setFont( *font );
473 if ( raised ) 473 if ( raised )
474 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 474 p->setPen( KGlobalSettings::toolBarHighlightColor() );
475 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); 475 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext );
476 } 476 }
477 } 477 }
478 else if ( type == IconTextBottom ) { 478 else if ( type == IconTextBottom ) {
479 if ( pixmap ) { 479 if ( pixmap ) {
480 dx = ( w - pixmap->width() ) / 2; 480 dx = ( w - pixmap->width() ) / 2;
481 dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; 481 dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2;
482 if ( sunken ) { 482 if ( sunken ) {
483 ++dx; 483 ++dx;
484 ++dy; 484 ++dy;
485 } 485 }
486 p->drawPixmap( x + dx, y + dy, *pixmap ); 486 p->drawPixmap( x + dx, y + dy, *pixmap );
487 } 487 }
488 if ( !btext.isNull() ) { 488 if ( !btext.isNull() ) {
489 int tf = AlignBottom | AlignHCenter; 489 int tf = AlignBottom | AlignHCenter;
490 dx = ( w - fm.width( btext ) ) / 2; 490 dx = ( w - fm.width( btext ) ) / 2;
491 dy = h - fm.lineSpacing() - 4; 491 dy = h - fm.lineSpacing() - 4;
492 if ( sunken ) { 492 if ( sunken ) {
493 ++dx; 493 ++dx;
494 ++dy; 494 ++dy;
495 } 495 }
496 if ( font ) 496 if ( font )
497 p->setFont( *font ); 497 p->setFont( *font );
498 if ( raised ) 498 if ( raised )
499 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 499 p->setPen( KGlobalSettings::toolBarHighlightColor() );
500 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); 500 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext );
501 } 501 }
502 } 502 }
503 if ( popup ) { 503 if ( popup ) {
504 if ( enabled ) 504 if ( enabled )
505 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, 505 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0,
506 g, true ); 506 g, true );
507 else 507 else
508 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 508 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5,
509 0, 0, g, false ); 509 0, 0, g, false );
510 } 510 }
511} 511}
512 512
513void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, 513void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h,
514 const QColorGroup &g, KToolBarPos, QBrush * ) 514 const QColorGroup &g, KToolBarPos, QBrush * )
515{ 515{
516 if ( w > h ) 516 if ( w > h )
517 drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, 517 drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false,
518 HBarHandle ); 518 HBarHandle );
519 else 519 else
520 drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, 520 drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false,
521 VBarHandle ); 521 VBarHandle );
522} 522}
523 523
524void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, 524void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h,
525 const QColorGroup &g, KToolBarPos, QBrush * ) 525 const QColorGroup &g, KToolBarPos, QBrush * )
526{ 526{
527 drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, 527 drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false,
528 ToolBar ); 528 ToolBar );
529} 529}
530#endif 530#endif
531 531
532QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) 532QRect OThemeStyle::buttonRect( int x, int y, int w, int h )
533{ 533{
534 int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? 534 int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ?
535 decoWidth( PushButton ) : decoWidth( PushButtonDown ); 535 decoWidth( PushButton ) : decoWidth( PushButtonDown );
536 return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); 536 return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) );
537} 537}
538 538
539void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 539void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
540 const QColorGroup &g, bool sunken, bool, 540 const QColorGroup &g, bool sunken, bool,
541 bool, const QBrush * ) 541 bool, const QBrush * )
542{ 542{
543 WidgetType widget = sunken ? ComboBoxDown : ComboBox; 543 WidgetType widget = sunken ? ComboBoxDown : ComboBox;
544 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, 544 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken,
545 roundComboBox(), widget ); 545 roundComboBox(), widget );
546 if ( !sunken && isPixmap( ComboDeco ) ) 546 if ( !sunken && isPixmap( ComboDeco ) )
547 p->drawPixmap( w - uncached( ComboDeco ) ->width() - 547 p->drawPixmap( w - uncached( ComboDeco ) ->width() -
548 decoWidth( ComboBox ) - 2, 548 decoWidth( ComboBox ) - 2,
549 y + ( h - uncached( ComboDeco ) -> 549 y + ( h - uncached( ComboDeco ) ->
550 height() ) / 2, *uncached( ComboDeco ) ); 550 height() ) / 2, *uncached( ComboDeco ) );
551 else if ( sunken && isPixmap( ComboDecoDown ) ) 551 else if ( sunken && isPixmap( ComboDecoDown ) )
552 p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - 552 p->drawPixmap( w - uncached( ComboDecoDown ) ->width() -
553 decoWidth( ComboBoxDown ) - 2, 553 decoWidth( ComboBoxDown ) - 2,
554 y + ( h - uncached( ComboDecoDown ) -> 554 y + ( h - uncached( ComboDecoDown ) ->
555 height() ) / 2, *uncached( ComboDecoDown ) ); 555 height() ) / 2, *uncached( ComboDecoDown ) );
556 else { 556 else {
557 qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, 557 qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10,
558 h - 15, *colorGroup( g, widget ), true ); 558 h - 15, *colorGroup( g, widget ), true );
559 qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); 559 qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) );
560 } 560 }
561} 561}
562 562
563void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, 563void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb,
564 int sliderStart, uint controls, 564 int sliderStart, uint controls,
565 uint activeControl ) 565 uint activeControl )
566{ 566{
567 int sliderMin, sliderMax, sliderLength, buttonDim; 567 int sliderMin, sliderMax, sliderLength, buttonDim;
568 QRect add 568 QRect add
569 , sub, addPage, subPage, slider; 569 , sub, addPage, subPage, slider;
570 int addX, addY, subX, subY; 570 int addX, addY, subX, subY;
571 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 571 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
572 int len = ( horizontal ) ? sb->width() : sb->height(); 572 int len = ( horizontal ) ? sb->width() : sb->height();
573 int extent = ( horizontal ) ? sb->height() : sb->width(); 573 int extent = ( horizontal ) ? sb->height() : sb->width();
574 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); 574 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove );
575 QColorGroup g = sb->colorGroup(); 575 QColorGroup g = sb->colorGroup();
576 576
577 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 577 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
578 if ( sliderStart > sliderMax ) 578 if ( sliderStart > sliderMax )
579 sliderStart = sliderMax; 579 sliderStart = sliderMax;
580 580
581 int sliderEnd = sliderStart + sliderLength; 581 int sliderEnd = sliderStart + sliderLength;
582 int sliderWidth = extent - offset * 2; 582 int sliderWidth = extent - offset * 2;
583 583
584 // Scary button placement code >:-P Feel free to improve this if you 584 // Scary button placement code >:-P Feel free to improve this if you
585 // want. I get a headache just looking at it... (mosfet) 585 // want. I get a headache just looking at it... (mosfet)
586 if ( scrollBarLayout() == SBOpposite ) { 586 if ( scrollBarLayout() == SBOpposite ) {
587 if ( horizontal ) { 587 if ( horizontal ) {
588 subY = addY = ( extent - buttonDim ) / 2; 588 subY = addY = ( extent - buttonDim ) / 2;
589 subX = offset; 589 subX = offset;
590 addX = len - buttonDim - offset; 590 addX = len - buttonDim - offset;
591 } 591 }
592 else { 592 else {
593 subX = addX = ( extent - buttonDim ) / 2; 593 subX = addX = ( extent - buttonDim ) / 2;
594 subY = offset; 594 subY = offset;
595 addY = len - buttonDim - offset; 595 addY = len - buttonDim - offset;
596 } 596 }
597 sub.setRect( subX, subY, buttonDim, buttonDim ); 597 sub.setRect( subX, subY, buttonDim, buttonDim );
598 add.setRect( addX, addY, buttonDim, buttonDim ); 598 add.setRect( addX, addY, buttonDim, buttonDim );
599 if ( horizontal ) { 599 if ( horizontal ) {
600 subPage.setRect( sub.right() + 1, offset, 600 subPage.setRect( sub.right() + 1, offset,
601 sliderStart - sub.right() - 1 , sliderWidth ); 601 sliderStart - sub.right() - 1 , sliderWidth );
602 addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); 602 addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth );
603 slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); 603 slider.setRect( sliderStart, offset, sliderLength, sliderWidth );
604 } 604 }
605 else { 605 else {
606 subPage.setRect( offset, sub.bottom() + 1, sliderWidth, 606 subPage.setRect( offset, sub.bottom() + 1, sliderWidth,
607 sliderStart - sub.bottom() - 1 ); 607 sliderStart - sub.bottom() - 1 );
608 addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); 608 addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd );
609 slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); 609 slider.setRect( offset, sliderStart, sliderWidth, sliderLength );
610 } 610 }
611 } 611 }
612 else if ( horizontal ) { 612 else if ( horizontal ) {
613 subY = addY = ( extent - buttonDim ) / 2; 613 subY = addY = ( extent - buttonDim ) / 2;
614 if ( scrollBarLayout() == SBBottomLeft ) { 614 if ( scrollBarLayout() == SBBottomLeft ) {
615 subX = offset; 615 subX = offset;
616 addX = buttonDim + offset; 616 addX = buttonDim + offset;
617 subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); 617 subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent );
618 addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); 618 addPage.setRect( sliderEnd, 0, len - sliderEnd, extent );
619 slider.setRect( sliderStart, 0, sliderLength, extent ); 619 slider.setRect( sliderStart, 0, sliderLength, extent );
620 } 620 }
621 else { 621 else {
622 subX = len - buttonDim - buttonDim - offset; 622 subX = len - buttonDim - buttonDim - offset;
623 addX = len - buttonDim - offset; 623 addX = len - buttonDim - offset;
624 subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); 624 subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth );
625 addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); 625 addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth );
626 slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); 626 slider.setRect( sliderStart, offset, sliderLength, sliderWidth );
627 } 627 }
628 sub.setRect( subX, subY, buttonDim, buttonDim ); 628 sub.setRect( subX, subY, buttonDim, buttonDim );
629 add.setRect( addX, addY, buttonDim, buttonDim ); 629 add.setRect( addX, addY, buttonDim, buttonDim );
630 } 630 }
631 else { // BottomLeft and BottomRight vertical bars are the same. 631 else { // BottomLeft and BottomRight vertical bars are the same.
632 subX = addX = ( extent - buttonDim ) / 2; 632 subX = addX = ( extent - buttonDim ) / 2;
633 subY = len - buttonDim - buttonDim - offset; 633 subY = len - buttonDim - buttonDim - offset;
634 addY = len - buttonDim - offset; 634 addY = len - buttonDim - offset;
635 subPage.setRect( offset, offset + 1, sliderWidth, 635 subPage.setRect( offset, offset + 1, sliderWidth,
636 sliderStart - offset - 1 ); 636 sliderStart - offset - 1 );
637 addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); 637 addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd );
638 slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); 638 slider.setRect( offset, sliderStart, sliderWidth, sliderLength );
639 sub.setRect( subX, subY, buttonDim, buttonDim ); 639 sub.setRect( subX, subY, buttonDim, buttonDim );
640 add.setRect( addX, addY, buttonDim, buttonDim ); 640 add.setRect( addX, addY, buttonDim, buttonDim );
641 } 641 }
642 // End of the button placement code 642 // End of the button placement code
643 643
644 bool active; 644 bool active;
645 if ( ( controls & QStyle::SubPage ) ) { 645 if ( ( controls & QStyle::SubPage ) ) {
646 drawScrollBarGroove( p, sb, horizontal, subPage, g ); 646 drawScrollBarGroove( p, sb, horizontal, subPage, g );
647 } 647 }
648 if ( ( controls & QStyle::AddPage ) ) { 648 if ( ( controls & QStyle::AddPage ) ) {
649 drawScrollBarGroove( p, sb, horizontal, addPage, g ); 649 drawScrollBarGroove( p, sb, horizontal, addPage, g );
650 } 650 }
651 if ( controls & QStyle::AddLine ) { 651 if ( controls & QStyle::AddLine ) {
652 active = activeControl == QStyle::AddLine; 652 active = activeControl == QStyle::AddLine;
653 drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), 653 drawBaseButton( p, add.x(), add.y(), add.width(), add.height(),
654 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), 654 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ),
655 active, false, active ? ScrollButtonDown : ScrollButton ); 655 active, false, active ? ScrollButtonDown : ScrollButton );
656 drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, 656 drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3,
657 add.y() + 3, add.width() - 6, add.height() - 6, 657 add.y() + 3, add.width() - 6, add.height() - 6,
658 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); 658 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) );
659 } 659 }
660 if ( controls & QStyle::SubLine ) { 660 if ( controls & QStyle::SubLine ) {
661 active = activeControl == QStyle::SubLine; 661 active = activeControl == QStyle::SubLine;
662 p->setPen( g.dark() ); 662 p->setPen( g.dark() );
663 p->drawRect( sub ); 663 p->drawRect( sub );
664 drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), 664 drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(),
665 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), 665 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ),
666 active, false, active ? ScrollButtonDown : ScrollButton ); 666 active, false, active ? ScrollButtonDown : ScrollButton );
667 drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, 667 drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3,
668 sub.y() + 3, sub.width() - 6, sub.height() - 6, 668 sub.y() + 3, sub.width() - 6, sub.height() - 6,
669 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); 669 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) );
670 } 670 }
671 if ( controls & QStyle::Slider ) { 671 if ( controls & QStyle::Slider ) {
672 active = activeControl == QStyle::Slider; 672 active = activeControl == QStyle::Slider;
673 WidgetType widget = horizontal ? 673 WidgetType widget = horizontal ?
674 active ? HScrollBarSliderDown : HScrollBarSlider : 674 active ? HScrollBarSliderDown : HScrollBarSlider :
675 active ? VScrollBarSliderDown : VScrollBarSlider; 675 active ? VScrollBarSliderDown : VScrollBarSlider;
676 676
677 drawBaseButton( p, slider.x(), slider.y(), slider.width(), 677 drawBaseButton( p, slider.x(), slider.y(), slider.width(),
678 slider.height(), *colorGroup( g, widget ), active, false, 678 slider.height(), *colorGroup( g, widget ), active, false,
679 widget ); 679 widget );
680 int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : 680 int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 :
681 slider.width(); 681 slider.width();
682 int spaceH = horizontal ? slider.height() : 682 int spaceH = horizontal ? slider.height() :
683 slider.height() - decoWidth( widget ) - 4; 683 slider.height() - decoWidth( widget ) - 4;
684widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : 684widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown :
685 horizontal ? HScrollDeco : VScrollDeco; 685 horizontal ? HScrollDeco : VScrollDeco;
686 if ( isPixmap( widget ) ) { 686 if ( isPixmap( widget ) ) {
687 if ( spaceW >= uncached( widget ) ->width() && 687 if ( spaceW >= uncached( widget ) ->width() &&
688 spaceH >= uncached( widget ) ->height() ) { 688 spaceH >= uncached( widget ) ->height() ) {
689 p->drawPixmap( slider.x() + ( slider.width() - 689 p->drawPixmap( slider.x() + ( slider.width() -
690 uncached( widget ) ->width() ) / 2, 690 uncached( widget ) ->width() ) / 2,
691 slider.y() + ( slider.height() - 691 slider.y() + ( slider.height() -
692 uncached( widget ) ->height() ) / 2, 692 uncached( widget ) ->height() ) / 2,
693 *uncached( widget ) ); 693 *uncached( widget ) );
694 } 694 }
695 } 695 }
696 } 696 }
697} 697}
698 698
699void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, 699void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb,
700 bool horizontal, QRect r, QColorGroup g ) 700 bool horizontal, QRect r, QColorGroup g )
701 701
702{ 702{
703 WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; 703 WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove;
704 if ( !isPixmap( widget ) ) { 704 if ( !isPixmap( widget ) ) {
705 p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); 705 p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) );
706 } 706 }
707 else { 707 else {
708 // If the groove is pixmapped we make a full-sized image (it gets 708 // If the groove is pixmapped we make a full-sized image (it gets
709 // cached) then bitBlt it to the appropriate rect. 709 // cached) then bitBlt it to the appropriate rect.
710 QPixmap buffer( sb->size() ); 710 QPixmap buffer( sb->size() );
711 QPainter bPainter( &buffer ); 711 QPainter bPainter( &buffer );
712 bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), 712 bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(),
713 *scalePixmap( buffer.width(), buffer.height(), 713 *scalePixmap( buffer.width(), buffer.height(),
714 widget ) ); 714 widget ) );
715 bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), 715 bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(),
716 r.height(), Qt::CopyROP ); 716 r.height(), Qt::CopyROP );
717 } 717 }
718 // Do the borders and frame 718 // Do the borders and frame
719 drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), 719 drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(),
720 sb->rect().height(), *colorGroup( g, widget ), true, false, 720 sb->rect().height(), *colorGroup( g, widget ), true, false,
721 highlightWidth( widget ), borderWidth( widget ), shade() ); 721 highlightWidth( widget ), borderWidth( widget ), shade() );
722} 722}
723 723
724void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, 724void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin,
725 int &sliderMax, int &sliderLength, 725 int &sliderMax, int &sliderLength,
726 int &buttonDim ) 726 int &buttonDim )
727{ 727{
728 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 728 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
729 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); 729 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove );
730 int maxlen; 730 int maxlen;
731 int len = horizontal ? sb->width() : sb->height(); 731 int len = horizontal ? sb->width() : sb->height();
732 int extent = horizontal ? sb->height() : sb->width(); 732 int extent = horizontal ? sb->height() : sb->width();
733 733
734 if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) 734 if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 )
735 buttonDim = extent - offset * 2; 735 buttonDim = extent - offset * 2;
736 else 736 else
737 buttonDim = ( len - offset * 2 ) / 2 - 1; 737 buttonDim = ( len - offset * 2 ) / 2 - 1;
738 maxlen = len - offset * 2 - buttonDim * 2 - 1; 738 maxlen = len - offset * 2 - buttonDim * 2 - 1;
739 739
740 switch ( scrollBarLayout() ) { 740 switch ( scrollBarLayout() ) {
741 case SBBottomLeft: 741 case SBBottomLeft:
742 sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; 742 sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1;
743 break; 743 break;
744 case SBBottomRight: 744 case SBBottomRight:
745 sliderMin = offset + 1; 745 sliderMin = offset + 1;
746 break; 746 break;
747 case SBOpposite: 747 case SBOpposite:
748 default: 748 default:
749 sliderMin = offset + buttonDim; 749 sliderMin = offset + buttonDim;
750 break; 750 break;
751 } 751 }
752 if ( sb->maxValue() == sb->minValue() ) 752 if ( sb->maxValue() == sb->minValue() )
753 sliderLength = maxlen; 753 sliderLength = maxlen;
754 else 754 else
755 sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - 755 sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() -
756 sb->minValue() + sb->pageStep() ); 756 sb->minValue() + sb->pageStep() );
757 if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) 757 if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 )
758 sliderLength = 12; 758 sliderLength = 12;
759 if ( sliderLength > maxlen ) 759 if ( sliderLength > maxlen )
760 sliderLength = maxlen; 760 sliderLength = maxlen;
761 sliderMax = sliderMin + maxlen - sliderLength; 761 sliderMax = sliderMin + maxlen - sliderLength;
762} 762}
763 763
764QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb, 764QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb,
765 int sliderStart, 765 int sliderStart,
766 const QPoint &p ) 766 const QPoint &p )
767{ 767{
768 if ( !sb->rect().contains( p ) ) 768 if ( !sb->rect().contains( p ) )
769 return ( QStyle::NoScroll ); 769 return ( QStyle::NoScroll );
770 int sliderMin, sliderMax, sliderLength, buttonDim; 770 int sliderMin, sliderMax, sliderLength, buttonDim;
771 int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y(); 771 int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y();
772 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 772 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
773 773
774 if ( scrollBarLayout() == SBOpposite ) { 774 if ( scrollBarLayout() == SBOpposite ) {
775 if ( pos < sliderMin ) 775 if ( pos < sliderMin )
776 return QStyle::SubLine; 776 return QStyle::SubLine;
777 if ( pos < sliderStart ) 777 if ( pos < sliderStart )
778 return SubPage; 778 return SubPage;
779 if ( pos < sliderStart + sliderLength ) 779 if ( pos < sliderStart + sliderLength )
780 return QStyle::Slider; 780 return QStyle::Slider;
781 if ( pos < sliderMax + sliderLength ) 781 if ( pos < sliderMax + sliderLength )
782 return QStyle::AddPage; 782 return QStyle::AddPage;
783 return QStyle::AddLine; 783 return QStyle::AddLine;
784 } 784 }
785 if ( scrollBarLayout() == SBBottomLeft && sb->orientation() == 785 if ( scrollBarLayout() == SBBottomLeft && sb->orientation() ==
786 QScrollBar::Horizontal ) { 786 QScrollBar::Horizontal ) {
787 if ( pos <= buttonDim ) 787 if ( pos <= buttonDim )
788 return ( QStyle::SubLine ); 788 return ( QStyle::SubLine );
789 else if ( pos <= buttonDim * 2 ) 789 else if ( pos <= buttonDim * 2 )
790 return ( QStyle::AddLine ); 790 return ( QStyle::AddLine );
791 else if ( pos < sliderStart ) 791 else if ( pos < sliderStart )
792 return ( QStyle::SubPage ); 792 return ( QStyle::SubPage );
793 else if ( pos < sliderStart + sliderLength ) 793 else if ( pos < sliderStart + sliderLength )
794 return ( QStyle::Slider ); 794 return ( QStyle::Slider );
795 return ( AddPage ); 795 return ( AddPage );
796 } 796 }
797 else { 797 else {
798 if ( pos < sliderStart ) 798 if ( pos < sliderStart )
799 return QStyle::SubPage; 799 return QStyle::SubPage;
800 if ( pos < sliderStart + sliderLength ) 800 if ( pos < sliderStart + sliderLength )
801 return QStyle::Slider; 801 return QStyle::Slider;
802 if ( pos < sliderMax + sliderLength ) 802 if ( pos < sliderMax + sliderLength )
803 return QStyle::AddPage; 803 return QStyle::AddPage;
804 if ( pos < sliderMax + sliderLength + buttonDim ) 804 if ( pos < sliderMax + sliderLength + buttonDim )
805 return QStyle::SubLine; 805 return QStyle::SubLine;
806 return QStyle::AddLine; 806 return QStyle::AddLine;
807 } 807 }
808} 808}
809 809
810QSize OThemeStyle::exclusiveIndicatorSize() const 810QSize OThemeStyle::exclusiveIndicatorSize() const
811{ 811{
812 if ( isPixmap( ExIndicatorOn ) ) 812 if ( isPixmap( ExIndicatorOn ) )
813 return ( uncached( ExIndicatorOn ) ->size() ); 813 return ( uncached( ExIndicatorOn ) ->size() );
814 else 814 else
815 return ( QWindowsStyle::exclusiveIndicatorSize() ); 815 return ( QWindowsStyle::exclusiveIndicatorSize() );
816} 816}
817 817
818QSize OThemeStyle::indicatorSize() const 818QSize OThemeStyle::indicatorSize() const
819{ 819{
820 if ( isPixmap( IndicatorOn ) ) 820 if ( isPixmap( IndicatorOn ) )
821 return ( uncached( IndicatorOn ) ->size() ); 821 return ( uncached( IndicatorOn ) ->size() );
822 else 822 else
823 return ( QWindowsStyle::indicatorSize() ); 823 return ( QWindowsStyle::indicatorSize() );
824} 824}
825 825
826void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, 826void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w,
827 int h, const QColorGroup &g, bool on, 827 int h, const QColorGroup &g, bool on,
828 bool down, bool enabled ) 828 bool down, bool enabled )
829{ 829{
830 if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) { 830 if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) {
831 p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn : 831 p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn :
832 ExIndicatorOff ) ); 832 ExIndicatorOff ) );
833 } 833 }
834 else { 834 else {
835 QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h, 835 QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h,
836 *colorGroup( g, ExIndicatorOn ), 836 *colorGroup( g, ExIndicatorOn ),
837 on, down, enabled ); 837 on, down, enabled );
838 } 838 }
839 839
840} 840}
841 841
842void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, 842void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h,
843 const QColorGroup &g, int state, bool down, 843 const QColorGroup &g, int state, bool down,
844 bool enabled ) 844 bool enabled )
845{ 845{
846 if ( isPixmap( ( down || state != QButton::Off ) ? 846 if ( isPixmap( ( down || state != QButton::Off ) ?
847 IndicatorOn : IndicatorOff ) ) { 847 IndicatorOn : IndicatorOff ) ) {
848 p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ? 848 p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ?
849 IndicatorOn : IndicatorOff ) ); 849 IndicatorOn : IndicatorOff ) );
850 } 850 }
851 else { 851 else {
852 QWindowsStyle::drawIndicator( p, x, y, w, h, 852 QWindowsStyle::drawIndicator( p, x, y, w, h,
853 *colorGroup( g, IndicatorOn ), state, 853 *colorGroup( g, IndicatorOn ), state,
854 down, enabled ); 854 down, enabled );
855 } 855 }
856} 856}
857 857
858void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, 858void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w,
859 int h, bool on ) 859 int h, bool on )
860{ 860{
861 if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) { 861 if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) {
862 const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) -> 862 const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ->
863 mask(); 863 mask();
864 if ( mask ) { 864 if ( mask ) {
865 p->drawPixmap( x, y, *mask ); 865 p->drawPixmap( x, y, *mask );
866 } 866 }
867 else 867 else
868 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); 868 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) );
869 } 869 }
870 else 870 else
871 QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on ); 871 QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on );
872} 872}
873 873
874void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, 874void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h,
875 int state ) 875 int state )
876{ 876{
877 if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) { 877 if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) {
878 const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn : 878 const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn :
879 IndicatorOff ) ->mask(); 879 IndicatorOff ) ->mask();
880 if ( mask ) 880 if ( mask )
881 p->drawPixmap( x, y, *mask ); 881 p->drawPixmap( x, y, *mask );
882 else 882 else
883 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); 883 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) );
884 } 884 }
885 else 885 else
886 QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state ); 886 QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state );
887} 887}
888 888
889void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, 889void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h,
890 const QColorGroup& g, QCOORD c, 890 const QColorGroup& g, QCOORD c,
891 Orientation orient ) 891 Orientation orient )
892{ 892{
893 if ( roundSlider() ) 893 if ( roundSlider() )
894 QWindowsStyle::drawSliderGroove( p, x, y, w, h, 894 QWindowsStyle::drawSliderGroove( p, x, y, w, h,
895 *colorGroup( g, SliderGroove ), 895 *colorGroup( g, SliderGroove ),
896 c, orient ); 896 c, orient );
897 else 897 else
898 drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true, 898 drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true,
899 false, SliderGroove ); 899 false, SliderGroove );
900} 900}
901 901
902void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, 902void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
903 const QColorGroup &g, Orientation orient, 903 const QColorGroup &g, Orientation orient,
904 bool tickAbove, bool tickBelow ) 904 bool tickAbove, bool tickBelow )
905{ 905{
906 if ( isPixmap( Slider ) ) { 906 if ( isPixmap( Slider ) ) {
907 if ( orient == Qt::Horizontal ) 907 if ( orient == Qt::Horizontal )
908 p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2, 908 p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2,
909 *uncached( Slider ) ); 909 *uncached( Slider ) );
910 else 910 else
911 p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2, 911 p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2,
912 y, *uncached( Slider ) ); 912 y, *uncached( Slider ) );
913 } 913 }
914 else { 914 else {
915 QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ), 915 QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ),
916 orient, tickAbove, tickBelow ); 916 orient, tickAbove, tickBelow );
917 } 917 }
918} 918}
919 919
920void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, 920void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h,
921 Orientation orient, bool tickAbove, 921 Orientation orient, bool tickAbove,
922 bool tickBelow ) 922 bool tickBelow )
923{ 923{
924 // This is odd. If we fill in the entire region it still masks the slider 924 // This is odd. If we fill in the entire region it still masks the slider
925 // properly. I have no idea, this used to be different in Qt betas... 925 // properly. I have no idea, this used to be different in Qt betas...
926 if ( isPixmap( Slider ) ) 926 if ( isPixmap( Slider ) )
927 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); 927 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) );
928 else 928 else
929 QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, 929 QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove,
930 tickBelow ); 930 tickBelow );
931} 931}
932 932
933int OThemeStyle::defaultFrameWidth() const 933int OThemeStyle::defaultFrameWidth() const
934{ 934{
935 return ( frameWidth() ); 935 return ( frameWidth() );
936} 936}
937 937
938void OThemeStyle::getButtonShift( int &x, int &y ) 938void OThemeStyle::getButtonShift( int &x, int &y )
939{ 939{
940 x = buttonXShift(); 940 x = buttonXShift();
941 y = buttonYShift(); 941 y = buttonYShift();
942} 942}
943 943
944int OThemeStyle::sliderLength() const 944int OThemeStyle::sliderLength() const
945{ 945{
946 return ( sliderButtonLength() ); 946 return ( sliderButtonLength() );
947} 947}
948 948
949void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, 949void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x,
950 int y, int w, int h, const QColorGroup &g, 950 int y, int w, int h, const QColorGroup &g,
951 bool enabled, const QBrush * ) 951 bool enabled, const QBrush * )
952{ 952{
953 // Handles pixmapped arrows. A little inefficent because you can specify 953 // Handles pixmapped arrows. A little inefficent because you can specify
954 // some as pixmaps and some as default types. 954 // some as pixmaps and some as default types.
955 WidgetType widget; 955 WidgetType widget;
956 switch ( type ) { 956 switch ( type ) {
957 case UpArrow: 957 case UpArrow:
958widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; 958widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp;
959 break; 959 break;
960 case DownArrow: 960 case DownArrow:
961widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; 961widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown;
962 break; 962 break;
963 case LeftArrow: 963 case LeftArrow:
964widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; 964widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft;
965 break; 965 break;
966 case RightArrow: 966 case RightArrow:
967 default: 967 default:
968widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; 968widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight;
969 break; 969 break;
970 } 970 }
971 if ( isPixmap( widget ) ) { 971 if ( isPixmap( widget ) ) {
972 p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, 972 p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2,
973 y + ( h - uncached( widget ) ->height() ) / 2, 973 y + ( h - uncached( widget ) ->height() ) / 2,
974 *uncached( widget ) ); 974 *uncached( widget ) );
975 return ; 975 return ;
976 } 976 }
977 const QColorGroup *cg = colorGroup( g, widget ); 977 const QColorGroup *cg = colorGroup( g, widget );
978 // Standard arrow types 978 // Standard arrow types
979 if ( arrowType() == MotifArrow ) 979 if ( arrowType() == MotifArrow )
980 qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); 980 qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled );
981 else if ( arrowType() == SmallArrow ) { 981 else if ( arrowType() == SmallArrow ) {
982 QColorGroup tmp( *cg ); 982 QColorGroup tmp( *cg );
983 tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); 983 tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) );
984 QWindowsStyle::drawArrow( p, type, false, x, y, w, h, 984 QWindowsStyle::drawArrow( p, type, false, x, y, w, h,
985 tmp, true ); 985 tmp, true );
986 } 986 }
987 else { 987 else {
988 QPointArray a; 988 QPointArray a;
989 int x2 = x + w - 1, y2 = y + h - 1; 989 int x2 = x + w - 1, y2 = y + h - 1;
990 switch ( type ) { 990 switch ( type ) {
991 case Qt::UpArrow: 991 case Qt::UpArrow:
992 a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); 992 a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 );
993 break; 993 break;
994 case Qt::DownArrow: 994 case Qt::DownArrow:
995 a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); 995 a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y );
996 break; 996 break;
997 case Qt::LeftArrow: 997 case Qt::LeftArrow:
998 a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); 998 a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y );
999 break; 999 break;
1000 default: 1000 default:
1001 a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); 1001 a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y );
1002 break; 1002 break;
1003 } 1003 }
1004 QBrush oldBrush = p->brush(); 1004 QBrush oldBrush = p->brush();
1005 QPen oldPen = p->pen(); 1005 QPen oldPen = p->pen();
1006 p->setBrush( cg->brush( QColorGroup::Shadow ) ); 1006 p->setBrush( cg->brush( QColorGroup::Shadow ) );
1007 p->setPen( cg->shadow() ); 1007 p->setPen( cg->shadow() );
1008 p->drawPolygon( a ); 1008 p->drawPolygon( a );
1009 p->setBrush( oldBrush ); 1009 p->setBrush( oldBrush );
1010 p->setPen( oldPen ); 1010 p->setPen( oldPen );
1011 } 1011 }
1012} 1012}
1013 1013
1014/* This is where we draw the borders and highlights. The new round button 1014/* This is where we draw the borders and highlights. The new round button
1015 * code is a pain in the arse. We don't want to be calculating arcs so 1015 * code is a pain in the arse. We don't want to be calculating arcs so
1016 * use a whole lotta QPointArray's ;-) The code is made a lot more complex 1016 * use a whole lotta QPointArray's ;-) The code is made a lot more complex
1017 * because you can have variable width border and highlights... 1017 * because you can have variable width border and highlights...
1018 * I may want to cache this if round buttons are used, but am concerned 1018 * I may want to cache this if round buttons are used, but am concerned
1019 * about excessive cache misses. This is a memory/speed tradeoff that I 1019 * about excessive cache misses. This is a memory/speed tradeoff that I
1020 * have to test. 1020 * have to test.
1021 */ 1021 */
1022void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, 1022void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h,
1023 const QColorGroup &g, bool sunken, bool rounded, 1023 const QColorGroup &g, bool sunken, bool rounded,
1024 int hWidth, int bWidth, ShadeStyle style ) 1024 int hWidth, int bWidth, ShadeStyle style )
1025{ 1025{
1026 int i, sc, bc, x2, y2; 1026 int i, sc, bc, x2, y2;
1027 QPen highPen, lowPen; 1027 QPen highPen, lowPen;
1028 1028
1029 if ( style == Motif ) { 1029 if ( style == Motif ) {
1030 highPen.setColor( sunken ? g.dark() : g.light() ); 1030 highPen.setColor( sunken ? g.dark() : g.light() );
1031 lowPen.setColor( sunken ? g.light() : g.dark() ); 1031 lowPen.setColor( sunken ? g.light() : g.dark() );
1032 } 1032 }
1033 else { 1033 else {
1034 highPen.setColor( sunken ? g.shadow() : g.light() ); 1034 highPen.setColor( sunken ? g.shadow() : g.light() );
1035 lowPen.setColor( sunken ? g.light() : g.shadow() ); 1035 lowPen.setColor( sunken ? g.light() : g.shadow() );
1036 } 1036 }
1037 1037
1038 // Advanced round buttons 1038 // Advanced round buttons
1039 if ( rounded && w > 19 && h > 19 ) { 1039 if ( rounded && w > 19 && h > 19 ) {
1040 x2 = x + w - 1, y2 = y + h - 1; 1040 x2 = x + w - 1, y2 = y + h - 1;
1041 QPointArray bPntArray, hPntArray, lPntArray; 1041 QPointArray bPntArray, hPntArray, lPntArray;
1042 QPointArray bLineArray, hLineArray, lLineArray; 1042 QPointArray bLineArray, hLineArray, lLineArray;
1043 // borders 1043 // borders
1044 for ( i = 0, bc = 0; i < bWidth; ++i ) { 1044 for ( i = 0, bc = 0; i < bWidth; ++i ) {
1045 bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, 1045 bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3,
1046 x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, 1046 x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3,
1047 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, 1047 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1,
1048 x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, 1048 x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5,
1049 x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, 1049 x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1,
1050 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); 1050 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
1051 bc += 24; 1051 bc += 24;
1052 // ellispe edges don't match exactly, so fill in blanks 1052 // ellispe edges don't match exactly, so fill in blanks
1053 if ( i < bWidth - 1 || hWidth != 0 ) { 1053 if ( i < bWidth - 1 || hWidth != 0 ) {
1054 bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, 1054 bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3,
1055 x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, 1055 x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2,
1056 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, 1056 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1,
1057 x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, 1057 x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
1058 x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, 1058 x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6,
1059 x2 - 2, y + 4 ); 1059 x2 - 2, y + 4 );
1060 bc += 20; 1060 bc += 20;
1061 } 1061 }
1062 bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, 1062 bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6,
1063 x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); 1063 x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
1064 ++x, ++y; 1064 ++x, ++y;
1065 --x2, --y2; 1065 --x2, --y2;
1066 } 1066 }
1067 // highlights 1067 // highlights
1068 for ( i = 0, sc = 0; i < hWidth; ++i ) { 1068 for ( i = 0, sc = 0; i < hWidth; ++i ) {
1069 hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left 1069 hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left
1070 x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, 1070 x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5,
1071 x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners 1071 x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners
1072 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); 1072 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 );
1073 lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right 1073 lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right
1074 x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, 1074 x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4,
1075 x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners 1075 x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners
1076 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); 1076 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
1077 sc += 12; 1077 sc += 12;
1078 if ( i < hWidth - 1 ) { 1078 if ( i < hWidth - 1 ) {
1079 hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left 1079 hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left
1080 x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, 1080 x + 3, y + 3, x + 2, y + 4, x + 1, y + 6,
1081 x2 - 6, y + 1, x2 - 4, y + 2, // half corners 1081 x2 - 6, y + 1, x2 - 4, y + 2, // half corners
1082 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); 1082 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 );
1083 lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right 1083 lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right
1084 x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, 1084 x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
1085 x + 6, y2 - 1, x + 4, y2 - 2, // half corners 1085 x + 6, y2 - 1, x + 4, y2 - 2, // half corners
1086 x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); 1086 x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 );
1087 sc += 10; 1087 sc += 10;
1088 } 1088 }
1089 hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); 1089 hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 );
1090 lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); 1090 lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
1091 ++x, ++y; 1091 ++x, ++y;
1092 --x2, --y2; 1092 --x2, --y2;
1093 } 1093 }
1094 p->setPen( Qt::black ); 1094 p->setPen( Qt::black );
1095 p->drawPoints( bPntArray ); 1095 p->drawPoints( bPntArray );
1096 p->drawLineSegments( bLineArray ); 1096 p->drawLineSegments( bLineArray );
1097 p->setPen( highPen ); 1097 p->setPen( highPen );
1098 p->drawPoints( hPntArray ); 1098 p->drawPoints( hPntArray );
1099 p->drawLineSegments( hLineArray ); 1099 p->drawLineSegments( hLineArray );
1100 p->setPen( lowPen ); 1100 p->setPen( lowPen );
1101 p->drawPoints( lPntArray ); 1101 p->drawPoints( lPntArray );
1102 p->drawLineSegments( lLineArray ); 1102 p->drawLineSegments( lLineArray );
1103 } 1103 }
1104 // Rectangular buttons 1104 // Rectangular buttons
1105 else { 1105 else {
1106 QPointArray highShade( hWidth * 4 ); 1106 QPointArray highShade( hWidth * 4 );
1107 QPointArray lowShade( hWidth * 4 ); 1107 QPointArray lowShade( hWidth * 4 );
1108 1108
1109 p->setPen( g.shadow() ); 1109 p->setPen( g.shadow() );
1110 for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) 1110 for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 )
1111 p->drawRect( x, y , w, h ); 1111 p->drawRect( x, y , w, h );
1112 1112
1113 if ( !hWidth ) 1113 if ( !hWidth )
1114 return ; 1114 return ;
1115 1115
1116 x2 = x + w - 1, y2 = y + h - 1; 1116 x2 = x + w - 1, y2 = y + h - 1;
1117 for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { 1117 for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) {
1118 highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); 1118 highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 );
1119 lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); 1119 lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 );
1120 } 1120 }
1121 if ( style == Windows && hWidth > 1 ) { 1121 if ( style == Windows && hWidth > 1 ) {
1122 p->setPen( highPen ); 1122 p->setPen( highPen );
1123 p->drawLineSegments( highShade, 0, 2 ); 1123 p->drawLineSegments( highShade, 0, 2 );
1124 p->setPen( lowPen ); 1124 p->setPen( lowPen );
1125 p->drawLineSegments( lowShade, 0, 2 ); 1125 p->drawLineSegments( lowShade, 0, 2 );
1126 1126
1127 p->setPen( ( sunken ) ? g.dark() : g.mid() ); 1127 p->setPen( ( sunken ) ? g.dark() : g.mid() );
1128 p->drawLineSegments( highShade, 4 ); 1128 p->drawLineSegments( highShade, 4 );
1129 p->setPen( ( sunken ) ? g.mid() : g.dark() ); 1129 p->setPen( ( sunken ) ? g.mid() : g.dark() );
1130 p->drawLineSegments( lowShade, 4 ); 1130 p->drawLineSegments( lowShade, 4 );
1131 } 1131 }
1132 else { 1132 else {
1133 p->setPen( ( sunken ) ? g.dark() : g.light() ); 1133 p->setPen( ( sunken ) ? g.dark() : g.light() );
1134 p->drawLineSegments( highShade ); 1134 p->drawLineSegments( highShade );
1135 p->setPen( ( sunken ) ? g.light() : g.dark() ); 1135 p->setPen( ( sunken ) ? g.light() : g.dark() );
1136 p->drawLineSegments( lowShade ); 1136 p->drawLineSegments( lowShade );
1137 } 1137 }
1138 } 1138 }
1139} 1139}
1140 1140
1141void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) 1141void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
1142{ 1142{
1143 WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : 1143 WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown :
1144 PushButton; 1144 PushButton;
1145 const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); 1145 const QColorGroup *cg = colorGroup( btn->colorGroup(), widget );
1146 int x, y, w, h; 1146 int x, y, w, h;
1147 1147
1148 QRect r = btn->rect(); 1148 QRect r = btn->rect();
1149 r.rect( &x, &y, &w, &h ); 1149 r.rect( &x, &y, &w, &h );
1150 x += decoWidth( widget ); 1150 x += decoWidth( widget );
1151 y += decoWidth( widget ); 1151 y += decoWidth( widget );
1152 w -= decoWidth( widget ) * 2; 1152 w -= decoWidth( widget ) * 2;
1153 h -= decoWidth( widget ) * 2; 1153 h -= decoWidth( widget ) * 2;
1154 bool act = btn->isOn() || btn->isDown(); 1154 bool act = btn->isOn() || btn->isDown();
1155 1155
1156 // If this is a button with an associated popup menu, draw an arrow first 1156 // If this is a button with an associated popup menu, draw an arrow first
1157 if ( btn->popup() ) { 1157 if ( btn->popup() ) {
1158 int dx = menuButtonIndicatorWidth( btn->height() ); 1158 int dx = menuButtonIndicatorWidth( btn->height() );
1159 1159
1160 QColorGroup g( btn->colorGroup() ); 1160 QColorGroup g( btn->colorGroup() );
1161 int xx = x + w - dx - 4; 1161 int xx = x + w - dx - 4;
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}
1211 1211
1212void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, 1212void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h,
1213 const QColorGroup &g, Orientation ) 1213 const QColorGroup &g, Orientation )
1214{ 1214{
1215 drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, 1215 drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false,
1216 Splitter ); 1216 Splitter );
1217} 1217}
1218 1218
1219void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, 1219void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h,
1220 const QColorGroup &g, bool act, bool dis ) 1220 const QColorGroup &g, bool act, bool dis )
1221{ 1221{
1222 if ( isPixmap( CheckMark ) ) { 1222 if ( isPixmap( CheckMark ) ) {
1223 if ( !dis ) 1223 if ( !dis )
1224 p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, 1224 p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2,
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
1275 QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) 1274 QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem )
1276 : act ? *colorGroup( pal.active(), MenuItemDown ) 1275 : act ? *colorGroup( pal.active(), MenuItemDown )
1277 : *colorGroup( pal.normal(), MenuItem ); 1276 : *colorGroup( pal.normal(), MenuItem );
1278 1277
1279 maxpmw = QMAX( maxpmw, 20 ); 1278 maxpmw = QMAX( maxpmw, 20 );
1280 int checkcol = maxpmw; 1279 int checkcol = maxpmw;
1281 1280
1282 if ( mi && mi->isSeparator() ) { 1281 if ( mi && mi->isSeparator() ) {
1283 p->setPen( g.dark() ); 1282 p->setPen( g.dark() );
1284 p->drawLine( x, y, x + w, y ); 1283 p->drawLine( x, y, x + w, y );
1285 p->setPen( g.light() ); 1284 p->setPen( g.light() );
1286 p->drawLine( x, y + 1, x + w, y + 1 ); 1285 p->drawLine( x, y + 1, x + w, y + 1 );
1287 return ; 1286 return ;
1288 } 1287 }
1289 if ( act ) { 1288 if ( act ) {
1290 drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); 1289 drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown );
1291 } 1290 }
1292 else { 1291 else {
1293 drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, 1292 drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false,
1294 highlightWidth( MenuItem ), borderWidth( MenuItem ), 1293 highlightWidth( MenuItem ), borderWidth( MenuItem ),
1295 shade() ); 1294 shade() );
1296 int dw = decoWidth( MenuItem ); 1295 int dw = decoWidth( MenuItem );
1297 if ( !isPixmap( MenuItem ) ) { 1296 if ( !isPixmap( MenuItem ) ) {
1298 p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, 1297 p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2,
1299 colorGroup( g, MenuItem ) -> 1298 colorGroup( g, MenuItem ) ->
1300 brush( QColorGroup::Background ) ); 1299 brush( QColorGroup::Background ) );
1301 } 1300 }
1302 else { 1301 else {
1303 // process inactive item pixmaps as one large item 1302 // process inactive item pixmaps as one large item
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 );
1353 } 1356 }
1354 1357
1355 int xm = motifItemFrame + checkcol + motifItemHMargin; 1358 int xm = motifItemFrame + checkcol + motifItemHMargin;
1356 1359
1357 QString s = mi->text(); 1360 QString s = mi->text();
1358 if ( !s.isNull() ) { 1361 if ( !s.isNull() ) {
1359 int t = s.find( '\t' ); 1362 int t = s.find( '\t' );
1360 int m = motifItemVMargin; 1363 int m = motifItemVMargin;
1361 const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; 1364 const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
1362 if ( t >= 0 ) { 1365 if ( t >= 0 ) {
1363 if ( dis && !act ) { 1366 if ( dis && !act ) {
1364 p->setPen( g.light() ); 1367 p->setPen( g.light() );
1365 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, 1368 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1,
1366 y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); 1369 y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
1367 p->setPen( discol ); 1370 p->setPen( discol );
1368 } 1371 }
1369 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, 1372 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame,
1370 y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); 1373 y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
1371 } 1374 }
1372 if ( dis && !act ) { 1375 if ( dis && !act ) {
1373 p->setPen( g.light() ); 1376 p->setPen( g.light() );
1374 p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); 1377 p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t );
1375 p->setPen( discol ); 1378 p->setPen( discol );
1376 } 1379 }
1377 p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); 1380 p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t );
1378 } 1381 }
1379 else if ( mi->pixmap() ) { 1382 else if ( mi->pixmap() ) {
1380 QPixmap * pixmap = mi->pixmap(); 1383 QPixmap * pixmap = mi->pixmap();
1381 if ( pixmap->depth() == 1 ) 1384 if ( pixmap->depth() == 1 )
1382 p->setBackgroundMode( OpaqueMode ); 1385 p->setBackgroundMode( OpaqueMode );
1383 p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); 1386 p->drawPixmap( x + xm, y + motifItemFrame, *pixmap );
1384 if ( pixmap->depth() == 1 ) 1387 if ( pixmap->depth() == 1 )
1385 p->setBackgroundMode( TransparentMode ); 1388 p->setBackgroundMode( TransparentMode );
1386 } 1389 }
1387 if ( mi->popup() ) { 1390 if ( mi->popup() ) {
1388 int dim = ( h - 2 * motifItemFrame ) / 2; 1391 int dim = ( h - 2 * motifItemFrame ) / 2;
1389 if ( act ) { 1392 if ( act ) {
1390 if ( !dis ) 1393 if ( !dis )
1391 discol = colorGroup( g, MenuItemDown ) ->text(); 1394 discol = colorGroup( g, MenuItemDown ) ->text();
1392 //discol = white; 1395 //discol = white;
1393 QColorGroup g2( discol, g.highlight(), 1396 QColorGroup g2( discol, g.highlight(),
1394 white, white, 1397 white, white,
1395 dis ? discol : white, 1398 dis ? discol : white,
1396 discol, white ); 1399 discol, white );
1397 drawArrow( p, RightArrow, true, 1400 drawArrow( p, RightArrow, true,
1398 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, 1401 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
1399 dim, dim, g2, TRUE ); 1402 dim, dim, g2, TRUE );
1400 } 1403 }
1401 else { 1404 else {
1402 drawArrow( p, RightArrow, 1405 drawArrow( p, RightArrow,
1403 false, 1406 false,
1404 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, 1407 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
1405 dim, dim, g, mi->isEnabled() ); 1408 dim, dim, g, mi->isEnabled() );
1406 } 1409 }
1407 } 1410 }
1408} 1411}
1409 1412
1410void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, 1413void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r,
1411 const QColorGroup &g, const QColor *c, 1414 const QColorGroup &g, const QColor *c,
1412 bool atBorder ) 1415 bool atBorder )
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 );
1496} 1499}
1497 1500
1498void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , 1501void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t ,
1499 bool selected ) 1502 bool selected )
1500{ 1503{
1501 WidgetType widget = selected ? ActiveTab : InactiveTab; 1504 WidgetType widget = selected ? ActiveTab : InactiveTab;
1502 const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); 1505 const QColorGroup *cg = colorGroup( tb->colorGroup(), widget );
1503 int i; 1506 int i;
1504 int x = t->r.x(), y = t->r.y(); 1507 int x = t->r.x(), y = t->r.y();
1505 int x2 = t->r.right(), y2 = t->r.bottom(); 1508 int x2 = t->r.right(), y2 = t->r.bottom();
1506 int bWidth = borderWidth( widget ); 1509 int bWidth = borderWidth( widget );
1507 int hWidth = highlightWidth( widget ); 1510 int hWidth = highlightWidth( widget );
1508 if ( tb->shape() == QTabBar::RoundedAbove ) { 1511 if ( tb->shape() == QTabBar::RoundedAbove ) {
1509 if ( !selected ) { 1512 if ( !selected ) {
1510 p->fillRect( x, y, x2 - x + 1, 2, 1513 p->fillRect( x, y, x2 - x + 1, 2,
1511 tb->palette().normal().brush( QColorGroup::Background ) ); 1514 tb->palette().normal().brush( QColorGroup::Background ) );
1512 y += 2; 1515 y += 2;
1513 } 1516 }
1514 p->setPen( cg->text() ); 1517 p->setPen( cg->text() );
1515 i = 0; 1518 i = 0;
1516 if ( i < bWidth ) { 1519 if ( i < bWidth ) {
1517 p->drawLine( x, y + 1, x, y2 ); 1520 p->drawLine( x, y + 1, x, y2 );
1518 p->drawLine( x2, y + 1, x2, y2 ); 1521 p->drawLine( x2, y + 1, x2, y2 );
1519 p->drawLine( x + 1, y, x2 - 1, y ); 1522 p->drawLine( x + 1, y, x2 - 1, y );
1520 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1523 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1521 p->drawLine( x, y2, x2, y2 ); 1524 p->drawLine( x, y2, x2, y2 );
1522 --y2; 1525 --y2;
1523 } 1526 }
1524 ++i, ++x, ++y, --x2; 1527 ++i, ++x, ++y, --x2;
1525 } 1528 }
1526 for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { 1529 for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) {
1527 p->drawLine( x, y, x, y2 ); 1530 p->drawLine( x, y, x, y2 );
1528 p->drawLine( x2, y, x2, y2 ); 1531 p->drawLine( x2, y, x2, y2 );
1529 p->drawLine( x, y, x2, y ); 1532 p->drawLine( x, y, x2, y );
1530 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1533 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1531 p->drawLine( x, y2, x2, y2 ); 1534 p->drawLine( x, y2, x2, y2 );
1532 --y2; 1535 --y2;
1533 } 1536 }
1534 } 1537 }
1535 i = 0; 1538 i = 0;
1536 if ( i < hWidth && bWidth == 0 ) { 1539 if ( i < hWidth && bWidth == 0 ) {
1537 p->setPen( cg->light() ); 1540 p->setPen( cg->light() );
1538 p->drawLine( x, y + 1, x, y2 ); 1541 p->drawLine( x, y + 1, x, y2 );
1539 p->drawLine( x + 1, y, x2 - 1, y ); 1542 p->drawLine( x + 1, y, x2 - 1, y );
1540 p->setPen( cg->dark() ); 1543 p->setPen( cg->dark() );
1541 p->drawLine( x2, y + 1, x2, y2 ); 1544 p->drawLine( x2, y + 1, x2, y2 );
1542 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1545 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1543 p->drawLine( x, y2, x2, y2 ); 1546 p->drawLine( x, y2, x2, y2 );
1544 --y2; 1547 --y2;
1545 } 1548 }
1546 ++i, ++x, ++y, --x2; 1549 ++i, ++x, ++y, --x2;
1547 } 1550 }
1548 for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { 1551 for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) {
1549 p->setPen( cg->light() ); 1552 p->setPen( cg->light() );
1550 p->drawLine( x, y, x, y2 ); 1553 p->drawLine( x, y, x, y2 );
1551 p->drawLine( x, y, x2, y ); 1554 p->drawLine( x, y, x2, y );
1552 p->setPen( cg->dark() ); 1555 p->setPen( cg->dark() );
1553 p->drawLine( x2, y + 1, x2, y2 ); 1556 p->drawLine( x2, y + 1, x2, y2 );
1554 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1557 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1555 p->drawLine( x, y2, x2, y2 ); 1558 p->drawLine( x, y2, x2, y2 );
1556 --y2; 1559 --y2;
1557 } 1560 }
1558 } 1561 }
1559 if ( isPixmap( widget ) ) 1562 if ( isPixmap( widget ) )
1560 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, 1563 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
1561 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); 1564 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
1562 else 1565 else
1563 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); 1566 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
1564 } 1567 }
1565 else if ( tb->shape() == QTabBar::RoundedBelow ) { 1568 else if ( tb->shape() == QTabBar::RoundedBelow ) {
1566 if ( !selected ) { 1569 if ( !selected ) {
1567 p->fillRect( x, y2 - 2, x2 - x + 1, 2, 1570 p->fillRect( x, y2 - 2, x2 - x + 1, 2,
1568 tb->palette().normal().brush( QColorGroup::Background ) ); 1571 tb->palette().normal().brush( QColorGroup::Background ) );
1569 y2 -= 2; 1572 y2 -= 2;
1570 } 1573 }
1571 p->setPen( cg->text() ); 1574 p->setPen( cg->text() );
1572 i = 0; 1575 i = 0;
1573 if ( i < bWidth ) { 1576 if ( i < bWidth ) {
1574 p->drawLine( x, y, x, y2 - 1 ); 1577 p->drawLine( x, y, x, y2 - 1 );
1575 p->drawLine( x2, y, x2, y2 - 1 ); 1578 p->drawLine( x2, y, x2, y2 - 1 );
1576 p->drawLine( x + 1, y2, x2 - 1, y2 ); 1579 p->drawLine( x + 1, y2, x2 - 1, y2 );
1577 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1580 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1578 p->drawLine( x, y, x2, y ); 1581 p->drawLine( x, y, x2, y );
1579 ++y; 1582 ++y;
1580 } 1583 }
1581 } 1584 }
1582 for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { 1585 for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) {
1583 p->drawLine( x, y, x, y2 ); 1586 p->drawLine( x, y, x, y2 );
1584 p->drawLine( x2, y, x2, y2 ); 1587 p->drawLine( x2, y, x2, y2 );
1585 p->drawLine( x, y2, x2, y2 ); 1588 p->drawLine( x, y2, x2, y2 );
1586 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1589 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1587 p->drawLine( x, y, x2, y ); 1590 p->drawLine( x, y, x2, y );
1588 ++y; 1591 ++y;
1589 } 1592 }
1590 } 1593 }
1591 i = 0; 1594 i = 0;
1592 if ( i < hWidth && bWidth == 0 ) { 1595 if ( i < hWidth && bWidth == 0 ) {
1593 p->setPen( cg->dark() ); 1596 p->setPen( cg->dark() );
1594 p->drawLine( x + 1, y2, x2 - 1, y2 ); 1597 p->drawLine( x + 1, y2, x2 - 1, y2 );
1595 p->drawLine( x2, y, x2, y2 - 1 ); 1598 p->drawLine( x2, y, x2, y2 - 1 );
1596 p->setPen( cg->light() ); 1599 p->setPen( cg->light() );
1597 p->drawLine( x, y, x, y2 - 1 ); 1600 p->drawLine( x, y, x, y2 - 1 );
1598 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1601 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1599 p->drawLine( x, y, x2, y ); 1602 p->drawLine( x, y, x2, y );
1600 ++y; 1603 ++y;
1601 } 1604 }
1602 ++i, ++x, --x2, --y2; 1605 ++i, ++x, --x2, --y2;
1603 } 1606 }
1604 for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { 1607 for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) {
1605 p->setPen( cg->dark() ); 1608 p->setPen( cg->dark() );
1606 p->drawLine( x, y2, x2, y2 ); 1609 p->drawLine( x, y2, x2, y2 );
1607 p->drawLine( x2, y, x2, y2 ); 1610 p->drawLine( x2, y, x2, y2 );
1608 p->setPen( cg->light() ); 1611 p->setPen( cg->light() );
1609 p->drawLine( x, y, x, y2 ); 1612 p->drawLine( x, y, x, y2 );
1610 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1613 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1611 p->drawLine( x, y, x2, y ); 1614 p->drawLine( x, y, x2, y );
1612 ++y; 1615 ++y;
1613 } 1616 }
1614 } 1617 }
1615 if ( isPixmap( widget ) ) 1618 if ( isPixmap( widget ) )
1616 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, 1619 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
1617 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); 1620 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
1618 else 1621 else
1619 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); 1622 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
1620 } 1623 }
1621 else 1624 else
1622 QCommonStyle::drawTab( p, tb, t, selected ); 1625 QCommonStyle::drawTab( p, tb, t, selected );
1623} 1626}
1624 1627
1625void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, 1628void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t,
1626 bool selected ) 1629 bool selected )
1627{ 1630{
1628 QRect r( t->r ); 1631 QRect r( t->r );
1629 1632
1630 if ( tb->shape() == QTabBar::RoundedAbove ) { 1633 if ( tb->shape() == QTabBar::RoundedAbove ) {
1631 if ( !selected ) 1634 if ( !selected )
1632 r.setTop( r.top() + 2 ); 1635 r.setTop( r.top() + 2 );
1633 p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); 1636 p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() );
1634 QBrush b( color1, SolidPattern ); 1637 QBrush b( color1, SolidPattern );
1635 p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); 1638 p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b );
1636 } 1639 }
1637 else if ( tb->shape() == QTabBar::RoundedBelow ) { 1640 else if ( tb->shape() == QTabBar::RoundedBelow ) {
1638 if ( !selected ) 1641 if ( !selected )
1639 r.setBottom( r.bottom() - 2 ); 1642 r.setBottom( r.bottom() - 2 );
1640 p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); 1643 p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() );
1641 QBrush b( color1, SolidPattern ); 1644 QBrush b( color1, SolidPattern );
1642 p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); 1645 p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b );
1643 } 1646 }
1644 else 1647 else
1645 QCommonStyle::drawTabMask( p, tb, t, selected ); 1648 QCommonStyle::drawTabMask( p, tb, t, selected );
1646 1649
1647} 1650}
1648 1651
1649 1652
1650//#include "kthemestyle.moc" 1653//#include "kthemestyle.moc"
1651 1654
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
@@ -1,1183 +1,1303 @@
1/* 1/*
2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA. 17 * Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20#ifndef INCLUDE_MENUITEM_DEF 20#ifndef INCLUDE_MENUITEM_DEF
21#define INCLUDE_MENUITEM_DEF 21#define INCLUDE_MENUITEM_DEF
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(
70 const QScrollBar * sb, 79 const QScrollBar * sb,
71 int sliderStart, 80 int sliderStart,
72 int /* sliderMin */, 81 int /* sliderMin */,
73 int sliderMax, 82 int sliderMax,
74 int sliderLength, 83 int sliderLength,
75 int buttonDim, 84 int buttonDim,
76 QRect & rSub, 85 QRect & rSub,
77 QRect & rAdd, 86 QRect & rAdd,
78 QRect & rSubPage, 87 QRect & rSubPage,
79 QRect & rAddPage, 88 QRect & rAddPage,
80 QRect & rSlider 89 QRect & rSlider
81 ) 90 )
82{ 91{
83 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 92 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
84 93
85 int len = horizontal ? sb->width() : sb->height(); 94 int len = horizontal ? sb->width() : sb->height();
86 95
87 int extent = horizontal ? sb->height() : sb->width(); 96 int extent = horizontal ? sb->height() : sb->width();
88 97
89 QColorGroup g = sb->colorGroup(); 98 QColorGroup g = sb->colorGroup();
90 99
91 if (sliderStart > sliderMax) 100 if (sliderStart > sliderMax)
92 sliderStart = sliderMax; 101 sliderStart = sliderMax;
93 102
94 int sliderEnd = sliderStart + sliderLength; 103 int sliderEnd = sliderStart + sliderLength;
95 104
96 int addX, addY; 105 int addX, addY;
97 int subX, subY; 106 int subX, subY;
98 int subPageX, subPageY, subPageW, subPageH; 107 int subPageX, subPageY, subPageW, subPageH;
99 int addPageX, addPageY, addPageW, addPageH; 108 int addPageX, addPageY, addPageW, addPageH;
100 int sliderX, sliderY, sliderW, sliderH; 109 int sliderX, sliderY, sliderW, sliderH;
101 110
102 if (horizontal) 111 if (horizontal)
103 { 112 {
104 subY = 0; 113 subY = 0;
105 addY = 0; 114 addY = 0;
106 subX = 0; 115 subX = 0;
107 addX = buttonDim; 116 addX = buttonDim;
108 117
109 subPageX = buttonDim * 2; 118 subPageX = buttonDim * 2;
110 subPageY = 0; 119 subPageY = 0;
111 subPageW = sliderStart - 1; 120 subPageW = sliderStart - 1;
112 subPageH = extent; 121 subPageH = extent;
113 122
114 addPageX = sliderEnd; 123 addPageX = sliderEnd;
115 addPageY = 0; 124 addPageY = 0;
116 addPageW = len - sliderEnd; 125 addPageW = len - sliderEnd;
117 addPageH = extent; 126 addPageH = extent;
118 127
119 sliderX = sliderStart; 128 sliderX = sliderStart;
120 sliderY = 0; 129 sliderY = 0;
121 sliderW = sliderLength; 130 sliderW = sliderLength;
122 sliderH = extent; 131 sliderH = extent;
123 } 132 }
124 else 133 else
125 { 134 {
126 subX = 0; 135 subX = 0;
127 addX = 0; 136 addX = 0;
128 subY = len - buttonDim * 2; 137 subY = len - buttonDim * 2;
129 addY = len - buttonDim; 138 addY = len - buttonDim;
130 139
131 subPageX = 0; 140 subPageX = 0;
132 subPageY = 0; 141 subPageY = 0;
133 subPageW = extent; 142 subPageW = extent;
134 subPageH = sliderStart; 143 subPageH = sliderStart;
135 144
136 addPageX = 0; 145 addPageX = 0;
137 addPageY = sliderEnd; 146 addPageY = sliderEnd;
138 addPageW = extent; 147 addPageW = extent;
139 addPageH = subY - sliderEnd; 148 addPageH = subY - sliderEnd;
140 149
141 sliderX = 0; 150 sliderX = 0;
142 sliderY = sliderStart; 151 sliderY = sliderStart;
143 sliderW = extent; 152 sliderW = extent;
144 sliderH = sliderLength; 153 sliderH = sliderLength;
145 } 154 }
146 155
147 rSub .setRect( subX, subY, buttonDim, buttonDim); 156 rSub .setRect( subX, subY, buttonDim, buttonDim);
148 rAdd .setRect( addX, addY, buttonDim, buttonDim); 157 rAdd .setRect( addX, addY, buttonDim, buttonDim);
149 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH); 158 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
150 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH); 159 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
151 rSlider .setRect( sliderX, sliderY, sliderW, sliderH); 160 rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
152} 161}
153 162
154// Rounded rects my way. 163// Rounded rects my way.
155 164
156 static void 165 static void
157drawFunkyRect 166drawFunkyRect
158( 167(
159 QPainter * p, 168 QPainter * p,
160 int x, 169 int x,
161 int y, 170 int y,
162 int w, 171 int w,
163 int h, 172 int h,
164 bool small 173 bool small
165) 174)
166{ 175{
167 p->translate(x, y); 176 p->translate(x, y);
168 177
169 if (small) 178 if (small)
170 { 179 {
171 p->drawLine( 2, 0, w - 3, 0 ); 180 p->drawLine( 2, 0, w - 3, 0 );
172 p->drawLine( w - 1, 2, w - 1, h - 3 ); 181 p->drawLine( w - 1, 2, w - 1, h - 3 );
173 p->drawLine( w - 3, h - 1, 2, h - 1 ); 182 p->drawLine( w - 3, h - 1, 2, h - 1 );
174 p->drawLine( 0, h - 3, 0, 2 ); 183 p->drawLine( 0, h - 3, 0, 2 );
175 184
176 // Use an array of points so that there's only one round-trip with the 185 // Use an array of points so that there's only one round-trip with the
177 // X server. 186 // X server.
178 187
179 QCOORD pointList[] = 188 QCOORD pointList[] =
180 { 189 {
181 1, 1, 190 1, 1,
182 w - 2, 1, 191 w - 2, 1,
183 w - 2, h - 2, 192 w - 2, h - 2,
184 1, h - 2 193 1, h - 2
185 }; 194 };
186 195
187 p->drawPoints(QPointArray(4, pointList)); 196 p->drawPoints(QPointArray(4, pointList));
188 } 197 }
189 else 198 else
190 { 199 {
191 p->drawLine( 3, 0, w - 4, 0 ); 200 p->drawLine( 3, 0, w - 4, 0 );
192 p->drawLine( w - 1, 3, w - 1, h - 4 ); 201 p->drawLine( w - 1, 3, w - 1, h - 4 );
193 p->drawLine( w - 4, h - 1, 3, h - 1 ); 202 p->drawLine( w - 4, h - 1, 3, h - 1 );
194 p->drawLine( 0, h - 4, 0, 3 ); 203 p->drawLine( 0, h - 4, 0, 3 );
195 204
196 QCOORD pointList[] = 205 QCOORD pointList[] =
197 { 206 {
198 1, 2, 207 1, 2,
199 2, 1, 208 2, 1,
200 w - 3, 1, 209 w - 3, 1,
201 w - 2, 2, 210 w - 2, 2,
202 w - 2, h - 3, 211 w - 2, h - 3,
203 w - 3, h - 2, 212 w - 3, h - 2,
204 2, h - 2, 213 2, h - 2,
205 1, h - 3 214 1, h - 3
206 }; 215 };
207 216
208 p->drawPoints(QPointArray(8, pointList)); 217 p->drawPoints(QPointArray(8, pointList));
209 } 218 }
210 219
211 p->translate(-x, -y); 220 p->translate(-x, -y);
212} 221}
213 222
214WebStyle::WebStyle() 223WebStyle::WebStyle()
215 : QWindowsStyle() 224 : QWindowsStyle()
216{ 225{
217 setButtonDefaultIndicatorWidth(1); 226 setButtonDefaultIndicatorWidth(1);
218 setScrollBarExtent(_scrollBarExtent, _scrollBarExtent); 227 setScrollBarExtent(_scrollBarExtent, _scrollBarExtent);
219 setButtonMargin( 3 ); 228 setButtonMargin( 3 );
220 setSliderThickness(_scrollBarExtent ); 229 setSliderThickness(_scrollBarExtent );
221} 230}
222 231
223WebStyle::~WebStyle() 232WebStyle::~WebStyle()
224{ 233{
225 // Empty. 234 // Empty.
226} 235}
227 236
228 void 237 void
229WebStyle::polish(QApplication *) 238WebStyle::polish(QApplication *)
230{ 239{
231 // Empty. 240 // Empty.
232} 241}
233 242
234 void 243 void
235WebStyle::polish(QPalette &) 244WebStyle::polish(QPalette &)
236{ 245{
237 // Empty. 246 // Empty.
238} 247}
239 248
240 void 249 void
241WebStyle::unPolish(QApplication *) 250WebStyle::unPolish(QApplication *)
242{ 251{
243 // Empty. 252 // Empty.
244} 253}
245 254
246 void 255 void
247WebStyle::polish(QWidget * w) 256WebStyle::polish(QWidget * w)
248{ 257{
249 if (w->inherits("QPushButton")) 258 if (w->inherits("QPushButton"))
250 w->installEventFilter(this); 259 w->installEventFilter(this);
251 260
252 else if (w->inherits("QGroupBox") || w->inherits("QFrame")) 261 else if (w->inherits("QGroupBox") || w->inherits("QFrame"))
253 { 262 {
254 QFrame * f(static_cast<QFrame *>(w)); 263 QFrame * f(static_cast<QFrame *>(w));
255 264
256 if (f->frameStyle() != QFrame::NoFrame) 265 if (f->frameStyle() != QFrame::NoFrame)
257 { 266 {
258 _currentFrame = f; 267 _currentFrame = f;
259 268
260 _savedFrameLineWidth = f->lineWidth(); 269 _savedFrameLineWidth = f->lineWidth();
261 _savedFrameMidLineWidth = f->midLineWidth(); 270 _savedFrameMidLineWidth = f->midLineWidth();
262 _savedFrameStyle = f->frameStyle(); 271 _savedFrameStyle = f->frameStyle();
263 272
264 if (f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine) 273 if (f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine)
265 { 274 {
266 f->setMidLineWidth(1); 275 f->setMidLineWidth(1);
267 f->setFrameStyle(f->frameShape() | QFrame::Plain); 276 f->setFrameStyle(f->frameShape() | QFrame::Plain);
268 } 277 }
269 else 278 else
270 { 279 {
271 f->setLineWidth(1); 280 f->setLineWidth(1);
272 f->setFrameStyle(QFrame::Box | QFrame::Plain); 281 f->setFrameStyle(QFrame::Box | QFrame::Plain);
273 } 282 }
274 } 283 }
275 } 284 }
276} 285}
277 286
278 void 287 void
279WebStyle::unPolish(QWidget * w) 288WebStyle::unPolish(QWidget * w)
280{ 289{
281 if (w->inherits("QPushButton")) 290 if (w->inherits("QPushButton"))
282 w->removeEventFilter(this); 291 w->removeEventFilter(this);
283 292
284 else if (w == _currentFrame) 293 else if (w == _currentFrame)
285 { 294 {
286 QFrame * f(static_cast<QFrame *>(w)); 295 QFrame * f(static_cast<QFrame *>(w));
287 296
288 f->setLineWidth(_savedFrameLineWidth); 297 f->setLineWidth(_savedFrameLineWidth);
289 f->setMidLineWidth(_savedFrameMidLineWidth); 298 f->setMidLineWidth(_savedFrameMidLineWidth);
290 f->setFrameStyle(_savedFrameStyle); 299 f->setFrameStyle(_savedFrameStyle);
291 } 300 }
292} 301}
293 302
294 bool 303 bool
295WebStyle::eventFilter(QObject * o, QEvent * e) 304WebStyle::eventFilter(QObject * o, QEvent * e)
296{ 305{
297 QPushButton * pb(static_cast<QPushButton *>(o)); 306 QPushButton * pb(static_cast<QPushButton *>(o));
298 307
299 if (e->type() == QEvent::Enter) 308 if (e->type() == QEvent::Enter)
300 { 309 {
301 _highlightedButton = pb; 310 _highlightedButton = pb;
302 pb->repaint(false); 311 pb->repaint(false);
303 } 312 }
304 else if (e->type() == QEvent::Leave) 313 else if (e->type() == QEvent::Leave)
305 { 314 {
306 _highlightedButton = 0; 315 _highlightedButton = 0;
307 pb->repaint(false); 316 pb->repaint(false);
308 } 317 }
309 318
310 return false; 319 return false;
311} 320}
312 321
313 void 322 void
314WebStyle::drawButton 323WebStyle::drawButton
315( 324(
316 QPainter * p, 325 QPainter * p,
317 int x, 326 int x,
318 int y, 327 int y,
319 int w, 328 int w,
320 int h, 329 int h,
321 const QColorGroup & g, 330 const QColorGroup & g,
322 bool sunken, 331 bool sunken,
323 const QBrush * fill 332 const QBrush * fill
324) 333)
325{ 334{
326 p->save(); 335 p->save();
327 336
328 if (sunken) 337 if (sunken)
329 p->setPen(contrastingForeground(g.light(), g.button())); 338 p->setPen(contrastingForeground(g.light(), g.button()));
330 else 339 else
331 p->setPen(contrastingForeground(g.mid(), g.button())); 340 p->setPen(contrastingForeground(g.mid(), g.button()));
332 341
333 p->setBrush(0 == fill ? NoBrush : *fill); 342 p->setBrush(0 == fill ? NoBrush : *fill);
334 343
335 drawFunkyRect(p, x, y, w, h, true); 344 drawFunkyRect(p, x, y, w, h, true);
336 345
337 p->restore(); 346 p->restore();
338} 347}
339 348
340 QRect 349 QRect
341WebStyle::buttonRect(int x, int y, int w, int h) 350WebStyle::buttonRect(int x, int y, int w, int h)
342{ 351{
343 return QRect(x + 2, y + 2, w - 4, h - 4); 352 return QRect(x + 2, y + 2, w - 4, h - 4);
344} 353}
345 354
346 void 355 void
347WebStyle::drawBevelButton 356WebStyle::drawBevelButton
348( 357(
349 QPainter * p, 358 QPainter * p,
350 int x, 359 int x,
351 int y, 360 int y,
352 int w, 361 int w,
353 int h, 362 int h,
354 const QColorGroup & g, 363 const QColorGroup & g,
355 bool sunken, 364 bool sunken,
356 const QBrush * fill 365 const QBrush * fill
357) 366)
358{ 367{
359 drawButton(p, x, y, w, h, g, sunken, fill); 368 drawButton(p, x, y, w, h, g, sunken, fill);
360} 369}
361 370
362 void 371 void
363WebStyle::drawPushButton(QPushButton * b, QPainter * p) 372WebStyle::drawPushButton(QPushButton * b, QPainter * p)
364{ 373{
365 // Note: painter is already translated for us. 374 // Note: painter is already translated for us.
366 375
367 bool sunken(b->isDown() || b->isOn()); 376 bool sunken(b->isDown() || b->isOn());
368 bool hl(_highlightedButton == b); 377 bool hl(_highlightedButton == b);
369 378
370 QColor bg(b->colorGroup().button()); 379 QColor bg(b->colorGroup().button());
371 380
372 p->save(); 381 p->save();
373 p->fillRect(b->rect(), b->colorGroup().brush(QColorGroup::Background)); 382 p->fillRect(b->rect(), b->colorGroup().brush(QColorGroup::Background));
374 383
375 if (b->isDefault()) 384 if (b->isDefault())
376 { 385 {
377 QColor c(hl ? b->colorGroup().highlight() : b->colorGroup().mid()); 386 QColor c(hl ? b->colorGroup().highlight() : b->colorGroup().mid());
378 387
379 p->setPen(contrastingForeground(c, bg)); 388 p->setPen(contrastingForeground(c, bg));
380 389
381 drawFunkyRect(p, 0, 0, b->width(), b->height(), false); 390 drawFunkyRect(p, 0, 0, b->width(), b->height(), false);
382 } 391 }
383 392
384 p->fillRect 393 p->fillRect
385 ( 394 (
386 4, 395 4,
387 4, 396 4,
388 b->width() - 8, 397 b->width() - 8,
389 b->height() - 8, 398 b->height() - 8,
390 b->colorGroup().brush(QColorGroup::Button) 399 b->colorGroup().brush(QColorGroup::Button)
391 ); 400 );
392 401
393 if (b->isEnabled()) 402 if (b->isEnabled())
394 { 403 {
395 if (sunken) 404 if (sunken)
396 { 405 {
397 p->setPen(contrastingForeground(b->colorGroup().light(), bg)); 406 p->setPen(contrastingForeground(b->colorGroup().light(), bg));
398 } 407 }
399 else 408 else
400 { 409 {
401 if (hl) 410 if (hl)
402 p->setPen(contrastingForeground(b->colorGroup().highlight(), bg)); 411 p->setPen(contrastingForeground(b->colorGroup().highlight(), bg));
403 else 412 else
404 p->setPen(contrastingForeground(b->colorGroup().mid(), bg)); 413 p->setPen(contrastingForeground(b->colorGroup().mid(), bg));
405 } 414 }
406 } 415 }
407 else 416 else
408 { 417 {
409 p->setPen(b->colorGroup().button()); 418 p->setPen(b->colorGroup().button());
410 } 419 }
411 420
412 drawFunkyRect(p, 3, 3, b->width() - 6, b->height() - 6, true); 421 drawFunkyRect(p, 3, 3, b->width() - 6, b->height() - 6, true);
413 422
414 p->restore(); 423 p->restore();
415} 424}
416 425
417 void 426 void
418WebStyle::drawPushButtonLabel(QPushButton * b, QPainter * p) 427WebStyle::drawPushButtonLabel(QPushButton * b, QPainter * p)
419{ 428{
420 // This is complicated stuff and we don't really want to mess with it. 429 // This is complicated stuff and we don't really want to mess with it.
421 430
422 QWindowsStyle::drawPushButtonLabel(b, p); 431 QWindowsStyle::drawPushButtonLabel(b, p);
423} 432}
424 433
425 void 434 void
426WebStyle::drawScrollBarControls 435WebStyle::drawScrollBarControls
427( 436(
428 QPainter * p, 437 QPainter * p,
429 const QScrollBar * sb, 438 const QScrollBar * sb,
430 int sliderStart, 439 int sliderStart,
431 uint controls, 440 uint controls,
432 uint activeControl 441 uint activeControl
433) 442)
434{ 443{
435 p->save(); 444 p->save();
436 445
437 int sliderMin, sliderMax, sliderLength, buttonDim; 446 int sliderMin, sliderMax, sliderLength, buttonDim;
438 447
439 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 448 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
440 449
441 QRect rSub, rAdd, rSubPage, rAddPage, rSlider; 450 QRect rSub, rAdd, rSubPage, rAddPage, rSlider;
442 451
443 scrollBarControlsMetrics 452 scrollBarControlsMetrics
444 ( 453 (
445 sb, 454 sb,
446 sliderStart, 455 sliderStart,
447 sliderMin, 456 sliderMin,
448 sliderMax, 457 sliderMax,
449 sliderLength, 458 sliderLength,
450 buttonDim, 459 buttonDim,
451 rSub, 460 rSub,
452 rAdd, 461 rAdd,
453 rSubPage, 462 rSubPage,
454 rAddPage, 463 rAddPage,
455 rSlider 464 rSlider
456 ); 465 );
457 466
458 QColorGroup g(sb->colorGroup()); 467 QColorGroup g(sb->colorGroup());
459 468
460 if (controls & AddLine && rAdd.isValid()) 469 if (controls & AddLine && rAdd.isValid())
461 { 470 {
462 bool active(activeControl & AddLine); 471 bool active(activeControl & AddLine);
463 472
464 QColor c(active ? g.highlight() : g.dark()); 473 QColor c(active ? g.highlight() : g.dark());
465 474
466 p->setPen(c); 475 p->setPen(c);
467 p->setBrush(g.button()); 476 p->setBrush(g.button());
468 p->drawRect(rAdd); 477 p->drawRect(rAdd);
469 478
470 Qt::ArrowType t = 479 Qt::ArrowType t =
471 sb->orientation() == Horizontal ? Qt::RightArrow : Qt::DownArrow; 480 sb->orientation() == Horizontal ? Qt::RightArrow : Qt::DownArrow;
472 481
473 // Is it me or is KStyle::drawArrow broken ? 482 // Is it me or is KStyle::drawArrow broken ?
474 483
475 drawArrow 484 drawArrow
476 ( 485 (
477 p, 486 p,
478 t, 487 t,
479 true, // FIXME - down ? 488 true, // FIXME - down ?
480 rAdd.x(), 489 rAdd.x(),
481 rAdd.y(), 490 rAdd.y(),
482 rAdd.width(), 491 rAdd.width(),
483 rAdd.height(), 492 rAdd.height(),
484 g, 493 g,
485 true // FIXME - enabled ? 494 true // FIXME - enabled ?
486 ); 495 );
487 } 496 }
488 497
489 if (controls & SubLine && rSub.isValid()) 498 if (controls & SubLine && rSub.isValid())
490 { 499 {
491 bool active(activeControl & SubLine); 500 bool active(activeControl & SubLine);
492 501
493 QColor c(active ? g.highlight() : g.dark()); 502 QColor c(active ? g.highlight() : g.dark());
494 503
495 p->setPen(c); 504 p->setPen(c);
496 p->setBrush(g.button()); 505 p->setBrush(g.button());
497 p->drawRect(rSub); 506 p->drawRect(rSub);
498 507
499 Qt::ArrowType t = 508 Qt::ArrowType t =
500 sb->orientation() == Horizontal ? Qt::LeftArrow : Qt::UpArrow; 509 sb->orientation() == Horizontal ? Qt::LeftArrow : Qt::UpArrow;
501 510
502 drawArrow 511 drawArrow
503 ( 512 (
504 p, 513 p,
505 t, 514 t,
506 true, // FIXME - down ? 515 true, // FIXME - down ?
507 rSub.x(), 516 rSub.x(),
508 rSub.y(), 517 rSub.y(),
509 rSub.width(), 518 rSub.width(),
510 rSub.height(), 519 rSub.height(),
511 g, 520 g,
512 true // FIXME - enabled ? 521 true // FIXME - enabled ?
513 ); 522 );
514 } 523 }
515 524
516 if (controls & SubPage && rSubPage.isValid()) 525 if (controls & SubPage && rSubPage.isValid())
517 { 526 {
518 p->setPen(g.mid()); 527 p->setPen(g.mid());
519 p->setBrush(g.base()); 528 p->setBrush(g.base());
520 p->drawRect(rSubPage); 529 p->drawRect(rSubPage);
521 } 530 }
522 531
523 if (controls & AddPage && rAddPage.isValid()) 532 if (controls & AddPage && rAddPage.isValid())
524 { 533 {
525 p->setPen(g.mid()); 534 p->setPen(g.mid());
526 p->setBrush(g.base()); 535 p->setBrush(g.base());
527 p->drawRect(rAddPage); 536 p->drawRect(rAddPage);
528 } 537 }
529 538
530 if (controls & Slider && rSlider.isValid()) 539 if (controls & Slider && rSlider.isValid())
531 { 540 {
532 p->setPen(activeControl & Slider ? g.highlight() : g.dark()); 541 p->setPen(activeControl & Slider ? g.highlight() : g.dark());
533 542
534 p->setBrush(g.button()); 543 p->setBrush(g.button());
535 p->drawRect(rSlider); 544 p->drawRect(rSlider);
536 545
537 p->setBrush(g.light()); 546 p->setBrush(g.light());
538 p->setPen(g.dark()); 547 p->setPen(g.dark());
539 548
540 if (sliderLength > _scrollBarExtent * 2) 549 if (sliderLength > _scrollBarExtent * 2)
541 { 550 {
542 int ellipseSize = 551 int ellipseSize =
543 Horizontal == sb->orientation() 552 Horizontal == sb->orientation()
544 ? 553 ?
545 rSlider.height() - 4 554 rSlider.height() - 4
546 : 555 :
547 rSlider.width() - 4 556 rSlider.width() - 4
548 ; 557 ;
549 558
550 QPoint center(rSlider.center()); 559 QPoint center(rSlider.center());
551 560
552 if (Horizontal == sb->orientation()) 561 if (Horizontal == sb->orientation())
553 { 562 {
554 p->drawEllipse 563 p->drawEllipse
555 ( 564 (
556 center.x() - ellipseSize / 2, rSlider.y() + 2, 565 center.x() - ellipseSize / 2, rSlider.y() + 2,
557 ellipseSize, ellipseSize 566 ellipseSize, ellipseSize
558 ); 567 );
559 } 568 }
560 else 569 else
561 { 570 {
562 p->drawEllipse 571 p->drawEllipse
563 ( 572 (
564 rSlider.x() + 2, center.y() - ellipseSize / 2, 573 rSlider.x() + 2, center.y() - ellipseSize / 2,
565 ellipseSize, ellipseSize 574 ellipseSize, ellipseSize
566 ); 575 );
567 } 576 }
568 } 577 }
569 } 578 }
570 579
571 p->restore(); 580 p->restore();
572} 581}
573 582
574 QStyle::ScrollControl 583 QStyle::ScrollControl
575WebStyle::scrollBarPointOver 584WebStyle::scrollBarPointOver
576( 585(
577 const QScrollBar * sb, 586 const QScrollBar * sb,
578 int sliderStart, 587 int sliderStart,
579 const QPoint & point 588 const QPoint & point
580) 589)
581{ 590{
582 if (!sb->rect().contains(point)) 591 if (!sb->rect().contains(point))
583 return NoScroll; 592 return NoScroll;
584 593
585 int sliderMin, sliderMax, sliderLength, buttonDim; 594 int sliderMin, sliderMax, sliderLength, buttonDim;
586 595
587 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 596 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
588 597
589 if (sb->orientation() == QScrollBar::Horizontal) 598 if (sb->orientation() == QScrollBar::Horizontal)
590 { 599 {
591 int x = point.x(); 600 int x = point.x();
592 601
593 if (x <= buttonDim) 602 if (x <= buttonDim)
594 return SubLine; 603 return SubLine;
595 604
596 else if (x <= buttonDim * 2) 605 else if (x <= buttonDim * 2)
597 return AddLine; 606 return AddLine;
598 607
599 else if (x < sliderStart) 608 else if (x < sliderStart)
600 return SubPage; 609 return SubPage;
601 610
602 else if (x < sliderStart+sliderLength) 611 else if (x < sliderStart+sliderLength)
603 return Slider; 612 return Slider;
604 613
605 return AddPage; 614 return AddPage;
606 } 615 }
607 else 616 else
608 { 617 {
609 int y = point.y(); 618 int y = point.y();
610 619
611 if (y < sliderStart) 620 if (y < sliderStart)
612 return SubPage; 621 return SubPage;
613 622
614 else if (y < sliderStart + sliderLength) 623 else if (y < sliderStart + sliderLength)
615 return Slider; 624 return Slider;
616 625
617 else if (y < sliderMax + sliderLength) 626 else if (y < sliderMax + sliderLength)
618 return AddPage; 627 return AddPage;
619 628
620 else if (y < sliderMax + sliderLength + buttonDim) 629 else if (y < sliderMax + sliderLength + buttonDim)
621 return SubLine; 630 return SubLine;
622 631
623 return AddLine; 632 return AddLine;
624 } 633 }
625} 634}
626 635
627 void 636 void
628WebStyle::scrollBarMetrics 637WebStyle::scrollBarMetrics
629( 638(
630 const QScrollBar * sb, 639 const QScrollBar * sb,
631 int & sliderMin, 640 int & sliderMin,
632 int & sliderMax, 641 int & sliderMax,
633 int & sliderLength, 642 int & sliderLength,
634 int & buttonDim 643 int & buttonDim
635) 644)
636{ 645{
637// return QWindowsStyle::scrollBarMetrics(sb, sliderMin, sliderMax, 646// return QWindowsStyle::scrollBarMetrics(sb, sliderMin, sliderMax,
638// sliderLength, buttonDim ); 647// sliderLength, buttonDim );
639 int maxlen; 648 int maxlen;
640 649
641 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 650 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
642 651
643 int len = (horizontal) ? sb->width() : sb->height(); 652 int len = (horizontal) ? sb->width() : sb->height();
644 653
645 int extent = (horizontal) ? sb->height() : sb->width(); 654 int extent = (horizontal) ? sb->height() : sb->width();
646 655
647 if (len > (extent - 1) * 2) 656 if (len > (extent - 1) * 2)
648 buttonDim = extent; 657 buttonDim = extent;
649 else 658 else
650 buttonDim = len / 2 - 1; 659 buttonDim = len / 2 - 1;
651 660
652 if (horizontal) 661 if (horizontal)
653 sliderMin = buttonDim * 2; 662 sliderMin = buttonDim * 2;
654 else 663 else
655 sliderMin = 1; 664 sliderMin = 1;
656 665
657 maxlen = len - buttonDim * 2 - 1; 666 maxlen = len - buttonDim * 2 - 1;
658 667
659 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) ); 668 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) );
660 669
661 sliderLength = 670 sliderLength =
662 (sb->pageStep() * maxlen) / div; 671 (sb->pageStep() * maxlen) / div;
663 672
664 if (sliderLength < _scrollBarExtent) 673 if (sliderLength < _scrollBarExtent)
665 sliderLength = _scrollBarExtent; 674 sliderLength = _scrollBarExtent;
666 675
667 if (sliderLength > maxlen) 676 if (sliderLength > maxlen)
668 sliderLength = maxlen; 677 sliderLength = maxlen;
669 678
670 sliderMax = sliderMin + maxlen - sliderLength; 679 sliderMax = sliderMin + maxlen - sliderLength;
671} 680}
672 681
673 QSize 682 QSize
674WebStyle::indicatorSize() const 683WebStyle::indicatorSize() const
675{ 684{
676 return QSize(_indicatorSize, _indicatorSize); 685 return QSize(_indicatorSize, _indicatorSize);
677} 686}
678 687
679 void 688 void
680WebStyle::drawIndicator 689WebStyle::drawIndicator
681( 690(
682 QPainter * p, 691 QPainter * p,
683 int x, 692 int x,
684 int y, 693 int y,
685 int w, 694 int w,
686 int h, 695 int h,
687 const QColorGroup & g, 696 const QColorGroup & g,
688 int state, 697 int state,
689 bool down, 698 bool down,
690 bool enabled 699 bool enabled
691) 700)
692{ 701{
693 p->save(); 702 p->save();
694 703
695 p->fillRect(x, y, w, h, g.background()); 704 p->fillRect(x, y, w, h, g.background());
696 705
697 if (enabled) 706 if (enabled)
698 { 707 {
699 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background())); 708 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background()));
700 } 709 }
701 else 710 else
702 { 711 {
703 g.mid(); 712 g.mid();
704 } 713 }
705 714
706 p->drawRect(x, y, w, h); 715 p->drawRect(x, y, w, h);
707 716
708 if (state != QButton::Off) 717 if (state != QButton::Off)
709 { 718 {
710 p->fillRect(x + 2, y + 2, w - 4, h - 4, enabled ? g.highlight() : g.mid()); 719 p->fillRect(x + 2, y + 2, w - 4, h - 4, enabled ? g.highlight() : g.mid());
711 720
712 if (state == QButton::NoChange) 721 if (state == QButton::NoChange)
713 { 722 {
714 p->fillRect(x + 4, y + 4, w - 8, h - 8, g.background()); 723 p->fillRect(x + 4, y + 4, w - 8, h - 8, g.background());
715 } 724 }
716 } 725 }
717 726
718 p->restore(); 727 p->restore();
719} 728}
720 729
721 QSize 730 QSize
722WebStyle::exclusiveIndicatorSize() const 731WebStyle::exclusiveIndicatorSize() const
723{ 732{
724 return QSize(_indicatorSize+2, _indicatorSize+2); 733 return QSize(_indicatorSize+2, _indicatorSize+2);
725} 734}
726 735
727 void 736 void
728WebStyle::drawExclusiveIndicator 737WebStyle::drawExclusiveIndicator
729( 738(
730 QPainter * p, 739 QPainter * p,
731 int x, 740 int x,
732 int y, 741 int y,
733 int w, 742 int w,
734 int h, 743 int h,
735 const QColorGroup & g, 744 const QColorGroup & g,
736 bool on, 745 bool on,
737 bool down, 746 bool down,
738 bool enabled 747 bool enabled
739) 748)
740{ 749{
741 p->save(); 750 p->save();
742 751
743 p->fillRect(x, y, w, h, g.background()); 752 p->fillRect(x, y, w, h, g.background());
744 753
745 if (enabled) 754 if (enabled)
746 { 755 {
747 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background())); 756 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background()));
748 } 757 }
749 else 758 else
750 { 759 {
751 p->setPen(g.mid()); 760 p->setPen(g.mid());
752 } 761 }
753 762
754 p->setBrush(g.brush(QColorGroup::Background)); 763 p->setBrush(g.brush(QColorGroup::Background));
755 764
756 // Avoid misshapen ellipses. Qt or X bug ? Who knows... 765 // Avoid misshapen ellipses. Qt or X bug ? Who knows...
757 766
758 if (0 == w % 2) 767 if (0 == w % 2)
759 --w; 768 --w;
760 769
761 if (0 == h % 2) 770 if (0 == h % 2)
762 --h; 771 --h;
763 772
764 p->drawEllipse(x, y, w, h); 773 p->drawEllipse(x, y, w, h);
765 774
766 if (on) 775 if (on)
767 { 776 {
768 p->setPen(enabled ? g.highlight() : g.mid()); 777 p->setPen(enabled ? g.highlight() : g.mid());
769 p->setBrush(enabled ? g.highlight() : g.mid()); 778 p->setBrush(enabled ? g.highlight() : g.mid());
770 p->drawEllipse(x + 3, y + 3, w - 6, h - 6); 779 p->drawEllipse(x + 3, y + 3, w - 6, h - 6);
771 } 780 }
772 781
773 p->restore(); 782 p->restore();
774} 783}
775 784
776 void 785 void
777WebStyle::drawIndicatorMask 786WebStyle::drawIndicatorMask
778( 787(
779 QPainter * p, 788 QPainter * p,
780 int x, 789 int x,
781 int y, 790 int y,
782 int w, 791 int w,
783 int h, 792 int h,
784 int /* state */ 793 int /* state */
785) 794)
786{ 795{
787 p->fillRect(x, y, w, h, Qt::color1); 796 p->fillRect(x, y, w, h, Qt::color1);
788} 797}
789 798
790 void 799 void
791WebStyle::drawExclusiveIndicatorMask 800WebStyle::drawExclusiveIndicatorMask
792( 801(
793 QPainter * p, 802 QPainter * p,
794 int x, 803 int x,
795 int y, 804 int y,
796 int w, 805 int w,
797 int h, 806 int h,
798 bool /* on */ 807 bool /* on */
799) 808)
800{ 809{
801 if (0 == w % 2) 810 if (0 == w % 2)
802 --w; 811 --w;
803 812
804 if (0 == h % 2) 813 if (0 == h % 2)
805 --h; 814 --h;
806 815
807 p->setPen(Qt::color1); 816 p->setPen(Qt::color1);
808 p->setBrush(Qt::color1); 817 p->setBrush(Qt::color1);
809 p->drawEllipse(x, y, w, h); 818 p->drawEllipse(x, y, w, h);
810} 819}
811 820
812 void 821 void
813WebStyle::drawComboButton 822WebStyle::drawComboButton
814( 823(
815 QPainter * p, 824 QPainter * p,
816 int x, 825 int x,
817 int y, 826 int y,
818 int w, 827 int w,
819 int h, 828 int h,
820 const QColorGroup & g, 829 const QColorGroup & g,
821 bool sunken, 830 bool sunken,
822 bool editable, 831 bool editable,
823 bool enabled, 832 bool enabled,
824 const QBrush * fill 833 const QBrush * fill
825) 834)
826{ 835{
827 p->save(); 836 p->save();
828 837
829 p->setPen(NoPen); 838 p->setPen(NoPen);
830 p->setBrush(0 == fill ? g.brush(QColorGroup::Background) : *fill); 839 p->setBrush(0 == fill ? g.brush(QColorGroup::Background) : *fill);
831 p->drawRect(x, y, w, h); 840 p->drawRect(x, y, w, h);
832 841
833 if (enabled) 842 if (enabled)
834 { 843 {
835 if (sunken) 844 if (sunken)
836 p->setPen(contrastingForeground(g.highlight(), g.background())); 845 p->setPen(contrastingForeground(g.highlight(), g.background()));
837 else 846 else
838 p->setPen(contrastingForeground(g.mid(), g.background())); 847 p->setPen(contrastingForeground(g.mid(), g.background()));
839 } 848 }
840 else 849 else
841 { 850 {
842 p->setPen(contrastingForeground(g.mid(), g.background())); 851 p->setPen(contrastingForeground(g.mid(), g.background()));
843 } 852 }
844 853
845 drawFunkyRect(p, x, y, w, h, true); 854 drawFunkyRect(p, x, y, w, h, true);
846 855
847 p->drawPoint(w - 10, h - 6); 856 p->drawPoint(w - 10, h - 6);
848 p->drawPoint(w - 9, h - 6); 857 p->drawPoint(w - 9, h - 6);
849 p->drawPoint(w - 8, h - 6); 858 p->drawPoint(w - 8, h - 6);
850 p->drawPoint(w - 7, h - 6); 859 p->drawPoint(w - 7, h - 6);
851 p->drawPoint(w - 6, h - 6); 860 p->drawPoint(w - 6, h - 6);
852 861
853 p->drawPoint(w - 9, h - 7); 862 p->drawPoint(w - 9, h - 7);
854 p->drawPoint(w - 8, h - 7); 863 p->drawPoint(w - 8, h - 7);
855 p->drawPoint(w - 7, h - 7); 864 p->drawPoint(w - 7, h - 7);
856 p->drawPoint(w - 6, h - 7); 865 p->drawPoint(w - 6, h - 7);
857 866
858 p->drawPoint(w - 8, h - 8); 867 p->drawPoint(w - 8, h - 8);
859 p->drawPoint(w - 7, h - 8); 868 p->drawPoint(w - 7, h - 8);
860 p->drawPoint(w - 6, h - 8); 869 p->drawPoint(w - 6, h - 8);
861 870
862 p->drawPoint(w - 7, h - 9); 871 p->drawPoint(w - 7, h - 9);
863 p->drawPoint(w - 6, h - 9); 872 p->drawPoint(w - 6, h - 9);
864 873
865 p->drawPoint(w - 6, h - 10); 874 p->drawPoint(w - 6, h - 10);
866 875
867 if (editable) 876 if (editable)
868 p->fillRect(comboButtonFocusRect(x, y, w, h), Qt::red); 877 p->fillRect(comboButtonFocusRect(x, y, w, h), Qt::red);
869 878
870 p->restore(); 879 p->restore();
871} 880}
872 881
873 QRect 882 QRect
874WebStyle::comboButtonRect(int x, int y, int w, int h) 883WebStyle::comboButtonRect(int x, int y, int w, int h)
875{ 884{
876 return QRect(x + 2, y + 2, w - 20, h - 4); 885 return QRect(x + 2, y + 2, w - 20, h - 4);
877} 886}
878 887
879 QRect 888 QRect
880WebStyle::comboButtonFocusRect(int x, int y, int w, int h) 889WebStyle::comboButtonFocusRect(int x, int y, int w, int h)
881{ 890{
882 return QRect(x + 2, y + 2, w - 20, h - 4); 891 return QRect(x + 2, y + 2, w - 20, h - 4);
883} 892}
884 893
885 int 894 int
886WebStyle::sliderLength() const 895WebStyle::sliderLength() const
887{ 896{
888 return 13; 897 return 13;
889} 898}
890 899
891 void 900 void
892WebStyle::drawSliderGroove 901WebStyle::drawSliderGroove
893( 902(
894 QPainter * p, 903 QPainter * p,
895 int x, 904 int x,
896 int y, 905 int y,
897 int w, 906 int w,
898 int h, 907 int h,
899 const QColorGroup & g, 908 const QColorGroup & g,
900 QCOORD /* c */, 909 QCOORD /* c */,
901 Orientation o 910 Orientation o
902) 911)
903{ 912{
904 p->save(); 913 p->save();
905 914
906 p->setPen(QPen(g.dark(), 0, Qt::DotLine)); 915 p->setPen(QPen(g.dark(), 0, Qt::DotLine));
907 916
908 if( o == Qt::Horizontal ) 917 if( o == Qt::Horizontal )
909 p->drawLine(x, y + h / 2, w, y + h / 2); 918 p->drawLine(x, y + h / 2, w, y + h / 2);
910 else 919 else
911 if( o == Qt::Vertical ) 920 if( o == Qt::Vertical )
912 p->drawLine(x + w / 2, y, x + w / 2, h); 921 p->drawLine(x + w / 2, y, x + w / 2, h);
913 922
914 p->restore(); 923 p->restore();
915} 924}
916 925
917 void 926 void
918WebStyle::drawArrow 927WebStyle::drawArrow
919( 928(
920 QPainter * p, 929 QPainter * p,
921 Qt::ArrowType type, 930 Qt::ArrowType type,
922 bool down, 931 bool down,
923 int x, 932 int x,
924 int y, 933 int y,
925 int w, 934 int w,
926 int h, 935 int h,
927 const QColorGroup & g, 936 const QColorGroup & g,
928 bool enabled, 937 bool enabled,
929 const QBrush * fill 938 const QBrush * fill
930) 939)
931{ 940{
932 QWindowsStyle::drawArrow(p, type, down, x, y, w, h, g, enabled, fill); 941 QWindowsStyle::drawArrow(p, type, down, x, y, w, h, g, enabled, fill);
933} 942}
934 943
935 void 944 void
936WebStyle::drawSlider 945WebStyle::drawSlider
937( 946(
938 QPainter * p, 947 QPainter * p,
939 int x, 948 int x,
940 int y, 949 int y,
941 int w, 950 int w,
942 int h, 951 int h,
943 const QColorGroup & g, 952 const QColorGroup & g,
944 Orientation o, 953 Orientation o,
945 bool /* tickAbove */, 954 bool /* tickAbove */,
946 bool /* tickBelow */ 955 bool /* tickBelow */
947) 956)
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 {
1009 p->drawRect(r); 1129 p->drawRect(r);
1010 } 1130 }
1011 1131
1012 p->restore(); 1132 p->restore();
1013} 1133}
1014 1134
1015 void 1135 void
1016WebStyle::drawPanel 1136WebStyle::drawPanel
1017( 1137(
1018 QPainter * p, 1138 QPainter * p,
1019 int x, 1139 int x,
1020 int y, 1140 int y,
1021 int w, 1141 int w,
1022 int h, 1142 int h,
1023 const QColorGroup & g, 1143 const QColorGroup & g,
1024 bool /* sunken */, 1144 bool /* sunken */,
1025 int /* lineWidth */, 1145 int /* lineWidth */,
1026 const QBrush * fill 1146 const QBrush * fill
1027) 1147)
1028{ 1148{
1029 p->save(); 1149 p->save();
1030 1150
1031 p->setPen(g.dark()); 1151 p->setPen(g.dark());
1032 1152
1033 p->setBrush(0 == fill ? NoBrush : *fill); 1153 p->setBrush(0 == fill ? NoBrush : *fill);
1034 1154
1035 p->drawRect(x, y, w, h); 1155 p->drawRect(x, y, w, h);
1036 1156
1037 p->restore(); 1157 p->restore();
1038} 1158}
1039 1159
1040 void 1160 void
1041WebStyle::drawPopupPanel 1161WebStyle::drawPopupPanel
1042( 1162(
1043 QPainter * p, 1163 QPainter * p,
1044 int x, 1164 int x,
1045 int y, 1165 int y,
1046 int w, 1166 int w,
1047 int h, 1167 int h,
1048 const QColorGroup & g, 1168 const QColorGroup & g,
1049 int /* lineWidth */, 1169 int /* lineWidth */,
1050 const QBrush * fill 1170 const QBrush * fill
1051) 1171)
1052{ 1172{
1053 p->save(); 1173 p->save();
1054 1174
1055 p->setPen(g.dark()); 1175 p->setPen(g.dark());
1056 1176
1057 p->setBrush(0 == fill ? NoBrush : *fill); 1177 p->setBrush(0 == fill ? NoBrush : *fill);
1058 1178
1059 p->drawRect(x, y, w, h); 1179 p->drawRect(x, y, w, h);
1060 1180
1061 p->restore(); 1181 p->restore();
1062} 1182}
1063 1183
1064 void 1184 void
1065WebStyle::drawSeparator 1185WebStyle::drawSeparator
1066( 1186(
1067 QPainter * p, 1187 QPainter * p,
1068 int x, 1188 int x,
1069 int y, 1189 int y,
1070 int w, 1190 int w,
1071 int h, 1191 int h,
1072 const QColorGroup & g, 1192 const QColorGroup & g,
1073 bool /* sunken */, 1193 bool /* sunken */,
1074 int /* lineWidth */, 1194 int /* lineWidth */,
1075 int /* midLineWidth */ 1195 int /* midLineWidth */
1076) 1196)
1077{ 1197{
1078 p->save(); 1198 p->save();
1079 1199
1080 p->setPen(g.dark()); 1200 p->setPen(g.dark());
1081 1201
1082 if (w > h) 1202 if (w > h)
1083 { 1203 {
1084 p->drawLine(x, y + h / 2, x + w, y + h / 2); 1204 p->drawLine(x, y + h / 2, x + w, y + h / 2);
1085 } 1205 }
1086 else 1206 else
1087 { 1207 {
1088 p->drawLine(x + w / 2, y, x + w / 2, y + h); 1208 p->drawLine(x + w / 2, y, x + w / 2, y + h);
1089 } 1209 }
1090 1210
1091 p->restore(); 1211 p->restore();
1092} 1212}
1093 1213
1094 void 1214 void
1095WebStyle::drawTab 1215WebStyle::drawTab
1096( 1216(
1097 QPainter * p, 1217 QPainter * p,
1098 const QTabBar * tabBar, 1218 const QTabBar * tabBar,
1099 QTab * tab, 1219 QTab * tab,
1100 bool selected 1220 bool selected
1101) 1221)
1102{ 1222{
1103 QRect r(tab->rect()); 1223 QRect r(tab->rect());
1104 1224
1105 QColorGroup g(tabBar->colorGroup()); 1225 QColorGroup g(tabBar->colorGroup());
1106 1226
1107 p->save(); 1227 p->save();
1108 1228
1109 p->setPen(selected ? g.dark() : g.mid()); 1229 p->setPen(selected ? g.dark() : g.mid());
1110 p->fillRect(r, g.brush(QColorGroup::Background)); 1230 p->fillRect(r, g.brush(QColorGroup::Background));
1111 1231
1112 switch (tabBar->shape()) 1232 switch (tabBar->shape())
1113 { 1233 {
1114 case QTabBar::RoundedAbove: 1234 case QTabBar::RoundedAbove:
1115 case QTabBar::TriangularAbove: 1235 case QTabBar::TriangularAbove:
1116 p->drawLine(r.left(), r.top(), r.left(), r.bottom()); 1236 p->drawLine(r.left(), r.top(), r.left(), r.bottom());
1117 p->drawLine(r.left(), r.top(), r.right(), r.top()); 1237 p->drawLine(r.left(), r.top(), r.right(), r.top());
1118 p->drawLine(r.right(), r.top(), r.right(), r.bottom()); 1238 p->drawLine(r.right(), r.top(), r.right(), r.bottom());
1119 if (!selected) 1239 if (!selected)
1120 { 1240 {
1121 p->setPen(g.dark()); 1241 p->setPen(g.dark());
1122 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); 1242 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
1123 } 1243 }
1124 break; 1244 break;
1125 case QTabBar::RoundedBelow: 1245 case QTabBar::RoundedBelow:
1126 case QTabBar::TriangularBelow: 1246 case QTabBar::TriangularBelow:
1127 if (!selected) 1247 if (!selected)
1128 { 1248 {
1129 p->setPen(g.dark()); 1249 p->setPen(g.dark());
1130 p->drawLine(r.left(), r.top(), r.right(), r.top()); 1250 p->drawLine(r.left(), r.top(), r.right(), r.top());
1131 } 1251 }
1132 p->drawLine(r.left(), r.top(), r.left(), r.bottom()); 1252 p->drawLine(r.left(), r.top(), r.left(), r.bottom());
1133 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); 1253 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
1134 p->drawLine(r.right(), r.top(), r.right(), r.bottom()); 1254 p->drawLine(r.right(), r.top(), r.right(), r.bottom());
1135 break; 1255 break;
1136 } 1256 }
1137 1257
1138 p->restore(); 1258 p->restore();
1139} 1259}
1140 1260
1141 void 1261 void
1142WebStyle::drawTabMask 1262WebStyle::drawTabMask
1143( 1263(
1144 QPainter * p, 1264 QPainter * p,
1145 const QTabBar *, 1265 const QTabBar *,
1146 QTab * tab, 1266 QTab * tab,
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
@@ -1,299 +1,299 @@
1/* 1/*
2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA. 17 * Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20#ifndef WEB_STYLE_H 20#ifndef WEB_STYLE_H
21#define WEB_STYLE_H 21#define WEB_STYLE_H
22 22
23#include <qstyle.h> 23#include <qstyle.h>
24#include <qwindowsstyle.h> 24#include <qwindowsstyle.h>
25#include <qpalette.h> 25#include <qpalette.h>
26 26
27class QPainter; 27class QPainter;
28class QScrollBar; 28class QScrollBar;
29class QPushButton; 29class QPushButton;
30class QWidget; 30class QWidget;
31 31
32class WebStyle : public QWindowsStyle { 32class WebStyle : public QWindowsStyle {
33 public: 33 public:
34 34
35 WebStyle(); 35 WebStyle();
36 36
37 ~WebStyle(); 37 ~WebStyle();
38 38
39 void polish(QApplication *); 39 void polish(QApplication *);
40 40
41 void unPolish(QWidget *); 41 void unPolish(QWidget *);
42 42
43 void polish(QWidget *); 43 void polish(QWidget *);
44 44
45 void polish(QPalette &); 45 void polish(QPalette &);
46 46
47 void unPolish(QApplication *); 47 void unPolish(QApplication *);
48 48
49 void drawButton 49 void drawButton
50 ( 50 (
51 QPainter * p, 51 QPainter * p,
52 int x, 52 int x,
53 int y, 53 int y,
54 int w, 54 int w,
55 int h, 55 int h,
56 const QColorGroup & g, 56 const QColorGroup & g,
57 bool sunken = false, 57 bool sunken = false,
58 const QBrush * fill = 0 58 const QBrush * fill = 0
59 ); 59 );
60 60
61 QRect buttonRect(int x, int y, int w, int h); 61 QRect buttonRect(int x, int y, int w, int h);
62 62
63 void drawBevelButton 63 void drawBevelButton
64 ( 64 (
65 QPainter *, 65 QPainter *,
66 int x, 66 int x,
67 int y, 67 int y,
68 int w, 68 int w,
69 int h, 69 int h,
70 const QColorGroup &, 70 const QColorGroup &,
71 bool sunken = false, 71 bool sunken = false,
72 const QBrush * fill = 0 72 const QBrush * fill = 0
73 ); 73 );
74 74
75 void drawPushButton(QPushButton *, QPainter *); 75 void drawPushButton(QPushButton *, QPainter *);
76 76
77 virtual void drawPushButtonLabel(QPushButton *, QPainter *); 77 virtual void drawPushButtonLabel(QPushButton *, QPainter *);
78 78
79 void drawScrollBarControls 79 void drawScrollBarControls
80 ( 80 (
81 QPainter *, 81 QPainter *,
82 const QScrollBar *, 82 const QScrollBar *,
83 int sliderStart, 83 int sliderStart,
84 uint controls, 84 uint controls,
85 uint activeControl 85 uint activeControl
86 ); 86 );
87 87
88 QStyle::ScrollControl scrollBarPointOver 88 QStyle::ScrollControl scrollBarPointOver
89 ( 89 (
90 const QScrollBar *, 90 const QScrollBar *,
91 int sliderStart, 91 int sliderStart,
92 const QPoint & 92 const QPoint &
93 ); 93 );
94 94
95 void scrollBarMetrics 95 void scrollBarMetrics
96 ( 96 (
97 const QScrollBar *, 97 const QScrollBar *,
98 int & sliderMin, 98 int & sliderMin,
99 int & sliderMax, 99 int & sliderMax,
100 int & sliderLength, 100 int & sliderLength,
101 int & buttonDim 101 int & buttonDim
102 ); 102 );
103 103
104 QSize indicatorSize() const; 104 QSize indicatorSize() const;
105 105
106 void drawIndicator 106 void drawIndicator
107 ( 107 (
108 QPainter *, 108 QPainter *,
109 int x, 109 int x,
110 int y, 110 int y,
111 int w, 111 int w,
112 int h, 112 int h,
113 const QColorGroup &, 113 const QColorGroup &,
114 int state, 114 int state,
115 bool down = false, 115 bool down = false,
116 bool enabled = true 116 bool enabled = true
117 ); 117 );
118 118
119 QSize exclusiveIndicatorSize() const; 119 QSize exclusiveIndicatorSize() const;
120 120
121 void drawExclusiveIndicator 121 void drawExclusiveIndicator
122 ( 122 (
123 QPainter *, 123 QPainter *,
124 int x, 124 int x,
125 int y, 125 int y,
126 int w, 126 int w,
127 int h, 127 int h,
128 const QColorGroup &, 128 const QColorGroup &,
129 bool on, 129 bool on,
130 bool down = false, 130 bool down = false,
131 bool enabled = true 131 bool enabled = true
132 ); 132 );
133 133
134 void drawIndicatorMask 134 void drawIndicatorMask
135 ( 135 (
136 QPainter *, 136 QPainter *,
137 int x, 137 int x,
138 int y, 138 int y,
139 int w, 139 int w,
140 int h, 140 int h,
141 int state 141 int state
142 ); 142 );
143 143
144 void drawExclusiveIndicatorMask 144 void drawExclusiveIndicatorMask
145 ( 145 (
146 QPainter *, 146 QPainter *,
147 int x, 147 int x,
148 int y, 148 int y,
149 int w, 149 int w,
150 int h, 150 int h,
151 bool on 151 bool on
152 ); 152 );
153 153
154 void drawComboButton 154 void drawComboButton
155 ( 155 (
156 QPainter *, 156 QPainter *,
157 int x, 157 int x,
158 int y, 158 int y,
159 int w, 159 int w,
160 int h, 160 int h,
161 const QColorGroup &, 161 const QColorGroup &,
162 bool sunken = false, 162 bool sunken = false,
163 bool editable = false, 163 bool editable = false,
164 bool enabled = true, 164 bool enabled = true,
165 const QBrush * fill = 0 165 const QBrush * fill = 0
166 ); 166 );
167 167
168 QRect comboButtonRect(int x, int y, int w, int h); 168 QRect comboButtonRect(int x, int y, int w, int h);
169 169
170 QRect comboButtonFocusRect(int x, int y, int w, int h); 170 QRect comboButtonFocusRect(int x, int y, int w, int h);
171 171
172 int sliderLength() const; 172 int sliderLength() const;
173 173
174 void drawSliderGroove 174 void drawSliderGroove
175 ( 175 (
176 QPainter *, 176 QPainter *,
177 int x, 177 int x,
178 int y, 178 int y,
179 int w, 179 int w,
180 int h, 180 int h,
181 const QColorGroup &, 181 const QColorGroup &,
182 QCOORD, 182 QCOORD,
183 Orientation 183 Orientation
184 ); 184 );
185 185
186 void drawArrow 186 void drawArrow
187 ( 187 (
188 QPainter *, 188 QPainter *,
189 Qt::ArrowType, 189 Qt::ArrowType,
190 bool down, 190 bool down,
191 int x, 191 int x,
192 int y, 192 int y,
193 int w, 193 int w,
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,
243 int w, 243 int w,
244 int h, 244 int h,
245 const QColorGroup &, 245 const QColorGroup &,
246 bool sunken, 246 bool sunken,
247 int lineWidth = 1, 247 int lineWidth = 1,
248 const QBrush * = 0 248 const QBrush * = 0
249 ); 249 );
250 250
251 void drawPopupPanel 251 void drawPopupPanel
252 ( 252 (
253 QPainter *, 253 QPainter *,
254 int x, 254 int x,
255 int y, 255 int y,
256 int w, 256 int w,
257 int h, 257 int h,
258 const QColorGroup &, 258 const QColorGroup &,
259 int lineWidth = 2, 259 int lineWidth = 2,
260 const QBrush * = 0 260 const QBrush * = 0
261 ); 261 );
262 262
263 void drawSeparator 263 void drawSeparator
264 ( 264 (
265 QPainter *, 265 QPainter *,
266 int x, 266 int x,
267 int y, 267 int y,
268 int w, 268 int w,
269 int h, 269 int h,
270 const QColorGroup &, 270 const QColorGroup &,
271 bool sunken = true, 271 bool sunken = true,
272 int lineWidth = 1, 272 int lineWidth = 1,
273 int midLineWidth = 0 273 int midLineWidth = 0
274 ); 274 );
275 275
276 void drawTab 276 void drawTab
277 ( 277 (
278 QPainter * p, 278 QPainter * p,
279 const QTabBar * tabBar, 279 const QTabBar * tabBar,
280 QTab * tab, 280 QTab * tab,
281 bool selected 281 bool selected
282 ); 282 );
283 283
284 void drawTabMask 284 void drawTabMask
285 ( 285 (
286 QPainter * p, 286 QPainter * p,
287 const QTabBar *, 287 const QTabBar *,
288 QTab * tab, 288 QTab * tab,
289 bool 289 bool
290 ); 290 );
291 291
292 int popupMenuItemHeight(bool, QMenuItem *, const QFontMetrics &); 292 int popupMenuItemHeight(bool, QMenuItem *, const QFontMetrics &);
293 293
294 GUIStyle guiStyle() const { return Qt::MotifStyle; } 294 GUIStyle guiStyle() const { return Qt::MotifStyle; }
295 295
296 bool eventFilter(QObject *, QEvent *); 296 bool eventFilter(QObject *, QEvent *);
297}; 297};
298 298
299#endif 299#endif