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