summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-23 21:34:09 (UTC)
committer sandman <sandman>2002-10-23 21:34:09 (UTC)
commiteb521bfc7d3a05f900f6c81db25aa4cea572f064 (patch) (unidiff)
tree538988925c7a761b10561e765f1684dd4da016eb
parent71f52c08e595cb3bfa3697baa97b4279325fa9ac (diff)
downloadopie-eb521bfc7d3a05f900f6c81db25aa4cea572f064.zip
opie-eb521bfc7d3a05f900f6c81db25aa4cea572f064.tar.gz
opie-eb521bfc7d3a05f900f6c81db25aa4cea572f064.tar.bz2
fixed a transparency bug: every QWidget child in a QPopupMenu had a full
transparent bg-pixmap
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 4013981..eb1ec6e 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,416 +1,414 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5 5
6 6
7#ifndef INCLUDE_MENUITEM_DEF 7#ifndef INCLUDE_MENUITEM_DEF
8#define INCLUDE_MENUITEM_DEF 8#define INCLUDE_MENUITEM_DEF
9#endif 9#endif
10 10
11#include <qmenudata.h> 11#include <qmenudata.h>
12#include "liquid.h" 12#include "liquid.h"
13//#include "liquiddeco.h" 13//#include "liquiddeco.h"
14#include <qapplication.h> 14#include <qapplication.h>
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include "effects.h" 16#include "effects.h"
17#include <qpalette.h> 17#include <qpalette.h>
18#include <qbitmap.h> 18#include <qbitmap.h>
19#include <qtabbar.h> 19#include <qtabbar.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qobjectlist.h> 21#include <qobjectlist.h>
22#include <qimage.h> 22#include <qimage.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qpixmapcache.h> 24#include <qpixmapcache.h>
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qwidgetlist.h> 28#include <qwidgetlist.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qheader.h> 30#include <qheader.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qprogressbar.h> 33#include <qprogressbar.h>
34 34
35#include <stdio.h> 35#include <stdio.h>
36 36
37#include "htmlmasks.h" 37#include "htmlmasks.h"
38#include "embeddata.h" 38#include "embeddata.h"
39 39
40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 40typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
41 QColorGroup &, bool, bool); 41 QColorGroup &, bool, bool);
42 42
43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 43QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
44 44
45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 45void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
46{ 46{
47 QImage img(pix.convertToImage()); 47 QImage img(pix.convertToImage());
48 QImageEffect::fade(img, 0.9, color); 48 QImageEffect::fade(img, 0.9, color);
49 int x, y; 49 int x, y;
50 int r, g, b; 50 int r, g, b;
51 for(y=0; y < img.height(); y+=3){ 51 for(y=0; y < img.height(); y+=3){
52 unsigned int *data = (unsigned int *) img.scanLine(y); 52 unsigned int *data = (unsigned int *) img.scanLine(y);
53 for(x=0; x < img.width(); ++x){ 53 for(x=0; x < img.width(); ++x){
54 r = qRed(data[x]); 54 r = qRed(data[x]);
55 g = qGreen(data[x]); 55 g = qGreen(data[x]);
56 b = qBlue(data[x]); 56 b = qBlue(data[x]);
57 if(r-10) 57 if(r-10)
58 r-=10; 58 r-=10;
59 if(g-10) 59 if(g-10)
60 g-=10; 60 g-=10;
61 if(b-10) 61 if(b-10)
62 b-=10; 62 b-=10;
63 data[x] = qRgb(r, g, b); 63 data[x] = qRgb(r, g, b);
64 } 64 }
65 } 65 }
66 pix.convertFromImage(img); 66 pix.convertFromImage(img);
67} 67}
68 68
69TransMenuHandler::TransMenuHandler(QObject *parent) 69TransMenuHandler::TransMenuHandler(QObject *parent)
70 : QObject(parent) 70 : QObject(parent)
71{ 71{
72 pixDict.setAutoDelete(true); 72 pixDict.setAutoDelete(true);
73 reloadSettings(); 73 reloadSettings();
74} 74}
75 75
76void TransMenuHandler::reloadSettings() 76void TransMenuHandler::reloadSettings()
77{ 77{
78 pixDict.clear(); 78 pixDict.clear();
79 79
80 Config config ( "qpe" ); 80 Config config ( "qpe" );
81 config. setGroup ( "Liquid-Style" ); 81 config. setGroup ( "Liquid-Style" );
82 82
83 type = config. readNumEntry("Type", TransStippleBg); 83 type = config. readNumEntry("Type", TransStippleBg);
84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 84 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 85 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
86 opacity = config. readNumEntry("Opacity", 10); 86 opacity = config. readNumEntry("Opacity", 10);
87 if ( opacity < -20 ) 87 if ( opacity < -20 )
88 opacity = 20; 88 opacity = 20;
89 else if ( opacity > 20 ) 89 else if ( opacity > 20 )
90 opacity = 20; 90 opacity = 20;
91 91
92 shadowText = config. readBoolEntry("ShadowText", true); 92 shadowText = config. readBoolEntry("ShadowText", true);
93} 93}
94 94
95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 95bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
96{ 96{
97 QWidget *p = (QWidget *)obj; 97 QWidget *p = (QWidget *)obj;
98 98
99 if(ev->type() == QEvent::Show){ 99 if(ev->type() == QEvent::Show){
100 if(type == TransStippleBg || type == TransStippleBtn || 100 if(type == TransStippleBg || type == TransStippleBtn ||
101 type == Custom){ 101 type == Custom){
102 QApplication::syncX(); 102 QApplication::syncX();
103 QPixmap *pix = new QPixmap; 103 QPixmap *pix = new QPixmap;
104 if(p->testWFlags(Qt::WType_Popup)){ 104 if(p->testWFlags(Qt::WType_Popup)){
105 QRect r(p->x(), p->y(), p->width(), p->height()); 105 QRect r(p->x(), p->y(), p->width(), p->height());
106 QRect deskR = QApplication::desktop()->rect(); 106 QRect deskR = QApplication::desktop()->rect();
107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 107 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
108 r.setBottom(deskR.bottom()); 108 r.setBottom(deskR.bottom());
109 r.setRight(deskR.right()); 109 r.setRight(deskR.right());
110 } 110 }
111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 111 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
112 r.width(), r.height()); 112 r.width(), r.height());
113 } 113 }
114 else{ // tear off menu 114 else{ // tear off menu
115 pix->resize(p->width(), p->height()); 115 pix->resize(p->width(), p->height());
116 pix->fill(Qt::black.rgb()); 116 pix->fill(Qt::black.rgb());
117 } 117 }
118 if(type == TransStippleBg){ 118 if(type == TransStippleBg){
119 stripePixmap(*pix, p->colorGroup().background()); 119 stripePixmap(*pix, p->colorGroup().background());
120 } 120 }
121 else if(type == TransStippleBtn){ 121 else if(type == TransStippleBtn){
122 stripePixmap(*pix, p->colorGroup().button()); 122 stripePixmap(*pix, p->colorGroup().button());
123 } 123 }
124 else{ 124 else{
125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 125 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
126 } 126 }
127 127
128 pixDict.insert(p->winId(), pix); 128 pixDict.insert(p->winId(), pix);
129 129
130 if (!p->inherits("QPopupMenu")) { 130 if ( !p->inherits("QPopupMenu"))
131 p->setBackgroundPixmap(*pix); 131 p->setBackgroundPixmap(*pix);
132 132
133 QObjectList *ol = p-> queryList("QWidget"); 133 QObjectList *ol = p-> queryList("QWidget");
134 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 134 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
135 QWidget *wid = (QWidget *) it.current ( ); 135 QWidget *wid = (QWidget *) it.current ( );
136 136
137 wid-> setBackgroundPixmap(*pix); 137 wid-> setBackgroundPixmap(*pix);
138 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 138 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
139 } 139 }
140 delete ol; 140 delete ol;
141 }
142 } 141 }
143 } 142 }
144 else if(ev->type() == QEvent::Hide){ 143 else if(ev->type() == QEvent::Hide){
145 if(type == TransStippleBg || type == TransStippleBtn || 144 if(type == TransStippleBg || type == TransStippleBtn ||
146 type == Custom){ 145 type == Custom){
147// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 146// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
148 147
149 pixDict.remove(p->winId()); 148 pixDict.remove(p->winId());
150 if (!p->inherits("QPopupMenu")) { 149 if ( !p->inherits("QPopupMenu"))
151 p->setBackgroundMode(QWidget::PaletteBackground); 150 p->setBackgroundMode(QWidget::PaletteBackground);
152 151
153 QObjectList *ol = p-> queryList("QWidget"); 152 QObjectList *ol = p-> queryList("QWidget");
154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 153 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
155 QWidget *wid = (QWidget *) it.current ( ); 154 QWidget *wid = (QWidget *) it.current ( );
156 155
157 wid-> setBackgroundMode( QWidget::PaletteBackground ); 156 wid-> setBackgroundMode( QWidget::PaletteBackground );
158 }
159 delete ol;
160 } 157 }
158 delete ol;
161 } 159 }
162 } 160 }
163 return(false); 161 return(false);
164} 162}
165 163
166 164
167LiquidStyle::LiquidStyle() 165LiquidStyle::LiquidStyle()
168 :QWindowsStyle() 166 :QWindowsStyle()
169{ 167{
170 setName ( "LiquidStyle" ); 168 setName ( "LiquidStyle" );
171 169
172 flatTBButtons = false; 170 flatTBButtons = false;
173 171
174 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 172 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
175 btnMaskBmp.setMask(btnMaskBmp); 173 btnMaskBmp.setMask(btnMaskBmp);
176 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 174 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
177 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 175 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
178 headerHoverID = -1; 176 headerHoverID = -1;
179 highlightWidget = NULL; 177 highlightWidget = NULL;
180 setButtonDefaultIndicatorWidth(0); 178 setButtonDefaultIndicatorWidth(0);
181 btnDict.setAutoDelete(true); 179 btnDict.setAutoDelete(true);
182 bevelFillDict.setAutoDelete(true); 180 bevelFillDict.setAutoDelete(true);
183 smallBevelFillDict.setAutoDelete(true); 181 smallBevelFillDict.setAutoDelete(true);
184 customBtnColorList.setAutoDelete(true); 182 customBtnColorList.setAutoDelete(true);
185 customBtnIconList.setAutoDelete(true); 183 customBtnIconList.setAutoDelete(true);
186 customBtnLabelList.setAutoDelete(true); 184 customBtnLabelList.setAutoDelete(true);
187 185
188 rMatrix.rotate(270.0); 186 rMatrix.rotate(270.0);
189 highcolor = QPixmap::defaultDepth() > 8; 187 highcolor = QPixmap::defaultDepth() > 8;
190 btnBorderPix = new QPixmap; 188 btnBorderPix = new QPixmap;
191 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 189 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
192 btnBlendPix = new QPixmap; 190 btnBlendPix = new QPixmap;
193 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 191 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
194 bevelFillPix = new QPixmap; 192 bevelFillPix = new QPixmap;
195 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 193 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
196 smallBevelFillPix = new QPixmap; 194 smallBevelFillPix = new QPixmap;
197 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 195 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
198 // new stuff 196 // new stuff
199 vsbSliderFillPix = menuPix = NULL; 197 vsbSliderFillPix = menuPix = NULL;
200 menuHandler = new TransMenuHandler(this); 198 menuHandler = new TransMenuHandler(this);
201 setScrollBarExtent(15, 15); 199 setScrollBarExtent(15, 15);
202 int i; 200 int i;
203 for(i=0; i < BITMAP_ITEMS; ++i){ 201 for(i=0; i < BITMAP_ITEMS; ++i){
204 pixmaps[i] = NULL; 202 pixmaps[i] = NULL;
205 } 203 }
206 oldSliderThickness = sliderThickness(); 204 oldSliderThickness = sliderThickness();
207 setSliderThickness(11); 205 setSliderThickness(11);
208} 206}
209 207
210LiquidStyle::~LiquidStyle() 208LiquidStyle::~LiquidStyle()
211{ 209{
212 if(btnBorderPix) 210 if(btnBorderPix)
213 delete btnBorderPix; 211 delete btnBorderPix;
214 if(btnBlendPix) 212 if(btnBlendPix)
215 delete btnBlendPix; 213 delete btnBlendPix;
216 if(bevelFillPix) 214 if(bevelFillPix)
217 delete bevelFillPix; 215 delete bevelFillPix;
218 if(smallBevelFillPix) 216 if(smallBevelFillPix)
219 delete smallBevelFillPix; 217 delete smallBevelFillPix;
220 if(vsbSliderFillPix) 218 if(vsbSliderFillPix)
221 delete vsbSliderFillPix; 219 delete vsbSliderFillPix;
222 if(menuPix) 220 if(menuPix)
223 delete menuPix; 221 delete menuPix;
224 222
225 setScrollBarExtent(16, 16); 223 setScrollBarExtent(16, 16);
226 setSliderThickness(oldSliderThickness); 224 setSliderThickness(oldSliderThickness);
227 int i; 225 int i;
228 for(i=0; i < BITMAP_ITEMS; ++i){ 226 for(i=0; i < BITMAP_ITEMS; ++i){
229 if(pixmaps[i]) 227 if(pixmaps[i])
230 delete pixmaps[i]; 228 delete pixmaps[i];
231 } 229 }
232} 230}
233 231
234void 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,
235 const QColor &c, const QColor &bg) 233 const QColor &c, const QColor &bg)
236{ 234{
237 235
238 QPen oldPen = p->pen(); // headers need this 236 QPen oldPen = p->pen(); // headers need this
239 int x2 = x+w-1; 237 int x2 = x+w-1;
240 int y2 = y+h-1; 238 int y2 = y+h-1;
241 // outer dark rect 239 // outer dark rect
242 p->setPen(c.dark(130)); 240 p->setPen(c.dark(130));
243 p->drawLine(x, y+2, x, y2-2); // l 241 p->drawLine(x, y+2, x, y2-2); // l
244 p->drawLine(x2, y+2, x2, y2-2); // r 242 p->drawLine(x2, y+2, x2, y2-2); // r
245 p->drawLine(x+2, y, x2-2, y); // t 243 p->drawLine(x+2, y, x2-2, y); // t
246 p->drawLine(x+2, y2, x2-2, y2); // b 244 p->drawLine(x+2, y2, x2-2, y2); // b
247 p->drawPoint(x+1, y+1); // tl 245 p->drawPoint(x+1, y+1); // tl
248 p->drawPoint(x2-1, y+1); // tr 246 p->drawPoint(x2-1, y+1); // tr
249 p->drawPoint(x+1, y2-1); // bl 247 p->drawPoint(x+1, y2-1); // bl
250 p->drawPoint(x2-1, y2-1); // br 248 p->drawPoint(x2-1, y2-1); // br
251 249
252 // inner top light lines 250 // inner top light lines
253 p->setPen(c.light(105)); 251 p->setPen(c.light(105));
254 p->drawLine(x+2, y+1, x2-2, y+1); 252 p->drawLine(x+2, y+1, x2-2, y+1);
255 p->drawLine(x+1, y+2, x2-1, y+2); 253 p->drawLine(x+1, y+2, x2-1, y+2);
256 p->drawLine(x+1, y+3, x+2, y+3); 254 p->drawLine(x+1, y+3, x+2, y+3);
257 p->drawLine(x2-2, y+3, x2-1, y+3); 255 p->drawLine(x2-2, y+3, x2-1, y+3);
258 p->drawPoint(x+1, y+4); 256 p->drawPoint(x+1, y+4);
259 p->drawPoint(x2-1, y+4); 257 p->drawPoint(x2-1, y+4);
260 258
261 // inner bottom light lines 259 // inner bottom light lines
262 p->setPen(c.light(110)); 260 p->setPen(c.light(110));
263 p->drawLine(x+2, y2-1, x2-2, y2-1); 261 p->drawLine(x+2, y2-1, x2-2, y2-1);
264 p->drawLine(x+1, y2-2, x2-1, y2-2); 262 p->drawLine(x+1, y2-2, x2-1, y2-2);
265 p->drawLine(x+1, y2-3, x+2, y2-3); 263 p->drawLine(x+1, y2-3, x+2, y2-3);
266 p->drawLine(x2-2, y2-3, x2-1, y2-3); 264 p->drawLine(x2-2, y2-3, x2-1, y2-3);
267 p->drawPoint(x+1, y2-4); 265 p->drawPoint(x+1, y2-4);
268 p->drawPoint(x2-1, y2-4); 266 p->drawPoint(x2-1, y2-4);
269 267
270 // inner left mid lines 268 // inner left mid lines
271 //p->setPen(c.light(105)); 269 //p->setPen(c.light(105));
272 p->setPen(c); 270 p->setPen(c);
273 p->drawLine(x+1, y+5, x+1, y2-5); 271 p->drawLine(x+1, y+5, x+1, y2-5);
274 p->drawLine(x+2, y+4, x+2, y2-4); 272 p->drawLine(x+2, y+4, x+2, y2-4);
275 273
276 // inner right mid lines 274 // inner right mid lines
277 p->drawLine(x2-1, y+5, x2-1, y2-5); 275 p->drawLine(x2-1, y+5, x2-1, y2-5);
278 p->drawLine(x2-2, y+4, x2-2, y2-4); 276 p->drawLine(x2-2, y+4, x2-2, y2-4);
279 277
280 // fill 278 // fill
281 QPixmap *pix; 279 QPixmap *pix;
282 if(h >= 32){ 280 if(h >= 32){
283 pix = bevelFillDict.find(c.rgb()); 281 pix = bevelFillDict.find(c.rgb());
284 if(!pix){ 282 if(!pix){
285 int h, s, v; 283 int h, s, v;
286 c.hsv(&h, &s, &v); 284 c.hsv(&h, &s, &v);
287 pix = new QPixmap(*bevelFillPix); 285 pix = new QPixmap(*bevelFillPix);
288 adjustHSV(*pix, h, s, v); 286 adjustHSV(*pix, h, s, v);
289 bevelFillDict.insert(c.rgb(), pix); 287 bevelFillDict.insert(c.rgb(), pix);
290 } 288 }
291 } 289 }
292 else{ 290 else{
293 pix = smallBevelFillDict.find(c.rgb()); 291 pix = smallBevelFillDict.find(c.rgb());
294 if(!pix){ 292 if(!pix){
295 int h, s, v; 293 int h, s, v;
296 c.hsv(&h, &s, &v); 294 c.hsv(&h, &s, &v);
297 pix = new QPixmap(*smallBevelFillPix); 295 pix = new QPixmap(*smallBevelFillPix);
298 adjustHSV(*pix, h, s, v); 296 adjustHSV(*pix, h, s, v);
299 smallBevelFillDict.insert(c.rgb(), pix); 297 smallBevelFillDict.insert(c.rgb(), pix);
300 } 298 }
301 } 299 }
302 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 300 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
303 // blend 301 // blend
304 int red, green, blue; 302 int red, green, blue;
305 QColor btnColor(c.dark(130)); 303 QColor btnColor(c.dark(130));
306 red = (btnColor.red() >> 1) + (bg.red() >> 1); 304 red = (btnColor.red() >> 1) + (bg.red() >> 1);
307 green = (btnColor.green() >> 1) + (bg.green() >> 1); 305 green = (btnColor.green() >> 1) + (bg.green() >> 1);
308 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 306 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
309 btnColor.setRgb(red, green, blue); 307 btnColor.setRgb(red, green, blue);
310 308
311 p->setPen(btnColor); 309 p->setPen(btnColor);
312 p->drawPoint(x+1, y); 310 p->drawPoint(x+1, y);
313 p->drawPoint(x, y+1); 311 p->drawPoint(x, y+1);
314 p->drawPoint(x+1, y2); 312 p->drawPoint(x+1, y2);
315 p->drawPoint(x, y2-1); 313 p->drawPoint(x, y2-1);
316 314
317 p->drawPoint(x2-1, y); 315 p->drawPoint(x2-1, y);
318 p->drawPoint(x2, y+1); 316 p->drawPoint(x2, y+1);
319 p->drawPoint(x2-1, y2); 317 p->drawPoint(x2-1, y2);
320 p->drawPoint(x2, y2-1); 318 p->drawPoint(x2, y2-1);
321 319
322 p->setPen(oldPen); 320 p->setPen(oldPen);
323 321
324} 322}
325 323
326void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 324void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
327 const QColor &back, int x, int y, int w, int h, 325 const QColor &back, int x, int y, int w, int h,
328 bool supportPushDown, bool pushedDown, 326 bool supportPushDown, bool pushedDown,
329 bool autoDefault, bool isMasked) 327 bool autoDefault, bool isMasked)
330{ 328{
331 if(w < 21 || h < 21){ 329 if(w < 21 || h < 21){
332 drawClearBevel(painter, x, y, w, h, c, back); 330 drawClearBevel(painter, x, y, w, h, c, back);
333 return; 331 return;
334 } 332 }
335 if(supportPushDown){ 333 if(supportPushDown){
336 --w, --h; 334 --w, --h;
337 } 335 }
338 /* 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
339 if(autoDefault){ 337 if(autoDefault){
340 w = w-buttonDefaultIndicatorWidth()*2; 338 w = w-buttonDefaultIndicatorWidth()*2;
341 h = h-buttonDefaultIndicatorWidth()*2; 339 h = h-buttonDefaultIndicatorWidth()*2;
342 }*/ 340 }*/
343 341
344 342
345 QPixmap *pix = btnDict.find(c.rgb()); 343 QPixmap *pix = btnDict.find(c.rgb());
346 if(!pix){ 344 if(!pix){
347 int h, s, v; 345 int h, s, v;
348 c.hsv(&h, &s, &v); 346 c.hsv(&h, &s, &v);
349 pix = new QPixmap(*btnBorderPix); 347 pix = new QPixmap(*btnBorderPix);
350 adjustHSV(*pix, h, s, v); 348 adjustHSV(*pix, h, s, v);
351 btnDict.insert(c.rgb(), pix); 349 btnDict.insert(c.rgb(), pix);
352 } 350 }
353 int x2 = x+w-1; 351 int x2 = x+w-1;
354 int y2 = y+h-1; 352 int y2 = y+h-1;
355 int bx2 = pix->width()-1; 353 int bx2 = pix->width()-1;
356 int by2 = pix->height()-1; 354 int by2 = pix->height()-1;
357 355
358 QPixmap tmpPix(w, h); 356 QPixmap tmpPix(w, h);
359 QPixmap tilePix; 357 QPixmap tilePix;
360 QPainter p; 358 QPainter p;
361 p.begin(&tmpPix); 359 p.begin(&tmpPix);
362 360
363 // do the fill 361 // do the fill
364 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 362 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
365 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
366 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
367 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
368 366
369 // edges 367 // edges
370 tilePix.resize(pix->width()-20, 10); 368 tilePix.resize(pix->width()-20, 10);
371 // top 369 // top
372 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); 370 bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
373 p.drawTiledPixmap(10, 0, w-20, 10, tilePix); 371 p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
374 // bottom 372 // bottom
375 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);
376 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); 374 p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
377 // left 375 // left
378 tilePix.resize(10, pix->height()-20); 376 tilePix.resize(10, pix->height()-20);
379 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); 377 bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
380 p.drawTiledPixmap(0, 10, 10, h-20, tilePix); 378 p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
381 // right 379 // right
382 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);
383 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); 381 p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
384 382
385 // middle 383 // middle
386 tilePix.resize(pix->width()-20, pix->height()-20); 384 tilePix.resize(pix->width()-20, pix->height()-20);
387 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);
388 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); 386 p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
389 387
390 388
391 // do the blend 389 // do the blend
392 QBitmap blendMask; 390 QBitmap blendMask;
393 if(!isMasked){ 391 if(!isMasked){
394 //QRgb bgRgb = back.rgb(); 392 //QRgb bgRgb = back.rgb();
395 //QRgb fgRgb = c.rgb(); 393 //QRgb fgRgb = c.rgb();
396 //int r, g, b; 394 //int r, g, b;
397 395
398 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); 396 //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
399 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); 397 //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
400 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); 398 //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
401 //QColor blendColor(r, g, b); 399 //QColor blendColor(r, g, b);
402 int hue, sat, v1, v2; 400 int hue, sat, v1, v2;
403 QColor blendColor(autoDefault ? c : back); 401 QColor blendColor(autoDefault ? c : back);
404 back.hsv(&hue, &sat, &v1); 402 back.hsv(&hue, &sat, &v1);
405 blendColor.hsv(&hue, &sat, &v2); 403 blendColor.hsv(&hue, &sat, &v2);
406 if(v2 > v1) 404 if(v2 > v1)
407 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); 405 blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
408 406
409 pix = btnBorderDict.find(blendColor.rgb()); 407 pix = btnBorderDict.find(blendColor.rgb());
410 if(!pix){ 408 if(!pix){
411 int h, s, v; 409 int h, s, v;
412 blendColor.hsv(&h, &s, &v); 410 blendColor.hsv(&h, &s, &v);
413 pix = new QPixmap(*btnBlendPix); 411 pix = new QPixmap(*btnBlendPix);
414 adjustHSV(*pix, h, s, v); 412 adjustHSV(*pix, h, s, v);
415 btnBorderDict.insert(blendColor.rgb(), pix); 413 btnBorderDict.insert(blendColor.rgb(), pix);
416 } 414 }