summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/phase/phasestyle.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp
index fb6411c..139505f 100644
--- a/noncore/styles/phase/phasestyle.cpp
+++ b/noncore/styles/phase/phasestyle.cpp
@@ -1,1221 +1,1220 @@
1////////////////////////////////////////////////////////////////////////////// 1//////////////////////////////////////////////////////////////////////////////
2// phasestyle.h 2// phasestyle.h
3// ------------------- 3// -------------------
4// A style for KDE 4// A style for KDE
5// ------------------- 5// -------------------
6// Copyright (c) 2004 David Johnson <david@usermode.org> 6// Copyright (c) 2004 David Johnson <david@usermode.org>
7// 7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy 8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to 9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the 10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is 12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions: 13// furnished to do so, subject to the following conditions:
14// 14//
15// The above copyright notice and this permission notice shall be included in 15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software. 16// all copies or substantial portions of the Software.
17// 17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE. 24// IN THE SOFTWARE.
25////////////////////////////////////////////////////////////////////////////// 25//////////////////////////////////////////////////////////////////////////////
26 26
27#include "phasestyle.h" 27#include "phasestyle.h"
28 28
29#include "bitmaps.h" 29#include "bitmaps.h"
30 30
31#define INCLUDE_MENUITEM_DEF 31#define INCLUDE_MENUITEM_DEF
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qtoolbutton.h> 34#include <qtoolbutton.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qbrush.h> 36#include <qbrush.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qtabbar.h> 38#include <qtabbar.h>
39#include <qscrollbar.h> 39#include <qscrollbar.h>
40 40
41 41
42/* Spacing and sizeHint */ 42/* Spacing and sizeHint */
43static unsigned contrast = 110; 43static unsigned contrast = 110;
44 44
45static const int ITEMFRAME = 1; // menu stuff 45static const int ITEMFRAME = 1; // menu stuff
46static const int ITEMHMARGIN = 3; 46static const int ITEMHMARGIN = 3;
47static const int ITEMVMARGIN = 0; 47static const int ITEMVMARGIN = 0;
48 48
49static const int ARROWMARGIN = 6; 49static const int ARROWMARGIN = 6;
50static const int RIGHTBORDER = 10; 50static const int RIGHTBORDER = 10;
51static const int MINICONSIZE = 12; 51static const int MINICONSIZE = 12;
52static const int CHECKSIZE = 9; 52static const int CHECKSIZE = 9;
53static const int SCROLLBAR_EXTENT = 12; 53static const int SCROLLBAR_EXTENT = 12;
54 54
55 55
56/* 56/*
57 * Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> 57 * Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
58 * LGPLv2 from kdelibs/kdefx/kdrawutil.cpp 58 * LGPLv2 from kdelibs/kdefx/kdrawutil.cpp
59 */ 59 */
60void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y, 60void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y,
61 QBitmap *lightColor, QBitmap *midColor, 61 QBitmap *lightColor, QBitmap *midColor,
62 QBitmap *midlightColor, QBitmap *darkColor, 62 QBitmap *midlightColor, QBitmap *darkColor,
63 QBitmap *blackColor, QBitmap *whiteColor) 63 QBitmap *blackColor, QBitmap *whiteColor)
64{ 64{
65 QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor, 65 QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
66 blackColor, whiteColor}; 66 blackColor, whiteColor};
67 67
68 QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(), 68 QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
69 Qt::black, Qt::white}; 69 Qt::black, Qt::white};
70 70
71 int i; 71 int i;
72 for(i=0; i < 6; ++i){ 72 for(i=0; i < 6; ++i){
73 if(bitmaps[i]){ 73 if(bitmaps[i]){
74 if(!bitmaps[i]->mask()) 74 if(!bitmaps[i]->mask())
75 bitmaps[i]->setMask(*bitmaps[i]); 75 bitmaps[i]->setMask(*bitmaps[i]);
76 p->setPen(colors[i]); 76 p->setPen(colors[i]);
77 p->drawPixmap(x, y, *bitmaps[i]); 77 p->drawPixmap(x, y, *bitmaps[i]);
78 } 78 }
79 } 79 }
80} 80}
81 81
82 82
83/* 83/*
84 * drawMenuBarItem is not virtual 84 * drawMenuBarItem is not virtual
85 * this way we define our draw handler 85 * this way we define our draw handler
86 */ 86 */
87typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 87typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
88 QColorGroup &, bool, bool); 88 QColorGroup &, bool, bool);
89 89
90extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 90extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
91 91
92 92
93PhaseStyle::PhaseStyle() 93PhaseStyle::PhaseStyle()
94 : QWindowsStyle() 94 : QWindowsStyle()
95{ 95{
96 setName( "PhaseStyle" ); 96 setName( "PhaseStyle" );
97 97
98 /* small default sizes */ 98 /* small default sizes */
99 setButtonDefaultIndicatorWidth(1); 99 setButtonDefaultIndicatorWidth(1);
100 setScrollBarExtent(SCROLLBAR_EXTENT, SCROLLBAR_EXTENT); 100 setScrollBarExtent(SCROLLBAR_EXTENT, SCROLLBAR_EXTENT);
101 setSliderThickness(12); 101 setSliderThickness(12);
102 setButtonMargin( 1 ); 102 setButtonMargin( 1 );
103 103
104 // create bitmaps 104 // create bitmaps
105 uarrow = QBitmap(6, 6, uarrow_bits, true); 105 uarrow = QBitmap(6, 6, uarrow_bits, true);
106 uarrow.setMask(uarrow); 106 uarrow.setMask(uarrow);
107 darrow = QBitmap(6, 6, darrow_bits, true); 107 darrow = QBitmap(6, 6, darrow_bits, true);
108 darrow.setMask(darrow); 108 darrow.setMask(darrow);
109 larrow = QBitmap(6, 6, larrow_bits, true); 109 larrow = QBitmap(6, 6, larrow_bits, true);
110 larrow.setMask(larrow); 110 larrow.setMask(larrow);
111 rarrow = QBitmap(6, 6, rarrow_bits, true); 111 rarrow = QBitmap(6, 6, rarrow_bits, true);
112 rarrow.setMask(rarrow); 112 rarrow.setMask(rarrow);
113 bplus = QBitmap(6, 6, bplus_bits, true); 113 bplus = QBitmap(6, 6, bplus_bits, true);
114 bplus.setMask(bplus); 114 bplus.setMask(bplus);
115 bminus = QBitmap(6, 6, bminus_bits, true); 115 bminus = QBitmap(6, 6, bminus_bits, true);
116 bminus.setMask(bminus); 116 bminus.setMask(bminus);
117 bcheck = QBitmap(9, 9, bcheck_bits, true); 117 bcheck = QBitmap(9, 9, bcheck_bits, true);
118 bcheck.setMask(bcheck); 118 bcheck.setMask(bcheck);
119 dexpand = QBitmap(9, 9, dexpand_bits, true); 119 dexpand = QBitmap(9, 9, dexpand_bits, true);
120 dexpand.setMask(dexpand); 120 dexpand.setMask(dexpand);
121 rexpand = QBitmap(9, 9, rexpand_bits, true); 121 rexpand = QBitmap(9, 9, rexpand_bits, true);
122 rexpand.setMask(rexpand); 122 rexpand.setMask(rexpand);
123 doodad_mid = QBitmap(4, 4, doodad_mid_bits, true); 123 doodad_mid = QBitmap(4, 4, doodad_mid_bits, true);
124 doodad_light = QBitmap(4, 4, doodad_light_bits, true); 124 doodad_light = QBitmap(4, 4, doodad_light_bits, true);
125} 125}
126 126
127PhaseStyle::~PhaseStyle() { 127PhaseStyle::~PhaseStyle() {
128 /* deleted by Qt */ 128 /* deleted by Qt */
129} 129}
130 130
131void PhaseStyle::drawCheckMark ( QPainter * p, int x, int y, int w, 131void PhaseStyle::drawCheckMark ( QPainter * p, int x, int y, int w,
132 int h, const QColorGroup & g, 132 int h, const QColorGroup & g,
133 bool , bool) { 133 bool , bool) {
134 p->setPen(g.text()); 134 p->setPen(g.text());
135 p->drawPixmap(x+w/2-4, y+h/2-4, bcheck); 135 p->drawPixmap(x+w/2-4, y+h/2-4, bcheck);
136} 136}
137 137
138void PhaseStyle::drawArrow(QPainter *painter, Qt::ArrowType type, bool down, 138void PhaseStyle::drawArrow(QPainter *painter, Qt::ArrowType type, bool down,
139 int x, int y, int w, int h, const QColorGroup &group, 139 int x, int y, int w, int h, const QColorGroup &group,
140 bool enabled , const QBrush * ) { 140 bool enabled , const QBrush * ) {
141 switch( type ) { 141 switch( type ) {
142 case UpArrow: 142 case UpArrow:
143 if (enabled) 143 if (enabled)
144 painter->setPen(down ? group.midlight() : group.dark()); 144 painter->setPen(down ? group.midlight() : group.dark());
145 else painter->setPen(group.mid()); 145 else painter->setPen(group.mid());
146 painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow); 146 painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow);
147 break; 147 break;
148 case DownArrow: 148 case DownArrow:
149 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 149 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
150 else painter->setPen(group.mid()); 150 else painter->setPen(group.mid());
151 painter->drawPixmap(x+w/2-3, y+h/2-3, darrow); 151 painter->drawPixmap(x+w/2-3, y+h/2-3, darrow);
152 break; 152 break;
153 case LeftArrow: 153 case LeftArrow:
154 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 154 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
155 else painter->setPen(group.mid()); 155 else painter->setPen(group.mid());
156 painter->drawPixmap(x+w/2-3, y+h/2-3, larrow); 156 painter->drawPixmap(x+w/2-3, y+h/2-3, larrow);
157 break; 157 break;
158 case RightArrow: 158 case RightArrow:
159 if (enabled) painter->setPen(down ? group.midlight() : group.dark()); 159 if (enabled) painter->setPen(down ? group.midlight() : group.dark());
160 else painter->setPen(group.mid()); 160 else painter->setPen(group.mid());
161 painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow); 161 painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow);
162 break; 162 break;
163 } 163 }
164} 164}
165 165
166void PhaseStyle::drawPushButton(QPushButton *btn, QPainter *painter) { 166void PhaseStyle::drawPushButton(QPushButton *btn, QPainter *painter) {
167 QRect r = btn->rect(); 167 QRect r = btn->rect();
168 int x = r.x(); 168 int x = r.x();
169 int y = r.y(); 169 int y = r.y();
170 int h = r.height(); 170 int h = r.height();
171 int w = r.width(); 171 int w = r.width();
172 bool depress = btn->isOn() || btn->isDown(); 172 bool depress = btn->isOn() || btn->isDown();
173 QColorGroup group = btn->colorGroup(); 173 QColorGroup group = btn->colorGroup();
174 QBrush brush(group.button() ); 174 QBrush brush(group.button() );
175// int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1; 175// int bd = pixelMetric(PM_ButtonDefaultIndicator, widget) + 1;
176 static int bd = 2; 176 static int bd = 2;
177 177
178 if (btn->isDefault() && !depress) { 178 if (btn->isDefault() && !depress) {
179 drawPanel(painter, x, y, h, w, group, 179 drawPanel(painter, x, y, h, w, group,
180 &group.brush(QColorGroup::Mid), true); 180 &group.brush(QColorGroup::Mid), true);
181 drawBevelButton(painter, x+bd, y+bd, w-bd*2, h-bd*2, group, 181 drawBevelButton(painter, x+bd, y+bd, w-bd*2, h-bd*2, group,
182 false, &brush ); 182 false, &brush );
183 } else { 183 } else {
184 drawButton(painter, x, y, w, h, group, depress, 184 drawButton(painter, x, y, w, h, group, depress,
185 &brush ); 185 &brush );
186 } 186 }
187 187
188 if (btn->hasFocus() ) { // draw focus 188 if (btn->hasFocus() ) { // draw focus
189 QColor col; 189 QColor col;
190 drawFocusRect(painter, r, group, 190 drawFocusRect(painter, r, group,
191 &col, false ); 191 &col, false );
192 } 192 }
193} 193}
194 194
195 195
196void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h, 196void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h,
197 const QColorGroup& group, bool sunken, 197 const QColorGroup& group, bool sunken,
198 int , const QBrush* fill) { 198 int , const QBrush* fill) {
199 int x2 = x + w - 1; 199 int x2 = x + w - 1;
200 int y2 = y + h - 1; 200 int y2 = y + h - 1;
201 painter->save(); 201 painter->save();
202 202
203 if (sunken) { 203 if (sunken) {
204 painter->setPen(group.dark()); 204 painter->setPen(group.dark());
205 painter->drawRect(x+1, y+1, w-2, h-2); 205 painter->drawRect(x+1, y+1, w-2, h-2);
206 painter->setPen(group.midlight()); 206 painter->setPen(group.midlight());
207 painter->drawLine(x+1, y2, x2, y2); 207 painter->drawLine(x+1, y2, x2, y2);
208 painter->drawLine(x2, y+1, x2, y2-1); 208 painter->drawLine(x2, y+1, x2, y2-1);
209 painter->setPen(group.mid()); 209 painter->setPen(group.mid());
210 painter->drawLine(x, y, x, y2-1); 210 painter->drawLine(x, y, x, y2-1);
211 painter->drawLine(x+1, y, x2-1, y); 211 painter->drawLine(x+1, y, x2-1, y);
212 painter->setPen(group.background()); 212 painter->setPen(group.background());
213 painter->drawPoint(x, y2); 213 painter->drawPoint(x, y2);
214 painter->drawPoint(x2, y); 214 painter->drawPoint(x2, y);
215 } else { 215 } else {
216 painter->setPen(group.dark()); 216 painter->setPen(group.dark());
217 painter->drawRect(x, y, w, h); 217 painter->drawRect(x, y, w, h);
218 painter->setPen(group.midlight()); 218 painter->setPen(group.midlight());
219 painter->drawLine(x+1, y+1, x2-2, y+1); 219 painter->drawLine(x+1, y+1, x2-2, y+1);
220 painter->drawLine(x+1, y+2, x+1, y2-2); 220 painter->drawLine(x+1, y+2, x+1, y2-2);
221 painter->setPen(group.mid()); 221 painter->setPen(group.mid());
222 painter->drawLine(x+2, y2-1, x2-1, y2-1); 222 painter->drawLine(x+2, y2-1, x2-1, y2-1);
223 painter->drawLine(x2-1, y+2, x2-1, y2-2); 223 painter->drawLine(x2-1, y+2, x2-1, y2-2);
224 painter->setPen(group.background()); 224 painter->setPen(group.background());
225 painter->drawPoint(x+1, y2-1); 225 painter->drawPoint(x+1, y2-1);
226 painter->drawPoint(x2-1, y+1); 226 painter->drawPoint(x2-1, y+1);
227 } 227 }
228 228
229 if (fill) { 229 if (fill) {
230 painter->fillRect(x+2, y+2, w-4, h-4, *fill ); 230 painter->fillRect(x+2, y+2, w-4, h-4, *fill );
231 } 231 }
232 painter->restore(); 232 painter->restore();
233} 233}
234 234
235 235
236 236
237void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h, 237void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h,
238 const QColorGroup &group, bool sunken , 238 const QColorGroup &group, bool sunken ,
239 const QBrush *fill ) { 239 const QBrush *fill ) {
240 int x2 = x + w - 1; 240 int x2 = x + w - 1;
241 int y2 = y + h - 1; 241 int y2 = y + h - 1;
242 242
243 p->setPen(group.midlight()); 243 p->setPen(group.midlight());
244 p->drawLine(x+1, y2, x2, y2); 244 p->drawLine(x+1, y2, x2, y2);
245 p->drawLine(x2, y+1, x2, y2-1); 245 p->drawLine(x2, y+1, x2, y2-1);
246 246
247 p->setPen(group.mid()); 247 p->setPen(group.mid());
248 p->drawLine(x, y, x2-1, y); 248 p->drawLine(x, y, x2-1, y);
249 p->drawLine(x, y+1, x, y2-1); 249 p->drawLine(x, y+1, x, y2-1);
250 250
251 p->setPen(group.button()); 251 p->setPen(group.button());
252 p->drawPoint(x, y2); 252 p->drawPoint(x, y2);
253 p->drawPoint(x2, y); 253 p->drawPoint(x2, y);
254 254
255 drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken, 255 drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken,
256 fill); 256 fill);
257} 257}
258 258
259void PhaseStyle::drawButtonMask( QPainter* p, int x, int y, 259void PhaseStyle::drawButtonMask( QPainter* p, int x, int y,
260 int w, int h ) { 260 int w, int h ) {
261 QRect rect(x, y, w, h ); 261 QRect rect(x, y, w, h );
262 p->fillRect(rect, Qt::color1); 262 p->fillRect(rect, Qt::color1);
263 p->setPen(Qt::color0); 263 p->setPen(Qt::color0);
264} 264}
265 265
266 266
267void PhaseStyle::drawBevelButton(QPainter* p, int x, int y, 267void PhaseStyle::drawBevelButton(QPainter* p, int x, int y,
268 int w, int h, const QColorGroup& group, 268 int w, int h, const QColorGroup& group,
269 bool sunken, const QBrush* fill ) { 269 bool sunken, const QBrush* fill ) {
270 int x2 = x + w - 1; 270 int x2 = x + w - 1;
271 int y2 = y + h - 1; 271 int y2 = y + h - 1;
272 p->save(); 272 p->save();
273 273
274 p->setPen(group.dark()); 274 p->setPen(group.dark());
275 p->drawRect(x, y, w, h); 275 p->drawRect(x, y, w, h);
276 276
277 p->setPen(sunken ? group.mid() : group.midlight()); 277 p->setPen(sunken ? group.mid() : group.midlight());
278 p->drawLine(x+1, y+1, x2-2, y+1); 278 p->drawLine(x+1, y+1, x2-2, y+1);
279 p->drawLine(x+1, y+2, x+1, y2-2); 279 p->drawLine(x+1, y+2, x+1, y2-2);
280 280
281 p->setPen(sunken ? group.midlight() : group.mid()); 281 p->setPen(sunken ? group.midlight() : group.mid());
282 p->drawLine(x+2, y2-1, x2-1, y2-1); 282 p->drawLine(x+2, y2-1, x2-1, y2-1);
283 p->drawLine(x2-1, y+2, x2-1, y2-2); 283 p->drawLine(x2-1, y+2, x2-1, y2-2);
284 284
285 p->setPen(group.button()); 285 p->setPen(group.button());
286 p->drawPoint(x+1, y2-1); 286 p->drawPoint(x+1, y2-1);
287 p->drawPoint(x2-1, y+1); 287 p->drawPoint(x2-1, y+1);
288 288
289 QBrush b = fill ? *fill : group.brush( QColorGroup::Button ); 289 QBrush b = fill ? *fill : group.brush( QColorGroup::Button );
290 if (sunken) { 290 if (sunken) {
291 // sunken bevels don't get gradients 291 // sunken bevels don't get gradients
292 p->fillRect(x+2, y+2, w-4, h-4, b); 292 p->fillRect(x+2, y+2, w-4, h-4, b);
293 } else 293 } else
294 drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() ); 294 drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() );
295 295
296 p->restore(); 296 p->restore();
297} 297}
298 298
299void PhaseStyle::drawPhaseGradient(QPainter* painter, 299void PhaseStyle::drawPhaseGradient(QPainter* painter,
300 const QRect& rect, 300 const QRect& rect,
301 const QColor& color )const { 301 const QColor& color )const {
302 painter->fillRect(rect, color); 302 painter->fillRect(rect, color);
303} 303}
304 304
305void PhaseStyle::polish( QWidget* widget ) { 305void PhaseStyle::polish( QWidget* widget ) {
306 QWindowsStyle::polish(widget ); 306 QWindowsStyle::polish(widget );
307 307
308#if 0 308#if 0
309 if (widget->inherits("QMenuBar") || 309 if (widget->inherits("QMenuBar") ||
310 widget->inherits("QPopupMenu" ) || 310 widget->inherits("QPopupMenu" ) ||
311 widget->inherits("QToolButton") || 311 widget->inherits("QToolButton") ||
312 widget->inherits("QHeader" ) ) { 312 widget->inherits("QHeader" ) ) {
313 widget->setBackgroundMode(QWidget::NoBackground); 313 widget->setBackgroundMode(QWidget::NoBackground);
314 } 314 }
315// else if (widget->inherits("QFrame") ) { 315// else if (widget->inherits("QFrame") ) {
316// widget->installEventFilter(this); 316// widget->installEventFilter(this);
317// } 317// }
318#endif 318#endif
319} 319}
320 320
321void PhaseStyle::polish( QPalette &pal ) { 321void PhaseStyle::polish( QPalette &pal ) {
322 QWindowsStyle::polish( pal ); 322 QWindowsStyle::polish( pal );
323 // lighten up a bit, so the look is not so "crisp" 323 // lighten up a bit, so the look is not so "crisp"
324 if (QPixmap::defaultDepth() > 8) { // but not on low color displays 324 if (QPixmap::defaultDepth() > 8) { // but not on low color displays
325 pal.setColor(QPalette::Disabled, QColorGroup::Dark, 325 pal.setColor(QPalette::Disabled, QColorGroup::Dark,
326 pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast)); 326 pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast));
327 pal.setColor(QPalette::Active, QColorGroup::Dark, 327 pal.setColor(QPalette::Active, QColorGroup::Dark,
328 pal.color(QPalette::Active, QColorGroup::Dark).light(contrast)); 328 pal.color(QPalette::Active, QColorGroup::Dark).light(contrast));
329 pal.setColor(QPalette::Inactive, QColorGroup::Dark, 329 pal.setColor(QPalette::Inactive, QColorGroup::Dark,
330 pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast)); 330 pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast));
331 } 331 }
332} 332}
333 333
334void PhaseStyle::polish( QApplication* app ) { 334void PhaseStyle::polish( QApplication* app ) {
335 QWindowsStyle::polish( app ); 335 QWindowsStyle::polish( app );
336 336
337 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem); 337 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem);
338} 338}
339 339
340void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) { 340void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
341 bool active = button->isOn() || button->isDown(); 341 bool active = button->isOn() || button->isDown();
342 QRect r = pushButtonContentsRect( button ); 342 QRect r = pushButtonContentsRect( button );
343 QColorGroup group = button->colorGroup(); 343 QColorGroup group = button->colorGroup();
344 int x, y, w, h; 344 int x, y, w, h;
345 r.rect( &x, &y, &w, &h ); 345 r.rect( &x, &y, &w, &h );
346 bool sunken = false; 346 bool sunken = false;
347 QIconSet::Mode mode; 347 QIconSet::Mode mode;
348 QPixmap pixmap; 348 QPixmap pixmap;
349 349
350 if (active) {// shift contents 350 if (active) {// shift contents
351 x++; y++; 351 x++; y++;
352 sunken = true; 352 sunken = true;
353 } 353 }
354 354
355 355
356 if (button->isMenuButton()) { // draw the indicator 356 if (button->isMenuButton()) { // draw the indicator
357 //dx = pixelMetric(PM_MenuButtonIndicator, widget); 357 //dx = pixelMetric(PM_MenuButtonIndicator, widget);
358 int dx = menuButtonIndicatorWidth( button->height() ); 358 int dx = menuButtonIndicatorWidth( button->height() );
359 drawArrow(painter, Qt::DownArrow, active, 359 drawArrow(painter, Qt::DownArrow, active,
360 x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() ); 360 x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() );
361 w -= dx; 361 w -= dx;
362 } 362 }
363 363
364 if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon 364 if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon
365 if (button->isEnabled()) { 365 if (button->isEnabled()) {
366 if (button->hasFocus()) { 366 if (button->hasFocus()) {
367 mode = QIconSet::Active; 367 mode = QIconSet::Active;
368 } else { 368 } else {
369 mode = QIconSet::Normal; 369 mode = QIconSet::Normal;
370 } 370 }
371 } else { 371 } else {
372 mode = QIconSet::Disabled; 372 mode = QIconSet::Disabled;
373 } 373 }
374 374
375#if 0 375#if 0
376 if (button->isToggleButton() && button->isOn()) { 376 if (button->isToggleButton() && button->isOn()) {
377 state = true; 377 state = true;
378 } else { 378 } else {
379 state = false; 379 state = false;
380 } 380 }
381#endif 381#endif
382 382
383 pixmap = button->iconSet()->pixmap(QIconSet::Small, mode); 383 pixmap = button->iconSet()->pixmap(QIconSet::Small, mode);
384 if (button->text().isEmpty() && !button->pixmap()) { 384 if (button->text().isEmpty() && !button->pixmap()) {
385 painter->drawPixmap(x+w/2 - pixmap.width()/2, 385 painter->drawPixmap(x+w/2 - pixmap.width()/2,
386 y+h/2 - pixmap.height()/2, pixmap); 386 y+h/2 - pixmap.height()/2, pixmap);
387 } else { 387 } else {
388 painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap); 388 painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
389 } 389 }
390 x += pixmap.width() + 4; 390 x += pixmap.width() + 4;
391 w -= pixmap.width() + 4; 391 w -= pixmap.width() + 4;
392 } 392 }
393 393
394 if (active || button->isDefault()) { // default button 394 if (active || button->isDefault()) { // default button
395 for(int n=0; n<2; n++) { 395 for(int n=0; n<2; n++) {
396 drawItem(painter, x+n, y, w, h, 396 drawItem(painter, x+n, y, w, h,
397 AlignCenter | ShowPrefix, 397 AlignCenter | ShowPrefix,
398 button->colorGroup(), 398 button->colorGroup(),
399 button->isEnabled(), 399 button->isEnabled(),
400 button->pixmap(), 400 button->pixmap(),
401 button->text(), -1, 401 button->text(), -1,
402 (button->isEnabled()) ? 402 (button->isEnabled()) ?
403 &button->colorGroup().buttonText() : 403 &button->colorGroup().buttonText() :
404 &button->colorGroup().mid()); 404 &button->colorGroup().mid());
405 } 405 }
406 } else { // normal button 406 } else { // normal button
407 drawItem(painter, x, y, w, h, 407 drawItem(painter, x, y, w, h,
408 AlignCenter | ShowPrefix, 408 AlignCenter | ShowPrefix,
409 button->colorGroup(), 409 button->colorGroup(),
410 button->isEnabled(), 410 button->isEnabled(),
411 button->pixmap(), 411 button->pixmap(),
412 button->text(), -1, 412 button->text(), -1,
413 (button->isEnabled()) ? 413 (button->isEnabled()) ?
414 &button->colorGroup().buttonText() : 414 &button->colorGroup().buttonText() :
415 &button->colorGroup().mid()); 415 &button->colorGroup().mid());
416 } 416 }
417} 417}
418 418
419 419
420void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect, 420void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect,
421 const QColorGroup &group, 421 const QColorGroup &group,
422 const QColor *, bool atBorder) { 422 const QColor *, bool atBorder) {
423 423
424 424
425 QPen old = painter->pen(); 425 QPen old = painter->pen();
426 painter->setPen(group.highlight().dark(contrast)); 426 painter->setPen(group.highlight().dark(contrast));
427 painter->setBrush(NoBrush); 427 painter->setBrush(NoBrush);
428 428
429 if ( atBorder ) 429 if ( atBorder )
430 painter->drawRect(QRect(rect.x()+1, rect.y()+1, 430 painter->drawRect(QRect(rect.x()+1, rect.y()+1,
431 rect.width()-2, rect.height()-2 )); 431 rect.width()-2, rect.height()-2 ));
432 else 432 else
433 painter->drawRect(rect); 433 painter->drawRect(rect);
434 434
435 435
436 painter->setPen(old); 436 painter->setPen(old);
437 437
438} 438}
439 439
440void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w, 440void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w,
441 int h, const QColorGroup& group, bool, 441 int h, const QColorGroup& group, bool,
442 int , int ) { 442 int , int ) {
443 qWarning( "Seperator" ); 443 qWarning( "Seperator" );
444 QRect rect(x, y, w, h); 444 QRect rect(x, y, w, h);
445 int x2 = rect.right(); 445 int x2 = rect.right();
446 int y2 = rect.bottom(); 446 int y2 = rect.bottom();
447 447
448 painter->setPen(group.dark()); 448 painter->setPen(group.dark());
449 if (w < h) 449 if (w < h)
450 painter->drawLine(w/2, y, w/2, y2); 450 painter->drawLine(w/2, y, w/2, y2);
451 else 451 else
452 painter->drawLine(x, h/2, x2, h/2); 452 painter->drawLine(x, h/2, x2, h/2);
453} 453}
454 454
455void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h, 455void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h,
456 QMenuItem *mi, QColorGroup& g, bool enabled, 456 QMenuItem *mi, QColorGroup& g, bool enabled,
457 bool act ) { 457 bool act ) {
458 return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act); 458 return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act);
459} 459}
460 460
461 461
462void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h, 462void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h,
463 const QColorGroup &group, int state, bool, 463 const QColorGroup &group, int state, bool,
464 bool enabled ) { 464 bool enabled ) {
465 drawPanel(painter, x, y, w, h, group, true, 1, enabled ? 465 drawPanel(painter, x, y, w, h, group, true, 1, enabled ?
466 &group.brush(QColorGroup::Base) : 466 &group.brush(QColorGroup::Base) :
467 &group.brush(QColorGroup::Background)); 467 &group.brush(QColorGroup::Background));
468 468
469 if (QButton::On == state ) { 469 if (QButton::On == state ) {
470 painter->setPen(group.dark()); 470 painter->setPen(group.dark());
471 painter->drawRect(x+3, y+3, w-6, h-6); 471 painter->drawRect(x+3, y+3, w-6, h-6);
472 painter->fillRect(x+4, y+4, w-8, h-8, 472 painter->fillRect(x+4, y+4, w-8, h-8,
473 group.brush(QColorGroup::Highlight)); 473 group.brush(QColorGroup::Highlight));
474 } 474 }
475} 475}
476 476
477 477
478void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h, 478void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h,
479 const QColorGroup &group, bool on, 479 const QColorGroup &group, bool on,
480 bool /*down*/, bool enabled) { 480 bool /*down*/, bool enabled) {
481 481
482 QRect r(x, y, w, h ); 482 QRect r(x, y, w, h );
483 483
484 484
485 /* 485 /*
486 * As Polygon and Polyline are broken in Qt2 lets use 486 * As Polygon and Polyline are broken in Qt2 lets use
487 * something not that spectacilur -> ellipse 487 * something not that spectacilur -> ellipse
488 */ 488 */
489 painter->save(); 489 painter->save();
490 painter->fillRect(x, y, w, h, group.background()); 490 painter->fillRect(x, y, w, h, group.background());
491 491
492 492
493 painter->setBrush(enabled 493 painter->setBrush(enabled
494 ? group.brush(QColorGroup::Base) 494 ? group.brush(QColorGroup::Base)
495 : group.brush(QColorGroup::Background)); 495 : group.brush(QColorGroup::Background));
496 painter->setPen(group.dark()); 496 painter->setPen(group.dark());
497 497
498 if (0 == w % 2) --w; 498 if (0 == w % 2) --w;
499 if (0 == h % 2) --h; 499 if (0 == h % 2) --h;
500 painter->drawEllipse(x, y, w, h ); 500 painter->drawEllipse(x, y, w, h );
501 501
502 if(on) { 502 if(on) {
503 painter->setBrush(group.brush(QColorGroup::Highlight)); 503 painter->setBrush(group.brush(QColorGroup::Highlight));
504 painter->drawEllipse(x+3,y+3,w-6,h-6); 504 painter->drawEllipse(x+3,y+3,w-6,h-6);
505 } 505 }
506 506
507 painter->restore(); 507 painter->restore();
508} 508}
509 509
510 510
511/* 511/*
512 * Does not get called in QWS as it seems 512 * Does not get called in QWS as it seems
513 */ 513 */
514void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w, 514void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w,
515 int h, bool /*on*/ ) { 515 int h, bool /*on*/ ) {
516 return; 516 return;
517 517
518 518
519 519
520 if (0 != w%2) --w; 520 if (0 != w%2) --w;
521 if (0 != h%2) --h; 521 if (0 != h%2) --h;
522 522
523 QRect r(x, y, w, h ); 523 QRect r(x, y, w, h );
524 int x2 = r.right(); 524 int x2 = r.right();
525 int y2 = r.bottom(); 525 int y2 = r.bottom();
526 int cx = (x + x2) / 2; 526 int cx = (x + x2) / 2;
527 int cy = (y + y2) / 2; 527 int cy = (y + y2) / 2;
528 QPointArray parray; 528 QPointArray parray;
529 529
530 530
531 painter->setBrush(Qt::color1); 531 painter->setBrush(Qt::color1);
532 painter->setPen(Qt::color1); 532 painter->setPen(Qt::color1);
533 parray.putPoints(0, 8, 533 parray.putPoints(0, 8,
534 x,cy+1, x,cy, cx,y, cx+1,y, 534 x,cy+1, x,cy, cx,y, cx+1,y,
535 x2,cy, x2,cy+1, cx+1,y2, cx,y2); 535 x2,cy, x2,cy+1, cx+1,y2, cx,y2);
536 painter->drawPolygon(parray, 0, 8); 536 painter->drawPolygon(parray, 0, 8);
537} 537}
538 538
539int PhaseStyle::defaultFrameWidth()const { 539int PhaseStyle::defaultFrameWidth()const {
540 return 1; 540 return 1;
541} 541}
542 542
543int PhaseStyle::popupMenuItemHeight ( bool , 543int PhaseStyle::popupMenuItemHeight ( bool ,
544 QMenuItem * mi, 544 QMenuItem * mi,
545 const QFontMetrics & fm ) { 545 const QFontMetrics & fm ) {
546 int h = 0; 546 int h = 0;
547 if (mi->custom() ) { 547 if (mi->custom() ) {
548 h = mi->custom()->sizeHint().height(); 548 h = mi->custom()->sizeHint().height();
549 if (!mi->custom()->fullSpan() ) 549 if (!mi->custom()->fullSpan() )
550 h += ITEMVMARGIN*2 + ITEMFRAME*2; 550 h += ITEMVMARGIN*2 + ITEMFRAME*2;
551 }else if (mi->isSeparator() ) { 551 }else if (mi->isSeparator() ) {
552 h = 1; 552 h = 1;
553 }else { 553 }else {
554 if ( mi->pixmap() ) { 554 if ( mi->pixmap() ) {
555 h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2); 555 h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2);
556 }else { 556 }else {
557 h = QMAX(h, MINICONSIZE+ITEMFRAME*2 ); 557 h = QMAX(h, MINICONSIZE+ITEMFRAME*2 );
558 h = QMAX(h, fm.height() 558 h = QMAX(h, fm.height()
559 + ITEMVMARGIN*2 + ITEMFRAME*2 ); 559 + ITEMVMARGIN*2 + ITEMFRAME*2 );
560 } 560 }
561 if ( mi->iconSet() ) 561 if ( mi->iconSet() )
562 h = QMAX(h, mi->iconSet()-> 562 h = QMAX(h, mi->iconSet()->
563 pixmap(QIconSet::Small, QIconSet::Normal ).height() 563 pixmap(QIconSet::Small, QIconSet::Normal ).height()
564 + ITEMFRAME*2 ); 564 + ITEMFRAME*2 );
565 } 565 }
566 566
567 567
568 return h; 568 return h;
569} 569}
570 570
571int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw, 571int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw,
572 QMenuItem* mi, const QFontMetrics& ) { 572 QMenuItem* mi, const QFontMetrics& ) {
573 int w = 0; 573 int w = 0;
574 if (mi->isSeparator() ) 574 if (mi->isSeparator() )
575 return 3; 575 return 3;
576 576
577 else if ( mi->pixmap() ) 577 else if ( mi->pixmap() )
578 w = mi->pixmap()->width(); 578 w = mi->pixmap()->width();
579 579
580 if (!mi->text().isNull() && 580 if (!mi->text().isNull() &&
581 mi->text().find('\t' ) >= 0 ) 581 mi->text().find('\t' ) >= 0 )
582 w += 12; 582 w += 12;
583 else if ( mi->popup() ) 583 else if ( mi->popup() )
584 w += 2*ARROWMARGIN; 584 w += 2*ARROWMARGIN;
585 585
586 if ( maxpmw ) 586 if ( maxpmw )
587 w += maxpmw +4; 587 w += maxpmw +4;
588 588
589 589
590 if ( maxpmw > 0 || checkable ) 590 if ( maxpmw > 0 || checkable )
591 w += ITEMHMARGIN*2+8; 591 w += ITEMHMARGIN*2+8;
592 592
593 w += RIGHTBORDER; 593 w += RIGHTBORDER;
594 return w; 594 return w;
595} 595}
596 596
597QSize PhaseStyle::indicatorSize()const { 597QSize PhaseStyle::indicatorSize()const {
598 return QSize( 11, 11 ); 598 return QSize( 11, 11 );
599} 599}
600 600
601QSize PhaseStyle::exclusiveIndicatorSize()const { 601QSize PhaseStyle::exclusiveIndicatorSize()const {
602 return QSize( 11, 11 ); 602 return QSize( 11, 11 );
603} 603}
604 604
605void PhaseStyle::getButtonShift( int &x, int &y ) { 605void PhaseStyle::getButtonShift( int &x, int &y ) {
606 x++; 606 x++;
607 y++; 607 y++;
608} 608}
609 609
610void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable, 610void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
611 int maxpmw,int tabwidth, 611 int maxpmw,int tabwidth,
612 QMenuItem * mi, const QPalette & pal, 612 QMenuItem * mi, const QPalette & pal,
613 bool act, bool enabled, int x, 613 bool act, bool enabled, int x,
614 int y, int w, int h ) { 614 int y, int w, int h ) {
615 if ( !mi ) 615 if ( !mi )
616 return; 616 return;
617 617
618 QRect rect(x, y, w, h ); 618 QRect rect(x, y, w, h );
619 int x2, y2; 619 int x2, y2;
620 x2 = rect.right(); 620 x2 = rect.right();
621 y2 = rect.bottom(); 621 y2 = rect.bottom();
622 const QColorGroup& g = pal.active(); 622 const QColorGroup& g = pal.active();
623 QColorGroup itemg = !enabled ? pal.disabled() : pal.active(); 623 QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
624 624
625 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20); 625 if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
626 626
627 if (act && enabled ) 627 if (act && enabled )
628 p->fillRect(x, y, w, h, g.highlight() ); 628 p->fillRect(x, y, w, h, g.highlight() );
629 else 629 else
630 p->fillRect(x, y, w, h, g.background() ); 630 p->fillRect(x, y, w, h, g.background() );
631 631
632 // draw seperator 632 // draw seperator
633 if (mi->isSeparator() ) { 633 if (mi->isSeparator() ) {
634 p->setPen( g.dark() ); 634 p->setPen( g.dark() );
635 p->drawLine( x+8, y+1, x+w-8, y+1 ); 635 p->drawLine( x+8, y+1, x+w-8, y+1 );
636 636
637 p->setPen( g.mid() ); 637 p->setPen( g.mid() );
638 p->drawLine( x+8, y, x+w-8, y ); 638 p->drawLine( x+8, y, x+w-8, y );
639 p->drawPoint(x+w,y+1); 639 p->drawPoint(x+w,y+1);
640 640
641 p->setPen( g.midlight() ); 641 p->setPen( g.midlight() );
642 p->drawLine( x+8, y-1, x+w-8, y-1 ); 642 p->drawLine( x+8, y-1, x+w-8, y-1 );
643 p->drawPoint(x+8, y ); 643 p->drawPoint(x+8, y );
644 return; 644 return;
645 } 645 }
646 646
647 // draw icon 647 // draw icon
648 QIconSet::Mode mode; 648 QIconSet::Mode mode;
649 if ( mi->iconSet() && !mi->isChecked() ) { 649 if ( mi->iconSet() && !mi->isChecked() ) {
650 if ( act ) 650 if ( act )
651 mode = enabled ? QIconSet::Active : QIconSet::Disabled; 651 mode = enabled ? QIconSet::Active : QIconSet::Disabled;
652 else 652 else
653 mode = enabled ? QIconSet::Normal : QIconSet::Disabled; 653 mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
654 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode ); 654 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode );
655 QRect pmrect(0, 0, pixmap.width(), pixmap.height() ); 655 QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
656 QRect cr(x, y, maxpmw, h ); 656 QRect cr(x, y, maxpmw, h );
657 pmrect.moveCenter( cr.center() ); 657 pmrect.moveCenter( cr.center() );
658 p->drawPixmap(pmrect.topLeft(), pixmap); 658 p->drawPixmap(pmrect.topLeft(), pixmap);
659 } 659 }
660 660
661 // draw check 661 // draw check
662 if(mi->isChecked() ) { 662 if(mi->isChecked() ) {
663 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled ); 663 drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
664 } 664 }
665 665
666 666
667 // draw text 667 // draw text
668 int xm = maxpmw + 2; 668 int xm = maxpmw + 2;
669 int xp = x + xm; 669 int xp = x + xm;
670 int tw = w -xm - 2; 670 int tw = w -xm - 2;
671 671
672 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) : 672 p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
673 g.mid() ); 673 g.mid() );
674 674
675 675
676 if ( mi->custom() ) { 676 if ( mi->custom() ) {
677 p->save(); 677 p->save();
678 mi->custom()->paint(p, g, act, enabled, 678 mi->custom()->paint(p, g, act, enabled,
679 xp, y+1, tw, h-2 ); 679 xp, y+1, tw, h-2 );
680 p->restore(); 680 p->restore();
681 }else { // draw label 681 }else { // draw label
682 QString text = mi->text(); 682 QString text = mi->text();
683 if (!text.isNull() ) { 683 if (!text.isNull() ) {
684 int t = text.find('\t'); 684 int t = text.find('\t');
685 const int tflags = AlignVCenter | DontClip | 685 const int tflags = AlignVCenter | DontClip |
686 ShowPrefix | SingleLine | 686 ShowPrefix | SingleLine |
687 AlignLeft; 687 AlignLeft;
688 688
689 if (t >= 0) { 689 if (t >= 0) {
690 int tabx = x + w - tabwidth - RIGHTBORDER - 690 int tabx = x + w - tabwidth - RIGHTBORDER -
691 ITEMHMARGIN - ITEMFRAME; 691 ITEMHMARGIN - ITEMFRAME;
692 p->drawText(tabx, y+ITEMVMARGIN, tabwidth, 692 p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
693 h-2*ITEMVMARGIN, tflags, 693 h-2*ITEMVMARGIN, tflags,
694 text.mid(t+1) ); 694 text.mid(t+1) );
695 text = text.left(t ); 695 text = text.left(t );
696 } 696 }
697 697
698 // draw left label 698 // draw left label
699 p->drawText(xp, y+ITEMVMARGIN, 699 p->drawText(xp, y+ITEMVMARGIN,
700 tw, h-2*ITEMVMARGIN, 700 tw, h-2*ITEMVMARGIN,
701 tflags, text, t); 701 tflags, text, t);
702 }else if ( mi->pixmap() ) { // pixmap as label 702 }else if ( mi->pixmap() ) { // pixmap as label
703 QPixmap pixmap = *mi->pixmap(); 703 QPixmap pixmap = *mi->pixmap();
704 if ( pixmap.depth() == 1 ) 704 if ( pixmap.depth() == 1 )
705 p->setBackgroundMode( OpaqueMode ); 705 p->setBackgroundMode( OpaqueMode );
706 706
707 int dx = ((w-pixmap.width() ) /2 ) + 707 int dx = ((w-pixmap.width() ) /2 ) +
708 ((w - pixmap.width()) %2 ); 708 ((w - pixmap.width()) %2 );
709 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap ); 709 p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
710 710
711 if ( pixmap.depth() == 1 ) 711 if ( pixmap.depth() == 1 )
712 p->setBackgroundMode( TransparentMode ); 712 p->setBackgroundMode( TransparentMode );
713 } 713 }
714 } 714 }
715 715
716 if ( mi->popup() ) { // draw submenu arrow 716 if ( mi->popup() ) { // draw submenu arrow
717 int dim = (h-2*ITEMFRAME) / 2; 717 int dim = (h-2*ITEMFRAME) / 2;
718 drawArrow( p, RightArrow, false, 718 drawArrow( p, RightArrow, false,
719 x+w-ARROWMARGIN-ITEMFRAME-dim, 719 x+w-ARROWMARGIN-ITEMFRAME-dim,
720 y+h/2-dim/2, dim, dim, g, enabled ); 720 y+h/2-dim/2, dim, dim, g, enabled );
721 } 721 }
722} 722}
723 723
724 724
725QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) { 725QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) {
726 return QRect(x+2, y+2, w-4-17, h-5 ); 726 return QRect(x+2, y+2, w-4-17, h-5 );
727} 727}
728 728
729void PhaseStyle::drawComboButton( QPainter * p, int x, int y, 729void PhaseStyle::drawComboButton( QPainter * p, int x, int y,
730 int w, int h, 730 int w, int h,
731 const QColorGroup & g, 731 const QColorGroup & g,
732 bool sunken, 732 bool sunken,
733 bool editable, 733 bool editable,
734 bool, 734 bool,
735 const QBrush *) { 735 const QBrush *) {
736 drawButton(p, x, y, w, h, g, 736 drawButton(p, x, y, w, h, g,
737 sunken, &g.brush(QColorGroup::Button )); 737 sunken, &g.brush(QColorGroup::Button ));
738 738
739 for ( int n = 0; n < 2; ++n )
740 kColorBitmaps(p, g, w-16+(6*n), y+(h/2)-2,
741 0, &doodad_mid, &doodad_light, 0, 0, 0 );
739 742
740 bool odd = (h % 2);
741 drawPanel(p, w-15 , y+(h/2)-3, 10, (odd ? 7 : 6 ),
742 g, true , 1, sunken ? &g.brush(QColorGroup::Midlight)
743 : &g.brush(QColorGroup::Mid) );
744 743
745 if (editable ) { 744 if (editable ) {
746 const int x2 = x+w-1; const int y2 = y+h-1; 745 const int x2 = x+w-1; const int y2 = y+h-1;
747 p->setPen(g.dark()); 746 p->setPen(g.dark());
748 p->drawLine(x2+1, y, x2+1, y2); 747 p->drawLine(x2+1, y, x2+1, y2);
749 p->setPen(g.midlight()); 748 p->setPen(g.midlight());
750 p->drawLine(x2+2, y, x2+2, y2-1); 749 p->drawLine(x2+2, y, x2+2, y2-1);
751 p->setPen(g.button()); 750 p->setPen(g.button());
752 p->drawPoint(x2+2, y2); 751 p->drawPoint(x2+2, y2);
753 } 752 }
754 753
755 p->setPen(g.buttonText() ); 754 p->setPen(g.buttonText() );
756} 755}
757 756
758 757
759void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab, 758void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab,
760 bool selected ) { 759 bool selected ) {
761 bool edge = false; 760 bool edge = false;
762 int x, y, w, h; 761 int x, y, w, h;
763 QRect r = tab->rect(); 762 QRect r = tab->rect();
764 r.rect(&x,&y,&w,&h); 763 r.rect(&x,&y,&w,&h);
765 const int x2 = x+w-1; 764 const int x2 = x+w-1;
766 const int y2 = y+h-1; 765 const int y2 = y+h-1;
767 const QColorGroup &group = bar->colorGroup(); 766 const QColorGroup &group = bar->colorGroup();
768 767
769 768
770 painter->save(); 769 painter->save();
771 770
772 // what position is the tab? 771 // what position is the tab?
773 if ((bar->count() == 1 )) 772 if ((bar->count() == 1 ))
774 edge = true; 773 edge = true;
775 else 774 else
776 edge = false; 775 edge = false;
777 776
778 switch (QTabBar::Shape(bar->shape())) { 777 switch (QTabBar::Shape(bar->shape())) {
779 case QTabBar::RoundedAbove: 778 case QTabBar::RoundedAbove:
780 case QTabBar::TriangularAbove: { 779 case QTabBar::TriangularAbove: {
781 if (!selected) { // shorten 780 if (!selected) { // shorten
782 y += 2; h -= 2; 781 y += 2; h -= 2;
783 } 782 }
784 if (selected) { 783 if (selected) {
785 painter->setPen(Qt::NoPen); 784 painter->setPen(Qt::NoPen);
786 painter->fillRect(x+1, y+1, w-1, h-1, 785 painter->fillRect(x+1, y+1, w-1, h-1,
787 group.brush(QColorGroup::Background)); 786 group.brush(QColorGroup::Background));
788 } else 787 } else
789 drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2), 788 drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2),
790 group.background().dark(contrast) ); 789 group.background().dark(contrast) );
791 790
792 791
793 // draw tab 792 // draw tab
794 painter->setPen(group.dark()); 793 painter->setPen(group.dark());
795 painter->drawLine(x, y, x, y2-2); 794 painter->drawLine(x, y, x, y2-2);
796 painter->drawLine(x+1, y, x2, y); 795 painter->drawLine(x+1, y, x2, y);
797 painter->drawLine(x2, y+1, x2, y2-2); 796 painter->drawLine(x2, y+1, x2, y2-2);
798 797
799 painter->setPen(group.mid()); 798 painter->setPen(group.mid());
800 painter->drawLine(x2-1, y+2, x2-1, y2-2); 799 painter->drawLine(x2-1, y+2, x2-1, y2-2);
801 800
802 painter->setPen(group.midlight()); 801 painter->setPen(group.midlight());
803 painter->drawLine(x+1, y+1, x2-2, y+1); 802 painter->drawLine(x+1, y+1, x2-2, y+1);
804 if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2); 803 if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2);
805 804
806 // finish off bottom 805 // finish off bottom
807 if (selected) { 806 if (selected) {
808 painter->setPen(group.dark()); 807 painter->setPen(group.dark());
809 painter->drawPoint(x, y2-1); 808 painter->drawPoint(x, y2-1);
810 painter->drawPoint(x2, y2-1); 809 painter->drawPoint(x2, y2-1);
811 810
812 painter->setPen(group.midlight()); 811 painter->setPen(group.midlight());
813 painter->drawPoint(x, y2); 812 painter->drawPoint(x, y2);
814 painter->drawLine(x+1, y2-1, x+1, y2); 813 painter->drawLine(x+1, y2-1, x+1, y2);
815 painter->drawPoint(x2, y2); 814 painter->drawPoint(x2, y2);
816 815
817 painter->setPen(group.mid()); 816 painter->setPen(group.mid());
818 painter->drawPoint(x2-1, y2-1); 817 painter->drawPoint(x2-1, y2-1);
819 818
820 if (edge) { 819 if (edge) {
821 painter->setPen(group.dark()); 820 painter->setPen(group.dark());
822 painter->drawLine(x, y2-1, x, y2); 821 painter->drawLine(x, y2-1, x, y2);
823 painter->setPen(group.midlight()); 822 painter->setPen(group.midlight());
824 painter->drawPoint(x+1, y2); 823 painter->drawPoint(x+1, y2);
825 } 824 }
826 } else { 825 } else {
827 painter->setPen(group.dark()); 826 painter->setPen(group.dark());
828 painter->drawLine(x, y2-1, x2, y2-1); 827 painter->drawLine(x, y2-1, x2, y2-1);
829 828
830 painter->setPen(group.midlight()); 829 painter->setPen(group.midlight());
831 painter->drawLine(x, y2, x2, y2); 830 painter->drawLine(x, y2, x2, y2);
832 831
833 if (edge) { 832 if (edge) {
834 painter->setPen(group.dark()); 833 painter->setPen(group.dark());
835 painter->drawLine(x, y2-1, x, y2); 834 painter->drawLine(x, y2-1, x, y2);
836 } 835 }
837 } 836 }
838 break; 837 break;
839 } 838 }
840 case QTabBar::RoundedBelow: 839 case QTabBar::RoundedBelow:
841 case QTabBar::TriangularBelow: { 840 case QTabBar::TriangularBelow: {
842 painter->setBrush( group.background().dark(contrast)); 841 painter->setBrush( group.background().dark(contrast));
843 painter->setPen(Qt::NoPen); 842 painter->setPen(Qt::NoPen);
844 painter->fillRect(x+1, y+1, w-1, h-1, painter->brush()); 843 painter->fillRect(x+1, y+1, w-1, h-1, painter->brush());
845 844
846 // draw tab 845 // draw tab
847 painter->setPen(group.dark()); 846 painter->setPen(group.dark());
848 painter->drawLine(x, y+1, x, y2); 847 painter->drawLine(x, y+1, x, y2);
849 painter->drawLine(x+1, y2, x2, y2); 848 painter->drawLine(x+1, y2, x2, y2);
850 painter->drawLine(x2, y+1, x2, y2-1); 849 painter->drawLine(x2, y+1, x2, y2-1);
851 850
852 painter->setPen(group.mid()); 851 painter->setPen(group.mid());
853 painter->drawLine(x2-1, y+1, x2-1, y2-1); 852 painter->drawLine(x2-1, y+1, x2-1, y2-1);
854 painter->drawLine(x+2, y2-1, x2-1, y2-1); 853 painter->drawLine(x+2, y2-1, x2-1, y2-1);
855 painter->drawPoint(x, y); 854 painter->drawPoint(x, y);
856 painter->drawPoint(x2, y); 855 painter->drawPoint(x2, y);
857 856
858 if ((selected) || edge) { 857 if ((selected) || edge) {
859 painter->setPen(group.midlight()); 858 painter->setPen(group.midlight());
860 painter->drawLine(x+1, y+1, x+1, y2-2); 859 painter->drawLine(x+1, y+1, x+1, y2-2);
861 } 860 }
862 861
863 // finish off top 862 // finish off top
864 if (selected) { 863 if (selected) {
865 if (edge) { 864 if (edge) {
866 painter->setPen(group.dark()); 865 painter->setPen(group.dark());
867 painter->drawPoint(x, y); 866 painter->drawPoint(x, y);
868 painter->setPen(group.midlight()); 867 painter->setPen(group.midlight());
869 painter->drawPoint(x+1, y); 868 painter->drawPoint(x+1, y);
870 } 869 }
871 } else { 870 } else {
872 painter->setPen(group.dark()); 871 painter->setPen(group.dark());
873 painter->drawLine(x, y+1, x2, y+1); 872 painter->drawLine(x, y+1, x2, y+1);
874 873
875 painter->setPen(group.mid()); 874 painter->setPen(group.mid());
876 painter->drawLine(x, y, x2, y); 875 painter->drawLine(x, y, x2, y);
877 876
878 if (edge) { 877 if (edge) {
879 painter->setPen(group.dark()); 878 painter->setPen(group.dark());
880 painter->drawPoint(x, y); 879 painter->drawPoint(x, y);
881 } 880 }
882 } 881 }
883 break; 882 break;
884 } 883 }
885 } 884 }
886 885
887 painter->restore(); 886 painter->restore();
888} 887}
889 888
890void PhaseStyle::drawTabMask( QPainter* p, const QTabBar*, QTab* tab, 889void PhaseStyle::drawTabMask( QPainter* p, const QTabBar*, QTab* tab,
891 bool ) { 890 bool ) {
892 p->fillRect(tab->rect(), Qt::color1); 891 p->fillRect(tab->rect(), Qt::color1);
893} 892}
894 893
895void PhaseStyle::drawToolButton(QPainter * p, int x, int y, 894void PhaseStyle::drawToolButton(QPainter * p, int x, int y,
896 int w, int h, const QColorGroup & g, 895 int w, int h, const QColorGroup & g,
897 bool sunken, 896 bool sunken,
898 const QBrush * fill ) { 897 const QBrush * fill ) {
899 QRect r(x, y, w, h ); 898 QRect r(x, y, w, h );
900 p->fillRect(r, g.background()); 899 p->fillRect(r, g.background());
901 900
902 drawPanel(p, x, y, w, h, g, sunken, 1, 901 drawPanel(p, x, y, w, h, g, sunken, 1,
903 fill ? fill : &g.brush(QColorGroup::Button) ); 902 fill ? fill : &g.brush(QColorGroup::Button) );
904 903
905 904
906 p->setPen(g.text() ); 905 p->setPen(g.text() );
907} 906}
908 907
909 908
910/* 909/*
911 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 910 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
912 * 911 *
913 * ../web/webstyle.cpp 912 * ../web/webstyle.cpp
914 */ 913 */
915void PhaseStyle::scrollBarMetrics(const QScrollBar* sb, int& sliderMin, 914void PhaseStyle::scrollBarMetrics(const QScrollBar* sb, int& sliderMin,
916 int& sliderMax, int &sliderLength, 915 int& sliderMax, int &sliderLength,
917 int& buttonDim ) { 916 int& buttonDim ) {
918 int maxlen; 917 int maxlen;
919 bool horizontal = sb->orientation() == QScrollBar::Horizontal; 918 bool horizontal = sb->orientation() == QScrollBar::Horizontal;
920 int len = (horizontal) ? sb->width() : sb->height(); 919 int len = (horizontal) ? sb->width() : sb->height();
921 int extent = (horizontal) ? sb->height() : sb->width(); 920 int extent = (horizontal) ? sb->height() : sb->width();
922 921
923 if (len > (extent - 1) * 2) 922 if (len > (extent - 1) * 2)
924 buttonDim = extent; 923 buttonDim = extent;
925 else 924 else
926 buttonDim = len / 2 - 1; 925 buttonDim = len / 2 - 1;
927 926
928 if (horizontal) 927 if (horizontal)
929 sliderMin = buttonDim * 2; 928 sliderMin = buttonDim * 2;
930 else 929 else
931 sliderMin = 1; 930 sliderMin = 1;
932 931
933 maxlen = len - buttonDim * 2 - 1; 932 maxlen = len - buttonDim * 2 - 1;
934 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) ); 933 int div = QMAX(1, (sb->maxValue() - sb->minValue() + sb->pageStep() ) );
935 934
936 sliderLength = 935 sliderLength =
937 (sb->pageStep() * maxlen) / div; 936 (sb->pageStep() * maxlen) / div;
938 937
939 if (sliderLength < SCROLLBAR_EXTENT) 938 if (sliderLength < SCROLLBAR_EXTENT)
940 sliderLength = SCROLLBAR_EXTENT; 939 sliderLength = SCROLLBAR_EXTENT;
941 940
942 if (sliderLength > maxlen) 941 if (sliderLength > maxlen)
943 sliderLength = maxlen; 942 sliderLength = maxlen;
944 943
945 sliderMax = sliderMin + maxlen - sliderLength; 944 sliderMax = sliderMin + maxlen - sliderLength;
946} 945}
947 946
948void PhaseStyle::drawScrollBarControls( QPainter* p, const QScrollBar *sb, 947void PhaseStyle::drawScrollBarControls( QPainter* p, const QScrollBar *sb,
949 int sliderStart, uint controls, 948 int sliderStart, uint controls,
950 uint activeControl) { 949 uint activeControl) {
951 const bool horizontal = (sb->orientation() == Qt::Horizontal ); 950 const bool horizontal = (sb->orientation() == Qt::Horizontal );
952 int sliderMin, sliderMax, sliderLength, buttonDim; 951 int sliderMin, sliderMax, sliderLength, buttonDim;
953 const QColorGroup& g = sb->colorGroup(); 952 const QColorGroup& g = sb->colorGroup();
954 QRect sub, add, subPage, addPage, slider; 953 QRect sub, add, subPage, addPage, slider;
955 int x, y, x2, y2; 954 int x, y, x2, y2;
956 955
957 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 956 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
958 957
959 /* lets get the positions */ 958 /* lets get the positions */
960 scrollBarItemPositions(sb, horizontal, sliderStart, 959 scrollBarItemPositions(sb, horizontal, sliderStart,
961 sliderMax, sliderLength, buttonDim, 960 sliderMax, sliderLength, buttonDim,
962 sub, add, subPage, addPage, 961 sub, add, subPage, addPage,
963 slider ); 962 slider );
964 963
965 964
966 /* sanity */ 965 /* sanity */
967 if ( sliderStart > sliderMax ) 966 if ( sliderStart > sliderMax )
968 sliderStart = sliderMax; 967 sliderStart = sliderMax;
969 968
970 // addline 969 // addline
971 if ( controls & AddLine && add.isValid() ) { 970 if ( controls & AddLine && add.isValid() ) {
972 x = add.x(); y = add.y(); 971 x = add.x(); y = add.y();
973 x2 = add.width(); y2 = add.height(); 972 x2 = add.width(); y2 = add.height();
974 const bool down = (activeControl & AddLine ); 973 const bool down = (activeControl & AddLine );
975 drawBevelButton(p, x, y, x2, y2, g, down, 974 drawBevelButton(p, x, y, x2, y2, g, down,
976 &g.brush(QColorGroup::Button)); 975 &g.brush(QColorGroup::Button));
977 976
978 Qt::ArrowType arrow = horizontal ? RightArrow : DownArrow; 977 Qt::ArrowType arrow = horizontal ? RightArrow : DownArrow;
979 if (down ) { 978 if (down ) {
980 switch (arrow ) { 979 switch (arrow ) {
981 case DownArrow: y++; break; 980 case DownArrow: y++; break;
982 case RightArrow: x++; break; 981 case RightArrow: x++; break;
983 default: break; 982 default: break;
984 } 983 }
985 } 984 }
986 drawArrow( p, arrow, down, x, y, x2, y2, g, true ); 985 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
987 } 986 }
988 987
989 if ( controls & SubLine && sub.isValid() ) { 988 if ( controls & SubLine && sub.isValid() ) {
990 x = sub.x(); y = sub.y(); 989 x = sub.x(); y = sub.y();
991 x2 = sub.width(); y2 = sub.height(); 990 x2 = sub.width(); y2 = sub.height();
992 const bool down = (activeControl & SubLine ); 991 const bool down = (activeControl & SubLine );
993 drawBevelButton(p, x, y, x2, y2, g, down, 992 drawBevelButton(p, x, y, x2, y2, g, down,
994 &g.brush(QColorGroup::Button)); 993 &g.brush(QColorGroup::Button));
995 994
996 Qt::ArrowType arrow = horizontal ? LeftArrow : UpArrow; 995 Qt::ArrowType arrow = horizontal ? LeftArrow : UpArrow;
997 if (down ) { 996 if (down ) {
998 switch (arrow ) { 997 switch (arrow ) {
999 case UpArrow: y--; break; 998 case UpArrow: y--; break;
1000 case LeftArrow: x--; break; 999 case LeftArrow: x--; break;
1001 default: break; 1000 default: break;
1002 } 1001 }
1003 } 1002 }
1004 drawArrow( p, arrow, down, x, y, x2, y2, g, true ); 1003 drawArrow( p, arrow, down, x, y, x2, y2, g, true );
1005 } 1004 }
1006 1005
1007 if ( controls & AddPage && addPage.isValid() ) { 1006 if ( controls & AddPage && addPage.isValid() ) {
1008 x = addPage.x(); y = addPage.y(); 1007 x = addPage.x(); y = addPage.y();
1009 x2 = addPage.right(); y2 = addPage.bottom(); 1008 x2 = addPage.right(); y2 = addPage.bottom();
1010 1009
1011 p->fillRect(addPage, g.mid()); 1010 p->fillRect(addPage, g.mid());
1012 p->setPen(g.dark()); 1011 p->setPen(g.dark());
1013 if (horizontal) { // vertical 1012 if (horizontal) { // vertical
1014 p->drawLine(x, y, x2, y); 1013 p->drawLine(x, y, x2, y);
1015 p->drawLine(x, y2, x2, y2); 1014 p->drawLine(x, y2, x2, y2);
1016 } else { // horizontal 1015 } else { // horizontal
1017 p->drawLine(x, y, x, y2); 1016 p->drawLine(x, y, x, y2);
1018 p->drawLine(x2, y, x2, y2); 1017 p->drawLine(x2, y, x2, y2);
1019 } 1018 }
1020 } 1019 }
1021 1020
1022 if ( controls & SubPage && subPage.isValid() ) { 1021 if ( controls & SubPage && subPage.isValid() ) {
1023 x = subPage.x(); y = subPage.y(); 1022 x = subPage.x(); y = subPage.y();
1024 x2 = subPage.right(); y2 = subPage.bottom(); 1023 x2 = subPage.right(); y2 = subPage.bottom();
1025 1024
1026 p->fillRect(subPage, g.mid()); 1025 p->fillRect(subPage, g.mid());
1027 p->setPen(g.dark()); 1026 p->setPen(g.dark());
1028 if (horizontal) { // vertical 1027 if (horizontal) { // vertical
1029 p->drawLine(x, y, x2, y); 1028 p->drawLine(x, y, x2, y);
1030 p->drawLine(x, y2, x2, y2); 1029 p->drawLine(x, y2, x2, y2);
1031 } else { // horizontal 1030 } else { // horizontal
1032 p->drawLine(x, y, x, y2); 1031 p->drawLine(x, y, x, y2);
1033 p->drawLine(x2, y, x2, y2); 1032 p->drawLine(x2, y, x2, y2);
1034 } 1033 }
1035} 1034}
1036 1035
1037 if ( controls & Slider && slider.isValid() ) { 1036 if ( controls & Slider && slider.isValid() ) {
1038 x = slider.x(); y = slider.y(); 1037 x = slider.x(); y = slider.y();
1039 x2 = slider.width(); y2 = slider.height(); 1038 x2 = slider.width(); y2 = slider.height();
1040 const bool down = ( activeControl & Slider ); 1039 const bool down = ( activeControl & Slider );
1041 int cx = x + x2/2 -2; int cy = y + y2/2 -2; 1040 int cx = x + x2/2 -2; int cy = y + y2/2 -2;
1042 1041
1043 drawBevelButton(p, x, y, x2, y2, g, down, 1042 drawBevelButton(p, x, y, x2, y2, g, down,
1044 &g.brush(QColorGroup::Button) ); 1043 &g.brush(QColorGroup::Button) );
1045 1044
1046 if (horizontal && (x2 >=20)) { 1045 if (horizontal && (x2 >=20)) {
1047 for (int n = -5; n <= 5; n += 5) 1046 for (int n = -5; n <= 5; n += 5)
1048 kColorBitmaps(p, g, cx+n, cy, 1047 kColorBitmaps(p, g, cx+n, cy,
1049 0, &doodad_mid, &doodad_light, 0, 0, 0); 1048 0, &doodad_mid, &doodad_light, 0, 0, 0);
1050 } else if (!horizontal && (y2 >= 20)) { 1049 } else if (!horizontal && (y2 >= 20)) {
1051 for (int n = -5; n <= 5; n += 5) 1050 for (int n = -5; n <= 5; n += 5)
1052 kColorBitmaps(p, g, cx, cy+n, 1051 kColorBitmaps(p, g, cx, cy+n,
1053 0, &doodad_mid, &doodad_light, 0, 0, 0); 1052 0, &doodad_mid, &doodad_light, 0, 0, 0);
1054 } 1053 }
1055 1054
1056 if ( sb->hasFocus() && down ) { 1055 if ( sb->hasFocus() && down ) {
1057 slider = QRect(slider.x()+2, slider.y()+2, 1056 slider = QRect(slider.x()+2, slider.y()+2,
1058 slider.width()-2, slider.height()-2 ); 1057 slider.width()-2, slider.height()-2 );
1059 drawFocusRect(p, slider, g, false ); 1058 drawFocusRect(p, slider, g, false );
1060 } 1059 }
1061 1060
1062 } 1061 }
1063} 1062}
1064 1063
1065/* 1064/*
1066 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 1065 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1067 * 1066 *
1068 * ../web/webstyle.cpp 1067 * ../web/webstyle.cpp
1069 */ 1068 */
1070QStyle::ScrollControl PhaseStyle::scrollBarPointOver( const QScrollBar * sb, 1069QStyle::ScrollControl PhaseStyle::scrollBarPointOver( const QScrollBar * sb,
1071 int sliderStart, 1070 int sliderStart,
1072 const QPoint & point ) { 1071 const QPoint & point ) {
1073 if (!sb->rect().contains(point)) 1072 if (!sb->rect().contains(point))
1074 return NoScroll; 1073 return NoScroll;
1075 1074
1076 int sliderMin, sliderMax, sliderLength, buttonDim; 1075 int sliderMin, sliderMax, sliderLength, buttonDim;
1077 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim); 1076 scrollBarMetrics(sb, sliderMin, sliderMax, sliderLength, buttonDim);
1078 1077
1079 if (sb->orientation() == QScrollBar::Horizontal) { 1078 if (sb->orientation() == QScrollBar::Horizontal) {
1080 int x = point.x(); 1079 int x = point.x();
1081 1080
1082 if (x <= buttonDim) 1081 if (x <= buttonDim)
1083 return SubLine; 1082 return SubLine;
1084 else if (x <= buttonDim * 2) 1083 else if (x <= buttonDim * 2)
1085 return AddLine; 1084 return AddLine;
1086 else if (x < sliderStart) 1085 else if (x < sliderStart)
1087 return SubPage; 1086 return SubPage;
1088 else if (x < sliderStart+sliderLength) 1087 else if (x < sliderStart+sliderLength)
1089 return Slider; 1088 return Slider;
1090 else 1089 else
1091 return AddPage; 1090 return AddPage;
1092 } else { 1091 } else {
1093 int y = point.y(); 1092 int y = point.y();
1094 1093
1095 if (y < sliderStart) 1094 if (y < sliderStart)
1096 return SubPage; 1095 return SubPage;
1097 else if (y < sliderStart + sliderLength) 1096 else if (y < sliderStart + sliderLength)
1098 return Slider; 1097 return Slider;
1099 else if (y < sliderMax + sliderLength) 1098 else if (y < sliderMax + sliderLength)
1100 return AddPage; 1099 return AddPage;
1101 else if (y < sliderMax + sliderLength + buttonDim) 1100 else if (y < sliderMax + sliderLength + buttonDim)
1102 return SubLine; 1101 return SubLine;
1103 else 1102 else
1104 return AddLine; 1103 return AddLine;
1105 } 1104 }
1106} 1105}
1107 1106
1108/* 1107/*
1109 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 1108 * LGPLv2 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
1110 * 1109 *
1111 * ../web/webstyle.cpp 1110 * ../web/webstyle.cpp
1112 * scrollBarControlsMetrics 1111 * scrollBarControlsMetrics
1113 */ 1112 */
1114void PhaseStyle::scrollBarItemPositions( const QScrollBar* sb, const bool horizontal, 1113void PhaseStyle::scrollBarItemPositions( const QScrollBar* sb, const bool horizontal,
1115 int sliderStart, int sliderMax, 1114 int sliderStart, int sliderMax,
1116 int sliderLength, int buttonDim, 1115 int sliderLength, int buttonDim,
1117 QRect &rSub, QRect& rAdd, QRect& rSubPage, 1116 QRect &rSub, QRect& rAdd, QRect& rSubPage,
1118 QRect &rAddPage, QRect& rSlider ) { 1117 QRect &rAddPage, QRect& rSlider ) {
1119 1118
1120 int len = horizontal ? sb->width() : sb->height(); 1119 int len = horizontal ? sb->width() : sb->height();
1121 int extent = horizontal ? sb->height() : sb->width(); 1120 int extent = horizontal ? sb->height() : sb->width();
1122 1121
1123 QColorGroup g = sb->colorGroup(); 1122 QColorGroup g = sb->colorGroup();
1124 1123
1125 if (sliderStart > sliderMax) 1124 if (sliderStart > sliderMax)
1126 sliderStart = sliderMax; 1125 sliderStart = sliderMax;
1127 1126
1128 int sliderEnd = sliderStart + sliderLength; 1127 int sliderEnd = sliderStart + sliderLength;
1129 1128
1130 int addX, addY; 1129 int addX, addY;
1131 int subX, subY; 1130 int subX, subY;
1132 int subPageX, subPageY, subPageW, subPageH; 1131 int subPageX, subPageY, subPageW, subPageH;
1133 int addPageX, addPageY, addPageW, addPageH; 1132 int addPageX, addPageY, addPageW, addPageH;
1134 int sliderX, sliderY, sliderW, sliderH; 1133 int sliderX, sliderY, sliderW, sliderH;
1135 1134
1136 if (horizontal){ 1135 if (horizontal){
1137 subY = 0; 1136 subY = 0;
1138 addY = 0; 1137 addY = 0;
1139 subX = 0; 1138 subX = 0;
1140 addX = buttonDim; 1139 addX = buttonDim;
1141 1140
1142 subPageX = buttonDim * 2; 1141 subPageX = buttonDim * 2;
1143 subPageY = 0; 1142 subPageY = 0;
1144 subPageW = sliderStart - 1; 1143 subPageW = sliderStart - 1;
1145 subPageH = extent; 1144 subPageH = extent;
1146 1145
1147 addPageX = sliderEnd; 1146 addPageX = sliderEnd;
1148 addPageY = 0; 1147 addPageY = 0;
1149 addPageW = len - sliderEnd; 1148 addPageW = len - sliderEnd;
1150 addPageH = extent; 1149 addPageH = extent;
1151 1150
1152 sliderX = sliderStart; 1151 sliderX = sliderStart;
1153 sliderY = 0; 1152 sliderY = 0;
1154 sliderW = sliderLength; 1153 sliderW = sliderLength;
1155 sliderH = extent; 1154 sliderH = extent;
1156 }else { 1155 }else {
1157 subX = 0; 1156 subX = 0;
1158 addX = 0; 1157 addX = 0;
1159 subY = len - buttonDim * 2; 1158 subY = len - buttonDim * 2;
1160 addY = len - buttonDim; 1159 addY = len - buttonDim;
1161 1160
1162 subPageX = 0; 1161 subPageX = 0;
1163 subPageY = 0; 1162 subPageY = 0;
1164 subPageW = extent; 1163 subPageW = extent;
1165 subPageH = sliderStart; 1164 subPageH = sliderStart;
1166 1165
1167 addPageX = 0; 1166 addPageX = 0;
1168 addPageY = sliderEnd; 1167 addPageY = sliderEnd;
1169 addPageW = extent; 1168 addPageW = extent;
1170 addPageH = subY - sliderEnd; 1169 addPageH = subY - sliderEnd;
1171 1170
1172 sliderX = 0; 1171 sliderX = 0;
1173 sliderY = sliderStart; 1172 sliderY = sliderStart;
1174 sliderW = extent; 1173 sliderW = extent;
1175 sliderH = sliderLength; 1174 sliderH = sliderLength;
1176 } 1175 }
1177 1176
1178 rSub .setRect( subX, subY, buttonDim, buttonDim); 1177 rSub .setRect( subX, subY, buttonDim, buttonDim);
1179 rAdd .setRect( addX, addY, buttonDim, buttonDim); 1178 rAdd .setRect( addX, addY, buttonDim, buttonDim);
1180 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH); 1179 rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
1181 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH); 1180 rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
1182 rSlider .setRect( sliderX, sliderY, sliderW, sliderH); 1181 rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
1183 1182
1184} 1183}
1185 1184
1186 1185
1187void PhaseStyle::drawSlider (QPainter * p, int x, int y, 1186void PhaseStyle::drawSlider (QPainter * p, int x, int y,
1188 int w, int h, const QColorGroup &g, 1187 int w, int h, const QColorGroup &g,
1189 Orientation o, bool, bool ) { 1188 Orientation o, bool, bool ) {
1190 int cx = x + w/2; 1189 int cx = x + w/2;
1191 int cy = y + h/2; 1190 int cy = y + h/2;
1192 QBrush brush = g.brush( QColorGroup::Button ); 1191 QBrush brush = g.brush( QColorGroup::Button );
1193 1192
1194 if ( o == Horizontal ) { 1193 if ( o == Horizontal ) {
1195 drawBevelButton(p, cx-5, y, 6, h, g, false, 1194 drawBevelButton(p, cx-5, y, 6, h, g, false,
1196 &brush ); 1195 &brush );
1197 drawBevelButton(p, cx, y, 6, h, g, false, 1196 drawBevelButton(p, cx, y, 6, h, g, false,
1198 &brush ); 1197 &brush );
1199 }else { 1198 }else {
1200 drawBevelButton(p, x, cy-5, w, 6, g, false, 1199 drawBevelButton(p, x, cy-5, w, 6, g, false,
1201 &brush ); 1200 &brush );
1202 drawBevelButton(p, x, cy, w, 6, g, false, 1201 drawBevelButton(p, x, cy, w, 6, g, false,
1203 &brush ); 1202 &brush );
1204 } 1203 }
1205} 1204}
1206 1205
1207void PhaseStyle::drawSliderGroove(QPainter* p, int x, int y, 1206void PhaseStyle::drawSliderGroove(QPainter* p, int x, int y,
1208 int w, int h, const QColorGroup& g, 1207 int w, int h, const QColorGroup& g,
1209 QCOORD , Orientation o ) { 1208 QCOORD , Orientation o ) {
1210 int cx = x + w/2; 1209 int cx = x + w/2;
1211 int cy = y + h/2; 1210 int cy = y + h/2;
1212 1211
1213 if ( o == Horizontal ) { 1212 if ( o == Horizontal ) {
1214 y = cy-3; h = 7; 1213 y = cy-3; h = 7;
1215 }else { 1214 }else {
1216 x = cx-3; w = 7; 1215 x = cx-3; w = 7;
1217 } 1216 }
1218 1217
1219 drawPanel(p, x, y, w, h, g, true, 1, 1218 drawPanel(p, x, y, w, h, g, true, 1,
1220 &g.brush(QColorGroup::Mid ) ); 1219 &g.brush(QColorGroup::Mid ) );
1221} 1220}