author | sandman <sandman> | 2002-12-03 00:59:30 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-03 00:59:30 (UTC) |
commit | 26557b9370b3d1f28224374f8a035ae9051a1317 (patch) (unidiff) | |
tree | b45c67bd4d71910f1faf020e23a01b648d2effbf | |
parent | c3c95ff297355f7024c15134bbc1d15d340bf8fd (diff) | |
download | opie-26557b9370b3d1f28224374f8a035ae9051a1317.zip opie-26557b9370b3d1f28224374f8a035ae9051a1317.tar.gz opie-26557b9370b3d1f28224374f8a035ae9051a1317.tar.bz2 |
small fix regarding focus handling on combo-boxes
-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,235 +1,237 @@ | |||
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){ |
@@ -1219,385 +1221,386 @@ void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | |||
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()); |