summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 1d01c65..259f6af 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,2731 +1,2743 @@
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 6
7#ifndef INCLUDE_MENUITEM_DEF 7#ifndef INCLUDE_MENUITEM_DEF
8#define INCLUDE_MENUITEM_DEF 8#define INCLUDE_MENUITEM_DEF
9#endif 9#endif
10 10
11#include <qmenudata.h> 11#include <qmenudata.h>
12#include "liquid.h" 12#include "liquid.h"
13//#include "liquiddeco.h" 13//#include "liquiddeco.h"
14#include <qapplication.h> 14#include <qapplication.h>
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include "effects.h" 16#include "effects.h"
17#include <qpalette.h> 17#include <qpalette.h>
18#include <qbitmap.h> 18#include <qbitmap.h>
19#include <qtabbar.h> 19#include <qtabbar.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qobjectlist.h> 21#include <qobjectlist.h>
22#include <qimage.h> 22#include <qimage.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qpixmapcache.h> 24#include <qpixmapcache.h>
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qwidgetlist.h> 28#include <qwidgetlist.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qheader.h> 30#include <qheader.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <qmenubar.h> 32#include <qmenubar.h>
33 33
34 34
35#include <stdio.h> 35#include <stdio.h>
36 36
37#include "htmlmasks.h" 37#include "htmlmasks.h"
38#include "embeddata.h" 38#include "embeddata.h"
39 39
40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
41 QColorGroup &, bool, bool); 41 QColorGroup &, bool, bool);
42 42
43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
44 44
45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
46{ 46{
47 QImage img(pix.convertToImage()); 47 QImage img(pix.convertToImage());
48 QImageEffect::fade(img, 0.9, color); 48 QImageEffect::fade(img, 0.9, color);
49 int x, y; 49 int x, y;
50 int r, g, b; 50 int r, g, b;
51 for(y=0; y < img.height(); y+=3){ 51 for(y=0; y < img.height(); y+=3){
52 unsigned int *data = (unsigned int *) img.scanLine(y); 52 unsigned int *data = (unsigned int *) img.scanLine(y);
53 for(x=0; x < img.width(); ++x){ 53 for(x=0; x < img.width(); ++x){
54 r = qRed(data[x]); 54 r = qRed(data[x]);
55 g = qGreen(data[x]); 55 g = qGreen(data[x]);
56 b = qBlue(data[x]); 56 b = qBlue(data[x]);
57 if(r-10) 57 if(r-10)
58 r-=10; 58 r-=10;
59 if(g-10) 59 if(g-10)
60 g-=10; 60 g-=10;
61 if(b-10) 61 if(b-10)
62 b-=10; 62 b-=10;
63 data[x] = qRgb(r, g, b); 63 data[x] = qRgb(r, g, b);
64 } 64 }
65 } 65 }
66 pix.convertFromImage(img); 66 pix.convertFromImage(img);
67} 67}
68 68
69TransMenuHandler::TransMenuHandler(QObject *parent) 69TransMenuHandler::TransMenuHandler(QObject *parent)
70 : QObject(parent) 70 : QObject(parent)
71{ 71{
72 pixDict.setAutoDelete(true); 72 pixDict.setAutoDelete(true);
73 reloadSettings(); 73 reloadSettings();
74} 74}
75 75
76void TransMenuHandler::reloadSettings() 76void TransMenuHandler::reloadSettings()
77{ 77{
78 pixDict.clear(); 78 pixDict.clear();
79 79
80 Config config ( "qpe" ); 80 Config config ( "qpe" );
81 config. setGroup ( "Liquid-Style" ); 81 config. setGroup ( "Liquid-Style" );
82 82
83 type = config. readNumEntry("Type", TransStippleBg); 83 type = config. readNumEntry("Type", TransStippleBg);
84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
86 opacity = config. readNumEntry("Opacity", 10); 86 opacity = config. readNumEntry("Opacity", 10);
87 if ( opacity < -20 ) 87 if ( opacity < -20 )
88 opacity = 20; 88 opacity = 20;
89 else if ( opacity > 20 ) 89 else if ( opacity > 20 )
90 opacity = 20; 90 opacity = 20;
91 91
92 shadowText = config. readBoolEntry("ShadowText", true); 92 shadowText = config. readBoolEntry("ShadowText", true);
93} 93}
94 94
95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
96{ 96{
97 QWidget *p = (QWidget *)obj; 97 QWidget *p = (QWidget *)obj;
98 98
99 if(ev->type() == QEvent::Show){ 99 if(ev->type() == QEvent::Show){
100 if(type == TransStippleBg || type == TransStippleBtn || 100 if(type == TransStippleBg || type == TransStippleBtn ||
101 type == Custom){ 101 type == Custom){
102 QApplication::syncX(); 102 QApplication::syncX();
103 QPixmap *pix = new QPixmap; 103 QPixmap *pix = new QPixmap;
104 if(p->testWFlags(Qt::WType_Popup)){ 104 if(p->testWFlags(Qt::WType_Popup)){
105 QRect r(p->x(), p->y(), p->width(), p->height()); 105 QRect r(p->x(), p->y(), p->width(), p->height());
106 QRect deskR = QApplication::desktop()->rect(); 106 QRect deskR = QApplication::desktop()->rect();
107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
108 r.setBottom(deskR.bottom()); 108 r.setBottom(deskR.bottom());
109 r.setRight(deskR.right()); 109 r.setRight(deskR.right());
110 } 110 }
111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
112 r.width(), r.height()); 112 r.width(), r.height());
113 } 113 }
114 else{ // tear off menu 114 else{ // tear off menu
115 pix->resize(p->width(), p->height()); 115 pix->resize(p->width(), p->height());
116 pix->fill(Qt::black.rgb()); 116 pix->fill(Qt::black.rgb());
117 } 117 }
118 if(type == TransStippleBg){ 118 if(type == TransStippleBg){
119 stripePixmap(*pix, p->colorGroup().background()); 119 stripePixmap(*pix, p->colorGroup().background());
120 } 120 }
121 else if(type == TransStippleBtn){ 121 else if(type == TransStippleBtn){
122 stripePixmap(*pix, p->colorGroup().button()); 122 stripePixmap(*pix, p->colorGroup().button());
123 } 123 }
124 else{ 124 else{
125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
126 } 126 }
127 127
128 pixDict.insert(p->winId(), pix); 128 pixDict.insert(p->winId(), pix);
129 129
130 if (!p->inherits("QPopupMenu")) { 130 if (!p->inherits("QPopupMenu")) {
131 p->setBackgroundPixmap(*pix); 131 p->setBackgroundPixmap(*pix);
132 132
133 QObjectList *ol = p-> queryList("QWidget"); 133 QObjectList *ol = p-> queryList("QWidget");
134 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 134 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
135 QWidget *wid = (QWidget *) it.current ( ); 135 QWidget *wid = (QWidget *) it.current ( );
136 136
137 wid-> setBackgroundPixmap(*pix); 137 wid-> setBackgroundPixmap(*pix);
138 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 138 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
139 } 139 }
140 delete ol; 140 delete ol;
141 } 141 }
142 } 142 }
143 } 143 }
144 else if(ev->type() == QEvent::Hide){ 144 else if(ev->type() == QEvent::Hide){
145 if(type == TransStippleBg || type == TransStippleBtn || 145 if(type == TransStippleBg || type == TransStippleBtn ||
146 type == Custom){ 146 type == Custom){
147// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 147// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
148 148
149 pixDict.remove(p->winId()); 149 pixDict.remove(p->winId());
150 if (!p->inherits("QPopupMenu")) { 150 if (!p->inherits("QPopupMenu")) {
151 p->setBackgroundMode(QWidget::PaletteBackground); 151 p->setBackgroundMode(QWidget::PaletteBackground);
152 152
153 QObjectList *ol = p-> queryList("QWidget"); 153 QObjectList *ol = p-> queryList("QWidget");
154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
155 QWidget *wid = (QWidget *) it.current ( ); 155 QWidget *wid = (QWidget *) it.current ( );
156 156
157 wid-> setBackgroundMode( QWidget::PaletteBackground ); 157 wid-> setBackgroundMode( QWidget::PaletteBackground );
158 } 158 }
159 delete ol; 159 delete ol;
160 } 160 }
161 } 161 }
162 } 162 }
163 return(false); 163 return(false);
164} 164}
165 165
166 166
167LiquidStyle::LiquidStyle() 167LiquidStyle::LiquidStyle()
168 :QWindowsStyle() 168 :QWindowsStyle()
169{ 169{
170 setName ( "LiquidStyle" ); 170 setName ( "LiquidStyle" );
171 171
172 flatTBButtons = false; 172 flatTBButtons = false;
173 173
174 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 174 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
175 btnMaskBmp.setMask(btnMaskBmp); 175 btnMaskBmp.setMask(btnMaskBmp);
176 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 176 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
177 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 177 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
178 headerHoverID = -1; 178 headerHoverID = -1;
179 highlightWidget = NULL; 179 highlightWidget = NULL;
180 setButtonDefaultIndicatorWidth(0); 180 setButtonDefaultIndicatorWidth(0);
181 btnDict.setAutoDelete(true); 181 btnDict.setAutoDelete(true);
182 bevelFillDict.setAutoDelete(true); 182 bevelFillDict.setAutoDelete(true);
183 smallBevelFillDict.setAutoDelete(true); 183 smallBevelFillDict.setAutoDelete(true);
184 customBtnColorList.setAutoDelete(true); 184 customBtnColorList.setAutoDelete(true);
185 customBtnIconList.setAutoDelete(true); 185 customBtnIconList.setAutoDelete(true);
186 customBtnLabelList.setAutoDelete(true); 186 customBtnLabelList.setAutoDelete(true);
187 187
188 rMatrix.rotate(270.0); 188 rMatrix.rotate(270.0);
189 highcolor = QPixmap::defaultDepth() > 8; 189 highcolor = QPixmap::defaultDepth() > 8;
190 btnBorderPix = new QPixmap; 190 btnBorderPix = new QPixmap;
191 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 191 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
192 btnBlendPix = new QPixmap; 192 btnBlendPix = new QPixmap;
193 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 193 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
194 bevelFillPix = new QPixmap; 194 bevelFillPix = new QPixmap;
195 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 195 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
196 smallBevelFillPix = new QPixmap; 196 smallBevelFillPix = new QPixmap;
197 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 197 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
198 // new stuff 198 // new stuff
199 vsbSliderFillPix = menuPix = NULL; 199 vsbSliderFillPix = menuPix = NULL;
200 menuHandler = new TransMenuHandler(this); 200 menuHandler = new TransMenuHandler(this);
201 setScrollBarExtent(15, 15); 201 setScrollBarExtent(15, 15);
202 int i; 202 int i;
203 for(i=0; i < BITMAP_ITEMS; ++i){ 203 for(i=0; i < BITMAP_ITEMS; ++i){
204 pixmaps[i] = NULL; 204 pixmaps[i] = NULL;
205 } 205 }
206 oldSliderThickness = sliderThickness(); 206 oldSliderThickness = sliderThickness();
207 setSliderThickness(11); 207 setSliderThickness(11);
208} 208}
209 209
210LiquidStyle::~LiquidStyle() 210LiquidStyle::~LiquidStyle()
211{ 211{
212 if(btnBorderPix) 212 if(btnBorderPix)
213 delete btnBorderPix; 213 delete btnBorderPix;
214 if(btnBlendPix) 214 if(btnBlendPix)
215 delete btnBlendPix; 215 delete btnBlendPix;
216 if(bevelFillPix) 216 if(bevelFillPix)
217 delete bevelFillPix; 217 delete bevelFillPix;
218 if(smallBevelFillPix) 218 if(smallBevelFillPix)
219 delete smallBevelFillPix; 219 delete smallBevelFillPix;
220 if(vsbSliderFillPix) 220 if(vsbSliderFillPix)
221 delete vsbSliderFillPix; 221 delete vsbSliderFillPix;
222 if(menuPix) 222 if(menuPix)
223 delete menuPix; 223 delete menuPix;
224 224
225 setScrollBarExtent(16, 16); 225 setScrollBarExtent(16, 16);
226 setSliderThickness(oldSliderThickness); 226 setSliderThickness(oldSliderThickness);
227 int i; 227 int i;
228 for(i=0; i < BITMAP_ITEMS; ++i){ 228 for(i=0; i < BITMAP_ITEMS; ++i){
229 if(pixmaps[i]) 229 if(pixmaps[i])
230 delete pixmaps[i]; 230 delete pixmaps[i];
231 } 231 }
232} 232}
233 233
234void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 234void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
235 const QColor &c, const QColor &bg) 235 const QColor &c, const QColor &bg)
236{ 236{
237 237
238 QPen oldPen = p->pen(); // headers need this 238 QPen oldPen = p->pen(); // headers need this
239 int x2 = x+w-1; 239 int x2 = x+w-1;
240 int y2 = y+h-1; 240 int y2 = y+h-1;
241 // outer dark rect 241 // outer dark rect
242 p->setPen(c.dark(130)); 242 p->setPen(c.dark(130));
243 p->drawLine(x, y+2, x, y2-2); // l 243 p->drawLine(x, y+2, x, y2-2); // l
244 p->drawLine(x2, y+2, x2, y2-2); // r 244 p->drawLine(x2, y+2, x2, y2-2); // r
245 p->drawLine(x+2, y, x2-2, y); // t 245 p->drawLine(x+2, y, x2-2, y); // t
246 p->drawLine(x+2, y2, x2-2, y2); // b 246 p->drawLine(x+2, y2, x2-2, y2); // b
247 p->drawPoint(x+1, y+1); // tl 247 p->drawPoint(x+1, y+1); // tl
248 p->drawPoint(x2-1, y+1); // tr 248 p->drawPoint(x2-1, y+1); // tr
249 p->drawPoint(x+1, y2-1); // bl 249 p->drawPoint(x+1, y2-1); // bl
250 p->drawPoint(x2-1, y2-1); // br 250 p->drawPoint(x2-1, y2-1); // br
251 251
252 // inner top light lines 252 // inner top light lines
253 p->setPen(c.light(105)); 253 p->setPen(c.light(105));
254 p->drawLine(x+2, y+1, x2-2, y+1); 254 p->drawLine(x+2, y+1, x2-2, y+1);
255 p->drawLine(x+1, y+2, x2-1, y+2); 255 p->drawLine(x+1, y+2, x2-1, y+2);
256 p->drawLine(x+1, y+3, x+2, y+3); 256 p->drawLine(x+1, y+3, x+2, y+3);
257 p->drawLine(x2-2, y+3, x2-1, y+3); 257 p->drawLine(x2-2, y+3, x2-1, y+3);
258 p->drawPoint(x+1, y+4); 258 p->drawPoint(x+1, y+4);
259 p->drawPoint(x2-1, y+4); 259 p->drawPoint(x2-1, y+4);
260 260
261 // inner bottom light lines 261 // inner bottom light lines
262 p->setPen(c.light(110)); 262 p->setPen(c.light(110));
263 p->drawLine(x+2, y2-1, x2-2, y2-1); 263 p->drawLine(x+2, y2-1, x2-2, y2-1);
264 p->drawLine(x+1, y2-2, x2-1, y2-2); 264 p->drawLine(x+1, y2-2, x2-1, y2-2);
265 p->drawLine(x+1, y2-3, x+2, y2-3); 265 p->drawLine(x+1, y2-3, x+2, y2-3);
266 p->drawLine(x2-2, y2-3, x2-1, y2-3); 266 p->drawLine(x2-2, y2-3, x2-1, y2-3);
267 p->drawPoint(x+1, y2-4); 267 p->drawPoint(x+1, y2-4);
268 p->drawPoint(x2-1, y2-4); 268 p->drawPoint(x2-1, y2-4);
269 269
270 // inner left mid lines 270 // inner left mid lines
271 //p->setPen(c.light(105)); 271 //p->setPen(c.light(105));
272 p->setPen(c); 272 p->setPen(c);
273 p->drawLine(x+1, y+5, x+1, y2-5); 273 p->drawLine(x+1, y+5, x+1, y2-5);
274 p->drawLine(x+2, y+4, x+2, y2-4); 274 p->drawLine(x+2, y+4, x+2, y2-4);
275 275
276 // inner right mid lines 276 // inner right mid lines
277 p->drawLine(x2-1, y+5, x2-1, y2-5); 277 p->drawLine(x2-1, y+5, x2-1, y2-5);
278 p->drawLine(x2-2, y+4, x2-2, y2-4); 278 p->drawLine(x2-2, y+4, x2-2, y2-4);
279 279
280 // fill 280 // fill
281 QPixmap *pix; 281 QPixmap *pix;
282 if(h >= 32){ 282 if(h >= 32){
283 pix = bevelFillDict.find(c.rgb()); 283 pix = bevelFillDict.find(c.rgb());
284 if(!pix){ 284 if(!pix){
285 int h, s, v; 285 int h, s, v;
286 c.hsv(&h, &s, &v); 286 c.hsv(&h, &s, &v);
287 pix = new QPixmap(*bevelFillPix); 287 pix = new QPixmap(*bevelFillPix);
288 adjustHSV(*pix, h, s, v); 288 adjustHSV(*pix, h, s, v);
289 bevelFillDict.insert(c.rgb(), pix); 289 bevelFillDict.insert(c.rgb(), pix);
290 } 290 }
291 } 291 }
292 else{ 292 else{
293 pix = smallBevelFillDict.find(c.rgb()); 293 pix = smallBevelFillDict.find(c.rgb());
294 if(!pix){ 294 if(!pix){
295 int h, s, v; 295 int h, s, v;
296 c.hsv(&h, &s, &v); 296 c.hsv(&h, &s, &v);
297 pix = new QPixmap(*smallBevelFillPix); 297 pix = new QPixmap(*smallBevelFillPix);
298 adjustHSV(*pix, h, s, v); 298 adjustHSV(*pix, h, s, v);
299 smallBevelFillDict.insert(c.rgb(), pix); 299 smallBevelFillDict.insert(c.rgb(), pix);
300 } 300 }
301 } 301 }
302 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 302 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
303 // blend 303 // blend
304 int red, green, blue; 304 int red, green, blue;
305 QColor btnColor(c.dark(130)); 305 QColor btnColor(c.dark(130));
306 red = (btnColor.red() >> 1) + (bg.red() >> 1); 306 red = (btnColor.red() >> 1) + (bg.red() >> 1);
307 green = (btnColor.green() >> 1) + (bg.green() >> 1); 307 green = (btnColor.green() >> 1) + (bg.green() >> 1);
308 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 308 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
309 btnColor.setRgb(red, green, blue); 309 btnColor.setRgb(red, green, blue);
310 310
311 p->setPen(btnColor); 311 p->setPen(btnColor);
312 p->drawPoint(x+1, y); 312 p->drawPoint(x+1, y);
313 p->drawPoint(x, y+1); 313 p->drawPoint(x, y+1);
314 p->drawPoint(x+1, y2); 314 p->drawPoint(x+1, y2);
315 p->drawPoint(x, y2-1); 315 p->drawPoint(x, y2-1);
316 316
317 p->drawPoint(x2-1, y); 317 p->drawPoint(x2-1, y);
318 p->drawPoint(x2, y+1); 318 p->drawPoint(x2, y+1);
319 p->drawPoint(x2-1, y2); 319 p->drawPoint(x2-1, y2);
320 p->drawPoint(x2, y2-1); 320 p->drawPoint(x2, y2-1);
321 321
322 p->setPen(oldPen); 322 p->setPen(oldPen);
323 323
324} 324}
325 325
326void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 326void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
327 const QColor &back, int x, int y, int w, int h, 327 const QColor &back, int x, int y, int w, int h,
328 bool supportPushDown, bool pushedDown, 328 bool supportPushDown, bool pushedDown,
329 bool autoDefault, bool isMasked) 329 bool autoDefault, bool isMasked)
330{ 330{
331 if(w < 21 || h < 21){ 331 if(w < 21 || h < 21){
332 drawClearBevel(painter, x, y, w, h, c, back); 332 drawClearBevel(painter, x, y, w, h, c, back);
333 return; 333 return;
334 } 334 }
335 if(supportPushDown){ 335 if(supportPushDown){
336 --w, --h; 336 --w, --h;
337 } 337 }
338 /* We don't make the round buttons smaller, since they don't look as good 338 /* We don't make the round buttons smaller, since they don't look as good
339 if(autoDefault){ 339 if(autoDefault){
340 w = w-buttonDefaultIndicatorWidth()*2; 340 w = w-buttonDefaultIndicatorWidth()*2;
341 h = h-buttonDefaultIndicatorWidth()*2; 341 h = h-buttonDefaultIndicatorWidth()*2;
342 }*/ 342 }*/
343 343
344 344
345 QPixmap *pix = btnDict.find(c.rgb()); 345 QPixmap *pix = btnDict.find(c.rgb());
346 if(!pix){ 346 if(!pix){
347 int h, s, v; 347 int h, s, v;
348 c.hsv(&h, &s, &v); 348 c.hsv(&h, &s, &v);
349 pix = new QPixmap(*btnBorderPix); 349 pix = new QPixmap(*btnBorderPix);
350 adjustHSV(*pix, h, s, v); 350 adjustHSV(*pix, h, s, v);
351 btnDict.insert(c.rgb(), pix); 351 btnDict.insert(c.rgb(), pix);
352 } 352 }
353 int x2 = x+w-1; 353 int x2 = x+w-1;
354 int y2 = y+h-1; 354 int y2 = y+h-1;
355 int bx2 = pix->width()-1; 355 int bx2 = pix->width()-1;
356 int by2 = pix->height()-1; 356 int by2 = pix->height()-1;
357 357
358 QPixmap tmpPix(w, h); 358 QPixmap tmpPix(w, h);
359 QPixmap tilePix; 359 QPixmap tilePix;
360 QPainter p; 360 QPainter p;
361 p.begin(&tmpPix); 361 p.begin(&tmpPix);
362 362
363 // do the fill 363 // do the fill
364 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 364 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
365 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 365 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
366 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 366 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
367 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 367 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
368 368
369 // edges 369 // edges
370 tilePix.resize(pix->width()-20, 10); 370 tilePix.resize(pix->width()-20, 10);
371 // top 371 // top
372 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 372 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
373 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 373 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
374 // bottom 374 // bottom
375 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 375 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
376 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 376 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
377 // left 377 // left
378 tilePix.resize(10, pix->height()-20); 378 tilePix.resize(10, pix->height()-20);
379 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 379 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
380 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 380 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
381 // right 381 // right
382 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 382 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
383 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 383 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
384 384
385 // middle 385 // middle
386 tilePix.resize(pix->width()-20, pix->height()-20); 386 tilePix.resize(pix->width()-20, pix->height()-20);
387 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); 387 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20);
388 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); 388 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
389 389
390 390
391 // do the blend 391 // do the blend
392 QBitmap blendMask; 392 QBitmap blendMask;
393 if(!isMasked){ 393 if(!isMasked){
394 //QRgb bgRgb = back.rgb(); 394 //QRgb bgRgb = back.rgb();
395 //QRgb fgRgb = c.rgb(); 395 //QRgb fgRgb = c.rgb();
396 //int r, g, b; 396 //int r, g, b;
397 397
398 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); 398 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
399 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); 399 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
400 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); 400 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
401 //QColor blendColor(r, g, b); 401 //QColor blendColor(r, g, b);
402 int hue, sat, v1, v2; 402 int hue, sat, v1, v2;
403 QColor blendColor(autoDefault ? c : back); 403 QColor blendColor(autoDefault ? c : back);
404 back.hsv(&hue, &sat, &v1); 404 back.hsv(&hue, &sat, &v1);
405 blendColor.hsv(&hue, &sat, &v2); 405 blendColor.hsv(&hue, &sat, &v2);
406 if(v2 > v1) 406 if(v2 > v1)
407 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); 407 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
408 408
409 pix = btnBorderDict.find(blendColor.rgb()); 409 pix = btnBorderDict.find(blendColor.rgb());
410 if(!pix){ 410 if(!pix){
411 int h, s, v; 411 int h, s, v;
412 blendColor.hsv(&h, &s, &v); 412 blendColor.hsv(&h, &s, &v);
413 pix = new QPixmap(*btnBlendPix); 413 pix = new QPixmap(*btnBlendPix);
414 adjustHSV(*pix, h, s, v); 414 adjustHSV(*pix, h, s, v);
415 btnBorderDict.insert(blendColor.rgb(), pix); 415 btnBorderDict.insert(blendColor.rgb(), pix);
416 } 416 }
417 } 417 }
418 else{ 418 else{
419 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : 419 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) :
420 getPixmap(HTMLBtnBorder); 420 getPixmap(HTMLBtnBorder);
421 } 421 }
422 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 422 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
423 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 423 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
424 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 424 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
425 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 425 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
426 426
427 // edges 427 // edges
428 tilePix.resize(pix->width()-20, 10); 428 tilePix.resize(pix->width()-20, 10);
429 blendMask.resize(pix->width()-20, 10); 429 blendMask.resize(pix->width()-20, 10);
430 // top 430 // top
431 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 431 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
432 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); 432 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10);
433 tilePix.setMask(blendMask); 433 tilePix.setMask(blendMask);
434 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 434 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
435 // bottom 435 // bottom
436 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 436 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
437 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); 437 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20);
438 tilePix.setMask(blendMask); 438 tilePix.setMask(blendMask);
439 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 439 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
440 // left 440 // left
441 tilePix.resize(10, pix->height()-20); 441 tilePix.resize(10, pix->height()-20);
442 blendMask.resize(10, pix->height()-20); 442 blendMask.resize(10, pix->height()-20);
443 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 443 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
444 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); 444 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20);
445 tilePix.setMask(blendMask); 445 tilePix.setMask(blendMask);
446 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 446 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
447 // right 447 // right
448 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 448 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
449 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); 449 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20);
450 tilePix.setMask(blendMask); 450 tilePix.setMask(blendMask);
451 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 451 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
452 452
453 p.end(); 453 p.end();
454 454
455 // do the button mask - we don't automask buttons 455 // do the button mask - we don't automask buttons
456 QBitmap btnMask(w, h); 456 QBitmap btnMask(w, h);
457 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 457 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
458 p.begin(&btnMask); 458 p.begin(&btnMask);
459 p.fillRect(0, 0, w, h, Qt::color0); 459 p.fillRect(0, 0, w, h, Qt::color0);
460 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 460 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
461 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 461 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
462 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 462 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
463 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 463 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
464 // fills 464 // fills
465 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 465 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
466 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 466 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
467 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 467 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
468 p.end(); 468 p.end();
469 tmpPix.setMask(btnMask); 469 tmpPix.setMask(btnMask);
470 /*if(autoDefault){ 470 /*if(autoDefault){
471 if(supportPushDown && pushedDown){ 471 if(supportPushDown && pushedDown){
472 painter->drawPixmap(x+3, y+3, tmpPix); 472 painter->drawPixmap(x+3, y+3, tmpPix);
473 } 473 }
474 else{ 474 else{
475 painter->drawPixmap(x+2, y+2, tmpPix); 475 painter->drawPixmap(x+2, y+2, tmpPix);
476 } 476 }
477 } 477 }
478 else */if(supportPushDown && pushedDown) 478 else */if(supportPushDown && pushedDown)
479 painter->drawPixmap(x+1, y+1, tmpPix); 479 painter->drawPixmap(x+1, y+1, tmpPix);
480 else 480 else
481 painter->drawPixmap(x, y, tmpPix); 481 painter->drawPixmap(x, y, tmpPix);
482 482
483 483
484 484
485} 485}
486 486
487 487
488QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, 488QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
489 bool blend) 489 bool blend)
490{ 490{
491 QImage img(qembed_findImage(label)); 491 QImage img(qembed_findImage(label));
492 img.detach(); 492 img.detach();
493 if(img.isNull()){ // shouldn't happen, been tested 493 if(img.isNull()){ // shouldn't happen, been tested
494 qWarning("Invalid embedded label %s", label); 494 qWarning("Invalid embedded label %s", label);
495 return(NULL); 495 return(NULL);
496 } 496 }
497 if(img.depth() != 32) 497 if(img.depth() != 32)
498 img = img.convertDepth(32); 498 img = img.convertDepth(32);
499 unsigned int *data = (unsigned int *)img.bits(); 499 unsigned int *data = (unsigned int *)img.bits();
500 int total = img.width()*img.height(); 500 int total = img.width()*img.height();
501 int current; 501 int current;
502 QColor c; 502 QColor c;
503 int oldH, oldS, oldV; 503 int oldH, oldS, oldV;
504 int alpha; 504 int alpha;
505 if(v < 235) 505 if(v < 235)
506 v += 20; 506 v += 20;
507 else 507 else
508 v = 255; 508 v = 255;
509 float intensity = v/255.0; 509 float intensity = v/255.0;
510 510
511 for(current=0; current<total; ++current){ 511 for(current=0; current<total; ++current){
512 alpha = qAlpha(data[current]); 512 alpha = qAlpha(data[current]);
513 c.setRgb(data[current]); 513 c.setRgb(data[current]);
514 c.hsv(&oldH, &oldS, &oldV); 514 c.hsv(&oldH, &oldS, &oldV);
515 oldV = (int)(oldV*intensity); 515 oldV = (int)(oldV*intensity);
516 c.setHsv(h, s, oldV); 516 c.setHsv(h, s, oldV);
517 if(blend && alpha != 255 && alpha != 0){ 517 if(blend && alpha != 255 && alpha != 0){
518 float srcPercent = ((float)alpha)/255.0; 518 float srcPercent = ((float)alpha)/255.0;
519 float destPercent = 1.0-srcPercent; 519 float destPercent = 1.0-srcPercent;
520 oldH = (int)((srcPercent*h) + (destPercent*bH)); 520 oldH = (int)((srcPercent*h) + (destPercent*bH));
521 oldS = (int)((srcPercent*s) + (destPercent*bS)); 521 oldS = (int)((srcPercent*s) + (destPercent*bS));
522 oldV = (int)((srcPercent*oldV) + (destPercent*bV)); 522 oldV = (int)((srcPercent*oldV) + (destPercent*bV));
523 c.setHsv(oldH, oldS, oldV); 523 c.setHsv(oldH, oldS, oldV);
524 alpha = 255; 524 alpha = 255;
525 } 525 }
526 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); 526 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
527 } 527 }
528 QPixmap *pix = new QPixmap; 528 QPixmap *pix = new QPixmap;
529 pix->convertFromImage(img); 529 pix->convertFromImage(img);
530 return(pix); 530 return(pix);
531} 531}
532 532
533 533
534 534
535 535
536QPixmap* LiquidStyle::getPixmap(BitmapData item) 536QPixmap* LiquidStyle::getPixmap(BitmapData item)
537{ 537{
538 538
539 if(pixmaps[item]) 539 if(pixmaps[item])
540 return(pixmaps[item]); 540 return(pixmaps[item]);
541 541
542 switch(item){ 542 switch(item){
543 case HTMLBtnBorder: 543 case HTMLBtnBorder:
544 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); 544 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
545 break; 545 break;
546 case HTMLBtnBorderDown: 546 case HTMLBtnBorderDown:
547 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); 547 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
548 break; 548 break;
549 case HTMLCB: 549 case HTMLCB:
550 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); 550 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
551 break; 551 break;
552 case HTMLCBDown: 552 case HTMLCBDown:
553 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); 553 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
554 break; 554 break;
555 case HTMLCBHover: 555 case HTMLCBHover:
556 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); 556 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV);
557 break; 557 break;
558 case HTMLCBDownHover: 558 case HTMLCBDownHover:
559 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", 559 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown",
560 btnHoverH, btnHoverS, 560 btnHoverH, btnHoverS,
561 btnHoverV); 561 btnHoverV);
562 break; 562 break;
563 case HTMLRadio: 563 case HTMLRadio:
564 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 564 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
565 case HTMLRadioDown: 565 case HTMLRadioDown:
566 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 566 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
567 case HTMLRadioHover: 567 case HTMLRadioHover:
568 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); 568 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV);
569 case HTMLRadioDownHover: 569 case HTMLRadioDownHover:
570 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", 570 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown",
571 btnHoverH, btnHoverS, 571 btnHoverH, btnHoverS,
572 btnHoverV); 572 btnHoverV);
573 case RadioOn: 573 case RadioOn:
574 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); 574 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true);
575 break; 575 break;
576 case RadioOnHover: 576 case RadioOnHover:
577 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, 577 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS,
578 btnHoverV, true); 578 btnHoverV, true);
579 break; 579 break;
580 case RadioOffHover: 580 case RadioOffHover:
581 pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); 581 pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true);
582 break; 582 break;
583 case TabDown: 583 case TabDown:
584 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); 584 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true);
585 break; 585 break;
586 case TabFocus: 586 case TabFocus:
587 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, 587 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS,
588 btnHoverS, true); 588 btnHoverS, true);
589 break; 589 break;
590 case CBDown: 590 case CBDown:
591 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); 591 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true);
592 break; 592 break;
593 case CBDownHover: 593 case CBDownHover:
594 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, 594 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH,
595 btnHoverS, btnHoverV, true); 595 btnHoverS, btnHoverV, true);
596 break; 596 break;
597 case CBHover: 597 case CBHover:
598 pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); 598 pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true);
599 break; 599 break;
600 case HSlider: 600 case HSlider:
601 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); 601 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true);
602 break; 602 break;
603 case VSlider: 603 case VSlider:
604 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); 604 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true);
605 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 605 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
606 break; 606 break;
607 case RadioOff: 607 case RadioOff:
608 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); 608 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true);
609 break; 609 break;
610 case Tab: 610 case Tab:
611 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); 611 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true);
612 break; 612 break;
613 case CB: 613 case CB:
614 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); 614 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true);
615 break; 615 break;
616 case VSBSliderTop: 616 case VSBSliderTop:
617 pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 617 pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true);
618 break; 618 break;
619 case VSBSliderBtm: 619 case VSBSliderBtm:
620 pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); 620 pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true);
621 break; 621 break;
622 case VSBSliderMid: 622 case VSBSliderMid:
623 pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 623 pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
624 break; 624 break;
625 case VSBSliderTopHover: 625 case VSBSliderTopHover:
626 pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 626 pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true);
627 break; 627 break;
628 case VSBSliderBtmHover: 628 case VSBSliderBtmHover:
629 pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 629 pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true);
630 break; 630 break;
631 case VSBSliderMidHover: 631 case VSBSliderMidHover:
632 pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 632 pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV);
633 break; 633 break;
634 634
635 case HSBSliderTop: 635 case HSBSliderTop:
636 pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 636 pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true);
637 *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); 637 *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix);
638 break; 638 break;
639 case HSBSliderBtm: 639 case HSBSliderBtm:
640 pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); 640 pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true);
641 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); 641 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix);
642 break; 642 break;
643 case HSBSliderMid: 643 case HSBSliderMid:
644 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 644 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
645 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); 645 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix);
646 break; 646 break;
647 case HSBSliderTopHover: 647 case HSBSliderTopHover:
648 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 648 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true);
649 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); 649 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix);
650 break; 650 break;
651 case HSBSliderBtmHover: 651 case HSBSliderBtmHover:
652 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 652 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true);
653 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); 653 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix);
654 break; 654 break;
655 case HSBSliderMidHover: 655 case HSBSliderMidHover:
656 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 656 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV);
657 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); 657 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix);
658 break; 658 break;
659 case VSBSliderTopBg: 659 case VSBSliderTopBg:
660 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 660 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
661 break; 661 break;
662 case VSBSliderBtmBg: 662 case VSBSliderBtmBg:
663 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 663 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
664 break; 664 break;
665 case VSBSliderMidBg: 665 case VSBSliderMidBg:
666 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 666 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
667 break; 667 break;
668 case HSBSliderTopBg: 668 case HSBSliderTopBg:
669 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 669 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
670 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 670 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
671 break; 671 break;
672 case HSBSliderBtmBg: 672 case HSBSliderBtmBg:
673 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 673 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
674 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 674 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
675 break; 675 break;
676 case HSBSliderMidBg: 676 case HSBSliderMidBg:
677 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 677 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
678 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 678 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
679 break; 679 break;
680 default: 680 default:
681 break; 681 break;
682 } 682 }
683 return(pixmaps[item]); 683 return(pixmaps[item]);
684} 684}
685 685
686void LiquidStyle::polish(QPalette &appPal) 686void LiquidStyle::polish(QPalette &appPal)
687{ 687{
688 int i; 688 int i;
689 for(i=0; i < BITMAP_ITEMS; ++i){ 689 for(i=0; i < BITMAP_ITEMS; ++i){
690 if(pixmaps[i]){ 690 if(pixmaps[i]){
691 delete pixmaps[i]; 691 delete pixmaps[i];
692 pixmaps[i] = NULL; 692 pixmaps[i] = NULL;
693 } 693 }
694 } 694 }
695 QWidgetList *list = QApplication::allWidgets(); 695 QWidgetList *list = QApplication::allWidgets();
696 QWidgetListIt it( *list ); 696 QWidgetListIt it( *list );
697 QWidget *w; 697 QWidget *w;
698 while ((w=it.current()) != 0 ){ 698 while ((w=it.current()) != 0 ){
699 ++it; 699 ++it;
700 if(w->inherits("QPushButton")){ 700 if(w->inherits("QPushButton")){
701 unapplyCustomAttributes((QPushButton *)w); 701 unapplyCustomAttributes((QPushButton *)w);
702 } 702 }
703 } 703 }
704 704
705 loadCustomButtons(); 705 loadCustomButtons();
706 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 706 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
707 btnDict.clear(); 707 btnDict.clear();
708 btnBorderDict.clear(); 708 btnBorderDict.clear();
709 bevelFillDict.clear(); 709 bevelFillDict.clear();
710 smallBevelFillDict.clear(); 710 smallBevelFillDict.clear();
711 711
712 Config config ( "qpe" ); 712 Config config ( "qpe" );
713 config. setGroup ( "Liquid-Style" ); 713 config. setGroup ( "Liquid-Style" );
714 int contrast = config. readNumEntry ( "StippleContrast", 5 ); 714 int contrast = config. readNumEntry ( "StippleContrast", 5 );
715 if ( contrast < 0 ) 715 if ( contrast < 0 )
716 contrast = 0; 716 contrast = 0;
717 else if ( contrast > 10 ) 717 else if ( contrast > 10 )
718 contrast = 10; 718 contrast = 10;
719 719
720// QPalette pal = QApplication::palette(); 720// QPalette pal = QApplication::palette();
721 721
722 // button color stuff 722 // button color stuff
723 config. setGroup ( "Appearance" ); 723 config. setGroup ( "Appearance" );
724 QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); 724 QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( )));
725 appPal. color ( QPalette::Active, QColorGroup::Button ); 725 appPal. color ( QPalette::Active, QColorGroup::Button );
726 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) 726 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )
727 //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) 727 //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))
728 ) { 728 ) {
729 // force button color to be different from background 729 // force button color to be different from background
730 QBrush btnBrush(QColor(200, 202, 228)); 730 QBrush btnBrush(QColor(200, 202, 228));
731 appPal.setBrush(QColorGroup::Button, btnBrush); 731 appPal.setBrush(QColorGroup::Button, btnBrush);
732 } 732 }
733 c.hsv(&btnH, &btnS, &btnV); 733 c.hsv(&btnH, &btnS, &btnV);
734 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 734 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
735 735
736 // menu pixmap 736 // menu pixmap
737 if(!menuPix){ 737 if(!menuPix){
738 menuPix = new QPixmap; 738 menuPix = new QPixmap;
739 menuPix->resize(64, 64); 739 menuPix->resize(64, 64);
740 } 740 }
741 QPainter painter; 741 QPainter painter;
742 menuPix->fill(c.rgb()); 742 menuPix->fill(c.rgb());
743 painter.begin(menuPix); 743 painter.begin(menuPix);
744 painter.setPen(c.dark(105)); 744 painter.setPen(c.dark(105));
745 for(i=0; i < 63; i+=4){ 745 for(i=0; i < 63; i+=4){
746 painter.drawLine(0, i, 63, i); 746 painter.drawLine(0, i, 63, i);
747 painter.drawLine(0, i+1, 63, i+1); 747 painter.drawLine(0, i+1, 63, i+1);
748 }; 748 };
749 painter.end(); 749 painter.end();
750 menuBrush.setColor(c); 750 menuBrush.setColor(c);
751 menuBrush.setPixmap(*menuPix); 751 menuBrush.setPixmap(*menuPix);
752 752
753 // pager brush 753 // pager brush
754 c = c.dark(120); 754 c = c.dark(120);
755 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 755 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
756 if(!pix){ 756 if(!pix){
757 int h, s, v; 757 int h, s, v;
758 c.hsv(&h, &s, &v); 758 c.hsv(&h, &s, &v);
759 pix = new QPixmap(*smallBevelFillPix); 759 pix = new QPixmap(*smallBevelFillPix);
760 adjustHSV(*pix, h, s, v); 760 adjustHSV(*pix, h, s, v);
761 smallBevelFillDict.insert(c.rgb(), pix); 761 smallBevelFillDict.insert(c.rgb(), pix);
762 } 762 }
763 pagerHoverBrush.setColor(c); 763 pagerHoverBrush.setColor(c);
764 pagerHoverBrush.setPixmap(*pix); 764 pagerHoverBrush.setPixmap(*pix);
765 765
766 c = c.dark(120); 766 c = c.dark(120);
767 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 767 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
768 if(!pix){ 768 if(!pix){
769 int h, s, v; 769 int h, s, v;
770 c.hsv(&h, &s, &v); 770 c.hsv(&h, &s, &v);
771 pix = new QPixmap(*smallBevelFillPix); 771 pix = new QPixmap(*smallBevelFillPix);
772 adjustHSV(*pix, h, s, v); 772 adjustHSV(*pix, h, s, v);
773 smallBevelFillDict.insert(c.rgb(), pix); 773 smallBevelFillDict.insert(c.rgb(), pix);
774 } 774 }
775 pagerBrush.setColor(c); 775 pagerBrush.setColor(c);
776 pagerBrush.setPixmap(*pix); 776 pagerBrush.setPixmap(*pix);
777 777
778 // background color stuff 778 // background color stuff
779 c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); 779 c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background );
780 c.hsv(&bH, &bS, &bV); 780 c.hsv(&bH, &bS, &bV);
781 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 781 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
782 782
783 // FIXME? 783 // FIXME?
784 if(vsbSliderFillPix) 784 if(vsbSliderFillPix)
785 delete vsbSliderFillPix; 785 delete vsbSliderFillPix;
786 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 786 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
787 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 787 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
788 788
789 // background brush 789 // background brush
790 QPixmap wallPaper(32, 32); 790 QPixmap wallPaper(32, 32);
791 wallPaper.fill(c.rgb()); 791 wallPaper.fill(c.rgb());
792 painter.begin(&wallPaper); 792 painter.begin(&wallPaper);
793 for(i=0; i < 32; i+=4){ 793 for(i=0; i < 32; i+=4){
794 painter.setPen(c.dark(100 + contrast)); 794 painter.setPen(c.dark(100 + contrast));
795 painter.drawLine(0, i, 32, i); 795 painter.drawLine(0, i, 32, i);
796 painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); 796 painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
797 painter.drawLine(0, i+1, 32, i+1); 797 painter.drawLine(0, i+1, 32, i+1);
798 }; 798 };
799 painter.end(); 799 painter.end();
800 bgBrush.setColor(c); 800 bgBrush.setColor(c);
801 bgBrush.setPixmap(wallPaper); 801 bgBrush.setPixmap(wallPaper);
802 appPal.setBrush(QColorGroup::Background, bgBrush); 802 appPal.setBrush(QColorGroup::Background, bgBrush);
803 803
804 // lineedits 804 // lineedits
805 c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); 805 c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base );
806 QPixmap basePix; 806 QPixmap basePix;
807 basePix.resize(32, 32); 807 basePix.resize(32, 32);
808 basePix.fill(c.rgb()); 808 basePix.fill(c.rgb());
809 painter.begin(&basePix); 809 painter.begin(&basePix);
810 painter.setPen(c.dark(105)); 810 painter.setPen(c.dark(105));
811 for(i=0; i < 32; i+=4){ 811 for(i=0; i < 32; i+=4){
812 painter.drawLine(0, i, 32, i); 812 painter.drawLine(0, i, 32, i);
813 painter.drawLine(0, i+1, 32, i+1); 813 painter.drawLine(0, i+1, 32, i+1);
814 }; 814 };
815 painter.end(); 815 painter.end();
816 baseBrush.setColor(c); 816 baseBrush.setColor(c);
817 baseBrush.setPixmap(basePix); 817 baseBrush.setPixmap(basePix);
818 it.toFirst(); 818 it.toFirst();
819 while ((w=it.current()) != 0 ){ 819 while ((w=it.current()) != 0 ){
820 ++it; 820 ++it;
821 if(w->inherits("QLineEdit")){ 821 if(w->inherits("QLineEdit")){
822 QPalette pal = w->palette(); 822 QPalette pal = w->palette();
823 pal.setBrush(QColorGroup::Base, baseBrush); 823 pal.setBrush(QColorGroup::Base, baseBrush);
824 w->setPalette(pal); 824 w->setPalette(pal);
825 } 825 }
826 else if(w->inherits("QPushButton")){ 826 else if(w->inherits("QPushButton")){
827 applyCustomAttributes((QPushButton *)w); 827 applyCustomAttributes((QPushButton *)w);
828 } 828 }
829 } 829 }
830} 830}
831 831
832void LiquidStyle::polish(QWidget *w) 832void LiquidStyle::polish(QWidget *w)
833{ 833{
834 if(w->inherits("QMenuBar")){ 834 if(w->inherits("QMenuBar")){
835 //((QFrame*)w)->setLineWidth(0); 835 //((QFrame*)w)->setLineWidth(0);
836 w->setBackgroundMode(QWidget::PaletteBackground); 836 w->setBackgroundMode(QWidget::PaletteBackground);
837 w->setBackgroundOrigin(QWidget::ParentOrigin); 837 w->setBackgroundOrigin(QWidget::ParentOrigin);
838 return; 838 return;
839 } 839 }
840 if(w->inherits("QToolBar")){ 840 if(w->inherits("QToolBar")){
841 w->installEventFilter(this); 841 w->installEventFilter(this);
842 w->setBackgroundMode(QWidget::PaletteBackground); 842 w->setBackgroundMode(QWidget::PaletteBackground);
843 w->setBackgroundOrigin(QWidget::WidgetOrigin); 843 w->setBackgroundOrigin(QWidget::WidgetOrigin);
844 return; 844 return;
845 } 845 }
846 if(w->inherits("QPopupMenu")) 846 if(w->inherits("QPopupMenu"))
847 w->setBackgroundMode(QWidget::NoBackground); 847 w->setBackgroundMode(QWidget::NoBackground);
848 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { 848 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
849 w->installEventFilter(menuHandler); 849 w->installEventFilter(menuHandler);
850 } 850 }
851 851
852 if(w->isTopLevel()){ 852 if(w->isTopLevel()){
853 return; 853 return;
854 } 854 }
855 855
856 856
857 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 857
858 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
859 858
860 if(w->inherits("QComboBox") || 859 if(w->inherits("QComboBox") ||
861 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 860 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
862 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 861 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
863 w->installEventFilter(this); 862 w->installEventFilter(this);
864 } 863 }
865 if(w->inherits("QLineEdit")){ 864 if(w->inherits("QLineEdit")){
866 QPalette pal = w->palette(); 865 QPalette pal = w->palette();
867 pal.setBrush(QColorGroup::Base, baseBrush); 866 pal.setBrush(QColorGroup::Base, baseBrush);
868 w->setPalette(pal); 867 w->setPalette(pal);
869 } 868 }
870 if(w->inherits("QPushButton")){ 869 if(w->inherits("QPushButton")){
871 applyCustomAttributes((QPushButton *)w); 870 applyCustomAttributes((QPushButton *)w);
872 w->installEventFilter(this); 871 w->installEventFilter(this);
873 } 872 }
874 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 873 if(w->inherits("QButton") || w-> inherits("QComboBox")){
875 w-> setBackgroundMode ( QWidget::PaletteBackground ); 874 w-> setBackgroundMode ( QWidget::PaletteBackground );
875 w->setBackgroundOrigin ( QWidget::ParentOrigin);
876 } 876 }
877 877
878 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 878 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
879 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 879 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
880 bool isViewportChild = w->parent() && 880 bool isViewportChild = w->parent() &&
881 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 881 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
882 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 882 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
883 883
884 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 884 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
885 w->setBackgroundMode(QWidget::X11ParentRelative); 885 w->setBackgroundMode(QWidget::X11ParentRelative);
886 return; 886 return;
887 } 887 }
888 if(isViewportChild){ 888 if(isViewportChild){
889 if(w->inherits("QButton") || w->inherits("QComboBox")){ 889 if(w->inherits("QButton") || w->inherits("QComboBox")){
890 if(w->parent()){ // heh, only way to test for KHTML children ;-) 890 if(w->parent()){ // heh, only way to test for KHTML children ;-)
891 if(w->parent()->parent()){ 891 if(w->parent()->parent()){
892 if(w->parent()->parent()->parent() && 892 if(w->parent()->parent()->parent() &&
893 w->parent()->parent()->parent()->inherits("KHTMLView")){ 893 w->parent()->parent()->parent()->inherits("KHTMLView")){
894 w->setAutoMask(true); 894 w->setAutoMask(true);
895 w->setBackgroundMode(QWidget::NoBackground); 895 w->setBackgroundMode(QWidget::NoBackground);
896 } 896 }
897 } 897 }
898 } 898 }
899 return; 899 return;
900 } 900 }
901 } 901 }
902 if(w->inherits("QHeader")){ 902 if(w->inherits("QHeader")){
903 w->setMouseTracking(true); 903 w->setMouseTracking(true);
904 w->installEventFilter(this); 904 w->installEventFilter(this);
905 } 905 }
906 if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { 906 if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) {
907 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 907 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
908 if ( flatTBButtons ) 908 if ( flatTBButtons )
909 w->setBackgroundOrigin(QWidget::ParentOrigin); 909 w->setBackgroundOrigin(QWidget::ParentOrigin);
910 } 910 }
911 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
912 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
913 }
911 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 914 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
912 return; 915 return;
913 } 916 }
914 917
915 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 918 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
916 palette().active().brush(QColorGroup::Background).pixmap()){ 919 palette().active().brush(QColorGroup::Background).pixmap()){
917 qWarning("No parent pixmap for child widget %s", w->className()); 920 qWarning("No parent pixmap for child widget %s", w->className());
918 return; 921 return;
919 } 922 }
920 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 923 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
921 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 924 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
922 if(w->backgroundMode() == QWidget::PaletteBackground || 925 if(w->backgroundMode() == QWidget::PaletteBackground ||
923 w->backgroundMode() == QWidget::PaletteButton){ 926 w->backgroundMode() == QWidget::PaletteButton){
924 w->setBackgroundMode(QWidget::X11ParentRelative); 927 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
928 w->setBackgroundOrigin(QWidget::ParentOrigin);
929 // w->setBackgroundMode(QWidget::NoBackground);
925 } 930 }
926 } 931 }
932 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
933 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
934 else if ( w-> inherits("QFrame") )
935 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
927 936
937 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
938 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
939 }
928} 940}
929 941
930void LiquidStyle::unPolish(QWidget *w) 942void LiquidStyle::unPolish(QWidget *w)
931{ 943{
932 if(w->inherits("QMenuBar")){ 944 if(w->inherits("QMenuBar")){
933 ((QFrame *)w)->setLineWidth(1); 945 ((QFrame *)w)->setLineWidth(1);
934 w->setBackgroundMode(QWidget::PaletteBackground); 946 w->setBackgroundMode(QWidget::PaletteBackground);
935 return; 947 return;
936 } 948 }
937 949
938 if(w->inherits("QPopupMenu")) 950 if(w->inherits("QPopupMenu"))
939 w->setBackgroundMode(QWidget::PaletteButton); 951 w->setBackgroundMode(QWidget::PaletteButton);
940 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { 952 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
941 w->removeEventFilter(menuHandler); 953 w->removeEventFilter(menuHandler);
942 } 954 }
943 955
944 if(w->isTopLevel()) 956 if(w->isTopLevel())
945 return; 957 return;
946 958
947 // for viewport children, don't just check for NoBackground.... 959 // for viewport children, don't just check for NoBackground....
948 bool isViewportChild = w->parent() && 960 bool isViewportChild = w->parent() &&
949 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 961 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
950 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 962 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
951 963
952 w->unsetPalette(); 964 w->unsetPalette();
953 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 965 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
954 if(w->inherits("QPushButton")) 966 if(w->inherits("QPushButton"))
955 w->setBackgroundMode(QWidget::PaletteButton); 967 w->setBackgroundMode(QWidget::PaletteButton);
956 else 968 else
957 w->setBackgroundMode(QWidget::PaletteBackground); 969 w->setBackgroundMode(QWidget::PaletteBackground);
958 } 970 }
959 971
960 if(isViewportChild) 972 if(isViewportChild)
961 w->setAutoMask(false); 973 w->setAutoMask(false);
962 974
963 if(w->inherits("QPushButton")){ 975 if(w->inherits("QPushButton")){
964 unapplyCustomAttributes((QPushButton *)w); 976 unapplyCustomAttributes((QPushButton *)w);
965 w->removeEventFilter(this); 977 w->removeEventFilter(this);
966 } 978 }
967/* 979/*
968 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 980 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
969 w-> setBackgroundMode ( PaletteBackground ); 981 w-> setBackgroundMode ( PaletteBackground );
970 } 982 }
971*/ 983*/
972 if(w->inherits("QComboBox") || 984 if(w->inherits("QComboBox") ||
973 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 985 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
974 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 986 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
975 w->removeEventFilter(this); 987 w->removeEventFilter(this);
976 } 988 }
977 if(w->inherits("QButton") || w->inherits("QComboBox")){ 989 if(w->inherits("QButton") || w->inherits("QComboBox")){
978 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 990 if(w->parent() && w->parent()->inherits("KHTMLPart")){
979 w->setAutoMask(false); 991 w->setAutoMask(false);
980 } 992 }
981 } 993 }
982 if(w->inherits("QToolBar")){ 994 if(w->inherits("QToolBar")){
983 w->removeEventFilter(this); 995 w->removeEventFilter(this);
984 w->setBackgroundMode(QWidget::PaletteBackground); 996 w->setBackgroundMode(QWidget::PaletteBackground);
985 return; 997 return;
986 } 998 }
987 if(w->inherits("QHeader")){ 999 if(w->inherits("QHeader")){
988 w->setMouseTracking(false); 1000 w->setMouseTracking(false);
989 w->removeEventFilter(this); 1001 w->removeEventFilter(this);
990 } 1002 }
991} 1003}
992 1004
993void LiquidStyle::polish(QApplication *app) 1005void LiquidStyle::polish(QApplication *app)
994{ 1006{
995 1007
996 QWindowsStyle::polish(app); 1008 QWindowsStyle::polish(app);
997 menuAni = app->isEffectEnabled(UI_AnimateMenu); 1009 menuAni = app->isEffectEnabled(UI_AnimateMenu);
998 menuFade = app->isEffectEnabled(UI_FadeMenu); 1010 menuFade = app->isEffectEnabled(UI_FadeMenu);
999 if(menuAni) 1011 if(menuAni)
1000 app->setEffectEnabled(UI_AnimateMenu, false); 1012 app->setEffectEnabled(UI_AnimateMenu, false);
1001 if(menuFade) 1013 if(menuFade)
1002 app->setEffectEnabled(UI_FadeMenu, false); 1014 app->setEffectEnabled(UI_FadeMenu, false);
1003 1015
1004 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 1016 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
1005 1017
1006 Config config ( "qpe" ); 1018 Config config ( "qpe" );
1007 config. setGroup ( "Liquid-Style" ); 1019 config. setGroup ( "Liquid-Style" );
1008 1020
1009 // if ( config. readBoolEntry ( "WinDecoration", true )) 1021 // if ( config. readBoolEntry ( "WinDecoration", true ))
1010 // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); 1022 // QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
1011 1023
1012 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); 1024 flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
1013} 1025}
1014 1026
1015void LiquidStyle::unPolish(QApplication *app) 1027void LiquidStyle::unPolish(QApplication *app)
1016{ 1028{
1017 QWindowsStyle::unPolish(app); 1029 QWindowsStyle::unPolish(app);
1018 app->setEffectEnabled(UI_AnimateMenu, menuAni); 1030 app->setEffectEnabled(UI_AnimateMenu, menuAni);
1019 app->setEffectEnabled(UI_FadeMenu, menuFade); 1031 app->setEffectEnabled(UI_FadeMenu, menuFade);
1020 1032
1021 qt_set_draw_menu_bar_impl ( 0 ); 1033 qt_set_draw_menu_bar_impl ( 0 );
1022 1034
1023// QApplication::qwsSetDecoration ( new QPEDecoration ( )); 1035// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
1024} 1036}
1025 1037
1026/* 1038/*
1027 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1039 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1028 * force everything to erase and repaint on resize. This is going away, I'm 1040 * force everything to erase and repaint on resize. This is going away, I'm
1029 * trying to get shaped widgets to work right without masking. QPushButton, 1041 * trying to get shaped widgets to work right without masking. QPushButton,
1030 * QComboBox, and Panel applet handles capture mouse enter and leaves in order 1042 * QComboBox, and Panel applet handles capture mouse enter and leaves in order
1031 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and 1043 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
1032 * RadioButtons need to do this differently. Qt buffers these in pixmaps and 1044 * RadioButtons need to do this differently. Qt buffers these in pixmaps and
1033 * caches them in QPixmapCache, which is bad for doing things like hover 1045 * caches them in QPixmapCache, which is bad for doing things like hover
1034 * because the style methods aren't called in paintEvents if everything 1046 * because the style methods aren't called in paintEvents if everything
1035 * is cached. We use our own Paint event handler instead. Taskbuttons and 1047 * is cached. We use our own Paint event handler instead. Taskbuttons and
1036 * pager buttons draw into a pixmap buffer, so we handle those with palette 1048 * pager buttons draw into a pixmap buffer, so we handle those with palette
1037 * modifications. For QHeader, different header items are actually one widget 1049 * modifications. For QHeader, different header items are actually one widget
1038 * that draws multiple items, so we need to check which ID is hightlighted 1050 * that draws multiple items, so we need to check which ID is hightlighted
1039 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1051 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1040 * since if it's inside a combobox we want to highlight the combobox during 1052 * since if it's inside a combobox we want to highlight the combobox during
1041 * hovering in the edit. 1053 * hovering in the edit.
1042 */ 1054 */
1043bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1055bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1044{ 1056{
1045 if(obj->inherits("QToolBar")){ 1057 if(obj->inherits("QToolBar")){
1046 if(ev->type() == QEvent::Resize){ 1058 if(ev->type() == QEvent::Resize){
1047 const QObjectList *tbChildList = obj->children(); 1059 const QObjectList *tbChildList = obj->children();
1048 QObjectListIt it(*tbChildList); 1060 QObjectListIt it(*tbChildList);
1049 QObject *child; 1061 QObject *child;
1050 while((child = it.current()) != NULL){ 1062 while((child = it.current()) != NULL){
1051 ++it; 1063 ++it;
1052 if(child->isWidgetType()) 1064 if(child->isWidgetType())
1053 ((QWidget *)child)->repaint(true); 1065 ((QWidget *)child)->repaint(true);
1054 } 1066 }
1055 1067
1056 } 1068 }
1057 } 1069 }
1058 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ 1070 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){
1059 QWidget *btn = (QWidget *)obj; 1071 QWidget *btn = (QWidget *)obj;
1060 if(ev->type() == QEvent::Enter){ 1072 if(ev->type() == QEvent::Enter){
1061 if(btn->isEnabled()){ 1073 if(btn->isEnabled()){
1062 highlightWidget = btn; 1074 highlightWidget = btn;
1063 btn->repaint(false); 1075 btn->repaint(false);
1064 } 1076 }
1065 } 1077 }
1066 else if(ev->type() == QEvent::Leave){ 1078 else if(ev->type() == QEvent::Leave){
1067 if(btn == highlightWidget){ 1079 if(btn == highlightWidget){
1068 highlightWidget = NULL; 1080 highlightWidget = NULL;
1069 btn->repaint(false); 1081 btn->repaint(false);
1070 } 1082 }
1071 } 1083 }
1072 } 1084 }
1073 else if(obj->inherits("QToolButton")){ 1085 else if(obj->inherits("QToolButton")){
1074 QToolButton *btn = (QToolButton *)btn; 1086 QToolButton *btn = (QToolButton *)btn;
1075 if(!btn->autoRaise()){ 1087 if(!btn->autoRaise()){
1076 if(btn->isEnabled()){ 1088 if(btn->isEnabled()){
1077 highlightWidget = btn; 1089 highlightWidget = btn;
1078 btn->repaint(false); 1090 btn->repaint(false);
1079 } 1091 }
1080 } 1092 }
1081 else if(ev->type() == QEvent::Leave){ 1093 else if(ev->type() == QEvent::Leave){
1082 QWidget *btn = (QWidget *)obj; 1094 QWidget *btn = (QWidget *)obj;
1083 if(btn == highlightWidget){ 1095 if(btn == highlightWidget){
1084 highlightWidget = NULL; 1096 highlightWidget = NULL;
1085 btn->repaint(false); 1097 btn->repaint(false);
1086 } 1098 }
1087 } 1099 }
1088 else 1100 else
1089 highlightWidget = NULL; 1101 highlightWidget = NULL;
1090 } 1102 }
1091 else if(obj->inherits("QScrollBar")){ 1103 else if(obj->inherits("QScrollBar")){
1092 QScrollBar *sb = (QScrollBar *)obj; 1104 QScrollBar *sb = (QScrollBar *)obj;
1093 if(ev->type() == QEvent::Enter){ 1105 if(ev->type() == QEvent::Enter){
1094 if(sb->isEnabled()){ 1106 if(sb->isEnabled()){
1095 highlightWidget = sb; 1107 highlightWidget = sb;
1096 sb->repaint(false); 1108 sb->repaint(false);
1097 } 1109 }
1098 } 1110 }
1099 else if(ev->type() == QEvent::Leave){ 1111 else if(ev->type() == QEvent::Leave){
1100 if(sb == highlightWidget && !sb->draggingSlider()){ 1112 if(sb == highlightWidget && !sb->draggingSlider()){
1101 highlightWidget = NULL; 1113 highlightWidget = NULL;
1102 sb->repaint(false); 1114 sb->repaint(false);
1103 } 1115 }
1104 } 1116 }
1105 else if(ev->type() == QEvent::MouseButtonRelease){ 1117 else if(ev->type() == QEvent::MouseButtonRelease){
1106 QMouseEvent *me = (QMouseEvent *)ev; 1118 QMouseEvent *me = (QMouseEvent *)ev;
1107 if(sb == highlightWidget && !sb->rect().contains(me->pos())){ 1119 if(sb == highlightWidget && !sb->rect().contains(me->pos())){
1108 highlightWidget = NULL; 1120 highlightWidget = NULL;
1109 sb->repaint(false); 1121 sb->repaint(false);
1110 } 1122 }
1111 } 1123 }
1112 } 1124 }
1113 else if(obj->inherits("QLineEdit")){ 1125 else if(obj->inherits("QLineEdit")){
1114 if(obj->parent() && obj->parent()->inherits("QComboBox")){ 1126 if(obj->parent() && obj->parent()->inherits("QComboBox")){
1115 QWidget *btn = (QComboBox *)obj->parent(); 1127 QWidget *btn = (QComboBox *)obj->parent();
1116 if(ev->type() == QEvent::Enter){ 1128 if(ev->type() == QEvent::Enter){
1117 if (btn->isEnabled()){ 1129 if (btn->isEnabled()){
1118 highlightWidget = btn; 1130 highlightWidget = btn;
1119 btn->repaint(false); 1131 btn->repaint(false);
1120 } 1132 }
1121 } 1133 }
1122 else if(ev->type() == QEvent::Leave){ 1134 else if(ev->type() == QEvent::Leave){
1123 if (btn == highlightWidget) 1135 if (btn == highlightWidget)
1124 highlightWidget = NULL; 1136 highlightWidget = NULL;
1125 btn->repaint(false); 1137 btn->repaint(false);
1126 } 1138 }
1127 } 1139 }
1128 } 1140 }
1129 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ 1141 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
1130 QButton *btn = (QButton *)obj; 1142 QButton *btn = (QButton *)obj;
1131 bool isRadio = obj->inherits("QRadioButton"); 1143 bool isRadio = obj->inherits("QRadioButton");
1132 if(ev->type() == QEvent::Paint){ 1144 if(ev->type() == QEvent::Paint){
1133 //if(btn->autoMask()) 1145 //if(btn->autoMask())
1134 btn->erase(); 1146 btn->erase();
1135 QPainter p; 1147 QPainter p;
1136 p.begin(btn); 1148 p.begin(btn);
1137 QFontMetrics fm = btn->fontMetrics(); 1149 QFontMetrics fm = btn->fontMetrics();
1138 QSize lsz = fm.size(ShowPrefix, btn->text()); 1150 QSize lsz = fm.size(ShowPrefix, btn->text());
1139 QSize sz = isRadio ? exclusiveIndicatorSize() 1151 QSize sz = isRadio ? exclusiveIndicatorSize()
1140 : indicatorSize(); 1152 : indicatorSize();
1141 1153
1142 if(btn->hasFocus()){ 1154 if(btn->hasFocus()){
1143 QRect r = QRect(0, 0, btn->width(), btn->height()); 1155 QRect r = QRect(0, 0, btn->width(), btn->height());
1144 p.setPen(btn->colorGroup().button().dark(140)); 1156 p.setPen(btn->colorGroup().button().dark(140));
1145 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1157 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1146 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1158 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1147 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1159 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1148 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1160 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1149 } 1161 }
1150 int x = 0; 1162 int x = 0;
1151 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1163 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1152 if(isRadio) 1164 if(isRadio)
1153 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1165 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1154 btn->colorGroup(), btn->isOn(), 1166 btn->colorGroup(), btn->isOn(),
1155 btn->isDown(), btn->isEnabled()); 1167 btn->isDown(), btn->isEnabled());
1156 else 1168 else
1157 drawIndicator(&p, x, y, sz.width(), sz.height(), 1169 drawIndicator(&p, x, y, sz.width(), sz.height(),
1158 btn->colorGroup(), btn->state(), btn->isDown(), 1170 btn->colorGroup(), btn->state(), btn->isDown(),
1159 btn->isEnabled()); 1171 btn->isEnabled());
1160 x = sz.width() + 6; 1172 x = sz.width() + 6;
1161 y = 0; 1173 y = 0;
1162 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), 1174 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
1163 btn->height(), AlignLeft|AlignVCenter|ShowPrefix, 1175 btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
1164 btn->colorGroup(), btn->isEnabled(), 1176 btn->colorGroup(), btn->isEnabled(),
1165 btn->pixmap(), btn->text()); 1177 btn->pixmap(), btn->text());
1166 p.end(); 1178 p.end();
1167 return(true); 1179 return(true);
1168 } 1180 }
1169 // for hover, just redraw the indicator (not the text) 1181 // for hover, just redraw the indicator (not the text)
1170 else if((ev->type() == QEvent::Enter && btn->isEnabled()) || 1182 else if((ev->type() == QEvent::Enter && btn->isEnabled()) ||
1171 (ev->type() == QEvent::Leave && btn == highlightWidget)){ 1183 (ev->type() == QEvent::Leave && btn == highlightWidget)){
1172 QButton *btn = (QButton *)obj; 1184 QButton *btn = (QButton *)obj;
1173 bool isRadio = obj->inherits("QRadioButton"); 1185 bool isRadio = obj->inherits("QRadioButton");
1174 1186
1175 if(ev->type() == QEvent::Enter) 1187 if(ev->type() == QEvent::Enter)
1176 highlightWidget = btn; 1188 highlightWidget = btn;
1177 else 1189 else
1178 highlightWidget = NULL; 1190 highlightWidget = NULL;
1179 QFontMetrics fm = btn->fontMetrics(); 1191 QFontMetrics fm = btn->fontMetrics();
1180 QSize lsz = fm.size(ShowPrefix, btn->text()); 1192 QSize lsz = fm.size(ShowPrefix, btn->text());
1181 QSize sz = isRadio ? exclusiveIndicatorSize() 1193 QSize sz = isRadio ? exclusiveIndicatorSize()
1182 : indicatorSize(); 1194 : indicatorSize();
1183 int x = 0; 1195 int x = 0;
1184 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1196 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1185 //if(btn->autoMask()) 1197 //if(btn->autoMask())
1186 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); 1198 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2);
1187 QPainter p; 1199 QPainter p;
1188 p.begin(btn); 1200 p.begin(btn);
1189 if(isRadio) 1201 if(isRadio)
1190 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1202 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1191 btn->colorGroup(), btn->isOn(), 1203 btn->colorGroup(), btn->isOn(),
1192 btn->isDown(), btn->isEnabled()); 1204 btn->isDown(), btn->isEnabled());
1193 else 1205 else
1194 drawIndicator(&p, x, y, sz.width(), sz.height(), 1206 drawIndicator(&p, x, y, sz.width(), sz.height(),
1195 btn->colorGroup(), btn->state(), btn->isDown(), 1207 btn->colorGroup(), btn->state(), btn->isDown(),
1196 btn->isEnabled()); 1208 btn->isEnabled());
1197 p.end(); 1209 p.end();
1198 } 1210 }
1199 } 1211 }
1200 else if(obj->inherits("QHeader")){ 1212 else if(obj->inherits("QHeader")){
1201 QHeader *hw = (QHeader *)obj; 1213 QHeader *hw = (QHeader *)obj;
1202 if(ev->type() == QEvent::Enter){ 1214 if(ev->type() == QEvent::Enter){
1203 currentHeader = hw; 1215 currentHeader = hw;
1204 headerHoverID = -1; 1216 headerHoverID = -1;
1205 } 1217 }
1206 else if(ev->type() == QEvent::Leave){ 1218 else if(ev->type() == QEvent::Leave){
1207 currentHeader = NULL; 1219 currentHeader = NULL;
1208 if(headerHoverID != -1){ 1220 if(headerHoverID != -1){
1209 hw->repaint(hw->sectionPos(headerHoverID), 0, 1221 hw->repaint(hw->sectionPos(headerHoverID), 0,
1210 hw->sectionSize(headerHoverID), hw->height()); 1222 hw->sectionSize(headerHoverID), hw->height());
1211 } 1223 }
1212 headerHoverID = -1; 1224 headerHoverID = -1;
1213 } 1225 }
1214 else if(ev->type() == QEvent::MouseMove){ 1226 else if(ev->type() == QEvent::MouseMove){
1215 QMouseEvent *me = (QMouseEvent *)ev; 1227 QMouseEvent *me = (QMouseEvent *)ev;
1216 int oldHeader = headerHoverID; 1228 int oldHeader = headerHoverID;
1217 headerHoverID = hw->sectionAt(me->x()); 1229 headerHoverID = hw->sectionAt(me->x());
1218 if(oldHeader != headerHoverID){ 1230 if(oldHeader != headerHoverID){
1219 // reset old header 1231 // reset old header
1220 if(oldHeader != -1){ 1232 if(oldHeader != -1){
1221 hw->repaint(hw->sectionPos(oldHeader), 0, 1233 hw->repaint(hw->sectionPos(oldHeader), 0,
1222 hw->sectionSize(oldHeader), hw->height()); 1234 hw->sectionSize(oldHeader), hw->height());
1223 } 1235 }
1224 if(headerHoverID != -1){ 1236 if(headerHoverID != -1){
1225 hw->repaint(hw->sectionPos(headerHoverID), 0, 1237 hw->repaint(hw->sectionPos(headerHoverID), 0,
1226 hw->sectionSize(headerHoverID), hw->height()); 1238 hw->sectionSize(headerHoverID), hw->height());
1227 } 1239 }
1228 } 1240 }
1229 } 1241 }
1230 } 1242 }
1231 return(false); 1243 return(false);
1232} 1244}
1233 1245
1234void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, 1246void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
1235 const QColorGroup &g, bool sunken, 1247 const QColorGroup &g, bool sunken,
1236 const QBrush *) 1248 const QBrush *)
1237{ 1249{
1238 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), 1250 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
1239 x, y, w, h); 1251 x, y, w, h);
1240} 1252}
1241 1253
1242void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, 1254void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
1243 const QColorGroup &g, bool sunken, 1255 const QColorGroup &g, bool sunken,
1244 const QBrush *) 1256 const QBrush *)
1245{ 1257{
1246 if(p->device()->devType() != QInternal::Widget){ 1258 if(p->device()->devType() != QInternal::Widget){
1247 // drawing into a temp pixmap, don't use mask 1259 // drawing into a temp pixmap, don't use mask
1248 QColor c = sunken ? g.button() : g.background(); 1260 QColor c = sunken ? g.button() : g.background();
1249 p->setPen(c.dark(130)); 1261 p->setPen(c.dark(130));
1250 p->drawRect(x, y, w, h); 1262 p->drawRect(x, y, w, h);
1251 p->setPen(c.light(105)); 1263 p->setPen(c.light(105));
1252 p->drawRect(x+1, y+1, w-2, h-2); 1264 p->drawRect(x+1, y+1, w-2, h-2);
1253 1265
1254 1266
1255 // fill 1267 // fill
1256 QPixmap *pix = bevelFillDict.find(c.rgb()); 1268 QPixmap *pix = bevelFillDict.find(c.rgb());
1257 if(!pix){ 1269 if(!pix){
1258 int h, s, v; 1270 int h, s, v;
1259 c.hsv(&h, &s, &v); 1271 c.hsv(&h, &s, &v);
1260 pix = new QPixmap(*bevelFillPix); 1272 pix = new QPixmap(*bevelFillPix);
1261 adjustHSV(*pix, h, s, v); 1273 adjustHSV(*pix, h, s, v);
1262 bevelFillDict.insert(c.rgb(), pix); 1274 bevelFillDict.insert(c.rgb(), pix);
1263 } 1275 }
1264 1276
1265 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); 1277 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
1266 } 1278 }
1267 else{ 1279 else{
1268 drawClearBevel(p, x, y, w, h, sunken ? g.button() : 1280 drawClearBevel(p, x, y, w, h, sunken ? g.button() :
1269 highlightWidget == p->device() ? g.button().light(110) : 1281 highlightWidget == p->device() ? g.button().light(110) :
1270 g.background(), g.background()); 1282 g.background(), g.background());
1271 } 1283 }
1272} 1284}
1273 1285
1274void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) 1286void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
1275{ 1287{
1276 QRect r = btn->rect(); 1288 QRect r = btn->rect();
1277 bool sunken = btn->isOn() || btn->isDown(); 1289 bool sunken = btn->isOn() || btn->isDown();
1278 QColorGroup g = btn->colorGroup(); 1290 QColorGroup g = btn->colorGroup();
1279 1291
1280 1292
1281 //int dw = buttonDefaultIndicatorWidth(); 1293 //int dw = buttonDefaultIndicatorWidth();
1282 if(btn->hasFocus() || btn->isDefault()){ 1294 if(btn->hasFocus() || btn->isDefault()){
1283 QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); 1295 QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
1284 QPixmap *pix = bevelFillDict.find(c.rgb()); 1296 QPixmap *pix = bevelFillDict.find(c.rgb());
1285 if(!pix){ 1297 if(!pix){
1286 int h, s, v; 1298 int h, s, v;
1287 c.hsv(&h, &s, &v); 1299 c.hsv(&h, &s, &v);
1288 pix = new QPixmap(*bevelFillPix); 1300 pix = new QPixmap(*bevelFillPix);
1289 adjustHSV(*pix, h, s, v); 1301 adjustHSV(*pix, h, s, v);
1290 bevelFillDict.insert(c.rgb(), pix); 1302 bevelFillDict.insert(c.rgb(), pix);
1291 } 1303 }
1292 p->setPen(c.dark(150)); 1304 p->setPen(c.dark(150));
1293 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1305 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1294 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1306 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1295 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1307 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1296 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1308 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1297 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1309 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1298 } 1310 }
1299 1311
1300 QColor newColor = btn == highlightWidget || sunken ? 1312 QColor newColor = btn == highlightWidget || sunken ?
1301 g.button().light(120) : g.button(); 1313 g.button().light(120) : g.button();
1302 1314
1303 drawRoundButton(p, newColor, g.background(), 1315 drawRoundButton(p, newColor, g.background(),
1304 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), 1316 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
1305 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), 1317 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
1306 btn->autoMask()); 1318 btn->autoMask());
1307} 1319}
1308 1320
1309void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) 1321void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
1310{ 1322{
1311 int x1, y1, x2, y2, w, h; 1323 int x1, y1, x2, y2, w, h;
1312 btn->rect().coords(&x1, &y1, &x2, &y2); 1324 btn->rect().coords(&x1, &y1, &x2, &y2);
1313 w = btn->width(); 1325 w = btn->width();
1314 h = btn->height(); 1326 h = btn->height();
1315 1327
1316 bool act = btn->isOn() || btn->isDown(); 1328 bool act = btn->isOn() || btn->isDown();
1317 if(act){ 1329 if(act){
1318 ++x1, ++y1; 1330 ++x1, ++y1;
1319 } 1331 }
1320 1332
1321 // Draw iconset first, if any 1333 // Draw iconset first, if any
1322 if ( btn->iconSet() && !btn->iconSet()->isNull() ) 1334 if ( btn->iconSet() && !btn->iconSet()->isNull() )
1323 { 1335 {
1324 QIconSet::Mode mode = btn->isEnabled() 1336 QIconSet::Mode mode = btn->isEnabled()
1325 ? QIconSet::Normal : QIconSet::Disabled; 1337 ? QIconSet::Normal : QIconSet::Disabled;
1326 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1338 if ( mode == QIconSet::Normal && btn->hasFocus() )
1327 mode = QIconSet::Active; 1339 mode = QIconSet::Active;
1328 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); 1340 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
1329 int pixw = pixmap.width(); 1341 int pixw = pixmap.width();
1330 int pixh = pixmap.height(); 1342 int pixh = pixmap.height();
1331 1343
1332 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); 1344 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
1333 x1 += pixw + 8; 1345 x1 += pixw + 8;
1334 w -= pixw + 8; 1346 w -= pixw + 8;
1335 } 1347 }
1336 1348
1337 if(act){ 1349 if(act){
1338 QFont font = btn->font(); 1350 QFont font = btn->font();
1339 font.setBold(true); 1351 font.setBold(true);
1340 p->setFont(font); 1352 p->setFont(font);
1341 QColor shadow(btn->colorGroup().button().dark(130)); 1353 QColor shadow(btn->colorGroup().button().dark(130));
1342 drawItem( p, x1+1, y1+1, w, h, 1354 drawItem( p, x1+1, y1+1, w, h,
1343 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1355 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1344 btn->pixmap(), btn->text(), -1, 1356 btn->pixmap(), btn->text(), -1,
1345 &shadow); 1357 &shadow);
1346 1358
1347 drawItem( p, x1, y1, w, h, 1359 drawItem( p, x1, y1, w, h,
1348 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1360 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1349 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); 1361 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
1350 } 1362 }
1351 else{ 1363 else{
1352 /* Too blurry 1364 /* Too blurry
1353 drawItem( p, x1+1, y1+1, w, h, 1365 drawItem( p, x1+1, y1+1, w, h,
1354 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1366 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1355 btn->pixmap(), btn->text(), -1, 1367 btn->pixmap(), btn->text(), -1,
1356 &btn->colorGroup().button().dark(115)); 1368 &btn->colorGroup().button().dark(115));
1357 */ 1369 */
1358 drawItem( p, x1, y1, w, h, 1370 drawItem( p, x1, y1, w, h,
1359 AlignCenter | ShowPrefix, 1371 AlignCenter | ShowPrefix,
1360 btn->colorGroup(), btn->isEnabled(), 1372 btn->colorGroup(), btn->isEnabled(),
1361 btn->pixmap(), btn->text(), -1, 1373 btn->pixmap(), btn->text(), -1,
1362 &btn->colorGroup().buttonText()); 1374 &btn->colorGroup().buttonText());
1363 } 1375 }
1364} 1376}
1365 1377
1366void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) 1378void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
1367{ 1379{
1368 int x2 = x+w-1; 1380 int x2 = x+w-1;
1369 int y2 = y+h-1; 1381 int y2 = y+h-1;
1370 1382
1371 p->setPen(Qt::color1); 1383 p->setPen(Qt::color1);
1372 p->fillRect(x, y, w, h, Qt::color0); 1384 p->fillRect(x, y, w, h, Qt::color0);
1373 if(w < 21 || h < 21){ 1385 if(w < 21 || h < 21){
1374 // outer rect 1386 // outer rect
1375 p->drawLine(x, y+2, x, y2-2); // l 1387 p->drawLine(x, y+2, x, y2-2); // l
1376 p->drawLine(x2, y+2, x2, y2-2); // r 1388 p->drawLine(x2, y+2, x2, y2-2); // r
1377 p->drawLine(x+2, y, x2-2, y); // t 1389 p->drawLine(x+2, y, x2-2, y); // t
1378 p->drawLine(x+2, y2, x2-2, y2); // b 1390 p->drawLine(x+2, y2, x2-2, y2); // b
1379 p->drawLine(x+1, y+1, x2-1, y+1); // top second line 1391 p->drawLine(x+1, y+1, x2-1, y+1); // top second line
1380 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line 1392 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line
1381 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); 1393 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1);
1382 } 1394 }
1383 else{ 1395 else{
1384 int x2 = x+w-1; 1396 int x2 = x+w-1;
1385 int y2 = y+h-1; 1397 int y2 = y+h-1;
1386 int bx2 = htmlBtnMaskBmp.width()-1; 1398 int bx2 = htmlBtnMaskBmp.width()-1;
1387 int by2 = htmlBtnMaskBmp.height()-1; 1399 int by2 = htmlBtnMaskBmp.height()-1;
1388 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl 1400 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
1389 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr 1401 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
1390 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl 1402 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
1391 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br 1403 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
1392 // fills 1404 // fills
1393 p->fillRect(10, 0, w-20, 10, Qt::color1); // top 1405 p->fillRect(10, 0, w-20, 10, Qt::color1); // top
1394 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1406 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1395 p->fillRect(0, 10, w, h-20, Qt::color1); // middle 1407 p->fillRect(0, 10, w, h-20, Qt::color1); // middle
1396 } 1408 }
1397} 1409}
1398 1410
1399void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, 1411void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
1400 const QColorGroup &g, bool sunken, 1412 const QColorGroup &g, bool sunken,
1401 const QBrush */*fill*/) 1413 const QBrush */*fill*/)
1402{ 1414{
1403 if(currentHeader && p->device() == currentHeader){ 1415 if(currentHeader && p->device() == currentHeader){
1404 int id = currentHeader->sectionAt(x); 1416 int id = currentHeader->sectionAt(x);
1405 bool isHeaderHover = id != -1 && id == headerHoverID; 1417 bool isHeaderHover = id != -1 && id == headerHoverID;
1406 drawClearBevel(p, x, y, w, h, sunken ? 1418 drawClearBevel(p, x, y, w, h, sunken ?
1407 g.button() : isHeaderHover ? g.button().light(110) : 1419 g.button() : isHeaderHover ? g.button().light(110) :
1408 g.background(), g.background()); 1420 g.background(), g.background());
1409 } 1421 }
1410 else 1422 else
1411 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), 1423 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
1412 g.background()); 1424 g.background());
1413} 1425}
1414 1426
1415QRect LiquidStyle::buttonRect(int x, int y, int w, int h) 1427QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
1416{ 1428{
1417 return(QRect(x+5, y+5, w-10, h-10)); 1429 return(QRect(x+5, y+5, w-10, h-10));
1418} 1430}
1419 1431
1420void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, 1432void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1421 const QColorGroup &g, bool sunken, 1433 const QColorGroup &g, bool sunken,
1422 bool edit, bool, const QBrush *) 1434 bool edit, bool, const QBrush *)
1423{ 1435{
1424 bool isHover = highlightWidget == painter->device(); 1436 bool isHover = highlightWidget == painter->device();
1425 bool isMasked = false; 1437 bool isMasked = false;
1426 if(painter->device()->devType() == QInternal::Widget) 1438 if(painter->device()->devType() == QInternal::Widget)
1427 isMasked = ((QWidget*)painter->device())->autoMask(); 1439 isMasked = ((QWidget*)painter->device())->autoMask();
1428 // TODO: Do custom code, don't just call drawRoundButton into a pixmap 1440 // TODO: Do custom code, don't just call drawRoundButton into a pixmap
1429 QPixmap tmpPix(w, h); 1441 QPixmap tmpPix(w, h);
1430 QPainter p(&tmpPix); 1442 QPainter p(&tmpPix);
1431 1443
1432 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, 1444 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
1433 sunken, false, isMasked); 1445 sunken, false, isMasked);
1434 if(!isHover){ 1446 if(!isHover){
1435 p.setClipRect(0, 0, w-17, h); 1447 p.setClipRect(0, 0, w-17, h);
1436 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, 1448 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
1437 sunken, false, isMasked); 1449 sunken, false, isMasked);
1438 } 1450 }
1439 p.end(); 1451 p.end();
1440 int x2 = x+w-1; 1452 int x2 = x+w-1;
1441 int y2 = y+h-1; 1453 int y2 = y+h-1;
1442 int bx2 = btnMaskBmp.width()-1; 1454 int bx2 = btnMaskBmp.width()-1;
1443 int by2 = btnMaskBmp.height()-1; 1455 int by2 = btnMaskBmp.height()-1;
1444 QBitmap btnMask(w, h); 1456 QBitmap btnMask(w, h);
1445 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 1457 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
1446 p.begin(&btnMask); 1458 p.begin(&btnMask);
1447 p.fillRect(0, 0, w, h, Qt::color0); 1459 p.fillRect(0, 0, w, h, Qt::color0);
1448 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 1460 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
1449 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 1461 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
1450 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 1462 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
1451 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 1463 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
1452 // fills 1464 // fills
1453 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 1465 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
1454 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1466 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1455 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 1467 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
1456 p.end(); 1468 p.end();
1457 tmpPix.setMask(btnMask); 1469 tmpPix.setMask(btnMask);
1458 1470
1459 painter->drawPixmap(x, y, tmpPix); 1471 painter->drawPixmap(x, y, tmpPix);
1460 1472
1461 painter->setPen(g.button().dark(120)); 1473 painter->setPen(g.button().dark(120));
1462 painter->drawLine(x2-16, y+1, x2-16, y2-1); 1474 painter->drawLine(x2-16, y+1, x2-16, y2-1);
1463 1475
1464 if(edit){ 1476 if(edit){
1465 painter->setPen(g.mid()); 1477 painter->setPen(g.mid());
1466 painter->drawRect(x+8, y+2, w-25, h-4); 1478 painter->drawRect(x+8, y+2, w-25, h-4);
1467 } 1479 }
1468 int arrow_h = h / 3; 1480 int arrow_h = h / 3;
1469 int arrow_w = arrow_h; 1481 int arrow_w = arrow_h;
1470 int arrow_x = w - arrow_w - 6; 1482 int arrow_x = w - arrow_w - 6;
1471 int arrow_y = (h - arrow_h) / 2; 1483 int arrow_y = (h - arrow_h) / 2;
1472 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); 1484 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true);
1473} 1485}
1474 1486
1475void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) 1487void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
1476{ 1488{
1477 drawButtonMask(p, x, y, w, h); 1489 drawButtonMask(p, x, y, w, h);
1478} 1490}
1479 1491
1480QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) 1492QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
1481{ 1493{
1482 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); 1494 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
1483 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); 1495 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
1484} 1496}
1485 1497
1486QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) 1498QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h)
1487{ 1499{
1488 return(QRect(x+5, y+3, w-(h/3)-13, h-5)); 1500 return(QRect(x+5, y+3, w-(h/3)-13, h-5));
1489} 1501}
1490 1502
1491void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, 1503void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1492 int sliderStart, uint controls, 1504 int sliderStart, uint controls,
1493 uint activeControl) 1505 uint activeControl)
1494{ 1506{
1495 bool isHover = highlightWidget == p->device(); 1507 bool isHover = highlightWidget == p->device();
1496 int sliderMin, sliderMax, sliderLength, buttonDim; 1508 int sliderMin, sliderMax, sliderLength, buttonDim;
1497 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1509 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1498 1510
1499 if (sliderStart > sliderMax) 1511 if (sliderStart > sliderMax)
1500 sliderStart = sliderMax; 1512 sliderStart = sliderMax;
1501 1513
1502 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1514 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1503 QColorGroup g = sb->colorGroup(); 1515 QColorGroup g = sb->colorGroup();
1504 QRect addB, subHC, subB; 1516 QRect addB, subHC, subB;
1505 QRect addPageR, subPageR, sliderR; 1517 QRect addPageR, subPageR, sliderR;
1506 int addX, addY, subX, subY; 1518 int addX, addY, subX, subY;
1507 int len = horiz ? sb->width() : sb->height(); 1519 int len = horiz ? sb->width() : sb->height();
1508 int extent = horiz ? sb->height() : sb->width(); 1520 int extent = horiz ? sb->height() : sb->width();
1509 1521
1510 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar 1522 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
1511 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. 1523 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
1512 bool brokenApp; 1524 bool brokenApp;
1513 if(extent == 16) 1525 if(extent == 16)
1514 brokenApp = true; 1526 brokenApp = true;
1515 else 1527 else
1516 brokenApp = false; 1528 brokenApp = false;
1517 1529
1518 if (horiz) { 1530 if (horiz) {
1519 subY = addY = ( extent - buttonDim ) / 2; 1531 subY = addY = ( extent - buttonDim ) / 2;
1520 subX = 0; 1532 subX = 0;
1521 addX = len - buttonDim; 1533 addX = len - buttonDim;
1522 if(sbBuffer.size() != sb->size()) 1534 if(sbBuffer.size() != sb->size())
1523 sbBuffer.resize(sb->size()); 1535 sbBuffer.resize(sb->size());
1524 } 1536 }
1525 else { 1537 else {
1526 subX = addX = ( extent - buttonDim ) / 2; 1538 subX = addX = ( extent - buttonDim ) / 2;
1527 subY = 0; 1539 subY = 0;
1528 addY = len - buttonDim; 1540 addY = len - buttonDim;
1529 if(sbBuffer.size() != sb->size()) 1541 if(sbBuffer.size() != sb->size())
1530 sbBuffer.resize(sb->size()); 1542 sbBuffer.resize(sb->size());
1531 } 1543 }
1532 subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); 1544 subB.setRect( subX,subY,0,0); // buttonDim,buttonDim );
1533 addB.setRect( addX,addY,buttonDim,buttonDim ); 1545 addB.setRect( addX,addY,buttonDim,buttonDim );
1534 if(horiz) 1546 if(horiz)
1535 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); 1547 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
1536 else 1548 else
1537 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); 1549 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
1538 1550
1539 int sliderEnd = sliderStart + sliderLength; 1551 int sliderEnd = sliderStart + sliderLength;
1540 int sliderW = extent; 1552 int sliderW = extent;
1541 1553
1542 if (horiz) { 1554 if (horiz) {
1543 subPageR.setRect( subB.right() + 1, 0, 1555 subPageR.setRect( subB.right() + 1, 0,
1544 sliderStart - subB.right() - 1 , sliderW ); 1556 sliderStart - subB.right() - 1 , sliderW );
1545 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); 1557 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
1546 sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); 1558 sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
1547 } 1559 }
1548 else { 1560 else {
1549 subPageR.setRect( 0, subB.bottom() + 1, sliderW, 1561 subPageR.setRect( 0, subB.bottom() + 1, sliderW,
1550 sliderStart - subB.bottom() - 1 ); 1562 sliderStart - subB.bottom() - 1 );
1551 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); 1563 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
1552 sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); 1564 sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
1553 } 1565 }
1554 1566
1555 bool maxed = sb->maxValue() == sb->minValue(); 1567 bool maxed = sb->maxValue() == sb->minValue();
1556 1568
1557 QPainter painter; 1569 QPainter painter;
1558 if(!horiz){ 1570 if(!horiz){
1559 painter.begin(&sbBuffer); 1571 painter.begin(&sbBuffer);
1560 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); 1572 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1);
1561 if(sliderR.height() >= 8){ 1573 if(sliderR.height() >= 8){
1562 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, 1574 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
1563 13, 8); 1575 13, 8);
1564 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); 1576 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
1565 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, 1577 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
1566 bgR.height()-16, *getPixmap(VSBSliderMidBg)); 1578 bgR.height()-16, *getPixmap(VSBSliderMidBg));
1567 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, 1579 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
1568 0, 0, 13, 8); 1580 0, 0, 13, 8);
1569 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); 1581 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
1570 } 1582 }
1571 else{ 1583 else{
1572 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), 1584 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
1573 *getPixmap(VSBSliderMidBg)); 1585 *getPixmap(VSBSliderMidBg));
1574 painter.setPen(g.background().dark(210)); 1586 painter.setPen(g.background().dark(210));
1575 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); 1587 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
1576 painter.setPen(g.mid()); 1588 painter.setPen(g.mid());
1577 painter.drawPoint(bgR.x()+1, bgR.y()); 1589 painter.drawPoint(bgR.x()+1, bgR.y());
1578 painter.drawPoint(bgR.x()+13, bgR.y()); 1590 painter.drawPoint(bgR.x()+13, bgR.y());
1579 painter.drawPoint(bgR.x()+1, bgR.bottom()-1); 1591 painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
1580 painter.drawPoint(bgR.x()+13, bgR.bottom()-1); 1592 painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
1581 } 1593 }
1582 if(controls & Slider){ 1594 if(controls & Slider){
1583 if(sliderR.height() >= 16){ 1595 if(sliderR.height() >= 16){
1584 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1596 painter.drawPixmap(sliderR.x()+1, sliderR.y(),
1585 isHover ? *getPixmap(VSBSliderTopHover): 1597 isHover ? *getPixmap(VSBSliderTopHover):
1586 *getPixmap(VSBSliderTop)); 1598 *getPixmap(VSBSliderTop));
1587 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, 1599 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
1588 sliderR.height()-16, isHover ? 1600 sliderR.height()-16, isHover ?
1589 *getPixmap(VSBSliderMidHover) : 1601 *getPixmap(VSBSliderMidHover) :
1590 *getPixmap(VSBSliderMid)); 1602 *getPixmap(VSBSliderMid));
1591 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, 1603 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8,
1592 isHover ? *getPixmap(VSBSliderBtmHover) : 1604 isHover ? *getPixmap(VSBSliderBtmHover) :
1593 *getPixmap(VSBSliderBtm)); 1605 *getPixmap(VSBSliderBtm));
1594 } 1606 }
1595 else if(sliderR.height() >= 8){ 1607 else if(sliderR.height() >= 8){
1596 int m = sliderR.height()/2; 1608 int m = sliderR.height()/2;
1597 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1609 painter.drawPixmap(sliderR.x()+1, sliderR.y(),
1598 isHover ? *getPixmap(VSBSliderTopHover): 1610 isHover ? *getPixmap(VSBSliderTopHover):
1599 *getPixmap(VSBSliderTop), 0, 0, 13, m); 1611 *getPixmap(VSBSliderTop), 0, 0, 13, m);
1600 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, 1612 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m,
1601 isHover ? *getPixmap(VSBSliderBtmHover): 1613 isHover ? *getPixmap(VSBSliderBtmHover):
1602 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); 1614 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1603 } 1615 }
1604 else{ 1616 else{
1605 painter.setPen(g.button().dark(210)); 1617 painter.setPen(g.button().dark(210));
1606 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), 1618 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
1607 13, sliderR.height()); 1619 13, sliderR.height());
1608 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, 1620 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
1609 11, sliderR.height()-2, 1621 11, sliderR.height()-2,
1610 isHover ? *getPixmap(VSBSliderMidHover) : 1622 isHover ? *getPixmap(VSBSliderMidHover) :
1611 *getPixmap(VSBSliderMid), 1, 0); 1623 *getPixmap(VSBSliderMid), 1, 0);
1612 } 1624 }
1613 } 1625 }
1614 painter.setPen(g.mid()); 1626 painter.setPen(g.mid());
1615 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); 1627 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
1616 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); 1628 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
1617 if(brokenApp && (controls & Slider)){ 1629 if(brokenApp && (controls & Slider)){
1618 painter.setPen(g.background()); 1630 painter.setPen(g.background());
1619 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, 1631 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
1620 bgR.bottom()); 1632 bgR.bottom());
1621 } 1633 }
1622 painter.end(); 1634 painter.end();
1623 } 1635 }
1624 else{ 1636 else{
1625 painter.begin(&sbBuffer); 1637 painter.begin(&sbBuffer);
1626 QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); 1638 QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height());
1627 if(sliderR.width() >= 8){ 1639 if(sliderR.width() >= 8){
1628 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, 1640 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
1629 8, 13); 1641 8, 13);
1630 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); 1642 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
1631 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, 1643 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
1632 13, *getPixmap(HSBSliderMidBg)); 1644 13, *getPixmap(HSBSliderMidBg));
1633 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, 1645 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
1634 0, 0, 8, 13); 1646 0, 0, 8, 13);
1635 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); 1647 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
1636 } 1648 }
1637 else{ 1649 else{
1638 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, 1650 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
1639 *getPixmap(HSBSliderMidBg)); 1651 *getPixmap(HSBSliderMidBg));
1640 painter.setPen(g.background().dark(210)); 1652 painter.setPen(g.background().dark(210));
1641 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); 1653 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
1642 painter.setPen(g.mid()); 1654 painter.setPen(g.mid());
1643 painter.drawPoint(bgR.x(), bgR.y()+1); 1655 painter.drawPoint(bgR.x(), bgR.y()+1);
1644 painter.drawPoint(bgR.x(), bgR.bottom()-1); 1656 painter.drawPoint(bgR.x(), bgR.bottom()-1);
1645 painter.drawPoint(bgR.right()-1, bgR.y()+1); 1657 painter.drawPoint(bgR.right()-1, bgR.y()+1);
1646 painter.drawPoint(bgR.right()-1, bgR.bottom()-1); 1658 painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
1647 } 1659 }
1648 if(controls & Slider){ 1660 if(controls & Slider){
1649 if(sliderR.width() >= 16){ 1661 if(sliderR.width() >= 16){
1650 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1662 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1651 isHover ? *getPixmap(HSBSliderTopHover) : 1663 isHover ? *getPixmap(HSBSliderTopHover) :
1652 *getPixmap(HSBSliderTop)); 1664 *getPixmap(HSBSliderTop));
1653 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 1665 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
1654 13, isHover ? *getPixmap(HSBSliderMidHover) : 1666 13, isHover ? *getPixmap(HSBSliderMidHover) :
1655 *getPixmap(HSBSliderMid)); 1667 *getPixmap(HSBSliderMid));
1656 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? 1668 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
1657 *getPixmap(HSBSliderBtmHover) : 1669 *getPixmap(HSBSliderBtmHover) :
1658 *getPixmap(HSBSliderBtm)); 1670 *getPixmap(HSBSliderBtm));
1659 } 1671 }
1660 else if(sliderR.width() >= 8){ 1672 else if(sliderR.width() >= 8){
1661 int m = sliderR.width()/2; 1673 int m = sliderR.width()/2;
1662 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1674 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1663 isHover ? *getPixmap(HSBSliderTopHover) : 1675 isHover ? *getPixmap(HSBSliderTopHover) :
1664 *getPixmap(HSBSliderTop), 0, 0, m, 13); 1676 *getPixmap(HSBSliderTop), 0, 0, m, 13);
1665 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? 1677 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
1666 *getPixmap(HSBSliderBtmHover) : 1678 *getPixmap(HSBSliderBtmHover) :
1667 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); 1679 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
1668 } 1680 }
1669 else{ 1681 else{
1670 painter.setPen(g.button().dark(210)); 1682 painter.setPen(g.button().dark(210));
1671 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, 1683 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
1672 sliderR.width(), 13); 1684 sliderR.width(), 13);
1673 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1685 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1674 sliderR.width()-2, 11, isHover ? 1686 sliderR.width()-2, 11, isHover ?
1675 *getPixmap(HSBSliderMidHover) : 1687 *getPixmap(HSBSliderMidHover) :
1676 *getPixmap(HSBSliderMid), 0, 1); 1688 *getPixmap(HSBSliderMid), 0, 1);
1677 } 1689 }
1678 } 1690 }
1679 painter.setPen(g.mid()); 1691 painter.setPen(g.mid());
1680 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); 1692 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
1681 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); 1693 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
1682 if(brokenApp && (controls & Slider)){ 1694 if(brokenApp && (controls & Slider)){
1683 painter.setPen(g.background()); 1695 painter.setPen(g.background());
1684 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), 1696 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
1685 bgR.bottom()-1); 1697 bgR.bottom()-1);
1686 } 1698 }
1687 painter.end(); 1699 painter.end();
1688 } 1700 }
1689 1701
1690 if ( controls & AddLine ) { 1702 if ( controls & AddLine ) {
1691 drawSBButton(p, addB, g, activeControl == AddLine); 1703 drawSBButton(p, addB, g, activeControl == AddLine);
1692 drawArrow( p, horiz ? RightArrow : DownArrow, 1704 drawArrow( p, horiz ? RightArrow : DownArrow,
1693 false, addB.x()+4, addB.y()+4, 1705 false, addB.x()+4, addB.y()+4,
1694 addB.width()-8, addB.height()-8, g, !maxed); 1706 addB.width()-8, addB.height()-8, g, !maxed);
1695 } 1707 }
1696 if ( controls & SubLine ) { 1708 if ( controls & SubLine ) {
1697 // drawSBButton(p, subB, g, activeControl == SubLine); 1709 // drawSBButton(p, subB, g, activeControl == SubLine);
1698 // drawArrow( p, horiz ? LeftArrow : UpArrow, 1710 // drawArrow( p, horiz ? LeftArrow : UpArrow,
1699 // false, subB.x()+4, subB.y()+4, 1711 // false, subB.x()+4, subB.y()+4,
1700 // subB.width()-8, subB.height()-8, g, !maxed); 1712 // subB.width()-8, subB.height()-8, g, !maxed);
1701 drawSBButton(p, subHC, g, activeControl == SubLine); 1713 drawSBButton(p, subHC, g, activeControl == SubLine);
1702 drawArrow( p, horiz ? LeftArrow : UpArrow, 1714 drawArrow( p, horiz ? LeftArrow : UpArrow,
1703 false, subHC.x()+4, subHC.y()+4, 1715 false, subHC.x()+4, subHC.y()+4,
1704 subHC.width()-8, subHC.height()-8, g, !maxed); 1716 subHC.width()-8, subHC.height()-8, g, !maxed);
1705 } 1717 }
1706 1718
1707 if(controls & AddPage){ 1719 if(controls & AddPage){
1708 if(addPageR.width()){ 1720 if(addPageR.width()){
1709 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, 1721 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
1710 addPageR.x(), addPageR.y(), addPageR.width(), 1722 addPageR.x(), addPageR.y(), addPageR.width(),
1711 addPageR.height()); 1723 addPageR.height());
1712 } 1724 }
1713 } 1725 }
1714 if(controls & SubPage){ 1726 if(controls & SubPage){
1715 if(subPageR.height()){ 1727 if(subPageR.height()){
1716 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, 1728 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
1717 subPageR.x(), subPageR.y(), subPageR.width(), 1729 subPageR.x(), subPageR.y(), subPageR.width(),
1718 subPageR.height()); 1730 subPageR.height());
1719 } 1731 }
1720 } 1732 }
1721 if ( controls & Slider ) { 1733 if ( controls & Slider ) {
1722 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, 1734 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
1723 sliderR.x(), sliderR.y(), sliderR.width(), 1735 sliderR.x(), sliderR.y(), sliderR.width(),
1724 sliderR.height()); 1736 sliderR.height());
1725 } 1737 }
1726} 1738}
1727 1739
1728void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, 1740void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
1729 bool down, bool /*fast*/) 1741 bool down, bool /*fast*/)
1730{ 1742{
1731 p->setPen(g.mid()); 1743 p->setPen(g.mid());
1732 p->drawRect(r); 1744 p->drawRect(r);
1733 QColor c(down ? g.button() : g.background()); 1745 QColor c(down ? g.button() : g.background());
1734 QPixmap *pix = bevelFillDict.find(c.rgb()); 1746 QPixmap *pix = bevelFillDict.find(c.rgb());
1735 if(!pix){ 1747 if(!pix){
1736 int h, s, v; 1748 int h, s, v;
1737 c.hsv(&h, &s, &v); 1749 c.hsv(&h, &s, &v);
1738 pix = new QPixmap(*bevelFillPix); 1750 pix = new QPixmap(*bevelFillPix);
1739 adjustHSV(*pix, h, s, v); 1751 adjustHSV(*pix, h, s, v);
1740 bevelFillDict.insert(c.rgb(), pix); 1752 bevelFillDict.insert(c.rgb(), pix);
1741 } 1753 }
1742 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1754 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1743 1755
1744} 1756}
1745 1757
1746void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, 1758void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
1747 bool horiz) 1759 bool horiz)
1748{ 1760{
1749 if(horiz){ 1761 if(horiz){
1750 if(r.width() >= 15){ 1762 if(r.width() >= 15){
1751 int y = r.y()+3; 1763 int y = r.y()+3;
1752 int x = r.x() + (r.width()-7)/2; 1764 int x = r.x() + (r.width()-7)/2;
1753 int y2 = r.bottom()-3; 1765 int y2 = r.bottom()-3;
1754 p->setPen(g.light()); 1766 p->setPen(g.light());
1755 p->drawLine(x, y, x, y2); 1767 p->drawLine(x, y, x, y2);
1756 p->drawLine(x+3, y, x+3, y2); 1768 p->drawLine(x+3, y, x+3, y2);
1757 p->drawLine(x+6, y, x+6, y2); 1769 p->drawLine(x+6, y, x+6, y2);
1758 1770
1759 p->setPen(g.mid()); 1771 p->setPen(g.mid());
1760 p->drawLine(x+1, y, x+1, y2); 1772 p->drawLine(x+1, y, x+1, y2);
1761 p->drawLine(x+4, y, x+4, y2); 1773 p->drawLine(x+4, y, x+4, y2);
1762 p->drawLine(x+7, y, x+7, y2); 1774 p->drawLine(x+7, y, x+7, y2);
1763 } 1775 }
1764 } 1776 }
1765 else{ 1777 else{
1766 if(r.height() >= 15){ 1778 if(r.height() >= 15){
1767 int x = r.x()+3; 1779 int x = r.x()+3;
1768 int y = r.y() + (r.height()-7)/2; 1780 int y = r.y() + (r.height()-7)/2;
1769 int x2 = r.right()-3; 1781 int x2 = r.right()-3;
1770 p->setPen(g.light()); 1782 p->setPen(g.light());
1771 p->drawLine(x, y, x2, y); 1783 p->drawLine(x, y, x2, y);
1772 p->drawLine(x, y+3, x2, y+3); 1784 p->drawLine(x, y+3, x2, y+3);
1773 p->drawLine(x, y+6, x2, y+6); 1785 p->drawLine(x, y+6, x2, y+6);
1774 1786
1775 p->setPen(g.mid()); 1787 p->setPen(g.mid());
1776 p->drawLine(x, y+1, x2, y+1); 1788 p->drawLine(x, y+1, x2, y+1);
1777 p->drawLine(x, y+4, x2, y+4); 1789 p->drawLine(x, y+4, x2, y+4);
1778 p->drawLine(x, y+7, x2, y+7); 1790 p->drawLine(x, y+7, x2, y+7);
1779 } 1791 }
1780 } 1792 }
1781 1793
1782} 1794}
1783 1795
1784 1796
1785void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, 1797void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
1786 int &sliderMax, int &sliderLength, 1798 int &sliderMax, int &sliderLength,
1787 int &buttonDim) 1799 int &buttonDim)
1788{ 1800{
1789 1801
1790 int maxLength; 1802 int maxLength;
1791 int b = 0; 1803 int b = 0;
1792 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1804 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1793 int length = horiz ? sb->width() : sb->height(); 1805 int length = horiz ? sb->width() : sb->height();
1794 int extent = horiz ? sb->height() : sb->width(); 1806 int extent = horiz ? sb->height() : sb->width();
1795 1807
1796 if ( length > ( extent - b*2 - 1 )*2 + b*2 ) 1808 if ( length > ( extent - b*2 - 1 )*2 + b*2 )
1797 buttonDim = extent - b*2; 1809 buttonDim = extent - b*2;
1798 else 1810 else
1799 buttonDim = ( length - b*2 )/2 - 1; 1811 buttonDim = ( length - b*2 )/2 - 1;
1800 1812
1801 sliderMin = b + 0; // buttonDim; 1813 sliderMin = b + 0; // buttonDim;
1802 maxLength = length - b*2 - buttonDim*2; // 3; 1814 maxLength = length - b*2 - buttonDim*2; // 3;
1803 1815
1804 if ( sb->maxValue() == sb->minValue() ) { 1816 if ( sb->maxValue() == sb->minValue() ) {
1805 sliderLength = maxLength; 1817 sliderLength = maxLength;
1806 } else { 1818 } else {
1807 sliderLength = (sb->pageStep()*maxLength)/ 1819 sliderLength = (sb->pageStep()*maxLength)/
1808 (sb->maxValue()-sb->minValue()+sb->pageStep()); 1820 (sb->maxValue()-sb->minValue()+sb->pageStep());
1809 uint range = sb->maxValue()-sb->minValue(); 1821 uint range = sb->maxValue()-sb->minValue();
1810 if ( sliderLength < 9 || range > INT_MAX/2 ) 1822 if ( sliderLength < 9 || range > INT_MAX/2 )
1811 sliderLength = 9; 1823 sliderLength = 9;
1812 if ( sliderLength > maxLength ) 1824 if ( sliderLength > maxLength )
1813 sliderLength = maxLength; 1825 sliderLength = maxLength;
1814 } 1826 }
1815 sliderMax = sliderMin + maxLength - sliderLength; 1827 sliderMax = sliderMin + maxLength - sliderLength;
1816 1828
1817} 1829}
1818 1830
1819QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, 1831QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
1820 int sliderStart, 1832 int sliderStart,
1821 const QPoint &p) 1833 const QPoint &p)
1822{ 1834{
1823 if ( !sb->rect().contains( p ) ) 1835 if ( !sb->rect().contains( p ) )
1824 return NoScroll; 1836 return NoScroll;
1825 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 1837 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
1826 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1838 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1827 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); 1839 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y();
1828 if ( pos < sliderMin ) 1840 if ( pos < sliderMin )
1829 return SubLine; 1841 return SubLine;
1830 if ( pos < sliderStart ) 1842 if ( pos < sliderStart )
1831 return SubPage; 1843 return SubPage;
1832 if ( pos < sliderStart + sliderLength ) 1844 if ( pos < sliderStart + sliderLength )
1833 return Slider; 1845 return Slider;
1834 if ( pos < sliderMax + sliderLength) 1846 if ( pos < sliderMax + sliderLength)
1835 return AddPage; 1847 return AddPage;
1836 if(pos > sliderMax + sliderLength + 16) 1848 if(pos > sliderMax + sliderLength + 16)
1837 return AddLine; 1849 return AddLine;
1838 1850
1839 return SubLine; 1851 return SubLine;
1840} 1852}
1841 1853
1842#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1854#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1843 1855
1844 1856
1845QSize LiquidStyle::exclusiveIndicatorSize() const 1857QSize LiquidStyle::exclusiveIndicatorSize() const
1846{ 1858{
1847 return(QSize(16, 16)); 1859 return(QSize(16, 16));
1848} 1860}
1849 1861
1850void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, 1862void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1851 int /*h*/, const QColorGroup &/*g*/, bool on, 1863 int /*h*/, const QColorGroup &/*g*/, bool on,
1852 bool down, bool) 1864 bool down, bool)
1853{ 1865{
1854 bool isHover = highlightWidget == p->device(); 1866 bool isHover = highlightWidget == p->device();
1855 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1867 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1856 && ((QWidget*)p->device())->autoMask(); 1868 && ((QWidget*)p->device())->autoMask();
1857 1869
1858 if(isMasked){ 1870 if(isMasked){
1859 if(on || down){ 1871 if(on || down){
1860 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : 1872 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) :
1861 *getPixmap(HTMLRadioDown)); 1873 *getPixmap(HTMLRadioDown));
1862 } 1874 }
1863 else 1875 else
1864 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : 1876 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) :
1865 *getPixmap(HTMLRadio)); 1877 *getPixmap(HTMLRadio));
1866 1878
1867 } 1879 }
1868 else{ 1880 else{
1869 if(on || down){ 1881 if(on || down){
1870 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : 1882 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) :
1871 *getPixmap(RadioOn)); 1883 *getPixmap(RadioOn));
1872 } 1884 }
1873 else 1885 else
1874 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : 1886 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) :
1875 *getPixmap(RadioOff)); 1887 *getPixmap(RadioOff));
1876 } 1888 }
1877} 1889}
1878 1890
1879void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, 1891void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w,
1880 int h, bool) 1892 int h, bool)
1881{ 1893{
1882 p->fillRect(x, y, w, h, Qt::color0); 1894 p->fillRect(x, y, w, h, Qt::color0);
1883 p->setPen(Qt::color1); 1895 p->setPen(Qt::color1);
1884 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); 1896 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask());
1885} 1897}
1886 1898
1887 1899
1888QSize LiquidStyle::indicatorSize() const 1900QSize LiquidStyle::indicatorSize() const
1889{ 1901{
1890 return(QSize(20, 22)); 1902 return(QSize(20, 22));
1891} 1903}
1892 1904
1893void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1905void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1894 const QColorGroup &/*g*/, int state, bool /*down*/, bool) 1906 const QColorGroup &/*g*/, int state, bool /*down*/, bool)
1895{ 1907{
1896 bool isHover = highlightWidget == p->device(); 1908 bool isHover = highlightWidget == p->device();
1897 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1909 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1898 && ((QWidget*)p->device())->autoMask(); 1910 && ((QWidget*)p->device())->autoMask();
1899 if(isMasked){ 1911 if(isMasked){
1900 if(state != QButton::Off){ 1912 if(state != QButton::Off){
1901 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : 1913 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) :
1902 *getPixmap(HTMLCBDown)); 1914 *getPixmap(HTMLCBDown));
1903 } 1915 }
1904 else 1916 else
1905 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : 1917 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) :
1906 *getPixmap(HTMLCB)); 1918 *getPixmap(HTMLCB));
1907 1919
1908 } 1920 }
1909 else{ 1921 else{
1910 if(state != QButton::Off){ 1922 if(state != QButton::Off){
1911 p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : 1923 p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) :
1912 *getPixmap(CBDown)); 1924 *getPixmap(CBDown));
1913 /* Todo - tristate 1925 /* Todo - tristate
1914 if(state == QButton::On){ 1926 if(state == QButton::On){
1915 p->setPen(Qt::black); 1927 p->setPen(Qt::black);
1916 p->drawPixmap(3, 3, xBmp); 1928 p->drawPixmap(3, 3, xBmp);
1917 } 1929 }
1918 else{ 1930 else{
1919 p->setPen(g.dark()); 1931 p->setPen(g.dark());
1920 p->drawRect(x+2, y+2, w-4, h-4); 1932 p->drawRect(x+2, y+2, w-4, h-4);
1921 p->setPen(Qt::black); 1933 p->setPen(Qt::black);
1922 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); 1934 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2);
1923 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); 1935 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2);
1924 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); 1936 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2);
1925 }*/ 1937 }*/
1926 } 1938 }
1927 else 1939 else
1928 p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); 1940 p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB));
1929 } 1941 }
1930} 1942}
1931 1943
1932void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1944void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1933 int /*state*/) 1945 int /*state*/)
1934{ 1946{
1935 // needed for some reason by KHtml, even tho it's all filled ;P 1947 // needed for some reason by KHtml, even tho it's all filled ;P
1936 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); 1948 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask());
1937 1949
1938} 1950}
1939 1951
1940void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, 1952void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
1941 const QColorGroup &/*g*/, Orientation orient, 1953 const QColorGroup &/*g*/, Orientation orient,
1942 bool, bool) 1954 bool, bool)
1943{ 1955{
1944 QWidget *parent = (QWidget *)p->device(); 1956 QWidget *parent = (QWidget *)p->device();
1945 p->setBrushOrigin(parent->pos()); 1957 p->setBrushOrigin(parent->pos());
1946 parent->erase(x, y, w, h); 1958 parent->erase(x, y, w, h);
1947 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : 1959 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) :
1948 *getPixmap(VSlider)); 1960 *getPixmap(VSlider));
1949} 1961}
1950 1962
1951void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1963void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1952 Orientation orient, bool, bool) 1964 Orientation orient, bool, bool)
1953{ 1965{
1954 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : 1966 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() :
1955 *getPixmap(VSlider)->mask()); 1967 *getPixmap(VSlider)->mask());
1956} 1968}
1957 1969
1958int LiquidStyle::sliderLength() const 1970int LiquidStyle::sliderLength() const
1959{ 1971{
1960 return(10); 1972 return(10);
1961} 1973}
1962 1974
1963#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1975#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1964 1976
1965void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, 1977void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
1966 int y, int w, int h, const QColorGroup &g, 1978 int y, int w, int h, const QColorGroup &g,
1967 bool enabled, const QBrush *) 1979 bool enabled, const QBrush *)
1968{ 1980{
1969 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; 1981 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5};
1970 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; 1982 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6};
1971 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; 1983 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7};
1972 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; 1984 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4};
1973 1985
1974 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); 1986 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid());
1975 if(w > 8){ 1987 if(w > 8){
1976 x = x + (w-8)/2; 1988 x = x + (w-8)/2;
1977 y = y + (h-8)/2; 1989 y = y + (h-8)/2;
1978 } 1990 }
1979 1991
1980 QPointArray a; 1992 QPointArray a;
1981 switch(type){ 1993 switch(type){
1982 case Qt::UpArrow: 1994 case Qt::UpArrow:
1983 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); 1995 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow);
1984 break; 1996 break;
1985 case Qt::DownArrow: 1997 case Qt::DownArrow:
1986 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); 1998 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow);
1987 break; 1999 break;
1988 case Qt::LeftArrow: 2000 case Qt::LeftArrow:
1989 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); 2001 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow);
1990 break; 2002 break;
1991 default: 2003 default:
1992 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); 2004 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
1993 break; 2005 break;
1994 } 2006 }
1995 2007
1996 a.translate(x, y); 2008 a.translate(x, y);
1997 p->drawLineSegments(a); 2009 p->drawLineSegments(a);
1998} 2010}
1999 2011
2000 2012
2001void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, 2013void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
2002 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) 2014 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
2003 { 2015 {
2004 if(active){ 2016 if(active){
2005 x -= 2; // Bug in Qt/E 2017 x -= 2; // Bug in Qt/E
2006 y -= 2; 2018 y -= 2;
2007 w += 2; 2019 w += 2;
2008 h += 2; 2020 h += 2;
2009 } 2021 }
2010 2022
2011 QWidget *parent = (QWidget *)p->device(); 2023 QWidget *parent = (QWidget *)p->device();
2012 p->setBrushOrigin(parent->pos()); 2024 p->setBrushOrigin(parent->pos());
2013 parent->erase(x, y, w, h); 2025 parent->erase(x, y, w, h);
2014 2026
2015 if(menuHandler->useShadowText()){ 2027 if(menuHandler->useShadowText()){
2016 QColor shadow; 2028 QColor shadow;
2017 if(p->device() && p->device()->devType() == QInternal::Widget && 2029 if(p->device() && p->device()->devType() == QInternal::Widget &&
2018 ((QWidget *)p->device())->inherits("QMenuBar")){ 2030 ((QWidget *)p->device())->inherits("QMenuBar")){
2019 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : 2031 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
2020 g.background().dark(130); 2032 g.background().dark(130);
2021 } 2033 }
2022 else 2034 else
2023 shadow = g.background().dark(130); 2035 shadow = g.background().dark(130);
2024 2036
2025 if(active){ 2037 if(active){
2026 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2038 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2027 QApplication::style().drawItem(p, x+1, y+1, w, h, 2039 QApplication::style().drawItem(p, x+1, y+1, w, h,
2028 AlignCenter|ShowPrefix|DontClip|SingleLine, 2040 AlignCenter|ShowPrefix|DontClip|SingleLine,
2029 g, mi->isEnabled(), NULL, mi->text(), 2041 g, mi->isEnabled(), NULL, mi->text(),
2030 -1, &shadow); 2042 -1, &shadow);
2031 QApplication::style().drawItem(p, x, y, w, h, 2043 QApplication::style().drawItem(p, x, y, w, h,
2032 AlignCenter|ShowPrefix|DontClip|SingleLine, 2044 AlignCenter|ShowPrefix|DontClip|SingleLine,
2033 g, mi->isEnabled(), NULL, mi->text(), 2045 g, mi->isEnabled(), NULL, mi->text(),
2034 -1, &g.text()); 2046 -1, &g.text());
2035 } 2047 }
2036 else{ 2048 else{
2037 QApplication::style().drawItem(p, x+1, y+1, w, h, 2049 QApplication::style().drawItem(p, x+1, y+1, w, h,
2038 AlignCenter|ShowPrefix|DontClip|SingleLine, 2050 AlignCenter|ShowPrefix|DontClip|SingleLine,
2039 g, mi->isEnabled(), NULL, mi->text(), 2051 g, mi->isEnabled(), NULL, mi->text(),
2040 -1, &shadow); 2052 -1, &shadow);
2041 QApplication::style().drawItem(p, x, y, w, h, 2053 QApplication::style().drawItem(p, x, y, w, h,
2042 AlignCenter|ShowPrefix|DontClip|SingleLine, 2054 AlignCenter|ShowPrefix|DontClip|SingleLine,
2043 g, mi->isEnabled(), NULL, mi->text(), 2055 g, mi->isEnabled(), NULL, mi->text(),
2044 -1, &g.text()); 2056 -1, &g.text());
2045 } 2057 }
2046 } 2058 }
2047 else{ 2059 else{
2048 if(active) 2060 if(active)
2049 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2061 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2050 QApplication::style().drawItem(p, x, y, w, h, 2062 QApplication::style().drawItem(p, x, y, w, h,
2051 AlignCenter|ShowPrefix|DontClip|SingleLine, 2063 AlignCenter|ShowPrefix|DontClip|SingleLine,
2052 g, mi->isEnabled(), NULL, mi->text(), 2064 g, mi->isEnabled(), NULL, mi->text(),
2053 -1, &g.text()); 2065 -1, &g.text());
2054 } 2066 }
2055} 2067}
2056 2068
2057void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, 2069void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h,
2058 const QColorGroup &g, int /*lineWidth*/, 2070 const QColorGroup &g, int /*lineWidth*/,
2059 const QBrush * /*fill*/) 2071 const QBrush * /*fill*/)
2060{ 2072{
2061 QColor c; 2073 QColor c;
2062 switch(menuHandler->transType()){ 2074 switch(menuHandler->transType()){
2063 case None: 2075 case None:
2064 case StippledBg: 2076 case StippledBg:
2065 case TransStippleBg: 2077 case TransStippleBg:
2066 c = g.background(); 2078 c = g.background();
2067 break; 2079 break;
2068 case StippledBtn: 2080 case StippledBtn:
2069 case TransStippleBtn: 2081 case TransStippleBtn:
2070 c = g.button(); 2082 c = g.button();
2071 break; 2083 break;
2072 default: 2084 default:
2073 c = menuHandler->bgColor(); 2085 c = menuHandler->bgColor();
2074 } 2086 }
2075 p->setPen(c.dark(140)); 2087 p->setPen(c.dark(140));
2076 p->drawRect(x, y, w, h); 2088 p->drawRect(x, y, w, h);
2077 p->setPen(c.light(120)); 2089 p->setPen(c.light(120));
2078 p->drawRect(x+1, y+1, w-2, h-2); 2090 p->drawRect(x+1, y+1, w-2, h-2);
2079} 2091}
2080 2092
2081void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 2093void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
2082 int tab, QMenuItem* mi, 2094 int tab, QMenuItem* mi,
2083 const QPalette& pal, bool act, 2095 const QPalette& pal, bool act,
2084 bool enabled, int x, int y, int w, int h) 2096 bool enabled, int x, int y, int w, int h)
2085{ 2097{
2086static const int motifItemFrame = 2; 2098static const int motifItemFrame = 2;
2087static const int motifItemHMargin = 3; 2099static const int motifItemHMargin = 3;
2088static const int motifItemVMargin = 2; 2100static const int motifItemVMargin = 2;
2089static const int motifArrowHMargin = 6; 2101static const int motifArrowHMargin = 6;
2090static const int windowsRightBorder = 12; 2102static const int windowsRightBorder = 12;
2091 2103
2092 maxpmw = QMAX( maxpmw, 20 ); 2104 maxpmw = QMAX( maxpmw, 20 );
2093 2105
2094 2106
2095 bool dis = !enabled; 2107 bool dis = !enabled;
2096 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 2108 QColorGroup itemg = dis ? pal.disabled() : pal.active();
2097 2109
2098 int checkcol = maxpmw; 2110 int checkcol = maxpmw;
2099 if(act){ 2111 if(act){
2100 2112
2101 // FIXME 2113 // FIXME
2102 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); 2114 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background());
2103 } 2115 }
2104 //else if(((QWidget*)p->device())->backgroundPixmap()){ 2116 //else if(((QWidget*)p->device())->backgroundPixmap()){
2105 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), 2117 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(),
2106 // x, y, w, h); 2118 // x, y, w, h);
2107 //} 2119 //}
2108 else{ 2120 else{
2109 if(menuHandler->transType() == None){ 2121 if(menuHandler->transType() == None){
2110 p->fillRect(x, y, w, h, pal.active().background()); 2122 p->fillRect(x, y, w, h, pal.active().background());
2111 } 2123 }
2112 else if(menuHandler->transType() == StippledBg){ 2124 else if(menuHandler->transType() == StippledBg){
2113 p->fillRect(x, y, w, h, bgBrush); 2125 p->fillRect(x, y, w, h, bgBrush);
2114 } 2126 }
2115 else if(menuHandler->transType() == StippledBtn){ 2127 else if(menuHandler->transType() == StippledBtn){
2116 p->fillRect(x, y, w, h, menuBrush); 2128 p->fillRect(x, y, w, h, menuBrush);
2117 } 2129 }
2118 else{ 2130 else{
2119 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); 2131 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId());
2120 if(pix) 2132 if(pix)
2121 p->drawPixmap(x, y, *pix, x, y, w, h); 2133 p->drawPixmap(x, y, *pix, x, y, w, h);
2122 } 2134 }
2123 } 2135 }
2124 2136
2125 if(!mi) 2137 if(!mi)
2126 return; 2138 return;
2127 2139
2128 QColor discol; 2140 QColor discol;
2129 if (dis) { 2141 if (dis) {
2130 discol = itemg.mid(); 2142 discol = itemg.mid();
2131 p->setPen(discol); 2143 p->setPen(discol);
2132 } 2144 }
2133 2145
2134 QColorGroup cg2(itemg); 2146 QColorGroup cg2(itemg);
2135 2147
2136 if(menuHandler->transType() == Custom){ 2148 if(menuHandler->transType() == Custom){
2137 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); 2149 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor());
2138 cg2.setColor(QColorGroup::Text, menuHandler->textColor()); 2150 cg2.setColor(QColorGroup::Text, menuHandler->textColor());
2139 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); 2151 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120));
2140 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); 2152 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120));
2141 } 2153 }
2142 else{ 2154 else{
2143 cg2 = QColorGroup(discol, itemg.highlight(), black, black, 2155 cg2 = QColorGroup(discol, itemg.highlight(), black, black,
2144 dis ? discol : black, discol, black); 2156 dis ? discol : black, discol, black);
2145 } 2157 }
2146 2158
2147 if(mi->isSeparator()){ 2159 if(mi->isSeparator()){
2148 QColor c; 2160 QColor c;
2149 switch(menuHandler->transType()){ 2161 switch(menuHandler->transType()){
2150 case None: 2162 case None:
2151 case StippledBg: 2163 case StippledBg:
2152 case TransStippleBg: 2164 case TransStippleBg:
2153 c = QApplication::palette().active().background(); 2165 c = QApplication::palette().active().background();
2154 break; 2166 break;
2155 case StippledBtn: 2167 case StippledBtn:
2156 case TransStippleBtn: 2168 case TransStippleBtn:
2157 c = QApplication::palette().active().button(); 2169 c = QApplication::palette().active().button();
2158 break; 2170 break;
2159 default: 2171 default:
2160 c = menuHandler->bgColor(); 2172 c = menuHandler->bgColor();
2161 } 2173 }
2162 p->setPen(c.dark(140)); 2174 p->setPen(c.dark(140));
2163 p->drawLine(x, y, x+w, y ); 2175 p->drawLine(x, y, x+w, y );
2164 p->setPen(c.light(115)); 2176 p->setPen(c.light(115));
2165 p->drawLine(x, y+1, x+w, y+1 ); 2177 p->drawLine(x, y+1, x+w, y+1 );
2166 return; 2178 return;
2167 } 2179 }
2168 if(mi->iconSet()) { 2180 if(mi->iconSet()) {
2169 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; 2181 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
2170 if (!dis) 2182 if (!dis)
2171 mode = QIconSet::Active; 2183 mode = QIconSet::Active;
2172 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); 2184 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
2173 int pixw = pixmap.width(); 2185 int pixw = pixmap.width();
2174 int pixh = pixmap.height(); 2186 int pixh = pixmap.height();
2175 QRect cr(x, y, checkcol, h); 2187 QRect cr(x, y, checkcol, h);
2176 QRect pmr(0, 0, pixw, pixh); 2188 QRect pmr(0, 0, pixw, pixh);
2177 pmr.moveCenter( cr.center() ); 2189 pmr.moveCenter( cr.center() );
2178 p->setPen(itemg.highlightedText()); 2190 p->setPen(itemg.highlightedText());
2179 p->drawPixmap(pmr.topLeft(), pixmap ); 2191 p->drawPixmap(pmr.topLeft(), pixmap );
2180 2192
2181 } 2193 }
2182 else if(checkable) { 2194 else if(checkable) {
2183 int mw = checkcol + motifItemFrame; 2195 int mw = checkcol + motifItemFrame;
2184 int mh = h - 2*motifItemFrame; 2196 int mh = h - 2*motifItemFrame;
2185 if (mi->isChecked()){ 2197 if (mi->isChecked()){
2186 drawCheckMark( p, x + motifItemFrame, 2198 drawCheckMark( p, x + motifItemFrame,
2187 y+motifItemFrame, mw, mh, cg2, act, dis ); 2199 y+motifItemFrame, mw, mh, cg2, act, dis );
2188 } 2200 }
2189 } 2201 }
2190 if(menuHandler->transType() == Custom) 2202 if(menuHandler->transType() == Custom)
2191 p->setPen(menuHandler->textColor()); 2203 p->setPen(menuHandler->textColor());
2192 else 2204 else
2193 p->setPen(itemg.text()); 2205 p->setPen(itemg.text());
2194 2206
2195 2207
2196 int xm = motifItemFrame + checkcol + motifItemHMargin; 2208 int xm = motifItemFrame + checkcol + motifItemHMargin;
2197 QString s = mi->text(); 2209 QString s = mi->text();
2198 if (!s.isNull()) { 2210 if (!s.isNull()) {
2199 int t = s.find( '\t' ); 2211 int t = s.find( '\t' );
2200 int m = motifItemVMargin; 2212 int m = motifItemVMargin;
2201 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 2213 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
2202 QPen oldPen = p->pen(); 2214 QPen oldPen = p->pen();
2203 if(menuHandler->useShadowText()){ 2215 if(menuHandler->useShadowText()){
2204 if(menuHandler->transType() == Custom) 2216 if(menuHandler->transType() == Custom)
2205 p->setPen(menuHandler->bgColor().dark(130)); 2217 p->setPen(menuHandler->bgColor().dark(130));
2206 else if(menuHandler->transType() == StippledBtn || 2218 else if(menuHandler->transType() == StippledBtn ||
2207 menuHandler->transType() == TransStippleBtn) 2219 menuHandler->transType() == TransStippleBtn)
2208 p->setPen(itemg.button().dark(130)); 2220 p->setPen(itemg.button().dark(130));
2209 else 2221 else
2210 p->setPen(bgBrush.color().dark(130)); 2222 p->setPen(bgBrush.color().dark(130));
2211 2223
2212 if (t >= 0) { 2224 if (t >= 0) {
2213 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, 2225 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2,
2214 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); 2226 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 ));
2215 } 2227 }
2216 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); 2228 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t);
2217 } 2229 }
2218 p->setPen(oldPen); 2230 p->setPen(oldPen);
2219 if (t >= 0) { 2231 if (t >= 0) {
2220 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 2232 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
2221 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 2233 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
2222 } 2234 }
2223 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); 2235 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t);
2224 2236
2225 } 2237 }
2226 else if (mi->pixmap()) { 2238 else if (mi->pixmap()) {
2227 QPixmap *pixmap = mi->pixmap(); 2239 QPixmap *pixmap = mi->pixmap();
2228 if (pixmap->depth() == 1) 2240 if (pixmap->depth() == 1)
2229 p->setBackgroundMode(OpaqueMode); 2241 p->setBackgroundMode(OpaqueMode);
2230 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); 2242 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap);
2231 if (pixmap->depth() == 1) 2243 if (pixmap->depth() == 1)
2232 p->setBackgroundMode(TransparentMode); 2244 p->setBackgroundMode(TransparentMode);
2233 } 2245 }
2234 if (mi->popup()) { 2246 if (mi->popup()) {
2235 int dim = (h-2*motifItemFrame) / 2; 2247 int dim = (h-2*motifItemFrame) / 2;
2236 drawArrow(p, RightArrow, true, 2248 drawArrow(p, RightArrow, true,
2237 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 2249 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
2238 dim, dim, cg2, TRUE); 2250 dim, dim, cg2, TRUE);
2239 } 2251 }
2240} 2252}
2241 2253
2242int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, 2254int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
2243 const QFontMetrics &fm) 2255 const QFontMetrics &fm)
2244{ 2256{
2245 if (mi->isSeparator()) 2257 if (mi->isSeparator())
2246 return 2; 2258 return 2;
2247 2259
2248 int h = 0; 2260 int h = 0;
2249 if (mi->pixmap()) 2261 if (mi->pixmap())
2250 h = mi->pixmap()->height(); 2262 h = mi->pixmap()->height();
2251 2263
2252 if (mi->iconSet()) 2264 if (mi->iconSet())
2253 h = QMAX(mi->iconSet()-> 2265 h = QMAX(mi->iconSet()->
2254 pixmap(QIconSet::Small, QIconSet::Normal).height(), h); 2266 pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
2255 2267
2256 h = QMAX(fm.height() + 4, h); 2268 h = QMAX(fm.height() + 4, h);
2257 2269
2258 // we want a minimum size of 18 2270 // we want a minimum size of 18
2259 h = QMAX(h, 18); 2271 h = QMAX(h, 18);
2260 2272
2261 return h; 2273 return h;
2262} 2274}
2263 2275
2264 2276
2265void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, 2277void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
2266 const QColorGroup &g, const QColor *c, 2278 const QColorGroup &g, const QColor *c,
2267 bool atBorder) 2279 bool atBorder)
2268{ 2280{
2269 // are we painting a widget? 2281 // are we painting a widget?
2270 if(p->device()->devType() == QInternal::Widget){ 2282 if(p->device()->devType() == QInternal::Widget){
2271 // if so does it use a special focus rectangle? 2283 // if so does it use a special focus rectangle?
2272 QWidget *w = (QWidget *)p->device(); 2284 QWidget *w = (QWidget *)p->device();
2273 if(w->inherits("QPushButton") || w->inherits("QSlider")){ 2285 if(w->inherits("QPushButton") || w->inherits("QSlider")){
2274 return; 2286 return;
2275 } 2287 }
2276 else{ 2288 else{
2277 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); 2289 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
2278 } 2290 }
2279 } 2291 }
2280 else 2292 else
2281 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); 2293 QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
2282 2294
2283} 2295}
2284 2296
2285void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) 2297void LiquidStyle::polishPopupMenu(QPopupMenu *mnu)
2286{ 2298{
2287 mnu->installEventFilter(menuHandler); 2299 mnu->installEventFilter(menuHandler);
2288 QWindowsStyle::polishPopupMenu(mnu); 2300 QWindowsStyle::polishPopupMenu(mnu);
2289} 2301}
2290 2302
2291void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, 2303void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab,
2292 bool selected) 2304 bool selected)
2293{ 2305{
2294 if(tabBar->shape() != QTabBar::RoundedAbove){ 2306 if(tabBar->shape() != QTabBar::RoundedAbove){
2295 QWindowsStyle::drawTab(p, tabBar, tab, selected); 2307 QWindowsStyle::drawTab(p, tabBar, tab, selected);
2296 return; 2308 return;
2297 } 2309 }
2298 QPixmap tilePix; 2310 QPixmap tilePix;
2299 QRect r = tab->rect(); 2311 QRect r = tab->rect();
2300 //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : 2312 //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] :
2301 // pixmaps[TabDown] : pixmaps[Tab]; 2313 // pixmaps[TabDown] : pixmaps[Tab];
2302 2314
2303 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); 2315 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
2304 p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); 2316 p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height());
2305 p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); 2317 p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height());
2306 tilePix.resize(pix->width()-18, r.height()); 2318 tilePix.resize(pix->width()-18, r.height());
2307 bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); 2319 bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height());
2308 p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); 2320 p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix);
2309 QColor c = tabBar->colorGroup().button(); 2321 QColor c = tabBar->colorGroup().button();
2310 if(!selected){ 2322 if(!selected){
2311 p->setPen(c.dark(130)); 2323 p->setPen(c.dark(130));
2312 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); 2324 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
2313 } 2325 }
2314 2326
2315 /* 2327 /*
2316 p->setPen(c.light(110)); 2328 p->setPen(c.light(110));
2317 p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); 2329 p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1);
2318 p->setPen(c); 2330 p->setPen(c);
2319 p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); 2331 p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2);
2320 p->setPen(c.light(110)); 2332 p->setPen(c.light(110));
2321 p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); 2333 p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3);
2322 p->setPen(c.light(120)); 2334 p->setPen(c.light(120));
2323 p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); 2335 p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4);
2324 */ 2336 */
2325 2337
2326 /* 2338 /*
2327 QColor c = tabBar->colorGroup().button(); 2339 QColor c = tabBar->colorGroup().button();
2328 pix = bevelFillDict.find(c.rgb()); 2340 pix = bevelFillDict.find(c.rgb());
2329 if(!pix){ 2341 if(!pix){
2330 int h, s, v; 2342 int h, s, v;
2331 c.hsv(&h, &s, &v); 2343 c.hsv(&h, &s, &v);
2332 pix = new QPixmap(*bevelFillPix); 2344 pix = new QPixmap(*bevelFillPix);
2333 adjustHSV(*pix, h, s); 2345 adjustHSV(*pix, h, s);
2334 bevelFillDict.insert(c.rgb(), pix); 2346 bevelFillDict.insert(c.rgb(), pix);
2335 }*/ 2347 }*/
2336 2348
2337 /* 2349 /*
2338 QRect r = tab->rect(); 2350 QRect r = tab->rect();
2339 QColorGroup g = tabBar->colorGroup(); 2351 QColorGroup g = tabBar->colorGroup();
2340 if(!selected){ 2352 if(!selected){
2341 r.setY(r.y()+1); 2353 r.setY(r.y()+1);
2342 p->setPen(g.dark()); 2354 p->setPen(g.dark());
2343 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); 2355 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2);
2344 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); 2356 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
2345 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); 2357 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
2346 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); 2358 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2);
2347 2359
2348 p->setPen(g.midlight()); 2360 p->setPen(g.midlight());
2349 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); 2361 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
2350 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); 2362 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
2351 p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); 2363 p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1);
2352 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); 2364 p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
2353 2365
2354 p->setPen(g.mid()); 2366 p->setPen(g.mid());
2355 p->drawPoint(r.right()-1, r.y()+1); 2367 p->drawPoint(r.right()-1, r.y()+1);
2356 p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); 2368 p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2);
2357 p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); 2369 p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3);
2358 2370
2359 p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, 2371 p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6,
2360 g.brush(QColorGroup::Mid)); 2372 g.brush(QColorGroup::Mid));
2361 2373
2362 p->setPen(g.light()); 2374 p->setPen(g.light());
2363 p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); 2375 p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1);
2364 2376
2365 } 2377 }
2366 else{ 2378 else{
2367 p->setPen(g.light()); 2379 p->setPen(g.light());
2368 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); 2380 p->drawLine(r.x(), r.y()+4, r.x(), r.bottom());
2369 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); 2381 p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
2370 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); 2382 p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
2371 p->setPen(g.dark()); 2383 p->setPen(g.dark());
2372 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); 2384 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom());
2373 2385
2374 p->setPen(g.midlight()); 2386 p->setPen(g.midlight());
2375 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); 2387 p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
2376 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); 2388 p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
2377 p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); 2389 p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1);
2378 p->setPen(g.mid()); 2390 p->setPen(g.mid());
2379 p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); 2391 p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom());
2380 }*/ 2392 }*/
2381 2393
2382} 2394}
2383 2395
2384 2396
2385 2397
2386void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, 2398void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab,
2387 bool selected) 2399 bool selected)
2388 2400
2389 2401
2390{ 2402{
2391 //p->fillRect(tab->rect(), Qt::color1); 2403 //p->fillRect(tab->rect(), Qt::color1);
2392 QRect r = tab->rect(); 2404 QRect r = tab->rect();
2393 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); 2405 QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
2394 p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); 2406 p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height());
2395 p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); 2407 p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height());
2396 p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); 2408 p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1);
2397} 2409}
2398 2410
2399void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, 2411void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame,
2400 int &overlap) 2412 int &overlap)
2401{ 2413{
2402 if(t->shape() == QTabBar::RoundedAbove){ 2414 if(t->shape() == QTabBar::RoundedAbove){
2403 overlap = 1; 2415 overlap = 1;
2404 hFrame = 18; // was 24 2416 hFrame = 18; // was 24
2405 vFrame = 8; // was 10 2417 vFrame = 8; // was 10
2406 } 2418 }
2407 else 2419 else
2408 QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); 2420 QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap);
2409} 2421}
2410 2422
2411 2423
2412 2424
2413void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, 2425void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h,
2414 const QColorGroup &g, Orientation) 2426 const QColorGroup &g, Orientation)
2415{ 2427{
2416 drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? 2428 drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ?
2417 g.button().light(120) : g.button(), g.background()); 2429 g.button().light(120) : g.button(), g.background());
2418} 2430}
2419 2431
2420 2432
2421void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, 2433void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
2422 const QColorGroup &g, bool sunken, 2434 const QColorGroup &g, bool sunken,
2423 int lineWidth, const QBrush *fill) 2435 int lineWidth, const QBrush *fill)
2424{ 2436{
2425 if(p->device()->devType() == QInternal::Widget && 2437 if(p->device()->devType() == QInternal::Widget &&
2426 ((QWidget *)p->device())->inherits("QLineEdit")){ 2438 ((QWidget *)p->device())->inherits("QLineEdit")){
2427 int x2 = x+w-1; 2439 int x2 = x+w-1;
2428 int y2 = y+h-1; 2440 int y2 = y+h-1;
2429 p->setPen(g.dark()); 2441 p->setPen(g.dark());
2430 p->drawRect(x, y, w, h); 2442 p->drawRect(x, y, w, h);
2431 p->setPen(g.mid()); 2443 p->setPen(g.mid());
2432 p->drawLine(x+1, y+1, x2-2, y+1); 2444 p->drawLine(x+1, y+1, x2-2, y+1);
2433 p->drawLine(x+1, y+1, x+1, y2-1); 2445 p->drawLine(x+1, y+1, x+1, y2-1);
2434 } 2446 }
2435 else if(lineWidth != 2 || !sunken) 2447 else if(lineWidth != 2 || !sunken)
2436 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); 2448 QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill);
2437 else{ 2449 else{
2438 QPen oldPen = p->pen(); 2450 QPen oldPen = p->pen();
2439 int x2 = x+w-1; 2451 int x2 = x+w-1;
2440 int y2 = y+h-1; 2452 int y2 = y+h-1;
2441 p->setPen(g.light()); 2453 p->setPen(g.light());
2442 p->drawLine(x, y2, x2, y2); 2454 p->drawLine(x, y2, x2, y2);
2443 p->drawLine(x2, y, x2, y2); 2455 p->drawLine(x2, y, x2, y2);
2444 p->setPen(g.mid()); 2456 p->setPen(g.mid());
2445 p->drawLine(x, y, x2, y); 2457 p->drawLine(x, y, x2, y);
2446 p->drawLine(x, y, x, y2); 2458 p->drawLine(x, y, x, y2);
2447 2459
2448 p->setPen(g.midlight()); 2460 p->setPen(g.midlight());
2449 p->drawLine(x+1, y2-1, x2-1, y2-1); 2461 p->drawLine(x+1, y2-1, x2-1, y2-1);
2450 p->drawLine(x2-1, y+1, x2-1, y2-1); 2462 p->drawLine(x2-1, y+1, x2-1, y2-1);
2451 p->setPen(g.dark()); 2463 p->setPen(g.dark());
2452 p->drawLine(x+1, y+1, x2-1, y+1); 2464 p->drawLine(x+1, y+1, x2-1, y+1);
2453 p->drawLine(x+1, y+1, x+1, y2-1); 2465 p->drawLine(x+1, y+1, x+1, y2-1);
2454 p->setPen(oldPen); 2466 p->setPen(oldPen);
2455 if(fill){ 2467 if(fill){
2456 // I believe here we are only supposed to fill if there is a 2468 // I believe here we are only supposed to fill if there is a
2457 // specified fill brush... 2469 // specified fill brush...
2458 p->fillRect(x+2, y+2, w-4, h-4, *fill); 2470 p->fillRect(x+2, y+2, w-4, h-4, *fill);
2459 } 2471 }
2460 } 2472 }
2461} 2473}
2462 2474
2463 2475
2464void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) 2476void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
2465{ 2477{
2466 QBitmap *maskBmp = NULL; 2478 QBitmap *maskBmp = NULL;
2467 if(pix.mask()) 2479 if(pix.mask())
2468 maskBmp = new QBitmap(*pix.mask()); 2480 maskBmp = new QBitmap(*pix.mask());
2469 QImage img = pix.convertToImage(); 2481 QImage img = pix.convertToImage();
2470 if(img.depth() != 32) 2482 if(img.depth() != 32)
2471 img = img.convertDepth(32); 2483 img = img.convertDepth(32);
2472 unsigned int *data = (unsigned int *)img.bits(); 2484 unsigned int *data = (unsigned int *)img.bits();
2473 int total = img.width()*img.height(); 2485 int total = img.width()*img.height();
2474 int current; 2486 int current;
2475 QColor c; 2487 QColor c;
2476 int oldH, oldS, oldV; 2488 int oldH, oldS, oldV;
2477 if(v < 235) 2489 if(v < 235)
2478 v += 20; 2490 v += 20;
2479 else 2491 else
2480 v = 255; 2492 v = 255;
2481 float intensity = v/255.0; 2493 float intensity = v/255.0;
2482 2494
2483 for(current=0; current<total; ++current){ 2495 for(current=0; current<total; ++current){
2484 c.setRgb(data[current]); 2496 c.setRgb(data[current]);
2485 c.hsv(&oldH, &oldS, &oldV); 2497 c.hsv(&oldH, &oldS, &oldV);
2486 oldV = (int)(oldV*intensity); 2498 oldV = (int)(oldV*intensity);
2487 c.setHsv(h, s, oldV); 2499 c.setHsv(h, s, oldV);
2488 data[current] = c.rgb(); 2500 data[current] = c.rgb();
2489 } 2501 }
2490 pix.convertFromImage(img); 2502 pix.convertFromImage(img);
2491 if(maskBmp) 2503 if(maskBmp)
2492 pix.setMask(*maskBmp); 2504 pix.setMask(*maskBmp);
2493} 2505}
2494 2506
2495void LiquidStyle::intensity(QPixmap &pix, float percent) 2507void LiquidStyle::intensity(QPixmap &pix, float percent)
2496{ 2508{
2497 QImage image = pix.convertToImage(); 2509 QImage image = pix.convertToImage();
2498 int i, tmp, r, g, b; 2510 int i, tmp, r, g, b;
2499 int segColors = image.depth() > 8 ? 256 : image.numColors(); 2511 int segColors = image.depth() > 8 ? 256 : image.numColors();
2500 unsigned char *segTbl = new unsigned char[segColors]; 2512 unsigned char *segTbl = new unsigned char[segColors];
2501 int pixels = image.depth() > 8 ? image.width()*image.height() : 2513 int pixels = image.depth() > 8 ? image.width()*image.height() :
2502 image.numColors(); 2514 image.numColors();
2503 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 2515 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
2504 (unsigned int *)image.colorTable(); 2516 (unsigned int *)image.colorTable();
2505 2517
2506 bool brighten = (percent >= 0); 2518 bool brighten = (percent >= 0);
2507 if(percent < 0) 2519 if(percent < 0)
2508 percent = -percent; 2520 percent = -percent;
2509 2521
2510 if(brighten){ // keep overflow check out of loops 2522 if(brighten){ // keep overflow check out of loops
2511 for(i=0; i < segColors; ++i){ 2523 for(i=0; i < segColors; ++i){
2512 tmp = (int)(i*percent); 2524 tmp = (int)(i*percent);
2513 if(tmp > 255) 2525 if(tmp > 255)
2514 tmp = 255; 2526 tmp = 255;
2515 segTbl[i] = tmp; 2527 segTbl[i] = tmp;
2516 } 2528 }
2517 } 2529 }
2518 else{ 2530 else{
2519 for(i=0; i < segColors; ++i){ 2531 for(i=0; i < segColors; ++i){
2520 tmp = (int)(i*percent); 2532 tmp = (int)(i*percent);
2521 if(tmp < 0) 2533 if(tmp < 0)
2522 tmp = 0; 2534 tmp = 0;
2523 segTbl[i] = tmp; 2535 segTbl[i] = tmp;
2524 } 2536 }
2525 } 2537 }
2526 2538
2527 if(brighten){ // same here 2539 if(brighten){ // same here
2528 for(i=0; i < pixels; ++i){ 2540 for(i=0; i < pixels; ++i){
2529 r = qRed(data[i]); 2541 r = qRed(data[i]);
2530 g = qGreen(data[i]); 2542 g = qGreen(data[i]);
2531 b = qBlue(data[i]); 2543 b = qBlue(data[i]);
2532 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 2544 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
2533 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 2545 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
2534 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 2546 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
2535 data[i] = qRgb(r, g, b); 2547 data[i] = qRgb(r, g, b);
2536 } 2548 }
2537 } 2549 }
2538 else{ 2550 else{
2539 for(i=0; i < pixels; ++i){ 2551 for(i=0; i < pixels; ++i){
2540 r = qRed(data[i]); 2552 r = qRed(data[i]);
2541 g = qGreen(data[i]); 2553 g = qGreen(data[i]);
2542 b = qBlue(data[i]); 2554 b = qBlue(data[i]);
2543 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; 2555 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
2544 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; 2556 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
2545 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; 2557 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
2546 data[i] = qRgb(r, g, b); 2558 data[i] = qRgb(r, g, b);
2547 } 2559 }
2548 } 2560 }
2549 delete [] segTbl; 2561 delete [] segTbl;
2550 pix.convertFromImage(image); 2562 pix.convertFromImage(image);
2551} 2563}
2552 2564
2553void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) 2565void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h)
2554{ 2566{
2555 int x2 = x+w-1; 2567 int x2 = x+w-1;
2556 int y2 = y+h-1; 2568 int y2 = y+h-1;
2557 p->drawLine(x+1, y, x2-1, y); 2569 p->drawLine(x+1, y, x2-1, y);
2558 p->drawLine(x, y+1, x, y2-1); 2570 p->drawLine(x, y+1, x, y2-1);
2559 p->drawLine(x+1, y2, x2-1, y2); 2571 p->drawLine(x+1, y2, x2-1, y2);
2560 p->drawLine(x2, y+1, x2, y2-1); 2572 p->drawLine(x2, y+1, x2, y2-1);
2561} 2573}
2562 2574
2563void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, 2575void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h,
2564 const QColorGroup &g, QCOORD, 2576 const QColorGroup &g, QCOORD,
2565 Orientation orient) 2577 Orientation orient)
2566{ 2578{
2567 bool isFocus = ((QWidget *)p->device())->hasFocus(); 2579 bool isFocus = ((QWidget *)p->device())->hasFocus();
2568 QColor c = isFocus ? g.background().dark(120) : g.background(); 2580 QColor c = isFocus ? g.background().dark(120) : g.background();
2569 if(orient == Qt::Horizontal){ 2581 if(orient == Qt::Horizontal){
2570 int x2 = x+w-1; 2582 int x2 = x+w-1;
2571 y+=2; 2583 y+=2;
2572 p->setPen(c.dark(130)); 2584 p->setPen(c.dark(130));
2573 p->drawLine(x+1, y, x2-1, y); 2585 p->drawLine(x+1, y, x2-1, y);
2574 p->setPen(c.dark(150)); 2586 p->setPen(c.dark(150));
2575 p->drawLine(x, y+1, x2, y+1); 2587 p->drawLine(x, y+1, x2, y+1);
2576 p->setPen(c.dark(125)); 2588 p->setPen(c.dark(125));
2577 p->drawLine(x, y+2, x2, y+2); 2589 p->drawLine(x, y+2, x2, y+2);
2578 p->setPen(c.dark(130)); 2590 p->setPen(c.dark(130));
2579 p->drawLine(x, y+3, x2, y+3); 2591 p->drawLine(x, y+3, x2, y+3);
2580 p->setPen(c.dark(120)); 2592 p->setPen(c.dark(120));
2581 p->drawLine(x, y+4, x2, y+4); 2593 p->drawLine(x, y+4, x2, y+4);
2582 p->setPen(c.light(110)); 2594 p->setPen(c.light(110));
2583 p->drawLine(x+1, y+5, x2-1, y+5); 2595 p->drawLine(x+1, y+5, x2-1, y+5);
2584 } 2596 }
2585 else{ 2597 else{
2586 int y2 = y+h-1; 2598 int y2 = y+h-1;
2587 x+=2; 2599 x+=2;
2588 p->setPen(c.dark(130)); 2600 p->setPen(c.dark(130));
2589 p->drawLine(x, y+1, x, y2-1); 2601 p->drawLine(x, y+1, x, y2-1);
2590 p->setPen(c.dark(150)); 2602 p->setPen(c.dark(150));
2591 p->drawLine(x+1, y, x+1, y2); 2603 p->drawLine(x+1, y, x+1, y2);
2592 p->setPen(c.dark(125)); 2604 p->setPen(c.dark(125));
2593 p->drawLine(x+2, y, x+2, y2); 2605 p->drawLine(x+2, y, x+2, y2);
2594 p->setPen(c.dark(130)); 2606 p->setPen(c.dark(130));
2595 p->drawLine(x+3, y, x+3, y2); 2607 p->drawLine(x+3, y, x+3, y2);
2596 p->setPen(c.dark(120)); 2608 p->setPen(c.dark(120));
2597 p->drawLine(x+4, y, x+4, y2); 2609 p->drawLine(x+4, y, x+4, y2);
2598 p->setPen(c.light(110)); 2610 p->setPen(c.light(110));
2599 p->drawLine(x+5, y+1, x+5, y2-1); 2611 p->drawLine(x+5, y+1, x+5, y2-1);
2600 } 2612 }
2601 //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); 2613 //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient);
2602 2614
2603} 2615}
2604 2616
2605void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, 2617void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w,
2606 int h, QCOORD, Orientation orient) 2618 int h, QCOORD, Orientation orient)
2607{ 2619{
2608 p->fillRect(x, y, w, h, Qt::color0); 2620 p->fillRect(x, y, w, h, Qt::color0);
2609 p->setPen(Qt::color1); 2621 p->setPen(Qt::color1);
2610 if(orient == Qt::Horizontal){ 2622 if(orient == Qt::Horizontal){
2611 int x2 = x+w-1; 2623 int x2 = x+w-1;
2612 y+=2; 2624 y+=2;
2613 p->drawLine(x+1, y, x2-1, y); 2625 p->drawLine(x+1, y, x2-1, y);
2614 p->fillRect(x, y+1, w, 4, Qt::color1); 2626 p->fillRect(x, y+1, w, 4, Qt::color1);
2615 p->drawLine(x+1, y+5, x2-1, y+5); 2627 p->drawLine(x+1, y+5, x2-1, y+5);
2616 } 2628 }
2617 else{ 2629 else{
2618 int y2 = y+h-1; 2630 int y2 = y+h-1;
2619 x+=2; 2631 x+=2;
2620 p->drawLine(x, y+1, x, y2-1); 2632 p->drawLine(x, y+1, x, y2-1);
2621 p->fillRect(x+1, y, 4, h, Qt::color1); 2633 p->fillRect(x+1, y, 4, h, Qt::color1);
2622 p->drawLine(x+5, y+1, x+5, y2-1); 2634 p->drawLine(x+5, y+1, x+5, y2-1);
2623 } 2635 }
2624} 2636}
2625 2637
2626// I'm debating if to use QValueList or QList here. I like QValueList better, 2638// I'm debating if to use QValueList or QList here. I like QValueList better,
2627// but QList handles pointers which is good for a lot of empty icons... 2639// but QList handles pointers which is good for a lot of empty icons...
2628 2640
2629void LiquidStyle::loadCustomButtons() 2641void LiquidStyle::loadCustomButtons()
2630{ 2642{
2631 return; // TODO 2643 return; // TODO
2632 customBtnColorList.clear(); 2644 customBtnColorList.clear();
2633 customBtnIconList.clear(); 2645 customBtnIconList.clear();
2634 customBtnLabelList.clear(); 2646 customBtnLabelList.clear();
2635 2647
2636// KConfig *config = KGlobal::config(); 2648// KConfig *config = KGlobal::config();
2637// QString oldGrp = config->group(); 2649// QString oldGrp = config->group();
2638// config->setGroup("MosfetButtons"); 2650// config->setGroup("MosfetButtons");
2639 2651
2640 QStrList iconList, colorList; //temp, we store QPixmaps and QColors 2652 QStrList iconList, colorList; //temp, we store QPixmaps and QColors
2641 iconList.setAutoDelete(true); 2653 iconList.setAutoDelete(true);
2642 colorList.setAutoDelete(true); 2654 colorList.setAutoDelete(true);
2643// config->readListEntry("Labels", customBtnLabelList); 2655// config->readListEntry("Labels", customBtnLabelList);
2644// config->readListEntry("Icons", iconList); 2656// config->readListEntry("Icons", iconList);
2645// config->readListEntry("Colors", colorList); 2657// config->readListEntry("Colors", colorList);
2646 2658
2647 const char *labelStr = customBtnLabelList.first(); 2659 const char *labelStr = customBtnLabelList.first();
2648 const char *colorStr = colorList.first(); 2660 const char *colorStr = colorList.first();
2649 const char *iconStr = iconList.first(); 2661 const char *iconStr = iconList.first();
2650 2662
2651// KIconLoader *ldr = KGlobal::iconLoader(); 2663// KIconLoader *ldr = KGlobal::iconLoader();
2652 while(labelStr != NULL){ 2664 while(labelStr != NULL){
2653 QColor *c = new QColor; 2665 QColor *c = new QColor;
2654 c->setNamedColor(QString(colorStr)); 2666 c->setNamedColor(QString(colorStr));
2655 customBtnColorList.append(c); 2667 customBtnColorList.append(c);
2656 2668
2657 QString tmpStr(iconStr); 2669 QString tmpStr(iconStr);
2658 if(!tmpStr.isEmpty()){ 2670 if(!tmpStr.isEmpty()){
2659 QPixmap *pixmap = 2671 QPixmap *pixmap =
2660 new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); 2672 new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small));
2661 if(pixmap->isNull()){ 2673 if(pixmap->isNull()){
2662 delete pixmap; 2674 delete pixmap;
2663 customBtnIconList.append(NULL); 2675 customBtnIconList.append(NULL);
2664 } 2676 }
2665 else 2677 else
2666 customBtnIconList.append(pixmap); 2678 customBtnIconList.append(pixmap);
2667 } 2679 }
2668 else 2680 else
2669 customBtnIconList.append(NULL); 2681 customBtnIconList.append(NULL);
2670 2682
2671 labelStr = customBtnLabelList.next(); 2683 labelStr = customBtnLabelList.next();
2672 colorStr = colorList.next(); 2684 colorStr = colorList.next();
2673 iconStr = iconList.next(); 2685 iconStr = iconList.next();
2674 } 2686 }
2675} 2687}
2676 2688
2677void LiquidStyle::applyCustomAttributes(QPushButton *btn) 2689void LiquidStyle::applyCustomAttributes(QPushButton *btn)
2678{ 2690{
2679 return; // TODO 2691 return; // TODO
2680 QString str = btn->text(); 2692 QString str = btn->text();
2681 if(str.isEmpty()) 2693 if(str.isEmpty())
2682 return; 2694 return;
2683 while(str.contains('&') != 0) 2695 while(str.contains('&') != 0)
2684 str = str.remove(str.find('&'), 1); 2696 str = str.remove(str.find('&'), 1);
2685 2697
2686 const char *s; 2698 const char *s;
2687 int idx = 0; 2699 int idx = 0;
2688 for(s = customBtnLabelList.first(); s != NULL; 2700 for(s = customBtnLabelList.first(); s != NULL;
2689 ++idx, s = customBtnLabelList.next()){ 2701 ++idx, s = customBtnLabelList.next()){
2690 if(qstricmp(s, str.latin1()) == 0){ 2702 if(qstricmp(s, str.latin1()) == 0){
2691 QPalette pal = btn->palette(); 2703 QPalette pal = btn->palette();
2692 pal.setColor(QColorGroup::Button, 2704 pal.setColor(QColorGroup::Button,
2693 *customBtnColorList.at(idx)); 2705 *customBtnColorList.at(idx));
2694 btn->setPalette(pal); 2706 btn->setPalette(pal);
2695 /* 2707 /*
2696 if(customBtnIconList.at(idx) != NULL){ 2708 if(customBtnIconList.at(idx) != NULL){
2697 QPixmap *pix = customBtnIconList.at(idx); 2709 QPixmap *pix = customBtnIconList.at(idx);
2698 btn->setIconSet(QIconSet(*pix)); 2710 btn->setIconSet(QIconSet(*pix));
2699 }*/ 2711 }*/
2700 break; 2712 break;
2701 } 2713 }
2702 } 2714 }
2703} 2715}
2704 2716
2705void LiquidStyle::unapplyCustomAttributes(QPushButton *btn) 2717void LiquidStyle::unapplyCustomAttributes(QPushButton *btn)
2706{ 2718{
2707 return; // TODO 2719 return; // TODO
2708 QString str = btn->text(); 2720 QString str = btn->text();
2709 if(str.isEmpty()) 2721 if(str.isEmpty())
2710 return; 2722 return;
2711 while(str.contains('&') != 0) 2723 while(str.contains('&') != 0)
2712 str = str.remove(str.find('&'), 1); 2724 str = str.remove(str.find('&'), 1);
2713 2725
2714 const char *s; 2726 const char *s;
2715 for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){ 2727 for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){
2716 if(qstricmp(s, str.latin1()) == 0){ 2728 if(qstricmp(s, str.latin1()) == 0){
2717 btn->setPalette(QApplication::palette()); 2729 btn->setPalette(QApplication::palette());
2718 btn->setIconSet(QIconSet()); 2730 btn->setIconSet(QIconSet());
2719 break; 2731 break;
2720 } 2732 }
2721 } 2733 }
2722} 2734}
2723 2735
2724// #include "liquid.moc" 2736// #include "liquid.moc"
2725 2737
2726 2738
2727 2739
2728 2740
2729 2741
2730 2742
2731/* vim: set noet sw=8 ts=8: */ 2743/* vim: set noet sw=8 ts=8: */