-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,171 +1,173 @@ | |||
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 ( ); |
@@ -1283,257 +1285,258 @@ void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | |||
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 ); |