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