summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-02 19:58:09 (UTC)
committer zecke <zecke>2004-08-02 19:58:09 (UTC)
commit1e8f0e771789b353ab025320dcb845818ed3d977 (patch) (unidiff)
treef6b02187a54d460f6b75251a44c5e9b764b302bf
parentafec356b8cbbda815308fb5fe8e277737e0ca32c (diff)
downloadopie-1e8f0e771789b353ab025320dcb845818ed3d977.zip
opie-1e8f0e771789b353ab025320dcb845818ed3d977.tar.gz
opie-1e8f0e771789b353ab025320dcb845818ed3d977.tar.bz2
Make CheckBox a bit smaller
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/web/webstyle.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/styles/web/webstyle.cpp b/noncore/styles/web/webstyle.cpp
index 10d9791..cd3cf08 100644
--- a/noncore/styles/web/webstyle.cpp
+++ b/noncore/styles/web/webstyle.cpp
@@ -1,1183 +1,1183 @@
1/* 1/*
2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA. 17 * Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20#ifndef INCLUDE_MENUITEM_DEF 20#ifndef INCLUDE_MENUITEM_DEF
21#define INCLUDE_MENUITEM_DEF 21#define INCLUDE_MENUITEM_DEF
22#endif 22#endif
23 23
24#include <qmenudata.h> 24#include <qmenudata.h>
25#include <qpalette.h> 25#include <qpalette.h>
26#include <qbitmap.h> 26#include <qbitmap.h>
27#include <qtabbar.h> 27#include <qtabbar.h>
28#include <qpointarray.h> 28#include <qpointarray.h>
29#include <qscrollbar.h> 29#include <qscrollbar.h>
30#include <qframe.h> 30#include <qframe.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qdrawutil.h> 32#include <qdrawutil.h>
33#include <qpainter.h> 33#include <qpainter.h>
34 34
35#include "webstyle.h" 35#include "webstyle.h"
36 36
37static const int _indicatorSize = 13; 37static const int _indicatorSize = 9;
38static QButton * _highlightedButton = 0; 38static QButton * _highlightedButton = 0;
39static const int _scrollBarExtent = 12; 39static const int _scrollBarExtent = 12;
40 40
41static QFrame * _currentFrame = 0; 41static QFrame * _currentFrame = 0;
42static int _savedFrameLineWidth; 42static int _savedFrameLineWidth;
43static int _savedFrameMidLineWidth; 43static int _savedFrameMidLineWidth;
44static ulong _savedFrameStyle; 44static ulong _savedFrameStyle;
45 45
46static QColor contrastingForeground(const QColor & fg, const QColor & bg) 46static QColor contrastingForeground(const QColor & fg, const QColor & bg)
47{ 47{
48 int h, s, vbg, vfg; 48 int h, s, vbg, vfg;
49 49
50 bg.hsv(&h, &s, &vbg); 50 bg.hsv(&h, &s, &vbg);
51 fg.hsv(&h, &s, &vfg); 51 fg.hsv(&h, &s, &vfg);
52 52
53 int diff(vbg - vfg); 53 int diff(vbg - vfg);
54 54
55 if ((diff > -72) && (diff < 72)) 55 if ((diff > -72) && (diff < 72))
56 { 56 {
57 return (vbg < 128) ? Qt::white : Qt::black; 57 return (vbg < 128) ? Qt::white : Qt::black;
58 } 58 }
59 else 59 else
60 { 60 {
61 return fg; 61 return fg;
62 } 62 }
63} 63}
64 64
65// Gotta keep it separated. 65// Gotta keep it separated.
66 66
67 static void 67 static void
68scrollBarControlsMetrics 68scrollBarControlsMetrics
69( 69(
70 const QScrollBar * sb, 70 const QScrollBar * sb,
71 int sliderStart, 71 int sliderStart,
72 int /* sliderMin */, 72 int /* sliderMin */,
73 int sliderMax, 73 int sliderMax,
74 int sliderLength, 74 int sliderLength,
75 int buttonDim, 75 int buttonDim,
76 QRect & rSub, 76 QRect & rSub,
77 QRect & rAdd, 77 QRect & rAdd,
78 QRect & rSubPage, 78 QRect & rSubPage,
79 QRect & rAddPage, 79 QRect & rAddPage,
80 QRect & rSlider 80 QRect & rSlider
81 ) 81 )
82{ 82{
83 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 83 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
84 84
85 int len = horizontal ? sb->width() : sb->height(); 85 int len = horizontal ? sb->width() : sb->height();
86 86
87 int extent = horizontal ? sb->height() : sb->width(); 87 int extent = horizontal ? sb->height() : sb->width();
88 88
89 QColorGroup g = sb->colorGroup(); 89 QColorGroup g = sb->colorGroup();
90 90
91 if (sliderStart > sliderMax) 91 if (sliderStart > sliderMax)
92 sliderStart = sliderMax; 92 sliderStart = sliderMax;
93 93
94 int sliderEnd = sliderStart + sliderLength; 94 int sliderEnd = sliderStart + sliderLength;
95 95
96 int addX, addY; 96 int addX, addY;
97 int subX, subY; 97 int subX, subY;
98 int subPageX, subPageY, subPageW, subPageH; 98 int subPageX, subPageY, subPageW, subPageH;
99 int addPageX, addPageY, addPageW, addPageH; 99 int addPageX, addPageY, addPageW, addPageH;
100 int sliderX, sliderY, sliderW, sliderH; 100 int sliderX, sliderY, sliderW, sliderH;
101 101
102 if (horizontal) 102 if (horizontal)
103 { 103 {
104 subY = 0; 104 subY = 0;
105 addY = 0; 105 addY = 0;
106 subX = 0; 106 subX = 0;
107 addX = buttonDim; 107 addX = buttonDim;
108 108
109 subPageX = buttonDim * 2; 109 subPageX = buttonDim * 2;
110 subPageY = 0; 110 subPageY = 0;
111 subPageW = sliderStart - 1; 111 subPageW = sliderStart - 1;
112 subPageH = extent; 112 subPageH = extent;
113 113
114 addPageX = sliderEnd; 114 addPageX = sliderEnd;
115 addPageY = 0; 115 addPageY = 0;
116 addPageW = len - sliderEnd; 116 addPageW = len - sliderEnd;
117 addPageH = extent; 117 addPageH = extent;
118 118
119 sliderX = sliderStart; 119 sliderX = sliderStart;
120 sliderY = 0; 120 sliderY = 0;
121 sliderW = sliderLength; 121 sliderW = sliderLength;
122 sliderH = extent; 122 sliderH = extent;
123 } 123 }
124 else 124 else
125 { 125 {
126 subX = 0; 126 subX = 0;
127 addX = 0; 127 addX = 0;
128 subY = len - buttonDim * 2; 128 subY = len - buttonDim * 2;
129 addY = len - buttonDim; 129 addY = len - buttonDim;
130 130
131 subPageX = 0; 131 subPageX = 0;
132 subPageY = 0; 132 subPageY = 0;
133 subPageW = extent; 133 subPageW = extent;
134 subPageH = sliderStart; 134 subPageH = sliderStart;
135 135
136 addPageX = 0; 136 addPageX = 0;
137 addPageY = sliderEnd; 137 addPageY = sliderEnd;
138 addPageW = extent; 138 addPageW = extent;
139 addPageH = subY - sliderEnd; 139 addPageH = subY - sliderEnd;
140 140
141 sliderX = 0; 141 sliderX = 0;
142 sliderY = sliderStart; 142 sliderY = sliderStart;
143 sliderW = extent; 143 sliderW = extent;
144 sliderH = sliderLength; 144 sliderH = sliderLength;
145 } 145 }
146 146
147 rSub .setRect( subX, subY, buttonDim, buttonDim); 147 rSub .setRect( subX, subY, buttonDim, buttonDim);
148 rAdd .setRect( addX, addY, buttonDim, buttonDim); 148 rAdd .setRect( addX, addY, buttonDim, buttonDim);
149 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH); 149 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
150 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH); 150 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
151 rSlider .setRect( sliderX, sliderY, sliderW, sliderH); 151 rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
152} 152}
153 153
154// Rounded rects my way. 154// Rounded rects my way.
155 155
156 static void 156 static void
157drawFunkyRect 157drawFunkyRect
158( 158(
159 QPainter * p, 159 QPainter * p,
160 int x, 160 int x,
161 int y, 161 int y,
162 int w, 162 int w,
163 int h, 163 int h,
164 bool small 164 bool small
165) 165)
166{ 166{
167 p->translate(x, y); 167 p->translate(x, y);
168 168
169 if (small) 169 if (small)
170 { 170 {
171 p->drawLine( 2, 0, w - 3, 0 ); 171 p->drawLine( 2, 0, w - 3, 0 );
172 p->drawLine( w - 1, 2, w - 1, h - 3 ); 172 p->drawLine( w - 1, 2, w - 1, h - 3 );
173 p->drawLine( w - 3, h - 1, 2, h - 1 ); 173 p->drawLine( w - 3, h - 1, 2, h - 1 );
174 p->drawLine( 0, h - 3, 0, 2 ); 174 p->drawLine( 0, h - 3, 0, 2 );
175 175
176 // Use an array of points so that there's only one round-trip with the 176 // Use an array of points so that there's only one round-trip with the
177 // X server. 177 // X server.
178 178
179 QCOORD pointList[] = 179 QCOORD pointList[] =
180 { 180 {
181 1, 1, 181 1, 1,
182 w - 2, 1, 182 w - 2, 1,
183 w - 2, h - 2, 183 w - 2, h - 2,
184 1, h - 2 184 1, h - 2
185 }; 185 };
186 186
187 p->drawPoints(QPointArray(4, pointList)); 187 p->drawPoints(QPointArray(4, pointList));
188 } 188 }
189 else 189 else
190 { 190 {
191 p->drawLine( 3, 0, w - 4, 0 ); 191 p->drawLine( 3, 0, w - 4, 0 );
192 p->drawLine( w - 1, 3, w - 1, h - 4 ); 192 p->drawLine( w - 1, 3, w - 1, h - 4 );
193 p->drawLine( w - 4, h - 1, 3, h - 1 ); 193 p->drawLine( w - 4, h - 1, 3, h - 1 );
194 p->drawLine( 0, h - 4, 0, 3 ); 194 p->drawLine( 0, h - 4, 0, 3 );
195 195
196 QCOORD pointList[] = 196 QCOORD pointList[] =
197 { 197 {
198 1, 2, 198 1, 2,
199 2, 1, 199 2, 1,
200 w - 3, 1, 200 w - 3, 1,
201 w - 2, 2, 201 w - 2, 2,
202 w - 2, h - 3, 202 w - 2, h - 3,
203 w - 3, h - 2, 203 w - 3, h - 2,
204 2, h - 2, 204 2, h - 2,
205 1, h - 3 205 1, h - 3
206 }; 206 };
207 207
208 p->drawPoints(QPointArray(8, pointList)); 208 p->drawPoints(QPointArray(8, pointList));
209 } 209 }
210 210
211 p->translate(-x, -y); 211 p->translate(-x, -y);
212} 212}
213 213
214WebStyle::WebStyle() 214WebStyle::WebStyle()
215 : QWindowsStyle() 215 : QWindowsStyle()
216{ 216{
217 setButtonDefaultIndicatorWidth(1); 217 setButtonDefaultIndicatorWidth(1);
218 setScrollBarExtent(_scrollBarExtent, _scrollBarExtent); 218 setScrollBarExtent(_scrollBarExtent, _scrollBarExtent);
219 setButtonMargin( 3 ); 219 setButtonMargin( 3 );
220 setSliderThickness(_scrollBarExtent ); 220 setSliderThickness(_scrollBarExtent );
221} 221}
222 222
223WebStyle::~WebStyle() 223WebStyle::~WebStyle()
224{ 224{
225 // Empty. 225 // Empty.
226} 226}
227 227
228 void 228 void
229WebStyle::polish(QApplication *) 229WebStyle::polish(QApplication *)
230{ 230{
231 // Empty. 231 // Empty.
232} 232}
233 233
234 void 234 void
235WebStyle::polish(QPalette &) 235WebStyle::polish(QPalette &)
236{ 236{
237 // Empty. 237 // Empty.
238} 238}
239 239
240 void 240 void
241WebStyle::unPolish(QApplication *) 241WebStyle::unPolish(QApplication *)
242{ 242{
243 // Empty. 243 // Empty.
244} 244}
245 245
246 void 246 void
247WebStyle::polish(QWidget * w) 247WebStyle::polish(QWidget * w)
248{ 248{
249 if (w->inherits("QPushButton")) 249 if (w->inherits("QPushButton"))
250 w->installEventFilter(this); 250 w->installEventFilter(this);
251 251
252 else if (w->inherits("QGroupBox") || w->inherits("QFrame")) 252 else if (w->inherits("QGroupBox") || w->inherits("QFrame"))
253 { 253 {
254 QFrame * f(static_cast<QFrame *>(w)); 254 QFrame * f(static_cast<QFrame *>(w));
255 255
256 if (f->frameStyle() != QFrame::NoFrame) 256 if (f->frameStyle() != QFrame::NoFrame)
257 { 257 {
258 _currentFrame = f; 258 _currentFrame = f;
259 259
260 _savedFrameLineWidth = f->lineWidth(); 260 _savedFrameLineWidth = f->lineWidth();
261 _savedFrameMidLineWidth = f->midLineWidth(); 261 _savedFrameMidLineWidth = f->midLineWidth();
262 _savedFrameStyle = f->frameStyle(); 262 _savedFrameStyle = f->frameStyle();
263 263
264 if (f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine) 264 if (f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine)
265 { 265 {
266 f->setMidLineWidth(1); 266 f->setMidLineWidth(1);
267 f->setFrameStyle(f->frameShape() | QFrame::Plain); 267 f->setFrameStyle(f->frameShape() | QFrame::Plain);
268 } 268 }
269 else 269 else
270 { 270 {
271 f->setLineWidth(1); 271 f->setLineWidth(1);
272 f->setFrameStyle(QFrame::Box | QFrame::Plain); 272 f->setFrameStyle(QFrame::Box | QFrame::Plain);
273 } 273 }
274 } 274 }
275 } 275 }
276} 276}
277 277
278 void 278 void
279WebStyle::unPolish(QWidget * w) 279WebStyle::unPolish(QWidget * w)
280{ 280{
281 if (w->inherits("QPushButton")) 281 if (w->inherits("QPushButton"))
282 w->removeEventFilter(this); 282 w->removeEventFilter(this);
283 283
284 else if (w == _currentFrame) 284 else if (w == _currentFrame)
285 { 285 {
286 QFrame * f(static_cast<QFrame *>(w)); 286 QFrame * f(static_cast<QFrame *>(w));
287 287
288 f->setLineWidth(_savedFrameLineWidth); 288 f->setLineWidth(_savedFrameLineWidth);
289 f->setMidLineWidth(_savedFrameMidLineWidth); 289 f->setMidLineWidth(_savedFrameMidLineWidth);
290 f->setFrameStyle(_savedFrameStyle); 290 f->setFrameStyle(_savedFrameStyle);
291 } 291 }
292} 292}
293 293
294 bool 294 bool
295WebStyle::eventFilter(QObject * o, QEvent * e) 295WebStyle::eventFilter(QObject * o, QEvent * e)
296{ 296{
297 QPushButton * pb(static_cast<QPushButton *>(o)); 297 QPushButton * pb(static_cast<QPushButton *>(o));
298 298
299 if (e->type() == QEvent::Enter) 299 if (e->type() == QEvent::Enter)
300 { 300 {
301 _highlightedButton = pb; 301 _highlightedButton = pb;
302 pb->repaint(false); 302 pb->repaint(false);
303 } 303 }
304 else if (e->type() == QEvent::Leave) 304 else if (e->type() == QEvent::Leave)
305 { 305 {
306 _highlightedButton = 0; 306 _highlightedButton = 0;
307 pb->repaint(false); 307 pb->repaint(false);
308 } 308 }
309 309
310 return false; 310 return false;
311} 311}
312 312
313 void 313 void
314WebStyle::drawButton 314WebStyle::drawButton
315( 315(
316 QPainter * p, 316 QPainter * p,
317 int x, 317 int x,
318 int y, 318 int y,
319 int w, 319 int w,
320 int h, 320 int h,
321 const QColorGroup & g, 321 const QColorGroup & g,
322 bool sunken, 322 bool sunken,
323 const QBrush * fill 323 const QBrush * fill
324) 324)
325{ 325{
326 p->save(); 326 p->save();
327 327
328 if (sunken) 328 if (sunken)
329 p->setPen(contrastingForeground(g.light(), g.button())); 329 p->setPen(contrastingForeground(g.light(), g.button()));
330 else 330 else
331 p->setPen(contrastingForeground(g.mid(), g.button())); 331 p->setPen(contrastingForeground(g.mid(), g.button()));
332 332
333 p->setBrush(0 == fill ? NoBrush : *fill); 333 p->setBrush(0 == fill ? NoBrush : *fill);
334 334
335 drawFunkyRect(p, x, y, w, h, true); 335 drawFunkyRect(p, x, y, w, h, true);
336 336
337 p->restore(); 337 p->restore();
338} 338}
339 339
340 QRect 340 QRect
341WebStyle::buttonRect(int x, int y, int w, int h) 341WebStyle::buttonRect(int x, int y, int w, int h)
342{ 342{
343 return QRect(x + 2, y + 2, w - 4, h - 4); 343 return QRect(x + 2, y + 2, w - 4, h - 4);
344} 344}
345 345
346 void 346 void
347WebStyle::drawBevelButton 347WebStyle::drawBevelButton
348( 348(
349 QPainter * p, 349 QPainter * p,
350 int x, 350 int x,
351 int y, 351 int y,
352 int w, 352 int w,
353 int h, 353 int h,
354 const QColorGroup & g, 354 const QColorGroup & g,
355 bool sunken, 355 bool sunken,
356 const QBrush * fill 356 const QBrush * fill
357) 357)
358{ 358{
359 drawButton(p, x, y, w, h, g, sunken, fill); 359 drawButton(p, x, y, w, h, g, sunken, fill);
360} 360}
361 361
362 void 362 void
363WebStyle::drawPushButton(QPushButton * b, QPainter * p) 363WebStyle::drawPushButton(QPushButton * b, QPainter * p)
364{ 364{
365 // Note: painter is already translated for us. 365 // Note: painter is already translated for us.
366 366
367 bool sunken(b->isDown() || b->isOn()); 367 bool sunken(b->isDown() || b->isOn());
368 bool hl(_highlightedButton == b); 368 bool hl(_highlightedButton == b);
369 369
370 QColor bg(b->colorGroup().button()); 370 QColor bg(b->colorGroup().button());
371 371
372 p->save(); 372 p->save();
373 p->fillRect(b->rect(), b->colorGroup().brush(QColorGroup::Background)); 373 p->fillRect(b->rect(), b->colorGroup().brush(QColorGroup::Background));
374 374
375 if (b->isDefault()) 375 if (b->isDefault())
376 { 376 {
377 QColor c(hl ? b->colorGroup().highlight() : b->colorGroup().mid()); 377 QColor c(hl ? b->colorGroup().highlight() : b->colorGroup().mid());
378 378
379 p->setPen(contrastingForeground(c, bg)); 379 p->setPen(contrastingForeground(c, bg));
380 380
381 drawFunkyRect(p, 0, 0, b->width(), b->height(), false); 381 drawFunkyRect(p, 0, 0, b->width(), b->height(), false);
382 } 382 }
383 383
384 p->fillRect 384 p->fillRect
385 ( 385 (
386 4, 386 4,
387 4, 387 4,
388 b->width() - 8, 388 b->width() - 8,
389 b->height() - 8, 389 b->height() - 8,
390 b->colorGroup().brush(QColorGroup::Button) 390 b->colorGroup().brush(QColorGroup::Button)
391 ); 391 );
392 392
393 if (b->isEnabled()) 393 if (b->isEnabled())
394 { 394 {
395 if (sunken) 395 if (sunken)
396 { 396 {
397 p->setPen(contrastingForeground(b->colorGroup().light(), bg)); 397 p->setPen(contrastingForeground(b->colorGroup().light(), bg));
398 } 398 }
399 else 399 else
400 { 400 {
401 if (hl) 401 if (hl)
402 p->setPen(contrastingForeground(b->colorGroup().highlight(), bg)); 402 p->setPen(contrastingForeground(b->colorGroup().highlight(), bg));
403 else 403 else
404 p->setPen(contrastingForeground(b->colorGroup().mid(), bg)); 404 p->setPen(contrastingForeground(b->colorGroup().mid(), bg));
405 } 405 }
406 } 406 }
407 else 407 else
408 { 408 {
409 p->setPen(b->colorGroup().button()); 409 p->setPen(b->colorGroup().button());
410 } 410 }
411 411
412 drawFunkyRect(p, 3, 3, b->width() - 6, b->height() - 6, true); 412 drawFunkyRect(p, 3, 3, b->width() - 6, b->height() - 6, true);
413 413
414 p->restore(); 414 p->restore();
415} 415}
416 416
417 void 417 void
418WebStyle::drawPushButtonLabel(QPushButton * b, QPainter * p) 418WebStyle::drawPushButtonLabel(QPushButton * b, QPainter * p)
419{ 419{
420 // This is complicated stuff and we don't really want to mess with it. 420 // This is complicated stuff and we don't really want to mess with it.
421 421
422 QWindowsStyle::drawPushButtonLabel(b, p); 422 QWindowsStyle::drawPushButtonLabel(b, p);
423} 423}
424 424
425 void 425 void
426WebStyle::drawScrollBarControls 426WebStyle::drawScrollBarControls
427( 427(
428 QPainter * p, 428 QPainter * p,
429 const QScrollBar * sb, 429 const QScrollBar * sb,
430 int sliderStart, 430 int sliderStart,
431 uint controls, 431 uint controls,
432 uint activeControl 432 uint activeControl
433) 433)
434{ 434{
435 p->save(); 435 p->save();
436 436
437 int sliderMin, sliderMax, sliderLength, buttonDim; 437 int sliderMin, sliderMax, sliderLength, buttonDim;
438 438
439 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 439 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
440 440
441 QRect rSub, rAdd, rSubPage, rAddPage, rSlider; 441 QRect rSub, rAdd, rSubPage, rAddPage, rSlider;
442 442
443 scrollBarControlsMetrics 443 scrollBarControlsMetrics
444 ( 444 (
445 sb, 445 sb,
446 sliderStart, 446 sliderStart,
447 sliderMin, 447 sliderMin,
448 sliderMax, 448 sliderMax,
449 sliderLength, 449 sliderLength,
450 buttonDim, 450 buttonDim,
451 rSub, 451 rSub,
452 rAdd, 452 rAdd,
453 rSubPage, 453 rSubPage,
454 rAddPage, 454 rAddPage,
455 rSlider 455 rSlider
456 ); 456 );
457 457
458 QColorGroup g(sb->colorGroup()); 458 QColorGroup g(sb->colorGroup());
459 459
460 if (controls & AddLine && rAdd.isValid()) 460 if (controls & AddLine && rAdd.isValid())
461 { 461 {
462 bool active(activeControl & AddLine); 462 bool active(activeControl & AddLine);
463 463
464 QColor c(active ? g.highlight() : g.dark()); 464 QColor c(active ? g.highlight() : g.dark());
465 465
466 p->setPen(c); 466 p->setPen(c);
467 p->setBrush(g.button()); 467 p->setBrush(g.button());
468 p->drawRect(rAdd); 468 p->drawRect(rAdd);
469 469
470 Qt::ArrowType t = 470 Qt::ArrowType t =
471 sb->orientation() == Horizontal ? Qt::RightArrow : Qt::DownArrow; 471 sb->orientation() == Horizontal ? Qt::RightArrow : Qt::DownArrow;
472 472
473 // Is it me or is KStyle::drawArrow broken ? 473 // Is it me or is KStyle::drawArrow broken ?
474 474
475 drawArrow 475 drawArrow
476 ( 476 (
477 p, 477 p,
478 t, 478 t,
479 true, // FIXME - down ? 479 true, // FIXME - down ?
480 rAdd.x(), 480 rAdd.x(),
481 rAdd.y(), 481 rAdd.y(),
482 rAdd.width(), 482 rAdd.width(),
483 rAdd.height(), 483 rAdd.height(),
484 g, 484 g,
485 true // FIXME - enabled ? 485 true // FIXME - enabled ?
486 ); 486 );
487 } 487 }
488 488
489 if (controls & SubLine && rSub.isValid()) 489 if (controls & SubLine && rSub.isValid())
490 { 490 {
491 bool active(activeControl & SubLine); 491 bool active(activeControl & SubLine);
492 492
493 QColor c(active ? g.highlight() : g.dark()); 493 QColor c(active ? g.highlight() : g.dark());
494 494
495 p->setPen(c); 495 p->setPen(c);
496 p->setBrush(g.button()); 496 p->setBrush(g.button());
497 p->drawRect(rSub); 497 p->drawRect(rSub);
498 498
499 Qt::ArrowType t = 499 Qt::ArrowType t =
500 sb->orientation() == Horizontal ? Qt::LeftArrow : Qt::UpArrow; 500 sb->orientation() == Horizontal ? Qt::LeftArrow : Qt::UpArrow;
501 501
502 drawArrow 502 drawArrow
503 ( 503 (
504 p, 504 p,
505 t, 505 t,
506 true, // FIXME - down ? 506 true, // FIXME - down ?
507 rSub.x(), 507 rSub.x(),
508 rSub.y(), 508 rSub.y(),
509 rSub.width(), 509 rSub.width(),
510 rSub.height(), 510 rSub.height(),
511 g, 511 g,
512 true // FIXME - enabled ? 512 true // FIXME - enabled ?
513 ); 513 );
514 } 514 }
515 515
516 if (controls & SubPage && rSubPage.isValid()) 516 if (controls & SubPage && rSubPage.isValid())
517 { 517 {
518 p->setPen(g.mid()); 518 p->setPen(g.mid());
519 p->setBrush(g.base()); 519 p->setBrush(g.base());
520 p->drawRect(rSubPage); 520 p->drawRect(rSubPage);
521 } 521 }
522 522
523 if (controls & AddPage && rAddPage.isValid()) 523 if (controls & AddPage && rAddPage.isValid())
524 { 524 {
525 p->setPen(g.mid()); 525 p->setPen(g.mid());
526 p->setBrush(g.base()); 526 p->setBrush(g.base());
527 p->drawRect(rAddPage); 527 p->drawRect(rAddPage);
528 } 528 }
529 529
530 if (controls & Slider && rSlider.isValid()) 530 if (controls & Slider && rSlider.isValid())
531 { 531 {
532 p->setPen(activeControl & Slider ? g.highlight() : g.dark()); 532 p->setPen(activeControl & Slider ? g.highlight() : g.dark());
533 533
534 p->setBrush(g.button()); 534 p->setBrush(g.button());
535 p->drawRect(rSlider); 535 p->drawRect(rSlider);
536 536
537 p->setBrush(g.light()); 537 p->setBrush(g.light());
538 p->setPen(g.dark()); 538 p->setPen(g.dark());
539 539
540 if (sliderLength > _scrollBarExtent * 2) 540 if (sliderLength > _scrollBarExtent * 2)
541 { 541 {
542 int ellipseSize = 542 int ellipseSize =
543 Horizontal == sb->orientation() 543 Horizontal == sb->orientation()
544 ? 544 ?
545 rSlider.height() - 4 545 rSlider.height() - 4
546 : 546 :
547 rSlider.width() - 4 547 rSlider.width() - 4
548 ; 548 ;
549 549
550 QPoint center(rSlider.center()); 550 QPoint center(rSlider.center());
551 551
552 if (Horizontal == sb->orientation()) 552 if (Horizontal == sb->orientation())
553 { 553 {
554 p->drawEllipse 554 p->drawEllipse
555 ( 555 (
556 center.x() - ellipseSize / 2, rSlider.y() + 2, 556 center.x() - ellipseSize / 2, rSlider.y() + 2,
557 ellipseSize, ellipseSize 557 ellipseSize, ellipseSize
558 ); 558 );
559 } 559 }
560 else 560 else
561 { 561 {
562 p->drawEllipse 562 p->drawEllipse
563 ( 563 (
564 rSlider.x() + 2, center.y() - ellipseSize / 2, 564 rSlider.x() + 2, center.y() - ellipseSize / 2,
565 ellipseSize, ellipseSize 565 ellipseSize, ellipseSize
566 ); 566 );
567 } 567 }
568 } 568 }
569 } 569 }
570 570
571 p->restore(); 571 p->restore();
572} 572}
573 573
574 QStyle::ScrollControl 574 QStyle::ScrollControl
575WebStyle::scrollBarPointOver 575WebStyle::scrollBarPointOver
576( 576(
577 const QScrollBar * sb, 577 const QScrollBar * sb,
578 int sliderStart, 578 int sliderStart,
579 const QPoint & point 579 const QPoint & point
580) 580)
581{ 581{
582 if (!sb->rect().contains(point)) 582 if (!sb->rect().contains(point))
583 return NoScroll; 583 return NoScroll;
584 584
585 int sliderMin, sliderMax, sliderLength, buttonDim; 585 int sliderMin, sliderMax, sliderLength, buttonDim;
586 586
587 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 587 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
588 588
589 if (sb->orientation() == QScrollBar::Horizontal) 589 if (sb->orientation() == QScrollBar::Horizontal)
590 { 590 {
591 int x = point.x(); 591 int x = point.x();
592 592
593 if (x <= buttonDim) 593 if (x <= buttonDim)
594 return SubLine; 594 return SubLine;
595 595
596 else if (x <= buttonDim * 2) 596 else if (x <= buttonDim * 2)
597 return AddLine; 597 return AddLine;
598 598
599 else if (x < sliderStart) 599 else if (x < sliderStart)
600 return SubPage; 600 return SubPage;
601 601
602 else if (x < sliderStart+sliderLength) 602 else if (x < sliderStart+sliderLength)
603 return Slider; 603 return Slider;
604 604
605 return AddPage; 605 return AddPage;
606 } 606 }
607 else 607 else
608 { 608 {
609 int y = point.y(); 609 int y = point.y();
610 610
611 if (y < sliderStart) 611 if (y < sliderStart)
612 return SubPage; 612 return SubPage;
613 613
614 else if (y < sliderStart + sliderLength) 614 else if (y < sliderStart + sliderLength)
615 return Slider; 615 return Slider;
616 616
617 else if (y < sliderMax + sliderLength) 617 else if (y < sliderMax + sliderLength)
618 return AddPage; 618 return AddPage;
619 619
620 else if (y < sliderMax + sliderLength + buttonDim) 620 else if (y < sliderMax + sliderLength + buttonDim)
621 return SubLine; 621 return SubLine;
622 622
623 return AddLine; 623 return AddLine;
624 } 624 }
625} 625}
626 626
627 void 627 void
628WebStyle::scrollBarMetrics 628WebStyle::scrollBarMetrics
629( 629(
630 const QScrollBar * sb, 630 const QScrollBar * sb,
631 int & sliderMin, 631 int & sliderMin,
632 int & sliderMax, 632 int & sliderMax,
633 int & sliderLength, 633 int & sliderLength,
634 int & buttonDim 634 int & buttonDim
635) 635)
636{ 636{
637// return QWindowsStyle::scrollBarMetrics(sb, sliderMin, sliderMax, 637// return QWindowsStyle::scrollBarMetrics(sb, sliderMin, sliderMax,
638// sliderLength, buttonDim ); 638// sliderLength, buttonDim );
639 int maxlen; 639 int maxlen;
640 640
641 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 641 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
642 642
643 int len = (horizontal) ? sb->width() : sb->height(); 643 int len = (horizontal) ? sb->width() : sb->height();
644 644
645 int extent = (horizontal) ? sb->height() : sb->width(); 645 int extent = (horizontal) ? sb->height() : sb->width();
646 646
647 if (len > (extent - 1) * 2) 647 if (len > (extent - 1) * 2)
648 buttonDim = extent; 648 buttonDim = extent;
649 else 649 else
650 buttonDim = len / 2 - 1; 650 buttonDim = len / 2 - 1;
651 651
652 if (horizontal) 652 if (horizontal)
653 sliderMin = buttonDim * 2; 653 sliderMin = buttonDim * 2;
654 else 654 else
655 sliderMin = 1; 655 sliderMin = 1;
656 656
657 maxlen = len - buttonDim * 2 - 1; 657 maxlen = len - buttonDim * 2 - 1;
658 658
659 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) ); 659 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) );
660 660
661 sliderLength = 661 sliderLength =
662 (sb->pageStep() * maxlen) / div; 662 (sb->pageStep() * maxlen) / div;
663 663
664 if (sliderLength < _scrollBarExtent) 664 if (sliderLength < _scrollBarExtent)
665 sliderLength = _scrollBarExtent; 665 sliderLength = _scrollBarExtent;
666 666
667 if (sliderLength > maxlen) 667 if (sliderLength > maxlen)
668 sliderLength = maxlen; 668 sliderLength = maxlen;
669 669
670 sliderMax = sliderMin + maxlen - sliderLength; 670 sliderMax = sliderMin + maxlen - sliderLength;
671} 671}
672 672
673 QSize 673 QSize
674WebStyle::indicatorSize() const 674WebStyle::indicatorSize() const
675{ 675{
676 return QSize(_indicatorSize, _indicatorSize); 676 return QSize(_indicatorSize, _indicatorSize);
677} 677}
678 678
679 void 679 void
680WebStyle::drawIndicator 680WebStyle::drawIndicator
681( 681(
682 QPainter * p, 682 QPainter * p,
683 int x, 683 int x,
684 int y, 684 int y,
685 int w, 685 int w,
686 int h, 686 int h,
687 const QColorGroup & g, 687 const QColorGroup & g,
688 int state, 688 int state,
689 bool down, 689 bool down,
690 bool enabled 690 bool enabled
691) 691)
692{ 692{
693 p->save(); 693 p->save();
694 694
695 p->fillRect(x, y, w, h, g.background()); 695 p->fillRect(x, y, w, h, g.background());
696 696
697 if (enabled) 697 if (enabled)
698 { 698 {
699 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background())); 699 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background()));
700 } 700 }
701 else 701 else
702 { 702 {
703 g.mid(); 703 g.mid();
704 } 704 }
705 705
706 p->drawRect(x, y, w, h); 706 p->drawRect(x, y, w, h);
707 707
708 if (state != QButton::Off) 708 if (state != QButton::Off)
709 { 709 {
710 p->fillRect(x + 2, y + 2, w - 4, h - 4, enabled ? g.highlight() : g.mid()); 710 p->fillRect(x + 2, y + 2, w - 4, h - 4, enabled ? g.highlight() : g.mid());
711 711
712 if (state == QButton::NoChange) 712 if (state == QButton::NoChange)
713 { 713 {
714 p->fillRect(x + 4, y + 4, w - 8, h - 8, g.background()); 714 p->fillRect(x + 4, y + 4, w - 8, h - 8, g.background());
715 } 715 }
716 } 716 }
717 717
718 p->restore(); 718 p->restore();
719} 719}
720 720
721 QSize 721 QSize
722WebStyle::exclusiveIndicatorSize() const 722WebStyle::exclusiveIndicatorSize() const
723{ 723{
724 return QSize(_indicatorSize, _indicatorSize); 724 return QSize(_indicatorSize+2, _indicatorSize+2);
725} 725}
726 726
727 void 727 void
728WebStyle::drawExclusiveIndicator 728WebStyle::drawExclusiveIndicator
729( 729(
730 QPainter * p, 730 QPainter * p,
731 int x, 731 int x,
732 int y, 732 int y,
733 int w, 733 int w,
734 int h, 734 int h,
735 const QColorGroup & g, 735 const QColorGroup & g,
736 bool on, 736 bool on,
737 bool down, 737 bool down,
738 bool enabled 738 bool enabled
739) 739)
740{ 740{
741 p->save(); 741 p->save();
742 742
743 p->fillRect(x, y, w, h, g.background()); 743 p->fillRect(x, y, w, h, g.background());
744 744
745 if (enabled) 745 if (enabled)
746 { 746 {
747 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background())); 747 p->setPen(down ? g.highlight() : contrastingForeground(g.dark(), g.background()));
748 } 748 }
749 else 749 else
750 { 750 {
751 p->setPen(g.mid()); 751 p->setPen(g.mid());
752 } 752 }
753 753
754 p->setBrush(g.brush(QColorGroup::Background)); 754 p->setBrush(g.brush(QColorGroup::Background));
755 755
756 // Avoid misshapen ellipses. Qt or X bug ? Who knows... 756 // Avoid misshapen ellipses. Qt or X bug ? Who knows...
757 757
758 if (0 == w % 2) 758 if (0 == w % 2)
759 --w; 759 --w;
760 760
761 if (0 == h % 2) 761 if (0 == h % 2)
762 --h; 762 --h;
763 763
764 p->drawEllipse(x, y, w, h); 764 p->drawEllipse(x, y, w, h);
765 765
766 if (on) 766 if (on)
767 { 767 {
768 p->setPen(enabled ? g.highlight() : g.mid()); 768 p->setPen(enabled ? g.highlight() : g.mid());
769 p->setBrush(enabled ? g.highlight() : g.mid()); 769 p->setBrush(enabled ? g.highlight() : g.mid());
770 p->drawEllipse(x + 3, y + 3, w - 6, h - 6); 770 p->drawEllipse(x + 3, y + 3, w - 6, h - 6);
771 } 771 }
772 772
773 p->restore(); 773 p->restore();
774} 774}
775 775
776 void 776 void
777WebStyle::drawIndicatorMask 777WebStyle::drawIndicatorMask
778( 778(
779 QPainter * p, 779 QPainter * p,
780 int x, 780 int x,
781 int y, 781 int y,
782 int w, 782 int w,
783 int h, 783 int h,
784 int /* state */ 784 int /* state */
785) 785)
786{ 786{
787 p->fillRect(x, y, w, h, Qt::color1); 787 p->fillRect(x, y, w, h, Qt::color1);
788} 788}
789 789
790 void 790 void
791WebStyle::drawExclusiveIndicatorMask 791WebStyle::drawExclusiveIndicatorMask
792( 792(
793 QPainter * p, 793 QPainter * p,
794 int x, 794 int x,
795 int y, 795 int y,
796 int w, 796 int w,
797 int h, 797 int h,
798 bool /* on */ 798 bool /* on */
799) 799)
800{ 800{
801 if (0 == w % 2) 801 if (0 == w % 2)
802 --w; 802 --w;
803 803
804 if (0 == h % 2) 804 if (0 == h % 2)
805 --h; 805 --h;
806 806
807 p->setPen(Qt::color1); 807 p->setPen(Qt::color1);
808 p->setBrush(Qt::color1); 808 p->setBrush(Qt::color1);
809 p->drawEllipse(x, y, w, h); 809 p->drawEllipse(x, y, w, h);
810} 810}
811 811
812 void 812 void
813WebStyle::drawComboButton 813WebStyle::drawComboButton
814( 814(
815 QPainter * p, 815 QPainter * p,
816 int x, 816 int x,
817 int y, 817 int y,
818 int w, 818 int w,
819 int h, 819 int h,
820 const QColorGroup & g, 820 const QColorGroup & g,
821 bool sunken, 821 bool sunken,
822 bool editable, 822 bool editable,
823 bool enabled, 823 bool enabled,
824 const QBrush * fill 824 const QBrush * fill
825) 825)
826{ 826{
827 p->save(); 827 p->save();
828 828
829 p->setPen(NoPen); 829 p->setPen(NoPen);
830 p->setBrush(0 == fill ? g.brush(QColorGroup::Background) : *fill); 830 p->setBrush(0 == fill ? g.brush(QColorGroup::Background) : *fill);
831 p->drawRect(x, y, w, h); 831 p->drawRect(x, y, w, h);
832 832
833 if (enabled) 833 if (enabled)
834 { 834 {
835 if (sunken) 835 if (sunken)
836 p->setPen(contrastingForeground(g.highlight(), g.background())); 836 p->setPen(contrastingForeground(g.highlight(), g.background()));
837 else 837 else
838 p->setPen(contrastingForeground(g.mid(), g.background())); 838 p->setPen(contrastingForeground(g.mid(), g.background()));
839 } 839 }
840 else 840 else
841 { 841 {
842 p->setPen(contrastingForeground(g.mid(), g.background())); 842 p->setPen(contrastingForeground(g.mid(), g.background()));
843 } 843 }
844 844
845 drawFunkyRect(p, x, y, w, h, true); 845 drawFunkyRect(p, x, y, w, h, true);
846 846
847 p->drawPoint(w - 10, h - 6); 847 p->drawPoint(w - 10, h - 6);
848 p->drawPoint(w - 9, h - 6); 848 p->drawPoint(w - 9, h - 6);
849 p->drawPoint(w - 8, h - 6); 849 p->drawPoint(w - 8, h - 6);
850 p->drawPoint(w - 7, h - 6); 850 p->drawPoint(w - 7, h - 6);
851 p->drawPoint(w - 6, h - 6); 851 p->drawPoint(w - 6, h - 6);
852 852
853 p->drawPoint(w - 9, h - 7); 853 p->drawPoint(w - 9, h - 7);
854 p->drawPoint(w - 8, h - 7); 854 p->drawPoint(w - 8, h - 7);
855 p->drawPoint(w - 7, h - 7); 855 p->drawPoint(w - 7, h - 7);
856 p->drawPoint(w - 6, h - 7); 856 p->drawPoint(w - 6, h - 7);
857 857
858 p->drawPoint(w - 8, h - 8); 858 p->drawPoint(w - 8, h - 8);
859 p->drawPoint(w - 7, h - 8); 859 p->drawPoint(w - 7, h - 8);
860 p->drawPoint(w - 6, h - 8); 860 p->drawPoint(w - 6, h - 8);
861 861
862 p->drawPoint(w - 7, h - 9); 862 p->drawPoint(w - 7, h - 9);
863 p->drawPoint(w - 6, h - 9); 863 p->drawPoint(w - 6, h - 9);
864 864
865 p->drawPoint(w - 6, h - 10); 865 p->drawPoint(w - 6, h - 10);
866 866
867 if (editable) 867 if (editable)
868 p->fillRect(comboButtonFocusRect(x, y, w, h), Qt::red); 868 p->fillRect(comboButtonFocusRect(x, y, w, h), Qt::red);
869 869
870 p->restore(); 870 p->restore();
871} 871}
872 872
873 QRect 873 QRect
874WebStyle::comboButtonRect(int x, int y, int w, int h) 874WebStyle::comboButtonRect(int x, int y, int w, int h)
875{ 875{
876 return QRect(x + 2, y + 2, w - 20, h - 4); 876 return QRect(x + 2, y + 2, w - 20, h - 4);
877} 877}
878 878
879 QRect 879 QRect
880WebStyle::comboButtonFocusRect(int x, int y, int w, int h) 880WebStyle::comboButtonFocusRect(int x, int y, int w, int h)
881{ 881{
882 return QRect(x + 2, y + 2, w - 20, h - 4); 882 return QRect(x + 2, y + 2, w - 20, h - 4);
883} 883}
884 884
885 int 885 int
886WebStyle::sliderLength() const 886WebStyle::sliderLength() const
887{ 887{
888 return 13; 888 return 13;
889} 889}
890 890
891 void 891 void
892WebStyle::drawSliderGroove 892WebStyle::drawSliderGroove
893( 893(
894 QPainter * p, 894 QPainter * p,
895 int x, 895 int x,
896 int y, 896 int y,
897 int w, 897 int w,
898 int h, 898 int h,
899 const QColorGroup & g, 899 const QColorGroup & g,
900 QCOORD /* c */, 900 QCOORD /* c */,
901 Orientation o 901 Orientation o
902) 902)
903{ 903{
904 p->save(); 904 p->save();
905 905
906 p->setPen(QPen(g.dark(), 0, Qt::DotLine)); 906 p->setPen(QPen(g.dark(), 0, Qt::DotLine));
907 907
908 if( o == Qt::Horizontal ) 908 if( o == Qt::Horizontal )
909 p->drawLine(x, y + h / 2, w, y + h / 2); 909 p->drawLine(x, y + h / 2, w, y + h / 2);
910 else 910 else
911 if( o == Qt::Vertical ) 911 if( o == Qt::Vertical )
912 p->drawLine(x + w / 2, y, x + w / 2, h); 912 p->drawLine(x + w / 2, y, x + w / 2, h);
913 913
914 p->restore(); 914 p->restore();
915} 915}
916 916
917 void 917 void
918WebStyle::drawArrow 918WebStyle::drawArrow
919( 919(
920 QPainter * p, 920 QPainter * p,
921 Qt::ArrowType type, 921 Qt::ArrowType type,
922 bool down, 922 bool down,
923 int x, 923 int x,
924 int y, 924 int y,
925 int w, 925 int w,
926 int h, 926 int h,
927 const QColorGroup & g, 927 const QColorGroup & g,
928 bool enabled, 928 bool enabled,
929 const QBrush * fill 929 const QBrush * fill
930) 930)
931{ 931{
932 QWindowsStyle::drawArrow(p, type, down, x, y, w, h, g, enabled, fill); 932 QWindowsStyle::drawArrow(p, type, down, x, y, w, h, g, enabled, fill);
933} 933}
934 934
935 void 935 void
936WebStyle::drawSlider 936WebStyle::drawSlider
937( 937(
938 QPainter * p, 938 QPainter * p,
939 int x, 939 int x,
940 int y, 940 int y,
941 int w, 941 int w,
942 int h, 942 int h,
943 const QColorGroup & g, 943 const QColorGroup & g,
944 Orientation o, 944 Orientation o,
945 bool /* tickAbove */, 945 bool /* tickAbove */,
946 bool /* tickBelow */ 946 bool /* tickBelow */
947) 947)
948{ 948{
949 p->save(); 949 p->save();
950 950
951 p->fillRect(x + 1, y + 1, w - 2, h - 2, g.background()); 951 p->fillRect(x + 1, y + 1, w - 2, h - 2, g.background());
952 p->setPen(g.dark()); 952 p->setPen(g.dark());
953 p->setBrush(g.light()); 953 p->setBrush(g.light());
954 954
955 int sl = sliderLength(); 955 int sl = sliderLength();
956 956
957 if( o == Qt::Horizontal ) 957 if( o == Qt::Horizontal )
958 p->drawEllipse(x, y + h / 2 - sl / 2, sl, sl); 958 p->drawEllipse(x, y + h / 2 - sl / 2, sl, sl);
959 else 959 else
960 if( o == Qt::Vertical ) 960 if( o == Qt::Vertical )
961 p->drawEllipse(x + w / 2 - sl / 2, y, sl, sl); 961 p->drawEllipse(x + w / 2 - sl / 2, y, sl, sl);
962 962
963 p->restore(); 963 p->restore();
964} 964}
965 965
966 void 966 void
967WebStyle::drawPopupMenuItem 967WebStyle::drawPopupMenuItem
968( 968(
969 QPainter * p, 969 QPainter * p,
970 bool checkable, 970 bool checkable,
971 int maxpmw, 971 int maxpmw,
972 int tab, 972 int tab,
973 QMenuItem * mi, 973 QMenuItem * mi,
974 const QPalette & pal, 974 const QPalette & pal,
975 bool act, 975 bool act,
976 bool enabled, 976 bool enabled,
977 int x, 977 int x,
978 int y, 978 int y,
979 int w, 979 int w,
980 int h 980 int h
981) 981)
982{ 982{
983 // TODO 983 // TODO
984 QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h); 984 QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
985} 985}
986 986
987 void 987 void
988WebStyle::drawFocusRect 988WebStyle::drawFocusRect
989( 989(
990 QPainter * p, 990 QPainter * p,
991 const QRect & r, 991 const QRect & r,
992 const QColorGroup & g, 992 const QColorGroup & g,
993 const QColor * pen, 993 const QColor * pen,
994 bool atBorder 994 bool atBorder
995) 995)
996{ 996{
997 p->save(); 997 p->save();
998 998
999 if (0 != pen) 999 if (0 != pen)
1000 p->setPen(0 == pen ? g.foreground() : *pen); 1000 p->setPen(0 == pen ? g.foreground() : *pen);
1001 p->setBrush(NoBrush); 1001 p->setBrush(NoBrush);
1002 1002
1003 if (atBorder) 1003 if (atBorder)
1004 { 1004 {
1005 p->drawRect(QRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2)); 1005 p->drawRect(QRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2));
1006 } 1006 }
1007 else 1007 else
1008 { 1008 {
1009 p->drawRect(r); 1009 p->drawRect(r);
1010 } 1010 }
1011 1011
1012 p->restore(); 1012 p->restore();
1013} 1013}
1014 1014
1015 void 1015 void
1016WebStyle::drawPanel 1016WebStyle::drawPanel
1017( 1017(
1018 QPainter * p, 1018 QPainter * p,
1019 int x, 1019 int x,
1020 int y, 1020 int y,
1021 int w, 1021 int w,
1022 int h, 1022 int h,
1023 const QColorGroup & g, 1023 const QColorGroup & g,
1024 bool /* sunken */, 1024 bool /* sunken */,
1025 int /* lineWidth */, 1025 int /* lineWidth */,
1026 const QBrush * fill 1026 const QBrush * fill
1027) 1027)
1028{ 1028{
1029 p->save(); 1029 p->save();
1030 1030
1031 p->setPen(g.dark()); 1031 p->setPen(g.dark());
1032 1032
1033 p->setBrush(0 == fill ? NoBrush : *fill); 1033 p->setBrush(0 == fill ? NoBrush : *fill);
1034 1034
1035 p->drawRect(x, y, w, h); 1035 p->drawRect(x, y, w, h);
1036 1036
1037 p->restore(); 1037 p->restore();
1038} 1038}
1039 1039
1040 void 1040 void
1041WebStyle::drawPopupPanel 1041WebStyle::drawPopupPanel
1042( 1042(
1043 QPainter * p, 1043 QPainter * p,
1044 int x, 1044 int x,
1045 int y, 1045 int y,
1046 int w, 1046 int w,
1047 int h, 1047 int h,
1048 const QColorGroup & g, 1048 const QColorGroup & g,
1049 int /* lineWidth */, 1049 int /* lineWidth */,
1050 const QBrush * fill 1050 const QBrush * fill
1051) 1051)
1052{ 1052{
1053 p->save(); 1053 p->save();
1054 1054
1055 p->setPen(g.dark()); 1055 p->setPen(g.dark());
1056 1056
1057 p->setBrush(0 == fill ? NoBrush : *fill); 1057 p->setBrush(0 == fill ? NoBrush : *fill);
1058 1058
1059 p->drawRect(x, y, w, h); 1059 p->drawRect(x, y, w, h);
1060 1060
1061 p->restore(); 1061 p->restore();
1062} 1062}
1063 1063
1064 void 1064 void
1065WebStyle::drawSeparator 1065WebStyle::drawSeparator
1066( 1066(
1067 QPainter * p, 1067 QPainter * p,
1068 int x, 1068 int x,
1069 int y, 1069 int y,
1070 int w, 1070 int w,
1071 int h, 1071 int h,
1072 const QColorGroup & g, 1072 const QColorGroup & g,
1073 bool /* sunken */, 1073 bool /* sunken */,
1074 int /* lineWidth */, 1074 int /* lineWidth */,
1075 int /* midLineWidth */ 1075 int /* midLineWidth */
1076) 1076)
1077{ 1077{
1078 p->save(); 1078 p->save();
1079 1079
1080 p->setPen(g.dark()); 1080 p->setPen(g.dark());
1081 1081
1082 if (w > h) 1082 if (w > h)
1083 { 1083 {
1084 p->drawLine(x, y + h / 2, x + w, y + h / 2); 1084 p->drawLine(x, y + h / 2, x + w, y + h / 2);
1085 } 1085 }
1086 else 1086 else
1087 { 1087 {
1088 p->drawLine(x + w / 2, y, x + w / 2, y + h); 1088 p->drawLine(x + w / 2, y, x + w / 2, y + h);
1089 } 1089 }
1090 1090
1091 p->restore(); 1091 p->restore();
1092} 1092}
1093 1093
1094 void 1094 void
1095WebStyle::drawTab 1095WebStyle::drawTab
1096( 1096(
1097 QPainter * p, 1097 QPainter * p,
1098 const QTabBar * tabBar, 1098 const QTabBar * tabBar,
1099 QTab * tab, 1099 QTab * tab,
1100 bool selected 1100 bool selected
1101) 1101)
1102{ 1102{
1103 QRect r(tab->rect()); 1103 QRect r(tab->rect());
1104 1104
1105 QColorGroup g(tabBar->colorGroup()); 1105 QColorGroup g(tabBar->colorGroup());
1106 1106
1107 p->save(); 1107 p->save();
1108 1108
1109 p->setPen(selected ? g.dark() : g.mid()); 1109 p->setPen(selected ? g.dark() : g.mid());
1110 p->fillRect(r, g.brush(QColorGroup::Background)); 1110 p->fillRect(r, g.brush(QColorGroup::Background));
1111 1111
1112 switch (tabBar->shape()) 1112 switch (tabBar->shape())
1113 { 1113 {
1114 case QTabBar::RoundedAbove: 1114 case QTabBar::RoundedAbove:
1115 case QTabBar::TriangularAbove: 1115 case QTabBar::TriangularAbove:
1116 p->drawLine(r.left(), r.top(), r.left(), r.bottom()); 1116 p->drawLine(r.left(), r.top(), r.left(), r.bottom());
1117 p->drawLine(r.left(), r.top(), r.right(), r.top()); 1117 p->drawLine(r.left(), r.top(), r.right(), r.top());
1118 p->drawLine(r.right(), r.top(), r.right(), r.bottom()); 1118 p->drawLine(r.right(), r.top(), r.right(), r.bottom());
1119 if (!selected) 1119 if (!selected)
1120 { 1120 {
1121 p->setPen(g.dark()); 1121 p->setPen(g.dark());
1122 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); 1122 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
1123 } 1123 }
1124 break; 1124 break;
1125 case QTabBar::RoundedBelow: 1125 case QTabBar::RoundedBelow:
1126 case QTabBar::TriangularBelow: 1126 case QTabBar::TriangularBelow:
1127 if (!selected) 1127 if (!selected)
1128 { 1128 {
1129 p->setPen(g.dark()); 1129 p->setPen(g.dark());
1130 p->drawLine(r.left(), r.top(), r.right(), r.top()); 1130 p->drawLine(r.left(), r.top(), r.right(), r.top());
1131 } 1131 }
1132 p->drawLine(r.left(), r.top(), r.left(), r.bottom()); 1132 p->drawLine(r.left(), r.top(), r.left(), r.bottom());
1133 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom()); 1133 p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
1134 p->drawLine(r.right(), r.top(), r.right(), r.bottom()); 1134 p->drawLine(r.right(), r.top(), r.right(), r.bottom());
1135 break; 1135 break;
1136 } 1136 }
1137 1137
1138 p->restore(); 1138 p->restore();
1139} 1139}
1140 1140
1141 void 1141 void
1142WebStyle::drawTabMask 1142WebStyle::drawTabMask
1143( 1143(
1144 QPainter * p, 1144 QPainter * p,
1145 const QTabBar *, 1145 const QTabBar *,
1146 QTab * tab, 1146 QTab * tab,
1147 bool 1147 bool
1148) 1148)
1149{ 1149{
1150 p->fillRect(tab->rect(), Qt::color1); 1150 p->fillRect(tab->rect(), Qt::color1);
1151} 1151}
1152 1152
1153 1153
1154 int 1154 int
1155WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm) 1155WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm)
1156{ 1156{
1157 if (i->isSeparator()) 1157 if (i->isSeparator())
1158 return 1; 1158 return 1;
1159 1159
1160 int h = 0; 1160 int h = 0;
1161 1161
1162 if (0 != i->pixmap()) 1162 if (0 != i->pixmap())
1163 { 1163 {
1164 h = i->pixmap()->height(); 1164 h = i->pixmap()->height();
1165 } 1165 }
1166 1166
1167 if (0 != i->iconSet()) 1167 if (0 != i->iconSet())
1168 { 1168 {
1169 h = QMAX 1169 h = QMAX
1170 ( 1170 (
1171 i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(), 1171 i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(),
1172 h 1172 h
1173 ); 1173 );
1174 } 1174 }
1175 1175
1176 h = QMAX(fm.height() + 4, h); 1176 h = QMAX(fm.height() + 4, h);
1177 1177
1178 h = QMAX(18, h); 1178 h = QMAX(18, h);
1179 1179
1180 return h; 1180 return h;
1181 1181
1182} 1182}
1183 1183