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