-rw-r--r-- | library/lightstyle.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp index f18bdca..3bd1623 100644 --- a/library/lightstyle.cpp +++ b/library/lightstyle.cpp | |||
@@ -1,562 +1,562 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "lightstyle.h" | 20 | #include "lightstyle.h" |
21 | 21 | ||
22 | #if QT_VERSION < 300 | 22 | #if QT_VERSION < 0x030000 |
23 | 23 | ||
24 | #define INCLUDE_MENUITEM_DEF | 24 | #define INCLUDE_MENUITEM_DEF |
25 | #include "qmenubar.h" | 25 | #include "qmenubar.h" |
26 | #include "qapplication.h" | 26 | #include "qapplication.h" |
27 | #include "qpainter.h" | 27 | #include "qpainter.h" |
28 | #include "qpalette.h" | 28 | #include "qpalette.h" |
29 | #include "qframe.h" | 29 | #include "qframe.h" |
30 | #include "qpushbutton.h" | 30 | #include "qpushbutton.h" |
31 | #include "qdrawutil.h" | 31 | #include "qdrawutil.h" |
32 | #include "qscrollbar.h" | 32 | #include "qscrollbar.h" |
33 | #include "qtabbar.h" | 33 | #include "qtabbar.h" |
34 | #include "qguardedptr.h" | 34 | #include "qguardedptr.h" |
35 | #include "qlayout.h" | 35 | #include "qlayout.h" |
36 | #include "qlineedit.h" | 36 | #include "qlineedit.h" |
37 | 37 | ||
38 | 38 | ||
39 | class LightStylePrivate | 39 | class LightStylePrivate |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | LightStylePrivate() | 42 | LightStylePrivate() |
43 | : hoverWidget(0), ref(1), savePalette(0) | 43 | : hoverWidget(0), ref(1), savePalette(0) |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | QGuardedPtr<QWidget> hoverWidget; | 47 | QGuardedPtr<QWidget> hoverWidget; |
48 | QPalette oldPalette, hoverPalette; | 48 | QPalette oldPalette, hoverPalette; |
49 | int ref; | 49 | int ref; |
50 | QPoint mousePos; | 50 | QPoint mousePos; |
51 | QPalette *savePalette; | 51 | QPalette *savePalette; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | 54 | ||
55 | static LightStylePrivate *singleton = 0; | 55 | static LightStylePrivate *singleton = 0; |
56 | 56 | ||
57 | 57 | ||
58 | LightStyle::LightStyle() | 58 | LightStyle::LightStyle() |
59 | : QWindowsStyle() | 59 | : QWindowsStyle() |
60 | { | 60 | { |
61 | if (! singleton) { | 61 | if (! singleton) { |
62 | singleton = new LightStylePrivate; | 62 | singleton = new LightStylePrivate; |
63 | 63 | ||
64 | QPalette pal = QApplication::palette(); | 64 | QPalette pal = QApplication::palette(); |
65 | singleton->oldPalette = pal; | 65 | singleton->oldPalette = pal; |
66 | 66 | ||
67 | QColor bg = pal.color(QPalette::Active, QColorGroup::Background); | 67 | QColor bg = pal.color(QPalette::Active, QColorGroup::Background); |
68 | QColor prelight; | 68 | QColor prelight; |
69 | 69 | ||
70 | if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) | 70 | if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) |
71 | prelight = pal.color(QPalette::Active, | 71 | prelight = pal.color(QPalette::Active, |
72 | QColorGroup::Background).light(110); | 72 | QColorGroup::Background).light(110); |
73 | else | 73 | else |
74 | prelight = pal.color(QPalette::Active, | 74 | prelight = pal.color(QPalette::Active, |
75 | QColorGroup::Background).light(120); | 75 | QColorGroup::Background).light(120); |
76 | 76 | ||
77 | QColorGroup active2(pal.color(QPalette::Active, | 77 | QColorGroup active2(pal.color(QPalette::Active, |
78 | QColorGroup::Foreground), // foreground | 78 | QColorGroup::Foreground), // foreground |
79 | prelight, // button | 79 | prelight, // button |
80 | prelight.light(), // light | 80 | prelight.light(), // light |
81 | prelight.dark(), // dark | 81 | prelight.dark(), // dark |
82 | prelight.dark(120), // mid | 82 | prelight.dark(120), // mid |
83 | pal.color(QPalette::Active, | 83 | pal.color(QPalette::Active, |
84 | QColorGroup::Text), // text | 84 | QColorGroup::Text), // text |
85 | pal.color(QPalette::Active, | 85 | pal.color(QPalette::Active, |
86 | QColorGroup::BrightText), // bright text | 86 | QColorGroup::BrightText), // bright text |
87 | pal.color(QPalette::Active, | 87 | pal.color(QPalette::Active, |
88 | QColorGroup::Base), // base | 88 | QColorGroup::Base), // base |
89 | bg); // background | 89 | bg); // background |
90 | active2.setColor(QColorGroup::Highlight, | 90 | active2.setColor(QColorGroup::Highlight, |
91 | pal.color(QPalette::Active, QColorGroup::Highlight)); | 91 | pal.color(QPalette::Active, QColorGroup::Highlight)); |
92 | 92 | ||
93 | singleton->hoverPalette = pal; | 93 | singleton->hoverPalette = pal; |
94 | singleton->hoverPalette.setActive(active2); | 94 | singleton->hoverPalette.setActive(active2); |
95 | singleton->hoverPalette.setInactive(active2); | 95 | singleton->hoverPalette.setInactive(active2); |
96 | } else | 96 | } else |
97 | singleton->ref++; | 97 | singleton->ref++; |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | LightStyle::~LightStyle() | 101 | LightStyle::~LightStyle() |
102 | { | 102 | { |
103 | if (singleton && singleton->ref-- <= 0) { | 103 | if (singleton && singleton->ref-- <= 0) { |
104 | delete singleton; | 104 | delete singleton; |
105 | singleton = 0; | 105 | singleton = 0; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | QSize LightStyle::scrollBarExtent() const | 110 | QSize LightStyle::scrollBarExtent() const |
111 | { | 111 | { |
112 | return QSize(12 + defaultFrameWidth(), 12 + defaultFrameWidth()); | 112 | return QSize(12 + defaultFrameWidth(), 12 + defaultFrameWidth()); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | int LightStyle::buttonDefaultIndicatorWidth() const | 116 | int LightStyle::buttonDefaultIndicatorWidth() const |
117 | { | 117 | { |
118 | return 2; | 118 | return 2; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | int LightStyle::sliderThickness() const | 122 | int LightStyle::sliderThickness() const |
123 | { | 123 | { |
124 | return 16; | 124 | return 16; |
125 | } | 125 | } |
126 | 126 | ||
127 | int LightStyle::sliderLength() const | 127 | int LightStyle::sliderLength() const |
128 | { | 128 | { |
129 | return 13; | 129 | return 13; |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | int LightStyle::buttonMargin() const | 133 | int LightStyle::buttonMargin() const |
134 | { | 134 | { |
135 | return 4; | 135 | return 4; |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | QSize LightStyle::exclusiveIndicatorSize() const | 139 | QSize LightStyle::exclusiveIndicatorSize() const |
140 | { | 140 | { |
141 | return QSize(13, 13); | 141 | return QSize(13, 13); |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | int LightStyle::defaultFrameWidth() const | 145 | int LightStyle::defaultFrameWidth() const |
146 | { | 146 | { |
147 | return 2; | 147 | return 2; |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | QSize LightStyle::indicatorSize() const | 151 | QSize LightStyle::indicatorSize() const |
152 | { | 152 | { |
153 | return QSize(13, 13); | 153 | return QSize(13, 13); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void LightStyle::polish(QWidget *widget) | 157 | void LightStyle::polish(QWidget *widget) |
158 | { | 158 | { |
159 | if (widget->inherits("QPushButton")) | 159 | if (widget->inherits("QPushButton")) |
160 | widget->installEventFilter(this); | 160 | widget->installEventFilter(this); |
161 | 161 | ||
162 | #if QT_VERSION >= 300 | 162 | #if QT_VERSION >= 0x030000 |
163 | if (widget->inherits("QLineEdit")) { | 163 | if (widget->inherits("QLineEdit")) { |
164 | QLineEdit *lineedit = (QLineEdit *) widget; | 164 | QLineEdit *lineedit = (QLineEdit *) widget; |
165 | lineedit->setFrameShape(QFrame::StyledPanel); | 165 | lineedit->setFrameShape(QFrame::StyledPanel); |
166 | lineedit->setLineWidth(2); | 166 | lineedit->setLineWidth(2); |
167 | } | 167 | } |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | QWindowsStyle::polish(widget); | 170 | QWindowsStyle::polish(widget); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void LightStyle::unPolish(QWidget *widget) | 174 | void LightStyle::unPolish(QWidget *widget) |
175 | { | 175 | { |
176 | if (widget->inherits("QPushButton")) | 176 | if (widget->inherits("QPushButton")) |
177 | widget->removeEventFilter(this); | 177 | widget->removeEventFilter(this); |
178 | 178 | ||
179 | #if QT_VERSION >= 300 | 179 | #if QT_VERSION >= 0x030000 |
180 | if (widget->inherits("QLineEdit")) { | 180 | if (widget->inherits("QLineEdit")) { |
181 | QLineEdit *lineedit = (QLineEdit *) widget; | 181 | QLineEdit *lineedit = (QLineEdit *) widget; |
182 | lineedit->setLineWidth(1); | 182 | lineedit->setLineWidth(1); |
183 | lineedit->setFrameShape(QFrame::WinPanel); | 183 | lineedit->setFrameShape(QFrame::WinPanel); |
184 | } | 184 | } |
185 | #endif | 185 | #endif |
186 | 186 | ||
187 | QWindowsStyle::unPolish(widget); | 187 | QWindowsStyle::unPolish(widget); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void LightStyle::polish(QApplication *app) | 191 | void LightStyle::polish(QApplication *app) |
192 | { | 192 | { |
193 | QPalette pal = app->palette(); | 193 | QPalette pal = app->palette(); |
194 | 194 | ||
195 | QColorGroup active(pal.color(QPalette::Active, | 195 | QColorGroup active(pal.color(QPalette::Active, |
196 | QColorGroup::Foreground), // foreground | 196 | QColorGroup::Foreground), // foreground |
197 | pal.color(QPalette::Active, | 197 | pal.color(QPalette::Active, |
198 | QColorGroup::Button), // button | 198 | QColorGroup::Button), // button |
199 | pal.color(QPalette::Active, | 199 | pal.color(QPalette::Active, |
200 | QColorGroup::Background).light(), // light | 200 | QColorGroup::Background).light(), // light |
201 | pal.color(QPalette::Active, | 201 | pal.color(QPalette::Active, |
202 | QColorGroup::Background).dark(175), // dark | 202 | QColorGroup::Background).dark(175), // dark |
203 | pal.color(QPalette::Active, | 203 | pal.color(QPalette::Active, |
204 | QColorGroup::Background).dark(110), // mid | 204 | QColorGroup::Background).dark(110), // mid |
205 | pal.color(QPalette::Active, | 205 | pal.color(QPalette::Active, |
206 | QColorGroup::Text), // text | 206 | QColorGroup::Text), // text |
207 | pal.color(QPalette::Active, | 207 | pal.color(QPalette::Active, |
208 | QColorGroup::BrightText), // bright text | 208 | QColorGroup::BrightText), // bright text |
209 | pal.color(QPalette::Active, | 209 | pal.color(QPalette::Active, |
210 | QColorGroup::Base), // base | 210 | QColorGroup::Base), // base |
211 | pal.color(QPalette::Active, | 211 | pal.color(QPalette::Active, |
212 | QColorGroup::Background)), // background | 212 | QColorGroup::Background)), // background |
213 | 213 | ||
214 | 214 | ||
215 | disabled(pal.color(QPalette::Disabled, | 215 | disabled(pal.color(QPalette::Disabled, |
216 | QColorGroup::Foreground), // foreground | 216 | QColorGroup::Foreground), // foreground |
217 | pal.color(QPalette::Disabled, | 217 | pal.color(QPalette::Disabled, |
218 | QColorGroup::Button), // button | 218 | QColorGroup::Button), // button |
219 | pal.color(QPalette::Disabled, | 219 | pal.color(QPalette::Disabled, |
220 | QColorGroup::Background).light(), // light | 220 | QColorGroup::Background).light(), // light |
221 | pal.color(QPalette::Disabled, | 221 | pal.color(QPalette::Disabled, |
222 | QColorGroup::Background).dark(), // dark | 222 | QColorGroup::Background).dark(), // dark |
223 | pal.color(QPalette::Disabled, | 223 | pal.color(QPalette::Disabled, |
224 | QColorGroup::Background).dark(110), // mid | 224 | QColorGroup::Background).dark(110), // mid |
225 | pal.color(QPalette::Disabled, | 225 | pal.color(QPalette::Disabled, |
226 | QColorGroup::Text), // text | 226 | QColorGroup::Text), // text |
227 | pal.color(QPalette::Disabled, | 227 | pal.color(QPalette::Disabled, |
228 | QColorGroup::BrightText), // bright text | 228 | QColorGroup::BrightText), // bright text |
229 | pal.color(QPalette::Disabled, | 229 | pal.color(QPalette::Disabled, |
230 | QColorGroup::Base), // base | 230 | QColorGroup::Base), // base |
231 | pal.color(QPalette::Disabled, | 231 | pal.color(QPalette::Disabled, |
232 | QColorGroup::Background)); // background | 232 | QColorGroup::Background)); // background |
233 | 233 | ||
234 | active.setColor(QColorGroup::Highlight, | 234 | active.setColor(QColorGroup::Highlight, |
235 | pal.color(QPalette::Active, QColorGroup::Highlight)); | 235 | pal.color(QPalette::Active, QColorGroup::Highlight)); |
236 | disabled.setColor(QColorGroup::Highlight, | 236 | disabled.setColor(QColorGroup::Highlight, |
237 | pal.color(QPalette::Disabled, QColorGroup::Highlight)); | 237 | pal.color(QPalette::Disabled, QColorGroup::Highlight)); |
238 | 238 | ||
239 | active.setColor(QColorGroup::HighlightedText, | 239 | active.setColor(QColorGroup::HighlightedText, |
240 | pal.color(QPalette::Active, QColorGroup::HighlightedText)); | 240 | pal.color(QPalette::Active, QColorGroup::HighlightedText)); |
241 | disabled.setColor(QColorGroup::HighlightedText, | 241 | disabled.setColor(QColorGroup::HighlightedText, |
242 | pal.color(QPalette::Disabled, QColorGroup::HighlightedText)); | 242 | pal.color(QPalette::Disabled, QColorGroup::HighlightedText)); |
243 | 243 | ||
244 | pal.setActive(active); | 244 | pal.setActive(active); |
245 | pal.setInactive(active); | 245 | pal.setInactive(active); |
246 | pal.setDisabled(disabled); | 246 | pal.setDisabled(disabled); |
247 | 247 | ||
248 | singleton->oldPalette = pal; | 248 | singleton->oldPalette = pal; |
249 | 249 | ||
250 | QColor bg = pal.color(QPalette::Active, QColorGroup::Background); | 250 | QColor bg = pal.color(QPalette::Active, QColorGroup::Background); |
251 | QColor prelight; | 251 | QColor prelight; |
252 | 252 | ||
253 | if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) | 253 | if ( (bg.red() + bg.green() + bg.blue()) / 3 > 128) |
254 | prelight = pal.color(QPalette::Active, | 254 | prelight = pal.color(QPalette::Active, |
255 | QColorGroup::Background).light(110); | 255 | QColorGroup::Background).light(110); |
256 | else | 256 | else |
257 | prelight = pal.color(QPalette::Active, | 257 | prelight = pal.color(QPalette::Active, |
258 | QColorGroup::Background).light(120); | 258 | QColorGroup::Background).light(120); |
259 | 259 | ||
260 | QColorGroup active2(pal.color(QPalette::Active, | 260 | QColorGroup active2(pal.color(QPalette::Active, |
261 | QColorGroup::Foreground), // foreground | 261 | QColorGroup::Foreground), // foreground |
262 | prelight, // button | 262 | prelight, // button |
263 | prelight.light(), // light | 263 | prelight.light(), // light |
264 | prelight.dark(), // dark | 264 | prelight.dark(), // dark |
265 | prelight.dark(120), // mid | 265 | prelight.dark(120), // mid |
266 | pal.color(QPalette::Active, | 266 | pal.color(QPalette::Active, |
267 | QColorGroup::Text), // text | 267 | QColorGroup::Text), // text |
268 | pal.color(QPalette::Active, | 268 | pal.color(QPalette::Active, |
269 | QColorGroup::BrightText), // bright text | 269 | QColorGroup::BrightText), // bright text |
270 | pal.color(QPalette::Active, | 270 | pal.color(QPalette::Active, |
271 | QColorGroup::Base), // base | 271 | QColorGroup::Base), // base |
272 | bg); // background | 272 | bg); // background |
273 | active2.setColor(QColorGroup::Highlight, | 273 | active2.setColor(QColorGroup::Highlight, |
274 | pal.color(QPalette::Active, QColorGroup::Highlight)); | 274 | pal.color(QPalette::Active, QColorGroup::Highlight)); |
275 | 275 | ||
276 | singleton->hoverPalette = pal; | 276 | singleton->hoverPalette = pal; |
277 | singleton->hoverPalette.setActive(active2); | 277 | singleton->hoverPalette.setActive(active2); |
278 | singleton->hoverPalette.setInactive(active2); | 278 | singleton->hoverPalette.setInactive(active2); |
279 | 279 | ||
280 | app->setPalette(pal); | 280 | app->setPalette(pal); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void LightStyle::unPolish(QApplication *app) | 284 | void LightStyle::unPolish(QApplication *app) |
285 | { | 285 | { |
286 | app->setPalette(singleton->oldPalette); | 286 | app->setPalette(singleton->oldPalette); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void LightStyle::polishPopupMenu(QPopupMenu *menu) | 290 | void LightStyle::polishPopupMenu(QPopupMenu *menu) |
291 | { | 291 | { |
292 | menu->setMouseTracking(TRUE); | 292 | menu->setMouseTracking(TRUE); |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | void LightStyle::drawPushButton(QPushButton *button, QPainter *p) | 296 | void LightStyle::drawPushButton(QPushButton *button, QPainter *p) |
297 | { | 297 | { |
298 | int x1, y1, x2, y2; | 298 | int x1, y1, x2, y2; |
299 | button->rect().coords(&x1, &y1, &x2, &y2); | 299 | button->rect().coords(&x1, &y1, &x2, &y2); |
300 | 300 | ||
301 | if (button->isDefault()) { | 301 | if (button->isDefault()) { |
302 | p->save(); | 302 | p->save(); |
303 | p->setPen(button->palette().active().color(QColorGroup::Highlight)); | 303 | p->setPen(button->palette().active().color(QColorGroup::Highlight)); |
304 | p->setBrush(button->palette().active().brush(QColorGroup::Highlight)); | 304 | p->setBrush(button->palette().active().brush(QColorGroup::Highlight)); |
305 | p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15); | 305 | p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15); |
306 | p->restore(); | 306 | p->restore(); |
307 | } | 307 | } |
308 | 308 | ||
309 | if (button->isDefault() || button->autoDefault()) { | 309 | if (button->isDefault() || button->autoDefault()) { |
310 | x1 += buttonDefaultIndicatorWidth(); | 310 | x1 += buttonDefaultIndicatorWidth(); |
311 | y1 += buttonDefaultIndicatorWidth(); | 311 | y1 += buttonDefaultIndicatorWidth(); |
312 | x2 -= buttonDefaultIndicatorWidth(); | 312 | x2 -= buttonDefaultIndicatorWidth(); |
313 | y2 -= buttonDefaultIndicatorWidth(); | 313 | y2 -= buttonDefaultIndicatorWidth(); |
314 | 314 | ||
315 | if (button->isDefault()) { | 315 | if (button->isDefault()) { |
316 | QPointArray pa(8); | 316 | QPointArray pa(8); |
317 | pa.setPoint(0, x1 + 2, y1 ); | 317 | pa.setPoint(0, x1 + 2, y1 ); |
318 | pa.setPoint(1, x2 - 1, y1 ); | 318 | pa.setPoint(1, x2 - 1, y1 ); |
319 | pa.setPoint(2, x2 + 1, y1 + 2); | 319 | pa.setPoint(2, x2 + 1, y1 + 2); |
320 | pa.setPoint(3, x2 + 1, y2 - 2); | 320 | pa.setPoint(3, x2 + 1, y2 - 2); |
321 | pa.setPoint(4, x2 - 2, y2 + 1); | 321 | pa.setPoint(4, x2 - 2, y2 + 1); |
322 | pa.setPoint(5, x1 + 2, y2 + 1); | 322 | pa.setPoint(5, x1 + 2, y2 + 1); |
323 | pa.setPoint(6, x1, y2 - 1); | 323 | pa.setPoint(6, x1, y2 - 1); |
324 | pa.setPoint(7, x1, y1 + 2); | 324 | pa.setPoint(7, x1, y1 + 2); |
325 | QRegion r(pa); | 325 | QRegion r(pa); |
326 | p->setClipRegion(r); | 326 | p->setClipRegion(r); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | QBrush fill; | 330 | QBrush fill; |
331 | if (button->isDown() || button->isOn()) | 331 | if (button->isDown() || button->isOn()) |
332 | fill = button->colorGroup().brush(QColorGroup::Mid); | 332 | fill = button->colorGroup().brush(QColorGroup::Mid); |
333 | else | 333 | else |
334 | fill = button->colorGroup().brush(QColorGroup::Button); | 334 | fill = button->colorGroup().brush(QColorGroup::Button); |
335 | 335 | ||
336 | if ( !button->isFlat() || button->isOn() || button->isDown() ) | 336 | if ( !button->isFlat() || button->isOn() || button->isDown() ) |
337 | drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1, | 337 | drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1, |
338 | button->colorGroup(), button->isOn() || button->isDown(), &fill); | 338 | button->colorGroup(), button->isOn() || button->isDown(), &fill); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 342 | void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
343 | const QColorGroup &g, | 343 | const QColorGroup &g, |
344 | bool sunken, const QBrush *fill) | 344 | bool sunken, const QBrush *fill) |
345 | { | 345 | { |
346 | p->save(); | 346 | p->save(); |
347 | if ( fill ) | 347 | if ( fill ) |
348 | p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); | 348 | p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); |
349 | else | 349 | else |
350 | p->fillRect(x + 2, y + 2, w - 4, h - 4, | 350 | p->fillRect(x + 2, y + 2, w - 4, h - 4, |
351 | QBrush(sunken ? g.mid() : g.button())); | 351 | QBrush(sunken ? g.mid() : g.button())); |
352 | 352 | ||
353 | // frame | 353 | // frame |
354 | p->setPen(g.dark()); | 354 | p->setPen(g.dark()); |
355 | p->drawLine(x, y + 2, x, y + h - 3); // left | 355 | p->drawLine(x, y + 2, x, y + h - 3); // left |
356 | p->drawLine(x + 2, y, x + w - 3, y); // top | 356 | p->drawLine(x + 2, y, x + w - 3, y); // top |
357 | p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right | 357 | p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right |
358 | p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom | 358 | p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom |
359 | p->drawPoint(x + 1, y + 1); | 359 | p->drawPoint(x + 1, y + 1); |
360 | p->drawPoint(x + 1, y + h - 2); | 360 | p->drawPoint(x + 1, y + h - 2); |
361 | p->drawPoint(x + w - 2, y + 1); | 361 | p->drawPoint(x + w - 2, y + 1); |
362 | p->drawPoint(x + w - 2, y + h - 2); | 362 | p->drawPoint(x + w - 2, y + h - 2); |
363 | 363 | ||
364 | // bevel | 364 | // bevel |
365 | if (sunken) | 365 | if (sunken) |
366 | p->setPen(g.mid()); | 366 | p->setPen(g.mid()); |
367 | else | 367 | else |
368 | p->setPen(g.light()); | 368 | p->setPen(g.light()); |
369 | 369 | ||
370 | p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left | 370 | p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left |
371 | p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top | 371 | p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top |
372 | 372 | ||
373 | if (sunken) | 373 | if (sunken) |
374 | p->setPen(g.light()); | 374 | p->setPen(g.light()); |
375 | else | 375 | else |
376 | p->setPen(g.mid()); | 376 | p->setPen(g.mid()); |
377 | 377 | ||
378 | p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 | 378 | p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 |
379 | p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 | 379 | p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 |
380 | 380 | ||
381 | p->restore(); | 381 | p->restore(); |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, | 385 | void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, |
386 | const QColorGroup &g, | 386 | const QColorGroup &g, |
387 | bool sunken, const QBrush *fill) | 387 | bool sunken, const QBrush *fill) |
388 | { | 388 | { |
389 | drawButton(p, x, y, w, h, g, sunken, fill); | 389 | drawButton(p, x, y, w, h, g, sunken, fill); |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void LightStyle::getButtonShift(int &x, int &y) const | 393 | void LightStyle::getButtonShift(int &x, int &y) const |
394 | { | 394 | { |
395 | x = y = 0; | 395 | x = y = 0; |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h, | 399 | void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h, |
400 | const QColorGroup &g, bool, | 400 | const QColorGroup &g, bool, |
401 | bool editable, bool, | 401 | bool editable, bool, |
402 | const QBrush *fill) | 402 | const QBrush *fill) |
403 | { | 403 | { |
404 | drawButton(p, x, y, w, h, g, FALSE, fill); | 404 | drawButton(p, x, y, w, h, g, FALSE, fill); |
405 | 405 | ||
406 | if (editable) { | 406 | if (editable) { |
407 | QRect r = comboButtonRect(x, y, w, h); | 407 | QRect r = comboButtonRect(x, y, w, h); |
408 | qDrawShadePanel(p, r.x() - 1, r.y() - 1, | 408 | qDrawShadePanel(p, r.x() - 1, r.y() - 1, |
409 | r.width() + defaultFrameWidth(), | 409 | r.width() + defaultFrameWidth(), |
410 | r.height() + defaultFrameWidth(), | 410 | r.height() + defaultFrameWidth(), |
411 | g, TRUE); | 411 | g, TRUE); |
412 | } | 412 | } |
413 | 413 | ||
414 | int indent = ((y + h) / 2) - 3; | 414 | int indent = ((y + h) / 2) - 3; |
415 | int xpos = x; | 415 | int xpos = x; |
416 | 416 | ||
417 | #if QT_VERSION >= 300 | 417 | #if QT_VERSION >= 0x030000 |
418 | if( QApplication::reverseLayout() ) | 418 | if( QApplication::reverseLayout() ) |
419 | xpos += indent; | 419 | xpos += indent; |
420 | else | 420 | else |
421 | #endif | 421 | #endif |
422 | xpos += w - indent - 5; | 422 | xpos += w - indent - 5; |
423 | 423 | ||
424 | drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill); | 424 | drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill); |
425 | } | 425 | } |
426 | 426 | ||
427 | 427 | ||
428 | QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const | 428 | QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const |
429 | { | 429 | { |
430 | QRect r(x + 3, y + 3, w - 6, h - 6); | 430 | QRect r(x + 3, y + 3, w - 6, h - 6); |
431 | int indent = ((y + h) / 2) - 3; | 431 | int indent = ((y + h) / 2) - 3; |
432 | r.setRight(r.right() - indent - 10); | 432 | r.setRight(r.right() - indent - 10); |
433 | 433 | ||
434 | #if QT_VERSION >= 300 | 434 | #if QT_VERSION >= 0x030000 |
435 | if( QApplication::reverseLayout() ) | 435 | if( QApplication::reverseLayout() ) |
436 | r.moveBy( indent + 10, 0 ); | 436 | r.moveBy( indent + 10, 0 ); |
437 | #endif | 437 | #endif |
438 | 438 | ||
439 | return r; | 439 | return r; |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const | 443 | QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const |
444 | { | 444 | { |
445 | return comboButtonRect(x, y, w, h); | 445 | return comboButtonRect(x, y, w, h); |
446 | } | 446 | } |
447 | 447 | ||
448 | 448 | ||
449 | void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h, | 449 | void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h, |
450 | const QColorGroup &g, bool sunken, | 450 | const QColorGroup &g, bool sunken, |
451 | int lw, const QBrush *fill) | 451 | int lw, const QBrush *fill) |
452 | { | 452 | { |
453 | if (lw >= 2) { | 453 | if (lw >= 2) { |
454 | if ( fill ) | 454 | if ( fill ) |
455 | p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); | 455 | p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill); |
456 | 456 | ||
457 | QPen oldpen = p->pen(); | 457 | QPen oldpen = p->pen(); |
458 | 458 | ||
459 | // frame | 459 | // frame |
460 | p->setPen(g.dark()); | 460 | p->setPen(g.dark()); |
461 | p->drawLine(x, y + 2, x, y + h - 3); // left | 461 | p->drawLine(x, y + 2, x, y + h - 3); // left |
462 | p->drawLine(x + 2, y, x + w - 3, y); // top | 462 | p->drawLine(x + 2, y, x + w - 3, y); // top |
463 | p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right | 463 | p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right |
464 | p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom | 464 | p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom |
465 | p->drawPoint(x + 1, y + 1); | 465 | p->drawPoint(x + 1, y + 1); |
466 | p->drawPoint(x + 1, y + h - 2); | 466 | p->drawPoint(x + 1, y + h - 2); |
467 | p->drawPoint(x + w - 2, y + 1); | 467 | p->drawPoint(x + w - 2, y + 1); |
468 | p->drawPoint(x + w - 2, y + h - 2); | 468 | p->drawPoint(x + w - 2, y + h - 2); |
469 | 469 | ||
470 | // bevel | 470 | // bevel |
471 | if (sunken) | 471 | if (sunken) |
472 | p->setPen(g.mid()); | 472 | p->setPen(g.mid()); |
473 | else | 473 | else |
474 | p->setPen(g.light()); | 474 | p->setPen(g.light()); |
475 | 475 | ||
476 | p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left | 476 | p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left |
477 | p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top | 477 | p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top |
478 | 478 | ||
479 | if (sunken) | 479 | if (sunken) |
480 | p->setPen(g.light()); | 480 | p->setPen(g.light()); |
481 | else | 481 | else |
482 | p->setPen(g.mid()); | 482 | p->setPen(g.mid()); |
483 | 483 | ||
484 | p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 | 484 | p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1 |
485 | p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 | 485 | p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1 |
486 | 486 | ||
487 | // corners | 487 | // corners |
488 | p->setPen(g.background()); | 488 | p->setPen(g.background()); |
489 | p->drawLine(x, y, x + 1, y); | 489 | p->drawLine(x, y, x + 1, y); |
490 | p->drawLine(x, y + h - 1, x + 1, y + h - 1); | 490 | p->drawLine(x, y + h - 1, x + 1, y + h - 1); |
491 | p->drawLine(x + w - 2, y, x + w - 1, y); | 491 | p->drawLine(x + w - 2, y, x + w - 1, y); |
492 | p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1); | 492 | p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1); |
493 | p->drawPoint(x, y + 1); | 493 | p->drawPoint(x, y + 1); |
494 | p->drawPoint(x, y + h - 2); | 494 | p->drawPoint(x, y + h - 2); |
495 | p->drawPoint(x + w - 1, y + 1); | 495 | p->drawPoint(x + w - 1, y + 1); |
496 | p->drawPoint(x + w - 1, y + h - 2); | 496 | p->drawPoint(x + w - 1, y + h - 2); |
497 | 497 | ||
498 | p->setPen(oldpen); | 498 | p->setPen(oldpen); |
499 | } else | 499 | } else |
500 | qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill); | 500 | qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h, | 504 | void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h, |
505 | const QColorGroup &g, int state, | 505 | const QColorGroup &g, int state, |
506 | bool down, bool) | 506 | bool down, bool) |
507 | { | 507 | { |
508 | drawButton(p, x, y, w, h, g, TRUE, | 508 | drawButton(p, x, y, w, h, g, TRUE, |
509 | &g.brush(down ? QColorGroup::Mid : QColorGroup::Base)); | 509 | &g.brush(down ? QColorGroup::Mid : QColorGroup::Base)); |
510 | 510 | ||
511 | p->save(); | 511 | p->save(); |
512 | 512 | ||
513 | p->setPen(g.foreground()); | 513 | p->setPen(g.foreground()); |
514 | if (state == QButton::NoChange) { | 514 | if (state == QButton::NoChange) { |
515 | p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2); | 515 | p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2); |
516 | p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2); | 516 | p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2); |
517 | p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2); | 517 | p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2); |
518 | } else if (state == QButton::On) { | 518 | } else if (state == QButton::On) { |
519 | p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5); | 519 | p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5); |
520 | p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4); | 520 | p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4); |
521 | p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4); | 521 | p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4); |
522 | p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3); | 522 | p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3); |
523 | p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3); | 523 | p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3); |
524 | p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4); | 524 | p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4); |
525 | } | 525 | } |
526 | 526 | ||
527 | p->restore(); | 527 | p->restore(); |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h, | 531 | void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h, |
532 | const QColorGroup &g, bool on, | 532 | const QColorGroup &g, bool on, |
533 | bool down, bool) | 533 | bool down, bool) |
534 | { | 534 | { |
535 | p->save(); | 535 | p->save(); |
536 | 536 | ||
537 | p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); | 537 | p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); |
538 | 538 | ||
539 | p->setPen(g.dark()); | 539 | p->setPen(g.dark()); |
540 | p->drawArc(x, y, w, h, 0, 16*360); | 540 | p->drawArc(x, y, w, h, 0, 16*360); |
541 | p->setPen(g.mid()); | 541 | p->setPen(g.mid()); |
542 | p->drawArc(x + 1, y + 1, w - 2, h - 2, 45*16, 180*16); | 542 | p->drawArc(x + 1, y + 1, w - 2, h - 2, 45*16, 180*16); |
543 | p->setPen(g.light()); | 543 | p->setPen(g.light()); |
544 | p->drawArc(x + 1, y + 1, w - 2, h - 2, 235*16, 180*16); | 544 | p->drawArc(x + 1, y + 1, w - 2, h - 2, 235*16, 180*16); |
545 | 545 | ||
546 | p->setPen(down ? g.mid() : g.base()); | 546 | p->setPen(down ? g.mid() : g.base()); |
547 | p->setBrush(down ? g.mid() : g.base()); | 547 | p->setBrush(down ? g.mid() : g.base()); |
548 | p->drawEllipse(x + 2, y + 2, w - 4, h - 4); | 548 | p->drawEllipse(x + 2, y + 2, w - 4, h - 4); |
549 | 549 | ||
550 | if (on) { | 550 | if (on) { |
551 | p->setBrush(g.foreground()); | 551 | p->setBrush(g.foreground()); |
552 | p->drawEllipse(x + 3, y + 3, w - x - 6, h - y - 6); | 552 | p->drawEllipse(x + 3, y + 3, w - x - 6, h - y - 6); |
553 | } | 553 | } |
554 | 554 | ||
555 | p->restore(); | 555 | p->restore(); |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | 559 | ||
560 | #if 1 | 560 | #if 1 |
561 | //copied from QPE style | 561 | //copied from QPE style |
562 | void LightStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) | 562 | void LightStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) |