summaryrefslogtreecommitdiff
Unidiff
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,165 +1,165 @@
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)
@@ -596,257 +596,257 @@ WebStyle::scrollBarPointOver
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