add more spacing
[personal-kdebase.git] / runtime / kstyles / highcolor / highcolor.cpp
blobe88c14ef470e36604e285bdca01747d136a249a3
1 /*
2 * KDE3 HighColor Style (version 1.0)
3 * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
4 * (C) 2001-2002 Fredrik Höglund <fredrik@kde.org>
6 * Drawing routines adapted from the KDE2 HCStyle,
7 * Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
8 * (C) 2000 Dirk Mueller <mueller@kde.org>
9 * (C) 2001 Martijn Klingens <klingens@kde.org>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License version 2 as published by the Free Software Foundation.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
26 #include "highcolor.h"
27 #include "highcolor.moc"
29 #include <QtGui/qdrawutil.h>
30 #include <QtGui/QPainter>
31 #include <Qt3Support/Q3PointArray>
32 #include <QtGui/QStylePlugin>
34 #include <QtGui/QComboBox>
35 #include <Qt3Support/Q3Header>
36 #include <QtGui/QMenuBar>
37 #include <QtGui/QPushButton>
38 #include <QtGui/QScrollBar>
39 #include <QtGui/QSlider>
40 #include <QtGui/QTabBar>
41 #include <QtGui/QToolButton>
42 #include <Qt3Support/Q3ToolBar>
43 #include <QtGui/QMenu>
44 #include <Qt3Support/Q3IntDict>
46 #include <kdrawutil.h>
47 #include <kpixmapeffect.h>
49 #include "bitmaps.h"
52 // -- Style Plugin Interface -------------------------
53 class HighColorStylePlugin : public QStylePlugin
55 public:
56 HighColorStylePlugin() {}
57 ~HighColorStylePlugin() {}
59 QStringList keys() const
61 return QStringList() << "HighColor" << "Default" << "B3";
64 QStyle* create( const QString& key )
66 if ( key == "highcolor" )
67 return new HighColorStyle( HighColorStyle::HighColor );
69 else if ( key == "default" )
70 return new HighColorStyle( HighColorStyle::Default );
72 else if ( key == "b3" )
73 return new HighColorStyle( HighColorStyle::B3 );
75 return 0;
79 Q_EXPORT_PLUGIN( HighColorStylePlugin )
80 // ---------------------------------------------------
83 static QBitmap lightBmp;
84 static QBitmap grayBmp;
85 static QBitmap dgrayBmp;
86 static QBitmap centerBmp;
87 static QBitmap maskBmp;
88 static QBitmap xBmp;
89 static Q3IntDict<GradientSet> gDict;
91 static const int itemFrame = 1;
92 static const int itemHMargin = 3;
93 static const int itemVMargin = 0;
94 static const int arrowHMargin = 6;
95 static const int rightBorder = 12;
96 static const char* kdeToolbarWidget = "kde toolbar widget";
98 // ---------------------------------------------------------------------------
100 GradientSet::GradientSet(const QColor &baseColor)
102 c = baseColor;
103 for(int i=0; i < GradientCount; i++)
104 gradients[i] = NULL;
108 GradientSet::~GradientSet()
110 for(int i=0; i < GradientCount; i++)
111 if(gradients[i])
112 delete gradients[i];
116 KPixmap* GradientSet::gradient(GradientType type)
118 if (gradients[type])
119 return gradients[type];
121 switch(type)
123 case VSmall: {
124 gradients[VSmall] = new KPixmap;
125 gradients[VSmall]->resize(18, 24);
126 KPixmapEffect::gradient(*gradients[VSmall], c.light(110), c.dark(110),
127 KPixmapEffect::VerticalGradient);
128 break;
131 case VMed: {
132 gradients[VMed] = new KPixmap;
133 gradients[VMed]->resize(18, 34);
134 KPixmapEffect::gradient(*gradients[VMed], c.light(110), c.dark(110),
135 KPixmapEffect::VerticalGradient);
136 break;
139 case VLarge: {
140 gradients[VLarge] = new KPixmap;
141 gradients[VLarge]->resize(18, 64);
142 KPixmapEffect::gradient(*gradients[VLarge], c.light(110), c.dark(110),
143 KPixmapEffect::VerticalGradient);
144 break;
147 case HMed: {
148 gradients[HMed] = new KPixmap;
149 gradients[HMed]->resize(34, 18);
150 KPixmapEffect::gradient(*gradients[HMed], c.light(110), c.dark(110),
151 KPixmapEffect::HorizontalGradient);
152 break;
155 case HLarge: {
156 gradients[HLarge] = new KPixmap;
157 gradients[HLarge]->resize(52, 18);
158 KPixmapEffect::gradient(*gradients[HLarge], c.light(110), c.dark(110),
159 KPixmapEffect::HorizontalGradient);
160 break;
163 default:
164 break;
166 return(gradients[type]);
171 // ---------------------------------------------------------------------------
173 HighColorStyle::HighColorStyle( StyleType styleType )
174 : KStyle( AllowMenuTransparency | FilledFrameWorkaround, ThreeButtonScrollBar )
176 type = styleType;
177 highcolor = (type == HighColor && QPixmap::defaultDepth() > 8);
178 gDict.setAutoDelete(true);
179 hoverWidget = 0L;
180 selectionBackground = false;
184 HighColorStyle::~HighColorStyle()
189 void HighColorStyle::polish(QWidget* widget)
191 // Put in order of highest occurrence to maximise hit rate
192 if (widget->inherits("QPushButton")) {
193 widget->installEventFilter(this);
194 } else if (widget->inherits("QMenuBar") || widget->inherits("QPopupMenu")) {
195 widget->setBackgroundMode(Qt::NoBackground);
196 } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
197 widget->installEventFilter(this);
198 } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
199 widget->setBackgroundMode( Qt::NoBackground ); // We paint the whole background.
200 widget->installEventFilter(this);
201 } else if (widget->inherits("QToolBoxButton")) {
202 QFont font = widget->font();
203 font.setBold(true);
204 widget->setFont(font);
207 KStyle::polish( widget );
211 void HighColorStyle::unPolish(QWidget* widget)
213 if (widget->inherits("QPushButton")) {
214 widget->removeEventFilter(this);
216 else if (widget->inherits("QMenuBar") || widget->inherits("QPopupMenu")) {
217 widget->setBackgroundMode(Qt::PaletteBackground);
218 } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
219 widget->removeEventFilter(this);
220 } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
221 widget->removeEventFilter(this);
222 widget->setBackgroundMode( Qt::PaletteBackground );
225 KStyle::unPolish( widget );
229 /* reimp. */
230 void HighColorStyle::renderMenuBlendPixmap( KPixmap& pix, const QColorGroup &cg,
231 const QMenu* /* popup */ ) const
233 QColor col = cg.button();
235 #ifdef Q_WS_X11 // Only draw menu gradients on TrueColor, X11 visuals
236 if ( QPaintDevice::x11AppDepth() >= 24 )
237 KPixmapEffect::gradient( pix, col.light(120), col.dark(115),
238 KPixmapEffect::HorizontalGradient );
239 else
240 #endif
241 pix.fill( col );
245 // This function draws primitive elements as well as their masks.
246 void HighColorStyle::drawPrimitive( PrimitiveElement pe,
247 QPainter *p,
248 const QRect &r,
249 const QColorGroup &cg,
250 SFlags flags,
251 const QStyleOption& opt ) const
253 bool down = flags & Style_Down;
254 bool on = flags & Style_On;
256 switch(pe)
258 // BUTTONS
259 // -------------------------------------------------------------------
260 case PE_ButtonDefault: {
261 if ( type != HighColor ) {
262 int x1, y1, x2, y2;
263 r.getCoords( &x1, &y1, &x2, &y2 );
265 // Button default indicator
266 p->setPen( cg.shadow() );
267 p->drawLine( x1+1, y1, x2-1, y1 );
268 p->drawLine( x1, y1+1, x1, y2-1 );
269 p->drawLine( x1+1, y2, x2-1, y2 );
270 p->drawLine( x2, y1+1, x2, y2-1 );
272 break;
275 case PE_ButtonDropDown:
276 case PE_ButtonTool: {
277 bool sunken = on || down;
278 int x,y,w,h;
279 r.rect(&x, &y, &w, &h);
280 int x2 = x+w-1;
281 int y2 = y+h-1;
282 QPen oldPen = p->pen();
284 // Outer frame (round style)
285 p->setPen(cg.shadow());
286 p->drawLine(x+1,y,x2-1,y);
287 p->drawLine(x,y+1,x,y2-1);
288 p->drawLine(x+1,y2,x2-1,y2);
289 p->drawLine(x2,y+1,x2,y2-1);
291 // Bevel
292 p->setPen(sunken ? cg.mid() : cg.light());
293 p->drawLine(x+1, y+1, x2-1, y+1);
294 p->drawLine(x+1, y+1, x+1, y2-1);
295 p->setPen(sunken ? cg.light() : cg.mid());
296 p->drawLine(x+2, y2-1, x2-1, y2-1);
297 p->drawLine(x2-1, y+2, x2-1, y2-1);
299 p->fillRect(x+2, y+2, w-4, h-4, cg.button());
301 p->setPen( oldPen );
302 break;
305 // PUSH BUTTON
306 // -------------------------------------------------------------------
307 case PE_ButtonCommand: {
308 bool sunken = on || down;
309 bool flat = !(flags & (Style_Raised | Style_Sunken));
310 int x, y, w, h;
311 r.rect(&x, &y, &w, &h);
312 int x2 = x+w-1;
313 int y2 = y+h-1;
315 if ( sunken )
316 kDrawBeButton( p, x, y, w, h, cg, true,
317 &cg.brush(QPalette::Mid) );
319 else if ( flags & Style_MouseOver && !flat ) {
320 QBrush brush(cg.button().light(110));
321 kDrawBeButton( p, x, y, w, h, cg, false, &brush );
324 // "Flat" button
325 else if ( flat ) {
326 if ( flags & Style_MouseOver )
327 p->fillRect(r, cg.button().light(110));
328 else
329 renderGradient(p, QRect(x, y, w-1, h-1),
330 cg.button(), false);
332 p->setPen(cg.button().light(75));
333 p->drawLine(x, y, x2, y);
334 p->drawLine(x, y, x, y2);
335 p->drawLine(x, y2, x2, y2);
336 p->drawLine(x2, y, x2, y2);
339 else if( highcolor )
341 int x2 = x+w-1;
342 int y2 = y+h-1;
343 p->setPen(cg.shadow());
344 p->drawLine(x+1, y, x2-1, y);
345 p->drawLine(x+1, y2, x2-1, y2);
346 p->drawLine(x, y+1, x, y2-1);
347 p->drawLine(x2, y+1, x2, y2-1);
349 p->setPen(cg.light());
350 p->drawLine(x+2, y+2, x2-1, y+2);
351 p->drawLine(x+2, y+3, x2-2, y+3);
352 p->drawLine(x+2, y+4, x+2, y2-1);
353 p->drawLine(x+3, y+4, x+3, y2-2);
355 p->setPen(cg.mid());
356 p->drawLine(x2-1, y+2, x2-1, y2-1);
357 p->drawLine(x+2, y2-1, x2-1, y2-1);
359 p->drawLine(x+1, y+1, x2-1, y+1);
360 p->drawLine(x+1, y+2, x+1, y2-1);
361 p->drawLine(x2-2, y+3, x2-2, y2-2);
363 renderGradient(p, QRect(x+4, y+4, w-6, h-6),
364 cg.button(), false);
365 } else
366 kDrawBeButton(p, x, y, w, h, cg, false,
367 &cg.brush(QPalette::Button));
368 break;
372 // BEVELS
373 // -------------------------------------------------------------------
374 case PE_ButtonBevel: {
375 int x,y,w,h;
376 r.rect(&x, &y, &w, &h);
377 bool sunken = on || down;
378 int x2 = x+w-1;
379 int y2 = y+h-1;
381 // Outer frame
382 p->setPen(cg.shadow());
383 p->drawRect(r);
385 // Bevel
386 p->setPen(sunken ? cg.mid() : cg.light());
387 p->drawLine(x+1, y+1, x2-1, y+1);
388 p->drawLine(x+1, y+1, x+1, y2-1);
389 p->setPen(sunken ? cg.light() : cg.mid());
390 p->drawLine(x+2, y2-1, x2-1, y2-1);
391 p->drawLine(x2-1, y+2, x2-1, y2-1);
393 if (w > 4 && h > 4) {
394 if (sunken)
395 p->fillRect(x+2, y+2, w-4, h-4, cg.button());
396 else
397 renderGradient( p, QRect(x+2, y+2, w-4, h-4),
398 cg.button(), flags & Style_Horizontal );
400 break;
404 // FOCUS RECT
405 // -------------------------------------------------------------------
406 case PE_FocusRect: {
407 p->drawWinFocusRect( r );
408 break;
412 // HEADER SECTION
413 // -------------------------------------------------------------------
414 case PE_HeaderSection: {
415 // Temporary solution for the proper orientation of gradients.
416 bool horizontal = true;
417 if (p && p->device()->devType() == QInternal::Widget) {
418 Q3Header* hdr = dynamic_cast<Q3Header*>(p->device());
419 if (hdr)
420 horizontal = hdr->orientation() == Qt::Horizontal;
423 int x,y,w,h;
424 r.rect(&x, &y, &w, &h);
425 bool sunken = on || down;
426 int x2 = x+w-1;
427 int y2 = y+h-1;
428 QPen oldPen = p->pen();
430 // Bevel
431 p->setPen(sunken ? cg.mid() : cg.light());
432 p->drawLine(x, y, x2-1, y);
433 p->drawLine(x, y, x, y2-1);
434 p->setPen(sunken ? cg.light() : cg.mid());
435 p->drawLine(x+1, y2-1, x2-1, y2-1);
436 p->drawLine(x2-1, y+1, x2-1, y2-1);
437 p->setPen(cg.shadow());
438 p->drawLine(x, y2, x2, y2);
439 p->drawLine(x2, y, x2, y2);
441 if (sunken)
442 p->fillRect(x+1, y+1, w-3, h-3, cg.button());
443 else
444 renderGradient( p, QRect(x+1, y+1, w-3, h-3),
445 cg.button(), !horizontal );
446 p->setPen( oldPen );
447 break;
451 // SCROLLBAR
452 // -------------------------------------------------------------------
453 case PE_ScrollBarSlider: {
454 // Small hack to ensure scrollbar gradients are drawn the right way.
455 flags ^= Style_Horizontal;
457 drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Enabled | Style_Raised);
459 // Draw a scrollbar riffle (note direction after above changes)
460 if ( type != B3 ) {
462 // HighColor & Default scrollbar
463 if (flags & Style_Horizontal) {
464 if (r.height() >= 15) {
465 int x = r.x()+3;
466 int y = r.y() + (r.height()-7)/2;
467 int x2 = r.right()-3;
468 p->setPen(cg.light());
469 p->drawLine(x, y, x2, y);
470 p->drawLine(x, y+3, x2, y+3);
471 p->drawLine(x, y+6, x2, y+6);
473 p->setPen(cg.mid());
474 p->drawLine(x, y+1, x2, y+1);
475 p->drawLine(x, y+4, x2, y+4);
476 p->drawLine(x, y+7, x2, y+7);
478 } else {
479 if (r.width() >= 15) {
480 int y = r.y()+3;
481 int x = r.x() + (r.width()-7)/2;
482 int y2 = r.bottom()-3;
483 p->setPen(cg.light());
484 p->drawLine(x, y, x, y2);
485 p->drawLine(x+3, y, x+3, y2);
486 p->drawLine(x+6, y, x+6, y2);
488 p->setPen(cg.mid());
489 p->drawLine(x+1, y, x+1, y2);
490 p->drawLine(x+4, y, x+4, y2);
491 p->drawLine(x+7, y, x+7, y2);
494 } else {
496 // B3 scrollbar
497 if (flags & Style_Horizontal) {
498 int buttons = 0;
500 if (r.height() >= 36) buttons = 3;
501 else if (r.height() >=24) buttons = 2;
502 else if (r.height() >=16) buttons = 1;
504 int x = r.x() + (r.width()-7) / 2;
505 int y = r.y() + (r.height() - (buttons * 5) -
506 (buttons-1)) / 2;
507 int x2 = x + 7;
509 for ( int i=0; i<buttons; i++, y+=6 )
511 p->setPen( cg.mid() );
512 p->drawLine( x+1, y, x2-1, y );
513 p->drawLine( x, y+1, x, y+3 );
514 p->setPen( cg.light() );
515 p->drawLine( x+1, y+1, x2-1, y+1 );
516 p->drawLine( x+1, y+1, x+1, y+3 );
517 p->setPen( cg.dark() );
518 p->drawLine( x+1, y+4, x2-1, y+4 );
519 p->drawLine( x2, y+1, x2, y+3 );
521 } else {
522 int buttons = 0;
524 if (r.width() >= 36) buttons = 3;
525 else if (r.width() >=24) buttons = 2;
526 else if (r.width() >=16) buttons = 1;
528 int x = r.x() + (r.width() - (buttons * 5) -
529 (buttons-1)) / 2;
530 int y = r.y() + (r.height()-7) / 2;
531 int y2 = y + 7;
533 for ( int i=0; i<buttons; i++, x+=6 )
535 p->setPen( cg.mid() );
536 p->drawLine( x+1, y, x+3, y );
537 p->drawLine( x, y+1, x, y2-1 );
538 p->setPen( cg.light() );
539 p->drawLine( x+1, y+1, x+3, y+1 );
540 p->drawLine( x+1, y+1, x+1, y2-1 );
541 p->setPen( cg.dark() );
542 p->drawLine( x+1, y2, x+3, y2 );
543 p->drawLine( x+4, y+1, x+4, y2-1 );
547 break;
551 case PE_ScrollBarAddPage:
552 case PE_ScrollBarSubPage: {
553 int x, y, w, h;
554 r.rect(&x, &y, &w, &h);
555 int x2 = x+w-1;
556 int y2 = y+h-1;
558 if ( type != B3 ) {
559 // HighColor & Default scrollbar
561 p->setPen(cg.shadow());
563 if (flags & Style_Horizontal) {
564 p->drawLine(x, y, x2, y);
565 p->drawLine(x, y2, x2, y2);
566 renderGradient(p, QRect(x, y+1, w, h-2),
567 cg.mid(), false);
568 } else {
569 p->drawLine(x, y, x, y2);
570 p->drawLine(x2, y, x2, y2);
571 renderGradient(p, QRect(x+1, y, w-2, h),
572 cg.mid(), true);
574 } else {
575 // B3 scrollbar
577 p->setPen( cg.mid() );
579 if (flags & Style_Horizontal) {
580 p->drawLine(x, y, x2, y);
581 p->drawLine(x, y2, x2, y2);
582 p->fillRect( QRect(x, y+1, w, h-2),
583 flags & Style_Down ? cg.button() : cg.midlight() );
584 } else {
585 p->drawLine(x, y, x, y2);
586 p->drawLine(x2, y, x2, y2);
587 p->fillRect( QRect(x+1, y, w-2, h),
588 flags & Style_Down ? cg.button() : cg.midlight() );
591 break;
595 case PE_ScrollBarAddLine: {
596 drawPrimitive( PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
597 ((flags & Style_Down) ? Style_Down : Style_Raised) );
599 drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
600 p, r, cg, flags );
601 break;
605 case PE_ScrollBarSubLine: {
606 drawPrimitive( PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
607 ((flags & Style_Down) ? Style_Down : Style_Raised) );
609 drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
610 p, r, cg, flags );
611 break;
615 // CHECKBOX (indicator)
616 // -------------------------------------------------------------------
617 case PE_Indicator: {
619 bool enabled = flags & Style_Enabled;
620 bool nochange = flags & Style_NoChange;
622 if (xBmp.isNull()) {
623 xBmp = QBitmap(7, 7, x_bits, true);
624 xBmp.setMask(xBmp);
627 int x,y,w,h;
628 x=r.x(); y=r.y(); w=r.width(); h=r.height();
629 int x2 = x+w-1;
630 int y2 = y+h-1;
632 p->setPen(cg.mid());
633 p->drawLine(x, y, x2, y);
634 p->drawLine(x, y, x, y2);
636 p->setPen(cg.light());
637 p->drawLine(x2, y+1, x2, y2);
638 p->drawLine(x+1, y2, x2, y2);
640 p->setPen(cg.shadow());
641 p->drawLine(x+1, y+1, x2-1, y+1);
642 p->drawLine(x+1, y+1, x+1, y2-1);
644 p->setPen(cg.midlight());
645 p->drawLine(x2-1, y+2, x2-1, y2-1);
646 p->drawLine(x+2, y2-1, x2-1, y2-1);
648 if ( enabled )
649 p->fillRect(x+2, y+2, w-4, h-4,
650 down ? cg.button(): cg.base());
651 else
652 p->fillRect(x+2, y+2, w-4, h-4, cg.background());
654 if (!(flags & Style_Off)) {
655 if (on) {
656 p->setPen(nochange ? cg.dark() : cg.text());
657 p->drawPixmap(x+3, y+3, xBmp);
659 else {
660 p->setPen(cg.shadow());
661 p->drawRect(x+2, y+2, w-4, h-4);
662 p->setPen(nochange ? cg.text() : cg.dark());
663 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2);
664 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2);
665 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2);
668 break;
672 // RADIOBUTTON (exclusive indicator)
673 // -------------------------------------------------------------------
674 case PE_ExclusiveIndicator: {
676 if (lightBmp.isNull()) {
677 lightBmp = QBitmap(13, 13, radiooff_light_bits, true);
678 grayBmp = QBitmap(13, 13, radiooff_gray_bits, true);
679 dgrayBmp = QBitmap(13, 13, radiooff_dgray_bits, true);
680 centerBmp = QBitmap(13, 13, radiooff_center_bits, true);
681 centerBmp.setMask( centerBmp );
684 // Bevel
685 kColorBitmaps(p, cg, r.x(), r.y(), &lightBmp , &grayBmp,
686 NULL, &dgrayBmp);
688 // The center fill of the indicator (grayed out when disabled)
689 if ( flags & Style_Enabled )
690 p->setPen( down ? cg.button() : cg.base() );
691 else
692 p->setPen( cg.background() );
693 p->drawPixmap( r.x(), r.y(), centerBmp );
695 // Indicator "dot"
696 if ( on ) {
697 QColor color = flags & Style_NoChange ?
698 cg.dark() : cg.text();
700 p->setPen(color);
701 p->drawLine(5, 4, 7, 4);
702 p->drawLine(4, 5, 4, 7);
703 p->drawLine(5, 8, 7, 8);
704 p->drawLine(8, 5, 8, 7);
705 p->fillRect(5, 5, 3, 3, color);
708 break;
712 // RADIOBUTTON (exclusive indicator) mask
713 // -------------------------------------------------------------------
714 case PE_ExclusiveIndicatorMask: {
715 if (maskBmp.isNull()) {
716 maskBmp = QBitmap(13, 13, radiomask_bits, true);
717 maskBmp.setMask(maskBmp);
720 p->setPen(Qt::color1);
721 p->drawPixmap(r.x(), r.y(), maskBmp);
722 break;
726 // SPLITTER/DOCKWINDOW HANDLES
727 // -------------------------------------------------------------------
728 case PE_DockWindowResizeHandle:
729 case PE_Splitter: {
730 int x,y,w,h;
731 r.rect(&x, &y, &w, &h);
732 int x2 = x+w-1;
733 int y2 = y+h-1;
735 p->setPen(cg.dark());
736 p->drawRect(x, y, w, h);
737 p->setPen(cg.background());
738 p->drawPoint(x, y);
739 p->drawPoint(x2, y);
740 p->drawPoint(x, y2);
741 p->drawPoint(x2, y2);
742 p->setPen(cg.light());
743 p->drawLine(x+1, y+1, x+1, y2-1);
744 p->drawLine(x+1, y+1, x2-1, y+1);
745 p->setPen(cg.midlight());
746 p->drawLine(x+2, y+2, x+2, y2-2);
747 p->drawLine(x+2, y+2, x2-2, y+2);
748 p->setPen(cg.mid());
749 p->drawLine(x2-1, y+1, x2-1, y2-1);
750 p->drawLine(x+1, y2-1, x2-1, y2-1);
751 p->fillRect(x+3, y+3, w-5, h-5, cg.brush(QPalette::Background));
752 break;
756 // GENERAL PANELS
757 // -------------------------------------------------------------------
758 case PE_Panel:
759 case PE_PanelPopup:
760 case PE_WindowFrame:
761 case PE_PanelLineEdit: {
762 bool sunken = flags & Style_Sunken;
763 int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
764 : opt.lineWidth();
765 if (lw == 2)
767 QPen oldPen = p->pen();
768 int x,y,w,h;
769 r.rect(&x, &y, &w, &h);
770 int x2 = x+w-1;
771 int y2 = y+h-1;
772 p->setPen(sunken ? cg.light() : cg.dark());
773 p->drawLine(x, y2, x2, y2);
774 p->drawLine(x2, y, x2, y2);
775 p->setPen(sunken ? cg.mid() : cg.light());
776 p->drawLine(x, y, x2, y);
777 p->drawLine(x, y, x, y2);
778 p->setPen(sunken ? cg.midlight() : cg.mid());
779 p->drawLine(x+1, y2-1, x2-1, y2-1);
780 p->drawLine(x2-1, y+1, x2-1, y2-1);
781 p->setPen(sunken ? cg.dark() : cg.midlight());
782 p->drawLine(x+1, y+1, x2-1, y+1);
783 p->drawLine(x+1, y+1, x+1, y2-1);
784 p->setPen(oldPen);
785 } else
786 KStyle::drawPrimitive(pe, p, r, cg, flags, opt);
788 break;
792 // MENU / TOOLBAR PANEL
793 // -------------------------------------------------------------------
794 case PE_PanelMenuBar: // Menu
795 case PE_PanelDockWindow: { // Toolbar
796 int x2 = r.x()+r.width()-1;
797 int y2 = r.y()+r.height()-1;
798 int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
799 : opt.lineWidth();
801 if (lw)
803 p->setPen(cg.light());
804 p->drawLine(r.x(), r.y(), x2-1, r.y());
805 p->drawLine(r.x(), r.y(), r.x(), y2-1);
806 p->setPen(cg.dark());
807 p->drawLine(r.x(), y2, x2, y2);
808 p->drawLine(x2, r.y(), x2, y2);
810 // ### Qt should specify Style_Horizontal where appropriate
811 renderGradient( p, QRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2),
812 cg.button(),
813 (r.width() < r.height()) && (pe != PE_PanelMenuBar) );
815 else
816 renderGradient( p, r, cg.button(),
817 (r.width() < r.height()) && (pe != PE_PanelMenuBar) );
819 break;
824 // TOOLBAR SEPARATOR
825 // -------------------------------------------------------------------
826 case PE_DockWindowSeparator: {
827 renderGradient( p, r, cg.button(),
828 !(flags & Style_Horizontal));
829 if ( !(flags & Style_Horizontal) ) {
830 p->setPen(cg.mid());
831 p->drawLine(4, r.height()/2, r.width()-5, r.height()/2);
832 p->setPen(cg.light());
833 p->drawLine(4, r.height()/2+1, r.width()-5, r.height()/2+1);
834 } else {
835 p->setPen(cg.mid());
836 p->drawLine(r.width()/2, 4, r.width()/2, r.height()-5);
837 p->setPen(cg.light());
838 p->drawLine(r.width()/2+1, 4, r.width()/2+1, r.height()-5);
840 break;
844 default:
846 // ARROWS
847 // -------------------------------------------------------------------
848 if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft)
850 Q3PointArray a;
852 if ( type != B3 ) {
853 // HighColor & Default arrows
854 switch(pe) {
855 case PE_ArrowUp:
856 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow);
857 break;
859 case PE_ArrowDown:
860 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow);
861 break;
863 case PE_ArrowLeft:
864 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow);
865 break;
867 default:
868 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
870 } else {
871 // B3 arrows
872 switch(pe) {
873 case PE_ArrowUp:
874 a.setPoints(QCOORDARRLEN(B3::u_arrow), B3::u_arrow);
875 break;
877 case PE_ArrowDown:
878 a.setPoints(QCOORDARRLEN(B3::d_arrow), B3::d_arrow);
879 break;
881 case PE_ArrowLeft:
882 a.setPoints(QCOORDARRLEN(B3::l_arrow), B3::l_arrow);
883 break;
885 default:
886 a.setPoints(QCOORDARRLEN(B3::r_arrow), B3::r_arrow);
890 p->save();
891 if ( flags & Style_Down )
892 p->translate( pixelMetric( PM_ButtonShiftHorizontal ),
893 pixelMetric( PM_ButtonShiftVertical ) );
895 if ( flags & Style_Enabled ) {
896 a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
897 p->setPen( cg.buttonText() );
898 p->drawLineSegments( a );
899 } else {
900 a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
901 p->setPen( cg.light() );
902 p->drawLineSegments( a );
903 a.translate( -1, -1 );
904 p->setPen( cg.mid() );
905 p->drawLineSegments( a );
907 p->restore();
909 } else
910 KStyle::drawPrimitive( pe, p, r, cg, flags, opt );
916 void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
917 QPainter* p,
918 const QWidget* widget,
919 const QRect &r,
920 const QColorGroup &cg,
921 SFlags flags,
922 const QStyleOption &opt ) const
924 switch ( kpe )
926 // TOOLBAR HANDLE
927 // -------------------------------------------------------------------
928 case KPE_ToolBarHandle: {
929 int x = r.x(); int y = r.y();
930 int x2 = r.x() + r.width()-1;
931 int y2 = r.y() + r.height()-1;
933 if (flags & Style_Horizontal) {
935 renderGradient( p, r, cg.button(), false);
936 p->setPen(cg.light());
937 p->drawLine(x+1, y+4, x+1, y2-4);
938 p->drawLine(x+3, y+4, x+3, y2-4);
939 p->drawLine(x+5, y+4, x+5, y2-4);
941 p->setPen(cg.mid());
942 p->drawLine(x+2, y+4, x+2, y2-4);
943 p->drawLine(x+4, y+4, x+4, y2-4);
944 p->drawLine(x+6, y+4, x+6, y2-4);
946 } else {
948 renderGradient( p, r, cg.button(), true);
949 p->setPen(cg.light());
950 p->drawLine(x+4, y+1, x2-4, y+1);
951 p->drawLine(x+4, y+3, x2-4, y+3);
952 p->drawLine(x+4, y+5, x2-4, y+5);
954 p->setPen(cg.mid());
955 p->drawLine(x+4, y+2, x2-4, y+2);
956 p->drawLine(x+4, y+4, x2-4, y+4);
957 p->drawLine(x+4, y+6, x2-4, y+6);
960 break;
964 // GENERAL/KICKER HANDLE
965 // -------------------------------------------------------------------
966 case KPE_GeneralHandle: {
967 int x = r.x(); int y = r.y();
968 int x2 = r.x() + r.width()-1;
969 int y2 = r.y() + r.height()-1;
971 if (flags & Style_Horizontal) {
973 p->setPen(cg.light());
974 p->drawLine(x+1, y, x+1, y2);
975 p->drawLine(x+3, y, x+3, y2);
976 p->drawLine(x+5, y, x+5, y2);
978 p->setPen(cg.mid());
979 p->drawLine(x+2, y, x+2, y2);
980 p->drawLine(x+4, y, x+4, y2);
981 p->drawLine(x+6, y, x+6, y2);
983 } else {
985 p->setPen(cg.light());
986 p->drawLine(x, y+1, x2, y+1);
987 p->drawLine(x, y+3, x2, y+3);
988 p->drawLine(x, y+5, x2, y+5);
990 p->setPen(cg.mid());
991 p->drawLine(x, y+2, x2, y+2);
992 p->drawLine(x, y+4, x2, y+4);
993 p->drawLine(x, y+6, x2, y+6);
996 break;
1000 // SLIDER GROOVE
1001 // -------------------------------------------------------------------
1002 case KPE_SliderGroove: {
1003 const QSlider* slider = (const QSlider*)widget;
1004 bool horizontal = slider->orientation() == Qt::Horizontal;
1005 int gcenter = (horizontal ? r.height() : r.width()) / 2;
1007 QRect gr;
1008 if (horizontal)
1009 gr = QRect(r.x(), r.y()+gcenter-3, r.width(), 7);
1010 else
1011 gr = QRect(r.x()+gcenter-3, r.y(), 7, r.height());
1013 int x,y,w,h;
1014 gr.rect(&x, &y, &w, &h);
1015 int x2=x+w-1;
1016 int y2=y+h-1;
1018 // Draw the slider groove.
1019 p->setPen(cg.dark());
1020 p->drawLine(x+2, y, x2-2, y);
1021 p->drawLine(x, y+2, x, y2-2);
1022 p->fillRect(x+2,y+2,w-4, h-4,
1023 slider->isEnabled() ? cg.dark() : cg.mid());
1024 p->setPen(cg.shadow());
1025 p->drawRect(x+1, y+1, w-2, h-2);
1026 p->setPen(cg.light());
1027 p->drawPoint(x+1,y2-1);
1028 p->drawPoint(x2-1,y2-1);
1029 p->drawLine(x2, y+2, x2, y2-2);
1030 p->drawLine(x+2, y2, x2-2, y2);
1031 break;
1034 // SLIDER HANDLE
1035 // -------------------------------------------------------------------
1036 case KPE_SliderHandle: {
1037 const QSlider* slider = (const QSlider*)widget;
1038 bool horizontal = slider->orientation() == Qt::Horizontal;
1039 int x,y,w,h;
1040 r.rect(&x, &y, &w, &h);
1041 int x2 = x+w-1;
1042 int y2 = y+h-1;
1044 p->setPen(cg.mid());
1045 p->drawLine(x+1, y, x2-1, y);
1046 p->drawLine(x, y+1, x, y2-1);
1047 p->setPen(cg.shadow());
1048 p->drawLine(x+1, y2, x2-1, y2);
1049 p->drawLine(x2, y+1, x2, y2-1);
1051 p->setPen(cg.light());
1052 p->drawLine(x+1, y+1, x2-1, y+1);
1053 p->drawLine(x+1, y+1, x+1, y2-1);
1054 p->setPen(cg.dark());
1055 p->drawLine(x+2, y2-1, x2-1, y2-1);
1056 p->drawLine(x2-1, y+2, x2-1, y2-1);
1057 p->setPen(cg.midlight());
1058 p->drawLine(x+2, y+2, x2-2, y+2);
1059 p->drawLine(x+2, y+2, x+2, y2-2);
1060 p->setPen(cg.mid());
1061 p->drawLine(x+3, y2-2, x2-2, y2-2);
1062 p->drawLine(x2-2, y+3, x2-2, y2-2);
1063 renderGradient(p, QRect(x+3, y+3, w-6, h-6),
1064 cg.button(), !horizontal);
1066 // Paint riffles
1067 if (horizontal) {
1068 p->setPen(cg.light());
1069 p->drawLine(x+5, y+4, x+5, y2-4);
1070 p->drawLine(x+8, y+4, x+8, y2-4);
1071 p->drawLine(x+11,y+4, x+11, y2-4);
1072 p->setPen(slider->isEnabled() ? cg.shadow(): cg.mid());
1073 p->drawLine(x+6, y+4, x+6, y2-4);
1074 p->drawLine(x+9, y+4, x+9, y2-4);
1075 p->drawLine(x+12,y+4, x+12, y2-4);
1076 } else {
1077 p->setPen(cg.light());
1078 p->drawLine(x+4, y+5, x2-4, y+5);
1079 p->drawLine(x+4, y+8, x2-4, y+8);
1080 p->drawLine(x+4, y+11, x2-4, y+11);
1081 p->setPen(slider->isEnabled() ? cg.shadow() : cg.mid());
1082 p->drawLine(x+4, y+6, x2-4, y+6);
1083 p->drawLine(x+4, y+9, x2-4, y+9);
1084 p->drawLine(x+4, y+12, x2-4, y+12);
1086 break;
1089 default:
1090 KStyle::drawKStylePrimitive( kpe, p, widget, r, cg, flags, opt);
1095 void HighColorStyle::drawControl( ControlElement element,
1096 QPainter *p,
1097 const QWidget *widget,
1098 const QRect &r,
1099 const QColorGroup &cg,
1100 SFlags flags,
1101 const QStyleOption& opt ) const
1103 switch (element)
1105 // PUSHBUTTON
1106 // -------------------------------------------------------------------
1107 case CE_PushButton: {
1108 if ( widget == hoverWidget )
1109 flags |= Style_MouseOver;
1111 if ( type != HighColor ) {
1112 QPushButton *button = (QPushButton*) widget;
1113 QRect br = r;
1114 bool btnDefault = button->isDefault();
1116 if ( btnDefault || button->autoDefault() ) {
1117 // Compensate for default indicator
1118 static int di = pixelMetric( PM_ButtonDefaultIndicator );
1119 br.adjust( di, di, -di, -di );
1122 if ( btnDefault )
1123 drawPrimitive( PE_ButtonDefault, p, r, cg, flags );
1125 drawPrimitive( PE_ButtonCommand, p, br, cg, flags );
1127 } else
1128 drawPrimitive( PE_ButtonCommand, p, r, cg, flags );
1130 break;
1134 // PUSHBUTTON LABEL
1135 // -------------------------------------------------------------------
1136 case CE_PushButtonLabel: {
1137 const QPushButton* button = (const QPushButton*)widget;
1138 bool active = button->isOn() || button->isDown();
1139 int x, y, w, h;
1140 r.rect( &x, &y, &w, &h );
1142 // Shift button contents if pushed.
1143 if ( active ) {
1144 x += pixelMetric(PM_ButtonShiftHorizontal, widget);
1145 y += pixelMetric(PM_ButtonShiftVertical, widget);
1146 flags |= Style_Sunken;
1149 // Does the button have a popup menu?
1150 if ( button->isMenuButton() ) {
1151 int dx = pixelMetric( PM_MenuButtonIndicator, widget );
1152 drawPrimitive( PE_ArrowDown, p, QRect(x + w - dx - 2, y + 2, dx, h - 4),
1153 cg, flags, opt );
1154 w -= dx;
1157 // Draw the icon if there is one
1158 if ( button->iconSet() && !button->iconSet()->isNull() ) {
1159 QIcon::Mode mode = QIcon::Disabled;
1160 QIcon::State state = QIcon::Off;
1162 if (button->isEnabled())
1163 mode = button->hasFocus() ? QIcon::Active : QIcon::Normal;
1164 if (button->isToggleButton() && button->isOn())
1165 state = QIcon::On;
1167 QPixmap pixmap = button->iconSet()->pixmap( QIcon::Small, mode, state );
1169 // Center the iconset if there's no text or pixmap
1170 if (button->text().isEmpty() && !button->pixmap())
1171 p->drawPixmap( x + (w - pixmap.width()) / 2,
1172 y + (h - pixmap.height()) / 2, pixmap );
1173 else
1174 p->drawPixmap( x + 4, y + (h - pixmap.height()) / 2, pixmap );
1176 int pw = pixmap.width();
1177 x += pw + 4;
1178 w -= pw + 4;
1181 // Make the label indicate if the button is a default button or not
1182 if ( active || button->isDefault() ) {
1183 // Draw "fake" bold text - this enables the font metrics to remain
1184 // the same as computed in QPushButton::sizeHint(), but gives
1185 // a reasonable bold effect.
1186 int i;
1188 // Text shadow
1189 if (button->isEnabled()) // Don't draw double-shadow when disabled
1190 for(i=0; i<2; i++)
1191 drawItem( p, QRect(x+i+1, y+1, w, h), Qt::AlignCenter | Qt::TextShowMnemonic,
1192 button->colorGroup(), button->isEnabled(), NULL,
1193 button->text(), -1,
1194 active ? &button->colorGroup().dark() : &button->colorGroup().mid() );
1196 // Normal Text
1197 for(i=0; i<2; i++)
1198 drawItem( p, QRect(x+i, y, w, h), Qt::AlignCenter | Qt::TextShowMnemonic,
1199 button->colorGroup(), button->isEnabled(), i == 0 ? button->pixmap() : NULL,
1200 button->text(), -1,
1201 active ? &button->colorGroup().light() : &button->colorGroup().buttonText() );
1202 } else
1203 drawItem( p, QRect(x, y, w, h), Qt::AlignCenter | Qt::TextShowMnemonic, button->colorGroup(),
1204 button->isEnabled(), button->pixmap(), button->text(), -1,
1205 active ? &button->colorGroup().light() : &button->colorGroup().buttonText() );
1207 // Draw a focus rect if the button has focus
1208 if ( flags & Style_HasFocus )
1209 drawPrimitive( PE_FocusRect, p,
1210 QStyle::visualRect(subRect(SR_PushButtonFocusRect, widget), widget),
1211 cg, flags );
1212 break;
1215 // TOOLBOX TAB
1216 // -------------------------------------------------------------------
1217 case CE_ToolBoxTab:
1219 bool pressed = flags & Style_Down;
1220 bool selected = flags & Style_Selected;
1221 int x, y, x2, y2;
1222 r.getCoords( &x, &y, &x2, &y2 );
1224 p->setPen( pressed ? cg.shadow() : cg.light() );
1225 p->drawLine( x, y, x2-1, y );
1226 p->drawLine( x, y, x, y2-1 );
1228 p->setPen( pressed ? cg.light() : cg.shadow() );
1229 p->drawLine( x, y2, x2, y2 );
1230 p->drawLine( x2, y, x2, y2 );
1232 QColor fill = selected ? cg.highlight() : cg.button();
1233 selectionBackground = selected;
1235 if ( pressed )
1236 p->fillRect( QRect(x+1, y+1, r.width()-2, r.height()-2), fill );
1237 else
1238 renderGradient(p, QRect(x+1, y+1, r.width()-2, r.height()-2),
1239 fill, false);
1240 break;
1243 // MENUBAR BACKGROUND
1244 // -------------------------------------------------------------------
1245 case CE_MenuBarEmptyArea:
1247 renderGradient(p, r, cg.button(), false);
1248 break;
1251 // MENUBAR ITEM (sunken panel on mouse over)
1252 // -------------------------------------------------------------------
1253 case CE_MenuBarItem:
1255 QMenuBar *mb = (QMenuBar*)widget;
1256 QMenuItem *mi = opt.menuItem();
1257 QRect pr = mb->rect();
1259 bool active = flags & Style_Active;
1260 bool focused = flags & Style_HasFocus;
1262 if ( active && focused )
1263 qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(),
1264 cg, true, 1, &cg.brush(QPalette::Midlight));
1265 else
1266 renderGradient( p, r, cg.button(), false,
1267 r.x(), r.y()-1, pr.width()-2, pr.height()-2);
1269 drawItem( p, r, Qt::AlignCenter | Qt::AlignVCenter | Qt::TextShowMnemonic
1270 | Qt::TextDontClip | Qt::TextSingleLine, cg, flags & Style_Enabled,
1271 mi->pixmap(), mi->text() );
1273 break;
1277 // POPUPMENU ITEM
1278 // -------------------------------------------------------------------
1279 case CE_PopupMenuItem: {
1280 const QMenu *popupmenu = (const QMenu *) widget;
1282 QMenuItem *mi = opt.menuItem();
1283 if ( !mi ) {
1284 // Don't leave blank holes if we set NoBackground for the QPopupMenu.
1285 // This only happens when the popupMenu spans more than one column.
1286 if (! (widget->erasePixmap() && !widget->erasePixmap()->isNull()) )
1287 p->fillRect(r, cg.brush(QPalette::Button) );
1288 break;
1291 int tab = opt.tabWidth();
1292 int checkcol = opt.maxIconWidth();
1293 bool enabled = mi->isEnabled();
1294 bool checkable = popupmenu->isCheckable();
1295 bool active = flags & Style_Active;
1296 bool etchtext = styleHint( SH_EtchDisabledText );
1297 bool reverse = QApplication::isRightToLeft();
1298 int x, y, w, h;
1299 r.rect( &x, &y, &w, &h );
1301 if ( checkable )
1302 checkcol = qMax( checkcol, 20 );
1304 // Are we a menu item separator?
1305 if ( mi->isSeparator() ) {
1306 p->setPen( cg.dark() );
1307 p->drawLine( x, y, x+w, y );
1308 p->setPen( cg.light() );
1309 p->drawLine( x, y+1, x+w, y+1 );
1310 break;
1313 // Draw the menu item background
1314 if ( active )
1315 qDrawShadePanel( p, x, y, w, h, cg, true, 1,
1316 &cg.brush(QPalette::Midlight) );
1317 // Draw the transparency pixmap
1318 else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() )
1319 p->drawPixmap( x, y, *widget->erasePixmap(), x, y, w, h );
1320 // Draw a solid background
1321 else
1322 p->fillRect( r, cg.button() );
1324 // Do we have an icon?
1325 if ( mi->iconSet() ) {
1326 QIcon::Mode mode;
1327 QRect cr = visualRect( QRect(x, y, checkcol, h), r );
1329 // Select the correct icon from the iconset
1330 if ( active )
1331 mode = enabled ? QIcon::Active : QIcon::Disabled;
1332 else
1333 mode = enabled ? QIcon::Normal : QIcon::Disabled;
1335 // Do we have an icon and are checked at the same time?
1336 // Then draw a "pressed" background behind the icon
1337 if ( checkable && !active && mi->isChecked() )
1338 qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(),
1339 cg, true, 1, &cg.brush(QPalette::Midlight) );
1340 // Draw the icon
1341 QPixmap pixmap = mi->iconSet()->pixmap( QIcon::Small, mode );
1342 QRect pmr( 0, 0, pixmap.width(), pixmap.height() );
1343 pmr.moveCenter( cr.center() );
1344 p->drawPixmap( pmr.topLeft(), pixmap );
1347 // Are we checked? (This time without an icon)
1348 else if ( checkable && mi->isChecked() ) {
1349 int cx = reverse ? x+w - checkcol : x;
1351 // We only have to draw the background if the menu item is inactive -
1352 // if it's active the "pressed" background is already drawn
1353 if ( ! active )
1354 qDrawShadePanel( p, cx, y, checkcol, h, cg, true, 1,
1355 &cg.brush(QPalette::Midlight) );
1357 // Draw the checkmark
1358 SFlags cflags = Style_Default;
1359 cflags |= active ? Style_Enabled : Style_On;
1361 drawPrimitive( PE_CheckMark, p, QRect( cx + itemFrame, y + itemFrame,
1362 checkcol - itemFrame*2, h - itemFrame*2), cg, cflags );
1365 // Time to draw the menu item label...
1366 int xm = itemFrame + checkcol + itemHMargin; // X position margin
1368 int xp = reverse ? // X position
1369 x + tab + rightBorder + itemHMargin + itemFrame - 1 :
1370 x + xm;
1372 int offset = reverse ? -1 : 1; // Shadow offset for etched text
1374 // Label width (minus the width of the accelerator portion)
1375 int tw = w - xm - tab - arrowHMargin - itemHMargin * 3 - itemFrame + 1;
1377 // Set the color for enabled and disabled text
1378 // (used for both active and inactive menu items)
1379 p->setPen( enabled ? cg.buttonText() : cg.mid() );
1381 // This color will be used instead of the above if the menu item
1382 // is active and disabled at the same time. (etched text)
1383 QColor discol = cg.mid();
1385 // Does the menu item draw it's own label?
1386 if ( mi->custom() ) {
1387 int m = itemVMargin;
1388 // Save the painter state in case the custom
1389 // paint method changes it in some way
1390 p->save();
1392 // Draw etched text if we're inactive and the menu item is disabled
1393 if ( etchtext && !enabled && !active ) {
1394 p->setPen( cg.light() );
1395 mi->custom()->paint( p, cg, active, enabled, xp+offset, y+m+1, tw, h-2*m );
1396 p->setPen( discol );
1398 mi->custom()->paint( p, cg, active, enabled, xp, y+m, tw, h-2*m );
1399 p->restore();
1401 else {
1402 // The menu item doesn't draw it's own label
1403 QString s = mi->text();
1405 // Does the menu item have a text label?
1406 if ( !s.isNull() ) {
1407 int t = s.find( '\t' );
1408 int m = itemVMargin;
1409 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1410 text_flags |= reverse ? Qt::AlignRight : Qt::AlignLeft;
1412 // Does the menu item have a tabstop? (for the accelerator text)
1413 if ( t >= 0 ) {
1414 int tabx = reverse ? x + rightBorder + itemHMargin + itemFrame :
1415 x + w - tab - rightBorder - itemHMargin - itemFrame;
1417 // Draw the right part of the label (accelerator text)
1418 if ( etchtext && !enabled && !active ) {
1419 // Draw etched text if we're inactive and the menu item is disabled
1420 p->setPen( cg.light() );
1421 p->drawText( tabx+offset, y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ) );
1422 p->setPen( discol );
1424 p->drawText( tabx, y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
1425 s = s.left( t );
1428 // Draw the left part of the label (or the whole label
1429 // if there's no accelerator)
1430 if ( etchtext && !enabled && !active ) {
1431 // Etched text again for inactive disabled menu items...
1432 p->setPen( cg.light() );
1433 p->drawText( xp+offset, y+m+1, tw, h-2*m, text_flags, s, t );
1434 p->setPen( discol );
1437 p->drawText( xp, y+m, tw, h-2*m, text_flags, s, t );
1441 // The menu item doesn't have a text label
1442 // Check if it has a pixmap instead
1443 else if ( mi->pixmap() ) {
1444 QPixmap *pixmap = mi->pixmap();
1446 // Draw the pixmap
1447 if ( pixmap->depth() == 1 )
1448 p->setBackgroundMode( Qt::OpaqueMode );
1450 int diffw = ( ( w - pixmap->width() ) / 2 )
1451 + ( ( w - pixmap->width() ) % 2 );
1452 p->drawPixmap( x+diffw, y+itemFrame, *pixmap );
1454 if ( pixmap->depth() == 1 )
1455 p->setBackgroundMode( Qt::TransparentMode );
1459 // Does the menu item have a submenu?
1460 if ( mi->popup() ) {
1461 PrimitiveElement arrow = reverse ? PE_ArrowLeft : PE_ArrowRight;
1462 int dim = pixelMetric(PM_MenuButtonIndicator);
1463 QRect vr = visualRect( QRect( x + w - arrowHMargin - 2*itemFrame - dim,
1464 y + h / 2 - dim / 2, dim, dim), r );
1466 // Draw an arrow at the far end of the menu item
1467 if ( active ) {
1468 if ( enabled )
1469 discol = cg.buttonText();
1471 QColorGroup g2( discol, cg.highlight(), Qt::white, Qt::white,
1472 enabled ? Qt::white : discol, discol, Qt::white );
1474 drawPrimitive( arrow, p, vr, g2, Style_Enabled );
1475 } else
1476 drawPrimitive( arrow, p, vr, cg,
1477 enabled ? Style_Enabled : Style_Default );
1479 break;
1482 default:
1483 KStyle::drawControl(element, p, widget, r, cg, flags, opt);
1488 void HighColorStyle::drawControlMask( ControlElement element,
1489 QPainter *p,
1490 const QWidget *widget,
1491 const QRect &r,
1492 const QStyleOption& opt ) const
1494 switch (element)
1496 // PUSHBUTTON MASK
1497 // ----------------------------------------------------------------------
1498 case CE_PushButton: {
1499 int x1, y1, x2, y2;
1500 r.getCoords( &x1, &y1, &x2, &y2 );
1501 QCOORD corners[] = { x1,y1, x2,y1, x1,y2, x2,y2 };
1502 p->fillRect( r, Qt::color1 );
1503 p->setPen( Qt::color0 );
1504 p->drawPoints( Q3PointArray(4, corners) );
1505 break;
1508 default:
1509 KStyle::drawControlMask(element, p, widget, r, opt);
1514 void HighColorStyle::drawComplexControl( ComplexControl control,
1515 QPainter *p,
1516 const QWidget *widget,
1517 const QRect &r,
1518 const QColorGroup &cg,
1519 SFlags flags,
1520 SCFlags controls,
1521 SCFlags active,
1522 const QStyleOption& opt ) const
1524 switch(control)
1526 // COMBOBOX
1527 // -------------------------------------------------------------------
1528 case CC_ComboBox: {
1530 // Draw box and arrow
1531 if ( controls & SC_ComboBoxArrow ) {
1532 bool sunken = (active == SC_ComboBoxArrow);
1534 // Draw the combo
1535 int x,y,w,h;
1536 r.rect(&x, &y, &w, &h);
1537 int x2 = x+w-1;
1538 int y2 = y+h-1;
1540 p->setPen(cg.shadow());
1541 p->drawLine(x+1, y, x2-1, y);
1542 p->drawLine(x+1, y2, x2-1, y2);
1543 p->drawLine(x, y+1, x, y2-1);
1544 p->drawLine(x2, y+1, x2, y2-1);
1546 // Ensure the edge notches are properly colored
1547 p->setPen(cg.button());
1548 p->drawPoint(x,y);
1549 p->drawPoint(x,y2);
1550 p->drawPoint(x2,y);
1551 p->drawPoint(x2,y2);
1553 renderGradient( p, QRect(x+2, y+2, w-4, h-4),
1554 cg.button(), false);
1556 p->setPen(sunken ? cg.light() : cg.mid());
1557 p->drawLine(x2-1, y+2, x2-1, y2-1);
1558 p->drawLine(x+1, y2-1, x2-1, y2-1);
1560 p->setPen(sunken ? cg.mid() : cg.light());
1561 p->drawLine(x+1, y+1, x2-1, y+1);
1562 p->drawLine(x+1, y+2, x+1, y2-2);
1564 // Get the button bounding box
1565 QRect ar = QStyle::visualRect(
1566 querySubControlMetrics(CC_ComboBox, widget, SC_ComboBoxArrow),
1567 widget );
1569 // Are we enabled?
1570 if ( widget->isEnabled() )
1571 flags |= Style_Enabled;
1573 // Are we "pushed" ?
1574 if ( active & Style_Sunken )
1575 flags |= Style_Sunken;
1577 drawPrimitive(PE_ArrowDown, p, ar, cg, flags);
1580 // Draw an edit field if required
1581 if ( controls & SC_ComboBoxEditField )
1583 const QComboBox * cb = (const QComboBox *) widget;
1584 QRect re = QStyle::visualRect(
1585 querySubControlMetrics( CC_ComboBox, widget,
1586 SC_ComboBoxEditField), widget );
1588 // Draw the indent
1589 if (cb->editable()) {
1590 p->setPen( cg.dark() );
1591 p->drawLine( re.x(), re.y()-1, re.x()+re.width(), re.y()-1 );
1592 p->drawLine( re.x()-1, re.y(), re.x()-1, re.y()+re.height() );
1595 if ( cb->hasFocus() ) {
1596 p->setPen( cg.highlightedText() );
1597 p->setBackgroundColor( cg.highlight() );
1598 } else {
1599 p->setPen( cg.text() );
1600 p->setBackgroundColor( cg.button() );
1603 if ( cb->hasFocus() && !cb->editable() ) {
1604 // Draw the contents
1605 p->fillRect( re.x(), re.y(), re.width(), re.height(),
1606 cg.brush( QPalette::Highlight ) );
1608 QRect re = QStyle::visualRect(
1609 subRect(SR_ComboBoxFocusRect, cb), widget);
1611 drawPrimitive( PE_FocusRect, p, re, cg,
1612 Style_FocusAtBorder, QStyleOption(cg.highlight()));
1615 break;
1618 // TOOLBUTTON
1619 // -------------------------------------------------------------------
1620 case CC_ToolButton: {
1621 const QToolButton *toolbutton = (const QToolButton *) widget;
1623 QRect button, menuarea;
1624 button = querySubControlMetrics(control, widget, SC_ToolButton, opt);
1625 menuarea = querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt);
1627 SFlags bflags = flags,
1628 mflags = flags;
1630 if (active & SC_ToolButton)
1631 bflags |= Style_Down;
1632 if (active & SC_ToolButtonMenu)
1633 mflags |= Style_Down;
1635 if (controls & SC_ToolButton)
1637 // If we're pressed, on, or raised...
1638 if (bflags & (Style_Down | Style_On | Style_Raised))
1639 drawPrimitive(PE_ButtonTool, p, button, cg, bflags, opt);
1641 // Check whether to draw a background pixmap
1642 else if ( toolbutton->parentWidget() &&
1643 toolbutton->parentWidget()->backgroundPixmap() &&
1644 !toolbutton->parentWidget()->backgroundPixmap()->isNull() )
1646 QPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap());
1647 p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
1649 else if (widget->parent())
1651 if (widget->parent()->inherits("QToolBar"))
1653 Q3ToolBar* parent = (Q3ToolBar*)widget->parent();
1654 QRect pr = parent->rect();
1656 renderGradient( p, r, cg.button(),
1657 parent->orientation() == Qt::Vertical,
1658 r.x(), r.y(), pr.width()-2, pr.height()-2);
1660 else if (widget->parent()->inherits("QToolBarExtensionWidget"))
1662 QWidget* parent = (QWidget*)widget->parent();
1663 Q3ToolBar* toolbar = (Q3ToolBar*)parent->parent();
1664 QRect tr = toolbar->rect();
1666 if ( toolbar->orientation() == Qt::Horizontal ) {
1667 renderGradient( p, r, cg.button(), false, r.x(), r.y(),
1668 r.width(), tr.height() );
1669 } else {
1670 renderGradient( p, r, cg.button(), true, r.x(), r.y(),
1671 tr.width(), r.height() );
1677 // Draw a toolbutton menu indicator if required
1678 if (controls & SC_ToolButtonMenu)
1680 if (mflags & (Style_Down | Style_On | Style_Raised))
1681 drawPrimitive(PE_ButtonDropDown, p, menuarea, cg, mflags, opt);
1682 drawPrimitive(PE_ArrowDown, p, menuarea, cg, mflags, opt);
1685 if (toolbutton->hasFocus() && !toolbutton->focusProxy()) {
1686 QRect fr = toolbutton->rect();
1687 fr.adjust(3, 3, -3, -3);
1688 drawPrimitive(PE_FocusRect, p, fr, cg);
1691 break;
1695 default:
1696 KStyle::drawComplexControl(control, p, widget,
1697 r, cg, flags, controls, active, opt);
1698 break;
1703 void HighColorStyle::drawComplexControlMask( ComplexControl control,
1704 QPainter *p,
1705 const QWidget *widget,
1706 const QRect &r,
1707 const QStyleOption& opt ) const
1709 switch (control)
1711 // COMBOBOX & TOOLBUTTON MASKS
1712 // -------------------------------------------------------------------
1713 case CC_ComboBox:
1714 case CC_ToolButton: {
1715 int x1, y1, x2, y2;
1716 r.getCoords( &x1, &y1, &x2, &y2 );
1717 QCOORD corners[] = { x1,y1, x2,y1, x1,y2, x2,y2 };
1718 p->fillRect( r, Qt::color1 );
1719 p->setPen( Qt::color0 );
1720 p->drawPoints( Q3PointArray(4, corners) );
1721 break;
1724 default:
1725 KStyle::drawComplexControlMask(control, p, widget, r, opt);
1730 void HighColorStyle::drawItem( QPainter *p,
1731 const QRect &r,
1732 int flags,
1733 const QColorGroup &cg,
1734 bool enabled,
1735 const QPixmap *pixmap,
1736 const QString &text,
1737 int len,
1738 const QColor *penColor ) const
1740 // We only reimplement this method this so we can override the
1741 // text color used for widgets when we draw them with the selection
1742 // color and Qt expects them to be drawn them with the button color.
1743 // -------------------------------------------------------------------
1744 const QColor *col;
1746 if ( selectionBackground ) {
1747 col = &cg.highlightedText();
1748 selectionBackground = false;
1749 } else
1750 col = penColor;
1752 KStyle::drawItem( p, r, flags, cg, enabled, pixmap,
1753 text, len, col );
1757 QRect HighColorStyle::subRect(SubRect r, const QWidget *widget) const
1759 // We want the focus rect for buttons to be adjusted from
1760 // the Qt3 defaults to be similar to Qt 2's defaults.
1761 // -------------------------------------------------------------------
1762 if (r == SR_PushButtonFocusRect ) {
1763 const QPushButton* button = (const QPushButton*) widget;
1764 QRect wrect(widget->rect());
1765 int dbw1 = 0, dbw2 = 0;
1767 if (button->isDefault() || button->autoDefault()) {
1768 dbw1 = pixelMetric(PM_ButtonDefaultIndicator, widget);
1769 dbw2 = dbw1 * 2;
1772 int dfw1 = pixelMetric(PM_DefaultFrameWidth, widget) * 2,
1773 dfw2 = dfw1 * 2;
1775 return QRect(wrect.x() + dfw1 + dbw1 + 1,
1776 wrect.y() + dfw1 + dbw1 + 1,
1777 wrect.width() - dfw2 - dbw2 - 1,
1778 wrect.height() - dfw2 - dbw2 - 1);
1779 } else
1780 return KStyle::subRect(r, widget);
1784 int HighColorStyle::pixelMetric(PixelMetric m, const QWidget *widget) const
1786 switch(m)
1788 // BUTTONS
1789 // -------------------------------------------------------------------
1790 case PM_ButtonMargin: // Space btw. frame and label
1791 return 4;
1793 case PM_ButtonDefaultIndicator: {
1794 if ( type == HighColor )
1795 return 0; // No indicator when highcolor
1796 else
1797 return 3;
1800 case PM_MenuButtonIndicator: { // Arrow width
1801 if ( type != B3 )
1802 return 8;
1803 else
1804 return 7;
1807 // CHECKBOXES / RADIO BUTTONS
1808 // -------------------------------------------------------------------
1809 case PM_ExclusiveIndicatorWidth: // Radiobutton size
1810 case PM_ExclusiveIndicatorHeight:
1811 case PM_IndicatorWidth: // Checkbox size
1812 case PM_IndicatorHeight: {
1813 return 13; // 13x13
1816 default:
1817 return KStyle::pixelMetric(m, widget);
1822 QSize HighColorStyle::sizeFromContents( ContentsType contents,
1823 const QWidget* widget,
1824 const QSize &contentSize,
1825 const QStyleOption& opt ) const
1827 switch (contents)
1829 // PUSHBUTTON SIZE
1830 // ------------------------------------------------------------------
1831 case CT_PushButton: {
1832 const QPushButton* button = (const QPushButton*) widget;
1833 int w = contentSize.width();
1834 int h = contentSize.height();
1835 int bm = pixelMetric( PM_ButtonMargin, widget );
1836 int fw = pixelMetric( PM_DefaultFrameWidth, widget ) * 2;
1838 w += bm + fw + 6; // ### Add 6 to make way for bold font.
1839 h += bm + fw;
1841 // Ensure we stick to standard width and heights.
1842 if ( button->isDefault() || button->autoDefault() ) {
1843 if ( w < 80 && !button->text().isEmpty() )
1844 w = 80;
1846 if ( type != HighColor ) {
1847 // Compensate for default indicator
1848 int di = pixelMetric( PM_ButtonDefaultIndicator );
1849 w += di * 2;
1850 h += di * 2;
1854 if ( h < 22 )
1855 h = 22;
1857 return QSize( w, h );
1861 // POPUPMENU ITEM SIZE
1862 // -----------------------------------------------------------------
1863 case CT_PopupMenuItem: {
1864 if ( ! widget || opt.isDefault() )
1865 return contentSize;
1867 const QMenu *popup = (const QMenu *) widget;
1868 bool checkable = popup->isCheckable();
1869 QMenuItem *mi = opt.menuItem();
1870 int maxpmw = opt.maxIconWidth();
1871 int w = contentSize.width(), h = contentSize.height();
1873 if ( mi->custom() ) {
1874 w = mi->custom()->sizeHint().width();
1875 h = mi->custom()->sizeHint().height();
1876 if ( ! mi->custom()->fullSpan() )
1877 h += 2*itemVMargin + 2*itemFrame;
1879 else if ( mi->widget() ) {
1880 } else if ( mi->isSeparator() ) {
1881 w = 10; // Arbitrary
1882 h = 2;
1884 else {
1885 if ( mi->pixmap() )
1886 h = qMax( h, mi->pixmap()->height() + 2*itemFrame );
1887 else {
1888 // Ensure that the minimum height for text-only menu items
1889 // is the same as the icon size used by KDE.
1890 h = qMax( h, 16 + 2*itemFrame );
1891 h = qMax( h, popup->fontMetrics().height()
1892 + 2*itemVMargin + 2*itemFrame );
1895 if ( mi->iconSet() )
1896 h = qMax( h, mi->iconSet()->pixmap(
1897 QIcon::Small, QIcon::Normal).height() +
1898 2 * itemFrame );
1901 if ( ! mi->text().isNull() && mi->text().find('\t') >= 0 )
1902 w += 12;
1903 else if ( mi->popup() )
1904 w += 2 * arrowHMargin;
1906 if ( maxpmw )
1907 w += maxpmw + 6;
1908 if ( checkable && maxpmw < 20 )
1909 w += 20 - maxpmw;
1910 if ( checkable || maxpmw > 0 )
1911 w += 12;
1913 w += rightBorder;
1915 return QSize( w, h );
1919 default:
1920 return KStyle::sizeFromContents( contents, widget, contentSize, opt );
1925 // Fix Qt's wacky image alignment
1926 QPixmap HighColorStyle::stylePixmap(StylePixmap stylepixmap,
1927 const QWidget* widget,
1928 const QStyleOption& opt) const
1930 switch (stylepixmap) {
1931 case SP_TitleBarMinButton:
1932 return QPixmap((const char **)hc_minimize_xpm);
1933 case SP_TitleBarCloseButton:
1934 return QPixmap((const char **)hc_close_xpm);
1935 default:
1936 break;
1939 return KStyle::stylePixmap(stylepixmap, widget, opt);
1943 bool HighColorStyle::eventFilter( QObject *object, QEvent *event )
1945 if (KStyle::eventFilter( object, event ))
1946 return true;
1948 Q3ToolBar* toolbar;
1950 // Handle push button hover effects.
1951 QPushButton* button = dynamic_cast<QPushButton*>(object);
1952 if ( button )
1954 if ( (event->type() == QEvent::Enter) &&
1955 (button->isEnabled()) ) {
1956 hoverWidget = button;
1957 button->repaint( false );
1959 else if ( (event->type() == QEvent::Leave) &&
1960 (object == hoverWidget) ) {
1961 hoverWidget = 0L;
1962 button->repaint( false );
1964 } else if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) )
1966 // Draw a gradient background for custom widgets in the toolbar
1967 // that have specified a "kde toolbar widget" name.
1969 if (event->type() == QEvent::Paint ) {
1970 // Find the top-level toolbar of this widget, since it may be nested in other
1971 // widgets that are on the toolbar.
1972 QWidget *widget = static_cast<QWidget*>(object);
1973 QWidget *parent = static_cast<QWidget*>(object->parent());
1974 int x_offset = widget->x(), y_offset = widget->y();
1975 while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) )
1977 x_offset += parent->x();
1978 y_offset += parent->y();
1979 parent = static_cast<QWidget*>(parent->parent());
1982 QRect r = widget->rect();
1983 QRect pr = parent->rect();
1984 bool horiz_grad = pr.width() < pr.height();
1986 // Check if the parent is a QToolbar, and use its orientation, else guess.
1987 Q3ToolBar* tb = dynamic_cast<Q3ToolBar*>(parent);
1988 if (tb) horiz_grad = tb->orientation() == Qt::Vertical;
1990 QPainter p( widget );
1991 renderGradient(&p, r, parent->colorGroup().button(), horiz_grad,
1992 x_offset, y_offset, pr.width(), pr.height());
1994 return false; // Now draw the contents
1996 } else if ( object->parent() &&
1997 (toolbar = dynamic_cast<Q3ToolBar*>(object->parent())) )
1999 // We need to override the paint event to draw a
2000 // gradient on a QToolBarExtensionWidget.
2001 if ( event->type() == QEvent::Paint ) {
2002 QWidget *widget = static_cast<QWidget*>(object);
2003 QRect wr = widget->rect(), tr = toolbar->rect();
2004 QPainter p( widget );
2005 renderGradient(&p, wr, toolbar->colorGroup().button(),
2006 toolbar->orientation() == Qt::Vertical,
2007 wr.x(), wr.y(), tr.width() - 2, tr.height() - 2);
2009 p.setPen( toolbar->colorGroup().dark() );
2010 if ( toolbar->orientation() == Qt::Horizontal )
2011 p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 );
2012 else
2013 p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 );
2015 return true;
2019 return false;
2023 void HighColorStyle::renderGradient( QPainter* p, const QRect& r,
2024 QColor clr, bool horizontal, int px, int py, int pwidth, int pheight) const
2026 // Make 8 bit displays happy
2027 if (!highcolor) {
2028 p->fillRect(r, clr);
2029 return;
2032 // px, py specify the gradient pixmap offset relative to the top-left corner.
2033 // pwidth, pheight specify the width and height of the parent's pixmap.
2034 // We use these to draw parent-relative pixmaps for toolbar buttons
2035 // and menubar items.
2037 GradientSet* grSet = gDict.find( clr.rgb() );
2039 if (!grSet) {
2040 grSet = new GradientSet(clr);
2041 gDict.insert( clr.rgb(), grSet );
2044 if (horizontal) {
2045 int width = (pwidth != -1) ? pwidth : r.width();
2047 if (width <= 34)
2048 p->drawTiledPixmap(r, *grSet->gradient(HMed), QPoint(px, 0));
2049 else if (width <= 52)
2050 p->drawTiledPixmap(r, *grSet->gradient(HLarge), QPoint(px, 0));
2051 else {
2052 KPixmap *hLarge = grSet->gradient(HLarge);
2054 // Don't draw a gradient if we don't need to
2055 if (hLarge->width() > px)
2057 int pixmapWidth = hLarge->width() - px;
2059 // Draw the gradient
2060 p->drawTiledPixmap( r.x(), r.y(), pixmapWidth, r.height(),
2061 *hLarge, px, 0 );
2062 // Draw the remaining fill
2063 p->fillRect(r.x()+pixmapWidth, r.y(), r.width()-pixmapWidth,
2064 r.height(), clr.dark(110));
2066 } else
2067 p->fillRect(r, clr.dark(110));
2070 } else {
2071 // Vertical gradient
2072 // -----------------
2073 int height = (pheight != -1) ? pheight : r.height();
2075 if (height <= 24)
2076 p->drawTiledPixmap(r, *grSet->gradient(VSmall), QPoint(0, py));
2077 else if (height <= 34)
2078 p->drawTiledPixmap(r, *grSet->gradient(VMed), QPoint(0, py));
2079 else if (height <= 64)
2080 p->drawTiledPixmap(r, *grSet->gradient(VLarge), QPoint(0, py));
2081 else {
2082 KPixmap *vLarge = grSet->gradient(VLarge);
2084 // Only draw the upper gradient if we need to.
2085 if (vLarge->height() > py)
2087 int pixmapHeight = vLarge->height() - py;
2089 // Draw the gradient
2090 p->drawTiledPixmap( r.x(), r.y(), r.width(), pixmapHeight,
2091 *vLarge, 0, py );
2092 // Draw the remaining fill
2093 p->fillRect(r.x(), r.y()+pixmapHeight, r.width(),
2094 r.height()-pixmapHeight, clr.dark(110));
2096 } else
2097 p->fillRect(r, clr.dark(110));
2103 // vim: set noet ts=4 sw=4: