summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 4a65952..bac882c 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,1149 +1,1140 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5// 5//
6// (c) 2002 Robert 'sandman' Griebl 6// (c) 2002 Robert 'sandman' Griebl
7// 7//
8 8
9 9
10#ifndef INCLUDE_MENUITEM_DEF 10#ifndef INCLUDE_MENUITEM_DEF
11#define INCLUDE_MENUITEM_DEF 11#define INCLUDE_MENUITEM_DEF
12#endif 12#endif
13 13
14#include <qmenudata.h> 14#include <qmenudata.h>
15#include "liquid.h" 15#include "liquid.h"
16//#include "liquiddeco.h" 16//#include "liquiddeco.h"
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include "effects.h" 19#include "effects.h"
20#include <qpalette.h> 20#include <qpalette.h>
21#include <qbitmap.h> 21#include <qbitmap.h>
22#include <qtabbar.h> 22#include <qtabbar.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qpixmapcache.h> 27#include <qpixmapcache.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qdrawutil.h> 30#include <qdrawutil.h>
31#include <qwidgetlist.h> 31#include <qwidgetlist.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qheader.h> 33#include <qheader.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qlistbox.h> 38#include <qlistbox.h>
39 39
40#include <stdio.h> 40#include <stdio.h>
41 41
42#include "htmlmasks.h" 42#include "htmlmasks.h"
43#include "embeddata.h" 43#include "embeddata.h"
44 44
45 45
46typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 46typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
47 QColorGroup &, bool, bool); 47 QColorGroup &, bool, bool);
48 48
49QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 49QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
50 50
51void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 51void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
52{ 52{
53 QImage img(pix.convertToImage()); 53 QImage img(pix.convertToImage());
54 QImageEffect::fade(img, 0.9, color); 54 QImageEffect::fade(img, 0.9, color);
55 int x, y; 55 int x, y;
56 int r, g, b; 56 int r, g, b;
57 for(y=0; y < img.height(); y+=3){ 57 for(y=0; y < img.height(); y+=3){
58 unsigned int *data = (unsigned int *) img.scanLine(y); 58 unsigned int *data = (unsigned int *) img.scanLine(y);
59 for(x=0; x < img.width(); ++x){ 59 for(x=0; x < img.width(); ++x){
60 r = qRed(data[x]); 60 r = qRed(data[x]);
61 g = qGreen(data[x]); 61 g = qGreen(data[x]);
62 b = qBlue(data[x]); 62 b = qBlue(data[x]);
63 if(r-10) 63 if(r-10)
64 r-=10; 64 r-=10;
65 if(g-10) 65 if(g-10)
66 g-=10; 66 g-=10;
67 if(b-10) 67 if(b-10)
68 b-=10; 68 b-=10;
69 data[x] = qRgb(r, g, b); 69 data[x] = qRgb(r, g, b);
70 } 70 }
71 } 71 }
72 pix.convertFromImage(img); 72 pix.convertFromImage(img);
73} 73}
74 74
75TransMenuHandler::TransMenuHandler(QObject *parent) 75TransMenuHandler::TransMenuHandler(QObject *parent)
76 : QObject(parent) 76 : QObject(parent)
77{ 77{
78 pixDict.setAutoDelete(true); 78 pixDict.setAutoDelete(true);
79 reloadSettings(); 79 reloadSettings();
80} 80}
81 81
82void TransMenuHandler::reloadSettings() 82void TransMenuHandler::reloadSettings()
83{ 83{
84 pixDict.clear(); 84 pixDict.clear();
85 85
86 Config config ( "qpe" ); 86 Config config ( "qpe" );
87 config. setGroup ( "Liquid-Style" ); 87 config. setGroup ( "Liquid-Style" );
88 88
89 type = config. readNumEntry("Type", TransStippleBg); 89 type = config. readNumEntry("Type", TransStippleBg);
90 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 90 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
91 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 91 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
92 opacity = config. readNumEntry("Opacity", 10); 92 opacity = config. readNumEntry("Opacity", 10);
93 if ( opacity < -20 ) 93 if ( opacity < -20 )
94 opacity = 20; 94 opacity = 20;
95 else if ( opacity > 20 ) 95 else if ( opacity > 20 )
96 opacity = 20; 96 opacity = 20;
97 97
98 shadowText = config. readBoolEntry("ShadowText", true); 98 shadowText = config. readBoolEntry("ShadowText", true);
99} 99}
100 100
101bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 101bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
102{ 102{
103 QWidget *p = (QWidget *)obj; 103 QWidget *p = (QWidget *)obj;
104 104
105 if(ev->type() == QEvent::Show){ 105 if(ev->type() == QEvent::Show){
106 if(type == TransStippleBg || type == TransStippleBtn || 106 if(type == TransStippleBg || type == TransStippleBtn ||
107 type == Custom){ 107 type == Custom){
108 QApplication::syncX(); 108 QApplication::syncX();
109 QPixmap *pix = new QPixmap; 109 QPixmap *pix = new QPixmap;
110 if(p->testWFlags(Qt::WType_Popup)){ 110 if(p->testWFlags(Qt::WType_Popup)){
111 QRect r(p->x(), p->y(), p->width(), p->height()); 111 QRect r(p->x(), p->y(), p->width(), p->height());
112 QRect deskR = QApplication::desktop()->rect(); 112 QRect deskR = QApplication::desktop()->rect();
113 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 113 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
114 r.setBottom(deskR.bottom()); 114 r.setBottom(deskR.bottom());
115 r.setRight(deskR.right()); 115 r.setRight(deskR.right());
116 } 116 }
117 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 117 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
118 r.width(), r.height()); 118 r.width(), r.height());
119 } 119 }
120 else{ // tear off menu 120 else{ // tear off menu
121 pix->resize(p->width(), p->height()); 121 pix->resize(p->width(), p->height());
122 pix->fill(Qt::black.rgb()); 122 pix->fill(Qt::black.rgb());
123 } 123 }
124 if(type == TransStippleBg){ 124 if(type == TransStippleBg){
125 stripePixmap(*pix, p->colorGroup().background()); 125 stripePixmap(*pix, p->colorGroup().background());
126 } 126 }
127 else if(type == TransStippleBtn){ 127 else if(type == TransStippleBtn){
128 stripePixmap(*pix, p->colorGroup().button()); 128 stripePixmap(*pix, p->colorGroup().button());
129 } 129 }
130 else{ 130 else{
131 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 131 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
132 } 132 }
133 133
134 pixDict.insert(p->winId(), pix); 134 pixDict.insert(p->winId(), pix);
135 135
136 if ( !p->inherits("QPopupMenu")) 136 if ( !p->inherits("QPopupMenu"))
137 p->setBackgroundPixmap(*pix); 137 p->setBackgroundPixmap(*pix);
138 138
139 QObjectList *ol = p-> queryList("QWidget"); 139 QObjectList *ol = p-> queryList("QWidget");
140 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 140 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
141 QWidget *wid = (QWidget *) it.current ( ); 141 QWidget *wid = (QWidget *) it.current ( );
142 142
143 wid-> setBackgroundPixmap(*pix); 143 wid-> setBackgroundPixmap(*pix);
144 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 144 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
145 } 145 }
146 delete ol; 146 delete ol;
147 } 147 }
148 } 148 }
149 else if(ev->type() == QEvent::Hide){ 149 else if(ev->type() == QEvent::Hide){
150 if(type == TransStippleBg || type == TransStippleBtn || 150 if(type == TransStippleBg || type == TransStippleBtn ||
151 type == Custom){ 151 type == Custom){
152// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 152// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
153 153
154 pixDict.remove(p->winId()); 154 pixDict.remove(p->winId());
155 if ( !p->inherits("QPopupMenu")) 155 if ( !p->inherits("QPopupMenu"))
156 p->setBackgroundMode(QWidget::PaletteBackground); 156 p->setBackgroundMode(QWidget::PaletteBackground);
157 157
158 QObjectList *ol = p-> queryList("QWidget"); 158 QObjectList *ol = p-> queryList("QWidget");
159 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 159 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
160 QWidget *wid = (QWidget *) it.current ( ); 160 QWidget *wid = (QWidget *) it.current ( );
161 161
162 wid-> setBackgroundMode( QWidget::PaletteBackground ); 162 wid-> setBackgroundMode( QWidget::PaletteBackground );
163 } 163 }
164 delete ol; 164 delete ol;
165 } 165 }
166 } 166 }
167 return(false); 167 return(false);
168} 168}
169 169
170 170
171static int qt_version ( )
172{
173 const char *qver = qVersion ( );
174 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
175}
176 171
177 172
178LiquidStyle::LiquidStyle() 173LiquidStyle::LiquidStyle()
179 :QWindowsStyle() 174 :QWindowsStyle()
180{ 175{
181 setName ( "LiquidStyle" ); 176 setName ( "LiquidStyle" );
182 177
183 oldqte = ( qt_version ( ) < 234 );
184 flatTBButtons = false; 178 flatTBButtons = false;
185 currentHeader = 0; 179 currentHeader = 0;
186 180
187 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 181 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
188 btnMaskBmp.setMask(btnMaskBmp); 182 btnMaskBmp.setMask(btnMaskBmp);
189 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 183 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
190 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 184 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
191 headerHoverID = -1; 185 headerHoverID = -1;
192 highlightWidget = NULL; 186 highlightWidget = NULL;
193 setButtonDefaultIndicatorWidth(0); 187 setButtonDefaultIndicatorWidth(0);
194 btnDict.setAutoDelete(true); 188 btnDict.setAutoDelete(true);
195 bevelFillDict.setAutoDelete(true); 189 bevelFillDict.setAutoDelete(true);
196 smallBevelFillDict.setAutoDelete(true); 190 smallBevelFillDict.setAutoDelete(true);
197 191
198 rMatrix.rotate(270.0); 192 rMatrix.rotate(270.0);
199 btnBorderPix = new QPixmap; 193 btnBorderPix = new QPixmap;
200 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 194 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
201 btnBlendPix = new QPixmap; 195 btnBlendPix = new QPixmap;
202 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 196 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
203 bevelFillPix = new QPixmap; 197 bevelFillPix = new QPixmap;
204 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 198 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
205 smallBevelFillPix = new QPixmap; 199 smallBevelFillPix = new QPixmap;
206 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 200 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
207 // new stuff 201 // new stuff
208 vsbSliderFillPix = menuPix = NULL; 202 vsbSliderFillPix = menuPix = NULL;
209 menuHandler = new TransMenuHandler(this); 203 menuHandler = new TransMenuHandler(this);
210 setScrollBarExtent(15, 15); 204 setScrollBarExtent(15, 15);
211 int i; 205 int i;
212 for(i=0; i < BITMAP_ITEMS; ++i){ 206 for(i=0; i < BITMAP_ITEMS; ++i){
213 pixmaps[i] = NULL; 207 pixmaps[i] = NULL;
214 } 208 }
215 oldSliderThickness = sliderThickness(); 209 oldSliderThickness = sliderThickness();
216 setSliderThickness(11); 210 setSliderThickness(11);
217} 211}
218 212
219LiquidStyle::~LiquidStyle() 213LiquidStyle::~LiquidStyle()
220{ 214{
221 if(btnBorderPix) 215 if(btnBorderPix)
222 delete btnBorderPix; 216 delete btnBorderPix;
223 if(btnBlendPix) 217 if(btnBlendPix)
224 delete btnBlendPix; 218 delete btnBlendPix;
225 if(bevelFillPix) 219 if(bevelFillPix)
226 delete bevelFillPix; 220 delete bevelFillPix;
227 if(smallBevelFillPix) 221 if(smallBevelFillPix)
228 delete smallBevelFillPix; 222 delete smallBevelFillPix;
229 if(vsbSliderFillPix) 223 if(vsbSliderFillPix)
230 delete vsbSliderFillPix; 224 delete vsbSliderFillPix;
231 if(menuPix) 225 if(menuPix)
232 delete menuPix; 226 delete menuPix;
233 227
234 setScrollBarExtent(16, 16); 228 setScrollBarExtent(16, 16);
235 setSliderThickness(oldSliderThickness); 229 setSliderThickness(oldSliderThickness);
236 int i; 230 int i;
237 for(i=0; i < BITMAP_ITEMS; ++i){ 231 for(i=0; i < BITMAP_ITEMS; ++i){
238 if(pixmaps[i]) 232 if(pixmaps[i])
239 delete pixmaps[i]; 233 delete pixmaps[i];
240 } 234 }
241} 235}
242 236
243void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 237void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
244 const QColor &c, const QColor &bg) 238 const QColor &c, const QColor &bg)
245{ 239{
246 240
247 QPen oldPen = p->pen(); // headers need this 241 QPen oldPen = p->pen(); // headers need this
248 int x2 = x+w-1; 242 int x2 = x+w-1;
249 int y2 = y+h-1; 243 int y2 = y+h-1;
250 // outer dark rect 244 // outer dark rect
251 p->setPen(c.dark(130)); 245 p->setPen(c.dark(130));
252 p->drawLine(x, y+2, x, y2-2); // l 246 p->drawLine(x, y+2, x, y2-2); // l
253 p->drawLine(x2, y+2, x2, y2-2); // r 247 p->drawLine(x2, y+2, x2, y2-2); // r
254 p->drawLine(x+2, y, x2-2, y); // t 248 p->drawLine(x+2, y, x2-2, y); // t
255 p->drawLine(x+2, y2, x2-2, y2); // b 249 p->drawLine(x+2, y2, x2-2, y2); // b
256 p->drawPoint(x+1, y+1); // tl 250 p->drawPoint(x+1, y+1); // tl
257 p->drawPoint(x2-1, y+1); // tr 251 p->drawPoint(x2-1, y+1); // tr
258 p->drawPoint(x+1, y2-1); // bl 252 p->drawPoint(x+1, y2-1); // bl
259 p->drawPoint(x2-1, y2-1); // br 253 p->drawPoint(x2-1, y2-1); // br
260 254
261 // inner top light lines 255 // inner top light lines
262 p->setPen(c.light(105)); 256 p->setPen(c.light(105));
263 p->drawLine(x+2, y+1, x2-2, y+1); 257 p->drawLine(x+2, y+1, x2-2, y+1);
264 p->drawLine(x+1, y+2, x2-1, y+2); 258 p->drawLine(x+1, y+2, x2-1, y+2);
265 p->drawLine(x+1, y+3, x+2, y+3); 259 p->drawLine(x+1, y+3, x+2, y+3);
266 p->drawLine(x2-2, y+3, x2-1, y+3); 260 p->drawLine(x2-2, y+3, x2-1, y+3);
267 p->drawPoint(x+1, y+4); 261 p->drawPoint(x+1, y+4);
268 p->drawPoint(x2-1, y+4); 262 p->drawPoint(x2-1, y+4);
269 263
270 // inner bottom light lines 264 // inner bottom light lines
271 p->setPen(c.light(110)); 265 p->setPen(c.light(110));
272 p->drawLine(x+2, y2-1, x2-2, y2-1); 266 p->drawLine(x+2, y2-1, x2-2, y2-1);
273 p->drawLine(x+1, y2-2, x2-1, y2-2); 267 p->drawLine(x+1, y2-2, x2-1, y2-2);
274 p->drawLine(x+1, y2-3, x+2, y2-3); 268 p->drawLine(x+1, y2-3, x+2, y2-3);
275 p->drawLine(x2-2, y2-3, x2-1, y2-3); 269 p->drawLine(x2-2, y2-3, x2-1, y2-3);
276 p->drawPoint(x+1, y2-4); 270 p->drawPoint(x+1, y2-4);
277 p->drawPoint(x2-1, y2-4); 271 p->drawPoint(x2-1, y2-4);
278 272
279 // inner left mid lines 273 // inner left mid lines
280 //p->setPen(c.light(105)); 274 //p->setPen(c.light(105));
281 p->setPen(c); 275 p->setPen(c);
282 p->drawLine(x+1, y+5, x+1, y2-5); 276 p->drawLine(x+1, y+5, x+1, y2-5);
283 p->drawLine(x+2, y+4, x+2, y2-4); 277 p->drawLine(x+2, y+4, x+2, y2-4);
284 278
285 // inner right mid lines 279 // inner right mid lines
286 p->drawLine(x2-1, y+5, x2-1, y2-5); 280 p->drawLine(x2-1, y+5, x2-1, y2-5);
287 p->drawLine(x2-2, y+4, x2-2, y2-4); 281 p->drawLine(x2-2, y+4, x2-2, y2-4);
288 282
289 // fill 283 // fill
290 QPixmap *pix; 284 QPixmap *pix;
291 if(h >= 32){ 285 if(h >= 32){
292 pix = bevelFillDict.find(c.rgb()); 286 pix = bevelFillDict.find(c.rgb());
293 if(!pix){ 287 if(!pix){
294 int h, s, v; 288 int h, s, v;
295 c.hsv(&h, &s, &v); 289 c.hsv(&h, &s, &v);
296 pix = new QPixmap(*bevelFillPix); 290 pix = new QPixmap(*bevelFillPix);
297 adjustHSV(*pix, h, s, v); 291 adjustHSV(*pix, h, s, v);
298 bevelFillDict.insert(c.rgb(), pix); 292 bevelFillDict.insert(c.rgb(), pix);
299 } 293 }
300 } 294 }
301 else{ 295 else{
302 pix = smallBevelFillDict.find(c.rgb()); 296 pix = smallBevelFillDict.find(c.rgb());
303 if(!pix){ 297 if(!pix){
304 int h, s, v; 298 int h, s, v;
305 c.hsv(&h, &s, &v); 299 c.hsv(&h, &s, &v);
306 pix = new QPixmap(*smallBevelFillPix); 300 pix = new QPixmap(*smallBevelFillPix);
307 adjustHSV(*pix, h, s, v); 301 adjustHSV(*pix, h, s, v);
308 smallBevelFillDict.insert(c.rgb(), pix); 302 smallBevelFillDict.insert(c.rgb(), pix);
309 } 303 }
310 } 304 }
311 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 305 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
312 // blend 306 // blend
313 int red, green, blue; 307 int red, green, blue;
314 QColor btnColor(c.dark(130)); 308 QColor btnColor(c.dark(130));
315 red = (btnColor.red() >> 1) + (bg.red() >> 1); 309 red = (btnColor.red() >> 1) + (bg.red() >> 1);
316 green = (btnColor.green() >> 1) + (bg.green() >> 1); 310 green = (btnColor.green() >> 1) + (bg.green() >> 1);
317 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 311 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
318 btnColor.setRgb(red, green, blue); 312 btnColor.setRgb(red, green, blue);
319 313
320 p->setPen(btnColor); 314 p->setPen(btnColor);
321 p->drawPoint(x+1, y); 315 p->drawPoint(x+1, y);
322 p->drawPoint(x, y+1); 316 p->drawPoint(x, y+1);
323 p->drawPoint(x+1, y2); 317 p->drawPoint(x+1, y2);
324 p->drawPoint(x, y2-1); 318 p->drawPoint(x, y2-1);
325 319
326 p->drawPoint(x2-1, y); 320 p->drawPoint(x2-1, y);
327 p->drawPoint(x2, y+1); 321 p->drawPoint(x2, y+1);
328 p->drawPoint(x2-1, y2); 322 p->drawPoint(x2-1, y2);
329 p->drawPoint(x2, y2-1); 323 p->drawPoint(x2, y2-1);
330 324
331 p->setPen(oldPen); 325 p->setPen(oldPen);
332 326
333} 327}
334 328
335void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 329void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
336 const QColor &back, int x, int y, int w, int h, 330 const QColor &back, int x, int y, int w, int h,
337 bool supportPushDown, bool pushedDown, 331 bool supportPushDown, bool pushedDown,
338 bool autoDefault, bool isMasked) 332 bool autoDefault, bool isMasked)
339{ 333{
340 if(w < 21 || h < 21){ 334 if(w < 21 || h < 21){
341 drawClearBevel(painter, x, y, w, h, c, back); 335 drawClearBevel(painter, x, y, w, h, c, back);
342 return; 336 return;
343 } 337 }
344 if(supportPushDown){ 338 if(supportPushDown){
345 --w, --h; 339 --w, --h;
346 } 340 }
347 /* We don't make the round buttons smaller, since they don't look as good 341 /* We don't make the round buttons smaller, since they don't look as good
348 if(autoDefault){ 342 if(autoDefault){
349 w = w-buttonDefaultIndicatorWidth()*2; 343 w = w-buttonDefaultIndicatorWidth()*2;
350 h = h-buttonDefaultIndicatorWidth()*2; 344 h = h-buttonDefaultIndicatorWidth()*2;
351 }*/ 345 }*/
352 346
353 347
354 QPixmap *pix = btnDict.find(c.rgb()); 348 QPixmap *pix = btnDict.find(c.rgb());
355 if(!pix){ 349 if(!pix){
356 int h, s, v; 350 int h, s, v;
357 c.hsv(&h, &s, &v); 351 c.hsv(&h, &s, &v);
358 pix = new QPixmap(*btnBorderPix); 352 pix = new QPixmap(*btnBorderPix);
359 adjustHSV(*pix, h, s, v); 353 adjustHSV(*pix, h, s, v);
360 btnDict.insert(c.rgb(), pix); 354 btnDict.insert(c.rgb(), pix);
361 } 355 }
362 int x2 = x+w-1; 356 int x2 = x+w-1;
363 int y2 = y+h-1; 357 int y2 = y+h-1;
364 int bx2 = pix->width()-1; 358 int bx2 = pix->width()-1;
365 int by2 = pix->height()-1; 359 int by2 = pix->height()-1;
366 360
367 QPixmap tmpPix(w, h); 361 QPixmap tmpPix(w, h);
368 QPixmap tilePix; 362 QPixmap tilePix;
369 QPainter p; 363 QPainter p;
370 p.begin(&tmpPix); 364 p.begin(&tmpPix);
371 365
372 // do the fill 366 // do the fill
373 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 367 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
374 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 368 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
375 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 369 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
376 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 370 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
377 371
378 // edges 372 // edges
379 tilePix.resize(pix->width()-20, 10); 373 tilePix.resize(pix->width()-20, 10);
380 // top 374 // top
381 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 375 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
382 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 376 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
383 // bottom 377 // bottom
384 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 378 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
385 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 379 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
386 // left 380 // left
387 tilePix.resize(10, pix->height()-20); 381 tilePix.resize(10, pix->height()-20);
388 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 382 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
389 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 383 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
390 // right 384 // right
391 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 385 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
392 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 386 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
393 387
394 // middle 388 // middle
395 tilePix.resize(pix->width()-20, pix->height()-20); 389 tilePix.resize(pix->width()-20, pix->height()-20);
396 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); 390 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20);
397 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); 391 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
398 392
399 393
400 // do the blend 394 // do the blend
401 QBitmap blendMask; 395 QBitmap blendMask;
402 if(!isMasked){ 396 if(!isMasked){
403 //QRgb bgRgb = back.rgb(); 397 //QRgb bgRgb = back.rgb();
404 //QRgb fgRgb = c.rgb(); 398 //QRgb fgRgb = c.rgb();
405 //int r, g, b; 399 //int r, g, b;
406 400
407 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); 401 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
408 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); 402 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
409 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); 403 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
410 //QColor blendColor(r, g, b); 404 //QColor blendColor(r, g, b);
411 int hue, sat, v1, v2; 405 int hue, sat, v1, v2;
412 QColor blendColor(autoDefault ? c : back); 406 QColor blendColor(autoDefault ? c : back);
413 back.hsv(&hue, &sat, &v1); 407 back.hsv(&hue, &sat, &v1);
414 blendColor.hsv(&hue, &sat, &v2); 408 blendColor.hsv(&hue, &sat, &v2);
415 if(v2 > v1) 409 if(v2 > v1)
416 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); 410 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
417 411
418 pix = btnBorderDict.find(blendColor.rgb()); 412 pix = btnBorderDict.find(blendColor.rgb());
419 if(!pix){ 413 if(!pix){
420 int h, s, v; 414 int h, s, v;
421 blendColor.hsv(&h, &s, &v); 415 blendColor.hsv(&h, &s, &v);
422 pix = new QPixmap(*btnBlendPix); 416 pix = new QPixmap(*btnBlendPix);
423 adjustHSV(*pix, h, s, v); 417 adjustHSV(*pix, h, s, v);
424 btnBorderDict.insert(blendColor.rgb(), pix); 418 btnBorderDict.insert(blendColor.rgb(), pix);
425 } 419 }
426 } 420 }
427 else{ 421 else{
428 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : 422 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) :
429 getPixmap(HTMLBtnBorder); 423 getPixmap(HTMLBtnBorder);
430 } 424 }
431 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 425 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
432 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 426 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
433 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 427 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
434 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 428 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
435 429
436 // edges 430 // edges
437 tilePix.resize(pix->width()-20, 10); 431 tilePix.resize(pix->width()-20, 10);
438 blendMask.resize(pix->width()-20, 10); 432 blendMask.resize(pix->width()-20, 10);
439 // top 433 // top
440 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 434 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
441 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); 435 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10);
442 tilePix.setMask(blendMask); 436 tilePix.setMask(blendMask);
443 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 437 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
444 // bottom 438 // bottom
445 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 439 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
446 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); 440 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20);
447 tilePix.setMask(blendMask); 441 tilePix.setMask(blendMask);
448 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 442 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
449 // left 443 // left
450 tilePix.resize(10, pix->height()-20); 444 tilePix.resize(10, pix->height()-20);
451 blendMask.resize(10, pix->height()-20); 445 blendMask.resize(10, pix->height()-20);
452 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 446 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
453 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); 447 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20);
454 tilePix.setMask(blendMask); 448 tilePix.setMask(blendMask);
455 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 449 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
456 // right 450 // right
457 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 451 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
458 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); 452 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20);
459 tilePix.setMask(blendMask); 453 tilePix.setMask(blendMask);
460 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 454 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
461 455
462 p.end(); 456 p.end();
463 457
464 // do the button mask - we don't automask buttons 458 // do the button mask - we don't automask buttons
465 QBitmap btnMask(w, h); 459 QBitmap btnMask(w, h);
466 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 460 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
467 p.begin(&btnMask); 461 p.begin(&btnMask);
468 p.fillRect(0, 0, w, h, Qt::color0); 462 p.fillRect(0, 0, w, h, Qt::color0);
469 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 463 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
470 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 464 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
471 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 465 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
472 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 466 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
473 // fills 467 // fills
474 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 468 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
475 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 469 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
476 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 470 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
477 p.end(); 471 p.end();
478 tmpPix.setMask(btnMask); 472 tmpPix.setMask(btnMask);
479 /*if(autoDefault){ 473 /*if(autoDefault){
480 if(supportPushDown && pushedDown){ 474 if(supportPushDown && pushedDown){
481 painter->drawPixmap(x+3, y+3, tmpPix); 475 painter->drawPixmap(x+3, y+3, tmpPix);
482 } 476 }
483 else{ 477 else{
484 painter->drawPixmap(x+2, y+2, tmpPix); 478 painter->drawPixmap(x+2, y+2, tmpPix);
485 } 479 }
486 } 480 }
487 else */if(supportPushDown && pushedDown) 481 else */if(supportPushDown && pushedDown)
488 painter->drawPixmap(x+1, y+1, tmpPix); 482 painter->drawPixmap(x+1, y+1, tmpPix);
489 else 483 else
490 painter->drawPixmap(x, y, tmpPix); 484 painter->drawPixmap(x, y, tmpPix);
491 485
492 486
493 487
494} 488}
495 489
496 490
497QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, 491QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
498 bool blend) 492 bool blend)
499{ 493{
500 QImage img(qembed_findImage(label)); 494 QImage img(qembed_findImage(label));
501 img.detach(); 495 img.detach();
502 if(img.isNull()){ // shouldn't happen, been tested 496 if(img.isNull()){ // shouldn't happen, been tested
503 qWarning("Invalid embedded label %s", label); 497 qWarning("Invalid embedded label %s", label);
504 return(NULL); 498 return(NULL);
505 } 499 }
506 if(img.depth() != 32) 500 if(img.depth() != 32)
507 img = img.convertDepth(32); 501 img = img.convertDepth(32);
508 unsigned int *data = (unsigned int *)img.bits(); 502 unsigned int *data = (unsigned int *)img.bits();
509 int total = img.width()*img.height(); 503 int total = img.width()*img.height();
510 int current; 504 int current;
511 QColor c; 505 QColor c;
512 int oldH, oldS, oldV; 506 int oldH, oldS, oldV;
513 int alpha; 507 int alpha;
514 if(v < 235) 508 if(v < 235)
515 v += 20; 509 v += 20;
516 else 510 else
517 v = 255; 511 v = 255;
518 float intensity = v/255.0; 512 float intensity = v/255.0;
519 513
520 for(current=0; current<total; ++current){ 514 for(current=0; current<total; ++current){
521 alpha = qAlpha(data[current]); 515 alpha = qAlpha(data[current]);
522 c.setRgb(data[current]); 516 c.setRgb(data[current]);
523 c.hsv(&oldH, &oldS, &oldV); 517 c.hsv(&oldH, &oldS, &oldV);
524 oldV = (int)(oldV*intensity); 518 oldV = (int)(oldV*intensity);
525 c.setHsv(h, s, oldV); 519 c.setHsv(h, s, oldV);
526 if(blend && alpha != 255 && alpha != 0){ 520 if(blend && alpha != 255 && alpha != 0){
527 float srcPercent = ((float)alpha)/255.0; 521 float srcPercent = ((float)alpha)/255.0;
528 float destPercent = 1.0-srcPercent; 522 float destPercent = 1.0-srcPercent;
529 oldH = (int)((srcPercent*h) + (destPercent*bH)); 523 oldH = (int)((srcPercent*h) + (destPercent*bH));
530 oldS = (int)((srcPercent*s) + (destPercent*bS)); 524 oldS = (int)((srcPercent*s) + (destPercent*bS));
531 oldV = (int)((srcPercent*oldV) + (destPercent*bV)); 525 oldV = (int)((srcPercent*oldV) + (destPercent*bV));
532 c.setHsv(oldH, oldS, oldV); 526 c.setHsv(oldH, oldS, oldV);
533 alpha = 255; 527 alpha = 255;
534 } 528 }
535 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); 529 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
536 } 530 }
537 QPixmap *pix = new QPixmap; 531 QPixmap *pix = new QPixmap;
538 pix->convertFromImage(img); 532 pix->convertFromImage(img);
539 return(pix); 533 return(pix);
540} 534}
541 535
542 536
543 537
544 538
545QPixmap* LiquidStyle::getPixmap(BitmapData item) 539QPixmap* LiquidStyle::getPixmap(BitmapData item)
546{ 540{
547 541
548 if(pixmaps[item]) 542 if(pixmaps[item])
549 return(pixmaps[item]); 543 return(pixmaps[item]);
550 544
551 switch(item){ 545 switch(item){
552 case HTMLBtnBorder: 546 case HTMLBtnBorder:
553 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); 547 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
554 break; 548 break;
555 case HTMLBtnBorderDown: 549 case HTMLBtnBorderDown:
556 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); 550 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
557 break; 551 break;
558 552
559 case HTMLCB: 553 case HTMLCB:
560 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); 554 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
561 break; 555 break;
562 case HTMLCBHover: 556 case HTMLCBHover:
563 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV); 557 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV);
564 break; 558 break;
565 case HTMLCBDown: 559 case HTMLCBDown:
566 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); 560 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
567 break; 561 break;
568 case HTMLCBDownHover: 562 case HTMLCBDownHover:
569 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV); 563 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV);
570 break; 564 break;
571 565
572 case HTMLRadio: 566 case HTMLRadio:
573 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 567 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
574 break; 568 break;
575 case HTMLRadioHover: 569 case HTMLRadioHover:
576 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV); 570 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV);
577 break; 571 break;
578 case HTMLRadioDown: 572 case HTMLRadioDown:
579 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 573 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
580 break; 574 break;
581 case HTMLRadioDownHover: 575 case HTMLRadioDownHover:
582 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV); 576 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV);
583 break; 577 break;
584 578
585 case RadioOff: 579 case RadioOff:
586 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/); 580 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/);
587 break; 581 break;
588 case RadioOffHover: 582 case RadioOffHover:
589 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/); 583 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/);
590 break; 584 break;
591 case RadioOn: 585 case RadioOn:
592 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/); 586 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
593 break; 587 break;
594 case RadioOnHover: 588 case RadioOnHover:
595 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/); 589 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
596 break; 590 break;
597 591
598 case Tab: 592 case Tab:
599 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/); 593 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
600 break; 594 break;
601 case TabDown: 595 case TabDown:
602 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/); 596 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
603 break; 597 break;
604 case TabFocus: 598 case TabFocus:
605 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/); 599 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
606 break; 600 break;
607 601
608 case CB: 602 case CB:
609 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); 603 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
610 break; 604 break;
611 case CBHover: 605 case CBHover:
612 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/); 606 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
613 break; 607 break;
614 case CBDown: 608 case CBDown:
615 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/); 609 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
616 break; 610 break;
617 case CBDownHover: 611 case CBDownHover:
618 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/); 612 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
619 break; 613 break;
620 614
621 case VSlider: 615 case VSlider:
622 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true ); 616 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true );
623 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 617 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
624 break; 618 break;
625 case VSBSliderTop: 619 case VSBSliderTop:
626 case VSBSliderTopHover: 620 case VSBSliderTopHover:
627 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/); 621 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/);
628 break; 622 break;
629 case VSBSliderBtm: 623 case VSBSliderBtm:
630 case VSBSliderBtmHover: 624 case VSBSliderBtmHover:
631 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/); 625 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/);
632 break; 626 break;
633 case VSBSliderMid: 627 case VSBSliderMid:
634 case VSBSliderMidHover: 628 case VSBSliderMidHover:
635 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 629 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
636 break; 630 break;
637 case VSBSliderTopBg: 631 case VSBSliderTopBg:
638 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/); 632 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/);
639 break; 633 break;
640 case VSBSliderBtmBg: 634 case VSBSliderBtmBg:
641 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/); 635 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/);
642 break; 636 break;
643 case VSBSliderMidBg: 637 case VSBSliderMidBg:
644 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 638 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
645 break; 639 break;
646 640
647 case HSlider: 641 case HSlider:
648 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/); 642 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/);
649 break; 643 break;
650 case HSBSliderTop: 644 case HSBSliderTop:
651 case HSBSliderTopHover: 645 case HSBSliderTopHover:
652 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true ); 646 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true );
653 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 647 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
654 break; 648 break;
655 case HSBSliderBtm: 649 case HSBSliderBtm:
656 case HSBSliderBtmHover: 650 case HSBSliderBtmHover:
657 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true ); 651 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true );
658 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 652 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
659 break; 653 break;
660 case HSBSliderMid: 654 case HSBSliderMid:
661 case HSBSliderMidHover: 655 case HSBSliderMidHover:
662 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 656 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
663 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 657 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
664 break; 658 break;
665 case HSBSliderTopBg: 659 case HSBSliderTopBg:
666 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true ); 660 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true );
667 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 661 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
668 break; 662 break;
669 case HSBSliderBtmBg: 663 case HSBSliderBtmBg:
670 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true ); 664 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true );
671 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 665 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
672 break; 666 break;
673 case HSBSliderMidBg: 667 case HSBSliderMidBg:
674 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 668 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
675 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 669 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
676 break; 670 break;
677 default: 671 default:
678 break; 672 break;
679 } 673 }
680 return(pixmaps[item]); 674 return(pixmaps[item]);
681} 675}
682 676
683void LiquidStyle::polish(QPalette &appPal) 677void LiquidStyle::polish(QPalette &appPal)
684{ 678{
685 int i; 679 int i;
686 for(i=0; i < BITMAP_ITEMS; ++i){ 680 for(i=0; i < BITMAP_ITEMS; ++i){
687 if(pixmaps[i]){ 681 if(pixmaps[i]){
688 delete pixmaps[i]; 682 delete pixmaps[i];
689 pixmaps[i] = NULL; 683 pixmaps[i] = NULL;
690 } 684 }
691 } 685 }
692 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 686 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
693 btnDict.clear(); 687 btnDict.clear();
694 btnBorderDict.clear(); 688 btnBorderDict.clear();
695 bevelFillDict.clear(); 689 bevelFillDict.clear();
696 smallBevelFillDict.clear(); 690 smallBevelFillDict.clear();
697 691
698 Config config ( "qpe" ); 692 Config config ( "qpe" );
699 config. setGroup ( "Liquid-Style" ); 693 config. setGroup ( "Liquid-Style" );
700 int contrast = config. readNumEntry ( "StippleContrast", 5 ); 694 int contrast = config. readNumEntry ( "StippleContrast", 5 );
701 if ( contrast < 0 ) 695 if ( contrast < 0 )
702 contrast = 0; 696 contrast = 0;
703 else if ( contrast > 10 ) 697 else if ( contrast > 10 )
704 contrast = 10; 698 contrast = 10;
705 699
706// QPalette pal = QApplication::palette(); 700// QPalette pal = QApplication::palette();
707 701
708 // button color stuff 702 // button color stuff
709 config. setGroup ( "Appearance" ); 703 config. setGroup ( "Appearance" );
710 QColor c = oldqte ? QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))) 704 QColor c = appPal. color ( QPalette::Active, QColorGroup::Button );
711 : appPal. color ( QPalette::Active, QColorGroup::Button ); 705 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )) {
712 if ( c == ( oldqte ? QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))
713 : appPal. color ( QPalette::Active, QColorGroup::Background ))) {
714 // force button color to be different from background 706 // force button color to be different from background
715 QBrush btnBrush(QColor(200, 202, 228)); 707 QBrush btnBrush(QColor(200, 202, 228));
716 appPal.setBrush(QColorGroup::Button, btnBrush); 708 appPal.setBrush(QColorGroup::Button, btnBrush);
717 } 709 }
718 c.hsv(&btnH, &btnS, &btnV); 710 c.hsv(&btnH, &btnS, &btnV);
719 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 711 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
720 712
721 // menu pixmap 713 // menu pixmap
722 if(!menuPix){ 714 if(!menuPix){
723 menuPix = new QPixmap; 715 menuPix = new QPixmap;
724 menuPix->resize(64, 64); 716 menuPix->resize(64, 64);
725 } 717 }
726 QPainter painter; 718 QPainter painter;
727 menuPix->fill(c.rgb()); 719 menuPix->fill(c.rgb());
728 painter.begin(menuPix); 720 painter.begin(menuPix);
729 painter.setPen(c.dark(105)); 721 painter.setPen(c.dark(105));
730 for(i=0; i < 63; i+=4){ 722 for(i=0; i < 63; i+=4){
731 painter.drawLine(0, i, 63, i); 723 painter.drawLine(0, i, 63, i);
732 painter.drawLine(0, i+1, 63, i+1); 724 painter.drawLine(0, i+1, 63, i+1);
733 }; 725 };
734 painter.end(); 726 painter.end();
735 menuBrush.setColor(c); 727 menuBrush.setColor(c);
736 menuBrush.setPixmap(*menuPix); 728 menuBrush.setPixmap(*menuPix);
737 729
738 // pager brush 730 // pager brush
739 c = c.dark(120); 731 c = c.dark(120);
740 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 732 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
741 if(!pix){ 733 if(!pix){
742 int h, s, v; 734 int h, s, v;
743 c.hsv(&h, &s, &v); 735 c.hsv(&h, &s, &v);
744 pix = new QPixmap(*smallBevelFillPix); 736 pix = new QPixmap(*smallBevelFillPix);
745 adjustHSV(*pix, h, s, v); 737 adjustHSV(*pix, h, s, v);
746 smallBevelFillDict.insert(c.rgb(), pix); 738 smallBevelFillDict.insert(c.rgb(), pix);
747 } 739 }
748// pagerHoverBrush.setColor(c); 740// pagerHoverBrush.setColor(c);
749// pagerHoverBrush.setPixmap(*pix); 741// pagerHoverBrush.setPixmap(*pix);
750 742
751 c = c.dark(120); 743 c = c.dark(120);
752 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 744 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
753 if(!pix){ 745 if(!pix){
754 int h, s, v; 746 int h, s, v;
755 c.hsv(&h, &s, &v); 747 c.hsv(&h, &s, &v);
756 pix = new QPixmap(*smallBevelFillPix); 748 pix = new QPixmap(*smallBevelFillPix);
757 adjustHSV(*pix, h, s, v); 749 adjustHSV(*pix, h, s, v);
758 smallBevelFillDict.insert(c.rgb(), pix); 750 smallBevelFillDict.insert(c.rgb(), pix);
759 } 751 }
760// pagerBrush.setColor(c); 752// pagerBrush.setColor(c);
761// pagerBrush.setPixmap(*pix); 753// pagerBrush.setPixmap(*pix);
762 754
763 // background color stuff 755 // background color stuff
764 c = oldqte ? QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))) 756 c = appPal. color ( QPalette::Active, QColorGroup::Background );
765 : appPal. color ( QPalette::Active, QColorGroup::Background );
766 757
767 c.hsv(&bH, &bS, &bV); 758 c.hsv(&bH, &bS, &bV);
768 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 759 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
769 760
770 // FIXME? 761 // FIXME?
771 if(vsbSliderFillPix) 762 if(vsbSliderFillPix)
772 delete vsbSliderFillPix; 763 delete vsbSliderFillPix;
773 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 764 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
774 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 765 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
775 766
776 // background brush 767 // background brush
777 QPixmap wallPaper(32, 32); 768 QPixmap wallPaper(32, 32);
778 wallPaper.fill(c.rgb()); 769 wallPaper.fill(c.rgb());
779 painter.begin(&wallPaper); 770 painter.begin(&wallPaper);
780 for(i=0; i < 32; i+=4){ 771 for(i=0; i < 32; i+=4){
781 painter.setPen(c.dark(100 + contrast)); 772 painter.setPen(c.dark(100 + contrast));
782 painter.drawLine(0, i, 32, i); 773 painter.drawLine(0, i, 32, i);
783 painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); 774 painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
784 painter.drawLine(0, i+1, 32, i+1); 775 painter.drawLine(0, i+1, 32, i+1);
785 }; 776 };
786 painter.end(); 777 painter.end();
787 bgBrush.setColor(c); 778 bgBrush.setColor(c);
788 bgBrush.setPixmap(wallPaper); 779 bgBrush.setPixmap(wallPaper);
789 appPal.setBrush(QColorGroup::Background, bgBrush); 780 appPal.setBrush(QColorGroup::Background, bgBrush);
790} 781}
791 782
792void LiquidStyle::polish(QWidget *w) 783void LiquidStyle::polish(QWidget *w)
793{ 784{
794 if(w->inherits("QMenuBar")){ 785 if(w->inherits("QMenuBar")){
795 //((QFrame*)w)->setLineWidth(0); 786 //((QFrame*)w)->setLineWidth(0);
796 w->setBackgroundMode(QWidget::PaletteBackground); 787 w->setBackgroundMode(QWidget::PaletteBackground);
797 w->setBackgroundOrigin(QWidget::ParentOrigin); 788 w->setBackgroundOrigin(QWidget::ParentOrigin);
798 return; 789 return;
799 } 790 }
800 if(w->inherits("QToolBar")){ 791 if(w->inherits("QToolBar")){
801 w->installEventFilter(this); 792 w->installEventFilter(this);
802 w->setBackgroundMode(QWidget::PaletteBackground); 793 w->setBackgroundMode(QWidget::PaletteBackground);
803 w->setBackgroundOrigin(QWidget::WidgetOrigin); 794 w->setBackgroundOrigin(QWidget::WidgetOrigin);
804 return; 795 return;
805 } 796 }
806 if(w->inherits("QPopupMenu")) 797 if(w->inherits("QPopupMenu"))
807 w->setBackgroundMode(QWidget::NoBackground); 798 w->setBackgroundMode(QWidget::NoBackground);
808 else if(w-> testWFlags(Qt::WType_Popup) && 799 else if(w-> testWFlags(Qt::WType_Popup) &&
809 !w->inherits("QListBox") && 800 !w->inherits("QListBox") &&
810 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 801 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
811 w->installEventFilter(menuHandler); 802 w->installEventFilter(menuHandler);
812 } 803 }
813 804
814 if(w->isTopLevel()){ 805 if(w->isTopLevel()){
815 return; 806 return;
816 } 807 }
817 808
818 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 809 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
819 w->installEventFilter(this); 810 w->installEventFilter(this);
820 } 811 }
821 812
822 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 813 if(w->inherits("QButton") || w-> inherits("QComboBox")){
823 w-> setBackgroundMode ( QWidget::PaletteBackground ); 814 w-> setBackgroundMode ( QWidget::PaletteBackground );
824 w->setBackgroundOrigin ( QWidget::ParentOrigin); 815 w->setBackgroundOrigin ( QWidget::ParentOrigin);
825 } 816 }
826 817
827 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 818 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
828 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 819 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
829 bool isViewportChild = w->parent() && 820 bool isViewportChild = w->parent() &&
830 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 821 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
831 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 822 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
832 823
833 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 824 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
834 w->setBackgroundMode(QWidget::X11ParentRelative); 825 w->setBackgroundMode(QWidget::X11ParentRelative);
835 return; 826 return;
836 } 827 }
837 if(isViewportChild){ 828 if(isViewportChild){
838 if(w->inherits("QButton") || w->inherits("QComboBox")){ 829 if(w->inherits("QButton") || w->inherits("QComboBox")){
839 if(w->parent()){ // heh, only way to test for KHTML children ;-) 830 if(w->parent()){ // heh, only way to test for KHTML children ;-)
840 if(w->parent()->parent()){ 831 if(w->parent()->parent()){
841 if(w->parent()->parent()->parent() && 832 if(w->parent()->parent()->parent() &&
842 w->parent()->parent()->parent()->inherits("KHTMLView")){ 833 w->parent()->parent()->parent()->inherits("KHTMLView")){
843 w->setAutoMask(true); 834 w->setAutoMask(true);
844 w->setBackgroundMode(QWidget::NoBackground); 835 w->setBackgroundMode(QWidget::NoBackground);
845 } 836 }
846 } 837 }
847 } 838 }
848 return; 839 return;
849 } 840 }
850 } 841 }
851 if(w->inherits("QHeader")){ 842 if(w->inherits("QHeader")){
852 w->setMouseTracking(true); 843 w->setMouseTracking(true);
853 w->installEventFilter(this); 844 w->installEventFilter(this);
854 } 845 }
855 if(w-> inherits("QToolButton")) { 846 if(w-> inherits("QToolButton")) {
856 if (w->parent()->inherits("QToolBar")) { 847 if (w->parent()->inherits("QToolBar")) {
857 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 848 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
858 if ( flatTBButtons ) 849 if ( flatTBButtons )
859 w->setBackgroundOrigin(QWidget::ParentOrigin); 850 w->setBackgroundOrigin(QWidget::ParentOrigin);
860 } 851 }
861 w-> installEventFilter ( this ); 852 w-> installEventFilter ( this );
862 } 853 }
863 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { 854 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
864 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); 855 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
865 } 856 }
866 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 857 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
867 return; 858 return;
868 } 859 }
869 860
870 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 861 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
871 palette().active().brush(QColorGroup::Background).pixmap()){ 862 palette().active().brush(QColorGroup::Background).pixmap()){
872 qWarning("No parent pixmap for child widget %s", w->className()); 863 qWarning("No parent pixmap for child widget %s", w->className());
873 return; 864 return;
874 } 865 }
875 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 866 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
876 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 867 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
877 if(w->backgroundMode() == QWidget::PaletteBackground || 868 if(w->backgroundMode() == QWidget::PaletteBackground ||
878 w->backgroundMode() == QWidget::PaletteButton){ 869 w->backgroundMode() == QWidget::PaletteButton){
879 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); 870 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
880 w->setBackgroundOrigin(QWidget::ParentOrigin); 871 w->setBackgroundOrigin(QWidget::ParentOrigin);
881 // w->setBackgroundMode(QWidget::NoBackground); 872 // w->setBackgroundMode(QWidget::NoBackground);
882 } 873 }
883 } 874 }
884 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 875 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
885 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 876 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
886 else if ( w-> inherits("QFrame") ) 877 else if ( w-> inherits("QFrame") )
887 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 878 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
888 879
889 if ( w->parentWidget()->inherits ( "QWidgetStack" )) { 880 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
890 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 881 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
891 } 882 }
892} 883}
893 884
894void LiquidStyle::unPolish(QWidget *w) 885void LiquidStyle::unPolish(QWidget *w)
895{ 886{
896 if(w->inherits("QMenuBar")){ 887 if(w->inherits("QMenuBar")){
897 ((QFrame *)w)->setLineWidth(1); 888 ((QFrame *)w)->setLineWidth(1);
898 w->setBackgroundMode(QWidget::PaletteBackground); 889 w->setBackgroundMode(QWidget::PaletteBackground);
899 return; 890 return;
900 } 891 }
901 892
902 if(w->inherits("QPopupMenu")) 893 if(w->inherits("QPopupMenu"))
903 w->setBackgroundMode(QWidget::PaletteButton); 894 w->setBackgroundMode(QWidget::PaletteButton);
904 else if(w-> testWFlags(Qt::WType_Popup) && 895 else if(w-> testWFlags(Qt::WType_Popup) &&
905 !w->inherits("QListBox") && 896 !w->inherits("QListBox") &&
906 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 897 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
907 w->removeEventFilter(menuHandler); 898 w->removeEventFilter(menuHandler);
908 } 899 }
909 900
910 if(w->isTopLevel()) 901 if(w->isTopLevel())
911 return; 902 return;
912 903
913 // for viewport children, don't just check for NoBackground.... 904 // for viewport children, don't just check for NoBackground....
914 bool isViewportChild = w->parent() && 905 bool isViewportChild = w->parent() &&
915 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 906 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
916 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 907 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
917 908
918 w->unsetPalette(); 909 w->unsetPalette();
919 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 910 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
920 if(w->inherits("QPushButton")) 911 if(w->inherits("QPushButton"))
921 w->setBackgroundMode(QWidget::PaletteButton); 912 w->setBackgroundMode(QWidget::PaletteButton);
922 else 913 else
923 w->setBackgroundMode(QWidget::PaletteBackground); 914 w->setBackgroundMode(QWidget::PaletteBackground);
924 } 915 }
925 916
926 if(isViewportChild) 917 if(isViewportChild)
927 w->setAutoMask(false); 918 w->setAutoMask(false);
928 919
929/* 920/*
930 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 921 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
931 w-> setBackgroundMode ( PaletteBackground ); 922 w-> setBackgroundMode ( PaletteBackground );
932 } 923 }
933*/ 924*/
934 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 925 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
935 w->removeEventFilter(this); 926 w->removeEventFilter(this);
936 } 927 }
937 if(w->inherits("QButton") || w->inherits("QComboBox")){ 928 if(w->inherits("QButton") || w->inherits("QComboBox")){
938 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 929 if(w->parent() && w->parent()->inherits("KHTMLPart")){
939 w->setAutoMask(false); 930 w->setAutoMask(false);
940 } 931 }
941 } 932 }
942 if(w-> inherits("QToolButton")) { 933 if(w-> inherits("QToolButton")) {
943 w-> removeEventFilter ( this ); 934 w-> removeEventFilter ( this );
944 } 935 }
945 if(w->inherits("QToolBar")){ 936 if(w->inherits("QToolBar")){
946 w->removeEventFilter(this); 937 w->removeEventFilter(this);
947 w->setBackgroundMode(QWidget::PaletteBackground); 938 w->setBackgroundMode(QWidget::PaletteBackground);
948 return; 939 return;
949 } 940 }
950 if(w->inherits("QHeader")){ 941 if(w->inherits("QHeader")){
951 w->setMouseTracking(false); 942 w->setMouseTracking(false);
952 w->removeEventFilter(this); 943 w->removeEventFilter(this);
953 } 944 }
954} 945}
955 946
956void LiquidStyle::polish(QApplication *app) 947void LiquidStyle::polish(QApplication *app)
957{ 948{
958 949
959 QWindowsStyle::polish(app); 950 QWindowsStyle::polish(app);
960 menuAni = app->isEffectEnabled(UI_AnimateMenu); 951 menuAni = app->isEffectEnabled(UI_AnimateMenu);
961 menuFade = app->isEffectEnabled(UI_FadeMenu); 952 menuFade = app->isEffectEnabled(UI_FadeMenu);
962 if(menuAni) 953 if(menuAni)
963 app->setEffectEnabled(UI_AnimateMenu, false); 954 app->setEffectEnabled(UI_AnimateMenu, false);
964 if(menuFade) 955 if(menuFade)
965 app->setEffectEnabled(UI_FadeMenu, false); 956 app->setEffectEnabled(UI_FadeMenu, false);
966 957
967 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 958 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
968 959
969 Config config ( "qpe" ); 960 Config config ( "qpe" );
970 config. setGroup ( "Liquid-Style" ); 961 config. setGroup ( "Liquid-Style" );
971 962
972 // if ( config. readBoolEntry ( "WinDecoration", true )) 963 // if ( config. readBoolEntry ( "WinDecoration", true ))
973 // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); 964 // QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
974 965
975 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); 966 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
976} 967}
977 968
978void LiquidStyle::unPolish(QApplication *app) 969void LiquidStyle::unPolish(QApplication *app)
979{ 970{
980 QWindowsStyle::unPolish(app); 971 QWindowsStyle::unPolish(app);
981 app->setEffectEnabled(UI_AnimateMenu, menuAni); 972 app->setEffectEnabled(UI_AnimateMenu, menuAni);
982 app->setEffectEnabled(UI_FadeMenu, menuFade); 973 app->setEffectEnabled(UI_FadeMenu, menuFade);
983 974
984 qt_set_draw_menu_bar_impl ( 0 ); 975 qt_set_draw_menu_bar_impl ( 0 );
985 976
986// QApplication::qwsSetDecoration ( new QPEDecoration ( )); 977// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
987} 978}
988 979
989 980
990/* !! HACK !! Beware 981/* !! HACK !! Beware
991 * 982 *
992 * TT forgot to make the QProgressBar widget styleable in Qt 2.x 983 * TT forgot to make the QProgressBar widget styleable in Qt 2.x
993 * So the only way to customize the drawing, is to intercept the 984 * So the only way to customize the drawing, is to intercept the
994 * paint event - since we have to use protected functions, we need 985 * paint event - since we have to use protected functions, we need
995 * to derive a "hack" class from QProgressBar and do the painting 986 * to derive a "hack" class from QProgressBar and do the painting
996 * in there. 987 * in there.
997 * 988 *
998 * - sandman 989 * - sandman
999 */ 990 */
1000 991
1001class HackProgressBar : public QProgressBar { 992class HackProgressBar : public QProgressBar {
1002public: 993public:
1003 HackProgressBar ( ); 994 HackProgressBar ( );
1004 995
1005 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) 996 void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix )
1006 { 997 {
1007 QPainter p( this ); 998 QPainter p( this );
1008 999
1009 if ( !contentsRect().contains( event->rect() ) ) { 1000 if ( !contentsRect().contains( event->rect() ) ) {
1010 p.save(); 1001 p.save();
1011 p.setClipRegion( event->region().intersect(frameRect()) ); 1002 p.setClipRegion( event->region().intersect(frameRect()) );
1012 drawFrame( &p); 1003 drawFrame( &p);
1013 p.restore(); 1004 p.restore();
1014 } 1005 }
1015 if ( event->rect().intersects( contentsRect() )) { 1006 if ( event->rect().intersects( contentsRect() )) {
1016 p.setClipRegion( event->region().intersect( contentsRect() ) ); 1007 p.setClipRegion( event->region().intersect( contentsRect() ) );
1017 1008
1018 int x, y, w, h; 1009 int x, y, w, h;
1019 contentsRect ( ). rect ( &x, &y, &w, &h ); 1010 contentsRect ( ). rect ( &x, &y, &w, &h );
1020 1011
1021 int prog = progress ( ); 1012 int prog = progress ( );
1022 int total = totalSteps ( ); 1013 int total = totalSteps ( );
1023 if ( prog < 0 ) 1014 if ( prog < 0 )
1024 prog = 0; 1015 prog = 0;
1025 if ( total <= 0 ) 1016 if ( total <= 0 )
1026 total = 1; 1017 total = 1;
1027 int bw = w * prog / total; 1018 int bw = w * prog / total;
1028 if ( bw > w ) 1019 if ( bw > w )
1029 bw = w; 1020 bw = w;
1030 1021
1031 p.setPen(g.button().dark(130)); 1022 p.setPen(g.button().dark(130));
1032 p.drawRect(x, y, bw, h); 1023 p.drawRect(x, y, bw, h);
1033 p.setPen(g.button().light(120)); 1024 p.setPen(g.button().light(120));
1034 p.drawRect(x+1, y+1, bw-2, h-2); 1025 p.drawRect(x+1, y+1, bw-2, h-2);
1035 1026
1036 if(bw >= 4 && h >= 4 && pix) 1027 if(bw >= 4 && h >= 4 && pix)
1037 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); 1028 p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
1038 1029
1039 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { 1030 if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
1040 QString pstr; 1031 QString pstr;
1041 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); 1032 pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
1042 p. setPen ( g.text());//g.highlightedText ( )); 1033 p. setPen ( g.text());//g.highlightedText ( ));
1043 p. drawText (x,y,w-1,h-1,AlignCenter,pstr); 1034 p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
1044 } 1035 }
1045 } 1036 }
1046 } 1037 }
1047}; 1038};
1048 1039
1049 1040
1050/* 1041/*
1051 * The same for QToolButton: 1042 * The same for QToolButton:
1052 * TT hardcoded the drawing of the focus rect ... 1043 * TT hardcoded the drawing of the focus rect ...
1053 * 1044 *
1054 * - sandman 1045 * - sandman
1055 */ 1046 */
1056 1047
1057 1048
1058class HackToolButton : public QToolButton { 1049class HackToolButton : public QToolButton {
1059public: 1050public:
1060 HackToolButton ( ); 1051 HackToolButton ( );
1061 1052
1062 void paint ( QPaintEvent *ev ) 1053 void paint ( QPaintEvent *ev )
1063 { 1054 {
1064 erase ( ev-> region ( )); 1055 erase ( ev-> region ( ));
1065 QPainter p ( this ); 1056 QPainter p ( this );
1066 style ( ). drawToolButton ( this, &p ); 1057 style ( ). drawToolButton ( this, &p );
1067 drawButtonLabel ( &p ); 1058 drawButtonLabel ( &p );
1068 } 1059 }
1069}; 1060};
1070 1061
1071/* 1062/*
1072 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1063 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1073 * force everything to erase and repaint on resize. This is going away, I'm 1064 * force everything to erase and repaint on resize. This is going away, I'm
1074 * trying to get shaped widgets to work right without masking. QPushButton, 1065 * trying to get shaped widgets to work right without masking. QPushButton,
1075 * QComboBox, and Panel applet handles capture mouse enter and leaves in order 1066 * QComboBox, and Panel applet handles capture mouse enter and leaves in order
1076 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and 1067 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
1077 * RadioButtons need to do this differently. Qt buffers these in pixmaps and 1068 * RadioButtons need to do this differently. Qt buffers these in pixmaps and
1078 * caches them in QPixmapCache, which is bad for doing things like hover 1069 * caches them in QPixmapCache, which is bad for doing things like hover
1079 * because the style methods aren't called in paintEvents if everything 1070 * because the style methods aren't called in paintEvents if everything
1080 * is cached. We use our own Paint event handler instead. Taskbuttons and 1071 * is cached. We use our own Paint event handler instead. Taskbuttons and
1081 * pager buttons draw into a pixmap buffer, so we handle those with palette 1072 * pager buttons draw into a pixmap buffer, so we handle those with palette
1082 * modifications. For QHeader, different header items are actually one widget 1073 * modifications. For QHeader, different header items are actually one widget
1083 * that draws multiple items, so we need to check which ID is hightlighted 1074 * that draws multiple items, so we need to check which ID is hightlighted
1084 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1075 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1085 * since if it's inside a combobox we want to highlight the combobox during 1076 * since if it's inside a combobox we want to highlight the combobox during
1086 * hovering in the edit. 1077 * hovering in the edit.
1087 */ 1078 */
1088bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1079bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1089{ 1080{
1090 if(obj->inherits("QToolBar")){ 1081 if(obj->inherits("QToolBar")){
1091 if(ev->type() == QEvent::Resize){ 1082 if(ev->type() == QEvent::Resize){
1092 const QObjectList *tbChildList = obj->children(); 1083 const QObjectList *tbChildList = obj->children();
1093 QObjectListIt it(*tbChildList); 1084 QObjectListIt it(*tbChildList);
1094 QObject *child; 1085 QObject *child;
1095 while((child = it.current()) != NULL){ 1086 while((child = it.current()) != NULL){
1096 ++it; 1087 ++it;
1097 if(child->isWidgetType()) 1088 if(child->isWidgetType())
1098 ((QWidget *)child)->repaint(true); 1089 ((QWidget *)child)->repaint(true);
1099 } 1090 }
1100 1091
1101 } 1092 }
1102 } 1093 }
1103 else if(obj->inherits("QToolButton")){ 1094 else if(obj->inherits("QToolButton")){
1104 QToolButton *btn = (QToolButton *)obj; 1095 QToolButton *btn = (QToolButton *)obj;
1105 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () 1096 if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
1106 if(btn->isEnabled()){ 1097 if(btn->isEnabled()){
1107 highlightWidget = btn; 1098 highlightWidget = btn;
1108 btn->repaint(false); 1099 btn->repaint(false);
1109 } 1100 }
1110 } 1101 }
1111 else if(ev->type() == QEvent::FocusOut ){ 1102 else if(ev->type() == QEvent::FocusOut ){
1112 if(btn == highlightWidget){ 1103 if(btn == highlightWidget){
1113 highlightWidget = NULL; 1104 highlightWidget = NULL;
1114 btn->repaint(false); 1105 btn->repaint(false);
1115 } 1106 }
1116 } 1107 }
1117 else if(ev->type() == QEvent::Paint) { 1108 else if(ev->type() == QEvent::Paint) {
1118 (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); 1109 (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev );
1119 return true; 1110 return true;
1120 } 1111 }
1121 } 1112 }
1122 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ 1113 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
1123 QButton *btn = (QButton *)obj; 1114 QButton *btn = (QButton *)obj;
1124 bool isRadio = obj->inherits("QRadioButton"); 1115 bool isRadio = obj->inherits("QRadioButton");
1125 if(ev->type() == QEvent::Paint){ 1116 if(ev->type() == QEvent::Paint){
1126 //if(btn->autoMask()) 1117 //if(btn->autoMask())
1127 btn->erase(); 1118 btn->erase();
1128 QPainter p; 1119 QPainter p;
1129 p.begin(btn); 1120 p.begin(btn);
1130 QFontMetrics fm = btn->fontMetrics(); 1121 QFontMetrics fm = btn->fontMetrics();
1131 QSize lsz = fm.size(ShowPrefix, btn->text()); 1122 QSize lsz = fm.size(ShowPrefix, btn->text());
1132 QSize sz = isRadio ? exclusiveIndicatorSize() 1123 QSize sz = isRadio ? exclusiveIndicatorSize()
1133 : indicatorSize(); 1124 : indicatorSize();
1134 1125
1135/* 1126/*
1136 if(btn->hasFocus()){ 1127 if(btn->hasFocus()){
1137 QRect r = QRect(0, 0, btn->width(), btn->height()); 1128 QRect r = QRect(0, 0, btn->width(), btn->height());
1138 p.setPen(btn->colorGroup().button().dark(140)); 1129 p.setPen(btn->colorGroup().button().dark(140));
1139 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1130 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1140 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1131 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1141 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1132 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1142 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1133 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1143 } 1134 }
1144*/ 1135*/
1145 int x = 0; 1136 int x = 0;
1146 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1137 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1147 if(isRadio) 1138 if(isRadio)
1148 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1139 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1149 btn->colorGroup(), btn->isOn(), 1140 btn->colorGroup(), btn->isOn(),