author | sandman <sandman> | 2002-11-21 19:54:25 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-21 19:54:25 (UTC) |
commit | 6d302b82aab909da59852d99a31bcc7726ba9f34 (patch) (unidiff) | |
tree | e090ba7fcd96afe5fd74e7451f2c59b64f0eb369 | |
parent | 440f1d4d439c83368a855355cdceda43660137f2 (diff) | |
download | opie-6d302b82aab909da59852d99a31bcc7726ba9f34.zip opie-6d302b82aab909da59852d99a31bcc7726ba9f34.tar.gz opie-6d302b82aab909da59852d99a31bcc7726ba9f34.tar.bz2 |
- progress bars are now also themed (same hack/workaround, that is used in
liquid)
- some speed optimizations
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 126 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.h | 16 |
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,213 +1,293 @@ | |||
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 | ||
33 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | ||
34 | QColorGroup &, bool, bool); | ||
35 | |||
36 | QDrawMenuBarItemImpl 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 | |||
50 | class HackProgressBar : public QProgressBar { | ||
51 | public: | ||
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 | ||
34 | OThemeStyle::OThemeStyle( const QString &configFile ) | 93 | OThemeStyle::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 | ||
41 | OThemeStyle::~OThemeStyle() | 100 | OThemeStyle::~OThemeStyle() |
42 | {} | 101 | {} |
43 | 102 | ||
44 | void OThemeStyle::polish( QApplication * /*app*/ ) | 103 | void OThemeStyle::polish( QApplication * /*app*/ ) |
45 | {} | 104 | { |
105 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem); | ||
106 | } | ||
107 | |||
46 | 108 | ||
47 | void OThemeStyle::polish( QPalette &p ) | 109 | void 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 | ||
80 | void OThemeStyle::unPolish( QApplication *app ) | 142 | void 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 | ||
85 | void OThemeStyle::polish( QWidget *w ) | 148 | void 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 | ||
144 | void OThemeStyle::unPolish( QWidget* w ) | 210 | void 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 | |||
236 | bool 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 | ||
168 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | 248 | void 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 |
@@ -1302,113 +1382,139 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, | |||
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 | ||
1326 | void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, | 1406 | void 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 |
1344 | void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, | 1424 | void 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 | ||
1351 | void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, | 1432 | void 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 | |||
1456 | void 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 | |||
1367 | void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, | 1473 | void 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 | ||
1374 | void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) | 1480 | void 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 | ||
1383 | void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) | 1489 | void 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 | ||
1388 | void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , | 1494 | void 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; |
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,113 +1,117 @@ | |||
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 | ||
29 | class 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 | ||
41 | class OThemeStyle: public OThemeBase | 43 | class OThemeStyle: public OThemeBase |
42 | { | 44 | { |
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | public: | 46 | public: |
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. |
@@ -267,105 +271,101 @@ public: | |||
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 ); |
364 | protected: | 364 | protected: |
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 |