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