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