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