| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qplatinumstyle.cpp 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Implementation of Platinum-like style class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 981231
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1998-2002 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #include "qplatinumstyle.h"
|
|---|
| 39 |
|
|---|
| 40 | #if !defined(QT_NO_STYLE_PLATINUM) || defined(QT_PLUGIN)
|
|---|
| 41 |
|
|---|
| 42 | #include "qapplication.h"
|
|---|
| 43 | #include "qcombobox.h"
|
|---|
| 44 | #include "qdrawutil.h"
|
|---|
| 45 | #include "qpainter.h"
|
|---|
| 46 | #include "qpalette.h"
|
|---|
| 47 | #include "qpixmap.h"
|
|---|
| 48 | #include "qpushbutton.h"
|
|---|
| 49 | #include "qscrollbar.h"
|
|---|
| 50 | #include "qslider.h"
|
|---|
| 51 | #include <limits.h>
|
|---|
| 52 |
|
|---|
| 53 | /*!
|
|---|
| 54 | \class QPlatinumStyle qplatinumstyle.h
|
|---|
| 55 | \brief The QPlatinumStyle class provides Mac/Platinum look and feel.
|
|---|
| 56 |
|
|---|
| 57 | \ingroup appearance
|
|---|
| 58 |
|
|---|
| 59 | This class implements the Platinum look and feel. It's an
|
|---|
| 60 | experimental class that tries to resemble a Macinosh-like GUI
|
|---|
| 61 | style with the QStyle system. The emulation is currently far from
|
|---|
| 62 | perfect.
|
|---|
| 63 |
|
|---|
| 64 | \sa QAquaStyle
|
|---|
| 65 | */
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | /*!
|
|---|
| 69 | Constructs a QPlatinumStyle
|
|---|
| 70 | */
|
|---|
| 71 | QPlatinumStyle::QPlatinumStyle()
|
|---|
| 72 | {
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | /*!\reimp
|
|---|
| 76 | */
|
|---|
| 77 | QPlatinumStyle::~QPlatinumStyle()
|
|---|
| 78 | {
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | /*!\reimp
|
|---|
| 83 | */
|
|---|
| 84 | void QPlatinumStyle::drawPrimitive( PrimitiveElement pe,
|
|---|
| 85 | QPainter *p,
|
|---|
| 86 | const QRect &r,
|
|---|
| 87 | const QColorGroup &cg,
|
|---|
| 88 | SFlags flags,
|
|---|
| 89 | const QStyleOption& opt ) const
|
|---|
| 90 | {
|
|---|
| 91 | switch (pe) {
|
|---|
| 92 | case PE_HeaderSection:
|
|---|
| 93 | {
|
|---|
| 94 | // adjust the sunken flag, otherwise headers are drawn
|
|---|
| 95 | // sunken...
|
|---|
| 96 | if ( flags & Style_Sunken )
|
|---|
| 97 | flags ^= Style_Sunken;
|
|---|
| 98 | drawPrimitive( PE_ButtonBevel, p, r, cg, flags, opt );
|
|---|
| 99 | break;
|
|---|
| 100 | }
|
|---|
| 101 | case PE_ButtonTool:
|
|---|
| 102 | {
|
|---|
| 103 | // tool buttons don't change color when pushed in platinum,
|
|---|
| 104 | // so we need to make the mid and button color the same
|
|---|
| 105 | QColorGroup myCG = cg;
|
|---|
| 106 | QBrush fill;
|
|---|
| 107 |
|
|---|
| 108 | // quick trick to make sure toolbuttons drawn sunken
|
|---|
| 109 | // when they are activated...
|
|---|
| 110 | if ( flags & Style_On )
|
|---|
| 111 | flags |= Style_Sunken;
|
|---|
| 112 |
|
|---|
| 113 | fill = myCG.brush( QColorGroup::Button );
|
|---|
| 114 | myCG.setBrush( QColorGroup::Mid, fill );
|
|---|
| 115 | drawPrimitive( PE_ButtonBevel, p, r, myCG, flags, opt );
|
|---|
| 116 | break;
|
|---|
| 117 | }
|
|---|
| 118 | case PE_ButtonBevel:
|
|---|
| 119 | {
|
|---|
| 120 | int x,
|
|---|
| 121 | y,
|
|---|
| 122 | w,
|
|---|
| 123 | h;
|
|---|
| 124 | r.rect( &x, &y, &w, &h );
|
|---|
| 125 |
|
|---|
| 126 | QPen oldPen = p->pen();
|
|---|
| 127 | if ( w * h < 1600 ||
|
|---|
| 128 | QABS(w - h) > 10 ) {
|
|---|
| 129 | // small buttons
|
|---|
| 130 |
|
|---|
| 131 | if ( !(flags & (Style_Sunken | Style_Down)) ) {
|
|---|
| 132 | p->fillRect( x + 2, y + 2, w - 4, h - 4,
|
|---|
| 133 | cg.brush(QColorGroup::Button) );
|
|---|
| 134 | // the bright side
|
|---|
| 135 | p->setPen( cg.dark() );
|
|---|
| 136 | // the bright side
|
|---|
| 137 | p->setPen( cg.dark() );
|
|---|
| 138 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 139 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 140 |
|
|---|
| 141 | p->setPen( cg.light() );
|
|---|
| 142 | p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
|
|---|
| 143 | p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
|
|---|
| 144 |
|
|---|
| 145 | // the dark side
|
|---|
| 146 | p->setPen( cg.mid() );
|
|---|
| 147 | p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
|
|---|
| 148 | p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 3 );
|
|---|
| 149 |
|
|---|
| 150 | p->setPen( cg.dark().dark() );
|
|---|
| 151 | p->drawLine( x + 1, y + h - 1, x + w - 1,
|
|---|
| 152 | y + h - 1 );
|
|---|
| 153 | p->drawLine( x + w - 1, y + 1,
|
|---|
| 154 | x + w - 1,
|
|---|
| 155 | y + h - 2 );
|
|---|
| 156 | } else {
|
|---|
| 157 | p->fillRect(x + 2, y + 2,
|
|---|
| 158 | w - 4, h - 4,
|
|---|
| 159 | cg.brush( QColorGroup::Mid ));
|
|---|
| 160 |
|
|---|
| 161 | // the dark side
|
|---|
| 162 | p->setPen( cg.dark().dark() );
|
|---|
| 163 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 164 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 165 |
|
|---|
| 166 | p->setPen( cg.mid().dark());
|
|---|
| 167 | p->drawLine( x + 1, y + 1,
|
|---|
| 168 | x + w-2, y + 1);
|
|---|
| 169 | p->drawLine( x + 1, y + 1,
|
|---|
| 170 | x + 1, y + h - 2 );
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | // the bright side!
|
|---|
| 174 |
|
|---|
| 175 | p->setPen(cg.button());
|
|---|
| 176 | p->drawLine( x + 1, y + h - 2,
|
|---|
| 177 | x + w - 2,
|
|---|
| 178 | y + h - 2 );
|
|---|
| 179 | p->drawLine( x + w - 2, y + 1,
|
|---|
| 180 | x + w - 2,
|
|---|
| 181 | y + h - 2 );
|
|---|
| 182 | p->setPen(cg.dark());
|
|---|
| 183 | p->drawLine(x, y + h - 1,
|
|---|
| 184 | x + w - 1,
|
|---|
| 185 | y + h - 1 );
|
|---|
| 186 | p->drawLine(x + w - 1, y,
|
|---|
| 187 | x + w - 1,
|
|---|
| 188 | y + h - 1 );
|
|---|
| 189 | }
|
|---|
| 190 | } else {
|
|---|
| 191 | // big ones
|
|---|
| 192 | if ( !(flags & (Style_Sunken | Style_Down)) ) {
|
|---|
| 193 | p->fillRect( x + 3, y + 3, w - 6,
|
|---|
| 194 | h - 6,
|
|---|
| 195 | cg.brush(QColorGroup::Button) );
|
|---|
| 196 |
|
|---|
| 197 | // the bright side
|
|---|
| 198 | p->setPen( cg.button().dark() );
|
|---|
| 199 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 200 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 201 |
|
|---|
| 202 | p->setPen( cg.button() );
|
|---|
| 203 | p->drawLine( x + 1, y + 1,
|
|---|
| 204 | x + w - 2, y + 1 );
|
|---|
| 205 | p->drawLine( x + 1, y + 1,
|
|---|
| 206 | x + 1, y + h - 2 );
|
|---|
| 207 |
|
|---|
| 208 | p->setPen( cg.light() );
|
|---|
| 209 | p->drawLine( x + 2, y + 2,
|
|---|
| 210 | x + 2, y + h - 2 );
|
|---|
| 211 | p->drawLine( x + 2, y + 2,
|
|---|
| 212 | x + w - 2, y + 2 );
|
|---|
| 213 | // the dark side!
|
|---|
| 214 |
|
|---|
| 215 | p->setPen( cg.mid() );
|
|---|
| 216 | p->drawLine( x + 3, y + h - 3,
|
|---|
| 217 | x + w - 3,
|
|---|
| 218 | y + h - 3 );
|
|---|
| 219 | p->drawLine( x + w - 3, y + 3,
|
|---|
| 220 | x + w - 3,
|
|---|
| 221 | y + h - 3 );
|
|---|
| 222 | p->setPen( cg.dark() );
|
|---|
| 223 | p->drawLine( x + 2, y + h - 2,
|
|---|
| 224 | x + w - 2,
|
|---|
| 225 | y + h - 2 );
|
|---|
| 226 | p->drawLine( x + w - 2, y + 2,
|
|---|
| 227 | x + w - 2,
|
|---|
| 228 | y + h - 2 );
|
|---|
| 229 |
|
|---|
| 230 | p->setPen( cg.dark().dark() );
|
|---|
| 231 | p->drawLine( x + 1, y + h - 1,
|
|---|
| 232 | x + w - 1,
|
|---|
| 233 | y + h - 1 );
|
|---|
| 234 | p->drawLine( x + w - 1, y + 1,
|
|---|
| 235 | x + w - 1,
|
|---|
| 236 | y + h - 1 );
|
|---|
| 237 | } else {
|
|---|
| 238 | p->fillRect( x + 3, y + 3, w - 6,
|
|---|
| 239 | h - 6,
|
|---|
| 240 | cg.brush( QColorGroup::Mid ) );
|
|---|
| 241 |
|
|---|
| 242 | // the dark side
|
|---|
| 243 | p->setPen( cg.dark().dark().dark() );
|
|---|
| 244 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 245 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 246 |
|
|---|
| 247 | p->setPen( cg.dark().dark() );
|
|---|
| 248 | p->drawLine( x + 1, y + 1,
|
|---|
| 249 | x + w - 2, y + 1 );
|
|---|
| 250 | p->drawLine( x + 1, y + 1,
|
|---|
| 251 | x + 1, y + h - 2 );
|
|---|
| 252 |
|
|---|
| 253 | p->setPen( cg.mid().dark() );
|
|---|
| 254 | p->drawLine( x + 2, y + 2,
|
|---|
| 255 | x + 2, y + w - 2 );
|
|---|
| 256 | p->drawLine( x + 2, y + 2,
|
|---|
| 257 | x + w - 2, y + 2 );
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 | // the bright side!
|
|---|
| 261 |
|
|---|
| 262 | p->setPen( cg.button() );
|
|---|
| 263 | p->drawLine( x + 2, y + h - 3,
|
|---|
| 264 | x + w - 3,
|
|---|
| 265 | y + h - 3 );
|
|---|
| 266 | p->drawLine( x + w - 3, y + 3,
|
|---|
| 267 | x + w - 3,
|
|---|
| 268 | y + h - 3 );
|
|---|
| 269 |
|
|---|
| 270 | p->setPen( cg.midlight() );
|
|---|
| 271 | p->drawLine( x + 1, y + h - 2,
|
|---|
| 272 | x + w - 2,
|
|---|
| 273 | y + h - 2 );
|
|---|
| 274 | p->drawLine( x + w - 2, y + 1,
|
|---|
| 275 | x + w - 2,
|
|---|
| 276 | y + h - 2 );
|
|---|
| 277 |
|
|---|
| 278 | p->setPen( cg.dark() );
|
|---|
| 279 | p->drawLine( x, y + h - 1,
|
|---|
| 280 | x + w - 1,
|
|---|
| 281 | y + h - 1 );
|
|---|
| 282 | p->drawLine( x + w - 1, y,
|
|---|
| 283 | x + w - 1,
|
|---|
| 284 | y + h - 1 );
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 | // corners
|
|---|
| 288 | p->setPen( mixedColor(cg.dark().dark().dark(),
|
|---|
| 289 | cg.dark()) );
|
|---|
| 290 | p->drawPoint( x, y + h - 1 );
|
|---|
| 291 | p->drawPoint( x + w - 1, y );
|
|---|
| 292 |
|
|---|
| 293 | p->setPen( mixedColor(cg.dark().dark(), cg.midlight()) );
|
|---|
| 294 | p->drawPoint( x + 1, y + h - 2 );
|
|---|
| 295 | p->drawPoint( x + w - 2, y + 1 );
|
|---|
| 296 |
|
|---|
| 297 | p->setPen( mixedColor(cg.mid().dark(), cg.button() ) );
|
|---|
| 298 | p->drawPoint( x + 2, y + h - 3 );
|
|---|
| 299 | p->drawPoint( x + w - 3, y + 2 );
|
|---|
| 300 | }
|
|---|
| 301 | }
|
|---|
| 302 | p->setPen( oldPen );
|
|---|
| 303 | break;
|
|---|
| 304 | }
|
|---|
| 305 | case PE_ButtonCommand:
|
|---|
| 306 | {
|
|---|
| 307 | QPen oldPen = p->pen();
|
|---|
| 308 | int x,
|
|---|
| 309 | y,
|
|---|
| 310 | w,
|
|---|
| 311 | h;
|
|---|
| 312 | r.rect( &x, &y, &w, &h);
|
|---|
| 313 |
|
|---|
| 314 | if ( !(flags & (Style_Down | Style_On)) ) {
|
|---|
| 315 | p->fillRect( x+3, y+3, w-6, h-6,
|
|---|
| 316 | cg.brush( QColorGroup::Button ));
|
|---|
| 317 | // the bright side
|
|---|
| 318 | p->setPen( cg.shadow() );
|
|---|
| 319 | p->drawLine( x, y, x+w-1, y );
|
|---|
| 320 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 321 |
|
|---|
| 322 | p->setPen( cg.button() );
|
|---|
| 323 | p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
|
|---|
| 324 | p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
|
|---|
| 325 |
|
|---|
| 326 | p->setPen( cg.light() );
|
|---|
| 327 | p->drawLine( x + 2, y + 2, x + 2, y + h - 2 );
|
|---|
| 328 | p->drawLine( x + 2, y + 2, x + w - 2, y + 2 );
|
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 | // the dark side!
|
|---|
| 332 |
|
|---|
| 333 | p->setPen( cg.mid() );
|
|---|
| 334 | p->drawLine( x + 3, y + h - 3 ,x + w - 3, y + h - 3 );
|
|---|
| 335 | p->drawLine( x + w - 3, y + 3, x + w - 3, y + h - 3 );
|
|---|
| 336 |
|
|---|
| 337 | p->setPen( cg.dark() );
|
|---|
| 338 | p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
|
|---|
| 339 | p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 2 );
|
|---|
| 340 |
|
|---|
| 341 | p->setPen( cg.shadow() );
|
|---|
| 342 | p->drawLine( x + 1, y + h - 1, x + w - 1, y + h - 1 );
|
|---|
| 343 | p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 | // top left corner:
|
|---|
| 347 | p->setPen( cg.background() );
|
|---|
| 348 | p->drawPoint( x, y );
|
|---|
| 349 | p->drawPoint( x + 1, y );
|
|---|
| 350 | p->drawPoint( x, y+1 );
|
|---|
| 351 | p->setPen( cg.shadow() );
|
|---|
| 352 | p->drawPoint( x + 1, y + 1 );
|
|---|
| 353 | p->setPen( cg.button() );
|
|---|
| 354 | p->drawPoint( x + 2, y + 2 );
|
|---|
| 355 | p->setPen( white );
|
|---|
| 356 | p->drawPoint( x + 3, y + 3 );
|
|---|
| 357 | // bottom left corner:
|
|---|
| 358 | p->setPen( cg.background() );
|
|---|
| 359 | p->drawPoint( x, y + h - 1 );
|
|---|
| 360 | p->drawPoint( x + 1, y + h - 1 );
|
|---|
| 361 | p->drawPoint( x, y + h - 2 );
|
|---|
| 362 | p->setPen( cg.shadow() );
|
|---|
| 363 | p->drawPoint( x + 1, y + h - 2 );
|
|---|
| 364 | p->setPen( cg.dark() );
|
|---|
| 365 | p->drawPoint( x + 2, y + h - 3 );
|
|---|
| 366 | // top right corner:
|
|---|
| 367 | p->setPen( cg.background() );
|
|---|
| 368 | p->drawPoint( x + w -1, y );
|
|---|
| 369 | p->drawPoint( x + w - 2, y );
|
|---|
| 370 | p->drawPoint( x + w - 1, y + 1 );
|
|---|
| 371 | p->setPen( cg.shadow() );
|
|---|
| 372 | p->drawPoint( x + w - 2, y + 1 );
|
|---|
| 373 | p->setPen( cg.dark() );
|
|---|
| 374 | p->drawPoint( x + w - 3, y + 2 );
|
|---|
| 375 | // bottom right corner:
|
|---|
| 376 | p->setPen( cg.background() );
|
|---|
| 377 | p->drawPoint( x + w - 1, y + h - 1 );
|
|---|
| 378 | p->drawPoint( x + w - 2, y + h - 1 );
|
|---|
| 379 | p->drawPoint( x + w - 1, y + h - 2 );
|
|---|
| 380 | p->setPen( cg.shadow() );
|
|---|
| 381 | p->drawPoint( x + w - 2, y + h - 2 );
|
|---|
| 382 | p->setPen( cg.dark() );
|
|---|
| 383 | p->drawPoint( x + w - 3, y + h - 3 );
|
|---|
| 384 | p->setPen( cg.mid() );
|
|---|
| 385 | p->drawPoint( x + w - 4, y + h - 4 );
|
|---|
| 386 |
|
|---|
| 387 | } else {
|
|---|
| 388 | p->fillRect( x + 2, y + 2, w - 4, h - 4,
|
|---|
| 389 | cg.brush(QColorGroup::Dark) );
|
|---|
| 390 |
|
|---|
| 391 | // the dark side
|
|---|
| 392 | p->setPen( cg.shadow() );
|
|---|
| 393 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 394 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 395 |
|
|---|
| 396 | p->setPen( cg.dark().dark() );
|
|---|
| 397 | p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
|
|---|
| 398 | p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
|
|---|
| 399 |
|
|---|
| 400 | // the bright side!
|
|---|
| 401 |
|
|---|
| 402 | p->setPen( cg.button() );
|
|---|
| 403 | p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 );
|
|---|
| 404 | p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 );
|
|---|
| 405 |
|
|---|
| 406 | p->setPen( cg.dark() );
|
|---|
| 407 | p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 );
|
|---|
| 408 | p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
|
|---|
| 409 |
|
|---|
| 410 | // top left corner:
|
|---|
| 411 | p->setPen( cg.background() );
|
|---|
| 412 | p->drawPoint( x, y );
|
|---|
| 413 | p->drawPoint( x + 1, y );
|
|---|
| 414 | p->drawPoint( x, y + 1 );
|
|---|
| 415 | p->setPen( cg.shadow() );
|
|---|
| 416 | p->drawPoint( x + 1, y + 1 );
|
|---|
| 417 | p->setPen( cg.dark().dark() );
|
|---|
| 418 | p->drawPoint( x + 3, y + 3 );
|
|---|
| 419 | // bottom left corner:
|
|---|
| 420 | p->setPen( cg.background() );
|
|---|
| 421 | p->drawPoint( x, y + h - 1 );
|
|---|
| 422 | p->drawPoint( x + 1, y + h - 1 );
|
|---|
| 423 | p->drawPoint( x, y + h - 2 );
|
|---|
| 424 | p->setPen( cg.shadow() );
|
|---|
| 425 | p->drawPoint( x + 1, y + h - 2 );
|
|---|
| 426 | // top right corner:
|
|---|
| 427 | p->setPen( cg.background() );
|
|---|
| 428 | p->drawPoint( x + w - 1, y );
|
|---|
| 429 | p->drawPoint( x + w - 2, y );
|
|---|
| 430 | p->drawPoint( x + w - 1, y + 1 );
|
|---|
| 431 | p->setPen( cg.shadow() );
|
|---|
| 432 | p->drawPoint( x + w - 2, y + 1 );
|
|---|
| 433 | // bottom right corner:
|
|---|
| 434 | p->setPen( cg.background() );
|
|---|
| 435 | p->drawPoint( x + w - 1, y + h - 1 );
|
|---|
| 436 | p->drawPoint( x + w - 2, y + h - 1 );
|
|---|
| 437 | p->drawPoint( x + w - 1, y + h - 2 );
|
|---|
| 438 | p->setPen( cg.shadow() );
|
|---|
| 439 | p->drawPoint( x + w - 2, y + h - 2 );
|
|---|
| 440 | p->setPen( cg.dark() );
|
|---|
| 441 | p->drawPoint( x + w - 3, y + h - 3 );
|
|---|
| 442 | p->setPen( cg.mid() );
|
|---|
| 443 | p->drawPoint( x + w - 4, y + h - 4 );
|
|---|
| 444 | }
|
|---|
| 445 | p->setPen( oldPen );
|
|---|
| 446 | break;
|
|---|
| 447 | }
|
|---|
| 448 | case PE_Indicator:
|
|---|
| 449 | {
|
|---|
| 450 | drawPrimitive( PE_ButtonBevel, p, QRect(r.x(), r.y(),
|
|---|
| 451 | r.width() - 2, r.height()),
|
|---|
| 452 | cg, flags );
|
|---|
| 453 | p->fillRect( r.x() + r.width() - 2, r.y(), 2, r.height(),
|
|---|
| 454 | cg.brush( QColorGroup::Background ) );
|
|---|
| 455 | p->setPen( cg.shadow() );
|
|---|
| 456 | p->drawRect( r.x(), r.y(), r.width() - 2, r.height() );
|
|---|
| 457 |
|
|---|
| 458 | static const QCOORD nochange_mark[] = { 3,5, 9,5, 3,6, 9,6 };
|
|---|
| 459 | static const QCOORD check_mark[] = {
|
|---|
| 460 | 3,5, 5,5, 4,6, 5,6, 5,7, 6,7, 5,8, 6,8, 6,9, 9,9,
|
|---|
| 461 | 6,10, 8,10, 7,11, 8,11, 7,12, 7,12, 8,8, 9,8, 8,7, 10,7,
|
|---|
| 462 | 9,6, 10,6, 9,5, 11,5, 10,4, 11,4, 10,3, 12,3,
|
|---|
| 463 | 11,2, 12,2, 11,1, 13,1, 12,0, 13,0 };
|
|---|
| 464 | if ( !(flags & Style_Off) ) {
|
|---|
| 465 | QPen oldPen = p->pen();
|
|---|
| 466 | int x1 = r.x();
|
|---|
| 467 | int y1 = r.y();
|
|---|
| 468 | if ( flags & Style_Down ) {
|
|---|
| 469 | x1++;
|
|---|
| 470 | y1++;
|
|---|
| 471 | }
|
|---|
| 472 | QPointArray amark;
|
|---|
| 473 | if ( flags & Style_On ) {
|
|---|
| 474 | amark = QPointArray( sizeof(check_mark)/(sizeof(QCOORD)*2),
|
|---|
| 475 | check_mark );
|
|---|
| 476 | // ### KLUDGE!!
|
|---|
| 477 | flags ^= Style_On;
|
|---|
| 478 | flags ^= Style_Down;
|
|---|
| 479 | } else if ( flags & Style_NoChange ) {
|
|---|
| 480 | amark = QPointArray( sizeof(nochange_mark)
|
|---|
| 481 | / (sizeof(QCOORD) * 2),
|
|---|
| 482 | nochange_mark );
|
|---|
| 483 | }
|
|---|
| 484 |
|
|---|
| 485 | amark.translate( x1 + 1, y1 + 1 );
|
|---|
| 486 | p->setPen( cg.dark() );
|
|---|
| 487 | p->drawLineSegments( amark );
|
|---|
| 488 | amark.translate( -1, -1 );
|
|---|
| 489 | p->setPen( cg.foreground() );
|
|---|
| 490 | p->drawLineSegments( amark );
|
|---|
| 491 | p->setPen( oldPen );
|
|---|
| 492 | }
|
|---|
| 493 | break;
|
|---|
| 494 | }
|
|---|
| 495 | case PE_IndicatorMask:
|
|---|
| 496 | {
|
|---|
| 497 | int x,
|
|---|
| 498 | y,
|
|---|
| 499 | w,
|
|---|
| 500 | h;
|
|---|
| 501 | r.rect( &x, &y, &w, &h );
|
|---|
| 502 | p->fillRect( x, y, w - 2, h, color1);
|
|---|
| 503 | if ( flags & Style_Off ) {
|
|---|
| 504 | QPen oldPen = p->pen();
|
|---|
| 505 | p->setPen ( QPen(color1, 2));
|
|---|
| 506 | p->drawLine( x + 2, y + h / 2 - 1,
|
|---|
| 507 | x + w / 2 - 1, y + h - 4 );
|
|---|
| 508 | p->drawLine( x + w / 2 - 1, y + h - 4,
|
|---|
| 509 | x + w, 0);
|
|---|
| 510 | p->setPen( oldPen );
|
|---|
| 511 | }
|
|---|
| 512 | break;
|
|---|
| 513 | }
|
|---|
| 514 | case PE_ExclusiveIndicator:
|
|---|
| 515 | {
|
|---|
| 516 | #define QCOORDARRLEN(x) sizeof(x) / (sizeof(QCOORD) * 2 )
|
|---|
| 517 | bool down = flags & Style_Down;
|
|---|
| 518 | bool on = flags & Style_On;
|
|---|
| 519 |
|
|---|
| 520 | static const QCOORD pts1[] = { // normal circle
|
|---|
| 521 | 5,0, 8,0, 9,1, 10,1, 11,2, 12,3, 12,4, 13,5,
|
|---|
| 522 | 13,8, 12,9, 12,10, 11,11, 10,12, 9,12, 8,13,
|
|---|
| 523 | 5,13, 4,12, 3,12, 2,11, 1,10, 1,9, 0,8, 0,5,
|
|---|
| 524 | 1,4, 1,3, 2,2, 3,1, 4,1 };
|
|---|
| 525 | static const QCOORD pts2[] = { // top left shadow
|
|---|
| 526 | 5,1, 8,1, 3,2, 7,2, 2,3, 5,3, 2,4, 4,4,
|
|---|
| 527 | 1,5, 3,5, 1,6, 1,8, 2,6, 2,7 };
|
|---|
| 528 | static const QCOORD pts3[] = { // bottom right, dark
|
|---|
| 529 | 5,12, 8,12, 7,11, 10,11, 8,10, 11,10,
|
|---|
| 530 | 9,9, 11,9, 10,8, 12,8, 11,7, 11,7,
|
|---|
| 531 | 12,5, 12,7 };
|
|---|
| 532 | static const QCOORD pts4[] = { // bottom right, light
|
|---|
| 533 | 5,12, 8,12, 7,11, 10,11, 9,10, 11,10,
|
|---|
| 534 | 10,9, 11,9, 11,7, 11,8, 12,5, 12,8 };
|
|---|
| 535 | static const QCOORD pts5[] = { // check mark
|
|---|
| 536 | 6,4, 8,4, 10,6, 10,8, 8,10, 6,10, 4,8, 4,6 };
|
|---|
| 537 | static const QCOORD pts6[] = { // check mark extras
|
|---|
| 538 | 4,5, 5,4, 9,4, 10,5, 10,9, 9,10, 5,10, 4,9 };
|
|---|
| 539 | int x, y;
|
|---|
| 540 | x = r.x();
|
|---|
| 541 | y = r.y();
|
|---|
| 542 | p->eraseRect( r );
|
|---|
| 543 | p->setBrush( (down||on) ? cg.brush( QColorGroup::Dark )
|
|---|
| 544 | : cg.brush( QColorGroup::Button) );
|
|---|
| 545 | p->setPen( NoPen );
|
|---|
| 546 | p->drawEllipse( x, y, 13, 13 );
|
|---|
| 547 | p->setPen( cg.shadow() );
|
|---|
| 548 | QPointArray a( QCOORDARRLEN(pts1), pts1 );
|
|---|
| 549 | a.translate( x, y );
|
|---|
| 550 | p->drawPolyline( a ); // draw normal circle
|
|---|
| 551 | QColor tc, bc;
|
|---|
| 552 | const QCOORD *bp;
|
|---|
| 553 | int bl;
|
|---|
| 554 | if ( down || on ) { // pressed down or on
|
|---|
| 555 | tc = cg.dark().dark();
|
|---|
| 556 | bc = cg.light();
|
|---|
| 557 | bp = pts4;
|
|---|
| 558 | bl = QCOORDARRLEN(pts4);
|
|---|
| 559 | } else { // released
|
|---|
| 560 | tc = cg.light();
|
|---|
| 561 | bc = cg.dark();
|
|---|
| 562 | bp = pts3;
|
|---|
| 563 | bl = QCOORDARRLEN(pts3);
|
|---|
| 564 | }
|
|---|
| 565 | p->setPen( tc );
|
|---|
| 566 | a.setPoints( QCOORDARRLEN(pts2), pts2 );
|
|---|
| 567 | a.translate( x, y );
|
|---|
| 568 | p->drawLineSegments( a ); // draw top shadow
|
|---|
| 569 | p->setPen( bc );
|
|---|
| 570 | a.setPoints( bl, bp );
|
|---|
| 571 | a.translate( x, y );
|
|---|
| 572 | p->drawLineSegments( a );
|
|---|
| 573 | if ( on ) { // draw check mark
|
|---|
| 574 | int x1 = x,
|
|---|
| 575 | y1 = y;
|
|---|
| 576 | p->setBrush( cg.foreground() );
|
|---|
| 577 | p->setPen( cg.foreground() );
|
|---|
| 578 | a.setPoints( QCOORDARRLEN(pts5), pts5 );
|
|---|
| 579 | a.translate( x1, y1 );
|
|---|
| 580 | p->drawPolygon( a );
|
|---|
| 581 | p->setBrush( NoBrush );
|
|---|
| 582 | p->setPen( cg.dark() );
|
|---|
| 583 | a.setPoints( QCOORDARRLEN(pts6), pts6 );
|
|---|
| 584 | a.translate( x1, y1 );
|
|---|
| 585 | p->drawLineSegments( a );
|
|---|
| 586 | }
|
|---|
| 587 | break;
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | case PE_ExclusiveIndicatorMask:
|
|---|
| 591 | {
|
|---|
| 592 | static const QCOORD pts1[] = { // normal circle
|
|---|
| 593 | 5,0, 8,0, 9,1, 10,1, 11,2, 12,3, 12,4, 13,5,
|
|---|
| 594 | 13,8, 12,9, 12,10, 11,11, 10,12, 9,12, 8,13,
|
|---|
| 595 | 5,13, 4,12, 3,12, 2,11, 1,10, 1,9, 0,8, 0,5,
|
|---|
| 596 | 1,4, 1,3, 2,2, 3,1, 4,1 };
|
|---|
| 597 | QPointArray a(QCOORDARRLEN(pts1), pts1);
|
|---|
| 598 | a.translate(r.x(), r.y());
|
|---|
| 599 | p->setPen(color1);
|
|---|
| 600 | p->setBrush(color1);
|
|---|
| 601 | p->drawPolygon(a);
|
|---|
| 602 | break;
|
|---|
| 603 | }
|
|---|
| 604 | case PE_ScrollBarAddLine:
|
|---|
| 605 | {
|
|---|
| 606 | drawPrimitive( PE_ButtonBevel, p, r, cg,
|
|---|
| 607 | (flags & Style_Enabled) | ((flags & Style_Down)
|
|---|
| 608 | ? Style_Sunken
|
|---|
| 609 | : Style_Raised) );
|
|---|
| 610 | p->setPen( cg.shadow() );
|
|---|
| 611 | p->drawRect( r );
|
|---|
| 612 | drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowRight
|
|---|
| 613 | : PE_ArrowDown), p, QRect(r.x() + 2,
|
|---|
| 614 | r.y() + 2,
|
|---|
| 615 | r.width() - 4,
|
|---|
| 616 | r.height() - 4),
|
|---|
| 617 | cg, flags );
|
|---|
| 618 | break;
|
|---|
| 619 | }
|
|---|
| 620 | case PE_ScrollBarSubLine:
|
|---|
| 621 | {
|
|---|
| 622 | drawPrimitive( PE_ButtonBevel, p, r, cg,
|
|---|
| 623 | (flags & Style_Enabled) | ((flags & Style_Down)
|
|---|
| 624 | ? Style_Sunken
|
|---|
| 625 | : Style_Raised) );
|
|---|
| 626 | p->setPen( cg.shadow() );
|
|---|
| 627 | p->drawRect( r );
|
|---|
| 628 | drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowLeft
|
|---|
| 629 | : PE_ArrowUp ), p, QRect(r.x() + 2,
|
|---|
| 630 | r.y() + 2,
|
|---|
| 631 | r.width() - 4,
|
|---|
| 632 | r.height() - 4),
|
|---|
| 633 | cg, flags );
|
|---|
| 634 | break;
|
|---|
| 635 | }
|
|---|
| 636 | case PE_ScrollBarAddPage:
|
|---|
| 637 | case PE_ScrollBarSubPage:
|
|---|
| 638 | {
|
|---|
| 639 | QPen oldPen = p->pen();
|
|---|
| 640 | if ( r.width() < 3 || r.height() < 3 ) {
|
|---|
| 641 | p->fillRect( r, cg.brush(QColorGroup::Mid) );
|
|---|
| 642 | p->setPen( cg.shadow() );
|
|---|
| 643 | p->drawRect( r );
|
|---|
| 644 | p->setPen( oldPen );
|
|---|
| 645 | } else {
|
|---|
| 646 | int x,
|
|---|
| 647 | y,
|
|---|
| 648 | w,
|
|---|
| 649 | h;
|
|---|
| 650 | r.rect( &x, &y, &w, &h );
|
|---|
| 651 | if ( flags & Style_Horizontal ) {
|
|---|
| 652 | p->fillRect( x + 2, y + 2, w - 2,
|
|---|
| 653 | h - 4,
|
|---|
| 654 | cg.brush(QColorGroup::Mid) );
|
|---|
| 655 | // the dark side
|
|---|
| 656 | p->setPen( cg.dark().dark() );
|
|---|
| 657 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 658 | p->setPen( cg.shadow());
|
|---|
| 659 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 660 |
|
|---|
| 661 | p->setPen( cg.mid().dark());
|
|---|
| 662 | p->drawLine( x + 1, y + 1, x + w - 1,
|
|---|
| 663 | y + 1 );
|
|---|
| 664 | p->drawLine( x + 1, y + 1, x + 1,
|
|---|
| 665 | y + h - 2 );
|
|---|
| 666 |
|
|---|
| 667 | // the bright side!
|
|---|
| 668 |
|
|---|
| 669 | p->setPen( cg.button());
|
|---|
| 670 | p->drawLine( x + 1, y + h - 2,
|
|---|
| 671 | x + w - 1,
|
|---|
| 672 | y + h - 2 );
|
|---|
| 673 | p->setPen( cg.shadow());
|
|---|
| 674 | p->drawLine( x, y + h - 1,
|
|---|
| 675 | x + w - 1,
|
|---|
| 676 | y + h - 1 );
|
|---|
| 677 |
|
|---|
| 678 | } else {
|
|---|
| 679 | p->fillRect( x + 2, y + 2, w - 4,
|
|---|
| 680 | h - 2,
|
|---|
| 681 | cg.brush(QColorGroup::Mid) );
|
|---|
| 682 |
|
|---|
| 683 | // the dark side
|
|---|
| 684 | p->setPen( cg.dark().dark() );
|
|---|
| 685 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 686 | p->setPen( cg.shadow() );
|
|---|
| 687 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 688 |
|
|---|
| 689 | p->setPen( cg.mid().dark() );
|
|---|
| 690 | p->drawLine( x + 1, y + 1, x + w - 2,
|
|---|
| 691 | y + 1 );
|
|---|
| 692 | p->drawLine( x + 1, y + 1, x + 1,
|
|---|
| 693 | y + h - 1 );
|
|---|
| 694 |
|
|---|
| 695 | // the bright side!
|
|---|
| 696 | p->setPen( cg.button() );
|
|---|
| 697 | p->drawLine( x + w - 2, y + 1,
|
|---|
| 698 | x + w - 2,
|
|---|
| 699 | y + h - 1 );
|
|---|
| 700 |
|
|---|
| 701 | p->setPen( cg.shadow() );
|
|---|
| 702 | p->drawLine( x + w - 1, y,
|
|---|
| 703 | x + w - 1,
|
|---|
| 704 | y + h - 1 );
|
|---|
| 705 |
|
|---|
| 706 | }
|
|---|
| 707 | }
|
|---|
| 708 | p->setPen( oldPen );
|
|---|
| 709 | break;
|
|---|
| 710 | }
|
|---|
| 711 | case PE_ScrollBarSlider:
|
|---|
| 712 | {
|
|---|
| 713 | QPoint bo = p->brushOrigin();
|
|---|
| 714 | p->setBrushOrigin( r.topLeft() );
|
|---|
| 715 | drawPrimitive( PE_ButtonBevel, p, r, cg, Style_Raised );
|
|---|
| 716 | p->setBrushOrigin( bo );
|
|---|
| 717 | drawRiffles( p, r.x(), r.y(), r.width(), r.height(), cg,
|
|---|
| 718 | flags & Style_Horizontal );
|
|---|
| 719 | p->setPen( cg.shadow() );
|
|---|
| 720 | p->drawRect( r );
|
|---|
| 721 | if ( flags & Style_HasFocus ) {
|
|---|
| 722 | drawPrimitive( PE_FocusRect, p, QRect(r.x() + 2, r.y() + 2,
|
|---|
| 723 | r.width() - 5,
|
|---|
| 724 | r.height() - 5 ),
|
|---|
| 725 | cg, flags );
|
|---|
| 726 | }
|
|---|
| 727 | break;
|
|---|
| 728 | }
|
|---|
| 729 | default:
|
|---|
| 730 | QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt );
|
|---|
| 731 | break;
|
|---|
| 732 | }
|
|---|
| 733 |
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | /*!\reimp
|
|---|
| 737 | */
|
|---|
| 738 | void QPlatinumStyle::drawControl( ControlElement element,
|
|---|
| 739 | QPainter *p,
|
|---|
| 740 | const QWidget *widget,
|
|---|
| 741 | const QRect &r,
|
|---|
| 742 | const QColorGroup &cg,
|
|---|
| 743 | SFlags how,
|
|---|
| 744 | const QStyleOption& opt ) const
|
|---|
| 745 | {
|
|---|
| 746 | switch( element ) {
|
|---|
| 747 | case CE_PushButton:
|
|---|
| 748 | {
|
|---|
| 749 | #ifndef QT_NO_PUSHBUTTON
|
|---|
| 750 | QColorGroup myCg( cg );
|
|---|
| 751 | const QPushButton *btn;
|
|---|
| 752 | int x1, y1, x2, y2;
|
|---|
| 753 | bool useBevelButton;
|
|---|
| 754 | SFlags flags;
|
|---|
| 755 | flags = Style_Default;
|
|---|
| 756 | btn = (const QPushButton*)widget;
|
|---|
| 757 | p->setBrushOrigin( -widget->backgroundOffset().x(),
|
|---|
| 758 | -widget->backgroundOffset().y() );
|
|---|
| 759 |
|
|---|
| 760 | // take care of the flags based on what we know...
|
|---|
| 761 | if ( btn->isDown() )
|
|---|
| 762 | flags |= Style_Down;
|
|---|
| 763 | if ( btn->isOn() )
|
|---|
| 764 | flags |= Style_On;
|
|---|
| 765 | if ( btn->isEnabled() )
|
|---|
| 766 | flags |= Style_Enabled;
|
|---|
| 767 | if ( btn->isDefault() )
|
|---|
| 768 | flags |= Style_Default;
|
|---|
| 769 | if (! btn->isFlat() && !(flags & Style_Down))
|
|---|
| 770 | flags |= Style_Raised;
|
|---|
| 771 |
|
|---|
| 772 | r.coords( &x1, &y1, &x2, &y2 );
|
|---|
| 773 |
|
|---|
| 774 | p->setPen( cg.foreground() );
|
|---|
| 775 | p->setBrush( QBrush(cg.button(), NoBrush) );
|
|---|
| 776 |
|
|---|
| 777 | QBrush fill;
|
|---|
| 778 | if ( btn->isDown() ) {
|
|---|
| 779 | fill = cg.brush( QColorGroup::Dark );
|
|---|
| 780 | // this could be done differently, but this
|
|---|
| 781 | // makes a down Bezel drawn correctly...
|
|---|
| 782 | myCg.setBrush( QColorGroup::Mid, fill );
|
|---|
| 783 | } else if ( btn->isOn() ) {
|
|---|
| 784 | fill = QBrush( cg.mid(), Dense4Pattern );
|
|---|
| 785 | myCg.setBrush( QColorGroup::Mid, fill );
|
|---|
| 786 | }
|
|---|
| 787 | // to quote the old QPlatinumStlye drawPushButton...
|
|---|
| 788 | // small or square image buttons as well as toggle buttons are
|
|---|
| 789 | // bevel buttons (what a heuristic....)
|
|---|
| 790 | if ( btn->isToggleButton()
|
|---|
| 791 | || ( btn->pixmap() &&
|
|---|
| 792 | (btn->width() * btn->height() < 1600 ||
|
|---|
| 793 | QABS( btn->width() - btn->height()) < 10 )) )
|
|---|
| 794 | useBevelButton = TRUE;
|
|---|
| 795 | else
|
|---|
| 796 | useBevelButton = FALSE;
|
|---|
| 797 |
|
|---|
| 798 | int diw = pixelMetric( PM_ButtonDefaultIndicator, widget );
|
|---|
| 799 | if ( btn->isDefault() ) {
|
|---|
| 800 | x1 += 1;
|
|---|
| 801 | y1 += 1;
|
|---|
| 802 | x2 -= 1;
|
|---|
| 803 | y2 -= 1;
|
|---|
| 804 | QColorGroup cg2( myCg );
|
|---|
| 805 | SFlags myFlags = flags;
|
|---|
| 806 | // don't draw the default button sunken, unless it's necessary.
|
|---|
| 807 | if ( myFlags & Style_Down )
|
|---|
| 808 | myFlags ^= Style_Down;
|
|---|
| 809 | if ( myFlags & Style_Sunken )
|
|---|
| 810 | myFlags ^= Style_Sunken;
|
|---|
| 811 |
|
|---|
| 812 | cg2.setColor( QColorGroup::Button, cg.mid() );
|
|---|
| 813 | if ( useBevelButton ) {
|
|---|
| 814 | drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1,
|
|---|
| 815 | x2 - x1 + 1,
|
|---|
| 816 | y2 - y1 + 1 ),
|
|---|
| 817 | myCg, myFlags, opt );
|
|---|
| 818 | } else {
|
|---|
| 819 | drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1,
|
|---|
| 820 | x2 - x1 + 1,
|
|---|
| 821 | y2 - y1 + 1 ),
|
|---|
| 822 | cg2, myFlags, opt );
|
|---|
| 823 | }
|
|---|
| 824 | }
|
|---|
| 825 |
|
|---|
| 826 | if ( btn->isDefault() || btn->autoDefault() ) {
|
|---|
| 827 | x1 += diw;
|
|---|
| 828 | y1 += diw;
|
|---|
| 829 | x2 -= diw;
|
|---|
| 830 | y2 -= diw;
|
|---|
| 831 | }
|
|---|
| 832 |
|
|---|
| 833 | if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) {
|
|---|
| 834 | if ( useBevelButton ) {
|
|---|
| 835 | // fix for toggle buttons...
|
|---|
| 836 | if ( flags & (Style_Down | Style_On) )
|
|---|
| 837 | flags |= Style_Sunken;
|
|---|
| 838 | drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1,
|
|---|
| 839 | x2 - x1 + 1,
|
|---|
| 840 | y2 - y1 + 1 ),
|
|---|
| 841 | myCg, flags, opt );
|
|---|
| 842 | } else {
|
|---|
| 843 |
|
|---|
| 844 | drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1,
|
|---|
| 845 | x2 - x1 + 1,
|
|---|
| 846 | y2 - y1 + 1 ),
|
|---|
| 847 | myCg, flags, opt );
|
|---|
| 848 | }
|
|---|
| 849 | }
|
|---|
| 850 |
|
|---|
| 851 |
|
|---|
| 852 | if ( p->brush().style() != NoBrush )
|
|---|
| 853 | p->setBrush( NoBrush );
|
|---|
| 854 | break;
|
|---|
| 855 | #endif
|
|---|
| 856 | }
|
|---|
| 857 | case CE_PushButtonLabel:
|
|---|
| 858 | {
|
|---|
| 859 | #ifndef QT_NO_PUSHBUTTON
|
|---|
| 860 | const QPushButton *btn;
|
|---|
| 861 | bool on;
|
|---|
| 862 | int x, y, w, h;
|
|---|
| 863 | SFlags flags;
|
|---|
| 864 | flags = Style_Default;
|
|---|
| 865 | btn = (const QPushButton*)widget;
|
|---|
| 866 | on = btn->isDown() || btn->isOn();
|
|---|
| 867 | r.rect( &x, &y, &w, &h );
|
|---|
| 868 | if ( btn->isMenuButton() ) {
|
|---|
| 869 | int dx = pixelMetric( PM_MenuButtonIndicator, widget );
|
|---|
| 870 |
|
|---|
| 871 | QColorGroup g = cg;
|
|---|
| 872 | int xx = x + w - dx - 4;
|
|---|
| 873 | int yy = y - 3;
|
|---|
| 874 | int hh = h + 6;
|
|---|
| 875 |
|
|---|
| 876 | if ( !on ) {
|
|---|
| 877 | p->setPen( g.mid() );
|
|---|
| 878 | p->drawLine( xx, yy + 2, xx, yy + hh - 3 );
|
|---|
| 879 | p->setPen( g.button() );
|
|---|
| 880 | p->drawLine( xx + 1, yy + 1, xx + 1, yy + hh - 2 );
|
|---|
| 881 | p->setPen( g.light() );
|
|---|
| 882 | p->drawLine( xx + 2, yy + 2, xx + 2, yy + hh - 2 );
|
|---|
| 883 | }
|
|---|
| 884 | if ( btn->isEnabled() )
|
|---|
| 885 | flags |= Style_Enabled;
|
|---|
| 886 | drawPrimitive( PE_ArrowDown, p, QRect(x + w - dx - 1, y + 2,
|
|---|
| 887 | dx, h - 4),
|
|---|
| 888 | g, flags, opt );
|
|---|
| 889 | w -= dx;
|
|---|
| 890 | }
|
|---|
| 891 | #ifndef QT_NO_ICONSET
|
|---|
| 892 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
|
|---|
| 893 | QIconSet::Mode mode = btn->isEnabled()
|
|---|
| 894 | ? QIconSet::Normal : QIconSet::Disabled;
|
|---|
| 895 | if ( mode == QIconSet::Normal && btn->hasFocus() )
|
|---|
| 896 | mode = QIconSet::Active;
|
|---|
| 897 | QIconSet::State state = QIconSet::Off;
|
|---|
| 898 | if ( btn->isToggleButton() && btn->isOn() )
|
|---|
| 899 | state = QIconSet::On;
|
|---|
| 900 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small,
|
|---|
| 901 | mode, state );
|
|---|
| 902 | int pixw = pixmap.width();
|
|---|
| 903 | int pixh = pixmap.height();
|
|---|
| 904 | p->drawPixmap( x + 2, y + h / 2 - pixh / 2, pixmap );
|
|---|
| 905 | x += pixw + 4;
|
|---|
| 906 | w -= pixw + 4;
|
|---|
| 907 | }
|
|---|
| 908 | #endif
|
|---|
| 909 | drawItem( p, QRect( x, y, w, h ),
|
|---|
| 910 | AlignCenter | ShowPrefix,
|
|---|
| 911 | btn->colorGroup(), btn->isEnabled(),
|
|---|
| 912 | btn->pixmap(), btn->text(), -1,
|
|---|
| 913 | on ? &btn->colorGroup().brightText()
|
|---|
| 914 | : &btn->colorGroup().buttonText() );
|
|---|
| 915 | if ( btn->hasFocus() )
|
|---|
| 916 | drawPrimitive( PE_FocusRect, p,
|
|---|
| 917 | subRect(SR_PushButtonFocusRect, widget),
|
|---|
| 918 | cg, flags );
|
|---|
| 919 | break;
|
|---|
| 920 | #endif
|
|---|
| 921 | }
|
|---|
| 922 | default:
|
|---|
| 923 | QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
|
|---|
| 924 | break;
|
|---|
| 925 | }
|
|---|
| 926 | }
|
|---|
| 927 |
|
|---|
| 928 | /*!\reimp
|
|---|
| 929 | */
|
|---|
| 930 | void QPlatinumStyle::drawComplexControl( ComplexControl control,
|
|---|
| 931 | QPainter *p,
|
|---|
| 932 | const QWidget *widget,
|
|---|
| 933 | const QRect &r,
|
|---|
| 934 | const QColorGroup &cg,
|
|---|
| 935 | SFlags how,
|
|---|
| 936 | SCFlags sub,
|
|---|
| 937 | SCFlags subActive,
|
|---|
| 938 | const QStyleOption& opt ) const
|
|---|
| 939 | {
|
|---|
| 940 | switch ( control ) {
|
|---|
| 941 | case CC_ComboBox:
|
|---|
| 942 | {
|
|---|
| 943 | int x,
|
|---|
| 944 | y,
|
|---|
| 945 | w,
|
|---|
| 946 | h;
|
|---|
| 947 | r.rect( &x, &y, &w, &h );
|
|---|
| 948 | p->fillRect( x + 2, y + 2, w - 4,
|
|---|
| 949 | h - 4, cg.brush(QColorGroup::Button) );
|
|---|
| 950 | // the bright side
|
|---|
| 951 | p->setPen(cg.shadow());
|
|---|
| 952 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 953 | p->drawLine( x, y, x, y + h - 1 );
|
|---|
| 954 |
|
|---|
| 955 | p->setPen( cg.light() );
|
|---|
| 956 | p->drawLine( x + 1, y + 1,
|
|---|
| 957 | x + w - 2, y + 1 );
|
|---|
| 958 | p->drawLine( x + 1, y + 1,
|
|---|
| 959 | x + 1, y + h - 2 );
|
|---|
| 960 |
|
|---|
| 961 | // the dark side!
|
|---|
| 962 |
|
|---|
| 963 |
|
|---|
| 964 | p->setPen( cg.mid() );
|
|---|
| 965 | p->drawLine( x + 2, y + h - 2,
|
|---|
| 966 | x + w - 2, y + h - 2 );
|
|---|
| 967 | p->drawLine( x + w - 2, y + 2,
|
|---|
| 968 | x + w - 2, y + h - 2 );
|
|---|
| 969 |
|
|---|
| 970 | p->setPen (cg.shadow() );
|
|---|
| 971 | p->drawLine( x + 1, y + h - 1,
|
|---|
| 972 | x + w - 1, y + h - 1 );
|
|---|
| 973 | p->drawLine( x + w - 1, y,
|
|---|
| 974 | x + w - 1, y + h - 1 );
|
|---|
| 975 |
|
|---|
| 976 | // top left corner:
|
|---|
| 977 | p->setPen( cg.background() );
|
|---|
| 978 | p->drawPoint( x, y );
|
|---|
| 979 | p->drawPoint( x + 1, y );
|
|---|
| 980 | p->drawPoint( x, y + 1 );
|
|---|
| 981 | p->setPen( cg.shadow() );
|
|---|
| 982 | p->drawPoint( x + 1, y + 1 );
|
|---|
| 983 | p->setPen( white );
|
|---|
| 984 | p->drawPoint( x + 3, y + 3 );
|
|---|
| 985 | // bottom left corner:
|
|---|
| 986 | p->setPen( cg.background() );
|
|---|
| 987 | p->drawPoint( x, y + h - 1 );
|
|---|
| 988 | p->drawPoint( x + 1, y + h - 1 );
|
|---|
| 989 | p->drawPoint( x, y + h - 2 );
|
|---|
| 990 | p->setPen( cg.shadow() );
|
|---|
| 991 | p->drawPoint( x + 1, y + h - 2 );
|
|---|
| 992 | // top right corner:
|
|---|
| 993 | p->setPen( cg.background() );
|
|---|
| 994 | p->drawPoint( x + w - 1, y );
|
|---|
| 995 | p->drawPoint( x + w - 2, y );
|
|---|
| 996 | p->drawPoint( x + w - 1, y + 1 );
|
|---|
| 997 | p->setPen( cg.shadow() );
|
|---|
| 998 | p->drawPoint( x + w - 2, y + 1 );
|
|---|
| 999 | // bottom right corner:
|
|---|
| 1000 | p->setPen( cg.background() );
|
|---|
| 1001 | p->drawPoint( x + w - 1, y + h - 1 );
|
|---|
| 1002 | p->drawPoint( x + w - 2, y + h - 1 );
|
|---|
| 1003 | p->drawPoint( x + w - 1, y + h - 2 );
|
|---|
| 1004 | p->setPen( cg.shadow() );
|
|---|
| 1005 | p->drawPoint( x + w - 2, y + h - 2 );
|
|---|
| 1006 | p->setPen( cg.dark() );
|
|---|
| 1007 | p->drawPoint( x + w - 3, y + h - 3 );
|
|---|
| 1008 |
|
|---|
| 1009 | if ( sub & SC_ComboBoxArrow ) {
|
|---|
| 1010 | QRect rTmp = querySubControlMetrics( CC_ComboBox, widget,
|
|---|
| 1011 | SC_ComboBoxArrow, opt );
|
|---|
| 1012 | int xx = rTmp.x(),
|
|---|
| 1013 | yy = rTmp.y(),
|
|---|
| 1014 | ww = rTmp.width(),
|
|---|
| 1015 | hh = rTmp.height();
|
|---|
| 1016 | // the bright side
|
|---|
| 1017 |
|
|---|
| 1018 | p->setPen( cg.mid() );
|
|---|
| 1019 | p->drawLine( xx, yy+2, xx, yy+hh-3 );
|
|---|
| 1020 |
|
|---|
| 1021 | p->setPen( cg.button() );
|
|---|
| 1022 | p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 );
|
|---|
| 1023 | p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 );
|
|---|
| 1024 |
|
|---|
| 1025 | p->setPen( cg.light() );
|
|---|
| 1026 | p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 );
|
|---|
| 1027 | p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 );
|
|---|
| 1028 |
|
|---|
| 1029 |
|
|---|
| 1030 | // the dark side!
|
|---|
| 1031 |
|
|---|
| 1032 | p->setPen( cg.mid() );
|
|---|
| 1033 | p->drawLine( xx+3, yy+hh-3 ,xx+ww-3, yy+hh-3 );
|
|---|
| 1034 | p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 );
|
|---|
| 1035 |
|
|---|
| 1036 | p->setPen( cg.dark() );
|
|---|
| 1037 | p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 );
|
|---|
| 1038 | p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 );
|
|---|
| 1039 |
|
|---|
| 1040 | p->setPen( cg.shadow() );
|
|---|
| 1041 | p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 );
|
|---|
| 1042 | p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 );
|
|---|
| 1043 |
|
|---|
| 1044 | // top right corner:
|
|---|
| 1045 | p->setPen( cg.background() );
|
|---|
| 1046 | p->drawPoint( xx + ww - 1, yy );
|
|---|
| 1047 | p->drawPoint( xx + ww - 2, yy );
|
|---|
| 1048 | p->drawPoint( xx + ww - 1, yy + 1 );
|
|---|
| 1049 | p->setPen( cg.shadow() );
|
|---|
| 1050 | p->drawPoint( xx + ww - 2, yy + 1 );
|
|---|
| 1051 | // bottom right corner:
|
|---|
| 1052 | p->setPen( cg.background() );
|
|---|
| 1053 | p->drawPoint( xx + ww - 1, yy + hh - 1 );
|
|---|
| 1054 | p->drawPoint( xx + ww - 2, yy + hh - 1 );
|
|---|
| 1055 | p->drawPoint( xx + ww - 1, yy + hh - 2 );
|
|---|
| 1056 | p->setPen( cg.shadow() );
|
|---|
| 1057 | p->drawPoint( xx + ww - 2, yy + hh - 2 );
|
|---|
| 1058 | p->setPen( cg.dark() );
|
|---|
| 1059 | p->drawPoint( xx + ww - 3, yy + hh - 3 );
|
|---|
| 1060 | p->setPen( cg.mid() );
|
|---|
| 1061 | p->drawPoint( xx + ww - 4, yy + hh - 4 );
|
|---|
| 1062 |
|
|---|
| 1063 | // and the arrows
|
|---|
| 1064 | p->setPen( cg.foreground() );
|
|---|
| 1065 | QPointArray a ;
|
|---|
| 1066 | a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 );
|
|---|
| 1067 | a.translate( xx + ww / 2, yy + hh / 2 - 3 );
|
|---|
| 1068 | p->drawLineSegments( a, 0, 3 ); // draw arrow
|
|---|
| 1069 | p->drawPoint( a[6] );
|
|---|
| 1070 | a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
|
|---|
| 1071 | a.translate( xx + ww / 2, yy + hh / 2 + 2 );
|
|---|
| 1072 | p->drawLineSegments( a, 0, 3 ); // draw arrow
|
|---|
| 1073 | p->drawPoint( a[6] );
|
|---|
| 1074 |
|
|---|
| 1075 | }
|
|---|
| 1076 | #ifndef QT_NO_COMBOBOX
|
|---|
| 1077 | if ( sub & SC_ComboBoxEditField ) {
|
|---|
| 1078 | const QComboBox *cmb;
|
|---|
| 1079 | cmb = (const QComboBox*)widget;
|
|---|
| 1080 | // sadly this is pretty much the windows code, except
|
|---|
| 1081 | // for the first fillRect call...
|
|---|
| 1082 | QRect re =
|
|---|
| 1083 | QStyle::visualRect( querySubControlMetrics( CC_ComboBox,
|
|---|
| 1084 | widget,
|
|---|
| 1085 | SC_ComboBoxEditField ),
|
|---|
| 1086 | widget );
|
|---|
| 1087 | if ( cmb->hasFocus() && !cmb->editable() )
|
|---|
| 1088 | p->fillRect( re.x() + 1, re.y() + 1,
|
|---|
| 1089 | re.width() - 2, re.height() - 2,
|
|---|
| 1090 | cg.brush( QColorGroup::Highlight ) );
|
|---|
| 1091 |
|
|---|
| 1092 | if ( cmb->hasFocus() ) {
|
|---|
| 1093 | p->setPen( cg.highlightedText() );
|
|---|
| 1094 | p->setBackgroundColor( cg.highlight() );
|
|---|
| 1095 | } else {
|
|---|
| 1096 | p->setPen( cg.text() );
|
|---|
| 1097 | p->setBackgroundColor( cg.background() );
|
|---|
| 1098 | }
|
|---|
| 1099 |
|
|---|
| 1100 | if ( cmb->hasFocus() && !cmb->editable() ) {
|
|---|
| 1101 | QRect re =
|
|---|
| 1102 | QStyle::visualRect( subRect( SR_ComboBoxFocusRect,
|
|---|
| 1103 | cmb ),
|
|---|
| 1104 | widget );
|
|---|
| 1105 | drawPrimitive( PE_FocusRect, p, re, cg,
|
|---|
| 1106 | Style_FocusAtBorder,
|
|---|
| 1107 | QStyleOption(cg.highlight()));
|
|---|
| 1108 | }
|
|---|
| 1109 | if ( cmb->editable() ) {
|
|---|
| 1110 | // need this for the moment...
|
|---|
| 1111 | // was the code in comboButton rect
|
|---|
| 1112 | QRect ir( x + 3, y + 3,
|
|---|
| 1113 | w - 6 - 16, h - 6 );
|
|---|
| 1114 | if ( QApplication::reverseLayout() )
|
|---|
| 1115 | ir.moveBy( 16, 0 );
|
|---|
| 1116 | // end comboButtonRect...
|
|---|
| 1117 | ir.setRect( ir.left() - 1, ir.top() - 1, ir.width() + 2,
|
|---|
| 1118 | ir.height() + 2 );
|
|---|
| 1119 | qDrawShadePanel( p, ir, cg, TRUE, 2, 0 );
|
|---|
| 1120 | }
|
|---|
| 1121 | }
|
|---|
| 1122 | #endif
|
|---|
| 1123 | break;
|
|---|
| 1124 | }
|
|---|
| 1125 | case CC_Slider:
|
|---|
| 1126 | {
|
|---|
| 1127 | #ifndef QT_NO_SLIDER
|
|---|
| 1128 | const QSlider *slider = (const QSlider *) widget;
|
|---|
| 1129 | int thickness = pixelMetric( PM_SliderControlThickness, widget );
|
|---|
| 1130 | int len = pixelMetric( PM_SliderLength, widget );
|
|---|
| 1131 | int ticks = slider->tickmarks();
|
|---|
| 1132 |
|
|---|
| 1133 | QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
|
|---|
| 1134 | opt),
|
|---|
| 1135 | handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
|
|---|
| 1136 | opt);
|
|---|
| 1137 |
|
|---|
| 1138 | if ((sub & SC_SliderGroove) && groove.isValid()) {
|
|---|
| 1139 | p->fillRect( groove, cg.brush(QColorGroup::Background) );
|
|---|
| 1140 |
|
|---|
| 1141 | int x, y, w, h;
|
|---|
| 1142 | int mid = thickness / 2;
|
|---|
| 1143 |
|
|---|
| 1144 | if ( ticks & QSlider::Above )
|
|---|
| 1145 | mid += len / 8;
|
|---|
| 1146 | if ( ticks & QSlider::Below )
|
|---|
| 1147 | mid -= len / 8;
|
|---|
| 1148 |
|
|---|
| 1149 | if ( slider->orientation() == Horizontal ) {
|
|---|
| 1150 | x = 0;
|
|---|
| 1151 | y = groove.y() + mid - 3;
|
|---|
| 1152 | w = slider->width();
|
|---|
| 1153 | h = 7;
|
|---|
| 1154 | } else {
|
|---|
| 1155 | x = groove.x() + mid - 3;
|
|---|
| 1156 | y = 0;
|
|---|
| 1157 | w = 7;
|
|---|
| 1158 | h = slider->height();
|
|---|
| 1159 | }
|
|---|
| 1160 |
|
|---|
| 1161 | p->fillRect( x, y, w, h, cg.brush( QColorGroup::Dark ));
|
|---|
| 1162 | // the dark side
|
|---|
| 1163 | p->setPen( cg.dark() );
|
|---|
| 1164 | p->drawLine( x, y, x + w - 1, y );
|
|---|
| 1165 | p->drawLine( x, y, x, y + h - 1);
|
|---|
| 1166 | p->setPen( cg.shadow() );
|
|---|
| 1167 | p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
|
|---|
| 1168 | p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
|
|---|
| 1169 | // the bright side!
|
|---|
| 1170 | p->setPen(cg.shadow());
|
|---|
| 1171 | p->drawLine( x + 1, y + h - 2, x + w - 2, y + h - 2 );
|
|---|
| 1172 | p->drawLine( x + w - 2, y + 1, x + w - 2, y + h - 2 );
|
|---|
| 1173 | p->setPen( cg.light() );
|
|---|
| 1174 | p->drawLine( x, y + h - 1, x + w - 1, y + h - 1 );
|
|---|
| 1175 | p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
|
|---|
| 1176 | // top left corner:
|
|---|
| 1177 | p->setPen(cg.background());
|
|---|
| 1178 | p->drawPoint( x, y );
|
|---|
| 1179 | p->drawPoint( x + 1, y );
|
|---|
| 1180 | p->drawPoint( x, y + 1 );
|
|---|
| 1181 | p->setPen(cg.shadow());
|
|---|
| 1182 | p->drawPoint( x + 1, y + 1 );
|
|---|
| 1183 | // bottom left corner:
|
|---|
| 1184 | p->setPen( cg.background() );
|
|---|
| 1185 | p->drawPoint( x, y + h - 1 );
|
|---|
| 1186 | p->drawPoint( x + 1, y + h - 1 );
|
|---|
| 1187 | p->drawPoint( x, y + h - 2 );
|
|---|
| 1188 | p->setPen( cg.light() );
|
|---|
| 1189 | p->drawPoint( x + 1, y + h - 2 );
|
|---|
| 1190 | // top right corner:
|
|---|
| 1191 | p->setPen( cg.background() );
|
|---|
| 1192 | p->drawPoint( x + w - 1, y );
|
|---|
| 1193 | p->drawPoint( x + w - 2, y );
|
|---|
| 1194 | p->drawPoint( x + w - 1, y + 1 );
|
|---|
| 1195 | p->setPen( cg.dark() );
|
|---|
| 1196 | p->drawPoint( x + w - 2, y + 1 );
|
|---|
| 1197 | // bottom right corner:
|
|---|
| 1198 | p->setPen( cg.background() );
|
|---|
| 1199 | p->drawPoint( x + w - 1, y + h - 1 );
|
|---|
| 1200 | p->drawPoint( x + w - 2, y + h - 1 );
|
|---|
| 1201 | p->drawPoint( x + w - 1, y + h - 2 );
|
|---|
| 1202 | p->setPen( cg.light() );
|
|---|
| 1203 | p->drawPoint( x + w - 2, y + h - 2 );
|
|---|
| 1204 | p->setPen( cg.dark() );
|
|---|
| 1205 | p->drawPoint( x + w - 3, y + h - 3 );
|
|---|
| 1206 | // ### end slider groove
|
|---|
| 1207 |
|
|---|
| 1208 | if ( how & Style_HasFocus )
|
|---|
| 1209 | drawPrimitive( PE_FocusRect, p, groove, cg );
|
|---|
| 1210 | }
|
|---|
| 1211 |
|
|---|
| 1212 | if ((sub & SC_SliderHandle) && handle.isValid()) {
|
|---|
| 1213 | const QColor c0 = cg.shadow();
|
|---|
| 1214 | const QColor c1 = cg.dark();
|
|---|
| 1215 | const QColor c3 = cg.light();
|
|---|
| 1216 |
|
|---|
| 1217 | int x1 = handle.x();
|
|---|
| 1218 | int x2 = handle.x() + handle.width() - 1;
|
|---|
| 1219 | int y1 = handle.y();
|
|---|
| 1220 | int y2 = handle.y() + handle.height() - 1;
|
|---|
| 1221 | int mx = handle.width() / 2;
|
|---|
| 1222 | int my = handle.height() / 2;
|
|---|
| 1223 |
|
|---|
| 1224 | if ( slider->orientation() == Vertical ) {
|
|---|
| 1225 | // Background
|
|---|
| 1226 | QBrush oldBrush = p->brush();
|
|---|
| 1227 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
|---|
| 1228 | p->setPen( NoPen );
|
|---|
| 1229 | QPointArray a(6);
|
|---|
| 1230 | a.setPoint( 0, x1 + 1, y1 + 1 );
|
|---|
| 1231 | a.setPoint( 1, x2 - my + 2, y1 + 1 );
|
|---|
| 1232 | a.setPoint( 2, x2 - 1, y1 + my - 1 );
|
|---|
| 1233 | a.setPoint( 3, x2 - 1, y2 - my + 1 );
|
|---|
| 1234 | a.setPoint( 4, x2 - my + 2, y2 - 1 );
|
|---|
| 1235 | a.setPoint( 5, x1 + 1, y2 - 1 );
|
|---|
| 1236 | p->drawPolygon( a );
|
|---|
| 1237 | p->setBrush( oldBrush );
|
|---|
| 1238 |
|
|---|
| 1239 | // shadow border
|
|---|
| 1240 | p->setPen( c0 );
|
|---|
| 1241 | p->drawLine( x1, y1 + 1, x1,y2 - 1 );
|
|---|
| 1242 | p->drawLine( x2 - my + 2, y1, x2, y1 + my - 2 );
|
|---|
| 1243 | p->drawLine( x2 - my + 2, y2, x2, y1 + my + 2 );
|
|---|
| 1244 | p->drawLine( x2, y1 + my - 2, x2, y1 + my + 2 );
|
|---|
| 1245 | p->drawLine( x1 + 1, y1, x2 - my + 2, y1 );
|
|---|
| 1246 | p->drawLine( x1 + 1, y2, x2 - my + 2, y2 );
|
|---|
| 1247 |
|
|---|
| 1248 | // light shadow
|
|---|
| 1249 | p->setPen( c3 );
|
|---|
| 1250 | p->drawLine( x1 + 1, y1 + 2, x1 + 1, y2 - 2 );
|
|---|
| 1251 | p->drawLine( x1 + 1, y1 + 1, x2 - my + 2, y1 + 1 );
|
|---|
| 1252 | p->drawLine( x2 - my + 2, y1 + 1, x2 - 1, y1 + my - 2 );
|
|---|
| 1253 |
|
|---|
| 1254 | // dark shadow
|
|---|
| 1255 | p->setPen(c1);
|
|---|
| 1256 | p->drawLine( x2 - 1, y1 + my - 2, x2 - 1, y1 + my + 2 );
|
|---|
| 1257 | p->drawLine( x2 - my + 2, y2 - 1, x2 - 1, y1 + my + 2 );
|
|---|
| 1258 | p->drawLine( x1 + 1, y2 - 1, x2 -my + 2, y2 - 1 );
|
|---|
| 1259 |
|
|---|
| 1260 | drawRiffles( p, handle.x(), handle.y() + 2, handle.width() - 3,
|
|---|
| 1261 | handle.height() - 4, cg, TRUE );
|
|---|
| 1262 | } else { // Horizontal
|
|---|
| 1263 | QBrush oldBrush = p->brush();
|
|---|
| 1264 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
|---|
| 1265 | p->setPen( NoPen );
|
|---|
| 1266 | QPointArray a(6);
|
|---|
| 1267 | a.setPoint( 0, x2 - 1, y1 + 1 );
|
|---|
| 1268 | a.setPoint( 1, x2 - 1, y2 - mx + 2 );
|
|---|
| 1269 | a.setPoint( 2, x2 - mx + 1, y2 - 1 );
|
|---|
| 1270 | a.setPoint( 3, x1 + mx - 1, y2 - 1 );
|
|---|
| 1271 | a.setPoint( 4, x1 + 1, y2 - mx + 2 );
|
|---|
| 1272 | a.setPoint( 5, x1 + 1, y1 + 1 );
|
|---|
| 1273 | p->drawPolygon( a );
|
|---|
| 1274 | p->setBrush( oldBrush );
|
|---|
| 1275 |
|
|---|
| 1276 | // shadow border
|
|---|
| 1277 | p->setPen( c0 );
|
|---|
| 1278 | p->drawLine( x1 + 1, y1, x2 - 1, y1 );
|
|---|
| 1279 | p->drawLine( x1, y2 - mx + 2, x1 + mx - 2, y2 );
|
|---|
| 1280 | p->drawLine( x2, y2 - mx + 2, x1 + mx + 2, y2 );
|
|---|
| 1281 | p->drawLine( x1 + mx - 2, y2, x1 + mx + 2, y2 );
|
|---|
| 1282 | p->drawLine( x1, y1 + 1, x1, y2 - mx + 2 );
|
|---|
| 1283 | p->drawLine( x2, y1 + 1, x2, y2 - mx + 2 );
|
|---|
| 1284 |
|
|---|
| 1285 | // light shadow
|
|---|
| 1286 | p->setPen(c3);
|
|---|
| 1287 | p->drawLine( x1 + 1, y1 + 1, x2 - 1, y1 + 1 );
|
|---|
| 1288 | p->drawLine( x1 + 1, y1 + 1, x1 + 1, y2 - mx + 2 );
|
|---|
| 1289 |
|
|---|
| 1290 | // dark shadow
|
|---|
| 1291 | p->setPen(c1);
|
|---|
| 1292 | p->drawLine( x2 - 1, y1 + 1, x2 - 1, y2 - mx + 2 );
|
|---|
| 1293 | p->drawLine( x1 + 1, y2 - mx + 2, x1 + mx - 2, y2 - 1 );
|
|---|
| 1294 | p->drawLine( x2 - 1, y2 - mx + 2, x1 + mx + 2, y2 - 1 );
|
|---|
| 1295 | p->drawLine( x1 + mx - 2, y2 - 1, x1 + mx + 2, y2 - 1 );
|
|---|
| 1296 |
|
|---|
| 1297 | drawRiffles( p, handle.x() + 2, handle.y(), handle.width() - 4,
|
|---|
| 1298 | handle.height() - 5, cg, FALSE );
|
|---|
| 1299 | }
|
|---|
| 1300 | }
|
|---|
| 1301 |
|
|---|
| 1302 | if ( sub & SC_SliderTickmarks )
|
|---|
| 1303 | QCommonStyle::drawComplexControl( control, p, widget, r,
|
|---|
| 1304 | cg, how, SC_SliderTickmarks,
|
|---|
| 1305 | subActive, opt );
|
|---|
| 1306 | #endif
|
|---|
| 1307 | break;
|
|---|
| 1308 | }
|
|---|
| 1309 | default:
|
|---|
| 1310 | QWindowsStyle::drawComplexControl( control, p, widget, r, cg,
|
|---|
| 1311 | how, sub, subActive, opt );
|
|---|
| 1312 | break;
|
|---|
| 1313 | }
|
|---|
| 1314 | }
|
|---|
| 1315 |
|
|---|
| 1316 |
|
|---|
| 1317 |
|
|---|
| 1318 | /*!\reimp
|
|---|
| 1319 | */
|
|---|
| 1320 | QRect QPlatinumStyle::querySubControlMetrics( ComplexControl control,
|
|---|
| 1321 | const QWidget *widget,
|
|---|
| 1322 | SubControl sc,
|
|---|
| 1323 | const QStyleOption& opt ) const
|
|---|
| 1324 | {
|
|---|
| 1325 | switch( control ) {
|
|---|
| 1326 | #ifndef QT_NO_COMBOBOX
|
|---|
| 1327 | case CC_ComboBox:
|
|---|
| 1328 | const QComboBox *cb;
|
|---|
| 1329 | cb = (const QComboBox *)widget;
|
|---|
| 1330 | switch( sc ) {
|
|---|
| 1331 | case SC_ComboBoxArrow: {
|
|---|
| 1332 | QRect ir = cb->rect();
|
|---|
| 1333 | int xx;
|
|---|
| 1334 | if( QApplication::reverseLayout() )
|
|---|
| 1335 | xx = ir.x();
|
|---|
| 1336 | else
|
|---|
| 1337 | xx = ir.x() + ir.width() - 20;
|
|---|
| 1338 | return QRect( xx, ir.y(), 20, ir.height()); }
|
|---|
| 1339 | default:
|
|---|
| 1340 | break;
|
|---|
| 1341 | }
|
|---|
| 1342 | break;
|
|---|
| 1343 | #endif
|
|---|
| 1344 | #ifndef QT_NO_SCROLLBAR
|
|---|
| 1345 | case CC_ScrollBar: {
|
|---|
| 1346 | const QScrollBar *sb;
|
|---|
| 1347 | sb = (const QScrollBar *)widget;
|
|---|
| 1348 | int sliderStart = sb->sliderStart();
|
|---|
| 1349 | int sbextent = pixelMetric( PM_ScrollBarExtent, widget );
|
|---|
| 1350 | int maxlen = ((sb->orientation() == Qt::Horizontal) ?
|
|---|
| 1351 | sb->width() : sb->height()) - ( sbextent * 2 );
|
|---|
| 1352 |
|
|---|
| 1353 | int sliderlen;
|
|---|
| 1354 |
|
|---|
| 1355 | // calculate length
|
|---|
| 1356 | if ( sb->maxValue() != sb->minValue() ) {
|
|---|
| 1357 | uint range = sb->maxValue() - sb->minValue();
|
|---|
| 1358 | sliderlen = ( sb->pageStep() * maxlen ) /
|
|---|
| 1359 | ( range + sb->pageStep() );
|
|---|
| 1360 |
|
|---|
| 1361 | int slidermin = pixelMetric( PM_ScrollBarSliderMin, widget );
|
|---|
| 1362 | if ( sliderlen < slidermin || range > INT_MAX / 2 )
|
|---|
| 1363 | sliderlen = slidermin;
|
|---|
| 1364 | if ( sliderlen > maxlen )
|
|---|
| 1365 | sliderlen = maxlen;
|
|---|
| 1366 | } else {
|
|---|
| 1367 | sliderlen = maxlen;
|
|---|
| 1368 | }
|
|---|
| 1369 |
|
|---|
| 1370 | switch ( sc ) {
|
|---|
| 1371 | case SC_ScrollBarSubLine:
|
|---|
| 1372 | if ( sb->orientation() == Qt::Horizontal ) {
|
|---|
| 1373 | int buttonw = QMIN( sb->width() / 2, sbextent );
|
|---|
| 1374 | return QRect( sb->width() - 2 * buttonw, 0, buttonw, sbextent );
|
|---|
| 1375 | } else {
|
|---|
| 1376 | int buttonh = QMIN( sb->height() / 2, sbextent );
|
|---|
| 1377 | return QRect( 0, sb->height() - 2 * buttonh, sbextent, buttonh );
|
|---|
| 1378 | }
|
|---|
| 1379 | case SC_ScrollBarAddLine:
|
|---|
| 1380 | if ( sb->orientation() == Qt::Horizontal ) {
|
|---|
| 1381 | int buttonw = QMIN( sb->width() / 2, sbextent );
|
|---|
| 1382 | return QRect( sb->width() - buttonw, 0, sbextent, buttonw );
|
|---|
| 1383 | } else {
|
|---|
| 1384 | int buttonh = QMIN( sb->height() / 2, sbextent );
|
|---|
| 1385 | return QRect(0, sb->height() - buttonh, sbextent, buttonh );
|
|---|
| 1386 | }
|
|---|
| 1387 | case SC_ScrollBarSubPage:
|
|---|
| 1388 | if ( sb->orientation() == Qt::Horizontal )
|
|---|
| 1389 | return QRect( 1, 0, sliderStart, sbextent );
|
|---|
| 1390 | return QRect( 0, 1, sbextent, sliderStart );
|
|---|
| 1391 | case SC_ScrollBarAddPage:
|
|---|
| 1392 | if ( sb->orientation() == Qt::Horizontal )
|
|---|
| 1393 | return QRect( sliderStart + sliderlen, 0, maxlen - sliderStart - sliderlen, sbextent );
|
|---|
| 1394 | return QRect( 0, sliderStart + sliderlen, sbextent, maxlen - sliderStart - sliderlen );
|
|---|
| 1395 | case SC_ScrollBarGroove:
|
|---|
| 1396 | if ( sb->orientation() == Qt::Horizontal )
|
|---|
| 1397 | return QRect( 1, 0, sb->width() - sbextent * 2, sb->height() );
|
|---|
| 1398 | return QRect( 0, 1, sb->width(), sb->height() - sbextent * 2 );
|
|---|
| 1399 | default:
|
|---|
| 1400 | break;
|
|---|
| 1401 | }
|
|---|
| 1402 | break; }
|
|---|
| 1403 | #endif
|
|---|
| 1404 | #ifndef QT_NO_SLIDER
|
|---|
| 1405 | case CC_Slider: {
|
|---|
| 1406 |
|
|---|
| 1407 | const QSlider *slider = (const QSlider *) widget;
|
|---|
| 1408 | int tickOffset = pixelMetric( PM_SliderTickmarkOffset, widget);
|
|---|
| 1409 | int thickness = pixelMetric( PM_SliderControlThickness, widget);
|
|---|
| 1410 | int mid = thickness / 2;
|
|---|
| 1411 | int ticks = slider->tickmarks();
|
|---|
| 1412 | int len = pixelMetric( PM_SliderLength, widget );
|
|---|
| 1413 |
|
|---|
| 1414 | switch ( sc ) {
|
|---|
| 1415 | case SC_SliderGroove:
|
|---|
| 1416 | if ( ticks & QSlider::Above )
|
|---|
| 1417 | mid += len / 8;
|
|---|
| 1418 | if ( ticks & QSlider::Below )
|
|---|
| 1419 | mid -= len / 8;
|
|---|
| 1420 | if ( slider->orientation() == QSlider::Horizontal )
|
|---|
| 1421 | return QRect( 0, tickOffset, slider->width(), thickness );
|
|---|
| 1422 | return QRect( tickOffset, 0, thickness, slider->height() );
|
|---|
| 1423 | default:
|
|---|
| 1424 | break;
|
|---|
| 1425 | }
|
|---|
| 1426 | break; }
|
|---|
| 1427 | #endif
|
|---|
| 1428 | default:
|
|---|
| 1429 | break;
|
|---|
| 1430 | }
|
|---|
| 1431 | return QWindowsStyle::querySubControlMetrics( control, widget, sc, opt );
|
|---|
| 1432 | }
|
|---|
| 1433 |
|
|---|
| 1434 |
|
|---|
| 1435 | /*!\reimp
|
|---|
| 1436 | */
|
|---|
| 1437 | int QPlatinumStyle::pixelMetric( PixelMetric metric,
|
|---|
| 1438 | const QWidget *widget ) const
|
|---|
| 1439 | {
|
|---|
| 1440 | int ret;
|
|---|
| 1441 | switch( metric ) {
|
|---|
| 1442 | case PM_ButtonDefaultIndicator:
|
|---|
| 1443 | ret = 3;
|
|---|
| 1444 | break;
|
|---|
| 1445 | case PM_ButtonShiftHorizontal:
|
|---|
| 1446 | case PM_ButtonShiftVertical:
|
|---|
| 1447 | ret = 0;
|
|---|
| 1448 | break;
|
|---|
| 1449 | case PM_IndicatorWidth:
|
|---|
| 1450 | ret = 15;
|
|---|
| 1451 | break;
|
|---|
| 1452 | case PM_IndicatorHeight:
|
|---|
| 1453 | ret = 13;
|
|---|
| 1454 | break;
|
|---|
| 1455 | case PM_ExclusiveIndicatorHeight:
|
|---|
| 1456 | case PM_ExclusiveIndicatorWidth:
|
|---|
| 1457 | ret = 15;
|
|---|
| 1458 | break;
|
|---|
| 1459 | case PM_SliderLength:
|
|---|
| 1460 | ret = 17;
|
|---|
| 1461 | break;
|
|---|
| 1462 | case PM_MaximumDragDistance:
|
|---|
| 1463 | ret = -1;
|
|---|
| 1464 | break;
|
|---|
| 1465 | default:
|
|---|
| 1466 | ret = QWindowsStyle::pixelMetric( metric, widget );
|
|---|
| 1467 | break;
|
|---|
| 1468 | }
|
|---|
| 1469 | return ret;
|
|---|
| 1470 | }
|
|---|
| 1471 |
|
|---|
| 1472 | /*!\reimp
|
|---|
| 1473 | */
|
|---|
| 1474 | QRect QPlatinumStyle::subRect( SubRect r, const QWidget *widget ) const
|
|---|
| 1475 | {
|
|---|
| 1476 | QRect rect;
|
|---|
| 1477 | switch ( r ) {
|
|---|
| 1478 | case SR_ComboBoxFocusRect:
|
|---|
| 1479 | {
|
|---|
| 1480 | QRect tmpR = widget->rect();
|
|---|
| 1481 | rect = QRect( tmpR.x() + 4, tmpR.y() + 4, tmpR.width() - 8 - 16,
|
|---|
| 1482 | tmpR.height() - 8 );
|
|---|
| 1483 | break;
|
|---|
| 1484 | }
|
|---|
| 1485 | default:
|
|---|
| 1486 | rect = QWindowsStyle::subRect( r, widget );
|
|---|
| 1487 | break;
|
|---|
| 1488 | }
|
|---|
| 1489 | return rect;
|
|---|
| 1490 | }
|
|---|
| 1491 |
|
|---|
| 1492 | /*!
|
|---|
| 1493 | Mixes two colors \a c1 and \a c2 to a new color.
|
|---|
| 1494 | */
|
|---|
| 1495 | QColor QPlatinumStyle::mixedColor(const QColor &c1, const QColor &c2) const
|
|---|
| 1496 | {
|
|---|
| 1497 | int h1,s1,v1,h2,s2,v2;
|
|---|
| 1498 | c1.hsv(&h1,&s1,&v1);
|
|---|
| 1499 | c2.hsv(&h2,&s2,&v2);
|
|---|
| 1500 | return QColor( (h1+h2)/2, (s1+s2)/2, (v1+v2)/2, QColor::Hsv );
|
|---|
| 1501 | }
|
|---|
| 1502 |
|
|---|
| 1503 | /*!
|
|---|
| 1504 | Draws the nifty Macintosh decoration used on sliders using painter
|
|---|
| 1505 | \a p and colorgroup \a g. \a x, \a y, \a w, \a h and \a horizontal
|
|---|
| 1506 | specify the geometry and orientation of the riffles.
|
|---|
| 1507 | */
|
|---|
| 1508 | void QPlatinumStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
|
|---|
| 1509 | const QColorGroup &g, bool horizontal ) const
|
|---|
| 1510 | {
|
|---|
| 1511 | if (!horizontal) {
|
|---|
| 1512 | if (h > 20) {
|
|---|
| 1513 | y += (h-20)/2 ;
|
|---|
| 1514 | h = 20;
|
|---|
| 1515 | }
|
|---|
| 1516 | if (h > 8) {
|
|---|
| 1517 | int n = h / 4;
|
|---|
| 1518 | int my = y+h/2-n;
|
|---|
| 1519 | int i ;
|
|---|
| 1520 | p->setPen(g.light());
|
|---|
| 1521 | for (i=0; i<n; i++) {
|
|---|
| 1522 | p->drawLine(x+3, my+2*i, x+w-5, my+2*i);
|
|---|
| 1523 | }
|
|---|
| 1524 | p->setPen(g.dark());
|
|---|
| 1525 | my++;
|
|---|
| 1526 | for (i=0; i<n; i++) {
|
|---|
| 1527 | p->drawLine(x+4, my+2*i, x+w-4, my+2*i);
|
|---|
| 1528 | }
|
|---|
| 1529 | }
|
|---|
| 1530 | }
|
|---|
| 1531 | else {
|
|---|
| 1532 | if (w > 20) {
|
|---|
| 1533 | x += (w-20)/2 ;
|
|---|
| 1534 | w = 20;
|
|---|
| 1535 | }
|
|---|
| 1536 | if (w > 8) {
|
|---|
| 1537 | int n = w / 4;
|
|---|
| 1538 | int mx = x+w/2-n;
|
|---|
| 1539 | int i ;
|
|---|
| 1540 | p->setPen(g.light());
|
|---|
| 1541 | for (i=0; i<n; i++) {
|
|---|
| 1542 | p->drawLine(mx+2*i, y+3, mx + 2*i, y+h-5);
|
|---|
| 1543 | }
|
|---|
| 1544 | p->setPen(g.dark());
|
|---|
| 1545 | mx++;
|
|---|
| 1546 | for (i=0; i<n; i++) {
|
|---|
| 1547 | p->drawLine(mx+2*i, y+4, mx + 2*i, y+h-4);
|
|---|
| 1548 | }
|
|---|
| 1549 | }
|
|---|
| 1550 | }
|
|---|
| 1551 | }
|
|---|
| 1552 |
|
|---|
| 1553 |
|
|---|
| 1554 | #endif
|
|---|