-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index e6d8310..4a65952 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -1,427 +1,429 @@ | |||
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 | #include <qlistbox.h> | ||
38 | 39 | ||
39 | #include <stdio.h> | 40 | #include <stdio.h> |
40 | 41 | ||
41 | #include "htmlmasks.h" | 42 | #include "htmlmasks.h" |
42 | #include "embeddata.h" | 43 | #include "embeddata.h" |
43 | 44 | ||
45 | |||
44 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 46 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
45 | QColorGroup &, bool, bool); | 47 | QColorGroup &, bool, bool); |
46 | 48 | ||
47 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 49 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
48 | 50 | ||
49 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 51 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
50 | { | 52 | { |
51 | QImage img(pix.convertToImage()); | 53 | QImage img(pix.convertToImage()); |
52 | QImageEffect::fade(img, 0.9, color); | 54 | QImageEffect::fade(img, 0.9, color); |
53 | int x, y; | 55 | int x, y; |
54 | int r, g, b; | 56 | int r, g, b; |
55 | for(y=0; y < img.height(); y+=3){ | 57 | for(y=0; y < img.height(); y+=3){ |
56 | unsigned int *data = (unsigned int *) img.scanLine(y); | 58 | unsigned int *data = (unsigned int *) img.scanLine(y); |
57 | for(x=0; x < img.width(); ++x){ | 59 | for(x=0; x < img.width(); ++x){ |
58 | r = qRed(data[x]); | 60 | r = qRed(data[x]); |
59 | g = qGreen(data[x]); | 61 | g = qGreen(data[x]); |
60 | b = qBlue(data[x]); | 62 | b = qBlue(data[x]); |
61 | if(r-10) | 63 | if(r-10) |
62 | r-=10; | 64 | r-=10; |
63 | if(g-10) | 65 | if(g-10) |
64 | g-=10; | 66 | g-=10; |
65 | if(b-10) | 67 | if(b-10) |
66 | b-=10; | 68 | b-=10; |
67 | data[x] = qRgb(r, g, b); | 69 | data[x] = qRgb(r, g, b); |
68 | } | 70 | } |
69 | } | 71 | } |
70 | pix.convertFromImage(img); | 72 | pix.convertFromImage(img); |
71 | } | 73 | } |
72 | 74 | ||
73 | TransMenuHandler::TransMenuHandler(QObject *parent) | 75 | TransMenuHandler::TransMenuHandler(QObject *parent) |
74 | : QObject(parent) | 76 | : QObject(parent) |
75 | { | 77 | { |
76 | pixDict.setAutoDelete(true); | 78 | pixDict.setAutoDelete(true); |
77 | reloadSettings(); | 79 | reloadSettings(); |
78 | } | 80 | } |
79 | 81 | ||
80 | void TransMenuHandler::reloadSettings() | 82 | void TransMenuHandler::reloadSettings() |
81 | { | 83 | { |
82 | pixDict.clear(); | 84 | pixDict.clear(); |
83 | 85 | ||
84 | Config config ( "qpe" ); | 86 | Config config ( "qpe" ); |
85 | config. setGroup ( "Liquid-Style" ); | 87 | config. setGroup ( "Liquid-Style" ); |
86 | 88 | ||
87 | type = config. readNumEntry("Type", TransStippleBg); | 89 | type = config. readNumEntry("Type", TransStippleBg); |
88 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); | 90 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); |
89 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); | 91 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); |
90 | opacity = config. readNumEntry("Opacity", 10); | 92 | opacity = config. readNumEntry("Opacity", 10); |
91 | if ( opacity < -20 ) | 93 | if ( opacity < -20 ) |
92 | opacity = 20; | 94 | opacity = 20; |
93 | else if ( opacity > 20 ) | 95 | else if ( opacity > 20 ) |
94 | opacity = 20; | 96 | opacity = 20; |
95 | 97 | ||
96 | shadowText = config. readBoolEntry("ShadowText", true); | 98 | shadowText = config. readBoolEntry("ShadowText", true); |
97 | } | 99 | } |
98 | 100 | ||
99 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | 101 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) |
100 | { | 102 | { |
101 | QWidget *p = (QWidget *)obj; | 103 | QWidget *p = (QWidget *)obj; |
102 | 104 | ||
103 | if(ev->type() == QEvent::Show){ | 105 | if(ev->type() == QEvent::Show){ |
104 | if(type == TransStippleBg || type == TransStippleBtn || | 106 | if(type == TransStippleBg || type == TransStippleBtn || |
105 | type == Custom){ | 107 | type == Custom){ |
106 | QApplication::syncX(); | 108 | QApplication::syncX(); |
107 | QPixmap *pix = new QPixmap; | 109 | QPixmap *pix = new QPixmap; |
108 | if(p->testWFlags(Qt::WType_Popup)){ | 110 | if(p->testWFlags(Qt::WType_Popup)){ |
109 | QRect r(p->x(), p->y(), p->width(), p->height()); | 111 | QRect r(p->x(), p->y(), p->width(), p->height()); |
110 | QRect deskR = QApplication::desktop()->rect(); | 112 | QRect deskR = QApplication::desktop()->rect(); |
111 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ | 113 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ |
112 | r.setBottom(deskR.bottom()); | 114 | r.setBottom(deskR.bottom()); |
113 | r.setRight(deskR.right()); | 115 | r.setRight(deskR.right()); |
114 | } | 116 | } |
115 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), | 117 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), |
116 | r.width(), r.height()); | 118 | r.width(), r.height()); |
117 | } | 119 | } |
118 | else{ // tear off menu | 120 | else{ // tear off menu |
119 | pix->resize(p->width(), p->height()); | 121 | pix->resize(p->width(), p->height()); |
120 | pix->fill(Qt::black.rgb()); | 122 | pix->fill(Qt::black.rgb()); |
121 | } | 123 | } |
122 | if(type == TransStippleBg){ | 124 | if(type == TransStippleBg){ |
123 | stripePixmap(*pix, p->colorGroup().background()); | 125 | stripePixmap(*pix, p->colorGroup().background()); |
124 | } | 126 | } |
125 | else if(type == TransStippleBtn){ | 127 | else if(type == TransStippleBtn){ |
126 | stripePixmap(*pix, p->colorGroup().button()); | 128 | stripePixmap(*pix, p->colorGroup().button()); |
127 | } | 129 | } |
128 | else{ | 130 | else{ |
129 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 131 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
130 | } | 132 | } |
131 | 133 | ||
132 | pixDict.insert(p->winId(), pix); | 134 | pixDict.insert(p->winId(), pix); |
133 | 135 | ||
134 | if ( !p->inherits("QPopupMenu")) | 136 | if ( !p->inherits("QPopupMenu")) |
135 | p->setBackgroundPixmap(*pix); | 137 | p->setBackgroundPixmap(*pix); |
136 | 138 | ||
137 | QObjectList *ol = p-> queryList("QWidget"); | 139 | QObjectList *ol = p-> queryList("QWidget"); |
138 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 140 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
139 | QWidget *wid = (QWidget *) it.current ( ); | 141 | QWidget *wid = (QWidget *) it.current ( ); |
140 | 142 | ||
141 | wid-> setBackgroundPixmap(*pix); | 143 | wid-> setBackgroundPixmap(*pix); |
142 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); | 144 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); |
143 | } | 145 | } |
144 | delete ol; | 146 | delete ol; |
145 | } | 147 | } |
146 | } | 148 | } |
147 | else if(ev->type() == QEvent::Hide){ | 149 | else if(ev->type() == QEvent::Hide){ |
148 | if(type == TransStippleBg || type == TransStippleBtn || | 150 | if(type == TransStippleBg || type == TransStippleBtn || |
149 | type == Custom){ | 151 | type == Custom){ |
150 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 152 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
151 | 153 | ||
152 | pixDict.remove(p->winId()); | 154 | pixDict.remove(p->winId()); |
153 | if ( !p->inherits("QPopupMenu")) | 155 | if ( !p->inherits("QPopupMenu")) |
154 | p->setBackgroundMode(QWidget::PaletteBackground); | 156 | p->setBackgroundMode(QWidget::PaletteBackground); |
155 | 157 | ||
156 | QObjectList *ol = p-> queryList("QWidget"); | 158 | QObjectList *ol = p-> queryList("QWidget"); |
157 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 159 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
158 | QWidget *wid = (QWidget *) it.current ( ); | 160 | QWidget *wid = (QWidget *) it.current ( ); |
159 | 161 | ||
160 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 162 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
161 | } | 163 | } |
162 | delete ol; | 164 | delete ol; |
163 | } | 165 | } |
164 | } | 166 | } |
165 | return(false); | 167 | return(false); |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | static int qt_version ( ) | 171 | static int qt_version ( ) |
170 | { | 172 | { |
171 | const char *qver = qVersion ( ); | 173 | const char *qver = qVersion ( ); |
172 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); | 174 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); |
173 | } | 175 | } |
174 | 176 | ||
175 | 177 | ||
176 | LiquidStyle::LiquidStyle() | 178 | LiquidStyle::LiquidStyle() |
177 | :QWindowsStyle() | 179 | :QWindowsStyle() |
178 | { | 180 | { |
179 | setName ( "LiquidStyle" ); | 181 | setName ( "LiquidStyle" ); |
180 | 182 | ||
181 | oldqte = ( qt_version ( ) < 234 ); | 183 | oldqte = ( qt_version ( ) < 234 ); |
182 | flatTBButtons = false; | 184 | flatTBButtons = false; |
183 | currentHeader = 0; | 185 | currentHeader = 0; |
184 | 186 | ||
185 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 187 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
186 | btnMaskBmp.setMask(btnMaskBmp); | 188 | btnMaskBmp.setMask(btnMaskBmp); |
187 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 189 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
188 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 190 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
189 | headerHoverID = -1; | 191 | headerHoverID = -1; |
190 | highlightWidget = NULL; | 192 | highlightWidget = NULL; |
191 | setButtonDefaultIndicatorWidth(0); | 193 | setButtonDefaultIndicatorWidth(0); |
192 | btnDict.setAutoDelete(true); | 194 | btnDict.setAutoDelete(true); |
193 | bevelFillDict.setAutoDelete(true); | 195 | bevelFillDict.setAutoDelete(true); |
194 | smallBevelFillDict.setAutoDelete(true); | 196 | smallBevelFillDict.setAutoDelete(true); |
195 | 197 | ||
196 | rMatrix.rotate(270.0); | 198 | rMatrix.rotate(270.0); |
197 | btnBorderPix = new QPixmap; | 199 | btnBorderPix = new QPixmap; |
198 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 200 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
199 | btnBlendPix = new QPixmap; | 201 | btnBlendPix = new QPixmap; |
200 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 202 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
201 | bevelFillPix = new QPixmap; | 203 | bevelFillPix = new QPixmap; |
202 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 204 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
203 | smallBevelFillPix = new QPixmap; | 205 | smallBevelFillPix = new QPixmap; |
204 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 206 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
205 | // new stuff | 207 | // new stuff |
206 | vsbSliderFillPix = menuPix = NULL; | 208 | vsbSliderFillPix = menuPix = NULL; |
207 | menuHandler = new TransMenuHandler(this); | 209 | menuHandler = new TransMenuHandler(this); |
208 | setScrollBarExtent(15, 15); | 210 | setScrollBarExtent(15, 15); |
209 | int i; | 211 | int i; |
210 | for(i=0; i < BITMAP_ITEMS; ++i){ | 212 | for(i=0; i < BITMAP_ITEMS; ++i){ |
211 | pixmaps[i] = NULL; | 213 | pixmaps[i] = NULL; |
212 | } | 214 | } |
213 | oldSliderThickness = sliderThickness(); | 215 | oldSliderThickness = sliderThickness(); |
214 | setSliderThickness(11); | 216 | setSliderThickness(11); |
215 | } | 217 | } |
216 | 218 | ||
217 | LiquidStyle::~LiquidStyle() | 219 | LiquidStyle::~LiquidStyle() |
218 | { | 220 | { |
219 | if(btnBorderPix) | 221 | if(btnBorderPix) |
220 | delete btnBorderPix; | 222 | delete btnBorderPix; |
221 | if(btnBlendPix) | 223 | if(btnBlendPix) |
222 | delete btnBlendPix; | 224 | delete btnBlendPix; |
223 | if(bevelFillPix) | 225 | if(bevelFillPix) |
224 | delete bevelFillPix; | 226 | delete bevelFillPix; |
225 | if(smallBevelFillPix) | 227 | if(smallBevelFillPix) |
226 | delete smallBevelFillPix; | 228 | delete smallBevelFillPix; |
227 | if(vsbSliderFillPix) | 229 | if(vsbSliderFillPix) |
228 | delete vsbSliderFillPix; | 230 | delete vsbSliderFillPix; |
229 | if(menuPix) | 231 | if(menuPix) |
230 | delete menuPix; | 232 | delete menuPix; |
231 | 233 | ||
232 | setScrollBarExtent(16, 16); | 234 | setScrollBarExtent(16, 16); |
233 | setSliderThickness(oldSliderThickness); | 235 | setSliderThickness(oldSliderThickness); |
234 | int i; | 236 | int i; |
235 | for(i=0; i < BITMAP_ITEMS; ++i){ | 237 | for(i=0; i < BITMAP_ITEMS; ++i){ |
236 | if(pixmaps[i]) | 238 | if(pixmaps[i]) |
237 | delete pixmaps[i]; | 239 | delete pixmaps[i]; |
238 | } | 240 | } |
239 | } | 241 | } |
240 | 242 | ||
241 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, | 243 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, |
242 | const QColor &c, const QColor &bg) | 244 | const QColor &c, const QColor &bg) |
243 | { | 245 | { |
244 | 246 | ||
245 | QPen oldPen = p->pen(); // headers need this | 247 | QPen oldPen = p->pen(); // headers need this |
246 | int x2 = x+w-1; | 248 | int x2 = x+w-1; |
247 | int y2 = y+h-1; | 249 | int y2 = y+h-1; |
248 | // outer dark rect | 250 | // outer dark rect |
249 | p->setPen(c.dark(130)); | 251 | p->setPen(c.dark(130)); |
250 | p->drawLine(x, y+2, x, y2-2); // l | 252 | p->drawLine(x, y+2, x, y2-2); // l |
251 | p->drawLine(x2, y+2, x2, y2-2); // r | 253 | p->drawLine(x2, y+2, x2, y2-2); // r |
252 | p->drawLine(x+2, y, x2-2, y); // t | 254 | p->drawLine(x+2, y, x2-2, y); // t |
253 | p->drawLine(x+2, y2, x2-2, y2); // b | 255 | p->drawLine(x+2, y2, x2-2, y2); // b |
254 | p->drawPoint(x+1, y+1); // tl | 256 | p->drawPoint(x+1, y+1); // tl |
255 | p->drawPoint(x2-1, y+1); // tr | 257 | p->drawPoint(x2-1, y+1); // tr |
256 | p->drawPoint(x+1, y2-1); // bl | 258 | p->drawPoint(x+1, y2-1); // bl |
257 | p->drawPoint(x2-1, y2-1); // br | 259 | p->drawPoint(x2-1, y2-1); // br |
258 | 260 | ||
259 | // inner top light lines | 261 | // inner top light lines |
260 | p->setPen(c.light(105)); | 262 | p->setPen(c.light(105)); |
261 | p->drawLine(x+2, y+1, x2-2, y+1); | 263 | p->drawLine(x+2, y+1, x2-2, y+1); |
262 | p->drawLine(x+1, y+2, x2-1, y+2); | 264 | p->drawLine(x+1, y+2, x2-1, y+2); |
263 | p->drawLine(x+1, y+3, x+2, y+3); | 265 | p->drawLine(x+1, y+3, x+2, y+3); |
264 | p->drawLine(x2-2, y+3, x2-1, y+3); | 266 | p->drawLine(x2-2, y+3, x2-1, y+3); |
265 | p->drawPoint(x+1, y+4); | 267 | p->drawPoint(x+1, y+4); |
266 | p->drawPoint(x2-1, y+4); | 268 | p->drawPoint(x2-1, y+4); |
267 | 269 | ||
268 | // inner bottom light lines | 270 | // inner bottom light lines |
269 | p->setPen(c.light(110)); | 271 | p->setPen(c.light(110)); |
270 | p->drawLine(x+2, y2-1, x2-2, y2-1); | 272 | p->drawLine(x+2, y2-1, x2-2, y2-1); |
271 | p->drawLine(x+1, y2-2, x2-1, y2-2); | 273 | p->drawLine(x+1, y2-2, x2-1, y2-2); |
272 | p->drawLine(x+1, y2-3, x+2, y2-3); | 274 | p->drawLine(x+1, y2-3, x+2, y2-3); |
273 | p->drawLine(x2-2, y2-3, x2-1, y2-3); | 275 | p->drawLine(x2-2, y2-3, x2-1, y2-3); |
274 | p->drawPoint(x+1, y2-4); | 276 | p->drawPoint(x+1, y2-4); |
275 | p->drawPoint(x2-1, y2-4); | 277 | p->drawPoint(x2-1, y2-4); |
276 | 278 | ||
277 | // inner left mid lines | 279 | // inner left mid lines |
278 | //p->setPen(c.light(105)); | 280 | //p->setPen(c.light(105)); |
279 | p->setPen(c); | 281 | p->setPen(c); |
280 | p->drawLine(x+1, y+5, x+1, y2-5); | 282 | p->drawLine(x+1, y+5, x+1, y2-5); |
281 | p->drawLine(x+2, y+4, x+2, y2-4); | 283 | p->drawLine(x+2, y+4, x+2, y2-4); |
282 | 284 | ||
283 | // inner right mid lines | 285 | // inner right mid lines |
284 | p->drawLine(x2-1, y+5, x2-1, y2-5); | 286 | p->drawLine(x2-1, y+5, x2-1, y2-5); |
285 | p->drawLine(x2-2, y+4, x2-2, y2-4); | 287 | p->drawLine(x2-2, y+4, x2-2, y2-4); |
286 | 288 | ||
287 | // fill | 289 | // fill |
288 | QPixmap *pix; | 290 | QPixmap *pix; |
289 | if(h >= 32){ | 291 | if(h >= 32){ |
290 | pix = bevelFillDict.find(c.rgb()); | 292 | pix = bevelFillDict.find(c.rgb()); |
291 | if(!pix){ | 293 | if(!pix){ |
292 | int h, s, v; | 294 | int h, s, v; |
293 | c.hsv(&h, &s, &v); | 295 | c.hsv(&h, &s, &v); |
294 | pix = new QPixmap(*bevelFillPix); | 296 | pix = new QPixmap(*bevelFillPix); |
295 | adjustHSV(*pix, h, s, v); | 297 | adjustHSV(*pix, h, s, v); |
296 | bevelFillDict.insert(c.rgb(), pix); | 298 | bevelFillDict.insert(c.rgb(), pix); |
297 | } | 299 | } |
298 | } | 300 | } |
299 | else{ | 301 | else{ |
300 | pix = smallBevelFillDict.find(c.rgb()); | 302 | pix = smallBevelFillDict.find(c.rgb()); |
301 | if(!pix){ | 303 | if(!pix){ |
302 | int h, s, v; | 304 | int h, s, v; |
303 | c.hsv(&h, &s, &v); | 305 | c.hsv(&h, &s, &v); |
304 | pix = new QPixmap(*smallBevelFillPix); | 306 | pix = new QPixmap(*smallBevelFillPix); |
305 | adjustHSV(*pix, h, s, v); | 307 | adjustHSV(*pix, h, s, v); |
306 | smallBevelFillDict.insert(c.rgb(), pix); | 308 | smallBevelFillDict.insert(c.rgb(), pix); |
307 | } | 309 | } |
308 | } | 310 | } |
309 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); | 311 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); |
310 | // blend | 312 | // blend |
311 | int red, green, blue; | 313 | int red, green, blue; |
312 | QColor btnColor(c.dark(130)); | 314 | QColor btnColor(c.dark(130)); |
313 | red = (btnColor.red() >> 1) + (bg.red() >> 1); | 315 | red = (btnColor.red() >> 1) + (bg.red() >> 1); |
314 | green = (btnColor.green() >> 1) + (bg.green() >> 1); | 316 | green = (btnColor.green() >> 1) + (bg.green() >> 1); |
315 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); | 317 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); |
316 | btnColor.setRgb(red, green, blue); | 318 | btnColor.setRgb(red, green, blue); |
317 | 319 | ||
318 | p->setPen(btnColor); | 320 | p->setPen(btnColor); |
319 | p->drawPoint(x+1, y); | 321 | p->drawPoint(x+1, y); |
320 | p->drawPoint(x, y+1); | 322 | p->drawPoint(x, y+1); |
321 | p->drawPoint(x+1, y2); | 323 | p->drawPoint(x+1, y2); |
322 | p->drawPoint(x, y2-1); | 324 | p->drawPoint(x, y2-1); |
323 | 325 | ||
324 | p->drawPoint(x2-1, y); | 326 | p->drawPoint(x2-1, y); |
325 | p->drawPoint(x2, y+1); | 327 | p->drawPoint(x2, y+1); |
326 | p->drawPoint(x2-1, y2); | 328 | p->drawPoint(x2-1, y2); |
327 | p->drawPoint(x2, y2-1); | 329 | p->drawPoint(x2, y2-1); |
328 | 330 | ||
329 | p->setPen(oldPen); | 331 | p->setPen(oldPen); |
330 | 332 | ||
331 | } | 333 | } |
332 | 334 | ||
333 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, | 335 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, |
334 | const QColor &back, int x, int y, int w, int h, | 336 | const QColor &back, int x, int y, int w, int h, |
335 | bool supportPushDown, bool pushedDown, | 337 | bool supportPushDown, bool pushedDown, |
336 | bool autoDefault, bool isMasked) | 338 | bool autoDefault, bool isMasked) |
337 | { | 339 | { |
338 | if(w < 21 || h < 21){ | 340 | if(w < 21 || h < 21){ |
339 | drawClearBevel(painter, x, y, w, h, c, back); | 341 | drawClearBevel(painter, x, y, w, h, c, back); |
340 | return; | 342 | return; |
341 | } | 343 | } |
342 | if(supportPushDown){ | 344 | if(supportPushDown){ |
343 | --w, --h; | 345 | --w, --h; |
344 | } | 346 | } |
345 | /* We don't make the round buttons smaller, since they don't look as good | 347 | /* We don't make the round buttons smaller, since they don't look as good |
346 | if(autoDefault){ | 348 | if(autoDefault){ |
347 | w = w-buttonDefaultIndicatorWidth()*2; | 349 | w = w-buttonDefaultIndicatorWidth()*2; |
348 | h = h-buttonDefaultIndicatorWidth()*2; | 350 | h = h-buttonDefaultIndicatorWidth()*2; |
349 | }*/ | 351 | }*/ |
350 | 352 | ||
351 | 353 | ||
352 | QPixmap *pix = btnDict.find(c.rgb()); | 354 | QPixmap *pix = btnDict.find(c.rgb()); |
353 | if(!pix){ | 355 | if(!pix){ |
354 | int h, s, v; | 356 | int h, s, v; |
355 | c.hsv(&h, &s, &v); | 357 | c.hsv(&h, &s, &v); |
356 | pix = new QPixmap(*btnBorderPix); | 358 | pix = new QPixmap(*btnBorderPix); |
357 | adjustHSV(*pix, h, s, v); | 359 | adjustHSV(*pix, h, s, v); |
358 | btnDict.insert(c.rgb(), pix); | 360 | btnDict.insert(c.rgb(), pix); |
359 | } | 361 | } |
360 | int x2 = x+w-1; | 362 | int x2 = x+w-1; |
361 | int y2 = y+h-1; | 363 | int y2 = y+h-1; |
362 | int bx2 = pix->width()-1; | 364 | int bx2 = pix->width()-1; |
363 | int by2 = pix->height()-1; | 365 | int by2 = pix->height()-1; |
364 | 366 | ||
365 | QPixmap tmpPix(w, h); | 367 | QPixmap tmpPix(w, h); |
366 | QPixmap tilePix; | 368 | QPixmap tilePix; |
367 | QPainter p; | 369 | QPainter p; |
368 | p.begin(&tmpPix); | 370 | p.begin(&tmpPix); |
369 | 371 | ||
370 | // do the fill | 372 | // do the fill |
371 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl | 373 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl |
372 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr | 374 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr |
373 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl | 375 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl |
374 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br | 376 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br |
375 | 377 | ||
376 | // edges | 378 | // edges |
377 | tilePix.resize(pix->width()-20, 10); | 379 | tilePix.resize(pix->width()-20, 10); |
378 | // top | 380 | // top |
379 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); | 381 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); |
380 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); | 382 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); |
381 | // bottom | 383 | // bottom |
382 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); | 384 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); |
383 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); | 385 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); |
384 | // left | 386 | // left |
385 | tilePix.resize(10, pix->height()-20); | 387 | tilePix.resize(10, pix->height()-20); |
386 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); | 388 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); |
387 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); | 389 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); |
388 | // right | 390 | // right |
389 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); | 391 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); |
390 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); | 392 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); |
391 | 393 | ||
392 | // middle | 394 | // middle |
393 | tilePix.resize(pix->width()-20, pix->height()-20); | 395 | tilePix.resize(pix->width()-20, pix->height()-20); |
394 | bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); | 396 | bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); |
395 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); | 397 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); |
396 | 398 | ||
397 | 399 | ||
398 | // do the blend | 400 | // do the blend |
399 | QBitmap blendMask; | 401 | QBitmap blendMask; |
400 | if(!isMasked){ | 402 | if(!isMasked){ |
401 | //QRgb bgRgb = back.rgb(); | 403 | //QRgb bgRgb = back.rgb(); |
402 | //QRgb fgRgb = c.rgb(); | 404 | //QRgb fgRgb = c.rgb(); |
403 | //int r, g, b; | 405 | //int r, g, b; |
404 | 406 | ||
405 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); | 407 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); |
406 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); | 408 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); |
407 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); | 409 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); |
408 | //QColor blendColor(r, g, b); | 410 | //QColor blendColor(r, g, b); |
409 | int hue, sat, v1, v2; | 411 | int hue, sat, v1, v2; |
410 | QColor blendColor(autoDefault ? c : back); | 412 | QColor blendColor(autoDefault ? c : back); |
411 | back.hsv(&hue, &sat, &v1); | 413 | back.hsv(&hue, &sat, &v1); |
412 | blendColor.hsv(&hue, &sat, &v2); | 414 | blendColor.hsv(&hue, &sat, &v2); |
413 | if(v2 > v1) | 415 | if(v2 > v1) |
414 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); | 416 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); |
415 | 417 | ||
416 | pix = btnBorderDict.find(blendColor.rgb()); | 418 | pix = btnBorderDict.find(blendColor.rgb()); |
417 | if(!pix){ | 419 | if(!pix){ |
418 | int h, s, v; | 420 | int h, s, v; |
419 | blendColor.hsv(&h, &s, &v); | 421 | blendColor.hsv(&h, &s, &v); |
420 | pix = new QPixmap(*btnBlendPix); | 422 | pix = new QPixmap(*btnBlendPix); |
421 | adjustHSV(*pix, h, s, v); | 423 | adjustHSV(*pix, h, s, v); |
422 | btnBorderDict.insert(blendColor.rgb(), pix); | 424 | btnBorderDict.insert(blendColor.rgb(), pix); |
423 | } | 425 | } |
424 | } | 426 | } |
425 | else{ | 427 | else{ |
426 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : | 428 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : |
427 | getPixmap(HTMLBtnBorder); | 429 | getPixmap(HTMLBtnBorder); |
@@ -1027,769 +1029,770 @@ public: | |||
1027 | bw = w; | 1029 | bw = w; |
1028 | 1030 | ||
1029 | p.setPen(g.button().dark(130)); | 1031 | p.setPen(g.button().dark(130)); |
1030 | p.drawRect(x, y, bw, h); | 1032 | p.drawRect(x, y, bw, h); |
1031 | p.setPen(g.button().light(120)); | 1033 | p.setPen(g.button().light(120)); |
1032 | p.drawRect(x+1, y+1, bw-2, h-2); | 1034 | p.drawRect(x+1, y+1, bw-2, h-2); |
1033 | 1035 | ||
1034 | if(bw >= 4 && h >= 4 && pix) | 1036 | if(bw >= 4 && h >= 4 && pix) |
1035 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); | 1037 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); |
1036 | 1038 | ||
1037 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | 1039 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { |
1038 | QString pstr; | 1040 | QString pstr; |
1039 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | 1041 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); |
1040 | p. setPen ( g.text());//g.highlightedText ( )); | 1042 | p. setPen ( g.text());//g.highlightedText ( )); |
1041 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | 1043 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); |
1042 | } | 1044 | } |
1043 | } | 1045 | } |
1044 | } | 1046 | } |
1045 | }; | 1047 | }; |
1046 | 1048 | ||
1047 | 1049 | ||
1048 | /* | 1050 | /* |
1049 | * The same for QToolButton: | 1051 | * The same for QToolButton: |
1050 | * TT hardcoded the drawing of the focus rect ... | 1052 | * TT hardcoded the drawing of the focus rect ... |
1051 | * | 1053 | * |
1052 | * - sandman | 1054 | * - sandman |
1053 | */ | 1055 | */ |
1054 | 1056 | ||
1055 | 1057 | ||
1056 | class HackToolButton : public QToolButton { | 1058 | class HackToolButton : public QToolButton { |
1057 | public: | 1059 | public: |
1058 | HackToolButton ( ); | 1060 | HackToolButton ( ); |
1059 | 1061 | ||
1060 | void paint ( QPaintEvent *ev ) | 1062 | void paint ( QPaintEvent *ev ) |
1061 | { | 1063 | { |
1062 | erase ( ev-> region ( )); | 1064 | erase ( ev-> region ( )); |
1063 | QPainter p ( this ); | 1065 | QPainter p ( this ); |
1064 | style ( ). drawToolButton ( this, &p ); | 1066 | style ( ). drawToolButton ( this, &p ); |
1065 | drawButtonLabel ( &p ); | 1067 | drawButtonLabel ( &p ); |
1066 | } | 1068 | } |
1067 | }; | 1069 | }; |
1068 | 1070 | ||
1069 | /* | 1071 | /* |
1070 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1072 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1071 | * force everything to erase and repaint on resize. This is going away, I'm | 1073 | * force everything to erase and repaint on resize. This is going away, I'm |
1072 | * trying to get shaped widgets to work right without masking. QPushButton, | 1074 | * trying to get shaped widgets to work right without masking. QPushButton, |
1073 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1075 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1074 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1076 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1075 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1077 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1076 | * caches them in QPixmapCache, which is bad for doing things like hover | 1078 | * caches them in QPixmapCache, which is bad for doing things like hover |
1077 | * because the style methods aren't called in paintEvents if everything | 1079 | * because the style methods aren't called in paintEvents if everything |
1078 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1080 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1079 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1081 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1080 | * modifications. For QHeader, different header items are actually one widget | 1082 | * modifications. For QHeader, different header items are actually one widget |
1081 | * that draws multiple items, so we need to check which ID is hightlighted | 1083 | * that draws multiple items, so we need to check which ID is hightlighted |
1082 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1084 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1083 | * since if it's inside a combobox we want to highlight the combobox during | 1085 | * since if it's inside a combobox we want to highlight the combobox during |
1084 | * hovering in the edit. | 1086 | * hovering in the edit. |
1085 | */ | 1087 | */ |
1086 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1088 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1087 | { | 1089 | { |
1088 | if(obj->inherits("QToolBar")){ | 1090 | if(obj->inherits("QToolBar")){ |
1089 | if(ev->type() == QEvent::Resize){ | 1091 | if(ev->type() == QEvent::Resize){ |
1090 | const QObjectList *tbChildList = obj->children(); | 1092 | const QObjectList *tbChildList = obj->children(); |
1091 | QObjectListIt it(*tbChildList); | 1093 | QObjectListIt it(*tbChildList); |
1092 | QObject *child; | 1094 | QObject *child; |
1093 | while((child = it.current()) != NULL){ | 1095 | while((child = it.current()) != NULL){ |
1094 | ++it; | 1096 | ++it; |
1095 | if(child->isWidgetType()) | 1097 | if(child->isWidgetType()) |
1096 | ((QWidget *)child)->repaint(true); | 1098 | ((QWidget *)child)->repaint(true); |
1097 | } | 1099 | } |
1098 | 1100 | ||
1099 | } | 1101 | } |
1100 | } | 1102 | } |
1101 | else if(obj->inherits("QToolButton")){ | 1103 | else if(obj->inherits("QToolButton")){ |
1102 | QToolButton *btn = (QToolButton *)obj; | 1104 | QToolButton *btn = (QToolButton *)obj; |
1103 | if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () | 1105 | if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () |
1104 | if(btn->isEnabled()){ | 1106 | if(btn->isEnabled()){ |
1105 | highlightWidget = btn; | 1107 | highlightWidget = btn; |
1106 | btn->repaint(false); | 1108 | btn->repaint(false); |
1107 | } | 1109 | } |
1108 | } | 1110 | } |
1109 | else if(ev->type() == QEvent::FocusOut ){ | 1111 | else if(ev->type() == QEvent::FocusOut ){ |
1110 | if(btn == highlightWidget){ | 1112 | if(btn == highlightWidget){ |
1111 | highlightWidget = NULL; | 1113 | highlightWidget = NULL; |
1112 | btn->repaint(false); | 1114 | btn->repaint(false); |
1113 | } | 1115 | } |
1114 | } | 1116 | } |
1115 | else if(ev->type() == QEvent::Paint) { | 1117 | else if(ev->type() == QEvent::Paint) { |
1116 | (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); | 1118 | (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); |
1117 | return true; | 1119 | return true; |
1118 | } | 1120 | } |
1119 | } | 1121 | } |
1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1122 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1121 | QButton *btn = (QButton *)obj; | 1123 | QButton *btn = (QButton *)obj; |
1122 | bool isRadio = obj->inherits("QRadioButton"); | 1124 | bool isRadio = obj->inherits("QRadioButton"); |
1123 | if(ev->type() == QEvent::Paint){ | 1125 | if(ev->type() == QEvent::Paint){ |
1124 | //if(btn->autoMask()) | 1126 | //if(btn->autoMask()) |
1125 | btn->erase(); | 1127 | btn->erase(); |
1126 | QPainter p; | 1128 | QPainter p; |
1127 | p.begin(btn); | 1129 | p.begin(btn); |
1128 | QFontMetrics fm = btn->fontMetrics(); | 1130 | QFontMetrics fm = btn->fontMetrics(); |
1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1131 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1130 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1132 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1131 | : indicatorSize(); | 1133 | : indicatorSize(); |
1132 | 1134 | ||
1133 | /* | 1135 | /* |
1134 | if(btn->hasFocus()){ | 1136 | if(btn->hasFocus()){ |
1135 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1137 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1136 | p.setPen(btn->colorGroup().button().dark(140)); | 1138 | p.setPen(btn->colorGroup().button().dark(140)); |
1137 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1139 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1138 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1140 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1139 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1141 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1140 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1142 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1141 | } | 1143 | } |
1142 | */ | 1144 | */ |
1143 | int x = 0; | 1145 | int x = 0; |
1144 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1146 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1145 | if(isRadio) | 1147 | if(isRadio) |
1146 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1148 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1147 | btn->colorGroup(), btn->isOn(), | 1149 | btn->colorGroup(), btn->isOn(), |
1148 | btn->isDown(), btn->isEnabled()); | 1150 | btn->isDown(), btn->isEnabled()); |
1149 | else | 1151 | else |
1150 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1152 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1151 | btn->colorGroup(), btn->state(), btn->isDown(), | 1153 | btn->colorGroup(), btn->state(), btn->isDown(), |
1152 | btn->isEnabled()); | 1154 | btn->isEnabled()); |
1153 | x = sz.width() + 6; | 1155 | x = sz.width() + 6; |
1154 | y = 0; | 1156 | y = 0; |
1155 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1157 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1156 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1158 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1157 | btn->colorGroup(), btn->isEnabled(), | 1159 | btn->colorGroup(), btn->isEnabled(), |
1158 | btn->pixmap(), btn->text()); | 1160 | btn->pixmap(), btn->text()); |
1159 | p.end(); | 1161 | p.end(); |
1160 | return(true); | 1162 | return(true); |
1161 | } | 1163 | } |
1162 | } | 1164 | } |
1163 | else if(obj->inherits("QHeader")){ | 1165 | else if(obj->inherits("QHeader")){ |
1164 | QHeader *hw = (QHeader *)obj; | 1166 | QHeader *hw = (QHeader *)obj; |
1165 | if(ev->type() == QEvent::Enter){ | 1167 | if(ev->type() == QEvent::Enter){ |
1166 | currentHeader = hw; | 1168 | currentHeader = hw; |
1167 | headerHoverID = -1; | 1169 | headerHoverID = -1; |
1168 | } | 1170 | } |
1169 | else if(ev->type() == QEvent::Leave){ | 1171 | else if(ev->type() == QEvent::Leave){ |
1170 | currentHeader = NULL; | 1172 | currentHeader = NULL; |
1171 | if(headerHoverID != -1){ | 1173 | if(headerHoverID != -1){ |
1172 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1174 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1173 | hw->sectionSize(headerHoverID), hw->height()); | 1175 | hw->sectionSize(headerHoverID), hw->height()); |
1174 | } | 1176 | } |
1175 | headerHoverID = -1; | 1177 | headerHoverID = -1; |
1176 | } | 1178 | } |
1177 | else if(ev->type() == QEvent::MouseMove){ | 1179 | else if(ev->type() == QEvent::MouseMove){ |
1178 | QMouseEvent *me = (QMouseEvent *)ev; | 1180 | QMouseEvent *me = (QMouseEvent *)ev; |
1179 | int oldHeader = headerHoverID; | 1181 | int oldHeader = headerHoverID; |
1180 | headerHoverID = hw->sectionAt(me->x()); | 1182 | headerHoverID = hw->sectionAt(me->x()); |
1181 | if(oldHeader != headerHoverID){ | 1183 | if(oldHeader != headerHoverID){ |
1182 | // reset old header | 1184 | // reset old header |
1183 | if(oldHeader != -1){ | 1185 | if(oldHeader != -1){ |
1184 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1186 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1185 | hw->sectionSize(oldHeader), hw->height()); | 1187 | hw->sectionSize(oldHeader), hw->height()); |
1186 | } | 1188 | } |
1187 | if(headerHoverID != -1){ | 1189 | if(headerHoverID != -1){ |
1188 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1190 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1189 | hw->sectionSize(headerHoverID), hw->height()); | 1191 | hw->sectionSize(headerHoverID), hw->height()); |
1190 | } | 1192 | } |
1191 | } | 1193 | } |
1192 | } | 1194 | } |
1193 | } | 1195 | } |
1194 | else if (obj-> inherits( "QProgressBar" )) { | 1196 | else if (obj-> inherits( "QProgressBar" )) { |
1195 | if ( ev->type() == QEvent::Paint ) { | 1197 | if ( ev->type() == QEvent::Paint ) { |
1196 | HackProgressBar *p = (HackProgressBar *) obj; | 1198 | HackProgressBar *p = (HackProgressBar *) obj; |
1197 | const QColorGroup &g = p-> colorGroup ( ); | 1199 | const QColorGroup &g = p-> colorGroup ( ); |
1198 | 1200 | ||
1199 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | 1201 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); |
1200 | if(!pix){ | 1202 | if(!pix){ |
1201 | int h, s, v; | 1203 | int h, s, v; |
1202 | g.button().dark(120).hsv(&h, &s, &v); | 1204 | g.button().dark(120).hsv(&h, &s, &v); |
1203 | pix = new QPixmap(*bevelFillPix); | 1205 | pix = new QPixmap(*bevelFillPix); |
1204 | adjustHSV(*pix, h, s, v); | 1206 | adjustHSV(*pix, h, s, v); |
1205 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); | 1207 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); |
1206 | } | 1208 | } |
1207 | p-> paint ((QPaintEvent *) ev, g, pix ); | 1209 | p-> paint ((QPaintEvent *) ev, g, pix ); |
1208 | return true; | 1210 | return true; |
1209 | } | 1211 | } |
1210 | } | 1212 | } |
1211 | return false ; | 1213 | return false ; |
1212 | } | 1214 | } |
1213 | 1215 | ||
1214 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1216 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1215 | const QColorGroup &g, bool sunken, | 1217 | const QColorGroup &g, bool sunken, |
1216 | const QBrush *) | 1218 | const QBrush *) |
1217 | { | 1219 | { |
1218 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1220 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1219 | x, y, w, h); | 1221 | x, y, w, h); |
1220 | } | 1222 | } |
1221 | 1223 | ||
1222 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1224 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1223 | const QColorGroup &g, bool sunken, | 1225 | const QColorGroup &g, bool sunken, |
1224 | const QBrush *) | 1226 | const QBrush *) |
1225 | { | 1227 | { |
1226 | if(p->device()->devType() != QInternal::Widget){ | 1228 | if(p->device()->devType() != QInternal::Widget){ |
1227 | // drawing into a temp pixmap, don't use mask | 1229 | // drawing into a temp pixmap, don't use mask |
1228 | QColor c = sunken ? g.button() : g.background(); | 1230 | QColor c = sunken ? g.button() : g.background(); |
1229 | p->setPen(c.dark(130)); | 1231 | p->setPen(c.dark(130)); |
1230 | p->drawRect(x, y, w, h); | 1232 | p->drawRect(x, y, w, h); |
1231 | p->setPen(c.light(105)); | 1233 | p->setPen(c.light(105)); |
1232 | p->drawRect(x+1, y+1, w-2, h-2); | 1234 | p->drawRect(x+1, y+1, w-2, h-2); |
1233 | 1235 | ||
1234 | 1236 | ||
1235 | // fill | 1237 | // fill |
1236 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1238 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1237 | if(!pix){ | 1239 | if(!pix){ |
1238 | int h, s, v; | 1240 | int h, s, v; |
1239 | c.hsv(&h, &s, &v); | 1241 | c.hsv(&h, &s, &v); |
1240 | pix = new QPixmap(*bevelFillPix); | 1242 | pix = new QPixmap(*bevelFillPix); |
1241 | adjustHSV(*pix, h, s, v); | 1243 | adjustHSV(*pix, h, s, v); |
1242 | bevelFillDict.insert(c.rgb(), pix); | 1244 | bevelFillDict.insert(c.rgb(), pix); |
1243 | } | 1245 | } |
1244 | 1246 | ||
1245 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1247 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1246 | } | 1248 | } |
1247 | else{ | 1249 | else{ |
1248 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1250 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1249 | highlightWidget == p->device() ? g.button().light(110) : | 1251 | highlightWidget == p->device() ? g.button().light(110) : |
1250 | g.background(), g.background()); | 1252 | g.background(), g.background()); |
1251 | } | 1253 | } |
1252 | } | 1254 | } |
1253 | 1255 | ||
1254 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1256 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1255 | { | 1257 | { |
1256 | QRect r = btn->rect(); | 1258 | QRect r = btn->rect(); |
1257 | bool sunken = btn->isOn() || btn->isDown(); | 1259 | bool sunken = btn->isOn() || btn->isDown(); |
1258 | QColorGroup g = btn->colorGroup(); | 1260 | QColorGroup g = btn->colorGroup(); |
1259 | 1261 | ||
1260 | 1262 | ||
1261 | //int dw = buttonDefaultIndicatorWidth(); | 1263 | //int dw = buttonDefaultIndicatorWidth(); |
1262 | if(btn->hasFocus() || btn->isDefault()){ | 1264 | if(btn->hasFocus() || btn->isDefault()){ |
1263 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 1265 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
1264 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1266 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1265 | if(!pix){ | 1267 | if(!pix){ |
1266 | int h, s, v; | 1268 | int h, s, v; |
1267 | c.hsv(&h, &s, &v); | 1269 | c.hsv(&h, &s, &v); |
1268 | pix = new QPixmap(*bevelFillPix); | 1270 | pix = new QPixmap(*bevelFillPix); |
1269 | adjustHSV(*pix, h, s, v); | 1271 | adjustHSV(*pix, h, s, v); |
1270 | bevelFillDict.insert(c.rgb(), pix); | 1272 | bevelFillDict.insert(c.rgb(), pix); |
1271 | } | 1273 | } |
1272 | p->setPen(c.dark(150)); | 1274 | p->setPen(c.dark(150)); |
1273 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1275 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1274 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1276 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1275 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1277 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1276 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1278 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1277 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1279 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1278 | } | 1280 | } |
1279 | 1281 | ||
1280 | QColor newColor = btn == highlightWidget || sunken ? | 1282 | QColor newColor = btn == highlightWidget || sunken ? |
1281 | g.button().light(120) : g.button(); | 1283 | g.button().light(120) : g.button(); |
1282 | 1284 | ||
1283 | drawRoundButton(p, newColor, g.background(), | 1285 | drawRoundButton(p, newColor, g.background(), |
1284 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), | 1286 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), |
1285 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), | 1287 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), |
1286 | btn->autoMask()); | 1288 | btn->autoMask()); |
1287 | } | 1289 | } |
1288 | 1290 | ||
1289 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) | 1291 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) |
1290 | { | 1292 | { |
1291 | int x1, y1, x2, y2, w, h; | 1293 | int x1, y1, x2, y2, w, h; |
1292 | btn->rect().coords(&x1, &y1, &x2, &y2); | 1294 | btn->rect().coords(&x1, &y1, &x2, &y2); |
1293 | w = btn->width(); | 1295 | w = btn->width(); |
1294 | h = btn->height(); | 1296 | h = btn->height(); |
1295 | 1297 | ||
1296 | bool act = btn->isOn() || btn->isDown(); | 1298 | bool act = btn->isOn() || btn->isDown(); |
1297 | if(act){ | 1299 | if(act){ |
1298 | ++x1, ++y1; | 1300 | ++x1, ++y1; |
1299 | } | 1301 | } |
1300 | 1302 | ||
1301 | // Draw iconset first, if any | 1303 | // Draw iconset first, if any |
1302 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) | 1304 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) |
1303 | { | 1305 | { |
1304 | QIconSet::Mode mode = btn->isEnabled() | 1306 | QIconSet::Mode mode = btn->isEnabled() |
1305 | ? QIconSet::Normal : QIconSet::Disabled; | 1307 | ? QIconSet::Normal : QIconSet::Disabled; |
1306 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1308 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1307 | mode = QIconSet::Active; | 1309 | mode = QIconSet::Active; |
1308 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 1310 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
1309 | int pixw = pixmap.width(); | 1311 | int pixw = pixmap.width(); |
1310 | int pixh = pixmap.height(); | 1312 | int pixh = pixmap.height(); |
1311 | 1313 | ||
1312 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); | 1314 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); |
1313 | x1 += pixw + 8; | 1315 | x1 += pixw + 8; |
1314 | w -= pixw + 8; | 1316 | w -= pixw + 8; |
1315 | } | 1317 | } |
1316 | 1318 | ||
1317 | if(act){ | 1319 | if(act){ |
1318 | QFont font = btn->font(); | 1320 | QFont font = btn->font(); |
1319 | font.setBold(true); | 1321 | font.setBold(true); |
1320 | p->setFont(font); | 1322 | p->setFont(font); |
1321 | QColor shadow(btn->colorGroup().button().dark(130)); | 1323 | QColor shadow(btn->colorGroup().button().dark(130)); |
1322 | drawItem( p, x1+1, y1+1, w, h, | 1324 | drawItem( p, x1+1, y1+1, w, h, |
1323 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1325 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1324 | btn->pixmap(), btn->text(), -1, | 1326 | btn->pixmap(), btn->text(), -1, |
1325 | &shadow); | 1327 | &shadow); |
1326 | 1328 | ||
1327 | drawItem( p, x1, y1, w, h, | 1329 | drawItem( p, x1, y1, w, h, |
1328 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1330 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1329 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); | 1331 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); |
1330 | } | 1332 | } |
1331 | else{ | 1333 | else{ |
1332 | /* Too blurry | 1334 | /* Too blurry |
1333 | drawItem( p, x1+1, y1+1, w, h, | 1335 | drawItem( p, x1+1, y1+1, w, h, |
1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1336 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1335 | btn->pixmap(), btn->text(), -1, | 1337 | btn->pixmap(), btn->text(), -1, |
1336 | &btn->colorGroup().button().dark(115)); | 1338 | &btn->colorGroup().button().dark(115)); |
1337 | */ | 1339 | */ |
1338 | drawItem( p, x1, y1, w, h, | 1340 | drawItem( p, x1, y1, w, h, |
1339 | AlignCenter | ShowPrefix, | 1341 | AlignCenter | ShowPrefix, |
1340 | btn->colorGroup(), btn->isEnabled(), | 1342 | btn->colorGroup(), btn->isEnabled(), |
1341 | btn->pixmap(), btn->text(), -1, | 1343 | btn->pixmap(), btn->text(), -1, |
1342 | &btn->colorGroup().buttonText()); | 1344 | &btn->colorGroup().buttonText()); |
1343 | } | 1345 | } |
1344 | } | 1346 | } |
1345 | 1347 | ||
1346 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) | 1348 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) |
1347 | { | 1349 | { |
1348 | int x2 = x+w-1; | 1350 | int x2 = x+w-1; |
1349 | int y2 = y+h-1; | 1351 | int y2 = y+h-1; |
1350 | 1352 | ||
1351 | p->setPen(Qt::color1); | 1353 | p->setPen(Qt::color1); |
1352 | p->fillRect(x, y, w, h, Qt::color0); | 1354 | p->fillRect(x, y, w, h, Qt::color0); |
1353 | if(w < 21 || h < 21){ | 1355 | if(w < 21 || h < 21){ |
1354 | // outer rect | 1356 | // outer rect |
1355 | p->drawLine(x, y+2, x, y2-2); // l | 1357 | p->drawLine(x, y+2, x, y2-2); // l |
1356 | p->drawLine(x2, y+2, x2, y2-2); // r | 1358 | p->drawLine(x2, y+2, x2, y2-2); // r |
1357 | p->drawLine(x+2, y, x2-2, y); // t | 1359 | p->drawLine(x+2, y, x2-2, y); // t |
1358 | p->drawLine(x+2, y2, x2-2, y2); // b | 1360 | p->drawLine(x+2, y2, x2-2, y2); // b |
1359 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line | 1361 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line |
1360 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line | 1362 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line |
1361 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); | 1363 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); |
1362 | } | 1364 | } |
1363 | else{ | 1365 | else{ |
1364 | int x2 = x+w-1; | 1366 | int x2 = x+w-1; |
1365 | int y2 = y+h-1; | 1367 | int y2 = y+h-1; |
1366 | int bx2 = htmlBtnMaskBmp.width()-1; | 1368 | int bx2 = htmlBtnMaskBmp.width()-1; |
1367 | int by2 = htmlBtnMaskBmp.height()-1; | 1369 | int by2 = htmlBtnMaskBmp.height()-1; |
1368 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl | 1370 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl |
1369 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr | 1371 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr |
1370 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl | 1372 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl |
1371 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br | 1373 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br |
1372 | // fills | 1374 | // fills |
1373 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top | 1375 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top |
1374 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1376 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1375 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle | 1377 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle |
1376 | } | 1378 | } |
1377 | } | 1379 | } |
1378 | 1380 | ||
1379 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, | 1381 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, |
1380 | const QColorGroup &g, bool sunken, | 1382 | const QColorGroup &g, bool sunken, |
1381 | const QBrush */*fill*/) | 1383 | const QBrush */*fill*/) |
1382 | { | 1384 | { |
1383 | if(currentHeader && p->device() == currentHeader){ | 1385 | if(currentHeader && p->device() == currentHeader){ |
1384 | int id = currentHeader->sectionAt(x); | 1386 | int id = currentHeader->sectionAt(x); |
1385 | bool isHeaderHover = id != -1 && id == headerHoverID; | 1387 | bool isHeaderHover = id != -1 && id == headerHoverID; |
1386 | drawClearBevel(p, x, y, w, h, sunken ? | 1388 | drawClearBevel(p, x, y, w, h, sunken ? |
1387 | g.button() : isHeaderHover ? g.button().light(110) : | 1389 | g.button() : isHeaderHover ? g.button().light(110) : |
1388 | g.background(), g.background()); | 1390 | g.background(), g.background()); |
1389 | } | 1391 | } |
1390 | else | 1392 | else |
1391 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), | 1393 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), |
1392 | g.background()); | 1394 | g.background()); |
1393 | } | 1395 | } |
1394 | 1396 | ||
1395 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) | 1397 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) |
1396 | { | 1398 | { |
1397 | return(QRect(x+5, y+5, w-10, h-10)); | 1399 | return(QRect(x+5, y+5, w-10, h-10)); |
1398 | } | 1400 | } |
1399 | 1401 | ||
1400 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | 1402 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, |
1401 | const QColorGroup &g, bool sunken, | 1403 | const QColorGroup &g, bool sunken, |
1402 | bool edit, bool, const QBrush *) | 1404 | bool edit, bool, const QBrush *) |
1403 | { | 1405 | { |
1404 | bool isActive = false; | 1406 | bool isActive = false; |
1405 | if (( painter->device()->devType() == QInternal::Widget ) && | 1407 | if (( painter->device()->devType() == QInternal::Widget ) && |
1406 | ( | 1408 | ( |
1407 | ( qApp-> focusWidget ( ) == painter-> device ( )) || | 1409 | ( qApp-> focusWidget ( ) == painter-> device ( )) || |
1408 | ( | 1410 | ( |
1409 | edit && | 1411 | edit && |
1410 | ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && | 1412 | ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && |
1411 | ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( )) | 1413 | ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) || |
1414 | qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( )) | ||
1412 | ) | 1415 | ) |
1413 | ) | 1416 | ) |
1414 | ) { | 1417 | ) { |
1415 | isActive = true; | 1418 | isActive = true; |
1416 | } | 1419 | } |
1417 | 1420 | ||
1418 | bool isMasked = false; | 1421 | bool isMasked = false; |
1419 | if(painter->device()->devType() == QInternal::Widget) | 1422 | if(painter->device()->devType() == QInternal::Widget) |
1420 | isMasked = ((QWidget*)painter->device())->autoMask(); | 1423 | isMasked = ((QWidget*)painter->device())->autoMask(); |
1421 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap | 1424 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap |
1422 | QPixmap tmpPix(w, h); | 1425 | QPixmap tmpPix(w, h); |
1423 | QPainter p(&tmpPix); | 1426 | QPainter p(&tmpPix); |
1424 | 1427 | ||
1425 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, | 1428 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, |
1426 | sunken, false, isMasked); | 1429 | sunken, false, isMasked); |
1427 | if(!isActive){ | 1430 | if(!isActive){ |
1428 | p.setClipRect(0, 0, w-17, h); | 1431 | p.setClipRect(0, 0, w-17, h); |
1429 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, | 1432 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, |
1430 | sunken, false, isMasked); | 1433 | sunken, false, isMasked); |
1431 | } | 1434 | } |
1432 | p.end(); | 1435 | p.end(); |
1433 | int x2 = x+w-1; | 1436 | int x2 = x+w-1; |
1434 | int y2 = y+h-1; | 1437 | int y2 = y+h-1; |
1435 | int bx2 = btnMaskBmp.width()-1; | 1438 | int bx2 = btnMaskBmp.width()-1; |
1436 | int by2 = btnMaskBmp.height()-1; | 1439 | int by2 = btnMaskBmp.height()-1; |
1437 | QBitmap btnMask(w, h); | 1440 | QBitmap btnMask(w, h); |
1438 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 1441 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
1439 | p.begin(&btnMask); | 1442 | p.begin(&btnMask); |
1440 | p.fillRect(0, 0, w, h, Qt::color0); | 1443 | p.fillRect(0, 0, w, h, Qt::color0); |
1441 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl | 1444 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl |
1442 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr | 1445 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr |
1443 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl | 1446 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl |
1444 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br | 1447 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br |
1445 | // fills | 1448 | // fills |
1446 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 1449 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
1447 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1450 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1448 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 1451 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
1449 | p.end(); | 1452 | p.end(); |
1450 | tmpPix.setMask(btnMask); | 1453 | tmpPix.setMask(btnMask); |
1451 | 1454 | ||
1452 | painter->drawPixmap(x, y, tmpPix); | 1455 | painter->drawPixmap(x, y, tmpPix); |
1453 | 1456 | ||
1454 | painter->setPen(g.button().dark(120)); | 1457 | painter->setPen(g.button().dark(120)); |
1455 | painter->drawLine(x2-16, y+1, x2-16, y2-1); | 1458 | painter->drawLine(x2-16, y+1, x2-16, y2-1); |
1456 | 1459 | ||
1457 | if(edit){ | 1460 | if(edit){ |
1458 | painter->setPen(g.mid()); | 1461 | painter->setPen(g.mid()); |
1459 | painter->drawRect(x+8, y+2, w-25, h-4); | 1462 | painter->drawRect(x+8, y+2, w-25, h-4); |
1460 | } | 1463 | } |
1461 | int arrow_h = h / 3; | 1464 | int arrow_h = h / 3; |
1462 | int arrow_w = arrow_h; | 1465 | int arrow_w = arrow_h; |
1463 | int arrow_x = w - arrow_w - 6; | 1466 | int arrow_x = w - arrow_w - 6; |
1464 | int arrow_y = (h - arrow_h) / 2; | 1467 | int arrow_y = (h - arrow_h) / 2; |
1465 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); | 1468 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); |
1466 | } | 1469 | } |
1467 | 1470 | ||
1468 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) | 1471 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) |
1469 | { | 1472 | { |
1470 | drawButtonMask(p, x, y, w, h); | 1473 | drawButtonMask(p, x, y, w, h); |
1471 | } | 1474 | } |
1472 | 1475 | ||
1473 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) | 1476 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) |
1474 | { | 1477 | { |
1475 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); | 1478 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); |
1476 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); | 1479 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); |
1477 | } | 1480 | } |
1478 | 1481 | ||
1479 | QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/) | 1482 | QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/) |
1480 | { | 1483 | { |
1481 | return QRect ( ); | 1484 | return QRect ( ); |
1482 | 1485 | ||
1483 | // return(QRect(x+5, y+3, w-(h/3)-13, h-5)); | 1486 | // return(QRect(x+5, y+3, w-(h/3)-13, h-5)); |
1484 | } | 1487 | } |
1485 | 1488 | ||
1486 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | 1489 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, |
1487 | int sliderStart, uint controls, | 1490 | int sliderStart, uint controls, |
1488 | uint activeControl) | 1491 | uint activeControl) |
1489 | { | 1492 | { |
1490 | int sliderMin, sliderMax, sliderLength, buttonDim; | 1493 | int sliderMin, sliderMax, sliderLength, buttonDim; |
1491 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1494 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1492 | 1495 | ||
1493 | if (sliderStart > sliderMax) | 1496 | if (sliderStart > sliderMax) |
1494 | sliderStart = sliderMax; | 1497 | sliderStart = sliderMax; |
1495 | 1498 | ||
1496 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1499 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1497 | QColorGroup g = sb->colorGroup(); | 1500 | QColorGroup g = sb->colorGroup(); |
1498 | QRect addB, subHC, subB; | 1501 | QRect addB, subHC, subB; |
1499 | QRect addPageR, subPageR, sliderR; | 1502 | QRect addPageR, subPageR, sliderR; |
1500 | int addX, addY, subX, subY; | 1503 | int addX, addY, subX, subY; |
1501 | int len = horiz ? sb->width() : sb->height(); | 1504 | int len = horiz ? sb->width() : sb->height(); |
1502 | int extent = horiz ? sb->height() : sb->width(); | 1505 | int extent = horiz ? sb->height() : sb->width(); |
1503 | 1506 | ||
1504 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar | 1507 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar |
1505 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. | 1508 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. |
1506 | bool brokenApp; | 1509 | bool brokenApp; |
1507 | if(extent == 16) | 1510 | if(extent == 16) |
1508 | brokenApp = true; | 1511 | brokenApp = true; |
1509 | else | 1512 | else |
1510 | brokenApp = false; | 1513 | brokenApp = false; |
1511 | 1514 | ||
1512 | if (horiz) { | 1515 | if (horiz) { |
1513 | subY = addY = ( extent - buttonDim ) / 2; | 1516 | subY = addY = ( extent - buttonDim ) / 2; |
1514 | subX = 0; | 1517 | subX = 0; |
1515 | addX = len - buttonDim; | 1518 | addX = len - buttonDim; |
1516 | if(sbBuffer.size() != sb->size()) | 1519 | if(sbBuffer.size() != sb->size()) |
1517 | sbBuffer.resize(sb->size()); | 1520 | sbBuffer.resize(sb->size()); |
1518 | } | 1521 | } |
1519 | else { | 1522 | else { |
1520 | subX = addX = ( extent - buttonDim ) / 2; | 1523 | subX = addX = ( extent - buttonDim ) / 2; |
1521 | subY = 0; | 1524 | subY = 0; |
1522 | addY = len - buttonDim; | 1525 | addY = len - buttonDim; |
1523 | if(sbBuffer.size() != sb->size()) | 1526 | if(sbBuffer.size() != sb->size()) |
1524 | sbBuffer.resize(sb->size()); | 1527 | sbBuffer.resize(sb->size()); |
1525 | } | 1528 | } |
1526 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); | 1529 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); |
1527 | addB.setRect( addX,addY,buttonDim,buttonDim ); | 1530 | addB.setRect( addX,addY,buttonDim,buttonDim ); |
1528 | if(horiz) | 1531 | if(horiz) |
1529 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); | 1532 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); |
1530 | else | 1533 | else |
1531 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); | 1534 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); |
1532 | 1535 | ||
1533 | int sliderEnd = sliderStart + sliderLength; | 1536 | int sliderEnd = sliderStart + sliderLength; |
1534 | int sliderW = extent; | 1537 | int sliderW = extent; |
1535 | 1538 | ||
1536 | if (horiz) { | 1539 | if (horiz) { |
1537 | subPageR.setRect( subB.right() + 1, 0, | 1540 | subPageR.setRect( subB.right() + 1, 0, |
1538 | sliderStart - subB.right() - 1 , sliderW ); | 1541 | sliderStart - subB.right() - 1 , sliderW ); |
1539 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); | 1542 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); |
1540 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); | 1543 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); |
1541 | } | 1544 | } |
1542 | else { | 1545 | else { |
1543 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, | 1546 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, |
1544 | sliderStart - subB.bottom() - 1 ); | 1547 | sliderStart - subB.bottom() - 1 ); |
1545 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); | 1548 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); |
1546 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); | 1549 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); |
1547 | } | 1550 | } |
1548 | 1551 | ||
1549 | bool maxed = sb->maxValue() == sb->minValue(); | 1552 | bool maxed = sb->maxValue() == sb->minValue(); |
1550 | 1553 | ||
1551 | QPainter painter; | 1554 | QPainter painter; |
1552 | if(!horiz){ | 1555 | if(!horiz){ |
1553 | painter.begin(&sbBuffer); | 1556 | painter.begin(&sbBuffer); |
1554 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); | 1557 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); |
1555 | if(sliderR.height() >= 8){ | 1558 | if(sliderR.height() >= 8){ |
1556 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, | 1559 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, |
1557 | 13, 8); | 1560 | 13, 8); |
1558 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); | 1561 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); |
1559 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, | 1562 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, |
1560 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); | 1563 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); |
1561 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, | 1564 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, |
1562 | 0, 0, 13, 8); | 1565 | 0, 0, 13, 8); |
1563 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); | 1566 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); |
1564 | } | 1567 | } |
1565 | else{ | 1568 | else{ |
1566 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), | 1569 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), |
1567 | *getPixmap(VSBSliderMidBg)); | 1570 | *getPixmap(VSBSliderMidBg)); |
1568 | painter.setPen(g.background().dark(210)); | 1571 | painter.setPen(g.background().dark(210)); |
1569 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); | 1572 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); |
1570 | painter.setPen(g.mid()); | 1573 | painter.setPen(g.mid()); |
1571 | painter.drawPoint(bgR.x()+1, bgR.y()); | 1574 | painter.drawPoint(bgR.x()+1, bgR.y()); |
1572 | painter.drawPoint(bgR.x()+13, bgR.y()); | 1575 | painter.drawPoint(bgR.x()+13, bgR.y()); |
1573 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); | 1576 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); |
1574 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); | 1577 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); |
1575 | } | 1578 | } |
1576 | if(controls & Slider){ | 1579 | if(controls & Slider){ |
1577 | if(sliderR.height() >= 16){ | 1580 | if(sliderR.height() >= 16){ |
1578 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop)); | 1581 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop)); |
1579 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, | 1582 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, |
1580 | sliderR.height()-16, *getPixmap(VSBSliderMid)); | 1583 | sliderR.height()-16, *getPixmap(VSBSliderMid)); |
1581 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm)); | 1584 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm)); |
1582 | } | 1585 | } |
1583 | else if(sliderR.height() >= 8){ | 1586 | else if(sliderR.height() >= 8){ |
1584 | int m = sliderR.height()/2; | 1587 | int m = sliderR.height()/2; |
1585 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m); | 1588 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m); |
1586 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); | 1589 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); |
1587 | } | 1590 | } |
1588 | else{ | 1591 | else{ |
1589 | painter.setPen(g.button().dark(210)); | 1592 | painter.setPen(g.button().dark(210)); |
1590 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), | 1593 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), |
1591 | 13, sliderR.height()); | 1594 | 13, sliderR.height()); |
1592 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, | 1595 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, |
1593 | 11, sliderR.height()-2, | 1596 | 11, sliderR.height()-2, |
1594 | *getPixmap(VSBSliderMid), 1, 0); | 1597 | *getPixmap(VSBSliderMid), 1, 0); |
1595 | } | 1598 | } |
1596 | } | 1599 | } |
1597 | painter.setPen(g.mid()); | 1600 | painter.setPen(g.mid()); |
1598 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); | 1601 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); |
1599 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); | 1602 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); |
1600 | if(brokenApp && (controls & Slider)){ | 1603 | if(brokenApp && (controls & Slider)){ |
1601 | painter.setPen(g.background()); | 1604 | painter.setPen(g.background()); |
1602 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, | 1605 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, |
1603 | bgR.bottom()); | 1606 | bgR.bottom()); |
1604 | } | 1607 | } |
1605 | painter.end(); | 1608 | painter.end(); |
1606 | } | 1609 | } |
1607 | else{ | 1610 | else{ |
1608 | painter.begin(&sbBuffer); | 1611 | painter.begin(&sbBuffer); |
1609 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); | 1612 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); |
1610 | if(sliderR.width() >= 8){ | 1613 | if(sliderR.width() >= 8){ |
1611 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, | 1614 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, |
1612 | 8, 13); | 1615 | 8, 13); |
1613 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); | 1616 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); |
1614 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, | 1617 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, |
1615 | 13, *getPixmap(HSBSliderMidBg)); | 1618 | 13, *getPixmap(HSBSliderMidBg)); |
1616 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, | 1619 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, |
1617 | 0, 0, 8, 13); | 1620 | 0, 0, 8, 13); |
1618 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); | 1621 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); |
1619 | } | 1622 | } |
1620 | else{ | 1623 | else{ |
1621 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, | 1624 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, |
1622 | *getPixmap(HSBSliderMidBg)); | 1625 | *getPixmap(HSBSliderMidBg)); |
1623 | painter.setPen(g.background().dark(210)); | 1626 | painter.setPen(g.background().dark(210)); |
1624 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); | 1627 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); |
1625 | painter.setPen(g.mid()); | 1628 | painter.setPen(g.mid()); |
1626 | painter.drawPoint(bgR.x(), bgR.y()+1); | 1629 | painter.drawPoint(bgR.x(), bgR.y()+1); |
1627 | painter.drawPoint(bgR.x(), bgR.bottom()-1); | 1630 | painter.drawPoint(bgR.x(), bgR.bottom()-1); |
1628 | painter.drawPoint(bgR.right()-1, bgR.y()+1); | 1631 | painter.drawPoint(bgR.right()-1, bgR.y()+1); |
1629 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); | 1632 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); |
1630 | } | 1633 | } |
1631 | if(controls & Slider){ | 1634 | if(controls & Slider){ |
1632 | if(sliderR.width() >= 16){ | 1635 | if(sliderR.width() >= 16){ |
1633 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1636 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1634 | *getPixmap(HSBSliderTop)); | 1637 | *getPixmap(HSBSliderTop)); |
1635 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, | 1638 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, |
1636 | 13, *getPixmap(HSBSliderMid)); | 1639 | 13, *getPixmap(HSBSliderMid)); |
1637 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, | 1640 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, |
1638 | *getPixmap(HSBSliderBtm)); | 1641 | *getPixmap(HSBSliderBtm)); |
1639 | } | 1642 | } |
1640 | else if(sliderR.width() >= 8){ | 1643 | else if(sliderR.width() >= 8){ |
1641 | int m = sliderR.width()/2; | 1644 | int m = sliderR.width()/2; |
1642 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1645 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1643 | *getPixmap(HSBSliderTop), 0, 0, m, 13); | 1646 | *getPixmap(HSBSliderTop), 0, 0, m, 13); |
1644 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, | 1647 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, |
1645 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); | 1648 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); |
1646 | } | 1649 | } |
1647 | else{ | 1650 | else{ |
1648 | painter.setPen(g.button().dark(210)); | 1651 | painter.setPen(g.button().dark(210)); |
1649 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, | 1652 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, |
1650 | sliderR.width(), 13); | 1653 | sliderR.width(), 13); |
1651 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, | 1654 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, |
1652 | sliderR.width()-2, 11, | 1655 | sliderR.width()-2, 11, |
1653 | *getPixmap(HSBSliderMid), 0, 1); | 1656 | *getPixmap(HSBSliderMid), 0, 1); |
1654 | } | 1657 | } |
1655 | } | 1658 | } |
1656 | painter.setPen(g.mid()); | 1659 | painter.setPen(g.mid()); |
1657 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); | 1660 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); |
1658 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); | 1661 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); |
1659 | if(brokenApp && (controls & Slider)){ | 1662 | if(brokenApp && (controls & Slider)){ |
1660 | painter.setPen(g.background()); | 1663 | painter.setPen(g.background()); |
1661 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), | 1664 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), |
1662 | bgR.bottom()-1); | 1665 | bgR.bottom()-1); |
1663 | } | 1666 | } |
1664 | painter.end(); | 1667 | painter.end(); |
1665 | } | 1668 | } |
1666 | 1669 | ||
1667 | if ( controls & AddLine ) { | 1670 | if ( controls & AddLine ) { |
1668 | drawSBButton(p, addB, g, activeControl == AddLine); | 1671 | drawSBButton(p, addB, g, activeControl == AddLine); |
1669 | drawArrow( p, horiz ? RightArrow : DownArrow, | 1672 | drawArrow( p, horiz ? RightArrow : DownArrow, |
1670 | false, addB.x()+4, addB.y()+4, | 1673 | false, addB.x()+4, addB.y()+4, |
1671 | addB.width()-8, addB.height()-8, g, !maxed); | 1674 | addB.width()-8, addB.height()-8, g, !maxed); |
1672 | } | 1675 | } |
1673 | if ( controls & SubLine ) { | 1676 | if ( controls & SubLine ) { |
1674 | // drawSBButton(p, subB, g, activeControl == SubLine); | 1677 | // drawSBButton(p, subB, g, activeControl == SubLine); |
1675 | // drawArrow( p, horiz ? LeftArrow : UpArrow, | 1678 | // drawArrow( p, horiz ? LeftArrow : UpArrow, |
1676 | // false, subB.x()+4, subB.y()+4, | 1679 | // false, subB.x()+4, subB.y()+4, |
1677 | // subB.width()-8, subB.height()-8, g, !maxed); | 1680 | // subB.width()-8, subB.height()-8, g, !maxed); |
1678 | drawSBButton(p, subHC, g, activeControl == SubLine); | 1681 | drawSBButton(p, subHC, g, activeControl == SubLine); |
1679 | drawArrow( p, horiz ? LeftArrow : UpArrow, | 1682 | drawArrow( p, horiz ? LeftArrow : UpArrow, |
1680 | false, subHC.x()+4, subHC.y()+4, | 1683 | false, subHC.x()+4, subHC.y()+4, |
1681 | subHC.width()-8, subHC.height()-8, g, !maxed); | 1684 | subHC.width()-8, subHC.height()-8, g, !maxed); |
1682 | } | 1685 | } |
1683 | 1686 | ||
1684 | if(controls & AddPage){ | 1687 | if(controls & AddPage){ |
1685 | if(addPageR.width()){ | 1688 | if(addPageR.width()){ |
1686 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, | 1689 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, |
1687 | addPageR.x(), addPageR.y(), addPageR.width(), | 1690 | addPageR.x(), addPageR.y(), addPageR.width(), |
1688 | addPageR.height()); | 1691 | addPageR.height()); |
1689 | } | 1692 | } |
1690 | } | 1693 | } |
1691 | if(controls & SubPage){ | 1694 | if(controls & SubPage){ |
1692 | if(subPageR.height()){ | 1695 | if(subPageR.height()){ |
1693 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, | 1696 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, |
1694 | subPageR.x(), subPageR.y(), subPageR.width(), | 1697 | subPageR.x(), subPageR.y(), subPageR.width(), |
1695 | subPageR.height()); | 1698 | subPageR.height()); |
1696 | } | 1699 | } |
1697 | } | 1700 | } |
1698 | if ( controls & Slider ) { | 1701 | if ( controls & Slider ) { |
1699 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, | 1702 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, |
1700 | sliderR.x(), sliderR.y(), sliderR.width(), | 1703 | sliderR.x(), sliderR.y(), sliderR.width(), |
1701 | sliderR.height()); | 1704 | sliderR.height()); |
1702 | } | 1705 | } |
1703 | } | 1706 | } |
1704 | 1707 | ||
1705 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, | 1708 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, |
1706 | bool down, bool /*fast*/) | 1709 | bool down, bool /*fast*/) |
1707 | { | 1710 | { |
1708 | p->setPen(g.mid()); | 1711 | p->setPen(g.mid()); |
1709 | p->drawRect(r); | 1712 | p->drawRect(r); |
1710 | QColor c(down ? g.button() : g.background()); | 1713 | QColor c(down ? g.button() : g.background()); |
1711 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1714 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1712 | if(!pix){ | 1715 | if(!pix){ |
1713 | int h, s, v; | 1716 | int h, s, v; |
1714 | c.hsv(&h, &s, &v); | 1717 | c.hsv(&h, &s, &v); |
1715 | pix = new QPixmap(*bevelFillPix); | 1718 | pix = new QPixmap(*bevelFillPix); |
1716 | adjustHSV(*pix, h, s, v); | 1719 | adjustHSV(*pix, h, s, v); |
1717 | bevelFillDict.insert(c.rgb(), pix); | 1720 | bevelFillDict.insert(c.rgb(), pix); |
1718 | } | 1721 | } |
1719 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1722 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1720 | 1723 | ||
1721 | } | 1724 | } |
1722 | 1725 | ||
1723 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, | 1726 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, |
1724 | bool horiz) | 1727 | bool horiz) |
1725 | { | 1728 | { |
1726 | if(horiz){ | 1729 | if(horiz){ |
1727 | if(r.width() >= 15){ | 1730 | if(r.width() >= 15){ |
1728 | int y = r.y()+3; | 1731 | int y = r.y()+3; |
1729 | int x = r.x() + (r.width()-7)/2; | 1732 | int x = r.x() + (r.width()-7)/2; |
1730 | int y2 = r.bottom()-3; | 1733 | int y2 = r.bottom()-3; |
1731 | p->setPen(g.light()); | 1734 | p->setPen(g.light()); |
1732 | p->drawLine(x, y, x, y2); | 1735 | p->drawLine(x, y, x, y2); |
1733 | p->drawLine(x+3, y, x+3, y2); | 1736 | p->drawLine(x+3, y, x+3, y2); |
1734 | p->drawLine(x+6, y, x+6, y2); | 1737 | p->drawLine(x+6, y, x+6, y2); |
1735 | 1738 | ||
1736 | p->setPen(g.mid()); | 1739 | p->setPen(g.mid()); |
1737 | p->drawLine(x+1, y, x+1, y2); | 1740 | p->drawLine(x+1, y, x+1, y2); |
1738 | p->drawLine(x+4, y, x+4, y2); | 1741 | p->drawLine(x+4, y, x+4, y2); |
1739 | p->drawLine(x+7, y, x+7, y2); | 1742 | p->drawLine(x+7, y, x+7, y2); |
1740 | } | 1743 | } |
1741 | } | 1744 | } |
1742 | else{ | 1745 | else{ |
1743 | if(r.height() >= 15){ | 1746 | if(r.height() >= 15){ |
1744 | int x = r.x()+3; | 1747 | int x = r.x()+3; |
1745 | int y = r.y() + (r.height()-7)/2; | 1748 | int y = r.y() + (r.height()-7)/2; |
1746 | int x2 = r.right()-3; | 1749 | int x2 = r.right()-3; |
1747 | p->setPen(g.light()); | 1750 | p->setPen(g.light()); |
1748 | p->drawLine(x, y, x2, y); | 1751 | p->drawLine(x, y, x2, y); |
1749 | p->drawLine(x, y+3, x2, y+3); | 1752 | p->drawLine(x, y+3, x2, y+3); |
1750 | p->drawLine(x, y+6, x2, y+6); | 1753 | p->drawLine(x, y+6, x2, y+6); |
1751 | 1754 | ||
1752 | p->setPen(g.mid()); | 1755 | p->setPen(g.mid()); |
1753 | p->drawLine(x, y+1, x2, y+1); | 1756 | p->drawLine(x, y+1, x2, y+1); |
1754 | p->drawLine(x, y+4, x2, y+4); | 1757 | p->drawLine(x, y+4, x2, y+4); |
1755 | p->drawLine(x, y+7, x2, y+7); | 1758 | p->drawLine(x, y+7, x2, y+7); |
1756 | } | 1759 | } |
1757 | } | 1760 | } |
1758 | 1761 | ||
1759 | } | 1762 | } |
1760 | 1763 | ||
1761 | 1764 | ||
1762 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, | 1765 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, |
1763 | int &sliderMax, int &sliderLength, | 1766 | int &sliderMax, int &sliderLength, |
1764 | int &buttonDim) | 1767 | int &buttonDim) |
1765 | { | 1768 | { |
1766 | 1769 | ||
1767 | int maxLength; | 1770 | int maxLength; |
1768 | int b = 0; | 1771 | int b = 0; |
1769 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1772 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1770 | int length = horiz ? sb->width() : sb->height(); | 1773 | int length = horiz ? sb->width() : sb->height(); |
1771 | int extent = horiz ? sb->height() : sb->width(); | 1774 | int extent = horiz ? sb->height() : sb->width(); |
1772 | 1775 | ||
1773 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) | 1776 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) |
1774 | buttonDim = extent - b*2; | 1777 | buttonDim = extent - b*2; |
1775 | else | 1778 | else |
1776 | buttonDim = ( length - b*2 )/2 - 1; | 1779 | buttonDim = ( length - b*2 )/2 - 1; |
1777 | 1780 | ||
1778 | sliderMin = b + 0; // buttonDim; | 1781 | sliderMin = b + 0; // buttonDim; |
1779 | maxLength = length - b*2 - buttonDim*2; // 3; | 1782 | maxLength = length - b*2 - buttonDim*2; // 3; |
1780 | 1783 | ||
1781 | if ( sb->maxValue() == sb->minValue() ) { | 1784 | if ( sb->maxValue() == sb->minValue() ) { |
1782 | sliderLength = maxLength; | 1785 | sliderLength = maxLength; |
1783 | } else { | 1786 | } else { |
1784 | sliderLength = (sb->pageStep()*maxLength)/ | 1787 | sliderLength = (sb->pageStep()*maxLength)/ |
1785 | (sb->maxValue()-sb->minValue()+sb->pageStep()); | 1788 | (sb->maxValue()-sb->minValue()+sb->pageStep()); |
1786 | uint range = sb->maxValue()-sb->minValue(); | 1789 | uint range = sb->maxValue()-sb->minValue(); |
1787 | if ( sliderLength < 9 || range > INT_MAX/2 ) | 1790 | if ( sliderLength < 9 || range > INT_MAX/2 ) |
1788 | sliderLength = 9; | 1791 | sliderLength = 9; |
1789 | if ( sliderLength > maxLength ) | 1792 | if ( sliderLength > maxLength ) |
1790 | sliderLength = maxLength; | 1793 | sliderLength = maxLength; |
1791 | } | 1794 | } |
1792 | sliderMax = sliderMin + maxLength - sliderLength; | 1795 | sliderMax = sliderMin + maxLength - sliderLength; |
1793 | 1796 | ||
1794 | } | 1797 | } |
1795 | 1798 | ||