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