summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/theme/othemestyle.cpp126
-rw-r--r--noncore/styles/theme/othemestyle.h16
2 files changed, 124 insertions, 18 deletions
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 8c7a71b..a820efb 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -1,677 +1,757 @@
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 29
29#include <limits.h> 30#include <limits.h>
30#include <stdio.h> 31#include <stdio.h>
31 32
33typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
34 QColorGroup &, bool, bool);
35
36QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
37
38
39/* !! HACK !! Beware
40 *
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
43 * paint event - since we have to use protected functions, we need
44 * to derive a "hack" class from QProgressBar and do the painting
45 * in there.
46 *
47 * - sandman
48 */
49
50class HackProgressBar : public QProgressBar {
51public:
52 HackProgressBar ( );
53
54 void paint ( QPaintEvent *event, OThemeStyle *style )
55 {
56 QPainter p( this );
57
58 if ( !contentsRect().contains( event->rect() ) ) {
59 p.save();
60 p.setClipRegion( event->region().intersect(frameRect()) );
61 drawFrame( &p);
62 p.restore();
63 }
64 if ( event->rect().intersects( contentsRect() )) {
65 p.setClipRegion( event->region().intersect( contentsRect() ) );
66
67 int x, y, w, h;
68 contentsRect ( ). rect ( &x, &y, &w, &h );
69
70 int prog = progress ( );
71 int total = totalSteps ( );
72 if ( prog < 0 )
73 prog = 0;
74 if ( total <= 0 )
75 total = 1;
76 int perc = prog * 100 / total;
77
78 style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc );
79
80 if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) {
81 QString pstr;
82 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
83 p. setPen ( colorGroup().text());//g.highlightedText ( ));
84 p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
85 }
86 }
87 }
88};
89
90
32#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 91#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
33 92
34OThemeStyle::OThemeStyle( const QString &configFile ) 93OThemeStyle::OThemeStyle( const QString &configFile )
35 : OThemeBase( configFile ) 94 : OThemeBase( configFile )
36{ 95{
37 setScrollBarExtent( getSBExtent(), getSBExtent() ); 96 setScrollBarExtent( getSBExtent(), getSBExtent() );
38 setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! 97 setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below!
39} 98}
40 99
41OThemeStyle::~OThemeStyle() 100OThemeStyle::~OThemeStyle()
42{} 101{}
43 102
44void OThemeStyle::polish( QApplication * /*app*/ ) 103void OThemeStyle::polish( QApplication * /*app*/ )
45{} 104{
105 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem);
106}
107
46 108
47void OThemeStyle::polish( QPalette &p ) 109void OThemeStyle::polish( QPalette &p )
48{ 110{
49 oldPalette = p; 111 oldPalette = p;
50 112
51 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); 113 QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background );
52 114
53 if ( bgcolor. isValid ( )) 115 if ( bgcolor. isValid ( ))
54 bg = bgcolor; 116 bg = bgcolor;
55 117
56 if ( isColor ( Background )) 118 if ( isColor ( Background ))
57 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); 119 bg = colorGroup ( oldPalette. active ( ), Background )-> background ( );
58 120
59 p = QPalette ( bg, bg ); 121 p = QPalette ( bg, bg );
60 122
61 if ( isPixmap( Background ) ) 123 if ( isPixmap( Background ) )
62 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); 124 p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background )));
63 125
64 if ( fgcolor. isValid ( )) { 126 if ( fgcolor. isValid ( )) {
65 p. setColor ( QColorGroup::Foreground, fgcolor ); 127 p. setColor ( QColorGroup::Foreground, fgcolor );
66 p. setColor ( QColorGroup::ButtonText, fgcolor ); 128 p. setColor ( QColorGroup::ButtonText, fgcolor );
67 } 129 }
68 if ( selfgcolor. isValid ( )) 130 if ( selfgcolor. isValid ( ))
69 p. setColor ( QColorGroup::HighlightedText, selfgcolor ); 131 p. setColor ( QColorGroup::HighlightedText, selfgcolor );
70 if ( selbgcolor. isValid ( )) 132 if ( selbgcolor. isValid ( ))
71 p. setColor ( QColorGroup::Highlight, selbgcolor ); 133 p. setColor ( QColorGroup::Highlight, selbgcolor );
72 if ( winfgcolor. isValid ( )) 134 if ( winfgcolor. isValid ( ))
73 p. setColor ( QColorGroup::Text, winfgcolor ); 135 p. setColor ( QColorGroup::Text, winfgcolor );
74 if ( winbgcolor. isValid ( )) 136 if ( winbgcolor. isValid ( ))
75 p. setColor ( QColorGroup::Base, winbgcolor ); 137 p. setColor ( QColorGroup::Base, winbgcolor );
76 138
77} 139}
78 140
79 141
80void OThemeStyle::unPolish( QApplication *app ) 142void OThemeStyle::unPolish( QApplication *app )
81{ 143{
144 qt_set_draw_menu_bar_impl ( 0 );
82 app->setPalette( oldPalette, true ); 145 app->setPalette( oldPalette, true );
83} 146}
84 147
85void OThemeStyle::polish( QWidget *w ) 148void OThemeStyle::polish( QWidget *w )
86{ 149{
87 if ( !w->isTopLevel() ) { 150 if ( !w->isTopLevel() ) {
88 if ( w->inherits( "QGroupBox" ) 151 if ( w->inherits( "QGroupBox" )
89 || w->inherits( "QTabWidget" ) ) { 152 || w->inherits( "QTabWidget" ) ) {
90 w->setAutoMask( TRUE ); 153 w->setAutoMask( TRUE );
91 return ; 154 return ;
92 } 155 }
93 if ( w->inherits( "QLabel" ) 156 if ( w->inherits( "QLabel" )
94 || w->inherits( "QSlider" ) 157 || w->inherits( "QSlider" )
95 || w->inherits( "QButton" ) 158 || w->inherits( "QButton" )
96 || w->inherits( "QProgressBar" ) 159 || w->inherits( "QProgressBar" )
97 ) { 160 ) {
98 w->setBackgroundOrigin( QWidget::ParentOrigin ); 161 w->setBackgroundOrigin( QWidget::ParentOrigin );
99 } 162 }
100 } 163 }
101 if ( w->inherits( "QPopupMenu" ) ) { 164 if ( w->inherits( "QPopupMenu" ) ) {
102 popupPalette = w->palette(); 165 popupPalette = w->palette();
103 if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { 166 if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) {
104 QPalette newPal( w->palette() ); 167 QPalette newPal( w->palette() );
105 w->setPalettePropagation( QWidget::SamePalette ); 168 w->setPalettePropagation( QWidget::SamePalette );
106 if ( isColor( MenuItem ) ) { 169 if ( isColor( MenuItem ) ) {
107 newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); 170 newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) );
108 newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); 171 newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) );
109 } 172 }
110 if ( isColor( MenuItemDown ) ) 173 if ( isColor( MenuItemDown ) )
111 newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); 174 newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) );
112 w->setPalette( newPal ); 175 w->setPalette( newPal );
113 } 176 }
114 } 177 }
115 if ( w->inherits( "QCheckBox" ) ) { 178 else if ( w->inherits( "QCheckBox" ) ) {
116 if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { 179 if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) {
117 QPalette newPal( w->palette() ); 180 QPalette newPal( w->palette() );
118 w->setPalettePropagation( QWidget::SamePalette ); 181 w->setPalettePropagation( QWidget::SamePalette );
119 if ( isColor( IndicatorOff ) ) { 182 if ( isColor( IndicatorOff ) ) {
120 newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); 183 newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) );
121 newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); 184 newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) );
122 } 185 }
123 if ( isColor( IndicatorOn ) ) 186 if ( isColor( IndicatorOn ) )
124 newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); 187 newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) );
125 w->setPalette( newPal ); 188 w->setPalette( newPal );
126 } 189 }
127 } 190 }
128 if ( w->inherits( "QRadioButton" ) ) { 191 else if ( w->inherits( "QRadioButton" ) ) {
129 if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { 192 if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) {
130 QPalette newPal( w->palette() ); 193 QPalette newPal( w->palette() );
131 w->setPalettePropagation( QWidget::SamePalette ); 194 w->setPalettePropagation( QWidget::SamePalette );
132 if ( isColor( ExIndicatorOff ) ) { 195 if ( isColor( ExIndicatorOff ) ) {
133 newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); 196 newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) );
134 newPal.setDisabled( *colorGroup( newPal.normal(), 197 newPal.setDisabled( *colorGroup( newPal.normal(),
135 ExIndicatorOff ) ); 198 ExIndicatorOff ) );
136 } 199 }
137 if ( isColor( ExIndicatorOn ) ) 200 if ( isColor( ExIndicatorOn ) )
138 newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); 201 newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) );
139 w->setPalette( newPal ); 202 w->setPalette( newPal );
140 } 203 }
141 } 204 }
205 else if ( w-> inherits ( "QProgressBar" ) ) {
206 w-> installEventFilter ( this );
207 }
142} 208}
143 209
144void OThemeStyle::unPolish( QWidget* w ) 210void OThemeStyle::unPolish( QWidget* w )
145{ 211{
146 if ( !w->isTopLevel() ) { 212 if ( !w->isTopLevel() ) {
147 if ( w->inherits( "QGroupBox" ) 213 if ( w->inherits( "QGroupBox" )
148 || w->inherits( "QTabWidget" ) ) { 214 || w->inherits( "QTabWidget" ) ) {
149 w->setAutoMask( FALSE ); 215 w->setAutoMask( FALSE );
150 return ; 216 return ;
151 } 217 }
152 if ( w->inherits( "QLabel" ) 218 if ( w->inherits( "QLabel" )
153 || w->inherits( "QSlider" ) 219 || w->inherits( "QSlider" )
154 || w->inherits( "QButton" ) 220 || w->inherits( "QButton" )
155 || w->inherits( "QProgressBar" ) 221 || w->inherits( "QProgressBar" )
156 ) { 222 ) {
157 w->setBackgroundOrigin( QWidget::WidgetOrigin ); 223 w->setBackgroundOrigin( QWidget::WidgetOrigin );
158 } 224 }
159 } 225 }
160 if ( w->inherits( "QPopupMenu" ) ) 226 if ( w->inherits( "QPopupMenu" ) )
161 w->unsetPalette(); 227 w->unsetPalette();
162 if ( w->inherits( "QCheckBox" ) ) 228 else if ( w->inherits( "QCheckBox" ) )
163 w->unsetPalette(); 229 w->unsetPalette();
164 if ( w->inherits( "QRadioButton" ) ) 230 else if ( w->inherits( "QRadioButton" ) )
165 w->unsetPalette(); 231 w->unsetPalette();
232 else if ( w-> inherits ( "QProgressBar" ) )
233 w-> removeEventFilter ( this );
234}
235
236bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev )
237{
238 // only QProgressBar so far
239
240 if ( ev-> type ( ) == QEvent::Paint ) {
241 HackProgressBar *pb = (HackProgressBar *) obj;
242 pb-> paint ((QPaintEvent *) ev, this );
243 return true;
244 }
245 return false;
166} 246}
167 247
168void 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,
169 const QColorGroup &g, bool sunken, bool 249 const QColorGroup &g, bool sunken, bool
170 rounded, WidgetType type, const QBrush * ) 250 rounded, WidgetType type, const QBrush * )
171{ 251{
172 int offset = borderPixmap( type ) ? 0 : decoWidth( type ); 252 int offset = borderPixmap( type ) ? 0 : decoWidth( type );
173 QPen oldPen = p->pen(); 253 QPen oldPen = p->pen();
174 254
175 // handle reverse bevel here since it uses decowidth differently 255 // handle reverse bevel here since it uses decowidth differently
176 if ( gradientHint( type ) == GrReverseBevel ) { 256 if ( gradientHint( type ) == GrReverseBevel ) {
177 int i; 257 int i;
178 bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, 258 bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h,
179 Qt::CopyROP, true ); 259 Qt::CopyROP, true );
180 p->setPen( g.text() ); 260 p->setPen( g.text() );
181 for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) 261 for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 )
182 p->drawRect( x, y, w, h ); 262 p->drawRect( x, y, w, h );
183 } 263 }
184 // same with KDE style borders 264 // same with KDE style borders
185 else if ( !borderPixmap( type ) && shade() == KDE ) { 265 else if ( !borderPixmap( type ) && shade() == KDE ) {
186 qDrawWinButton( p, x, y, w, h, g, sunken ); 266 qDrawWinButton( p, x, y, w, h, g, sunken );
187 if ( isPixmap( type ) ) 267 if ( isPixmap( type ) )
188 p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, 268 p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6,
189 *scalePixmap( w - 6, h - 6, 269 *scalePixmap( w - 6, h - 6,
190 type ) ); 270 type ) );
191 else 271 else
192 p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, 272 p->fillRect( x + 4, y + 4, w - 6, h - offset * 6,
193 g.brush( QColorGroup::Button ) ); 273 g.brush( QColorGroup::Button ) );
194 274
195 } 275 }
196 else { 276 else {
197 if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { 277 if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) {
198 if ( isPixmap( type ) ) 278 if ( isPixmap( type ) )
199 if ( rounded ) 279 if ( rounded )
200 p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); 280 p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) );
201 else 281 else
202 p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, 282 p->drawTiledPixmap( x + offset, y + offset, w - offset * 2,
203 h - offset * 2, 283 h - offset * 2,
204 *scalePixmap( w - offset * 2, h - offset * 2, 284 *scalePixmap( w - offset * 2, h - offset * 2,
205 type ) ); 285 type ) );
206 else 286 else
207 p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, 287 p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2,
208 g.brush( QColorGroup::Button ) ); 288 g.brush( QColorGroup::Button ) );
209 } 289 }
210 if ( borderPixmap( type ) ) 290 if ( borderPixmap( type ) )
211 bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, 291 bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h,
212 Qt::CopyROP, false ); 292 Qt::CopyROP, false );
213 else 293 else
214 drawShade( p, x, y, w, h, g, sunken, rounded, 294 drawShade( p, x, y, w, h, g, sunken, rounded,
215 highlightWidth( type ), borderWidth( type ), shade() ); 295 highlightWidth( type ), borderWidth( type ), shade() );
216 } 296 }
217 p->setPen( oldPen ); 297 p->setPen( oldPen );
218} 298}
219 299
220void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, 300void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h,
221 const QColorGroup &g, bool sunken, 301 const QColorGroup &g, bool sunken,
222 const QBrush *fill ) 302 const QBrush *fill )
223{ 303{
224 drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? 304 drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ?
225 PushButtonDown : PushButton, fill ); 305 PushButtonDown : PushButton, fill );
226} 306}
227 307
228void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) 308void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p )
229{ 309{
230 bool sunken = btn->isOn() || btn->isDown(); 310 bool sunken = btn->isOn() || btn->isDown();
231 int diw = buttonDefaultIndicatorWidth(); 311 int diw = buttonDefaultIndicatorWidth();
232 drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, 312 drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw,
233 *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : 313 *colorGroup( btn->colorGroup(), sunken ? PushButtonDown :
234 PushButton ), sunken, roundButton(), 314 PushButton ), sunken, roundButton(),
235 sunken ? PushButtonDown : PushButton, NULL ); 315 sunken ? PushButtonDown : PushButton, NULL );
236 // TODO if diw, draw fancy default button indicator 316 // TODO if diw, draw fancy default button indicator
237} 317}
238 318
239void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, 319void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
240 bool round ) 320 bool round )
241{ 321{
242 // round edge fills 322 // round edge fills
243 static const QCOORD btm_left_fill[] = { 323 static const QCOORD btm_left_fill[] = {
244 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 324 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
245 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 325 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4
246 }; 326 };
247 327
248 static const QCOORD btm_right_fill[] = { 328 static const QCOORD btm_right_fill[] = {
249 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 329 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4,
250 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 330 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4
251 }; 331 };
252 332
253 static const QCOORD top_left_fill[] = { 333 static const QCOORD top_left_fill[] = {
254 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, 334 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3,
255 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 335 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
256 }; 336 };
257 337
258 static const QCOORD top_right_fill[] = { 338 static const QCOORD top_right_fill[] = {
259 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 339 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0,
260 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 340 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
261 }; 341 };
262 342
263 QBrush fillBrush( color1, SolidPattern ); 343 QBrush fillBrush( color1, SolidPattern );
264 p->setPen( color1 ); 344 p->setPen( color1 );
265 if ( round && w > 19 && h > 19 ) { 345 if ( round && w > 19 && h > 19 ) {
266 int x2 = x + w - 1; 346 int x2 = x + w - 1;
267 int y2 = y + h - 1; 347 int y2 = y + h - 1;
268 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); 348 QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill );
269 a.translate( 1, 1 ); 349 a.translate( 1, 1 );
270 p->drawPoints( a ); 350 p->drawPoints( a );
271 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); 351 a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill );
272 a.translate( 1, h - 6 ); 352 a.translate( 1, h - 6 );
273 p->drawPoints( a ); 353 p->drawPoints( a );
274 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); 354 a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill );
275 a.translate( w - 6, 1 ); 355 a.translate( w - 6, 1 );
276 p->drawPoints( a ); 356 p->drawPoints( a );
277 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); 357 a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill );
278 a.translate( w - 6, h - 6 ); 358 a.translate( w - 6, h - 6 );
279 p->drawPoints( a ); 359 p->drawPoints( a );
280 360
281 p->fillRect( x + 6, y, w - 12, h, fillBrush ); 361 p->fillRect( x + 6, y, w - 12, h, fillBrush );
282 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); 362 p->fillRect( x, y + 6, x + 6, h - 12, fillBrush );
283 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); 363 p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush );
284 p->drawLine( x + 6, y, x2 - 6, y ); 364 p->drawLine( x + 6, y, x2 - 6, y );
285 p->drawLine( x + 6, y2, x2 - 6, y2 ); 365 p->drawLine( x + 6, y2, x2 - 6, y2 );
286 p->drawLine( x, y + 6, x, y2 - 6 ); 366 p->drawLine( x, y + 6, x, y2 - 6 );
287 p->drawLine( x2, y + 6, x2, y2 - 6 ); 367 p->drawLine( x2, y + 6, x2, y2 - 6 );
288 368
289 } 369 }
290 else 370 else
291 p->fillRect( x, y, w, h, fillBrush ); 371 p->fillRect( x, y, w, h, fillBrush );
292} 372}
293 373
294void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) 374void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h )
295{ 375{
296 drawBaseMask( p, x, y, w, h, roundButton() ); 376 drawBaseMask( p, x, y, w, h, roundButton() );
297} 377}
298 378
299void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) 379void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h )
300{ 380{
301 drawBaseMask( p, x, y, w, h, roundComboBox() ); 381 drawBaseMask( p, x, y, w, h, roundComboBox() );
302} 382}
303 383
304void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, 384void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
305 const QColorGroup &g, bool sunken, 385 const QColorGroup &g, bool sunken,
306 const QBrush * ) 386 const QBrush * )
307{ 387{
308 WidgetType type = sunken ? BevelDown : Bevel; 388 WidgetType type = sunken ? BevelDown : Bevel;
309 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); 389 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
310} 390}
311 391
312void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, 392void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
313 const QColorGroup &g, bool sunken, 393 const QColorGroup &g, bool sunken,
314 const QBrush * ) 394 const QBrush * )
315{ 395{
316 WidgetType type = sunken ? ToolButtonDown : ToolButton; 396 WidgetType type = sunken ? ToolButtonDown : ToolButton;
317 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); 397 drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
318} 398}
319 399
320#if 0 400#if 0
321void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, 401void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
322 const QColorGroup &g, bool sunken, 402 const QColorGroup &g, bool sunken,
323 bool raised, bool enabled, bool popup, 403 bool raised, bool enabled, bool popup,
324 KToolButtonType type, const QString &btext, 404 KToolButtonType type, const QString &btext,
325 const QPixmap *pixmap, QFont *font, 405 const QPixmap *pixmap, QFont *font,
326 QWidget * ) 406 QWidget * )
327{ 407{
328 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); 408 QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 );
329 if ( font ) 409 if ( font )
330 tmp_font = *font; 410 tmp_font = *font;
331 QFontMetrics fm( tmp_font ); 411 QFontMetrics fm( tmp_font );
332 WidgetType widget = sunken ? ToolButtonDown : ToolButton; 412 WidgetType widget = sunken ? ToolButtonDown : ToolButton;
333 413
334 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, 414 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false,
335 widget ); 415 widget );
336 int dx, dy; 416 int dx, dy;
337 if ( type == Icon ) { // icon only 417 if ( type == Icon ) { // icon only
338 if ( pixmap ) { 418 if ( pixmap ) {
339 dx = ( w - pixmap->width() ) / 2; 419 dx = ( w - pixmap->width() ) / 2;
340 dy = ( h - pixmap->height() ) / 2; 420 dy = ( h - pixmap->height() ) / 2;
341 if ( sunken ) { 421 if ( sunken ) {
342 ++dx; 422 ++dx;
343 ++dy; 423 ++dy;
344 } 424 }
345 p->drawPixmap( x + dx, y + dy, *pixmap ); 425 p->drawPixmap( x + dx, y + dy, *pixmap );
346 } 426 }
347 } 427 }
348 else if ( type == IconTextRight ) { // icon and text (if any) 428 else if ( type == IconTextRight ) { // icon and text (if any)
349 if ( pixmap ) { 429 if ( pixmap ) {
350 dx = 4; 430 dx = 4;
351 dy = ( h - pixmap->height() ) / 2; 431 dy = ( h - pixmap->height() ) / 2;
352 if ( sunken ) { 432 if ( sunken ) {
353 ++dx; 433 ++dx;
354 ++dy; 434 ++dy;
355 } 435 }
356 p->drawPixmap( x + dx, y + dy, *pixmap ); 436 p->drawPixmap( x + dx, y + dy, *pixmap );
357 } 437 }
358 if ( !btext.isNull() ) { 438 if ( !btext.isNull() ) {
359 int tf = AlignVCenter | AlignLeft; 439 int tf = AlignVCenter | AlignLeft;
360 if ( pixmap ) 440 if ( pixmap )
361 dx = 4 + pixmap->width() + 2; 441 dx = 4 + pixmap->width() + 2;
362 else 442 else
363 dx = 4; 443 dx = 4;
364 dy = 0; 444 dy = 0;
365 if ( sunken ) { 445 if ( sunken ) {
366 ++dx; 446 ++dx;
367 ++dy; 447 ++dy;
368 } 448 }
369 if ( font ) 449 if ( font )
370 p->setFont( *font ); 450 p->setFont( *font );
371 if ( raised ) 451 if ( raised )
372 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 452 p->setPen( KGlobalSettings::toolBarHighlightColor() );
373 p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); 453 p->drawText( x + dx, y + dy, w - dx, h, tf, btext );
374 } 454 }
375 } 455 }
376 else if ( type == Text ) { // only text, even if there is a icon 456 else if ( type == Text ) { // only text, even if there is a icon
377 if ( !btext.isNull() ) { 457 if ( !btext.isNull() ) {
378 int tf = AlignTop | AlignLeft; 458 int tf = AlignTop | AlignLeft;
379 if ( !enabled ) 459 if ( !enabled )
380 p->setPen( g.dark() ); 460 p->setPen( g.dark() );
381 dx = ( w - fm.width( btext ) ) / 2; 461 dx = ( w - fm.width( btext ) ) / 2;
382 dy = ( h - fm.lineSpacing() ) / 2; 462 dy = ( h - fm.lineSpacing() ) / 2;
383 if ( sunken ) { 463 if ( sunken ) {
384 ++dx; 464 ++dx;
385 ++dy; 465 ++dy;
386 } 466 }
387 if ( font ) 467 if ( font )
388 p->setFont( *font ); 468 p->setFont( *font );
389 if ( raised ) 469 if ( raised )
390 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 470 p->setPen( KGlobalSettings::toolBarHighlightColor() );
391 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); 471 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext );
392 } 472 }
393 } 473 }
394 else if ( type == IconTextBottom ) { 474 else if ( type == IconTextBottom ) {
395 if ( pixmap ) { 475 if ( pixmap ) {
396 dx = ( w - pixmap->width() ) / 2; 476 dx = ( w - pixmap->width() ) / 2;
397 dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; 477 dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2;
398 if ( sunken ) { 478 if ( sunken ) {
399 ++dx; 479 ++dx;
400 ++dy; 480 ++dy;
401 } 481 }
402 p->drawPixmap( x + dx, y + dy, *pixmap ); 482 p->drawPixmap( x + dx, y + dy, *pixmap );
403 } 483 }
404 if ( !btext.isNull() ) { 484 if ( !btext.isNull() ) {
405 int tf = AlignBottom | AlignHCenter; 485 int tf = AlignBottom | AlignHCenter;
406 dx = ( w - fm.width( btext ) ) / 2; 486 dx = ( w - fm.width( btext ) ) / 2;
407 dy = h - fm.lineSpacing() - 4; 487 dy = h - fm.lineSpacing() - 4;
408 if ( sunken ) { 488 if ( sunken ) {
409 ++dx; 489 ++dx;
410 ++dy; 490 ++dy;
411 } 491 }
412 if ( font ) 492 if ( font )
413 p->setFont( *font ); 493 p->setFont( *font );
414 if ( raised ) 494 if ( raised )
415 p->setPen( KGlobalSettings::toolBarHighlightColor() ); 495 p->setPen( KGlobalSettings::toolBarHighlightColor() );
416 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); 496 p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext );
417 } 497 }
418 } 498 }
419 if ( popup ) { 499 if ( popup ) {
420 if ( enabled ) 500 if ( enabled )
421 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, 501 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0,
422 g, true ); 502 g, true );
423 else 503 else
424 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 504 qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5,
425 0, 0, g, false ); 505 0, 0, g, false );
426 } 506 }
427} 507}
428 508
429void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, 509void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h,
430 const QColorGroup &g, KToolBarPos, QBrush * ) 510 const QColorGroup &g, KToolBarPos, QBrush * )
431{ 511{
432 if ( w > h ) 512 if ( w > h )
433 drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, 513 drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false,
434 HBarHandle ); 514 HBarHandle );
435 else 515 else
436 drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, 516 drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false,
437 VBarHandle ); 517 VBarHandle );
438} 518}
439 519
440void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, 520void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h,
441 const QColorGroup &g, KToolBarPos, QBrush * ) 521 const QColorGroup &g, KToolBarPos, QBrush * )
442{ 522{
443 drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, 523 drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false,
444 ToolBar ); 524 ToolBar );
445} 525}
446#endif 526#endif
447 527
448QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) 528QRect OThemeStyle::buttonRect( int x, int y, int w, int h )
449{ 529{
450 int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? 530 int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ?
451 decoWidth( PushButton ) : decoWidth( PushButtonDown ); 531 decoWidth( PushButton ) : decoWidth( PushButtonDown );
452 return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); 532 return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) );
453} 533}
454 534
455void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, 535void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
456 const QColorGroup &g, bool sunken, bool, 536 const QColorGroup &g, bool sunken, bool,
457 bool, const QBrush * ) 537 bool, const QBrush * )
458{ 538{
459 WidgetType widget = sunken ? ComboBoxDown : ComboBox; 539 WidgetType widget = sunken ? ComboBoxDown : ComboBox;
460 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, 540 drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken,
461 roundComboBox(), widget ); 541 roundComboBox(), widget );
462 if ( !sunken && isPixmap( ComboDeco ) ) 542 if ( !sunken && isPixmap( ComboDeco ) )
463 p->drawPixmap( w - uncached( ComboDeco ) ->width() - 543 p->drawPixmap( w - uncached( ComboDeco ) ->width() -
464 decoWidth( ComboBox ) - 2, 544 decoWidth( ComboBox ) - 2,
465 y + ( h - uncached( ComboDeco ) -> 545 y + ( h - uncached( ComboDeco ) ->
466 height() ) / 2, *uncached( ComboDeco ) ); 546 height() ) / 2, *uncached( ComboDeco ) );
467 else if ( sunken && isPixmap( ComboDecoDown ) ) 547 else if ( sunken && isPixmap( ComboDecoDown ) )
468 p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - 548 p->drawPixmap( w - uncached( ComboDecoDown ) ->width() -
469 decoWidth( ComboBoxDown ) - 2, 549 decoWidth( ComboBoxDown ) - 2,
470 y + ( h - uncached( ComboDecoDown ) -> 550 y + ( h - uncached( ComboDecoDown ) ->
471 height() ) / 2, *uncached( ComboDecoDown ) ); 551 height() ) / 2, *uncached( ComboDecoDown ) );
472 else { 552 else {
473 qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, 553 qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10,
474 h - 15, *colorGroup( g, widget ), true ); 554 h - 15, *colorGroup( g, widget ), true );
475 qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); 555 qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) );
476 } 556 }
477} 557}
478 558
479void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, 559void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb,
480 int sliderStart, uint controls, 560 int sliderStart, uint controls,
481 uint activeControl ) 561 uint activeControl )
482{ 562{
483 int sliderMin, sliderMax, sliderLength, buttonDim; 563 int sliderMin, sliderMax, sliderLength, buttonDim;
484 QRect add 564 QRect add
485 , sub, addPage, subPage, slider; 565 , sub, addPage, subPage, slider;
486 int addX, addY, subX, subY; 566 int addX, addY, subX, subY;
487 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 567 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
488 int len = ( horizontal ) ? sb->width() : sb->height(); 568 int len = ( horizontal ) ? sb->width() : sb->height();
489 int extent = ( horizontal ) ? sb->height() : sb->width(); 569 int extent = ( horizontal ) ? sb->height() : sb->width();
490 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); 570 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove );
491 QColorGroup g = sb->colorGroup(); 571 QColorGroup g = sb->colorGroup();
492 572
493 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 573 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
494 if ( sliderStart > sliderMax ) 574 if ( sliderStart > sliderMax )
495 sliderStart = sliderMax; 575 sliderStart = sliderMax;
496 576
497 int sliderEnd = sliderStart + sliderLength; 577 int sliderEnd = sliderStart + sliderLength;
498 int sliderWidth = extent - offset * 2; 578 int sliderWidth = extent - offset * 2;
499 579
500 // Scary button placement code >:-P Feel free to improve this if you 580 // Scary button placement code >:-P Feel free to improve this if you
501 // want. I get a headache just looking at it... (mosfet) 581 // want. I get a headache just looking at it... (mosfet)
502 if ( scrollBarLayout() == SBOpposite ) { 582 if ( scrollBarLayout() == SBOpposite ) {
503 if ( horizontal ) { 583 if ( horizontal ) {
504 subY = addY = ( extent - buttonDim ) / 2; 584 subY = addY = ( extent - buttonDim ) / 2;
505 subX = offset; 585 subX = offset;
506 addX = len - buttonDim - offset; 586 addX = len - buttonDim - offset;
507 } 587 }
508 else { 588 else {
509 subX = addX = ( extent - buttonDim ) / 2; 589 subX = addX = ( extent - buttonDim ) / 2;
510 subY = offset; 590 subY = offset;
511 addY = len - buttonDim - offset; 591 addY = len - buttonDim - offset;
512 } 592 }
513 sub.setRect( subX, subY, buttonDim, buttonDim ); 593 sub.setRect( subX, subY, buttonDim, buttonDim );
514 add.setRect( addX, addY, buttonDim, buttonDim ); 594 add.setRect( addX, addY, buttonDim, buttonDim );
515 if ( horizontal ) { 595 if ( horizontal ) {
516 subPage.setRect( sub.right() + 1, offset, 596 subPage.setRect( sub.right() + 1, offset,
517 sliderStart - sub.right() - 1 , sliderWidth ); 597 sliderStart - sub.right() - 1 , sliderWidth );
518 addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); 598 addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth );
519 slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); 599 slider.setRect( sliderStart, offset, sliderLength, sliderWidth );
520 } 600 }
521 else { 601 else {
522 subPage.setRect( offset, sub.bottom() + 1, sliderWidth, 602 subPage.setRect( offset, sub.bottom() + 1, sliderWidth,
523 sliderStart - sub.bottom() - 1 ); 603 sliderStart - sub.bottom() - 1 );
524 addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); 604 addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd );
525 slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); 605 slider.setRect( offset, sliderStart, sliderWidth, sliderLength );
526 } 606 }
527 } 607 }
528 else if ( horizontal ) { 608 else if ( horizontal ) {
529 subY = addY = ( extent - buttonDim ) / 2; 609 subY = addY = ( extent - buttonDim ) / 2;
530 if ( scrollBarLayout() == SBBottomLeft ) { 610 if ( scrollBarLayout() == SBBottomLeft ) {
531 subX = offset; 611 subX = offset;
532 addX = buttonDim + offset; 612 addX = buttonDim + offset;
533 subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); 613 subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent );
534 addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); 614 addPage.setRect( sliderEnd, 0, len - sliderEnd, extent );
535 slider.setRect( sliderStart, 0, sliderLength, extent ); 615 slider.setRect( sliderStart, 0, sliderLength, extent );
536 } 616 }
537 else { 617 else {
538 subX = len - buttonDim - buttonDim - offset; 618 subX = len - buttonDim - buttonDim - offset;
539 addX = len - buttonDim - offset; 619 addX = len - buttonDim - offset;
540 subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); 620 subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth );
541 addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); 621 addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth );
542 slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); 622 slider.setRect( sliderStart, offset, sliderLength, sliderWidth );
543 } 623 }
544 sub.setRect( subX, subY, buttonDim, buttonDim ); 624 sub.setRect( subX, subY, buttonDim, buttonDim );
545 add.setRect( addX, addY, buttonDim, buttonDim ); 625 add.setRect( addX, addY, buttonDim, buttonDim );
546 } 626 }
547 else { // BottomLeft and BottomRight vertical bars are the same. 627 else { // BottomLeft and BottomRight vertical bars are the same.
548 subX = addX = ( extent - buttonDim ) / 2; 628 subX = addX = ( extent - buttonDim ) / 2;
549 subY = len - buttonDim - buttonDim - offset; 629 subY = len - buttonDim - buttonDim - offset;
550 addY = len - buttonDim - offset; 630 addY = len - buttonDim - offset;
551 subPage.setRect( offset, offset + 1, sliderWidth, 631 subPage.setRect( offset, offset + 1, sliderWidth,
552 sliderStart - offset - 1 ); 632 sliderStart - offset - 1 );
553 addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); 633 addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd );
554 slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); 634 slider.setRect( offset, sliderStart, sliderWidth, sliderLength );
555 sub.setRect( subX, subY, buttonDim, buttonDim ); 635 sub.setRect( subX, subY, buttonDim, buttonDim );
556 add.setRect( addX, addY, buttonDim, buttonDim ); 636 add.setRect( addX, addY, buttonDim, buttonDim );
557 } 637 }
558 // End of the button placement code 638 // End of the button placement code
559 639
560 bool active; 640 bool active;
561 if ( ( controls & QStyle::SubPage ) ) { 641 if ( ( controls & QStyle::SubPage ) ) {
562 drawScrollBarGroove( p, sb, horizontal, subPage, g ); 642 drawScrollBarGroove( p, sb, horizontal, subPage, g );
563 } 643 }
564 if ( ( controls & QStyle::AddPage ) ) { 644 if ( ( controls & QStyle::AddPage ) ) {
565 drawScrollBarGroove( p, sb, horizontal, addPage, g ); 645 drawScrollBarGroove( p, sb, horizontal, addPage, g );
566 } 646 }
567 if ( controls & QStyle::AddLine ) { 647 if ( controls & QStyle::AddLine ) {
568 active = activeControl == QStyle::AddLine; 648 active = activeControl == QStyle::AddLine;
569 drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), 649 drawBaseButton( p, add.x(), add.y(), add.width(), add.height(),
570 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), 650 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ),
571 active, false, active ? ScrollButtonDown : ScrollButton ); 651 active, false, active ? ScrollButtonDown : ScrollButton );
572 drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, 652 drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3,
573 add.y() + 3, add.width() - 6, add.height() - 6, 653 add.y() + 3, add.width() - 6, add.height() - 6,
574 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); 654 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) );
575 } 655 }
576 if ( controls & QStyle::SubLine ) { 656 if ( controls & QStyle::SubLine ) {
577 active = activeControl == QStyle::SubLine; 657 active = activeControl == QStyle::SubLine;
578 p->setPen( g.dark() ); 658 p->setPen( g.dark() );
579 p->drawRect( sub ); 659 p->drawRect( sub );
580 drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), 660 drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(),
581 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), 661 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ),
582 active, false, active ? ScrollButtonDown : ScrollButton ); 662 active, false, active ? ScrollButtonDown : ScrollButton );
583 drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, 663 drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3,
584 sub.y() + 3, sub.width() - 6, sub.height() - 6, 664 sub.y() + 3, sub.width() - 6, sub.height() - 6,
585 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); 665 *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) );
586 } 666 }
587 if ( controls & QStyle::Slider ) { 667 if ( controls & QStyle::Slider ) {
588 active = activeControl == QStyle::Slider; 668 active = activeControl == QStyle::Slider;
589 WidgetType widget = horizontal ? 669 WidgetType widget = horizontal ?
590 active ? HScrollBarSliderDown : HScrollBarSlider : 670 active ? HScrollBarSliderDown : HScrollBarSlider :
591 active ? VScrollBarSliderDown : VScrollBarSlider; 671 active ? VScrollBarSliderDown : VScrollBarSlider;
592 672
593 drawBaseButton( p, slider.x(), slider.y(), slider.width(), 673 drawBaseButton( p, slider.x(), slider.y(), slider.width(),
594 slider.height(), *colorGroup( g, widget ), active, false, 674 slider.height(), *colorGroup( g, widget ), active, false,
595 widget ); 675 widget );
596 int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : 676 int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 :
597 slider.width(); 677 slider.width();
598 int spaceH = horizontal ? slider.height() : 678 int spaceH = horizontal ? slider.height() :
599 slider.height() - decoWidth( widget ) - 4; 679 slider.height() - decoWidth( widget ) - 4;
600widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : 680widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown :
601 horizontal ? HScrollDeco : VScrollDeco; 681 horizontal ? HScrollDeco : VScrollDeco;
602 if ( isPixmap( widget ) ) { 682 if ( isPixmap( widget ) ) {
603 if ( spaceW >= uncached( widget ) ->width() && 683 if ( spaceW >= uncached( widget ) ->width() &&
604 spaceH >= uncached( widget ) ->height() ) { 684 spaceH >= uncached( widget ) ->height() ) {
605 p->drawPixmap( slider.x() + ( slider.width() - 685 p->drawPixmap( slider.x() + ( slider.width() -
606 uncached( widget ) ->width() ) / 2, 686 uncached( widget ) ->width() ) / 2,
607 slider.y() + ( slider.height() - 687 slider.y() + ( slider.height() -
608 uncached( widget ) ->height() ) / 2, 688 uncached( widget ) ->height() ) / 2,
609 *uncached( widget ) ); 689 *uncached( widget ) );
610 } 690 }
611 } 691 }
612 } 692 }
613} 693}
614 694
615void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, 695void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb,
616 bool horizontal, QRect r, QColorGroup g ) 696 bool horizontal, QRect r, QColorGroup g )
617 697
618{ 698{
619 WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; 699 WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove;
620 if ( !isPixmap( widget ) ) { 700 if ( !isPixmap( widget ) ) {
621 p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); 701 p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) );
622 } 702 }
623 else { 703 else {
624 // If the groove is pixmapped we make a full-sized image (it gets 704 // If the groove is pixmapped we make a full-sized image (it gets
625 // cached) then bitBlt it to the appropriate rect. 705 // cached) then bitBlt it to the appropriate rect.
626 QPixmap buffer( sb->size() ); 706 QPixmap buffer( sb->size() );
627 QPainter bPainter( &buffer ); 707 QPainter bPainter( &buffer );
628 bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), 708 bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(),
629 *scalePixmap( buffer.width(), buffer.height(), 709 *scalePixmap( buffer.width(), buffer.height(),
630 widget ) ); 710 widget ) );
631 bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), 711 bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(),
632 r.height(), Qt::CopyROP ); 712 r.height(), Qt::CopyROP );
633 } 713 }
634 // Do the borders and frame 714 // Do the borders and frame
635 drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), 715 drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(),
636 sb->rect().height(), *colorGroup( g, widget ), true, false, 716 sb->rect().height(), *colorGroup( g, widget ), true, false,
637 highlightWidth( widget ), borderWidth( widget ), shade() ); 717 highlightWidth( widget ), borderWidth( widget ), shade() );
638} 718}
639 719
640void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, 720void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin,
641 int &sliderMax, int &sliderLength, 721 int &sliderMax, int &sliderLength,
642 int &buttonDim ) 722 int &buttonDim )
643{ 723{
644 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 724 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
645 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); 725 int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove );
646 int maxlen; 726 int maxlen;
647 int len = horizontal ? sb->width() : sb->height(); 727 int len = horizontal ? sb->width() : sb->height();
648 int extent = horizontal ? sb->height() : sb->width(); 728 int extent = horizontal ? sb->height() : sb->width();
649 729
650 if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) 730 if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 )
651 buttonDim = extent - offset * 2; 731 buttonDim = extent - offset * 2;
652 else 732 else
653 buttonDim = ( len - offset * 2 ) / 2 - 1; 733 buttonDim = ( len - offset * 2 ) / 2 - 1;
654 maxlen = len - offset * 2 - buttonDim * 2 - 1; 734 maxlen = len - offset * 2 - buttonDim * 2 - 1;
655 735
656 switch ( scrollBarLayout() ) { 736 switch ( scrollBarLayout() ) {
657 case SBBottomLeft: 737 case SBBottomLeft:
658 sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; 738 sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1;
659 break; 739 break;
660 case SBBottomRight: 740 case SBBottomRight:
661 sliderMin = offset + 1; 741 sliderMin = offset + 1;
662 break; 742 break;
663 case SBOpposite: 743 case SBOpposite:
664 default: 744 default:
665 sliderMin = offset + buttonDim; 745 sliderMin = offset + buttonDim;
666 break; 746 break;
667 } 747 }
668 if ( sb->maxValue() == sb->minValue() ) 748 if ( sb->maxValue() == sb->minValue() )
669 sliderLength = maxlen; 749 sliderLength = maxlen;
670 else 750 else
671 sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - 751 sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() -
672 sb->minValue() + sb->pageStep() ); 752 sb->minValue() + sb->pageStep() );
673 if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) 753 if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 )
674 sliderLength = 12; 754 sliderLength = 12;
675 if ( sliderLength > maxlen ) 755 if ( sliderLength > maxlen )
676 sliderLength = maxlen; 756 sliderLength = maxlen;
677 sliderMax = sliderMin + maxlen - sliderLength; 757 sliderMax = sliderMin + maxlen - sliderLength;
@@ -838,704 +918,730 @@ void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h,
838 bool tickBelow ) 918 bool tickBelow )
839{ 919{
840 // This is odd. If we fill in the entire region it still masks the slider 920 // This is odd. If we fill in the entire region it still masks the slider
841 // properly. I have no idea, this used to be different in Qt betas... 921 // properly. I have no idea, this used to be different in Qt betas...
842 if ( isPixmap( Slider ) ) 922 if ( isPixmap( Slider ) )
843 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); 923 p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) );
844 else 924 else
845 QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, 925 QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove,
846 tickBelow ); 926 tickBelow );
847} 927}
848 928
849int OThemeStyle::defaultFrameWidth() const 929int OThemeStyle::defaultFrameWidth() const
850{ 930{
851 return ( frameWidth() ); 931 return ( frameWidth() );
852} 932}
853 933
854void OThemeStyle::getButtonShift( int &x, int &y ) 934void OThemeStyle::getButtonShift( int &x, int &y )
855{ 935{
856 x = buttonXShift(); 936 x = buttonXShift();
857 y = buttonYShift(); 937 y = buttonYShift();
858} 938}
859 939
860int OThemeStyle::sliderLength() const 940int OThemeStyle::sliderLength() const
861{ 941{
862 return ( sliderButtonLength() ); 942 return ( sliderButtonLength() );
863} 943}
864 944
865void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, 945void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x,
866 int y, int w, int h, const QColorGroup &g, 946 int y, int w, int h, const QColorGroup &g,
867 bool enabled, const QBrush * ) 947 bool enabled, const QBrush * )
868{ 948{
869 // Handles pixmapped arrows. A little inefficent because you can specify 949 // Handles pixmapped arrows. A little inefficent because you can specify
870 // some as pixmaps and some as default types. 950 // some as pixmaps and some as default types.
871 WidgetType widget; 951 WidgetType widget;
872 switch ( type ) { 952 switch ( type ) {
873 case UpArrow: 953 case UpArrow:
874widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; 954widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp;
875 break; 955 break;
876 case DownArrow: 956 case DownArrow:
877widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; 957widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown;
878 break; 958 break;
879 case LeftArrow: 959 case LeftArrow:
880widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; 960widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft;
881 break; 961 break;
882 case RightArrow: 962 case RightArrow:
883 default: 963 default:
884widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; 964widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight;
885 break; 965 break;
886 } 966 }
887 if ( isPixmap( widget ) ) { 967 if ( isPixmap( widget ) ) {
888 p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, 968 p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2,
889 y + ( h - uncached( widget ) ->height() ) / 2, 969 y + ( h - uncached( widget ) ->height() ) / 2,
890 *uncached( widget ) ); 970 *uncached( widget ) );
891 return ; 971 return ;
892 } 972 }
893 const QColorGroup *cg = colorGroup( g, widget ); 973 const QColorGroup *cg = colorGroup( g, widget );
894 // Standard arrow types 974 // Standard arrow types
895 if ( arrowType() == MotifArrow ) 975 if ( arrowType() == MotifArrow )
896 qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); 976 qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled );
897 else if ( arrowType() == SmallArrow ) { 977 else if ( arrowType() == SmallArrow ) {
898 QColorGroup tmp( *cg ); 978 QColorGroup tmp( *cg );
899 tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); 979 tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) );
900 QWindowsStyle::drawArrow( p, type, false, x, y, w, h, 980 QWindowsStyle::drawArrow( p, type, false, x, y, w, h,
901 tmp, true ); 981 tmp, true );
902 } 982 }
903 else { 983 else {
904 QPointArray a; 984 QPointArray a;
905 int x2 = x + w - 1, y2 = y + h - 1; 985 int x2 = x + w - 1, y2 = y + h - 1;
906 switch ( type ) { 986 switch ( type ) {
907 case Qt::UpArrow: 987 case Qt::UpArrow:
908 a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); 988 a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 );
909 break; 989 break;
910 case Qt::DownArrow: 990 case Qt::DownArrow:
911 a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); 991 a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y );
912 break; 992 break;
913 case Qt::LeftArrow: 993 case Qt::LeftArrow:
914 a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); 994 a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y );
915 break; 995 break;
916 default: 996 default:
917 a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); 997 a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y );
918 break; 998 break;
919 } 999 }
920 QBrush oldBrush = p->brush(); 1000 QBrush oldBrush = p->brush();
921 QPen oldPen = p->pen(); 1001 QPen oldPen = p->pen();
922 p->setBrush( cg->brush( QColorGroup::Shadow ) ); 1002 p->setBrush( cg->brush( QColorGroup::Shadow ) );
923 p->setPen( cg->shadow() ); 1003 p->setPen( cg->shadow() );
924 p->drawPolygon( a ); 1004 p->drawPolygon( a );
925 p->setBrush( oldBrush ); 1005 p->setBrush( oldBrush );
926 p->setPen( oldPen ); 1006 p->setPen( oldPen );
927 } 1007 }
928} 1008}
929 1009
930/* This is where we draw the borders and highlights. The new round button 1010/* This is where we draw the borders and highlights. The new round button
931 * code is a pain in the arse. We don't want to be calculating arcs so 1011 * code is a pain in the arse. We don't want to be calculating arcs so
932 * use a whole lotta QPointArray's ;-) The code is made a lot more complex 1012 * use a whole lotta QPointArray's ;-) The code is made a lot more complex
933 * because you can have variable width border and highlights... 1013 * because you can have variable width border and highlights...
934 * I may want to cache this if round buttons are used, but am concerned 1014 * I may want to cache this if round buttons are used, but am concerned
935 * about excessive cache misses. This is a memory/speed tradeoff that I 1015 * about excessive cache misses. This is a memory/speed tradeoff that I
936 * have to test. 1016 * have to test.
937 */ 1017 */
938void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, 1018void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h,
939 const QColorGroup &g, bool sunken, bool rounded, 1019 const QColorGroup &g, bool sunken, bool rounded,
940 int hWidth, int bWidth, ShadeStyle style ) 1020 int hWidth, int bWidth, ShadeStyle style )
941{ 1021{
942 int i, sc, bc, x2, y2; 1022 int i, sc, bc, x2, y2;
943 QPen highPen, lowPen; 1023 QPen highPen, lowPen;
944 1024
945 if ( style == Motif ) { 1025 if ( style == Motif ) {
946 highPen.setColor( sunken ? g.dark() : g.light() ); 1026 highPen.setColor( sunken ? g.dark() : g.light() );
947 lowPen.setColor( sunken ? g.light() : g.dark() ); 1027 lowPen.setColor( sunken ? g.light() : g.dark() );
948 } 1028 }
949 else { 1029 else {
950 highPen.setColor( sunken ? g.shadow() : g.light() ); 1030 highPen.setColor( sunken ? g.shadow() : g.light() );
951 lowPen.setColor( sunken ? g.light() : g.shadow() ); 1031 lowPen.setColor( sunken ? g.light() : g.shadow() );
952 } 1032 }
953 1033
954 // Advanced round buttons 1034 // Advanced round buttons
955 if ( rounded && w > 19 && h > 19 ) { 1035 if ( rounded && w > 19 && h > 19 ) {
956 x2 = x + w - 1, y2 = y + h - 1; 1036 x2 = x + w - 1, y2 = y + h - 1;
957 QPointArray bPntArray, hPntArray, lPntArray; 1037 QPointArray bPntArray, hPntArray, lPntArray;
958 QPointArray bLineArray, hLineArray, lLineArray; 1038 QPointArray bLineArray, hLineArray, lLineArray;
959 // borders 1039 // borders
960 for ( i = 0, bc = 0; i < bWidth; ++i ) { 1040 for ( i = 0, bc = 0; i < bWidth; ++i ) {
961 bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, 1041 bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3,
962 x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, 1042 x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3,
963 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, 1043 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1,
964 x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, 1044 x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5,
965 x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, 1045 x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1,
966 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); 1046 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
967 bc += 24; 1047 bc += 24;
968 // ellispe edges don't match exactly, so fill in blanks 1048 // ellispe edges don't match exactly, so fill in blanks
969 if ( i < bWidth - 1 || hWidth != 0 ) { 1049 if ( i < bWidth - 1 || hWidth != 0 ) {
970 bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, 1050 bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3,
971 x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, 1051 x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2,
972 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, 1052 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1,
973 x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, 1053 x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
974 x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, 1054 x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6,
975 x2 - 2, y + 4 ); 1055 x2 - 2, y + 4 );
976 bc += 20; 1056 bc += 20;
977 } 1057 }
978 bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, 1058 bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6,
979 x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); 1059 x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
980 ++x, ++y; 1060 ++x, ++y;
981 --x2, --y2; 1061 --x2, --y2;
982 } 1062 }
983 // highlights 1063 // highlights
984 for ( i = 0, sc = 0; i < hWidth; ++i ) { 1064 for ( i = 0, sc = 0; i < hWidth; ++i ) {
985 hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left 1065 hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left
986 x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, 1066 x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5,
987 x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners 1067 x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners
988 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); 1068 x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 );
989 lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right 1069 lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right
990 x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, 1070 x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4,
991 x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners 1071 x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners
992 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); 1072 x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
993 sc += 12; 1073 sc += 12;
994 if ( i < hWidth - 1 ) { 1074 if ( i < hWidth - 1 ) {
995 hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left 1075 hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left
996 x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, 1076 x + 3, y + 3, x + 2, y + 4, x + 1, y + 6,
997 x2 - 6, y + 1, x2 - 4, y + 2, // half corners 1077 x2 - 6, y + 1, x2 - 4, y + 2, // half corners
998 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); 1078 x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 );
999 lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right 1079 lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right
1000 x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, 1080 x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
1001 x + 6, y2 - 1, x + 4, y2 - 2, // half corners 1081 x + 6, y2 - 1, x + 4, y2 - 2, // half corners
1002 x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); 1082 x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 );
1003 sc += 10; 1083 sc += 10;
1004 } 1084 }
1005 hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); 1085 hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 );
1006 lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); 1086 lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
1007 ++x, ++y; 1087 ++x, ++y;
1008 --x2, --y2; 1088 --x2, --y2;
1009 } 1089 }
1010 p->setPen( Qt::black ); 1090 p->setPen( Qt::black );
1011 p->drawPoints( bPntArray ); 1091 p->drawPoints( bPntArray );
1012 p->drawLineSegments( bLineArray ); 1092 p->drawLineSegments( bLineArray );
1013 p->setPen( highPen ); 1093 p->setPen( highPen );
1014 p->drawPoints( hPntArray ); 1094 p->drawPoints( hPntArray );
1015 p->drawLineSegments( hLineArray ); 1095 p->drawLineSegments( hLineArray );
1016 p->setPen( lowPen ); 1096 p->setPen( lowPen );
1017 p->drawPoints( lPntArray ); 1097 p->drawPoints( lPntArray );
1018 p->drawLineSegments( lLineArray ); 1098 p->drawLineSegments( lLineArray );
1019 } 1099 }
1020 // Rectangular buttons 1100 // Rectangular buttons
1021 else { 1101 else {
1022 QPointArray highShade( hWidth * 4 ); 1102 QPointArray highShade( hWidth * 4 );
1023 QPointArray lowShade( hWidth * 4 ); 1103 QPointArray lowShade( hWidth * 4 );
1024 1104
1025 p->setPen( g.shadow() ); 1105 p->setPen( g.shadow() );
1026 for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) 1106 for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 )
1027 p->drawRect( x, y , w, h ); 1107 p->drawRect( x, y , w, h );
1028 1108
1029 if ( !hWidth ) 1109 if ( !hWidth )
1030 return ; 1110 return ;
1031 1111
1032 x2 = x + w - 1, y2 = y + h - 1; 1112 x2 = x + w - 1, y2 = y + h - 1;
1033 for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { 1113 for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) {
1034 highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); 1114 highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 );
1035 lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); 1115 lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 );
1036 } 1116 }
1037 if ( style == Windows && hWidth > 1 ) { 1117 if ( style == Windows && hWidth > 1 ) {
1038 p->setPen( highPen ); 1118 p->setPen( highPen );
1039 p->drawLineSegments( highShade, 0, 2 ); 1119 p->drawLineSegments( highShade, 0, 2 );
1040 p->setPen( lowPen ); 1120 p->setPen( lowPen );
1041 p->drawLineSegments( lowShade, 0, 2 ); 1121 p->drawLineSegments( lowShade, 0, 2 );
1042 1122
1043 p->setPen( ( sunken ) ? g.dark() : g.mid() ); 1123 p->setPen( ( sunken ) ? g.dark() : g.mid() );
1044 p->drawLineSegments( highShade, 4 ); 1124 p->drawLineSegments( highShade, 4 );
1045 p->setPen( ( sunken ) ? g.mid() : g.dark() ); 1125 p->setPen( ( sunken ) ? g.mid() : g.dark() );
1046 p->drawLineSegments( lowShade, 4 ); 1126 p->drawLineSegments( lowShade, 4 );
1047 } 1127 }
1048 else { 1128 else {
1049 p->setPen( ( sunken ) ? g.dark() : g.light() ); 1129 p->setPen( ( sunken ) ? g.dark() : g.light() );
1050 p->drawLineSegments( highShade ); 1130 p->drawLineSegments( highShade );
1051 p->setPen( ( sunken ) ? g.light() : g.dark() ); 1131 p->setPen( ( sunken ) ? g.light() : g.dark() );
1052 p->drawLineSegments( lowShade ); 1132 p->drawLineSegments( lowShade );
1053 } 1133 }
1054 } 1134 }
1055} 1135}
1056 1136
1057void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) 1137void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
1058{ 1138{
1059 WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : 1139 WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown :
1060 PushButton; 1140 PushButton;
1061 const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); 1141 const QColorGroup *cg = colorGroup( btn->colorGroup(), widget );
1062 int x, y, w, h; 1142 int x, y, w, h;
1063 1143
1064 QRect r = btn->rect(); 1144 QRect r = btn->rect();
1065 r.rect( &x, &y, &w, &h ); 1145 r.rect( &x, &y, &w, &h );
1066 x += decoWidth( widget ); 1146 x += decoWidth( widget );
1067 y += decoWidth( widget ); 1147 y += decoWidth( widget );
1068 w -= decoWidth( widget ) * 2; 1148 w -= decoWidth( widget ) * 2;
1069 h -= decoWidth( widget ) * 2; 1149 h -= decoWidth( widget ) * 2;
1070 bool act = btn->isOn() || btn->isDown(); 1150 bool act = btn->isOn() || btn->isDown();
1071 1151
1072 // If this is a button with an associated popup menu, draw an arrow first 1152 // If this is a button with an associated popup menu, draw an arrow first
1073 if ( btn->popup() ) { 1153 if ( btn->popup() ) {
1074 int dx = menuButtonIndicatorWidth( btn->height() ); 1154 int dx = menuButtonIndicatorWidth( btn->height() );
1075 1155
1076 QColorGroup g( btn->colorGroup() ); 1156 QColorGroup g( btn->colorGroup() );
1077 int xx = x + w - dx - 4; 1157 int xx = x + w - dx - 4;
1078 int yy = y - 3; 1158 int yy = y - 3;
1079 int hh = h + 6; 1159 int hh = h + 6;
1080 1160
1081 if ( !act ) { 1161 if ( !act ) {
1082 p->setPen( g.light() ); 1162 p->setPen( g.light() );
1083 p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); 1163 p->drawLine( xx, yy + 3, xx, yy + hh - 4 );
1084 } 1164 }
1085 else { 1165 else {
1086 p->setPen( g.button() ); 1166 p->setPen( g.button() );
1087 p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); 1167 p->drawLine( xx, yy + 4, xx, yy + hh - 4 );
1088 } 1168 }
1089 drawArrow( p, DownArrow, FALSE, 1169 drawArrow( p, DownArrow, FALSE,
1090 x + w - dx - 2, y + 2, dx, h - 4, 1170 x + w - dx - 2, y + 2, dx, h - 4,
1091 btn->colorGroup(), 1171 btn->colorGroup(),
1092 btn->isEnabled() ); 1172 btn->isEnabled() );
1093 w -= dx; 1173 w -= dx;
1094 } 1174 }
1095 1175
1096 // Next, draw iconset, if any 1176 // Next, draw iconset, if any
1097 if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { 1177 if ( btn->iconSet() && !btn->iconSet() ->isNull() ) {
1098 QIconSet::Mode mode = btn->isEnabled() 1178 QIconSet::Mode mode = btn->isEnabled()
1099 ? QIconSet::Normal : QIconSet::Disabled; 1179 ? QIconSet::Normal : QIconSet::Disabled;
1100 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1180 if ( mode == QIconSet::Normal && btn->hasFocus() )
1101 mode = QIconSet::Active; 1181 mode = QIconSet::Active;
1102 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); 1182 QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode );
1103 int pixw = pixmap.width(); 1183 int pixw = pixmap.width();
1104 int pixh = pixmap.height(); 1184 int pixh = pixmap.height();
1105 1185
1106 p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); 1186 p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap );
1107 x += pixw + 8; 1187 x += pixw + 8;
1108 w -= pixw + 8; 1188 w -= pixw + 8;
1109 } 1189 }
1110 1190
1111 if ( widget == PushButtonDown ) { 1191 if ( widget == PushButtonDown ) {
1112 drawItem( p, x + buttonXShift(), y + buttonYShift(), 1192 drawItem( p, x + buttonXShift(), y + buttonYShift(),
1113 w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), 1193 w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(),
1114 btn->pixmap(), btn->text(), -1, &cg->buttonText() ); 1194 btn->pixmap(), btn->text(), -1, &cg->buttonText() );
1115 } 1195 }
1116 else { 1196 else {
1117 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, 1197 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg,
1118 btn->isEnabled(), btn->pixmap(), btn->text(), -1, 1198 btn->isEnabled(), btn->pixmap(), btn->text(), -1,
1119 &cg->buttonText() ); 1199 &cg->buttonText() );
1120 } 1200 }
1121} 1201}
1122 1202
1123int OThemeStyle::splitterWidth() const 1203int OThemeStyle::splitterWidth() const
1124{ 1204{
1125 return ( splitWidth() ); 1205 return ( splitWidth() );
1126} 1206}
1127 1207
1128void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, 1208void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h,
1129 const QColorGroup &g, Orientation ) 1209 const QColorGroup &g, Orientation )
1130{ 1210{
1131 drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, 1211 drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false,
1132 Splitter ); 1212 Splitter );
1133} 1213}
1134 1214
1135void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, 1215void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h,
1136 const QColorGroup &g, bool act, bool dis ) 1216 const QColorGroup &g, bool act, bool dis )
1137{ 1217{
1138 if ( isPixmap( CheckMark ) ) { 1218 if ( isPixmap( CheckMark ) ) {
1139 if ( !dis ) 1219 if ( !dis )
1140 p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, 1220 p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2,
1141 y + ( h - uncached( CheckMark ) ->height() ) / 2, 1221 y + ( h - uncached( CheckMark ) ->height() ) / 2,
1142 *uncached( CheckMark ) ); 1222 *uncached( CheckMark ) );
1143 } 1223 }
1144 else 1224 else
1145 QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), 1225 QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ),
1146 act, dis ); 1226 act, dis );
1147} 1227}
1148 1228
1149int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, 1229int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
1150 const QFontMetrics &fm ) 1230 const QFontMetrics &fm )
1151{ 1231{
1152 int h2, h = 0; 1232 int h2, h = 0;
1153 int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; 1233 int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4;
1154 1234
1155 if ( mi->isSeparator() ) 1235 if ( mi->isSeparator() )
1156 return ( 2 ); 1236 return ( 2 );
1157 if ( mi->isChecked() ) 1237 if ( mi->isChecked() )
1158 h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : 1238 h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset :
1159 offset + 16; 1239 offset + 16;
1160 if ( mi->pixmap() ) { 1240 if ( mi->pixmap() ) {
1161 h2 = mi->pixmap() ->height() + offset; 1241 h2 = mi->pixmap() ->height() + offset;
1162 h = h2 > h ? h2 : h; 1242 h = h2 > h ? h2 : h;
1163 } 1243 }
1164 if ( mi->iconSet() ) { 1244 if ( mi->iconSet() ) {
1165 h2 = mi->iconSet() -> 1245 h2 = mi->iconSet() ->
1166 pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; 1246 pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset;
1167 h = h2 > h ? h2 : h; 1247 h = h2 > h ? h2 : h;
1168 } 1248 }
1169 h2 = fm.height() + offset; 1249 h2 = fm.height() + offset;
1170 h = h2 > h ? h2 : h; 1250 h = h2 > h ? h2 : h;
1171 return ( h ); 1251 return ( h );
1172} 1252}
1173 1253
1174void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 1254void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
1175 int tab, QMenuItem* mi, 1255 int tab, QMenuItem* mi,
1176 const QPalette& pal, bool act, 1256 const QPalette& pal, bool act,
1177 bool enabled, int x, int y, int w, int h ) 1257 bool enabled, int x, int y, int w, int h )
1178{ 1258{
1179 // I changed the following method to be based from Qt's instead of my own 1259 // I changed the following method to be based from Qt's instead of my own
1180 // wacky code. Works much better now :P (mosfet) 1260 // wacky code. Works much better now :P (mosfet)
1181 static const int motifItemFrame = 2; // menu item frame width 1261 static const int motifItemFrame = 2; // menu item frame width
1182 static const int motifItemHMargin = 5; // menu item hor text margin 1262 static const int motifItemHMargin = 5; // menu item hor text margin
1183 static const int motifItemVMargin = 4; // menu item ver text margin 1263 static const int motifItemVMargin = 4; // menu item ver text margin
1184 1264
1185 static const int motifArrowHMargin = 6; // arrow horizontal margin 1265 static const int motifArrowHMargin = 6; // arrow horizontal margin
1186 static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows 1266 static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows
1187 bool dis = !enabled; 1267 bool dis = !enabled;
1188 const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : 1268 const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) :
1189 *colorGroup( pal.normal(), MenuItemDown ); 1269 *colorGroup( pal.normal(), MenuItemDown );
1190 1270
1191 QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) 1271 QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem )
1192 : act ? *colorGroup( pal.active(), MenuItemDown ) 1272 : act ? *colorGroup( pal.active(), MenuItemDown )
1193 : *colorGroup( pal.normal(), MenuItem ); 1273 : *colorGroup( pal.normal(), MenuItem );
1194 1274
1195 maxpmw = QMAX( maxpmw, 20 ); 1275 maxpmw = QMAX( maxpmw, 20 );
1196 int checkcol = maxpmw; 1276 int checkcol = maxpmw;
1197 1277
1198 if ( mi && mi->isSeparator() ) { 1278 if ( mi && mi->isSeparator() ) {
1199 p->setPen( g.dark() ); 1279 p->setPen( g.dark() );
1200 p->drawLine( x, y, x + w, y ); 1280 p->drawLine( x, y, x + w, y );
1201 p->setPen( g.light() ); 1281 p->setPen( g.light() );
1202 p->drawLine( x, y + 1, x + w, y + 1 ); 1282 p->drawLine( x, y + 1, x + w, y + 1 );
1203 return ; 1283 return ;
1204 } 1284 }
1205 if ( act ) { 1285 if ( act ) {
1206 drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); 1286 drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown );
1207 } 1287 }
1208 else { 1288 else {
1209 drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, 1289 drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false,
1210 highlightWidth( MenuItem ), borderWidth( MenuItem ), 1290 highlightWidth( MenuItem ), borderWidth( MenuItem ),
1211 shade() ); 1291 shade() );
1212 int dw = decoWidth( MenuItem ); 1292 int dw = decoWidth( MenuItem );
1213 if ( !isPixmap( MenuItem ) ) { 1293 if ( !isPixmap( MenuItem ) ) {
1214 p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, 1294 p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2,
1215 colorGroup( g, MenuItem ) -> 1295 colorGroup( g, MenuItem ) ->
1216 brush( QColorGroup::Background ) ); 1296 brush( QColorGroup::Background ) );
1217 } 1297 }
1218 else { 1298 else {
1219 // process inactive item pixmaps as one large item 1299 // process inactive item pixmaps as one large item
1220 p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap 1300 p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap
1221 (w, ((QWidget *)p->device())->height(), MenuItem), 1301 (w, ((QWidget *)p->device())->height(), MenuItem),
1222 //( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E 1302 //( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E
1223 x, y ); 1303 x, y );
1224 } 1304 }
1225 1305
1226 if ( checkable && mi && mi->isChecked() ) { 1306 if ( checkable && mi && mi->isChecked() ) {
1227 // draw 'pressed' border around checkable items 1307 // draw 'pressed' border around checkable items
1228 // This is extremely important for items that have an iconset 1308 // This is extremely important for items that have an iconset
1229 // because the checkmark isn't drawn in that case 1309 // because the checkmark isn't drawn in that case
1230 // An alternative would be superimposing the checkmark over 1310 // An alternative would be superimposing the checkmark over
1231 // the iconset instead or not drawing the iconset at all. 1311 // the iconset instead or not drawing the iconset at all.
1232 int mw = checkcol + motifItemFrame; 1312 int mw = checkcol + motifItemFrame;
1233 drawShade( p, x, y, mw, h, g, true, false, 1313 drawShade( p, x, y, mw, h, g, true, false,
1234 highlightWidth( MenuItemDown ), 1314 highlightWidth( MenuItemDown ),
1235 borderWidth( MenuItemDown ), shade() ); 1315 borderWidth( MenuItemDown ), shade() );
1236 } 1316 }
1237 } 1317 }
1238 if ( !mi ) 1318 if ( !mi )
1239 return ; 1319 return ;
1240 if ( mi->iconSet() ) { 1320 if ( mi->iconSet() ) {
1241 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; 1321 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
1242 if ( act && !dis ) 1322 if ( act && !dis )
1243 mode = QIconSet::Active; 1323 mode = QIconSet::Active;
1244 QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); 1324 QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode );
1245 int pixw = pixmap.width(); 1325 int pixw = pixmap.width();
1246 int pixh = pixmap.height(); 1326 int pixh = pixmap.height();
1247 QRect cr( x, y, checkcol, h ); 1327 QRect cr( x, y, checkcol, h );
1248 QRect pmr( 0, 0, pixw, pixh ); 1328 QRect pmr( 0, 0, pixw, pixh );
1249 pmr.moveCenter( cr.center() ); 1329 pmr.moveCenter( cr.center() );
1250 p->setPen( itemg.text() ); 1330 p->setPen( itemg.text() );
1251 p->drawPixmap( pmr.topLeft(), pixmap ); 1331 p->drawPixmap( pmr.topLeft(), pixmap );
1252 1332
1253 } 1333 }
1254 else if ( checkable ) { 1334 else if ( checkable ) {
1255 int mw = checkcol + motifItemFrame; 1335 int mw = checkcol + motifItemFrame;
1256 int mh = h - 2 * motifItemFrame; 1336 int mh = h - 2 * motifItemFrame;
1257 if ( mi->isChecked() ) { 1337 if ( mi->isChecked() ) {
1258 drawCheckMark( p, x + motifItemFrame, 1338 drawCheckMark( p, x + motifItemFrame,
1259 y + motifItemFrame, mw, mh, itemg, act, dis ); 1339 y + motifItemFrame, mw, mh, itemg, act, dis );
1260 } 1340 }
1261 } 1341 }
1262 1342
1263 p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); 1343 p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() );
1264 1344
1265 QColor discol; 1345 QColor discol;
1266 if ( dis ) { 1346 if ( dis ) {
1267 discol = itemg.text(); 1347 discol = itemg.text();
1268 p->setPen( discol ); 1348 p->setPen( discol );
1269 } 1349 }
1270 1350
1271 int xm = motifItemFrame + checkcol + motifItemHMargin; 1351 int xm = motifItemFrame + checkcol + motifItemHMargin;
1272 1352
1273 QString s = mi->text(); 1353 QString s = mi->text();
1274 if ( !s.isNull() ) { 1354 if ( !s.isNull() ) {
1275 int t = s.find( '\t' ); 1355 int t = s.find( '\t' );
1276 int m = motifItemVMargin; 1356 int m = motifItemVMargin;
1277 const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; 1357 const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
1278 if ( t >= 0 ) { 1358 if ( t >= 0 ) {
1279 if ( dis && !act ) { 1359 if ( dis && !act ) {
1280 p->setPen( g.light() ); 1360 p->setPen( g.light() );
1281 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, 1361 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1,
1282 y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); 1362 y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
1283 p->setPen( discol ); 1363 p->setPen( discol );
1284 } 1364 }
1285 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, 1365 p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame,
1286 y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); 1366 y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
1287 } 1367 }
1288 if ( dis && !act ) { 1368 if ( dis && !act ) {
1289 p->setPen( g.light() ); 1369 p->setPen( g.light() );
1290 p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); 1370 p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t );
1291 p->setPen( discol ); 1371 p->setPen( discol );
1292 } 1372 }
1293 p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); 1373 p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t );
1294 } 1374 }
1295 else if ( mi->pixmap() ) { 1375 else if ( mi->pixmap() ) {
1296 QPixmap * pixmap = mi->pixmap(); 1376 QPixmap * pixmap = mi->pixmap();
1297 if ( pixmap->depth() == 1 ) 1377 if ( pixmap->depth() == 1 )
1298 p->setBackgroundMode( OpaqueMode ); 1378 p->setBackgroundMode( OpaqueMode );
1299 p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); 1379 p->drawPixmap( x + xm, y + motifItemFrame, *pixmap );
1300 if ( pixmap->depth() == 1 ) 1380 if ( pixmap->depth() == 1 )
1301 p->setBackgroundMode( TransparentMode ); 1381 p->setBackgroundMode( TransparentMode );
1302 } 1382 }
1303 if ( mi->popup() ) { 1383 if ( mi->popup() ) {
1304 int dim = ( h - 2 * motifItemFrame ) / 2; 1384 int dim = ( h - 2 * motifItemFrame ) / 2;
1305 if ( act ) { 1385 if ( act ) {
1306 if ( !dis ) 1386 if ( !dis )
1307 discol = colorGroup( g, MenuItemDown ) ->text(); 1387 discol = colorGroup( g, MenuItemDown ) ->text();
1308 //discol = white; 1388 //discol = white;
1309 QColorGroup g2( discol, g.highlight(), 1389 QColorGroup g2( discol, g.highlight(),
1310 white, white, 1390 white, white,
1311 dis ? discol : white, 1391 dis ? discol : white,
1312 discol, white ); 1392 discol, white );
1313 drawArrow( p, RightArrow, true, 1393 drawArrow( p, RightArrow, true,
1314 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, 1394 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
1315 dim, dim, g2, TRUE ); 1395 dim, dim, g2, TRUE );
1316 } 1396 }
1317 else { 1397 else {
1318 drawArrow( p, RightArrow, 1398 drawArrow( p, RightArrow,
1319 false, 1399 false,
1320 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, 1400 x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
1321 dim, dim, g, mi->isEnabled() ); 1401 dim, dim, g, mi->isEnabled() );
1322 } 1402 }
1323 } 1403 }
1324} 1404}
1325 1405
1326void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, 1406void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r,
1327 const QColorGroup &g, const QColor *c, 1407 const QColorGroup &g, const QColor *c,
1328 bool atBorder ) 1408 bool atBorder )
1329{ 1409{
1330 p->setPen( g.dark() ); 1410 p->setPen( g.dark() );
1331 if ( !is3DFocus() ) 1411 if ( !is3DFocus() )
1332 QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); 1412 QWindowsStyle::drawFocusRect( p, r, g, c, atBorder );
1333 else { 1413 else {
1334 int i = focusOffset(); 1414 int i = focusOffset();
1335 p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); 1415 p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i );
1336 p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); 1416 p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i );
1337 p->setPen( g.light() ); 1417 p->setPen( g.light() );
1338 p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); 1418 p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i );
1339 p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); 1419 p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i );
1340 } 1420 }
1341} 1421}
1342 1422
1343#if 0 1423#if 0
1344void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, 1424void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h,
1345 const QColorGroup &g, bool, QBrush * ) 1425 const QColorGroup &g, bool, QBrush * )
1346{ 1426{
1347 drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, 1427 drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false,
1348 MenuBar ); 1428 MenuBar );
1349} 1429}
1430#endif
1350 1431
1351void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, 1432void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
1352 const QColorGroup &g, bool active, 1433 QMenuItem *mi, const QColorGroup &g,
1353 QMenuItem *mi, QBrush * ) 1434 bool /*enabled*/, bool active )
1354{ 1435{
1436 if(active){
1437 x -= 2; // Bug in Qt/E
1438 y -= 2;
1439 w += 2;
1440 h += 2;
1441 }
1442
1355 const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); 1443 const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar );
1356 QColor btext = cg->buttonText(); 1444 QColor btext = cg->buttonText();
1357 if ( active ) 1445 if ( active )
1358 drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); 1446 drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem );
1359 //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); 1447 //qDrawShadePanel(p, x, y, w, h, *cg, false, 1);
1360 1448
1361 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, 1449 drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine,
1362 *cg, mi->isEnabled(), mi->pixmap(), mi->text(), 1450 *cg, mi-> isEnabled ( ), mi->pixmap(), mi->text(),
1363 -1, &btext ); 1451 -1, &btext );
1364 ;
1365} 1452}
1366 1453
1454
1455
1456void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int percent )
1457{
1458 const QColorGroup * cg = colorGroup( g, ProgressBg );
1459 QBrush bg;
1460 bg.setColor( cg->color( QColorGroup::Background ) );
1461 if ( isPixmap( ProgressBg ) )
1462 bg.setPixmap( *uncached( ProgressBg ) );
1463
1464 int pw = w * percent / 100;
1465
1466 p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO
1467
1468 drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar );
1469}
1470
1471#if 0
1472
1367void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, 1473void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h,
1368 const QColorGroup &g, QBrush * ) 1474 const QColorGroup &g, QBrush * )
1369{ 1475{
1370 drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, 1476 drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false,
1371 ProgressBar ); 1477 ProgressBar );
1372} 1478}
1373 1479
1374void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) 1480void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg )
1375{ 1481{
1376 const QColorGroup * cg = colorGroup( g, ProgressBg ); 1482 const QColorGroup * cg = colorGroup( g, ProgressBg );
1377 bg.setColor( cg->color( QColorGroup::Background ) ); 1483 bg.setColor( cg->color( QColorGroup::Background ) );
1378 if ( isPixmap( ProgressBg ) ) 1484 if ( isPixmap( ProgressBg ) )
1379 bg.setPixmap( *uncached( ProgressBg ) ); 1485 bg.setPixmap( *uncached( ProgressBg ) );
1380} 1486}
1381#endif 1487#endif
1382 1488
1383void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) 1489void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap )
1384{ 1490{
1385 QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); 1491 QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap );
1386} 1492}
1387 1493
1388void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , 1494void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t ,
1389 bool selected ) 1495 bool selected )
1390{ 1496{
1391 WidgetType widget = selected ? ActiveTab : InactiveTab; 1497 WidgetType widget = selected ? ActiveTab : InactiveTab;
1392 const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); 1498 const QColorGroup *cg = colorGroup( tb->colorGroup(), widget );
1393 int i; 1499 int i;
1394 int x = t->r.x(), y = t->r.y(); 1500 int x = t->r.x(), y = t->r.y();
1395 int x2 = t->r.right(), y2 = t->r.bottom(); 1501 int x2 = t->r.right(), y2 = t->r.bottom();
1396 int bWidth = borderWidth( widget ); 1502 int bWidth = borderWidth( widget );
1397 int hWidth = highlightWidth( widget ); 1503 int hWidth = highlightWidth( widget );
1398 if ( tb->shape() == QTabBar::RoundedAbove ) { 1504 if ( tb->shape() == QTabBar::RoundedAbove ) {
1399 if ( !selected ) { 1505 if ( !selected ) {
1400 p->fillRect( x, y, x2 - x + 1, 2, 1506 p->fillRect( x, y, x2 - x + 1, 2,
1401 tb->palette().normal().brush( QColorGroup::Background ) ); 1507 tb->palette().normal().brush( QColorGroup::Background ) );
1402 y += 2; 1508 y += 2;
1403 } 1509 }
1404 p->setPen( cg->text() ); 1510 p->setPen( cg->text() );
1405 i = 0; 1511 i = 0;
1406 if ( i < bWidth ) { 1512 if ( i < bWidth ) {
1407 p->drawLine( x, y + 1, x, y2 ); 1513 p->drawLine( x, y + 1, x, y2 );
1408 p->drawLine( x2, y + 1, x2, y2 ); 1514 p->drawLine( x2, y + 1, x2, y2 );
1409 p->drawLine( x + 1, y, x2 - 1, y ); 1515 p->drawLine( x + 1, y, x2 - 1, y );
1410 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1516 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1411 p->drawLine( x, y2, x2, y2 ); 1517 p->drawLine( x, y2, x2, y2 );
1412 --y2; 1518 --y2;
1413 } 1519 }
1414 ++i, ++x, ++y, --x2; 1520 ++i, ++x, ++y, --x2;
1415 } 1521 }
1416 for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { 1522 for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) {
1417 p->drawLine( x, y, x, y2 ); 1523 p->drawLine( x, y, x, y2 );
1418 p->drawLine( x2, y, x2, y2 ); 1524 p->drawLine( x2, y, x2, y2 );
1419 p->drawLine( x, y, x2, y ); 1525 p->drawLine( x, y, x2, y );
1420 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1526 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1421 p->drawLine( x, y2, x2, y2 ); 1527 p->drawLine( x, y2, x2, y2 );
1422 --y2; 1528 --y2;
1423 } 1529 }
1424 } 1530 }
1425 i = 0; 1531 i = 0;
1426 if ( i < hWidth && bWidth == 0 ) { 1532 if ( i < hWidth && bWidth == 0 ) {
1427 p->setPen( cg->light() ); 1533 p->setPen( cg->light() );
1428 p->drawLine( x, y + 1, x, y2 ); 1534 p->drawLine( x, y + 1, x, y2 );
1429 p->drawLine( x + 1, y, x2 - 1, y ); 1535 p->drawLine( x + 1, y, x2 - 1, y );
1430 p->setPen( cg->dark() ); 1536 p->setPen( cg->dark() );
1431 p->drawLine( x2, y + 1, x2, y2 ); 1537 p->drawLine( x2, y + 1, x2, y2 );
1432 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1538 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1433 p->drawLine( x, y2, x2, y2 ); 1539 p->drawLine( x, y2, x2, y2 );
1434 --y2; 1540 --y2;
1435 } 1541 }
1436 ++i, ++x, ++y, --x2; 1542 ++i, ++x, ++y, --x2;
1437 } 1543 }
1438 for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { 1544 for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) {
1439 p->setPen( cg->light() ); 1545 p->setPen( cg->light() );
1440 p->drawLine( x, y, x, y2 ); 1546 p->drawLine( x, y, x, y2 );
1441 p->drawLine( x, y, x2, y ); 1547 p->drawLine( x, y, x2, y );
1442 p->setPen( cg->dark() ); 1548 p->setPen( cg->dark() );
1443 p->drawLine( x2, y + 1, x2, y2 ); 1549 p->drawLine( x2, y + 1, x2, y2 );
1444 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1550 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1445 p->drawLine( x, y2, x2, y2 ); 1551 p->drawLine( x, y2, x2, y2 );
1446 --y2; 1552 --y2;
1447 } 1553 }
1448 } 1554 }
1449 if ( isPixmap( widget ) ) 1555 if ( isPixmap( widget ) )
1450 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, 1556 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
1451 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); 1557 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
1452 else 1558 else
1453 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); 1559 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
1454 } 1560 }
1455 else if ( tb->shape() == QTabBar::RoundedBelow ) { 1561 else if ( tb->shape() == QTabBar::RoundedBelow ) {
1456 if ( !selected ) { 1562 if ( !selected ) {
1457 p->fillRect( x, y2 - 2, x2 - x + 1, 2, 1563 p->fillRect( x, y2 - 2, x2 - x + 1, 2,
1458 tb->palette().normal().brush( QColorGroup::Background ) ); 1564 tb->palette().normal().brush( QColorGroup::Background ) );
1459 y2 -= 2; 1565 y2 -= 2;
1460 } 1566 }
1461 p->setPen( cg->text() ); 1567 p->setPen( cg->text() );
1462 i = 0; 1568 i = 0;
1463 if ( i < bWidth ) { 1569 if ( i < bWidth ) {
1464 p->drawLine( x, y, x, y2 - 1 ); 1570 p->drawLine( x, y, x, y2 - 1 );
1465 p->drawLine( x2, y, x2, y2 - 1 ); 1571 p->drawLine( x2, y, x2, y2 - 1 );
1466 p->drawLine( x + 1, y2, x2 - 1, y2 ); 1572 p->drawLine( x + 1, y2, x2 - 1, y2 );
1467 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1573 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1468 p->drawLine( x, y, x2, y ); 1574 p->drawLine( x, y, x2, y );
1469 ++y; 1575 ++y;
1470 } 1576 }
1471 } 1577 }
1472 for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { 1578 for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) {
1473 p->drawLine( x, y, x, y2 ); 1579 p->drawLine( x, y, x, y2 );
1474 p->drawLine( x2, y, x2, y2 ); 1580 p->drawLine( x2, y, x2, y2 );
1475 p->drawLine( x, y2, x2, y2 ); 1581 p->drawLine( x, y2, x2, y2 );
1476 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1582 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1477 p->drawLine( x, y, x2, y ); 1583 p->drawLine( x, y, x2, y );
1478 ++y; 1584 ++y;
1479 } 1585 }
1480 } 1586 }
1481 i = 0; 1587 i = 0;
1482 if ( i < hWidth && bWidth == 0 ) { 1588 if ( i < hWidth && bWidth == 0 ) {
1483 p->setPen( cg->dark() ); 1589 p->setPen( cg->dark() );
1484 p->drawLine( x + 1, y2, x2 - 1, y2 ); 1590 p->drawLine( x + 1, y2, x2 - 1, y2 );
1485 p->drawLine( x2, y, x2, y2 - 1 ); 1591 p->drawLine( x2, y, x2, y2 - 1 );
1486 p->setPen( cg->light() ); 1592 p->setPen( cg->light() );
1487 p->drawLine( x, y, x, y2 - 1 ); 1593 p->drawLine( x, y, x, y2 - 1 );
1488 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1594 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1489 p->drawLine( x, y, x2, y ); 1595 p->drawLine( x, y, x2, y );
1490 ++y; 1596 ++y;
1491 } 1597 }
1492 ++i, ++x, --x2, --y2; 1598 ++i, ++x, --x2, --y2;
1493 } 1599 }
1494 for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { 1600 for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) {
1495 p->setPen( cg->dark() ); 1601 p->setPen( cg->dark() );
1496 p->drawLine( x, y2, x2, y2 ); 1602 p->drawLine( x, y2, x2, y2 );
1497 p->drawLine( x2, y, x2, y2 ); 1603 p->drawLine( x2, y, x2, y2 );
1498 p->setPen( cg->light() ); 1604 p->setPen( cg->light() );
1499 p->drawLine( x, y, x, y2 ); 1605 p->drawLine( x, y, x, y2 );
1500 if ( selected ? activeTabLine() : inactiveTabLine() ) { 1606 if ( selected ? activeTabLine() : inactiveTabLine() ) {
1501 p->drawLine( x, y, x2, y ); 1607 p->drawLine( x, y, x2, y );
1502 ++y; 1608 ++y;
1503 } 1609 }
1504 } 1610 }
1505 if ( isPixmap( widget ) ) 1611 if ( isPixmap( widget ) )
1506 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, 1612 p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
1507 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); 1613 *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
1508 else 1614 else
1509 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); 1615 p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
1510 } 1616 }
1511 else 1617 else
1512 QCommonStyle::drawTab( p, tb, t, selected ); 1618 QCommonStyle::drawTab( p, tb, t, selected );
1513} 1619}
1514 1620
1515void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, 1621void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t,
1516 bool selected ) 1622 bool selected )
1517{ 1623{
1518 QRect r( t->r ); 1624 QRect r( t->r );
1519 1625
1520 if ( tb->shape() == QTabBar::RoundedAbove ) { 1626 if ( tb->shape() == QTabBar::RoundedAbove ) {
1521 if ( !selected ) 1627 if ( !selected )
1522 r.setTop( r.top() + 2 ); 1628 r.setTop( r.top() + 2 );
1523 p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); 1629 p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() );
1524 QBrush b( color1, SolidPattern ); 1630 QBrush b( color1, SolidPattern );
1525 p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); 1631 p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b );
1526 } 1632 }
1527 else if ( tb->shape() == QTabBar::RoundedBelow ) { 1633 else if ( tb->shape() == QTabBar::RoundedBelow ) {
1528 if ( !selected ) 1634 if ( !selected )
1529 r.setBottom( r.bottom() - 2 ); 1635 r.setBottom( r.bottom() - 2 );
1530 p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); 1636 p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() );
1531 QBrush b( color1, SolidPattern ); 1637 QBrush b( color1, SolidPattern );
1532 p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); 1638 p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b );
1533 } 1639 }
1534 else 1640 else
1535 QCommonStyle::drawTabMask( p, tb, t, selected ); 1641 QCommonStyle::drawTabMask( p, tb, t, selected );
1536 1642
1537} 1643}
1538 1644
1539 1645
1540//#include "kthemestyle.moc" 1646//#include "kthemestyle.moc"
1541 1647
diff --git a/noncore/styles/theme/othemestyle.h b/noncore/styles/theme/othemestyle.h
index 52445c4..406b35b 100644
--- a/noncore/styles/theme/othemestyle.h
+++ b/noncore/styles/theme/othemestyle.h
@@ -1,371 +1,371 @@
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#ifndef __KTHEMESTYLE_H 18#ifndef __KTHEMESTYLE_H
19#define __KTHEMESTYLE_H 19#define __KTHEMESTYLE_H
20 20
21#include "othemebase.h" 21#include "othemebase.h"
22#include <qwindowdefs.h> 22#include <qwindowdefs.h>
23#include <qobject.h> 23#include <qobject.h>
24#include <qbutton.h> 24#include <qbutton.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qscrollbar.h> 26#include <qscrollbar.h>
27#include <qstring.h> 27#include <qstring.h>
28 28
29class QProgressBar;
30
29 31
30/** 32/**
31 * KDE themed styles. 33 * KDE themed styles.
32 * 34 *
33 * It provides methods for 35 * It provides methods for
34 * drawing most widgets with user-specified borders, highlights, pixmaps, 36 * drawing most widgets with user-specified borders, highlights, pixmaps,
35 * etc. It also handles various other settings such as scrollbar types, 37 * etc. It also handles various other settings such as scrollbar types,
36 * rounded buttons, and shading types. For a full list of parameters this 38 * rounded buttons, and shading types. For a full list of parameters this
37 * class handles refer to the KDE theme configuration documentation. 39 * class handles refer to the KDE theme configuration documentation.
38 * 40 *
39 */ 41 */
40 42
41class OThemeStyle: public OThemeBase 43class OThemeStyle: public OThemeBase
42{ 44{
43 Q_OBJECT 45 Q_OBJECT
44public: 46public:
45 /** 47 /**
46 * Construct a new @ref OThemeStyle object. 48 * Construct a new @ref OThemeStyle object.
47 * 49 *
48 * @param configFile A KConfig file to use as the theme configuration. 50 * @param configFile A KConfig file to use as the theme configuration.
49 * Defaults to ~/.kderc. 51 * Defaults to ~/.kderc.
50 */ 52 */
51 OThemeStyle( const QString &configFile = QString::null ); 53 OThemeStyle( const QString &configFile = QString::null );
52 ~OThemeStyle(); 54 ~OThemeStyle();
53 virtual void polish( QWidget* ); 55 virtual void polish( QWidget* );
54 virtual void unPolish( QWidget* ); 56 virtual void unPolish( QWidget* );
55 /** 57 /**
56 * By default this just sets the background brushes to the pixmapped 58 * By default this just sets the background brushes to the pixmapped
57 * background. 59 * background.
58 */ 60 */
59 virtual void polish( QApplication *app ); 61 virtual void polish( QApplication *app );
60 virtual void unPolish( QApplication* ); 62 virtual void unPolish( QApplication* );
61 63
62 /// @internal 64 /// @internal
63 // to make it possible for derived classes to overload this function 65 // to make it possible for derived classes to overload this function
64 virtual void polish( QPalette& pal ); 66 virtual void polish( QPalette& pal );
65 67
68 virtual bool eventFilter ( QObject *obj, QEvent *ev );
69
66 /** 70 /**
67 * This is a convenience method for drawing widgets with 71 * This is a convenience method for drawing widgets with
68 * borders, highlights, pixmaps, colors, etc... 72 * borders, highlights, pixmaps, colors, etc...
69 * You specify the widget type and it will draw it according to the 73 * You specify the widget type and it will draw it according to the
70 * config file settings. 74 * config file settings.
71 * 75 *
72 * @param p The QPainter to draw on. 76 * @param p The QPainter to draw on.
73 * @param g The color group to use. 77 * @param g The color group to use.
74 * @param rounded @p true if the widget is rounded, @p false if rectangular. 78 * @param rounded @p true if the widget is rounded, @p false if rectangular.
75 * @param type The widget type to paint. 79 * @param type The widget type to paint.
76 * @param fill An optional fill brush. Currently ignored (the config file 80 * @param fill An optional fill brush. Currently ignored (the config file
77 * is used instead). 81 * is used instead).
78 */ 82 */
79 virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h, 83 virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h,
80 const QColorGroup &g, bool sunken = FALSE, 84 const QColorGroup &g, bool sunken = FALSE,
81 bool rounded = FALSE, WidgetType type = Bevel, 85 bool rounded = FALSE, WidgetType type = Bevel,
82 const QBrush *fill = 0 ); 86 const QBrush *fill = 0 );
83 /** 87 /**
84 * Draw a mask with for widgets that may be rounded. 88 * Draw a mask with for widgets that may be rounded.
85 * 89 *
86 *Currently used 90 *Currently used
87 * by pushbuttons and comboboxes. 91 * by pushbuttons and comboboxes.
88 * 92 *
89 * @param p The QPainter to draw on. 93 * @param p The QPainter to draw on.
90 * @param rounded @p true if the widget is rounded, @p false if rectangular. 94 * @param rounded @p true if the widget is rounded, @p false if rectangular.
91 */ 95 */
92 virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h, 96 virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h,
93 bool rounded ); 97 bool rounded );
94 /** 98 /**
95 * Draw a pushbutton. 99 * Draw a pushbutton.
96 * 100 *
97 * This calls @ref drawBaseButton() with @p PushButton as the 101 * This calls @ref drawBaseButton() with @p PushButton as the
98 * widget type. 102 * widget type.
99 */ 103 */
100 virtual void drawButton( QPainter *p, int x, int y, int w, int h, 104 virtual void drawButton( QPainter *p, int x, int y, int w, int h,
101 const QColorGroup &g, bool sunken = FALSE, 105 const QColorGroup &g, bool sunken = FALSE,
102 const QBrush *fill = 0 ); 106 const QBrush *fill = 0 );
103 /** 107 /**
104 * Draw a bevel button. 108 * Draw a bevel button.
105 * 109 *
106 * This calls @ref drawBaseButton() with Bevel as the 110 * This calls @ref drawBaseButton() with Bevel as the
107 * widget type. 111 * widget type.
108 */ 112 */
109 virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h, 113 virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h,
110 const QColorGroup &g, bool sunken = FALSE, 114 const QColorGroup &g, bool sunken = FALSE,
111 const QBrush *fill = 0 ); 115 const QBrush *fill = 0 );
112 /** 116 /**
113 * Draw a toolbar button. 117 * Draw a toolbar button.
114 */ 118 */
115 virtual void drawToolButton ( QPainter *p, int x, int y, int w, int h, 119 virtual void drawToolButton ( QPainter *p, int x, int y, int w, int h,
116 const QColorGroup &g, bool sunken = FALSE, 120 const QColorGroup &g, bool sunken = FALSE,
117 const QBrush *fill = 0 ); 121 const QBrush *fill = 0 );
118#if 0 122#if 0
119 /** 123 /**
120 * Draw a toolbar button. 124 * Draw a toolbar button.
121 */ 125 */
122 virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h, 126 virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
123 const QColorGroup &g, bool sunken = false, 127 const QColorGroup &g, bool sunken = false,
124 bool raised = true, bool enabled = true, 128 bool raised = true, bool enabled = true,
125 bool popup = false, KToolButtonType type = Icon, 129 bool popup = false, KToolButtonType type = Icon,
126 const QString &btext = QString::null, 130 const QString &btext = QString::null,
127 const QPixmap *icon = NULL, 131 const QPixmap *icon = NULL,
128 QFont *font = NULL, QWidget *btn = NULL ); 132 QFont *font = NULL, QWidget *btn = NULL );
129 /** 133 /**
130 * Draw the handle used in toolbars. 134 * Draw the handle used in toolbars.
131 */ 135 */
132 void drawKBarHandle( QPainter *p, int x, int y, int w, int h, 136 void drawKBarHandle( QPainter *p, int x, int y, int w, int h,
133 const QColorGroup &g, 137 const QColorGroup &g,
134 KToolBarPos type, QBrush *fill = NULL ); 138 KToolBarPos type, QBrush *fill = NULL );
135 139
136 /** 140 /**
137 * Draw a toolbar. 141 * Draw a toolbar.
138 */ 142 */
139 void drawKToolBar( QPainter *p, int x, int y, int w, int h, 143 void drawKToolBar( QPainter *p, int x, int y, int w, int h,
140 const QColorGroup &g, KToolBarPos type, 144 const QColorGroup &g, KToolBarPos type,
141 QBrush *fill = NULL ); 145 QBrush *fill = NULL );
142#endif 146#endif
143 /** 147 /**
144 * Return the space available in a pushbutton, taking configurable 148 * Return the space available in a pushbutton, taking configurable
145 * borders and highlights into account. 149 * borders and highlights into account.
146 */ 150 */
147 virtual QRect buttonRect( int x, int y, int w, int h ); 151 virtual QRect buttonRect( int x, int y, int w, int h );
148 /** 152 /**
149 * Draw an arrow in the style specified by the config file. 153 * Draw an arrow in the style specified by the config file.
150 */ 154 */
151 virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down, 155 virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down,
152 int x, int y, int w, int h, const QColorGroup &g, 156 int x, int y, int w, int h, const QColorGroup &g,
153 bool enabled = true, const QBrush *fill = 0 ); 157 bool enabled = true, const QBrush *fill = 0 );
154 /** 158 /**
155 * Return the size of the exclusive indicator pixmap if one is specified 159 * Return the size of the exclusive indicator pixmap if one is specified
156 * in the config file, otherwise it uses the base style's size. 160 * in the config file, otherwise it uses the base style's size.
157 */ 161 */
158 virtual QSize exclusiveIndicatorSize() const; 162 virtual QSize exclusiveIndicatorSize() const;
159 /** 163 /**
160 * Draw an exclusive indicator widget. 164 * Draw an exclusive indicator widget.
161 * 165 *
162 * If a pixmap is specified in the 166 * If a pixmap is specified in the
163 * config file that is used, otherwise the base style's widget is drawn. 167 * config file that is used, otherwise the base style's widget is drawn.
164 */ 168 */
165 virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w, 169 virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w,
166 int h, const QColorGroup &g, bool on, 170 int h, const QColorGroup &g, bool on,
167 bool down = FALSE, 171 bool down = FALSE,
168 bool enabled = TRUE ); 172 bool enabled = TRUE );
169 /** 173 /**
170 * Set the mask of an exclusive indicator widget. 174 * Set the mask of an exclusive indicator widget.
171 * 175 *
172 * If a pixmap is specified 176 * If a pixmap is specified
173 * it is masked according to it's transparent pixels, otherwise the 177 * it is masked according to it's transparent pixels, otherwise the
174 * base style's mask is used. 178 * base style's mask is used.
175 */ 179 */
176 virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, 180 virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w,
177 int h, bool on ); 181 int h, bool on );
178 /** 182 /**
179 * Set the mask of an indicator widget. 183 * Set the mask of an indicator widget.
180 * 184 *
181 * If a pixmap is specified 185 * If a pixmap is specified
182 * it is masked according to it's transparent pixels, otherwise the 186 * it is masked according to it's transparent pixels, otherwise the
183 * base style's mask is used. 187 * base style's mask is used.
184 */ 188 */
185 virtual void drawIndicatorMask( QPainter *p, int x, int y, int w, int h, 189 virtual void drawIndicatorMask( QPainter *p, int x, int y, int w, int h,
186 int state ); 190 int state );
187 /** 191 /**
188 * Set the mask for pushbuttons. 192 * Set the mask for pushbuttons.
189 */ 193 */
190 virtual void drawButtonMask( QPainter *p, int x, int y, int w, int h ); 194 virtual void drawButtonMask( QPainter *p, int x, int y, int w, int h );
191 /** 195 /**
192 * Set the mask for combo boxes. 196 * Set the mask for combo boxes.
193 */ 197 */
194 virtual void drawComboButtonMask( QPainter *p, int x, int y, int w, int h ); 198 virtual void drawComboButtonMask( QPainter *p, int x, int y, int w, int h );
195 /** 199 /**
196 * Return the size of the indicator pixmap if one is specified 200 * Return the size of the indicator pixmap if one is specified
197 * in the config file, otherwise it uses the base style's size. 201 * in the config file, otherwise it uses the base style's size.
198 */ 202 */
199 virtual QSize indicatorSize() const; 203 virtual QSize indicatorSize() const;
200 /** 204 /**
201 * Draw an indicator widget. 205 * Draw an indicator widget.
202 * 206 *
203 * If a pixmap is specified in the 207 * If a pixmap is specified in the
204 * config file that is used, otherwise the base style's widget is drawn. 208 * config file that is used, otherwise the base style's widget is drawn.
205 */ 209 */
206 virtual void drawIndicator( QPainter* p, int x, int y, int w, int h, 210 virtual void drawIndicator( QPainter* p, int x, int y, int w, int h,
207 const QColorGroup &g, int state, 211 const QColorGroup &g, int state,
208 bool down = FALSE, bool enabled = TRUE ); 212 bool down = FALSE, bool enabled = TRUE );
209 /** 213 /**
210 * Draw a combobox. 214 * Draw a combobox.
211 */ 215 */
212 virtual void drawComboButton( QPainter *p, int x, int y, int w, int h, 216 virtual void drawComboButton( QPainter *p, int x, int y, int w, int h,
213 const QColorGroup &g, bool sunken = FALSE, 217 const QColorGroup &g, bool sunken = FALSE,
214 bool editable = FALSE, bool enabled = TRUE, 218 bool editable = FALSE, bool enabled = TRUE,
215 const QBrush *fill = 0 ); 219 const QBrush *fill = 0 );
216 /** 220 /**
217 * Draw a pushbutton. 221 * Draw a pushbutton.
218 */ 222 */
219 virtual void drawPushButton( QPushButton* btn, QPainter *p ); 223 virtual void drawPushButton( QPushButton* btn, QPainter *p );
220 /** 224 /**
221 * Return the amount of button content displacement specified by the 225 * Return the amount of button content displacement specified by the
222 * config file. 226 * config file.
223 */ 227 */
224 virtual void getButtonShift( int &x, int &y ); 228 virtual void getButtonShift( int &x, int &y );
225 /** 229 /**
226 * Return the frame width. 230 * Return the frame width.
227 */ 231 */
228 virtual int defaultFrameWidth() const; 232 virtual int defaultFrameWidth() const;
229 /** 233 /**
230 * Calculate the metrics of the scrollbar controls according to the 234 * Calculate the metrics of the scrollbar controls according to the
231 * layout specified by the config file. 235 * layout specified by the config file.
232 */ 236 */
233 virtual void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& ); 237 virtual void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& );
234 /** 238 /**
235 * Draw a themed scrollbar. 239 * Draw a themed scrollbar.
236 */ 240 */
237 virtual void drawScrollBarControls( QPainter*, const QScrollBar*, 241 virtual void drawScrollBarControls( QPainter*, const QScrollBar*,
238 int sliderStart, uint controls, 242 int sliderStart, uint controls,
239 uint activeControl ); 243 uint activeControl );
240 /** 244 /**
241 * Return the control that the given point is over according to the 245 * Return the control that the given point is over according to the
242 * layout in the config file. 246 * layout in the config file.
243 */ 247 */
244 virtual ScrollControl scrollBarPointOver( const QScrollBar*, 248 virtual ScrollControl scrollBarPointOver( const QScrollBar*,
245 int sliderStart, const QPoint& ); 249 int sliderStart, const QPoint& );
246 /** 250 /**
247 * Return the configurable default slider length. 251 * Return the configurable default slider length.
248 */ 252 */
249 virtual int sliderLength() const; 253 virtual int sliderLength() const;
250 /** 254 /**
251 * Draw a slider control. 255 * Draw a slider control.
252 */ 256 */
253 virtual void drawSlider( QPainter *p, int x, int y, int w, int h, 257 virtual void drawSlider( QPainter *p, int x, int y, int w, int h,
254 const QColorGroup &g, Orientation, bool tickAbove, 258 const QColorGroup &g, Orientation, bool tickAbove,
255 bool tickBelow ); 259 bool tickBelow );
256 /** 260 /**
257 * Draw a slider groove. 261 * Draw a slider groove.
258 */ 262 */
259 void drawSliderGroove( QPainter *p, int x, int y, int w, int h, 263 void drawSliderGroove( QPainter *p, int x, int y, int w, int h,
260 const QColorGroup& g, QCOORD c, 264 const QColorGroup& g, QCOORD c,
261 Orientation ); 265 Orientation );
262 /** 266 /**
263 * Draw the mask for a slider (both the control and groove. 267 * Draw the mask for a slider (both the control and groove.
264 */ 268 */
265 virtual void drawSliderMask( QPainter *p, int x, int y, int w, int h, 269 virtual void drawSliderMask( QPainter *p, int x, int y, int w, int h,
266 Orientation, bool tickAbove, bool tickBelow ); 270 Orientation, bool tickAbove, bool tickBelow );
267 // void drawSliderGrooveMask(QPainter *p,int x, int y, int w, int h, 271 // void drawSliderGrooveMask(QPainter *p,int x, int y, int w, int h,
268 // QCOORD c, Orientation ); 272 // QCOORD c, Orientation );
269 /** 273 /**
270 * Convience method for drawing themed scrollbar grooves. 274 * Convience method for drawing themed scrollbar grooves.
271 * 275 *
272 * Since the 276 * Since the
273 * grooves may be a scaled pixmap you cannot just bitblt the pixmap at 277 * grooves may be a scaled pixmap you cannot just bitblt the pixmap at
274 * any offset. This generates a cached pixmap at full size if needed and 278 * any offset. This generates a cached pixmap at full size if needed and
275 * then copies the requested area. 279 * then copies the requested area.
276 * 280 *
277 * @param p The painter to draw on. 281 * @param p The painter to draw on.
278 * @param sb The scrollbar (usually given by drawScrollBarControls). 282 * @param sb The scrollbar (usually given by drawScrollBarControls).
279 * @param horizontal Is the scrollBar horizontal? 283 * @param horizontal Is the scrollBar horizontal?
280 * @param r The rectangle to fill. 284 * @param r The rectangle to fill.
281 * @param g The color group to use. 285 * @param g The color group to use.
282 */ 286 */
283 virtual void drawScrollBarGroove( QPainter *p, const QScrollBar *sb, 287 virtual void drawScrollBarGroove( QPainter *p, const QScrollBar *sb,
284 bool horizontal, QRect r, QColorGroup g ); 288 bool horizontal, QRect r, QColorGroup g );
285 /** 289 /**
286 * Draw a shaded rectangle using the given style. 290 * Draw a shaded rectangle using the given style.
287 * 291 *
288 * @param p The painter to draw on. 292 * @param p The painter to draw on.
289 * @param g The color group to use. 293 * @param g The color group to use.
290 * @param rounded Draws a rounded shape if true. Requires bWidth to be 294 * @param rounded Draws a rounded shape if true. Requires bWidth to be
291 * at least 1. 295 * at least 1.
292 * @param hWidth The highlight width. 296 * @param hWidth The highlight width.
293 * @param bWidth The border width. 297 * @param bWidth The border width.
294 * @param style The shading style to use. 298 * @param style The shading style to use.
295 */ 299 */
296 virtual void drawShade( QPainter *p, int x, int y, int w, int h, 300 virtual void drawShade( QPainter *p, int x, int y, int w, int h,
297 const QColorGroup &g, bool sunken, bool rounded, 301 const QColorGroup &g, bool sunken, bool rounded,
298 int hWidth, int bWidth, ShadeStyle style ); 302 int hWidth, int bWidth, ShadeStyle style );
299 /** 303 /**
300 * Draw the text for a pushbutton. 304 * Draw the text for a pushbutton.
301 */ 305 */
302 virtual void drawPushButtonLabel( QPushButton *btn, QPainter *p ); 306 virtual void drawPushButtonLabel( QPushButton *btn, QPainter *p );
303 /** 307 /**
304 * Draw a menubar. 308 * Draw a menubar.
305 */ 309 */
306#if 0 310#if 0
307 311
308 void drawKMenuBar( QPainter *p, int x, int y, int w, int h, 312 void drawKMenuBar( QPainter *p, int x, int y, int w, int h,
309 const QColorGroup &g, bool macMode, 313 const QColorGroup &g, bool macMode,
310 QBrush *fill = NULL ); 314 QBrush *fill = NULL );
311#endif 315#endif
312 /** 316 /**
313 * Draw a menubar item. 317 * Draw a menubar item.
314 */ 318 */
315#if 0 319 virtual void drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
316 320 QMenuItem *item, const QColorGroup &g,
317 virtual void drawKMenuItem( QPainter *p, int x, int y, int w, int h, 321 bool enabled, bool active );
318 const QColorGroup &g, bool active,
319 QMenuItem *item, QBrush *fill = NULL );
320#endif
321 /** 322 /**
322 * Return the width of the splitter as specified in the config file. 323 * Return the width of the splitter as specified in the config file.
323 */ 324 */
324 virtual int splitterWidth() const; 325 virtual int splitterWidth() const;
325 /** 326 /**
326 * Draw a splitter widget. 327 * Draw a splitter widget.
327 */ 328 */
328 virtual void drawSplitter( QPainter *p, int x, int y, int w, int h, 329 virtual void drawSplitter( QPainter *p, int x, int y, int w, int h,
329 const QColorGroup &g, Orientation ); 330 const QColorGroup &g, Orientation );
330 /** 331 /**
331 * Draw a checkmark. 332 * Draw a checkmark.
332 */ 333 */
333 virtual void drawCheckMark( QPainter *p, int x, int y, int w, int h, 334 virtual void drawCheckMark( QPainter *p, int x, int y, int w, int h,
334 const QColorGroup &g, bool act, bool dis ); 335 const QColorGroup &g, bool act, bool dis );
335 /** 336 /**
336 * Draw a menu item. 337 * Draw a menu item.
337 * 338 *
338 * Note: This method manually handles applying 339 * Note: This method manually handles applying
339 * inactive menu backgrounds to the entire widget. 340 * inactive menu backgrounds to the entire widget.
340 */ 341 */
341 virtual void drawPopupMenuItem( QPainter *p, bool checkable, int maxpmw, 342 virtual void drawPopupMenuItem( QPainter *p, bool checkable, int maxpmw,
342 int tab, QMenuItem *mi, const QPalette &pal, 343 int tab, QMenuItem *mi, const QPalette &pal,
343 bool act, bool enabled, int x, int y, int w, 344 bool act, bool enabled, int x, int y, int w,
344 int h ); 345 int h );
345 int popupMenuItemHeight( bool checkable, QMenuItem *mi, 346 int popupMenuItemHeight( bool checkable, QMenuItem *mi,
346 const QFontMetrics &fm ); 347 const QFontMetrics &fm );
347 /** 348 /**
348 * Draw the focus rectangle. 349 * Draw the focus rectangle.
349 */ 350 */
350 void drawFocusRect( QPainter *p, const QRect &r, const QColorGroup &g, 351 void drawFocusRect( QPainter *p, const QRect &r, const QColorGroup &g,
351 const QColor *c = 0, bool atBorder = false ); 352 const QColor *c = 0, bool atBorder = false );
352 /** 353 /**
353 * Draw a @ref KProgess bar. 354 * Draw a @ref KProgess bar.
354 */ 355 */
355 // virtual void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, 356 virtual void drawProgressBar (QPainter *, int , int , int , int , const QColorGroup &, int );
356 // const QColorGroup &g, QBrush *fill);
357 /** 357 /**
358 * Return the background for @ref KProgress. 358 * Return the background for @ref KProgress.
359 */ 359 */
360 // virtual void getKProgressBackground(const QColorGroup &g, QBrush &bg); 360 // virtual void getKProgressBackground(const QColorGroup &g, QBrush &bg);
361 virtual void tabbarMetrics( const QTabBar*, int&, int&, int& ); 361 virtual void tabbarMetrics( const QTabBar*, int&, int&, int& );
362 virtual void drawTab( QPainter*, const QTabBar*, QTab*, bool selected ); 362 virtual void drawTab( QPainter*, const QTabBar*, QTab*, bool selected );
363 virtual void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected ); 363 virtual void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected );
364protected: 364protected:
365 QPalette oldPalette, popupPalette, indiPalette, exIndiPalette; 365 QPalette oldPalette, popupPalette, indiPalette, exIndiPalette;
366 366
367 class OThemeStylePrivate; 367 class OThemeStylePrivate;
368 OThemeStylePrivate *d; 368 OThemeStylePrivate *d;
369}; 369};
370 370
371#endif 371#endif