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