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