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