summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp5
-rw-r--r--noncore/styles/liquid/liquid.pro2
-rw-r--r--noncore/styles/liquid/liquiddeco.cpp183
-rw-r--r--noncore/styles/liquid/liquiddeco.h41
4 files changed, 231 insertions, 0 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 2b6eaa4..9a7d2dd 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,1766 +1,1771 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5 5
6 6
7#ifndef INCLUDE_MENUITEM_DEF 7#ifndef INCLUDE_MENUITEM_DEF
8#define INCLUDE_MENUITEM_DEF 8#define INCLUDE_MENUITEM_DEF
9#endif 9#endif
10 10
11#include <qmenudata.h> 11#include <qmenudata.h>
12#include "liquid.h" 12#include "liquid.h"
13#include "liquiddeco.h"
13#include <qapplication.h> 14#include <qapplication.h>
14#include <qpe/config.h> 15#include <qpe/config.h>
15#include "effects.h" 16#include "effects.h"
16#include <qpalette.h> 17#include <qpalette.h>
17#include <qbitmap.h> 18#include <qbitmap.h>
18#include <qtabbar.h> 19#include <qtabbar.h>
19#include <qpopupmenu.h> 20#include <qpopupmenu.h>
20#include <qobjectlist.h> 21#include <qobjectlist.h>
21#include <qimage.h> 22#include <qimage.h>
22#include <qtimer.h> 23#include <qtimer.h>
23#include <qpixmapcache.h> 24#include <qpixmapcache.h>
24#include <qradiobutton.h> 25#include <qradiobutton.h>
25#include <qcombobox.h> 26#include <qcombobox.h>
26#include <qdrawutil.h> 27#include <qdrawutil.h>
27#include <qwidgetlist.h> 28#include <qwidgetlist.h>
28#include <qtoolbutton.h> 29#include <qtoolbutton.h>
29#include <qheader.h> 30#include <qheader.h>
30#include <unistd.h> 31#include <unistd.h>
31#include <qmenubar.h> 32#include <qmenubar.h>
32 33
33 34
34#include <stdio.h> 35#include <stdio.h>
35 36
36#include "htmlmasks.h" 37#include "htmlmasks.h"
37#include "embeddata.h" 38#include "embeddata.h"
38 39
39typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
40 QColorGroup &, bool, bool); 41 QColorGroup &, bool, bool);
41 42
42QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
43 44
44void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
45{ 46{
46 QImage img(pix.convertToImage()); 47 QImage img(pix.convertToImage());
47 QImageEffect::fade(img, 0.9, color); 48 QImageEffect::fade(img, 0.9, color);
48 int x, y; 49 int x, y;
49 int r, g, b; 50 int r, g, b;
50 for(y=0; y < img.height(); y+=3){ 51 for(y=0; y < img.height(); y+=3){
51 unsigned int *data = (unsigned int *) img.scanLine(y); 52 unsigned int *data = (unsigned int *) img.scanLine(y);
52 for(x=0; x < img.width(); ++x){ 53 for(x=0; x < img.width(); ++x){
53 r = qRed(data[x]); 54 r = qRed(data[x]);
54 g = qGreen(data[x]); 55 g = qGreen(data[x]);
55 b = qBlue(data[x]); 56 b = qBlue(data[x]);
56 if(r-10) 57 if(r-10)
57 r-=10; 58 r-=10;
58 if(g-10) 59 if(g-10)
59 g-=10; 60 g-=10;
60 if(b-10) 61 if(b-10)
61 b-=10; 62 b-=10;
62 data[x] = qRgb(r, g, b); 63 data[x] = qRgb(r, g, b);
63 } 64 }
64 } 65 }
65 pix.convertFromImage(img); 66 pix.convertFromImage(img);
66} 67}
67 68
68TransMenuHandler::TransMenuHandler(QObject *parent) 69TransMenuHandler::TransMenuHandler(QObject *parent)
69 : QObject(parent) 70 : QObject(parent)
70{ 71{
71 pixDict.setAutoDelete(true); 72 pixDict.setAutoDelete(true);
72 reloadSettings(); 73 reloadSettings();
73} 74}
74 75
75void TransMenuHandler::reloadSettings() 76void TransMenuHandler::reloadSettings()
76{ 77{
77 pixDict.clear(); 78 pixDict.clear();
78 79
79 Config config ( "qpe" ); 80 Config config ( "qpe" );
80 config. setGroup ( "MosfetMenus" ); 81 config. setGroup ( "MosfetMenus" );
81 82
82 type = config. readNumEntry("Type", TransStippleBg); 83 type = config. readNumEntry("Type", TransStippleBg);
83 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
84 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
85 opacity = config. readNumEntry("Opacity", 10); 86 opacity = config. readNumEntry("Opacity", 10);
86 if ( opacity < -20 ) 87 if ( opacity < -20 )
87 opacity = 20; 88 opacity = 20;
88 else if ( opacity > 20 ) 89 else if ( opacity > 20 )
89 opacity = 20; 90 opacity = 20;
90 91
91 shadowText = config. readBoolEntry("ShadowText", true); 92 shadowText = config. readBoolEntry("ShadowText", true);
92} 93}
93 94
94bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
95{ 96{
96 QWidget *p = (QWidget *)obj; 97 QWidget *p = (QWidget *)obj;
97 98
98 if(ev->type() == QEvent::Show){ 99 if(ev->type() == QEvent::Show){
99 if(type == TransStippleBg || type == TransStippleBtn || 100 if(type == TransStippleBg || type == TransStippleBtn ||
100 type == Custom){ 101 type == Custom){
101 QApplication::syncX(); 102 QApplication::syncX();
102 QPixmap *pix = new QPixmap; 103 QPixmap *pix = new QPixmap;
103 if(p->testWFlags(Qt::WType_Popup)){ 104 if(p->testWFlags(Qt::WType_Popup)){
104 QRect r(p->x(), p->y(), p->width(), p->height()); 105 QRect r(p->x(), p->y(), p->width(), p->height());
105 QRect deskR = QApplication::desktop()->rect(); 106 QRect deskR = QApplication::desktop()->rect();
106 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
107 r.setBottom(deskR.bottom()); 108 r.setBottom(deskR.bottom());
108 r.setRight(deskR.right()); 109 r.setRight(deskR.right());
109 } 110 }
110 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
111 r.width(), r.height()); 112 r.width(), r.height());
112 } 113 }
113 else{ // tear off menu 114 else{ // tear off menu
114 pix->resize(p->width(), p->height()); 115 pix->resize(p->width(), p->height());
115 pix->fill(Qt::black.rgb()); 116 pix->fill(Qt::black.rgb());
116 } 117 }
117 if(type == TransStippleBg){ 118 if(type == TransStippleBg){
118 stripePixmap(*pix, p->colorGroup().background()); 119 stripePixmap(*pix, p->colorGroup().background());
119 } 120 }
120 else if(type == TransStippleBtn){ 121 else if(type == TransStippleBtn){
121 stripePixmap(*pix, p->colorGroup().button()); 122 stripePixmap(*pix, p->colorGroup().button());
122 } 123 }
123 else{ 124 else{
124 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
125 } 126 }
126 127
127 if (p->inherits("QPopupMenu")) 128 if (p->inherits("QPopupMenu"))
128 pixDict.insert(p->winId(), pix); 129 pixDict.insert(p->winId(), pix);
129 else { 130 else {
130 p->setBackgroundPixmap(*pix); 131 p->setBackgroundPixmap(*pix);
131 132
132 QObjectList *ol = p-> queryList("QWidget"); 133 QObjectList *ol = p-> queryList("QWidget");
133 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 134 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
134 QWidget *wid = (QWidget *) it.current ( ); 135 QWidget *wid = (QWidget *) it.current ( );
135 136
136 wid-> setBackgroundPixmap(*pix); 137 wid-> setBackgroundPixmap(*pix);
137 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 138 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
138 } 139 }
139 delete ol; 140 delete ol;
140 } 141 }
141 } 142 }
142 } 143 }
143 else if(ev->type() == QEvent::Hide){ 144 else if(ev->type() == QEvent::Hide){
144 if(type == TransStippleBg || type == TransStippleBtn || 145 if(type == TransStippleBg || type == TransStippleBtn ||
145 type == Custom){ 146 type == Custom){
146// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 147// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
147 148
148 if (p->inherits("QPopupMenu")) 149 if (p->inherits("QPopupMenu"))
149 pixDict.remove(p->winId()); 150 pixDict.remove(p->winId());
150 else { 151 else {
151 p->setBackgroundMode(QWidget::PaletteBackground); 152 p->setBackgroundMode(QWidget::PaletteBackground);
152 153
153 QObjectList *ol = p-> queryList("QWidget"); 154 QObjectList *ol = p-> queryList("QWidget");
154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 155 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
155 QWidget *wid = (QWidget *) it.current ( ); 156 QWidget *wid = (QWidget *) it.current ( );
156 157
157 wid-> setBackgroundMode( QWidget::PaletteBackground ); 158 wid-> setBackgroundMode( QWidget::PaletteBackground );
158 } 159 }
159 delete ol; 160 delete ol;
160 } 161 }
161 } 162 }
162 } 163 }
163 return(false); 164 return(false);
164} 165}
165 166
166 167
167LiquidStyle::LiquidStyle() 168LiquidStyle::LiquidStyle()
168 :QWindowsStyle() 169 :QWindowsStyle()
169{ 170{
170 setName ( "LiquidStyle" ); 171 setName ( "LiquidStyle" );
171 172
172 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 173 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
173 btnMaskBmp.setMask(btnMaskBmp); 174 btnMaskBmp.setMask(btnMaskBmp);
174 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 175 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
175 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 176 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
176 headerHoverID = -1; 177 headerHoverID = -1;
177 highlightWidget = NULL; 178 highlightWidget = NULL;
178 setButtonDefaultIndicatorWidth(0); 179 setButtonDefaultIndicatorWidth(0);
179 btnDict.setAutoDelete(true); 180 btnDict.setAutoDelete(true);
180 bevelFillDict.setAutoDelete(true); 181 bevelFillDict.setAutoDelete(true);
181 smallBevelFillDict.setAutoDelete(true); 182 smallBevelFillDict.setAutoDelete(true);
182 customBtnColorList.setAutoDelete(true); 183 customBtnColorList.setAutoDelete(true);
183 customBtnIconList.setAutoDelete(true); 184 customBtnIconList.setAutoDelete(true);
184 customBtnLabelList.setAutoDelete(true); 185 customBtnLabelList.setAutoDelete(true);
185 186
186 rMatrix.rotate(270.0); 187 rMatrix.rotate(270.0);
187 highcolor = QPixmap::defaultDepth() > 8; 188 highcolor = QPixmap::defaultDepth() > 8;
188 btnBorderPix = new QPixmap; 189 btnBorderPix = new QPixmap;
189 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 190 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
190 btnBlendPix = new QPixmap; 191 btnBlendPix = new QPixmap;
191 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 192 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
192 bevelFillPix = new QPixmap; 193 bevelFillPix = new QPixmap;
193 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 194 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
194 smallBevelFillPix = new QPixmap; 195 smallBevelFillPix = new QPixmap;
195 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 196 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
196 // new stuff 197 // new stuff
197 vsbSliderFillPix = menuPix = NULL; 198 vsbSliderFillPix = menuPix = NULL;
198 menuHandler = new TransMenuHandler(this); 199 menuHandler = new TransMenuHandler(this);
199 setScrollBarExtent(15, 15); 200 setScrollBarExtent(15, 15);
200 int i; 201 int i;
201 for(i=0; i < BITMAP_ITEMS; ++i){ 202 for(i=0; i < BITMAP_ITEMS; ++i){
202 pixmaps[i] = NULL; 203 pixmaps[i] = NULL;
203 } 204 }
204 oldSliderThickness = sliderThickness(); 205 oldSliderThickness = sliderThickness();
205 setSliderThickness(11); 206 setSliderThickness(11);
206} 207}
207 208
208LiquidStyle::~LiquidStyle() 209LiquidStyle::~LiquidStyle()
209{ 210{
210 if(btnBorderPix) 211 if(btnBorderPix)
211 delete btnBorderPix; 212 delete btnBorderPix;
212 if(btnBlendPix) 213 if(btnBlendPix)
213 delete btnBlendPix; 214 delete btnBlendPix;
214 if(bevelFillPix) 215 if(bevelFillPix)
215 delete bevelFillPix; 216 delete bevelFillPix;
216 if(smallBevelFillPix) 217 if(smallBevelFillPix)
217 delete smallBevelFillPix; 218 delete smallBevelFillPix;
218 if(vsbSliderFillPix) 219 if(vsbSliderFillPix)
219 delete vsbSliderFillPix; 220 delete vsbSliderFillPix;
220 if(menuPix) 221 if(menuPix)
221 delete menuPix; 222 delete menuPix;
222 223
223 setScrollBarExtent(16, 16); 224 setScrollBarExtent(16, 16);
224 setSliderThickness(oldSliderThickness); 225 setSliderThickness(oldSliderThickness);
225 int i; 226 int i;
226 for(i=0; i < BITMAP_ITEMS; ++i){ 227 for(i=0; i < BITMAP_ITEMS; ++i){
227 if(pixmaps[i]) 228 if(pixmaps[i])
228 delete pixmaps[i]; 229 delete pixmaps[i];
229 } 230 }
230} 231}
231 232
232void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 233void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
233 const QColor &c, const QColor &bg) 234 const QColor &c, const QColor &bg)
234{ 235{
235 236
236 QPen oldPen = p->pen(); // headers need this 237 QPen oldPen = p->pen(); // headers need this
237 int x2 = x+w-1; 238 int x2 = x+w-1;
238 int y2 = y+h-1; 239 int y2 = y+h-1;
239 // outer dark rect 240 // outer dark rect
240 p->setPen(c.dark(130)); 241 p->setPen(c.dark(130));
241 p->drawLine(x, y+2, x, y2-2); // l 242 p->drawLine(x, y+2, x, y2-2); // l
242 p->drawLine(x2, y+2, x2, y2-2); // r 243 p->drawLine(x2, y+2, x2, y2-2); // r
243 p->drawLine(x+2, y, x2-2, y); // t 244 p->drawLine(x+2, y, x2-2, y); // t
244 p->drawLine(x+2, y2, x2-2, y2); // b 245 p->drawLine(x+2, y2, x2-2, y2); // b
245 p->drawPoint(x+1, y+1); // tl 246 p->drawPoint(x+1, y+1); // tl
246 p->drawPoint(x2-1, y+1); // tr 247 p->drawPoint(x2-1, y+1); // tr
247 p->drawPoint(x+1, y2-1); // bl 248 p->drawPoint(x+1, y2-1); // bl
248 p->drawPoint(x2-1, y2-1); // br 249 p->drawPoint(x2-1, y2-1); // br
249 250
250 // inner top light lines 251 // inner top light lines
251 p->setPen(c.light(105)); 252 p->setPen(c.light(105));
252 p->drawLine(x+2, y+1, x2-2, y+1); 253 p->drawLine(x+2, y+1, x2-2, y+1);
253 p->drawLine(x+1, y+2, x2-1, y+2); 254 p->drawLine(x+1, y+2, x2-1, y+2);
254 p->drawLine(x+1, y+3, x+2, y+3); 255 p->drawLine(x+1, y+3, x+2, y+3);
255 p->drawLine(x2-2, y+3, x2-1, y+3); 256 p->drawLine(x2-2, y+3, x2-1, y+3);
256 p->drawPoint(x+1, y+4); 257 p->drawPoint(x+1, y+4);
257 p->drawPoint(x2-1, y+4); 258 p->drawPoint(x2-1, y+4);
258 259
259 // inner bottom light lines 260 // inner bottom light lines
260 p->setPen(c.light(110)); 261 p->setPen(c.light(110));
261 p->drawLine(x+2, y2-1, x2-2, y2-1); 262 p->drawLine(x+2, y2-1, x2-2, y2-1);
262 p->drawLine(x+1, y2-2, x2-1, y2-2); 263 p->drawLine(x+1, y2-2, x2-1, y2-2);
263 p->drawLine(x+1, y2-3, x+2, y2-3); 264 p->drawLine(x+1, y2-3, x+2, y2-3);
264 p->drawLine(x2-2, y2-3, x2-1, y2-3); 265 p->drawLine(x2-2, y2-3, x2-1, y2-3);
265 p->drawPoint(x+1, y2-4); 266 p->drawPoint(x+1, y2-4);
266 p->drawPoint(x2-1, y2-4); 267 p->drawPoint(x2-1, y2-4);
267 268
268 // inner left mid lines 269 // inner left mid lines
269 //p->setPen(c.light(105)); 270 //p->setPen(c.light(105));
270 p->setPen(c); 271 p->setPen(c);
271 p->drawLine(x+1, y+5, x+1, y2-5); 272 p->drawLine(x+1, y+5, x+1, y2-5);
272 p->drawLine(x+2, y+4, x+2, y2-4); 273 p->drawLine(x+2, y+4, x+2, y2-4);
273 274
274 // inner right mid lines 275 // inner right mid lines
275 p->drawLine(x2-1, y+5, x2-1, y2-5); 276 p->drawLine(x2-1, y+5, x2-1, y2-5);
276 p->drawLine(x2-2, y+4, x2-2, y2-4); 277 p->drawLine(x2-2, y+4, x2-2, y2-4);
277 278
278 // fill 279 // fill
279 QPixmap *pix; 280 QPixmap *pix;
280 if(h >= 32){ 281 if(h >= 32){
281 pix = bevelFillDict.find(c.rgb()); 282 pix = bevelFillDict.find(c.rgb());
282 if(!pix){ 283 if(!pix){
283 int h, s, v; 284 int h, s, v;
284 c.hsv(&h, &s, &v); 285 c.hsv(&h, &s, &v);
285 pix = new QPixmap(*bevelFillPix); 286 pix = new QPixmap(*bevelFillPix);
286 adjustHSV(*pix, h, s, v); 287 adjustHSV(*pix, h, s, v);
287 bevelFillDict.insert(c.rgb(), pix); 288 bevelFillDict.insert(c.rgb(), pix);
288 } 289 }
289 } 290 }
290 else{ 291 else{
291 pix = smallBevelFillDict.find(c.rgb()); 292 pix = smallBevelFillDict.find(c.rgb());
292 if(!pix){ 293 if(!pix){
293 int h, s, v; 294 int h, s, v;
294 c.hsv(&h, &s, &v); 295 c.hsv(&h, &s, &v);
295 pix = new QPixmap(*smallBevelFillPix); 296 pix = new QPixmap(*smallBevelFillPix);
296 adjustHSV(*pix, h, s, v); 297 adjustHSV(*pix, h, s, v);
297 smallBevelFillDict.insert(c.rgb(), pix); 298 smallBevelFillDict.insert(c.rgb(), pix);
298 } 299 }
299 } 300 }
300 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 301 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
301 // blend 302 // blend
302 int red, green, blue; 303 int red, green, blue;
303 QColor btnColor(c.dark(130)); 304 QColor btnColor(c.dark(130));
304 red = (btnColor.red() >> 1) + (bg.red() >> 1); 305 red = (btnColor.red() >> 1) + (bg.red() >> 1);
305 green = (btnColor.green() >> 1) + (bg.green() >> 1); 306 green = (btnColor.green() >> 1) + (bg.green() >> 1);
306 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 307 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
307 btnColor.setRgb(red, green, blue); 308 btnColor.setRgb(red, green, blue);
308 309
309 p->setPen(btnColor); 310 p->setPen(btnColor);
310 p->drawPoint(x+1, y); 311 p->drawPoint(x+1, y);
311 p->drawPoint(x, y+1); 312 p->drawPoint(x, y+1);
312 p->drawPoint(x+1, y2); 313 p->drawPoint(x+1, y2);
313 p->drawPoint(x, y2-1); 314 p->drawPoint(x, y2-1);
314 315
315 p->drawPoint(x2-1, y); 316 p->drawPoint(x2-1, y);
316 p->drawPoint(x2, y+1); 317 p->drawPoint(x2, y+1);
317 p->drawPoint(x2-1, y2); 318 p->drawPoint(x2-1, y2);
318 p->drawPoint(x2, y2-1); 319 p->drawPoint(x2, y2-1);
319 320
320 p->setPen(oldPen); 321 p->setPen(oldPen);
321 322
322} 323}
323 324
324void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 325void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
325 const QColor &back, int x, int y, int w, int h, 326 const QColor &back, int x, int y, int w, int h,
326 bool supportPushDown, bool pushedDown, 327 bool supportPushDown, bool pushedDown,
327 bool autoDefault, bool isMasked) 328 bool autoDefault, bool isMasked)
328{ 329{
329 if(w < 21 || h < 21){ 330 if(w < 21 || h < 21){
330 drawClearBevel(painter, x, y, w, h, c, back); 331 drawClearBevel(painter, x, y, w, h, c, back);
331 return; 332 return;
332 } 333 }
333 if(supportPushDown){ 334 if(supportPushDown){
334 --w, --h; 335 --w, --h;
335 } 336 }
336 /* We don't make the round buttons smaller, since they don't look as good 337 /* We don't make the round buttons smaller, since they don't look as good
337 if(autoDefault){ 338 if(autoDefault){
338 w = w-buttonDefaultIndicatorWidth()*2; 339 w = w-buttonDefaultIndicatorWidth()*2;
339 h = h-buttonDefaultIndicatorWidth()*2; 340 h = h-buttonDefaultIndicatorWidth()*2;
340 }*/ 341 }*/
341 342
342 343
343 QPixmap *pix = btnDict.find(c.rgb()); 344 QPixmap *pix = btnDict.find(c.rgb());
344 if(!pix){ 345 if(!pix){
345 int h, s, v; 346 int h, s, v;
346 c.hsv(&h, &s, &v); 347 c.hsv(&h, &s, &v);
347 pix = new QPixmap(*btnBorderPix); 348 pix = new QPixmap(*btnBorderPix);
348 adjustHSV(*pix, h, s, v); 349 adjustHSV(*pix, h, s, v);
349 btnDict.insert(c.rgb(), pix); 350 btnDict.insert(c.rgb(), pix);
350 } 351 }
351 int x2 = x+w-1; 352 int x2 = x+w-1;
352 int y2 = y+h-1; 353 int y2 = y+h-1;
353 int bx2 = pix->width()-1; 354 int bx2 = pix->width()-1;
354 int by2 = pix->height()-1; 355 int by2 = pix->height()-1;
355 356
356 QPixmap tmpPix(w, h); 357 QPixmap tmpPix(w, h);
357 QPixmap tilePix; 358 QPixmap tilePix;
358 QPainter p; 359 QPainter p;
359 p.begin(&tmpPix); 360 p.begin(&tmpPix);
360 361
361 // do the fill 362 // do the fill
362 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 363 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
363 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 364 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
364 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 365 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
365 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 366 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
366 367
367 // edges 368 // edges
368 tilePix.resize(pix->width()-20, 10); 369 tilePix.resize(pix->width()-20, 10);
369 // top 370 // top
370 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 371 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
371 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 372 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
372 // bottom 373 // bottom
373 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 374 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
374 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 375 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
375 // left 376 // left
376 tilePix.resize(10, pix->height()-20); 377 tilePix.resize(10, pix->height()-20);
377 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 378 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
378 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 379 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
379 // right 380 // right
380 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 381 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
381 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 382 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
382 383
383 // middle 384 // middle
384 tilePix.resize(pix->width()-20, pix->height()-20); 385 tilePix.resize(pix->width()-20, pix->height()-20);
385 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); 386 bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20);
386 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); 387 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
387 388
388 389
389 // do the blend 390 // do the blend
390 QBitmap blendMask; 391 QBitmap blendMask;
391 if(!isMasked){ 392 if(!isMasked){
392 //QRgb bgRgb = back.rgb(); 393 //QRgb bgRgb = back.rgb();
393 //QRgb fgRgb = c.rgb(); 394 //QRgb fgRgb = c.rgb();
394 //int r, g, b; 395 //int r, g, b;
395 396
396 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); 397 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
397 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); 398 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
398 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); 399 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
399 //QColor blendColor(r, g, b); 400 //QColor blendColor(r, g, b);
400 int hue, sat, v1, v2; 401 int hue, sat, v1, v2;
401 QColor blendColor(autoDefault ? c : back); 402 QColor blendColor(autoDefault ? c : back);
402 back.hsv(&hue, &sat, &v1); 403 back.hsv(&hue, &sat, &v1);
403 blendColor.hsv(&hue, &sat, &v2); 404 blendColor.hsv(&hue, &sat, &v2);
404 if(v2 > v1) 405 if(v2 > v1)
405 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); 406 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
406 407
407 pix = btnBorderDict.find(blendColor.rgb()); 408 pix = btnBorderDict.find(blendColor.rgb());
408 if(!pix){ 409 if(!pix){
409 int h, s, v; 410 int h, s, v;
410 blendColor.hsv(&h, &s, &v); 411 blendColor.hsv(&h, &s, &v);
411 pix = new QPixmap(*btnBlendPix); 412 pix = new QPixmap(*btnBlendPix);
412 adjustHSV(*pix, h, s, v); 413 adjustHSV(*pix, h, s, v);
413 btnBorderDict.insert(blendColor.rgb(), pix); 414 btnBorderDict.insert(blendColor.rgb(), pix);
414 } 415 }
415 } 416 }
416 else{ 417 else{
417 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : 418 pix = pushedDown ? getPixmap(HTMLBtnBorderDown) :
418 getPixmap(HTMLBtnBorder); 419 getPixmap(HTMLBtnBorder);
419 } 420 }
420 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 421 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
421 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 422 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
422 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 423 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
423 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br 424 p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
424 425
425 // edges 426 // edges
426 tilePix.resize(pix->width()-20, 10); 427 tilePix.resize(pix->width()-20, 10);
427 blendMask.resize(pix->width()-20, 10); 428 blendMask.resize(pix->width()-20, 10);
428 // top 429 // top
429 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 430 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
430 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); 431 bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10);
431 tilePix.setMask(blendMask); 432 tilePix.setMask(blendMask);
432 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 433 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
433 // bottom 434 // bottom
434 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); 435 bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
435 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); 436 bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20);
436 tilePix.setMask(blendMask); 437 tilePix.setMask(blendMask);
437 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 438 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
438 // left 439 // left
439 tilePix.resize(10, pix->height()-20); 440 tilePix.resize(10, pix->height()-20);
440 blendMask.resize(10, pix->height()-20); 441 blendMask.resize(10, pix->height()-20);
441 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 442 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
442 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); 443 bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20);
443 tilePix.setMask(blendMask); 444 tilePix.setMask(blendMask);
444 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 445 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
445 // right 446 // right
446 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); 447 bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
447 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); 448 bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20);
448 tilePix.setMask(blendMask); 449 tilePix.setMask(blendMask);
449 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 450 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
450 451
451 p.end(); 452 p.end();
452 453
453 // do the button mask - we don't automask buttons 454 // do the button mask - we don't automask buttons
454 QBitmap btnMask(w, h); 455 QBitmap btnMask(w, h);
455 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 456 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
456 p.begin(&btnMask); 457 p.begin(&btnMask);
457 p.fillRect(0, 0, w, h, Qt::color0); 458 p.fillRect(0, 0, w, h, Qt::color0);
458 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 459 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
459 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 460 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
460 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 461 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
461 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 462 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
462 // fills 463 // fills
463 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 464 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
464 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 465 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
465 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 466 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
466 p.end(); 467 p.end();
467 tmpPix.setMask(btnMask); 468 tmpPix.setMask(btnMask);
468 /*if(autoDefault){ 469 /*if(autoDefault){
469 if(supportPushDown && pushedDown){ 470 if(supportPushDown && pushedDown){
470 painter->drawPixmap(x+3, y+3, tmpPix); 471 painter->drawPixmap(x+3, y+3, tmpPix);
471 } 472 }
472 else{ 473 else{
473 painter->drawPixmap(x+2, y+2, tmpPix); 474 painter->drawPixmap(x+2, y+2, tmpPix);
474 } 475 }
475 } 476 }
476 else */if(supportPushDown && pushedDown) 477 else */if(supportPushDown && pushedDown)
477 painter->drawPixmap(x+1, y+1, tmpPix); 478 painter->drawPixmap(x+1, y+1, tmpPix);
478 else 479 else
479 painter->drawPixmap(x, y, tmpPix); 480 painter->drawPixmap(x, y, tmpPix);
480 481
481 482
482 483
483} 484}
484 485
485 486
486QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, 487QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
487 bool blend) 488 bool blend)
488{ 489{
489 QImage img(qembed_findImage(label)); 490 QImage img(qembed_findImage(label));
490 img.detach(); 491 img.detach();
491 if(img.isNull()){ // shouldn't happen, been tested 492 if(img.isNull()){ // shouldn't happen, been tested
492 qWarning("Invalid embedded label %s", label); 493 qWarning("Invalid embedded label %s", label);
493 return(NULL); 494 return(NULL);
494 } 495 }
495 if(img.depth() != 32) 496 if(img.depth() != 32)
496 img = img.convertDepth(32); 497 img = img.convertDepth(32);
497 unsigned int *data = (unsigned int *)img.bits(); 498 unsigned int *data = (unsigned int *)img.bits();
498 int total = img.width()*img.height(); 499 int total = img.width()*img.height();
499 int current; 500 int current;
500 QColor c; 501 QColor c;
501 int oldH, oldS, oldV; 502 int oldH, oldS, oldV;
502 int alpha; 503 int alpha;
503 if(v < 235) 504 if(v < 235)
504 v += 20; 505 v += 20;
505 else 506 else
506 v = 255; 507 v = 255;
507 float intensity = v/255.0; 508 float intensity = v/255.0;
508 509
509 for(current=0; current<total; ++current){ 510 for(current=0; current<total; ++current){
510 alpha = qAlpha(data[current]); 511 alpha = qAlpha(data[current]);
511 c.setRgb(data[current]); 512 c.setRgb(data[current]);
512 c.hsv(&oldH, &oldS, &oldV); 513 c.hsv(&oldH, &oldS, &oldV);
513 oldV = (int)(oldV*intensity); 514 oldV = (int)(oldV*intensity);
514 c.setHsv(h, s, oldV); 515 c.setHsv(h, s, oldV);
515 if(blend && alpha != 255 && alpha != 0){ 516 if(blend && alpha != 255 && alpha != 0){
516 float srcPercent = ((float)alpha)/255.0; 517 float srcPercent = ((float)alpha)/255.0;
517 float destPercent = 1.0-srcPercent; 518 float destPercent = 1.0-srcPercent;
518 oldH = (int)((srcPercent*h) + (destPercent*bH)); 519 oldH = (int)((srcPercent*h) + (destPercent*bH));
519 oldS = (int)((srcPercent*s) + (destPercent*bS)); 520 oldS = (int)((srcPercent*s) + (destPercent*bS));
520 oldV = (int)((srcPercent*oldV) + (destPercent*bV)); 521 oldV = (int)((srcPercent*oldV) + (destPercent*bV));
521 c.setHsv(oldH, oldS, oldV); 522 c.setHsv(oldH, oldS, oldV);
522 alpha = 255; 523 alpha = 255;
523 } 524 }
524 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); 525 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
525 } 526 }
526 QPixmap *pix = new QPixmap; 527 QPixmap *pix = new QPixmap;
527 pix->convertFromImage(img); 528 pix->convertFromImage(img);
528 return(pix); 529 return(pix);
529} 530}
530 531
531 532
532 533
533 534
534QPixmap* LiquidStyle::getPixmap(BitmapData item) 535QPixmap* LiquidStyle::getPixmap(BitmapData item)
535{ 536{
536 537
537 if(pixmaps[item]) 538 if(pixmaps[item])
538 return(pixmaps[item]); 539 return(pixmaps[item]);
539 540
540 switch(item){ 541 switch(item){
541 case HTMLBtnBorder: 542 case HTMLBtnBorder:
542 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); 543 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
543 break; 544 break;
544 case HTMLBtnBorderDown: 545 case HTMLBtnBorderDown:
545 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); 546 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
546 break; 547 break;
547 case HTMLCB: 548 case HTMLCB:
548 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); 549 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
549 break; 550 break;
550 case HTMLCBDown: 551 case HTMLCBDown:
551 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); 552 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
552 break; 553 break;
553 case HTMLCBHover: 554 case HTMLCBHover:
554 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); 555 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV);
555 break; 556 break;
556 case HTMLCBDownHover: 557 case HTMLCBDownHover:
557 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", 558 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown",
558 btnHoverH, btnHoverS, 559 btnHoverH, btnHoverS,
559 btnHoverV); 560 btnHoverV);
560 break; 561 break;
561 case HTMLRadio: 562 case HTMLRadio:
562 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 563 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
563 case HTMLRadioDown: 564 case HTMLRadioDown:
564 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 565 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
565 case HTMLRadioHover: 566 case HTMLRadioHover:
566 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); 567 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV);
567 case HTMLRadioDownHover: 568 case HTMLRadioDownHover:
568 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", 569 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown",
569 btnHoverH, btnHoverS, 570 btnHoverH, btnHoverS,
570 btnHoverV); 571 btnHoverV);
571 case RadioOn: 572 case RadioOn:
572 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); 573 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true);
573 break; 574 break;
574 case RadioOnHover: 575 case RadioOnHover:
575 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, 576 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS,
576 btnHoverV, true); 577 btnHoverV, true);
577 break; 578 break;
578 case RadioOffHover: 579 case RadioOffHover:
579 pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); 580 pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true);
580 break; 581 break;
581 case TabDown: 582 case TabDown:
582 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); 583 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true);
583 break; 584 break;
584 case TabFocus: 585 case TabFocus:
585 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, 586 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS,
586 btnHoverS, true); 587 btnHoverS, true);
587 break; 588 break;
588 case CBDown: 589 case CBDown:
589 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); 590 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true);
590 break; 591 break;
591 case CBDownHover: 592 case CBDownHover:
592 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, 593 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH,
593 btnHoverS, btnHoverV, true); 594 btnHoverS, btnHoverV, true);
594 break; 595 break;
595 case CBHover: 596 case CBHover:
596 pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); 597 pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true);
597 break; 598 break;
598 case HSlider: 599 case HSlider:
599 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); 600 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true);
600 break; 601 break;
601 case VSlider: 602 case VSlider:
602 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); 603 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true);
603 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 604 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
604 break; 605 break;
605 case RadioOff: 606 case RadioOff:
606 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); 607 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true);
607 break; 608 break;
608 case Tab: 609 case Tab:
609 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); 610 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true);
610 break; 611 break;
611 case CB: 612 case CB:
612 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); 613 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true);
613 break; 614 break;
614 case VSBSliderTop: 615 case VSBSliderTop:
615 pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 616 pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true);
616 break; 617 break;
617 case VSBSliderBtm: 618 case VSBSliderBtm:
618 pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); 619 pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true);
619 break; 620 break;
620 case VSBSliderMid: 621 case VSBSliderMid:
621 pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 622 pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
622 break; 623 break;
623 case VSBSliderTopHover: 624 case VSBSliderTopHover:
624 pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 625 pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true);
625 break; 626 break;
626 case VSBSliderBtmHover: 627 case VSBSliderBtmHover:
627 pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 628 pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true);
628 break; 629 break;
629 case VSBSliderMidHover: 630 case VSBSliderMidHover:
630 pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 631 pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV);
631 break; 632 break;
632 633
633 case HSBSliderTop: 634 case HSBSliderTop:
634 pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); 635 pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true);
635 *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); 636 *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix);
636 break; 637 break;
637 case HSBSliderBtm: 638 case HSBSliderBtm:
638 pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); 639 pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true);
639 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); 640 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix);
640 break; 641 break;
641 case HSBSliderMid: 642 case HSBSliderMid:
642 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 643 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
643 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); 644 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix);
644 break; 645 break;
645 case HSBSliderTopHover: 646 case HSBSliderTopHover:
646 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 647 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true);
647 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); 648 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix);
648 break; 649 break;
649 case HSBSliderBtmHover: 650 case HSBSliderBtmHover:
650 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 651 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true);
651 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); 652 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix);
652 break; 653 break;
653 case HSBSliderMidHover: 654 case HSBSliderMidHover:
654 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 655 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV);
655 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); 656 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix);
656 break; 657 break;
657 case VSBSliderTopBg: 658 case VSBSliderTopBg:
658 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 659 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
659 break; 660 break;
660 case VSBSliderBtmBg: 661 case VSBSliderBtmBg:
661 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 662 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
662 break; 663 break;
663 case VSBSliderMidBg: 664 case VSBSliderMidBg:
664 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 665 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
665 break; 666 break;
666 case HSBSliderTopBg: 667 case HSBSliderTopBg:
667 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 668 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
668 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 669 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
669 break; 670 break;
670 case HSBSliderBtmBg: 671 case HSBSliderBtmBg:
671 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 672 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
672 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 673 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
673 break; 674 break;
674 case HSBSliderMidBg: 675 case HSBSliderMidBg:
675 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 676 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
676 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 677 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
677 break; 678 break;
678 default: 679 default:
679 break; 680 break;
680 } 681 }
681 return(pixmaps[item]); 682 return(pixmaps[item]);
682} 683}
683 684
684void LiquidStyle::polish(QPalette &appPal) 685void LiquidStyle::polish(QPalette &appPal)
685{ 686{
686 687
687 int i; 688 int i;
688 for(i=0; i < BITMAP_ITEMS; ++i){ 689 for(i=0; i < BITMAP_ITEMS; ++i){
689 if(pixmaps[i]){ 690 if(pixmaps[i]){
690 delete pixmaps[i]; 691 delete pixmaps[i];
691 pixmaps[i] = NULL; 692 pixmaps[i] = NULL;
692 } 693 }
693 } 694 }
694 QWidgetList *list = QApplication::allWidgets(); 695 QWidgetList *list = QApplication::allWidgets();
695 QWidgetListIt it( *list ); 696 QWidgetListIt it( *list );
696 QWidget *w; 697 QWidget *w;
697 while ((w=it.current()) != 0 ){ 698 while ((w=it.current()) != 0 ){
698 ++it; 699 ++it;
699 if(w->inherits("QPushButton")){ 700 if(w->inherits("QPushButton")){
700 unapplyCustomAttributes((QPushButton *)w); 701 unapplyCustomAttributes((QPushButton *)w);
701 } 702 }
702 } 703 }
703 704
704 loadCustomButtons(); 705 loadCustomButtons();
705 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 706 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
706 btnDict.clear(); 707 btnDict.clear();
707 btnBorderDict.clear(); 708 btnBorderDict.clear();
708 bevelFillDict.clear(); 709 bevelFillDict.clear();
709 smallBevelFillDict.clear(); 710 smallBevelFillDict.clear();
710 711
711 Config config ( "qpe" ); 712 Config config ( "qpe" );
712 QPalette pal = QApplication::palette(); 713 QPalette pal = QApplication::palette();
713 714
714 // button color stuff 715 // button color stuff
715 config. setGroup ( "Appearance" ); 716 config. setGroup ( "Appearance" );
716 QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); 717 QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( )));
717 if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { 718 if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) {
718 // force button color to be different from background 719 // force button color to be different from background
719 QBrush btnBrush(QColor(200, 202, 228)); 720 QBrush btnBrush(QColor(200, 202, 228));
720 appPal.setBrush(QColorGroup::Button, btnBrush); 721 appPal.setBrush(QColorGroup::Button, btnBrush);
721 } 722 }
722 c.hsv(&btnH, &btnS, &btnV); 723 c.hsv(&btnH, &btnS, &btnV);
723 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 724 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
724 725
725 // menu pixmap 726 // menu pixmap
726 if(!menuPix){ 727 if(!menuPix){
727 menuPix = new QPixmap; 728 menuPix = new QPixmap;
728 menuPix->resize(64, 64); 729 menuPix->resize(64, 64);
729 } 730 }
730 QPainter painter; 731 QPainter painter;
731 menuPix->fill(c.rgb()); 732 menuPix->fill(c.rgb());
732 painter.begin(menuPix); 733 painter.begin(menuPix);
733 painter.setPen(c.dark(105)); 734 painter.setPen(c.dark(105));
734 for(i=0; i < 63; i+=4){ 735 for(i=0; i < 63; i+=4){
735 painter.drawLine(0, i, 63, i); 736 painter.drawLine(0, i, 63, i);
736 painter.drawLine(0, i+1, 63, i+1); 737 painter.drawLine(0, i+1, 63, i+1);
737 }; 738 };
738 painter.end(); 739 painter.end();
739 menuBrush.setColor(c); 740 menuBrush.setColor(c);
740 menuBrush.setPixmap(*menuPix); 741 menuBrush.setPixmap(*menuPix);
741 742
742 // pager brush 743 // pager brush
743 c = c.dark(120); 744 c = c.dark(120);
744 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 745 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
745 if(!pix){ 746 if(!pix){
746 int h, s, v; 747 int h, s, v;
747 c.hsv(&h, &s, &v); 748 c.hsv(&h, &s, &v);
748 pix = new QPixmap(*smallBevelFillPix); 749 pix = new QPixmap(*smallBevelFillPix);
749 adjustHSV(*pix, h, s, v); 750 adjustHSV(*pix, h, s, v);
750 smallBevelFillDict.insert(c.rgb(), pix); 751 smallBevelFillDict.insert(c.rgb(), pix);
751 } 752 }
752 pagerHoverBrush.setColor(c); 753 pagerHoverBrush.setColor(c);
753 pagerHoverBrush.setPixmap(*pix); 754 pagerHoverBrush.setPixmap(*pix);
754 755
755 c = c.dark(120); 756 c = c.dark(120);
756 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 757 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
757 if(!pix){ 758 if(!pix){
758 int h, s, v; 759 int h, s, v;
759 c.hsv(&h, &s, &v); 760 c.hsv(&h, &s, &v);
760 pix = new QPixmap(*smallBevelFillPix); 761 pix = new QPixmap(*smallBevelFillPix);
761 adjustHSV(*pix, h, s, v); 762 adjustHSV(*pix, h, s, v);
762 smallBevelFillDict.insert(c.rgb(), pix); 763 smallBevelFillDict.insert(c.rgb(), pix);
763 } 764 }
764 pagerBrush.setColor(c); 765 pagerBrush.setColor(c);
765 pagerBrush.setPixmap(*pix); 766 pagerBrush.setPixmap(*pix);
766 767
767 // background color stuff 768 // background color stuff
768 c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); 769 c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));
769 c.hsv(&bH, &bS, &bV); 770 c.hsv(&bH, &bS, &bV);
770 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 771 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
771 772
772 // FIXME? 773 // FIXME?
773 if(vsbSliderFillPix) 774 if(vsbSliderFillPix)
774 delete vsbSliderFillPix; 775 delete vsbSliderFillPix;
775 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 776 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
776 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 777 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
777 778
778 // background brush 779 // background brush
779 QPixmap wallPaper(32, 32); 780 QPixmap wallPaper(32, 32);
780 wallPaper.fill(c.rgb()); 781 wallPaper.fill(c.rgb());
781 painter.begin(&wallPaper); 782 painter.begin(&wallPaper);
782 for(i=0; i < 32; i+=4){ 783 for(i=0; i < 32; i+=4){
783 painter.setPen(c.dark(105)); 784 painter.setPen(c.dark(105));
784 painter.drawLine(0, i, 32, i); 785 painter.drawLine(0, i, 32, i);
785 painter.setPen(c.dark(103)); 786 painter.setPen(c.dark(103));
786 painter.drawLine(0, i+1, 32, i+1); 787 painter.drawLine(0, i+1, 32, i+1);
787 }; 788 };
788 painter.end(); 789 painter.end();
789 bgBrush.setColor(c); 790 bgBrush.setColor(c);
790 bgBrush.setPixmap(wallPaper); 791 bgBrush.setPixmap(wallPaper);
791 appPal.setBrush(QColorGroup::Background, bgBrush); 792 appPal.setBrush(QColorGroup::Background, bgBrush);
792 793
793 // lineedits 794 // lineedits
794 c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); 795 c = QColor ( config. readEntry("Base", ( Qt::white). name ( )));
795 QPixmap basePix; 796 QPixmap basePix;
796 basePix.resize(32, 32); 797 basePix.resize(32, 32);
797 basePix.fill(c.rgb()); 798 basePix.fill(c.rgb());
798 painter.begin(&basePix); 799 painter.begin(&basePix);
799 painter.setPen(c.dark(105)); 800 painter.setPen(c.dark(105));
800 for(i=0; i < 32; i+=4){ 801 for(i=0; i < 32; i+=4){
801 painter.drawLine(0, i, 32, i); 802 painter.drawLine(0, i, 32, i);
802 painter.drawLine(0, i+1, 32, i+1); 803 painter.drawLine(0, i+1, 32, i+1);
803 }; 804 };
804 painter.end(); 805 painter.end();
805 baseBrush.setColor(c); 806 baseBrush.setColor(c);
806 baseBrush.setPixmap(basePix); 807 baseBrush.setPixmap(basePix);
807 it.toFirst(); 808 it.toFirst();
808 while ((w=it.current()) != 0 ){ 809 while ((w=it.current()) != 0 ){
809 ++it; 810 ++it;
810 if(w->inherits("QLineEdit")){ 811 if(w->inherits("QLineEdit")){
811 QPalette pal = w->palette(); 812 QPalette pal = w->palette();
812 pal.setBrush(QColorGroup::Base, baseBrush); 813 pal.setBrush(QColorGroup::Base, baseBrush);
813 w->setPalette(pal); 814 w->setPalette(pal);
814 } 815 }
815 else if(w->inherits("QPushButton")){ 816 else if(w->inherits("QPushButton")){
816 applyCustomAttributes((QPushButton *)w); 817 applyCustomAttributes((QPushButton *)w);
817 } 818 }
818 } 819 }
819 820
820} 821}
821 822
822void LiquidStyle::polish(QWidget *w) 823void LiquidStyle::polish(QWidget *w)
823{ 824{
824 if(w->inherits("QMenuBar")){ 825 if(w->inherits("QMenuBar")){
825 //((QFrame*)w)->setLineWidth(0); 826 //((QFrame*)w)->setLineWidth(0);
826 w->setBackgroundMode(QWidget::PaletteBackground); 827 w->setBackgroundMode(QWidget::PaletteBackground);
827 return; 828 return;
828 } 829 }
829 if(w->inherits("QPopupMenu")) 830 if(w->inherits("QPopupMenu"))
830 w->setBackgroundMode(QWidget::NoBackground); 831 w->setBackgroundMode(QWidget::NoBackground);
831 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { 832 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
832 w->installEventFilter(menuHandler); 833 w->installEventFilter(menuHandler);
833 } 834 }
834 835
835 if(w->isTopLevel()){ 836 if(w->isTopLevel()){
836 return; 837 return;
837 } 838 }
838 839
839 840
840 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 841 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
841 842
842 if(w->inherits("QComboBox") || 843 if(w->inherits("QComboBox") ||
843 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 844 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
844 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 845 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
845 w->installEventFilter(this); 846 w->installEventFilter(this);
846 } 847 }
847 if(w->inherits("QLineEdit")){ 848 if(w->inherits("QLineEdit")){
848 QPalette pal = w->palette(); 849 QPalette pal = w->palette();
849 pal.setBrush(QColorGroup::Base, baseBrush); 850 pal.setBrush(QColorGroup::Base, baseBrush);
850 w->setPalette(pal); 851 w->setPalette(pal);
851 } 852 }
852 if(w->inherits("QPushButton")){ 853 if(w->inherits("QPushButton")){
853 applyCustomAttributes((QPushButton *)w); 854 applyCustomAttributes((QPushButton *)w);
854 w->installEventFilter(this); 855 w->installEventFilter(this);
855 } 856 }
856 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 857 if(w->inherits("QButton") || w-> inherits("QComboBox")){
857 w-> setBackgroundMode ( QWidget::PaletteBackground ); 858 w-> setBackgroundMode ( QWidget::PaletteBackground );
858 } 859 }
859 860
860 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 861 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
861 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 862 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
862 bool isViewportChild = w->parent() && 863 bool isViewportChild = w->parent() &&
863 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 864 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
864 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 865 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
865 866
866 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 867 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
867 w->setBackgroundMode(QWidget::X11ParentRelative); 868 w->setBackgroundMode(QWidget::X11ParentRelative);
868 return; 869 return;
869 } 870 }
870 if(isViewportChild){ 871 if(isViewportChild){
871 if(w->inherits("QButton") || w->inherits("QComboBox")){ 872 if(w->inherits("QButton") || w->inherits("QComboBox")){
872 if(w->parent()){ // heh, only way to test for KHTML children ;-) 873 if(w->parent()){ // heh, only way to test for KHTML children ;-)
873 if(w->parent()->parent()){ 874 if(w->parent()->parent()){
874 if(w->parent()->parent()->parent() && 875 if(w->parent()->parent()->parent() &&
875 w->parent()->parent()->parent()->inherits("KHTMLView")){ 876 w->parent()->parent()->parent()->inherits("KHTMLView")){
876 w->setAutoMask(true); 877 w->setAutoMask(true);
877 w->setBackgroundMode(QWidget::NoBackground); 878 w->setBackgroundMode(QWidget::NoBackground);
878 } 879 }
879 } 880 }
880 } 881 }
881 return; 882 return;
882 } 883 }
883 } 884 }
884 if(w->inherits("QHeader")){ 885 if(w->inherits("QHeader")){
885 w->setMouseTracking(true); 886 w->setMouseTracking(true);
886 w->installEventFilter(this); 887 w->installEventFilter(this);
887 } 888 }
888 if(w-> inherits("QToolButton")) { 889 if(w-> inherits("QToolButton")) {
889 ((QToolButton*)w)->setAutoRaise (false); 890 ((QToolButton*)w)->setAutoRaise (false);
890 } 891 }
891 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 892 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
892 return; 893 return;
893 } 894 }
894 895
895 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 896 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
896 palette().active().brush(QColorGroup::Background).pixmap()){ 897 palette().active().brush(QColorGroup::Background).pixmap()){
897 qWarning("No parent pixmap for child widget %s", w->className()); 898 qWarning("No parent pixmap for child widget %s", w->className());
898 return; 899 return;
899 } 900 }
900 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 901 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
901 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 902 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
902 if(w->backgroundMode() == QWidget::PaletteBackground || 903 if(w->backgroundMode() == QWidget::PaletteBackground ||
903 w->backgroundMode() == QWidget::PaletteButton){ 904 w->backgroundMode() == QWidget::PaletteButton){
904 w->setBackgroundMode(QWidget::X11ParentRelative); 905 w->setBackgroundMode(QWidget::X11ParentRelative);
905 } 906 }
906 } 907 }
907 if(w->inherits("QToolBar")){ 908 if(w->inherits("QToolBar")){
908 w->installEventFilter(this); 909 w->installEventFilter(this);
909 w->setBackgroundMode(QWidget::PaletteBackground); 910 w->setBackgroundMode(QWidget::PaletteBackground);
910 return; 911 return;
911 } 912 }
912 913
913} 914}
914 915
915void LiquidStyle::unPolish(QWidget *w) 916void LiquidStyle::unPolish(QWidget *w)
916{ 917{
917 if(w->inherits("QMenuBar")){ 918 if(w->inherits("QMenuBar")){
918 ((QFrame *)w)->setLineWidth(1); 919 ((QFrame *)w)->setLineWidth(1);
919 w->setBackgroundMode(QWidget::PaletteBackground); 920 w->setBackgroundMode(QWidget::PaletteBackground);
920 return; 921 return;
921 } 922 }
922 923
923 if(w->inherits("QPopupMenu")) 924 if(w->inherits("QPopupMenu"))
924 w->setBackgroundMode(QWidget::PaletteButton); 925 w->setBackgroundMode(QWidget::PaletteButton);
925 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { 926 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
926 w->removeEventFilter(menuHandler); 927 w->removeEventFilter(menuHandler);
927 } 928 }
928 929
929 if(w->isTopLevel()) 930 if(w->isTopLevel())
930 return; 931 return;
931 932
932 // for viewport children, don't just check for NoBackground.... 933 // for viewport children, don't just check for NoBackground....
933 bool isViewportChild = w->parent() && 934 bool isViewportChild = w->parent() &&
934 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 935 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
935 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 936 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
936 937
937 w->setPalette(QApplication::palette()); 938 w->setPalette(QApplication::palette());
938 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 939 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
939 if(w->inherits("QPushButton")) 940 if(w->inherits("QPushButton"))
940 w->setBackgroundMode(QWidget::PaletteButton); 941 w->setBackgroundMode(QWidget::PaletteButton);
941 else 942 else
942 w->setBackgroundMode(QWidget::PaletteBackground); 943 w->setBackgroundMode(QWidget::PaletteBackground);
943 } 944 }
944 945
945 if(isViewportChild) 946 if(isViewportChild)
946 w->setAutoMask(false); 947 w->setAutoMask(false);
947 948
948 if(w->inherits("QPushButton")){ 949 if(w->inherits("QPushButton")){
949 unapplyCustomAttributes((QPushButton *)w); 950 unapplyCustomAttributes((QPushButton *)w);
950 w->removeEventFilter(this); 951 w->removeEventFilter(this);
951 } 952 }
952/* 953/*
953 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 954 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
954 w-> setBackgroundMode ( PaletteBackground ); 955 w-> setBackgroundMode ( PaletteBackground );
955 } 956 }
956*/ 957*/
957 if(w->inherits("QComboBox") || 958 if(w->inherits("QComboBox") ||
958 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 959 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
959 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 960 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
960 w->removeEventFilter(this); 961 w->removeEventFilter(this);
961 } 962 }
962 if(w->inherits("QButton") || w->inherits("QComboBox")){ 963 if(w->inherits("QButton") || w->inherits("QComboBox")){
963 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 964 if(w->parent() && w->parent()->inherits("KHTMLPart")){
964 w->setAutoMask(false); 965 w->setAutoMask(false);
965 } 966 }
966 } 967 }
967 if(w->inherits("QToolBar")){ 968 if(w->inherits("QToolBar")){
968 w->removeEventFilter(this); 969 w->removeEventFilter(this);
969 w->setBackgroundMode(QWidget::PaletteBackground); 970 w->setBackgroundMode(QWidget::PaletteBackground);
970 return; 971 return;
971 } 972 }
972 if(w->inherits("QHeader")){ 973 if(w->inherits("QHeader")){
973 w->setMouseTracking(false); 974 w->setMouseTracking(false);
974 w->removeEventFilter(this); 975 w->removeEventFilter(this);
975 } 976 }
976} 977}
977 978
978void LiquidStyle::polish(QApplication *app) 979void LiquidStyle::polish(QApplication *app)
979{ 980{
980 981
981 QWindowsStyle::polish(app); 982 QWindowsStyle::polish(app);
982 menuAni = app->isEffectEnabled(UI_AnimateMenu); 983 menuAni = app->isEffectEnabled(UI_AnimateMenu);
983 menuFade = app->isEffectEnabled(UI_FadeMenu); 984 menuFade = app->isEffectEnabled(UI_FadeMenu);
984 if(menuAni) 985 if(menuAni)
985 app->setEffectEnabled(UI_AnimateMenu, false); 986 app->setEffectEnabled(UI_AnimateMenu, false);
986 if(menuFade) 987 if(menuFade)
987 app->setEffectEnabled(UI_FadeMenu, false); 988 app->setEffectEnabled(UI_FadeMenu, false);
988 989
989 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 990 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
991
992 QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
990} 993}
991 994
992void LiquidStyle::unPolish(QApplication *app) 995void LiquidStyle::unPolish(QApplication *app)
993{ 996{
994 QWindowsStyle::unPolish(app); 997 QWindowsStyle::unPolish(app);
995 app->setEffectEnabled(UI_AnimateMenu, menuAni); 998 app->setEffectEnabled(UI_AnimateMenu, menuAni);
996 app->setEffectEnabled(UI_FadeMenu, menuFade); 999 app->setEffectEnabled(UI_FadeMenu, menuFade);
997 1000
998 qt_set_draw_menu_bar_impl ( 0 ); 1001 qt_set_draw_menu_bar_impl ( 0 );
1002
1003 QApplication::qwsSetDecoration ( new QPEDecoration ( ));
999} 1004}
1000 1005
1001/* 1006/*
1002 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1007 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1003 * force everything to erase and repaint on resize. This is going away, I'm 1008 * force everything to erase and repaint on resize. This is going away, I'm
1004 * trying to get shaped widgets to work right without masking. QPushButton, 1009 * trying to get shaped widgets to work right without masking. QPushButton,
1005 * QComboBox, and Panel applet handles capture mouse enter and leaves in order 1010 * QComboBox, and Panel applet handles capture mouse enter and leaves in order
1006 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and 1011 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
1007 * RadioButtons need to do this differently. Qt buffers these in pixmaps and 1012 * RadioButtons need to do this differently. Qt buffers these in pixmaps and
1008 * caches them in QPixmapCache, which is bad for doing things like hover 1013 * caches them in QPixmapCache, which is bad for doing things like hover
1009 * because the style methods aren't called in paintEvents if everything 1014 * because the style methods aren't called in paintEvents if everything
1010 * is cached. We use our own Paint event handler instead. Taskbuttons and 1015 * is cached. We use our own Paint event handler instead. Taskbuttons and
1011 * pager buttons draw into a pixmap buffer, so we handle those with palette 1016 * pager buttons draw into a pixmap buffer, so we handle those with palette
1012 * modifications. For QHeader, different header items are actually one widget 1017 * modifications. For QHeader, different header items are actually one widget
1013 * that draws multiple items, so we need to check which ID is hightlighted 1018 * that draws multiple items, so we need to check which ID is hightlighted
1014 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1019 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1015 * since if it's inside a combobox we want to highlight the combobox during 1020 * since if it's inside a combobox we want to highlight the combobox during
1016 * hovering in the edit. 1021 * hovering in the edit.
1017 */ 1022 */
1018bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1023bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1019{ 1024{
1020 if(obj->inherits("QToolBar")){ 1025 if(obj->inherits("QToolBar")){
1021 if(ev->type() == QEvent::Resize){ 1026 if(ev->type() == QEvent::Resize){
1022 const QObjectList *tbChildList = obj->children(); 1027 const QObjectList *tbChildList = obj->children();
1023 QObjectListIt it(*tbChildList); 1028 QObjectListIt it(*tbChildList);
1024 QObject *child; 1029 QObject *child;
1025 while((child = it.current()) != NULL){ 1030 while((child = it.current()) != NULL){
1026 ++it; 1031 ++it;
1027 if(child->isWidgetType()) 1032 if(child->isWidgetType())
1028 ((QWidget *)child)->repaint(true); 1033 ((QWidget *)child)->repaint(true);
1029 } 1034 }
1030 1035
1031 } 1036 }
1032 } 1037 }
1033 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ 1038 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){
1034 QWidget *btn = (QWidget *)obj; 1039 QWidget *btn = (QWidget *)obj;
1035 if(ev->type() == QEvent::Enter){ 1040 if(ev->type() == QEvent::Enter){
1036 if(btn->isEnabled()){ 1041 if(btn->isEnabled()){
1037 highlightWidget = btn; 1042 highlightWidget = btn;
1038 btn->repaint(false); 1043 btn->repaint(false);
1039 } 1044 }
1040 } 1045 }
1041 else if(ev->type() == QEvent::Leave){ 1046 else if(ev->type() == QEvent::Leave){
1042 if(btn == highlightWidget){ 1047 if(btn == highlightWidget){
1043 highlightWidget = NULL; 1048 highlightWidget = NULL;
1044 btn->repaint(false); 1049 btn->repaint(false);
1045 } 1050 }
1046 } 1051 }
1047 } 1052 }
1048 else if(obj->inherits("QToolButton")){ 1053 else if(obj->inherits("QToolButton")){
1049 QToolButton *btn = (QToolButton *)btn; 1054 QToolButton *btn = (QToolButton *)btn;
1050 if(!btn->autoRaise()){ 1055 if(!btn->autoRaise()){
1051 if(btn->isEnabled()){ 1056 if(btn->isEnabled()){
1052 highlightWidget = btn; 1057 highlightWidget = btn;
1053 btn->repaint(false); 1058 btn->repaint(false);
1054 } 1059 }
1055 } 1060 }
1056 else if(ev->type() == QEvent::Leave){ 1061 else if(ev->type() == QEvent::Leave){
1057 QWidget *btn = (QWidget *)obj; 1062 QWidget *btn = (QWidget *)obj;
1058 if(btn == highlightWidget){ 1063 if(btn == highlightWidget){
1059 highlightWidget = NULL; 1064 highlightWidget = NULL;
1060 btn->repaint(false); 1065 btn->repaint(false);
1061 } 1066 }
1062 } 1067 }
1063 else 1068 else
1064 highlightWidget = NULL; 1069 highlightWidget = NULL;
1065 } 1070 }
1066 else if(obj->inherits("QScrollBar")){ 1071 else if(obj->inherits("QScrollBar")){
1067 QScrollBar *sb = (QScrollBar *)obj; 1072 QScrollBar *sb = (QScrollBar *)obj;
1068 if(ev->type() == QEvent::Enter){ 1073 if(ev->type() == QEvent::Enter){
1069 if(sb->isEnabled()){ 1074 if(sb->isEnabled()){
1070 highlightWidget = sb; 1075 highlightWidget = sb;
1071 sb->repaint(false); 1076 sb->repaint(false);
1072 } 1077 }
1073 } 1078 }
1074 else if(ev->type() == QEvent::Leave){ 1079 else if(ev->type() == QEvent::Leave){
1075 if(sb == highlightWidget && !sb->draggingSlider()){ 1080 if(sb == highlightWidget && !sb->draggingSlider()){
1076 highlightWidget = NULL; 1081 highlightWidget = NULL;
1077 sb->repaint(false); 1082 sb->repaint(false);
1078 } 1083 }
1079 } 1084 }
1080 else if(ev->type() == QEvent::MouseButtonRelease){ 1085 else if(ev->type() == QEvent::MouseButtonRelease){
1081 QMouseEvent *me = (QMouseEvent *)ev; 1086 QMouseEvent *me = (QMouseEvent *)ev;
1082 if(sb == highlightWidget && !sb->rect().contains(me->pos())){ 1087 if(sb == highlightWidget && !sb->rect().contains(me->pos())){
1083 highlightWidget = NULL; 1088 highlightWidget = NULL;
1084 sb->repaint(false); 1089 sb->repaint(false);
1085 } 1090 }
1086 } 1091 }
1087 } 1092 }
1088 else if(obj->inherits("QLineEdit")){ 1093 else if(obj->inherits("QLineEdit")){
1089 if(obj->parent() && obj->parent()->inherits("QComboBox")){ 1094 if(obj->parent() && obj->parent()->inherits("QComboBox")){
1090 QWidget *btn = (QComboBox *)obj->parent(); 1095 QWidget *btn = (QComboBox *)obj->parent();
1091 if(ev->type() == QEvent::Enter){ 1096 if(ev->type() == QEvent::Enter){
1092 if (btn->isEnabled()){ 1097 if (btn->isEnabled()){
1093 highlightWidget = btn; 1098 highlightWidget = btn;
1094 btn->repaint(false); 1099 btn->repaint(false);
1095 } 1100 }
1096 } 1101 }
1097 else if(ev->type() == QEvent::Leave){ 1102 else if(ev->type() == QEvent::Leave){
1098 if (btn == highlightWidget) 1103 if (btn == highlightWidget)
1099 highlightWidget = NULL; 1104 highlightWidget = NULL;
1100 btn->repaint(false); 1105 btn->repaint(false);
1101 } 1106 }
1102 } 1107 }
1103 } 1108 }
1104 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ 1109 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
1105 QButton *btn = (QButton *)obj; 1110 QButton *btn = (QButton *)obj;
1106 bool isRadio = obj->inherits("QRadioButton"); 1111 bool isRadio = obj->inherits("QRadioButton");
1107 if(ev->type() == QEvent::Paint){ 1112 if(ev->type() == QEvent::Paint){
1108 //if(btn->autoMask()) 1113 //if(btn->autoMask())
1109 btn->erase(); 1114 btn->erase();
1110 QPainter p; 1115 QPainter p;
1111 p.begin(btn); 1116 p.begin(btn);
1112 QFontMetrics fm = btn->fontMetrics(); 1117 QFontMetrics fm = btn->fontMetrics();
1113 QSize lsz = fm.size(ShowPrefix, btn->text()); 1118 QSize lsz = fm.size(ShowPrefix, btn->text());
1114 QSize sz = isRadio ? exclusiveIndicatorSize() 1119 QSize sz = isRadio ? exclusiveIndicatorSize()
1115 : indicatorSize(); 1120 : indicatorSize();
1116 1121
1117 if(btn->hasFocus()){ 1122 if(btn->hasFocus()){
1118 QRect r = QRect(0, 0, btn->width(), btn->height()); 1123 QRect r = QRect(0, 0, btn->width(), btn->height());
1119 p.setPen(btn->colorGroup().button().dark(140)); 1124 p.setPen(btn->colorGroup().button().dark(140));
1120 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1125 p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1121 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1126 p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1122 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1127 p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1123 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1128 p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1124 } 1129 }
1125 int x = 0; 1130 int x = 0;
1126 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1131 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1127 if(isRadio) 1132 if(isRadio)
1128 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1133 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1129 btn->colorGroup(), btn->isOn(), 1134 btn->colorGroup(), btn->isOn(),
1130 btn->isDown(), btn->isEnabled()); 1135 btn->isDown(), btn->isEnabled());
1131 else 1136 else
1132 drawIndicator(&p, x, y, sz.width(), sz.height(), 1137 drawIndicator(&p, x, y, sz.width(), sz.height(),
1133 btn->colorGroup(), btn->state(), btn->isDown(), 1138 btn->colorGroup(), btn->state(), btn->isDown(),
1134 btn->isEnabled()); 1139 btn->isEnabled());
1135 x = sz.width() + 6; 1140 x = sz.width() + 6;
1136 y = 0; 1141 y = 0;
1137 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), 1142 drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
1138 btn->height(), AlignLeft|AlignVCenter|ShowPrefix, 1143 btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
1139 btn->colorGroup(), btn->isEnabled(), 1144 btn->colorGroup(), btn->isEnabled(),
1140 btn->pixmap(), btn->text()); 1145 btn->pixmap(), btn->text());
1141 p.end(); 1146 p.end();
1142 return(true); 1147 return(true);
1143 } 1148 }
1144 // for hover, just redraw the indicator (not the text) 1149 // for hover, just redraw the indicator (not the text)
1145 else if((ev->type() == QEvent::Enter && btn->isEnabled()) || 1150 else if((ev->type() == QEvent::Enter && btn->isEnabled()) ||
1146 (ev->type() == QEvent::Leave && btn == highlightWidget)){ 1151 (ev->type() == QEvent::Leave && btn == highlightWidget)){
1147 QButton *btn = (QButton *)obj; 1152 QButton *btn = (QButton *)obj;
1148 bool isRadio = obj->inherits("QRadioButton"); 1153 bool isRadio = obj->inherits("QRadioButton");
1149 1154
1150 if(ev->type() == QEvent::Enter) 1155 if(ev->type() == QEvent::Enter)
1151 highlightWidget = btn; 1156 highlightWidget = btn;
1152 else 1157 else
1153 highlightWidget = NULL; 1158 highlightWidget = NULL;
1154 QFontMetrics fm = btn->fontMetrics(); 1159 QFontMetrics fm = btn->fontMetrics();
1155 QSize lsz = fm.size(ShowPrefix, btn->text()); 1160 QSize lsz = fm.size(ShowPrefix, btn->text());
1156 QSize sz = isRadio ? exclusiveIndicatorSize() 1161 QSize sz = isRadio ? exclusiveIndicatorSize()
1157 : indicatorSize(); 1162 : indicatorSize();
1158 int x = 0; 1163 int x = 0;
1159 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; 1164 int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
1160 //if(btn->autoMask()) 1165 //if(btn->autoMask())
1161 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); 1166 // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2);
1162 QPainter p; 1167 QPainter p;
1163 p.begin(btn); 1168 p.begin(btn);
1164 if(isRadio) 1169 if(isRadio)
1165 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), 1170 drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
1166 btn->colorGroup(), btn->isOn(), 1171 btn->colorGroup(), btn->isOn(),
1167 btn->isDown(), btn->isEnabled()); 1172 btn->isDown(), btn->isEnabled());
1168 else 1173 else
1169 drawIndicator(&p, x, y, sz.width(), sz.height(), 1174 drawIndicator(&p, x, y, sz.width(), sz.height(),
1170 btn->colorGroup(), btn->state(), btn->isDown(), 1175 btn->colorGroup(), btn->state(), btn->isDown(),
1171 btn->isEnabled()); 1176 btn->isEnabled());
1172 p.end(); 1177 p.end();
1173 } 1178 }
1174 } 1179 }
1175 else if(obj->inherits("QHeader")){ 1180 else if(obj->inherits("QHeader")){
1176 QHeader *hw = (QHeader *)obj; 1181 QHeader *hw = (QHeader *)obj;
1177 if(ev->type() == QEvent::Enter){ 1182 if(ev->type() == QEvent::Enter){
1178 currentHeader = hw; 1183 currentHeader = hw;
1179 headerHoverID = -1; 1184 headerHoverID = -1;
1180 } 1185 }
1181 else if(ev->type() == QEvent::Leave){ 1186 else if(ev->type() == QEvent::Leave){
1182 currentHeader = NULL; 1187 currentHeader = NULL;
1183 if(headerHoverID != -1){ 1188 if(headerHoverID != -1){
1184 hw->repaint(hw->sectionPos(headerHoverID), 0, 1189 hw->repaint(hw->sectionPos(headerHoverID), 0,
1185 hw->sectionSize(headerHoverID), hw->height()); 1190 hw->sectionSize(headerHoverID), hw->height());
1186 } 1191 }
1187 headerHoverID = -1; 1192 headerHoverID = -1;
1188 } 1193 }
1189 else if(ev->type() == QEvent::MouseMove){ 1194 else if(ev->type() == QEvent::MouseMove){
1190 QMouseEvent *me = (QMouseEvent *)ev; 1195 QMouseEvent *me = (QMouseEvent *)ev;
1191 int oldHeader = headerHoverID; 1196 int oldHeader = headerHoverID;
1192 headerHoverID = hw->sectionAt(me->x()); 1197 headerHoverID = hw->sectionAt(me->x());
1193 if(oldHeader != headerHoverID){ 1198 if(oldHeader != headerHoverID){
1194 // reset old header 1199 // reset old header
1195 if(oldHeader != -1){ 1200 if(oldHeader != -1){
1196 hw->repaint(hw->sectionPos(oldHeader), 0, 1201 hw->repaint(hw->sectionPos(oldHeader), 0,
1197 hw->sectionSize(oldHeader), hw->height()); 1202 hw->sectionSize(oldHeader), hw->height());
1198 } 1203 }
1199 if(headerHoverID != -1){ 1204 if(headerHoverID != -1){
1200 hw->repaint(hw->sectionPos(headerHoverID), 0, 1205 hw->repaint(hw->sectionPos(headerHoverID), 0,
1201 hw->sectionSize(headerHoverID), hw->height()); 1206 hw->sectionSize(headerHoverID), hw->height());
1202 } 1207 }
1203 } 1208 }
1204 } 1209 }
1205 } 1210 }
1206 return(false); 1211 return(false);
1207} 1212}
1208 1213
1209void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, 1214void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
1210 const QColorGroup &g, bool sunken, 1215 const QColorGroup &g, bool sunken,
1211 const QBrush *) 1216 const QBrush *)
1212{ 1217{
1213 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), 1218 drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
1214 x, y, w, h); 1219 x, y, w, h);
1215} 1220}
1216 1221
1217void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, 1222void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
1218 const QColorGroup &g, bool sunken, 1223 const QColorGroup &g, bool sunken,
1219 const QBrush *) 1224 const QBrush *)
1220{ 1225{
1221 if(p->device()->devType() != QInternal::Widget){ 1226 if(p->device()->devType() != QInternal::Widget){
1222 // drawing into a temp pixmap, don't use mask 1227 // drawing into a temp pixmap, don't use mask
1223 QColor c = sunken ? g.button() : g.background(); 1228 QColor c = sunken ? g.button() : g.background();
1224 p->setPen(c.dark(130)); 1229 p->setPen(c.dark(130));
1225 p->drawRect(x, y, w, h); 1230 p->drawRect(x, y, w, h);
1226 p->setPen(c.light(105)); 1231 p->setPen(c.light(105));
1227 p->drawRect(x+1, y+1, w-2, h-2); 1232 p->drawRect(x+1, y+1, w-2, h-2);
1228 1233
1229 1234
1230 // fill 1235 // fill
1231 QPixmap *pix = bevelFillDict.find(c.rgb()); 1236 QPixmap *pix = bevelFillDict.find(c.rgb());
1232 if(!pix){ 1237 if(!pix){
1233 int h, s, v; 1238 int h, s, v;
1234 c.hsv(&h, &s, &v); 1239 c.hsv(&h, &s, &v);
1235 pix = new QPixmap(*bevelFillPix); 1240 pix = new QPixmap(*bevelFillPix);
1236 adjustHSV(*pix, h, s, v); 1241 adjustHSV(*pix, h, s, v);
1237 bevelFillDict.insert(c.rgb(), pix); 1242 bevelFillDict.insert(c.rgb(), pix);
1238 } 1243 }
1239 1244
1240 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); 1245 p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
1241 } 1246 }
1242 else{ 1247 else{
1243 drawClearBevel(p, x, y, w, h, sunken ? g.button() : 1248 drawClearBevel(p, x, y, w, h, sunken ? g.button() :
1244 highlightWidget == p->device() ? g.button().light(110) : 1249 highlightWidget == p->device() ? g.button().light(110) :
1245 g.background(), g.background()); 1250 g.background(), g.background());
1246 } 1251 }
1247} 1252}
1248 1253
1249void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) 1254void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
1250{ 1255{
1251 QRect r = btn->rect(); 1256 QRect r = btn->rect();
1252 bool sunken = btn->isOn() || btn->isDown(); 1257 bool sunken = btn->isOn() || btn->isDown();
1253 QColorGroup g = btn->colorGroup(); 1258 QColorGroup g = btn->colorGroup();
1254 1259
1255 1260
1256 //int dw = buttonDefaultIndicatorWidth(); 1261 //int dw = buttonDefaultIndicatorWidth();
1257 if(btn->hasFocus() || btn->isDefault()){ 1262 if(btn->hasFocus() || btn->isDefault()){
1258 QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); 1263 QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
1259 QPixmap *pix = bevelFillDict.find(c.rgb()); 1264 QPixmap *pix = bevelFillDict.find(c.rgb());
1260 if(!pix){ 1265 if(!pix){
1261 int h, s, v; 1266 int h, s, v;
1262 c.hsv(&h, &s, &v); 1267 c.hsv(&h, &s, &v);
1263 pix = new QPixmap(*bevelFillPix); 1268 pix = new QPixmap(*bevelFillPix);
1264 adjustHSV(*pix, h, s, v); 1269 adjustHSV(*pix, h, s, v);
1265 bevelFillDict.insert(c.rgb(), pix); 1270 bevelFillDict.insert(c.rgb(), pix);
1266 } 1271 }
1267 p->setPen(c.dark(150)); 1272 p->setPen(c.dark(150));
1268 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); 1273 p->drawLine(r.x()+1, r.y(), r.right()-1, r.y());
1269 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); 1274 p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
1270 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); 1275 p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
1271 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); 1276 p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
1272 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1277 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1273 } 1278 }
1274 1279
1275 QColor newColor = btn == highlightWidget || sunken ? 1280 QColor newColor = btn == highlightWidget || sunken ?
1276 g.button().light(120) : g.button(); 1281 g.button().light(120) : g.button();
1277 1282
1278 drawRoundButton(p, newColor, g.background(), 1283 drawRoundButton(p, newColor, g.background(),
1279 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), 1284 r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
1280 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), 1285 sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
1281 btn->autoMask()); 1286 btn->autoMask());
1282} 1287}
1283 1288
1284void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) 1289void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
1285{ 1290{
1286 int x1, y1, x2, y2, w, h; 1291 int x1, y1, x2, y2, w, h;
1287 btn->rect().coords(&x1, &y1, &x2, &y2); 1292 btn->rect().coords(&x1, &y1, &x2, &y2);
1288 w = btn->width(); 1293 w = btn->width();
1289 h = btn->height(); 1294 h = btn->height();
1290 1295
1291 bool act = btn->isOn() || btn->isDown(); 1296 bool act = btn->isOn() || btn->isDown();
1292 if(act){ 1297 if(act){
1293 ++x1, ++y1; 1298 ++x1, ++y1;
1294 } 1299 }
1295 1300
1296 // Draw iconset first, if any 1301 // Draw iconset first, if any
1297 if ( btn->iconSet() && !btn->iconSet()->isNull() ) 1302 if ( btn->iconSet() && !btn->iconSet()->isNull() )
1298 { 1303 {
1299 QIconSet::Mode mode = btn->isEnabled() 1304 QIconSet::Mode mode = btn->isEnabled()
1300 ? QIconSet::Normal : QIconSet::Disabled; 1305 ? QIconSet::Normal : QIconSet::Disabled;
1301 if ( mode == QIconSet::Normal && btn->hasFocus() ) 1306 if ( mode == QIconSet::Normal && btn->hasFocus() )
1302 mode = QIconSet::Active; 1307 mode = QIconSet::Active;
1303 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); 1308 QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
1304 int pixw = pixmap.width(); 1309 int pixw = pixmap.width();
1305 int pixh = pixmap.height(); 1310 int pixh = pixmap.height();
1306 1311
1307 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); 1312 p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
1308 x1 += pixw + 8; 1313 x1 += pixw + 8;
1309 w -= pixw + 8; 1314 w -= pixw + 8;
1310 } 1315 }
1311 1316
1312 if(act){ 1317 if(act){
1313 QFont font = btn->font(); 1318 QFont font = btn->font();
1314 font.setBold(true); 1319 font.setBold(true);
1315 p->setFont(font); 1320 p->setFont(font);
1316 QColor shadow(btn->colorGroup().button().dark(130)); 1321 QColor shadow(btn->colorGroup().button().dark(130));
1317 drawItem( p, x1+1, y1+1, w, h, 1322 drawItem( p, x1+1, y1+1, w, h,
1318 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1323 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1319 btn->pixmap(), btn->text(), -1, 1324 btn->pixmap(), btn->text(), -1,
1320 &shadow); 1325 &shadow);
1321 1326
1322 drawItem( p, x1, y1, w, h, 1327 drawItem( p, x1, y1, w, h,
1323 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1328 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1324 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); 1329 btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
1325 } 1330 }
1326 else{ 1331 else{
1327 /* Too blurry 1332 /* Too blurry
1328 drawItem( p, x1+1, y1+1, w, h, 1333 drawItem( p, x1+1, y1+1, w, h,
1329 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), 1334 AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
1330 btn->pixmap(), btn->text(), -1, 1335 btn->pixmap(), btn->text(), -1,
1331 &btn->colorGroup().button().dark(115)); 1336 &btn->colorGroup().button().dark(115));
1332 */ 1337 */
1333 drawItem( p, x1, y1, w, h, 1338 drawItem( p, x1, y1, w, h,
1334 AlignCenter | ShowPrefix, 1339 AlignCenter | ShowPrefix,
1335 btn->colorGroup(), btn->isEnabled(), 1340 btn->colorGroup(), btn->isEnabled(),
1336 btn->pixmap(), btn->text(), -1, 1341 btn->pixmap(), btn->text(), -1,
1337 &btn->colorGroup().buttonText()); 1342 &btn->colorGroup().buttonText());
1338 } 1343 }
1339} 1344}
1340 1345
1341void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) 1346void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
1342{ 1347{
1343 int x2 = x+w-1; 1348 int x2 = x+w-1;
1344 int y2 = y+h-1; 1349 int y2 = y+h-1;
1345 1350
1346 p->setPen(Qt::color1); 1351 p->setPen(Qt::color1);
1347 p->fillRect(x, y, w, h, Qt::color0); 1352 p->fillRect(x, y, w, h, Qt::color0);
1348 if(w < 21 || h < 21){ 1353 if(w < 21 || h < 21){
1349 // outer rect 1354 // outer rect
1350 p->drawLine(x, y+2, x, y2-2); // l 1355 p->drawLine(x, y+2, x, y2-2); // l
1351 p->drawLine(x2, y+2, x2, y2-2); // r 1356 p->drawLine(x2, y+2, x2, y2-2); // r
1352 p->drawLine(x+2, y, x2-2, y); // t 1357 p->drawLine(x+2, y, x2-2, y); // t
1353 p->drawLine(x+2, y2, x2-2, y2); // b 1358 p->drawLine(x+2, y2, x2-2, y2); // b
1354 p->drawLine(x+1, y+1, x2-1, y+1); // top second line 1359 p->drawLine(x+1, y+1, x2-1, y+1); // top second line
1355 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line 1360 p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line
1356 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); 1361 p->fillRect(x+1, y+2, w-2, h-4, Qt::color1);
1357 } 1362 }
1358 else{ 1363 else{
1359 int x2 = x+w-1; 1364 int x2 = x+w-1;
1360 int y2 = y+h-1; 1365 int y2 = y+h-1;
1361 int bx2 = htmlBtnMaskBmp.width()-1; 1366 int bx2 = htmlBtnMaskBmp.width()-1;
1362 int by2 = htmlBtnMaskBmp.height()-1; 1367 int by2 = htmlBtnMaskBmp.height()-1;
1363 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl 1368 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
1364 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr 1369 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
1365 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl 1370 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
1366 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br 1371 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
1367 // fills 1372 // fills
1368 p->fillRect(10, 0, w-20, 10, Qt::color1); // top 1373 p->fillRect(10, 0, w-20, 10, Qt::color1); // top
1369 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1374 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1370 p->fillRect(0, 10, w, h-20, Qt::color1); // middle 1375 p->fillRect(0, 10, w, h-20, Qt::color1); // middle
1371 } 1376 }
1372} 1377}
1373 1378
1374void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, 1379void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
1375 const QColorGroup &g, bool sunken, 1380 const QColorGroup &g, bool sunken,
1376 const QBrush */*fill*/) 1381 const QBrush */*fill*/)
1377{ 1382{
1378 if(currentHeader && p->device() == currentHeader){ 1383 if(currentHeader && p->device() == currentHeader){
1379 int id = currentHeader->sectionAt(x); 1384 int id = currentHeader->sectionAt(x);
1380 bool isHeaderHover = id != -1 && id == headerHoverID; 1385 bool isHeaderHover = id != -1 && id == headerHoverID;
1381 drawClearBevel(p, x, y, w, h, sunken ? 1386 drawClearBevel(p, x, y, w, h, sunken ?
1382 g.button() : isHeaderHover ? g.button().light(110) : 1387 g.button() : isHeaderHover ? g.button().light(110) :
1383 g.background(), g.background()); 1388 g.background(), g.background());
1384 } 1389 }
1385 else 1390 else
1386 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), 1391 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
1387 g.background()); 1392 g.background());
1388} 1393}
1389 1394
1390QRect LiquidStyle::buttonRect(int x, int y, int w, int h) 1395QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
1391{ 1396{
1392 return(QRect(x+5, y+5, w-10, h-10)); 1397 return(QRect(x+5, y+5, w-10, h-10));
1393} 1398}
1394 1399
1395void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, 1400void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1396 const QColorGroup &g, bool sunken, 1401 const QColorGroup &g, bool sunken,
1397 bool edit, bool, const QBrush *) 1402 bool edit, bool, const QBrush *)
1398{ 1403{
1399 bool isHover = highlightWidget == painter->device(); 1404 bool isHover = highlightWidget == painter->device();
1400 bool isMasked = false; 1405 bool isMasked = false;
1401 if(painter->device()->devType() == QInternal::Widget) 1406 if(painter->device()->devType() == QInternal::Widget)
1402 isMasked = ((QWidget*)painter->device())->autoMask(); 1407 isMasked = ((QWidget*)painter->device())->autoMask();
1403 // TODO: Do custom code, don't just call drawRoundButton into a pixmap 1408 // TODO: Do custom code, don't just call drawRoundButton into a pixmap
1404 QPixmap tmpPix(w, h); 1409 QPixmap tmpPix(w, h);
1405 QPainter p(&tmpPix); 1410 QPainter p(&tmpPix);
1406 1411
1407 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, 1412 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
1408 sunken, false, isMasked); 1413 sunken, false, isMasked);
1409 if(!isHover){ 1414 if(!isHover){
1410 p.setClipRect(0, 0, w-17, h); 1415 p.setClipRect(0, 0, w-17, h);
1411 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, 1416 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
1412 sunken, false, isMasked); 1417 sunken, false, isMasked);
1413 } 1418 }
1414 p.end(); 1419 p.end();
1415 int x2 = x+w-1; 1420 int x2 = x+w-1;
1416 int y2 = y+h-1; 1421 int y2 = y+h-1;
1417 int bx2 = btnMaskBmp.width()-1; 1422 int bx2 = btnMaskBmp.width()-1;
1418 int by2 = btnMaskBmp.height()-1; 1423 int by2 = btnMaskBmp.height()-1;
1419 QBitmap btnMask(w, h); 1424 QBitmap btnMask(w, h);
1420 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 1425 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
1421 p.begin(&btnMask); 1426 p.begin(&btnMask);
1422 p.fillRect(0, 0, w, h, Qt::color0); 1427 p.fillRect(0, 0, w, h, Qt::color0);
1423 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 1428 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
1424 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 1429 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
1425 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 1430 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
1426 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 1431 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
1427 // fills 1432 // fills
1428 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 1433 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
1429 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1434 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1430 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 1435 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
1431 p.end(); 1436 p.end();
1432 tmpPix.setMask(btnMask); 1437 tmpPix.setMask(btnMask);
1433 1438
1434 painter->drawPixmap(x, y, tmpPix); 1439 painter->drawPixmap(x, y, tmpPix);
1435 1440
1436 painter->setPen(g.button().dark(120)); 1441 painter->setPen(g.button().dark(120));
1437 painter->drawLine(x2-16, y+1, x2-16, y2-1); 1442 painter->drawLine(x2-16, y+1, x2-16, y2-1);
1438 1443
1439 if(edit){ 1444 if(edit){
1440 painter->setPen(g.mid()); 1445 painter->setPen(g.mid());
1441 painter->drawRect(x+8, y+2, w-25, h-4); 1446 painter->drawRect(x+8, y+2, w-25, h-4);
1442 } 1447 }
1443 int arrow_h = h / 3; 1448 int arrow_h = h / 3;
1444 int arrow_w = arrow_h; 1449 int arrow_w = arrow_h;
1445 int arrow_x = w - arrow_w - 6; 1450 int arrow_x = w - arrow_w - 6;
1446 int arrow_y = (h - arrow_h) / 2; 1451 int arrow_y = (h - arrow_h) / 2;
1447 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); 1452 drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true);
1448} 1453}
1449 1454
1450void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) 1455void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
1451{ 1456{
1452 drawButtonMask(p, x, y, w, h); 1457 drawButtonMask(p, x, y, w, h);
1453} 1458}
1454 1459
1455QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) 1460QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
1456{ 1461{
1457 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); 1462 //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
1458 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); 1463 return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
1459} 1464}
1460 1465
1461QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) 1466QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h)
1462{ 1467{
1463 return(QRect(x+5, y+3, w-(h/3)-13, h-5)); 1468 return(QRect(x+5, y+3, w-(h/3)-13, h-5));
1464} 1469}
1465 1470
1466void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, 1471void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
1467 int sliderStart, uint controls, 1472 int sliderStart, uint controls,
1468 uint activeControl) 1473 uint activeControl)
1469{ 1474{
1470 bool isHover = highlightWidget == p->device(); 1475 bool isHover = highlightWidget == p->device();
1471 int sliderMin, sliderMax, sliderLength, buttonDim; 1476 int sliderMin, sliderMax, sliderLength, buttonDim;
1472 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1477 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1473 1478
1474 if (sliderStart > sliderMax) 1479 if (sliderStart > sliderMax)
1475 sliderStart = sliderMax; 1480 sliderStart = sliderMax;
1476 1481
1477 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1482 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1478 QColorGroup g = sb->colorGroup(); 1483 QColorGroup g = sb->colorGroup();
1479 QRect addB, subHC, subB; 1484 QRect addB, subHC, subB;
1480 QRect addPageR, subPageR, sliderR; 1485 QRect addPageR, subPageR, sliderR;
1481 int addX, addY, subX, subY; 1486 int addX, addY, subX, subY;
1482 int len = horiz ? sb->width() : sb->height(); 1487 int len = horiz ? sb->width() : sb->height();
1483 int extent = horiz ? sb->height() : sb->width(); 1488 int extent = horiz ? sb->height() : sb->width();
1484 1489
1485 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar 1490 // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
1486 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. 1491 // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
1487 bool brokenApp; 1492 bool brokenApp;
1488 if(extent == 16) 1493 if(extent == 16)
1489 brokenApp = true; 1494 brokenApp = true;
1490 else 1495 else
1491 brokenApp = false; 1496 brokenApp = false;
1492 1497
1493 if (horiz) { 1498 if (horiz) {
1494 subY = addY = ( extent - buttonDim ) / 2; 1499 subY = addY = ( extent - buttonDim ) / 2;
1495 subX = 0; 1500 subX = 0;
1496 addX = len - buttonDim; 1501 addX = len - buttonDim;
1497 if(sbBuffer.size() != sb->size()) 1502 if(sbBuffer.size() != sb->size())
1498 sbBuffer.resize(sb->size()); 1503 sbBuffer.resize(sb->size());
1499 } 1504 }
1500 else { 1505 else {
1501 subX = addX = ( extent - buttonDim ) / 2; 1506 subX = addX = ( extent - buttonDim ) / 2;
1502 subY = 0; 1507 subY = 0;
1503 addY = len - buttonDim; 1508 addY = len - buttonDim;
1504 if(sbBuffer.size() != sb->size()) 1509 if(sbBuffer.size() != sb->size())
1505 sbBuffer.resize(sb->size()); 1510 sbBuffer.resize(sb->size());
1506 } 1511 }
1507 subB.setRect( subX,subY,buttonDim,buttonDim ); 1512 subB.setRect( subX,subY,buttonDim,buttonDim );
1508 addB.setRect( addX,addY,buttonDim,buttonDim ); 1513 addB.setRect( addX,addY,buttonDim,buttonDim );
1509 if(horiz) 1514 if(horiz)
1510 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); 1515 subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
1511 else 1516 else
1512 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); 1517 subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
1513 1518
1514 int sliderEnd = sliderStart + sliderLength; 1519 int sliderEnd = sliderStart + sliderLength;
1515 int sliderW = extent; 1520 int sliderW = extent;
1516 1521
1517 if (horiz) { 1522 if (horiz) {
1518 subPageR.setRect( subB.right() + 1, 0, 1523 subPageR.setRect( subB.right() + 1, 0,
1519 sliderStart - subB.right() - 1 , sliderW ); 1524 sliderStart - subB.right() - 1 , sliderW );
1520 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); 1525 addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
1521 sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); 1526 sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
1522 } 1527 }
1523 else { 1528 else {
1524 subPageR.setRect( 0, subB.bottom() + 1, sliderW, 1529 subPageR.setRect( 0, subB.bottom() + 1, sliderW,
1525 sliderStart - subB.bottom() - 1 ); 1530 sliderStart - subB.bottom() - 1 );
1526 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); 1531 addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
1527 sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); 1532 sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
1528 } 1533 }
1529 1534
1530 bool maxed = sb->maxValue() == sb->minValue(); 1535 bool maxed = sb->maxValue() == sb->minValue();
1531 1536
1532 QPainter painter; 1537 QPainter painter;
1533 if(!horiz){ 1538 if(!horiz){
1534 painter.begin(&sbBuffer); 1539 painter.begin(&sbBuffer);
1535 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1); 1540 QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1);
1536 if(sliderR.height() >= 8){ 1541 if(sliderR.height() >= 8){
1537 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, 1542 painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
1538 13, 8); 1543 13, 8);
1539 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); 1544 painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
1540 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, 1545 painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
1541 bgR.height()-16, *getPixmap(VSBSliderMidBg)); 1546 bgR.height()-16, *getPixmap(VSBSliderMidBg));
1542 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, 1547 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
1543 0, 0, 13, 8); 1548 0, 0, 13, 8);
1544 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); 1549 painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
1545 } 1550 }
1546 else{ 1551 else{
1547 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), 1552 painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
1548 *getPixmap(VSBSliderMidBg)); 1553 *getPixmap(VSBSliderMidBg));
1549 painter.setPen(g.background().dark(210)); 1554 painter.setPen(g.background().dark(210));
1550 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); 1555 painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
1551 painter.setPen(g.mid()); 1556 painter.setPen(g.mid());
1552 painter.drawPoint(bgR.x()+1, bgR.y()); 1557 painter.drawPoint(bgR.x()+1, bgR.y());
1553 painter.drawPoint(bgR.x()+13, bgR.y()); 1558 painter.drawPoint(bgR.x()+13, bgR.y());
1554 painter.drawPoint(bgR.x()+1, bgR.bottom()-1); 1559 painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
1555 painter.drawPoint(bgR.x()+13, bgR.bottom()-1); 1560 painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
1556 } 1561 }
1557 if(controls & Slider){ 1562 if(controls & Slider){
1558 if(sliderR.height() >= 16){ 1563 if(sliderR.height() >= 16){
1559 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1564 painter.drawPixmap(sliderR.x()+1, sliderR.y(),
1560 isHover ? *getPixmap(VSBSliderTopHover): 1565 isHover ? *getPixmap(VSBSliderTopHover):
1561 *getPixmap(VSBSliderTop)); 1566 *getPixmap(VSBSliderTop));
1562 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, 1567 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
1563 sliderR.height()-16, isHover ? 1568 sliderR.height()-16, isHover ?
1564 *getPixmap(VSBSliderMidHover) : 1569 *getPixmap(VSBSliderMidHover) :
1565 *getPixmap(VSBSliderMid)); 1570 *getPixmap(VSBSliderMid));
1566 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, 1571 painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8,
1567 isHover ? *getPixmap(VSBSliderBtmHover) : 1572 isHover ? *getPixmap(VSBSliderBtmHover) :
1568 *getPixmap(VSBSliderBtm)); 1573 *getPixmap(VSBSliderBtm));
1569 } 1574 }
1570 else if(sliderR.height() >= 8){ 1575 else if(sliderR.height() >= 8){
1571 int m = sliderR.height()/2; 1576 int m = sliderR.height()/2;
1572 painter.drawPixmap(sliderR.x()+1, sliderR.y(), 1577 painter.drawPixmap(sliderR.x()+1, sliderR.y(),
1573 isHover ? *getPixmap(VSBSliderTopHover): 1578 isHover ? *getPixmap(VSBSliderTopHover):
1574 *getPixmap(VSBSliderTop), 0, 0, 13, m); 1579 *getPixmap(VSBSliderTop), 0, 0, 13, m);
1575 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, 1580 painter.drawPixmap(sliderR.x()+1, sliderR.y()+m,
1576 isHover ? *getPixmap(VSBSliderBtmHover): 1581 isHover ? *getPixmap(VSBSliderBtmHover):
1577 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); 1582 *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
1578 } 1583 }
1579 else{ 1584 else{
1580 painter.setPen(g.button().dark(210)); 1585 painter.setPen(g.button().dark(210));
1581 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), 1586 drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
1582 13, sliderR.height()); 1587 13, sliderR.height());
1583 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, 1588 painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
1584 11, sliderR.height()-2, 1589 11, sliderR.height()-2,
1585 isHover ? *getPixmap(VSBSliderMidHover) : 1590 isHover ? *getPixmap(VSBSliderMidHover) :
1586 *getPixmap(VSBSliderMid), 1, 0); 1591 *getPixmap(VSBSliderMid), 1, 0);
1587 } 1592 }
1588 } 1593 }
1589 painter.setPen(g.mid()); 1594 painter.setPen(g.mid());
1590 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); 1595 painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
1591 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); 1596 painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
1592 if(brokenApp && (controls & Slider)){ 1597 if(brokenApp && (controls & Slider)){
1593 painter.setPen(g.background()); 1598 painter.setPen(g.background());
1594 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, 1599 painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
1595 bgR.bottom()); 1600 bgR.bottom());
1596 } 1601 }
1597 painter.end(); 1602 painter.end();
1598 } 1603 }
1599 else{ 1604 else{
1600 painter.begin(&sbBuffer); 1605 painter.begin(&sbBuffer);
1601 QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height()); 1606 QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height());
1602 if(sliderR.width() >= 8){ 1607 if(sliderR.width() >= 8){
1603 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, 1608 painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
1604 8, 13); 1609 8, 13);
1605 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); 1610 painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
1606 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, 1611 painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
1607 13, *getPixmap(HSBSliderMidBg)); 1612 13, *getPixmap(HSBSliderMidBg));
1608 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, 1613 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
1609 0, 0, 8, 13); 1614 0, 0, 8, 13);
1610 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); 1615 painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
1611 } 1616 }
1612 else{ 1617 else{
1613 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, 1618 painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
1614 *getPixmap(HSBSliderMidBg)); 1619 *getPixmap(HSBSliderMidBg));
1615 painter.setPen(g.background().dark(210)); 1620 painter.setPen(g.background().dark(210));
1616 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); 1621 painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
1617 painter.setPen(g.mid()); 1622 painter.setPen(g.mid());
1618 painter.drawPoint(bgR.x(), bgR.y()+1); 1623 painter.drawPoint(bgR.x(), bgR.y()+1);
1619 painter.drawPoint(bgR.x(), bgR.bottom()-1); 1624 painter.drawPoint(bgR.x(), bgR.bottom()-1);
1620 painter.drawPoint(bgR.right()-1, bgR.y()+1); 1625 painter.drawPoint(bgR.right()-1, bgR.y()+1);
1621 painter.drawPoint(bgR.right()-1, bgR.bottom()-1); 1626 painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
1622 } 1627 }
1623 if(controls & Slider){ 1628 if(controls & Slider){
1624 if(sliderR.width() >= 16){ 1629 if(sliderR.width() >= 16){
1625 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1630 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1626 isHover ? *getPixmap(HSBSliderTopHover) : 1631 isHover ? *getPixmap(HSBSliderTopHover) :
1627 *getPixmap(HSBSliderTop)); 1632 *getPixmap(HSBSliderTop));
1628 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, 1633 painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
1629 13, isHover ? *getPixmap(HSBSliderMidHover) : 1634 13, isHover ? *getPixmap(HSBSliderMidHover) :
1630 *getPixmap(HSBSliderMid)); 1635 *getPixmap(HSBSliderMid));
1631 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? 1636 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
1632 *getPixmap(HSBSliderBtmHover) : 1637 *getPixmap(HSBSliderBtmHover) :
1633 *getPixmap(HSBSliderBtm)); 1638 *getPixmap(HSBSliderBtm));
1634 } 1639 }
1635 else if(sliderR.width() >= 8){ 1640 else if(sliderR.width() >= 8){
1636 int m = sliderR.width()/2; 1641 int m = sliderR.width()/2;
1637 painter.drawPixmap(sliderR.x(), sliderR.y()+1, 1642 painter.drawPixmap(sliderR.x(), sliderR.y()+1,
1638 isHover ? *getPixmap(HSBSliderTopHover) : 1643 isHover ? *getPixmap(HSBSliderTopHover) :
1639 *getPixmap(HSBSliderTop), 0, 0, m, 13); 1644 *getPixmap(HSBSliderTop), 0, 0, m, 13);
1640 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? 1645 painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
1641 *getPixmap(HSBSliderBtmHover) : 1646 *getPixmap(HSBSliderBtmHover) :
1642 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); 1647 *getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
1643 } 1648 }
1644 else{ 1649 else{
1645 painter.setPen(g.button().dark(210)); 1650 painter.setPen(g.button().dark(210));
1646 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, 1651 drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
1647 sliderR.width(), 13); 1652 sliderR.width(), 13);
1648 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, 1653 painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
1649 sliderR.width()-2, 11, isHover ? 1654 sliderR.width()-2, 11, isHover ?
1650 *getPixmap(HSBSliderMidHover) : 1655 *getPixmap(HSBSliderMidHover) :
1651 *getPixmap(HSBSliderMid), 0, 1); 1656 *getPixmap(HSBSliderMid), 0, 1);
1652 } 1657 }
1653 } 1658 }
1654 painter.setPen(g.mid()); 1659 painter.setPen(g.mid());
1655 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); 1660 painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
1656 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); 1661 painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
1657 if(brokenApp && (controls & Slider)){ 1662 if(brokenApp && (controls & Slider)){
1658 painter.setPen(g.background()); 1663 painter.setPen(g.background());
1659 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), 1664 painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
1660 bgR.bottom()-1); 1665 bgR.bottom()-1);
1661 } 1666 }
1662 painter.end(); 1667 painter.end();
1663 } 1668 }
1664 1669
1665 if ( controls & AddLine ) { 1670 if ( controls & AddLine ) {
1666 drawSBButton(p, addB, g, activeControl == AddLine); 1671 drawSBButton(p, addB, g, activeControl == AddLine);
1667 drawArrow( p, horiz ? RightArrow : DownArrow, 1672 drawArrow( p, horiz ? RightArrow : DownArrow,
1668 false, addB.x()+4, addB.y()+4, 1673 false, addB.x()+4, addB.y()+4,
1669 addB.width()-8, addB.height()-8, g, !maxed); 1674 addB.width()-8, addB.height()-8, g, !maxed);
1670 } 1675 }
1671 if ( controls & SubLine ) { 1676 if ( controls & SubLine ) {
1672 drawSBButton(p, subB, g, activeControl == SubLine); 1677 drawSBButton(p, subB, g, activeControl == SubLine);
1673 drawArrow( p, horiz ? LeftArrow : UpArrow, 1678 drawArrow( p, horiz ? LeftArrow : UpArrow,
1674 false, subB.x()+4, subB.y()+4, 1679 false, subB.x()+4, subB.y()+4,
1675 subB.width()-8, subB.height()-8, g, !maxed); 1680 subB.width()-8, subB.height()-8, g, !maxed);
1676 drawSBButton(p, subHC, g, activeControl == SubLine); 1681 drawSBButton(p, subHC, g, activeControl == SubLine);
1677 drawArrow( p, horiz ? LeftArrow : UpArrow, 1682 drawArrow( p, horiz ? LeftArrow : UpArrow,
1678 false, subHC.x()+4, subHC.y()+4, 1683 false, subHC.x()+4, subHC.y()+4,
1679 subHC.width()-8, subHC.height()-8, g, !maxed); 1684 subHC.width()-8, subHC.height()-8, g, !maxed);
1680 } 1685 }
1681 1686
1682 if(controls & AddPage){ 1687 if(controls & AddPage){
1683 if(addPageR.width()){ 1688 if(addPageR.width()){
1684 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, 1689 p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
1685 addPageR.x(), addPageR.y(), addPageR.width(), 1690 addPageR.x(), addPageR.y(), addPageR.width(),
1686 addPageR.height()); 1691 addPageR.height());
1687 } 1692 }
1688 } 1693 }
1689 if(controls & SubPage){ 1694 if(controls & SubPage){
1690 if(subPageR.height()){ 1695 if(subPageR.height()){
1691 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, 1696 p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
1692 subPageR.x(), subPageR.y(), subPageR.width(), 1697 subPageR.x(), subPageR.y(), subPageR.width(),
1693 subPageR.height()); 1698 subPageR.height());
1694 } 1699 }
1695 } 1700 }
1696 if ( controls & Slider ) { 1701 if ( controls & Slider ) {
1697 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, 1702 p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
1698 sliderR.x(), sliderR.y(), sliderR.width(), 1703 sliderR.x(), sliderR.y(), sliderR.width(),
1699 sliderR.height()); 1704 sliderR.height());
1700 } 1705 }
1701} 1706}
1702 1707
1703void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, 1708void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
1704 bool down, bool /*fast*/) 1709 bool down, bool /*fast*/)
1705{ 1710{
1706 p->setPen(g.mid()); 1711 p->setPen(g.mid());
1707 p->drawRect(r); 1712 p->drawRect(r);
1708 QColor c(down ? g.button() : g.background()); 1713 QColor c(down ? g.button() : g.background());
1709 QPixmap *pix = bevelFillDict.find(c.rgb()); 1714 QPixmap *pix = bevelFillDict.find(c.rgb());
1710 if(!pix){ 1715 if(!pix){
1711 int h, s, v; 1716 int h, s, v;
1712 c.hsv(&h, &s, &v); 1717 c.hsv(&h, &s, &v);
1713 pix = new QPixmap(*bevelFillPix); 1718 pix = new QPixmap(*bevelFillPix);
1714 adjustHSV(*pix, h, s, v); 1719 adjustHSV(*pix, h, s, v);
1715 bevelFillDict.insert(c.rgb(), pix); 1720 bevelFillDict.insert(c.rgb(), pix);
1716 } 1721 }
1717 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); 1722 p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
1718 1723
1719} 1724}
1720 1725
1721void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, 1726void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
1722 bool horiz) 1727 bool horiz)
1723{ 1728{
1724 if(horiz){ 1729 if(horiz){
1725 if(r.width() >= 15){ 1730 if(r.width() >= 15){
1726 int y = r.y()+3; 1731 int y = r.y()+3;
1727 int x = r.x() + (r.width()-7)/2; 1732 int x = r.x() + (r.width()-7)/2;
1728 int y2 = r.bottom()-3; 1733 int y2 = r.bottom()-3;
1729 p->setPen(g.light()); 1734 p->setPen(g.light());
1730 p->drawLine(x, y, x, y2); 1735 p->drawLine(x, y, x, y2);
1731 p->drawLine(x+3, y, x+3, y2); 1736 p->drawLine(x+3, y, x+3, y2);
1732 p->drawLine(x+6, y, x+6, y2); 1737 p->drawLine(x+6, y, x+6, y2);
1733 1738
1734 p->setPen(g.mid()); 1739 p->setPen(g.mid());
1735 p->drawLine(x+1, y, x+1, y2); 1740 p->drawLine(x+1, y, x+1, y2);
1736 p->drawLine(x+4, y, x+4, y2); 1741 p->drawLine(x+4, y, x+4, y2);
1737 p->drawLine(x+7, y, x+7, y2); 1742 p->drawLine(x+7, y, x+7, y2);
1738 } 1743 }
1739 } 1744 }
1740 else{ 1745 else{
1741 if(r.height() >= 15){ 1746 if(r.height() >= 15){
1742 int x = r.x()+3; 1747 int x = r.x()+3;
1743 int y = r.y() + (r.height()-7)/2; 1748 int y = r.y() + (r.height()-7)/2;
1744 int x2 = r.right()-3; 1749 int x2 = r.right()-3;
1745 p->setPen(g.light()); 1750 p->setPen(g.light());
1746 p->drawLine(x, y, x2, y); 1751 p->drawLine(x, y, x2, y);
1747 p->drawLine(x, y+3, x2, y+3); 1752 p->drawLine(x, y+3, x2, y+3);
1748 p->drawLine(x, y+6, x2, y+6); 1753 p->drawLine(x, y+6, x2, y+6);
1749 1754
1750 p->setPen(g.mid()); 1755 p->setPen(g.mid());
1751 p->drawLine(x, y+1, x2, y+1); 1756 p->drawLine(x, y+1, x2, y+1);
1752 p->drawLine(x, y+4, x2, y+4); 1757 p->drawLine(x, y+4, x2, y+4);
1753 p->drawLine(x, y+7, x2, y+7); 1758 p->drawLine(x, y+7, x2, y+7);
1754 } 1759 }
1755 } 1760 }
1756 1761
1757} 1762}
1758 1763
1759 1764
1760void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, 1765void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
1761 int &sliderMax, int &sliderLength, 1766 int &sliderMax, int &sliderLength,
1762 int &buttonDim) 1767 int &buttonDim)
1763{ 1768{
1764 1769
1765 int maxLength; 1770 int maxLength;
1766 int b = 0; 1771 int b = 0;
diff --git a/noncore/styles/liquid/liquid.pro b/noncore/styles/liquid/liquid.pro
index 8689d3d..23dce09 100644
--- a/noncore/styles/liquid/liquid.pro
+++ b/noncore/styles/liquid/liquid.pro
@@ -1,28 +1,30 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG = qt embedded release warn_on 2CONFIG = qt embedded release warn_on
3SOURCES = liquid.cpp \ 3SOURCES = liquid.cpp \
4 liquiddeco.cpp \
4 effects.cpp \ 5 effects.cpp \
5 plugin.cpp 6 plugin.cpp
6 7
7HEADERS = liquid.h \ 8HEADERS = liquid.h \
9 liquiddeco.h \
8 effects.h 10 effects.h
9LIBS += -lqpe 11LIBS += -lqpe
10INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
11DESTDIR = $(OPIEDIR)/plugins/styles 13DESTDIR = $(OPIEDIR)/plugins/styles
12TARGET = liquid 14TARGET = liquid
13VERSION = 1.0.0 15VERSION = 1.0.0
14 16
15TRANSLATIONS = ../../../i18n/de/libliquid.ts \ 17TRANSLATIONS = ../../../i18n/de/libliquid.ts \
16 ../../../i18n/en/libliquid.ts \ 18 ../../../i18n/en/libliquid.ts \
17 ../../../i18n/es/libliquid.ts \ 19 ../../../i18n/es/libliquid.ts \
18 ../../../i18n/fr/libliquid.ts \ 20 ../../../i18n/fr/libliquid.ts \
19 ../../../i18n/hu/libliquid.ts \ 21 ../../../i18n/hu/libliquid.ts \
20 ../../../i18n/ja/libliquid.ts \ 22 ../../../i18n/ja/libliquid.ts \
21 ../../../i18n/ko/libliquid.ts \ 23 ../../../i18n/ko/libliquid.ts \
22 ../../../i18n/no/libliquid.ts \ 24 ../../../i18n/no/libliquid.ts \
23 ../../../i18n/pl/libliquid.ts \ 25 ../../../i18n/pl/libliquid.ts \
24 ../../../i18n/pt/libliquid.ts \ 26 ../../../i18n/pt/libliquid.ts \
25 ../../../i18n/pt_BR/libliquid.ts \ 27 ../../../i18n/pt_BR/libliquid.ts \
26 ../../../i18n/sl/libliquid.ts \ 28 ../../../i18n/sl/libliquid.ts \
27 ../../../i18n/zh_CN/libliquid.ts \ 29 ../../../i18n/zh_CN/libliquid.ts \
28 ../../../i18n/zh_TW/libliquid.ts 30 ../../../i18n/zh_TW/libliquid.ts
diff --git a/noncore/styles/liquid/liquiddeco.cpp b/noncore/styles/liquid/liquiddeco.cpp
new file mode 100644
index 0000000..8eee1b1
--- a/dev/null
+++ b/noncore/styles/liquid/liquiddeco.cpp
@@ -0,0 +1,183 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qapplication.h>
22#include <qstyle.h>
23#include <qwidget.h>
24#include <qpainter.h>
25#include <qtimer.h>
26#include <qwhatsthis.h>
27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qpedecoration_qws.h>
29#include <qdialog.h>
30#include <qdrawutil.h>
31#include <qgfx_qws.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/resource.h>
34#include <qpe/global.h>
35#include <qfile.h>
36#include <qsignal.h>
37
38#include "liquiddeco.h"
39
40#include <stdlib.h>
41
42extern QRect qt_maxWindowRect;
43
44class HackWidget : public QWidget
45{
46public:
47 bool needsOk()
48 {
49 return ( getWState() & WState_Reserved1 );
50 }
51};
52
53
54LiquidDecoration::LiquidDecoration()
55 : QPEDecoration()
56{}
57
58LiquidDecoration::~LiquidDecoration()
59{}
60
61int LiquidDecoration::getTitleHeight( const QWidget * )
62{
63 return 15;
64}
65
66
67void LiquidDecoration::paint( QPainter *painter, const QWidget *widget )
68{
69 int titleWidth = getTitleWidth( widget );
70 int titleHeight = getTitleHeight( widget );
71
72 QRect rect( widget->rect() );
73
74 // Border rect
75 QRect br( rect.left() - BORDER_WIDTH,
76 rect.top() - BORDER_WIDTH - titleHeight,
77 rect.width() + 2 * BORDER_WIDTH,
78 rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight );
79
80 // title bar rect
81 QRect tr;
82
83 tr = QRect( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
84
85 QRegion oldClip = painter->clipRegion();
86 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker
87
88 bool isActive = ( widget == qApp->activeWindow() );
89
90 QColorGroup cg = QApplication::palette().active();
91 if ( isActive )
92 cg. setBrush ( QColorGroup::Button, cg. brush ( QColorGroup::Highlight ) );
93
94 qDrawWinPanel( painter, br.x(), br.y(), br.width(),
95 br.height() - 4, cg, FALSE,
96 &cg.brush( QColorGroup::Background ) );
97
98 painter->setClipRegion( oldClip );
99
100 if ( titleWidth > 0 ) {
101 QBrush titleBrush;
102 QPen titlePen;
103 QPen titleLines;
104 int titleLeft = titleHeight + 4;
105
106 titleLeft = rect.left() + 5;
107 painter->setPen( cg.midlight() );
108 painter->drawLine( rect.left() - BORDER_WIDTH + 2,
109 rect.bottom() + 1, rect.right() + BORDER_WIDTH - 2,
110 rect.bottom() + 1 );
111
112 QRect t ( rect.left() - 2, rect.top() - titleHeight - 2, rect.width() + 3, titleHeight + 2 );
113
114
115
116 QApplication::style().drawBevelButton( painter, t.x(), t.y(), t.width(), t.height(), cg, isActive );
117
118 t.setLeft( t.left() + 4 );
119 t.setRight( t.right() - 2 );
120
121 QFont f( QApplication::font() );
122 f.setWeight( QFont::Bold );
123
124 painter-> setFont( f );
125
126 QColor textcol = cg.color( isActive ? QColorGroup::HighlightedText : QColorGroup::Text );
127 QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 130 ) : textcol.light( 200 );
128
129 if ( textcol == shadecol ) {
130 if ( qGray ( shadecol. rgb ( ) ) < 128 )
131 shadecol = QColor ( 225, 225, 225 );
132 else
133 shadecol = QColor ( 30, 30, 30 );
134 }
135
136 painter-> setPen( shadecol );
137 painter-> drawText( t.x() + 1, t.y() + 1, t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() );
138 painter-> setPen( textcol );
139 painter-> drawText( t.x(), t.y(), t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() );
140 }
141
142#ifndef MINIMIZE_HELP_HACK
143 paintButton( painter, widget, ( QWSDecoration::Region ) Help, 0 );
144#endif
145}
146
147void LiquidDecoration::paintButton( QPainter *painter, const QWidget *w,
148 QWSDecoration::Region type, int state )
149{
150 const QColorGroup & cg = w->palette().active();
151
152 QRect brect( region( w, w->rect(), type ).boundingRect() );
153
154 const QImage *img = 0;
155
156 switch ( ( int ) type ) {
157 case Close:
158 img = &imageClose;
159 break;
160 case Minimize:
161 if ( ( ( HackWidget * ) w ) ->needsOk() ||
162 ( w->inherits( "QDialog" ) && !w->inherits( "QMessageBox" ) ) )
163 img = &imageOk;
164 else if ( helpExists )
165 img = &imageHelp;
166 break;
167 case Help:
168 img = &imageHelp;
169 break;
170 default:
171 return ;
172 }
173
174 if ( img ) {
175 if ( ( state & QWSButton::MouseOver ) && ( state & QWSButton::Clicked ) )
176 painter->drawImage( brect.x() + 1, brect.y() + 3, *img );
177 else
178 painter->drawImage( brect.x(), brect.y() + 2, *img );
179 }
180}
181
182
183
diff --git a/noncore/styles/liquid/liquiddeco.h b/noncore/styles/liquid/liquiddeco.h
new file mode 100644
index 0000000..d975fe5
--- a/dev/null
+++ b/noncore/styles/liquid/liquiddeco.h
@@ -0,0 +1,41 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef OPIE_LIQUIDDECO_H__
21#define OPIE_LIQUIDDECO_H__
22
23#include <qpe/qpedecoration_qws.h>
24
25
26class LiquidDecoration : public QPEDecoration
27{
28public:
29 LiquidDecoration();
30 virtual ~LiquidDecoration();
31
32 virtual void paint(QPainter *, const QWidget *);
33 virtual void paintButton(QPainter *, const QWidget *, Region, int state);
34
35protected:
36 virtual int getTitleHeight(const QWidget *);
37};
38
39
40
41#endif // OPIE_LIQUIDDECO_H__