[2] | 1 | /****************************************************************************
|
---|
| 2 | ** $Id: qwindowsstyle.cpp 54 2006-01-15 22:16:48Z dmik $
|
---|
| 3 | **
|
---|
| 4 | ** Implementation of Windows-like style class
|
---|
| 5 | **
|
---|
| 6 | ** Created : 981231
|
---|
| 7 | **
|
---|
| 8 | ** Copyright (C) 1998-2000 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 "qwindowsstyle.h"
|
---|
| 39 |
|
---|
| 40 | #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
|
---|
| 41 |
|
---|
| 42 | #include "qpopupmenu.h"
|
---|
| 43 | #include "qapplication.h"
|
---|
| 44 | #include "qpainter.h"
|
---|
| 45 | #include "qdrawutil.h" // for now
|
---|
| 46 | #include "qpixmap.h" // for now
|
---|
| 47 | #include "qwidget.h"
|
---|
| 48 | #include "qlabel.h"
|
---|
| 49 | #include "qimage.h"
|
---|
| 50 | #include "qpushbutton.h"
|
---|
| 51 | #include "qcombobox.h"
|
---|
| 52 | #include "qlistbox.h"
|
---|
| 53 | #include "qwidget.h"
|
---|
| 54 | #include "qrangecontrol.h"
|
---|
| 55 | #include "qscrollbar.h"
|
---|
| 56 | #include "qslider.h"
|
---|
| 57 | #include "qtabwidget.h"
|
---|
| 58 | #include "qtabbar.h"
|
---|
| 59 | #include "qlistview.h"
|
---|
| 60 | #include "qbitmap.h"
|
---|
| 61 | #include "qcleanuphandler.h"
|
---|
| 62 | #include "qdockwindow.h"
|
---|
| 63 | #include "qobjectlist.h"
|
---|
| 64 | #include "qmenubar.h"
|
---|
| 65 |
|
---|
| 66 | #if defined(Q_WS_WIN)
|
---|
| 67 | #include "qt_windows.h"
|
---|
| 68 | #endif
|
---|
| 69 |
|
---|
| 70 | #include <limits.h>
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | static const int windowsItemFrame = 2; // menu item frame width
|
---|
| 74 | static const int windowsSepHeight = 2; // separator item height
|
---|
| 75 | static const int windowsItemHMargin = 3; // menu item hor text margin
|
---|
| 76 | static const int windowsItemVMargin = 2; // menu item ver text margin
|
---|
| 77 | static const int windowsArrowHMargin = 6; // arrow horizontal margin
|
---|
| 78 | static const int windowsTabSpacing = 12; // space between text and tab
|
---|
| 79 | static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark
|
---|
| 80 | static const int windowsRightBorder = 12; // right border on windows
|
---|
| 81 | static const int windowsCheckMarkWidth = 12; // checkmarks width on windows
|
---|
| 82 |
|
---|
| 83 | static bool use2000style = TRUE;
|
---|
| 84 |
|
---|
| 85 | enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
|
---|
| 86 |
|
---|
[8] | 87 | #ifndef QT_NO_MENUDATA
|
---|
[2] | 88 | // A friendly class providing access to QMenuData's protected member.
|
---|
| 89 | class FriendlyMenuData : public QMenuData
|
---|
| 90 | {
|
---|
| 91 | friend class QWindowsStyle;
|
---|
| 92 | };
|
---|
[8] | 93 | #endif
|
---|
[2] | 94 |
|
---|
| 95 | // Private class
|
---|
| 96 | class QWindowsStyle::Private : public QObject
|
---|
| 97 | {
|
---|
| 98 | public:
|
---|
| 99 | Private(QWindowsStyle *parent);
|
---|
| 100 |
|
---|
| 101 | bool hasSeenAlt(const QWidget *widget) const;
|
---|
| 102 | bool altDown() const { return alt_down; }
|
---|
| 103 |
|
---|
| 104 | protected:
|
---|
| 105 | bool eventFilter(QObject *o, QEvent *e);
|
---|
| 106 |
|
---|
| 107 | private:
|
---|
| 108 | QPtrList<QWidget> seenAlt;
|
---|
| 109 | bool alt_down;
|
---|
| 110 | int menuBarTimer;
|
---|
| 111 | };
|
---|
| 112 |
|
---|
| 113 | QWindowsStyle::Private::Private(QWindowsStyle *parent)
|
---|
| 114 | : QObject(parent, "QWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0)
|
---|
| 115 | {
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | // Returns true if the toplevel parent of \a widget has seen the Alt-key
|
---|
| 119 | bool QWindowsStyle::Private::hasSeenAlt(const QWidget *widget) const
|
---|
| 120 | {
|
---|
| 121 | widget = widget->topLevelWidget();
|
---|
| 122 | return seenAlt.contains(widget);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | // Records Alt- and Focus events
|
---|
| 126 | bool QWindowsStyle::Private::eventFilter(QObject *o, QEvent *e)
|
---|
| 127 | {
|
---|
| 128 | if (!o->isWidgetType())
|
---|
| 129 | return QObject::eventFilter(o, e);
|
---|
| 130 |
|
---|
| 131 | QWidget *widget = ::qt_cast<QWidget*>(o);
|
---|
| 132 |
|
---|
| 133 | switch(e->type()) {
|
---|
| 134 | case QEvent::KeyPress:
|
---|
| 135 | if (((QKeyEvent*)e)->key() == Key_Alt) {
|
---|
| 136 | widget = widget->topLevelWidget();
|
---|
| 137 |
|
---|
| 138 | // Alt has been pressed - find all widgets that care
|
---|
| 139 | QObjectList *l = widget->queryList("QWidget");
|
---|
| 140 | QObjectListIt it( *l );
|
---|
| 141 | QWidget *w;
|
---|
| 142 | while ( (w = (QWidget*)it.current()) != 0 ) {
|
---|
| 143 | ++it;
|
---|
| 144 | if (w->isTopLevel() || !w->isVisible() ||
|
---|
| 145 | w->style().styleHint(SH_UnderlineAccelerator, w))
|
---|
| 146 | l->removeRef(w);
|
---|
| 147 | }
|
---|
| 148 | // Update states before repainting
|
---|
| 149 | seenAlt.append(widget);
|
---|
| 150 | alt_down = TRUE;
|
---|
| 151 |
|
---|
| 152 | // Repaint all relevant widgets
|
---|
| 153 | it.toFirst();
|
---|
| 154 | while ( (w = (QWidget*)it.current()) != 0 ) {
|
---|
| 155 | ++it;
|
---|
| 156 | w->repaint(FALSE);
|
---|
| 157 | }
|
---|
| 158 | delete l;
|
---|
| 159 | }
|
---|
| 160 | break;
|
---|
| 161 | case QEvent::KeyRelease:
|
---|
[8] | 162 | #ifndef QT_NO_MENUDATA
|
---|
[2] | 163 | if (((QKeyEvent*)e)->key() == Key_Alt) {
|
---|
| 164 | widget = widget->topLevelWidget();
|
---|
| 165 |
|
---|
| 166 | // Update state
|
---|
| 167 | alt_down = FALSE;
|
---|
| 168 | // Repaint only menubars
|
---|
| 169 | QObjectList *l = widget->queryList("QMenuBar");
|
---|
| 170 | QObjectListIt it( *l );
|
---|
| 171 | QMenuBar *menuBar;
|
---|
| 172 | while ( (menuBar = (QMenuBar*)it.current()) != 0) {
|
---|
| 173 | ++it;
|
---|
| 174 | menuBar->repaint(FALSE);
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
[8] | 177 | #endif
|
---|
[2] | 178 | break;
|
---|
| 179 | case QEvent::FocusIn:
|
---|
| 180 | case QEvent::FocusOut:
|
---|
[8] | 181 | #ifndef QT_NO_MENUBAR
|
---|
[2] | 182 | {
|
---|
| 183 | // Menubars toggle based on focus
|
---|
| 184 | QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o);
|
---|
| 185 | if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker
|
---|
| 186 | menuBarTimer = menuBar->startTimer(0);
|
---|
| 187 | }
|
---|
[8] | 188 | #endif
|
---|
[2] | 189 | break;
|
---|
| 190 | case QEvent::Close:
|
---|
| 191 | // Reset widget when closing
|
---|
| 192 | seenAlt.removeRef(widget);
|
---|
| 193 | seenAlt.removeRef(widget->topLevelWidget());
|
---|
| 194 | break;
|
---|
| 195 | case QEvent::Timer:
|
---|
[8] | 196 | #ifndef QT_NO_MENUBAR
|
---|
[2] | 197 | {
|
---|
| 198 | QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o);
|
---|
| 199 | QTimerEvent *te = (QTimerEvent*)e;
|
---|
| 200 | if (menuBar && te->timerId() == menuBarTimer) {
|
---|
| 201 | menuBar->killTimer(te->timerId());
|
---|
| 202 | menuBarTimer = 0;
|
---|
| 203 | menuBar->repaint(FALSE);
|
---|
| 204 | return TRUE;
|
---|
| 205 | }
|
---|
| 206 | }
|
---|
[8] | 207 | #endif
|
---|
[2] | 208 | break;
|
---|
| 209 | default:
|
---|
| 210 | break;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | return QObject::eventFilter(o, e);
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | /*!
|
---|
| 217 | \class QWindowsStyle qwindowsstyle.h
|
---|
| 218 | \brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
|
---|
| 219 |
|
---|
| 220 | \ingroup appearance
|
---|
| 221 |
|
---|
| 222 | This style is Qt's default GUI style on Windows.
|
---|
| 223 | */
|
---|
| 224 |
|
---|
| 225 | /*!
|
---|
| 226 | Constructs a QWindowsStyle
|
---|
| 227 | */
|
---|
| 228 | QWindowsStyle::QWindowsStyle() : QCommonStyle(), d(0)
|
---|
| 229 | {
|
---|
| 230 | #if defined(Q_OS_WIN32)
|
---|
| 231 | use2000style = qWinVersion() != Qt::WV_NT && qWinVersion() != Qt::WV_95;
|
---|
| 232 | #endif
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | /*! \reimp */
|
---|
| 236 | QWindowsStyle::~QWindowsStyle()
|
---|
| 237 | {
|
---|
| 238 | delete d;
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | /*! \reimp */
|
---|
| 242 | void QWindowsStyle::polish(QApplication *app)
|
---|
| 243 | {
|
---|
| 244 | // We only need the overhead when shortcuts are sometimes hidden
|
---|
| 245 | if (!styleHint(SH_UnderlineAccelerator, 0)) {
|
---|
| 246 | d = new Private(this);
|
---|
| 247 | app->installEventFilter(d);
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | /*! \reimp */
|
---|
| 252 | void QWindowsStyle::unPolish(QApplication *)
|
---|
| 253 | {
|
---|
| 254 | delete d;
|
---|
| 255 | d = 0;
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | /*! \reimp */
|
---|
| 259 | void QWindowsStyle::polish(QWidget *widget)
|
---|
| 260 | {
|
---|
| 261 | QCommonStyle::polish(widget);
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /*! \reimp */
|
---|
| 265 | void QWindowsStyle::unPolish(QWidget *widget)
|
---|
| 266 | {
|
---|
| 267 | QCommonStyle::polish(widget);
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | /*! \reimp */
|
---|
| 271 | void QWindowsStyle::polish( QPalette &pal )
|
---|
| 272 | {
|
---|
| 273 | QCommonStyle::polish(pal);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | /*! \reimp */
|
---|
| 277 | void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
|
---|
| 278 | QPainter *p,
|
---|
| 279 | const QRect &r,
|
---|
| 280 | const QColorGroup &cg,
|
---|
| 281 | SFlags flags,
|
---|
| 282 | const QStyleOption& opt ) const
|
---|
| 283 | {
|
---|
| 284 | QRect rr( r );
|
---|
| 285 | switch (pe) {
|
---|
| 286 | case PE_ButtonCommand:
|
---|
| 287 | {
|
---|
| 288 | QBrush fill;
|
---|
| 289 |
|
---|
| 290 | if (! (flags & Style_Down) && (flags & Style_On))
|
---|
| 291 | fill = QBrush(cg.light(), Dense4Pattern);
|
---|
| 292 | else
|
---|
| 293 | fill = cg.brush(QColorGroup::Button);
|
---|
| 294 |
|
---|
| 295 | if (flags & Style_ButtonDefault && flags & Style_Down) {
|
---|
| 296 | p->setPen(cg.dark());
|
---|
| 297 | p->setBrush(fill);
|
---|
| 298 | p->drawRect(r);
|
---|
| 299 | } else if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
|
---|
| 300 | qDrawWinButton(p, r, cg, flags & (Style_Sunken | Style_Down |
|
---|
| 301 | Style_On), &fill);
|
---|
| 302 | else
|
---|
| 303 | p->fillRect(r, fill);
|
---|
| 304 | break;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | case PE_ButtonBevel:
|
---|
| 308 | case PE_HeaderSection:
|
---|
| 309 | {
|
---|
| 310 | QBrush fill;
|
---|
| 311 |
|
---|
| 312 | if (! (flags & Style_Down) && (flags & Style_On))
|
---|
| 313 | fill = QBrush(cg.light(), Dense4Pattern);
|
---|
| 314 | else
|
---|
| 315 | fill = cg.brush(QColorGroup::Button);
|
---|
| 316 |
|
---|
| 317 | if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
|
---|
| 318 | qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On), &fill);
|
---|
| 319 | else
|
---|
| 320 | p->fillRect(r, fill);
|
---|
| 321 | break;
|
---|
| 322 | }
|
---|
| 323 | #if defined(Q_WS_WIN)
|
---|
| 324 | case PE_HeaderArrow:
|
---|
| 325 | p->save();
|
---|
| 326 | if ( flags & Style_Up ) { // invert logic to follow Windows style guide
|
---|
| 327 | QPointArray pa( 3 );
|
---|
| 328 | p->setPen( cg.light() );
|
---|
| 329 | p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() );
|
---|
| 330 | p->setPen( cg.dark() );
|
---|
| 331 | pa.setPoint( 0, r.x() + r.width() / 2, r.height() );
|
---|
| 332 | pa.setPoint( 1, r.x(), r.y() );
|
---|
| 333 | pa.setPoint( 2, r.x() + r.width(), r.y() );
|
---|
| 334 | p->drawPolyline( pa );
|
---|
| 335 | } else {
|
---|
| 336 | QPointArray pa( 3 );
|
---|
| 337 | p->setPen( cg.light() );
|
---|
| 338 | pa.setPoint( 0, r.x(), r.height() );
|
---|
| 339 | pa.setPoint( 1, r.x() + r.width(), r.height() );
|
---|
| 340 | pa.setPoint( 2, r.x() + r.width() / 2, r.y() );
|
---|
| 341 | p->drawPolyline( pa );
|
---|
| 342 | p->setPen( cg.dark() );
|
---|
| 343 | p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() );
|
---|
| 344 | }
|
---|
| 345 | p->restore();
|
---|
| 346 | break;
|
---|
| 347 | #endif
|
---|
| 348 |
|
---|
| 349 | case PE_ButtonDefault:
|
---|
| 350 | p->setPen(cg.shadow());
|
---|
| 351 | p->drawRect(r);
|
---|
| 352 | break;
|
---|
| 353 |
|
---|
| 354 | case PE_ButtonTool:
|
---|
| 355 | {
|
---|
| 356 | QBrush fill;
|
---|
| 357 | bool stippled = FALSE;
|
---|
| 358 |
|
---|
| 359 | if (! (flags & (Style_Down | Style_MouseOver)) &&
|
---|
| 360 | (flags & Style_On) &&
|
---|
| 361 | use2000style) {
|
---|
| 362 | fill = QBrush(cg.light(), Dense4Pattern);
|
---|
| 363 | stippled = TRUE;
|
---|
| 364 | } else
|
---|
| 365 | fill = cg.brush(QColorGroup::Button);
|
---|
| 366 |
|
---|
| 367 | if (flags & (Style_Raised | Style_Down | Style_On)) {
|
---|
| 368 | if (flags & Style_AutoRaise) {
|
---|
| 369 | qDrawShadePanel(p, r, cg, flags & (Style_Down | Style_On),
|
---|
| 370 | 1, &fill);
|
---|
| 371 |
|
---|
| 372 | if (stippled) {
|
---|
| 373 | p->setPen(cg.button());
|
---|
| 374 | p->drawRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2);
|
---|
| 375 | }
|
---|
| 376 | } else
|
---|
| 377 | qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On),
|
---|
| 378 | &fill);
|
---|
| 379 | } else
|
---|
| 380 | p->fillRect(r, fill);
|
---|
| 381 |
|
---|
| 382 | break;
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | case PE_FocusRect:
|
---|
| 386 | if (opt.isDefault())
|
---|
| 387 | p->drawWinFocusRect(r);
|
---|
| 388 | else
|
---|
| 389 | p->drawWinFocusRect(r, opt.color());
|
---|
| 390 | break;
|
---|
| 391 |
|
---|
| 392 | case PE_Indicator:
|
---|
| 393 | {
|
---|
| 394 | QBrush fill;
|
---|
| 395 | if (flags & Style_NoChange) {
|
---|
| 396 | QBrush b = p->brush();
|
---|
| 397 | QColor c = p->backgroundColor();
|
---|
| 398 | p->setBackgroundMode( TransparentMode );
|
---|
| 399 | p->setBackgroundColor( green );
|
---|
| 400 | fill = QBrush(cg.base(), Dense4Pattern);
|
---|
| 401 | p->setBackgroundColor( c );
|
---|
| 402 | p->setBrush( b );
|
---|
| 403 | } else if (flags & Style_Down)
|
---|
| 404 | fill = cg.brush( QColorGroup::Button );
|
---|
| 405 | else if (flags & Style_Enabled)
|
---|
| 406 | fill = cg.brush( QColorGroup::Base );
|
---|
| 407 | else
|
---|
| 408 | fill = cg.brush( QColorGroup::Background );
|
---|
| 409 |
|
---|
| 410 | qDrawWinPanel( p, r, cg, TRUE, &fill );
|
---|
| 411 |
|
---|
| 412 | if (flags & Style_NoChange )
|
---|
| 413 | p->setPen( cg.dark() );
|
---|
| 414 | else
|
---|
| 415 | p->setPen( cg.text() );
|
---|
| 416 | } // FALLTHROUGH
|
---|
| 417 | case PE_CheckListIndicator:
|
---|
| 418 | if ( pe == PE_CheckListIndicator ) { //since we fall through from PE_Indicator
|
---|
| 419 | if ( flags & Style_Enabled )
|
---|
| 420 | p->setPen( QPen( cg.text(), 1 ) );
|
---|
| 421 | else
|
---|
| 422 | p->setPen( QPen( cg.dark(), 1 ) );
|
---|
| 423 | if ( flags & Style_NoChange )
|
---|
| 424 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
---|
| 425 | p->drawRect( r.x()+1, r.y()+1, 11, 11 );
|
---|
| 426 | }
|
---|
| 427 | if (! (flags & Style_Off)) {
|
---|
| 428 | QPointArray a( 7*2 );
|
---|
| 429 | int i, xx, yy;
|
---|
| 430 | xx = rr.x() + 3;
|
---|
| 431 | yy = rr.y() + 5;
|
---|
| 432 |
|
---|
| 433 | for ( i=0; i<3; i++ ) {
|
---|
| 434 | a.setPoint( 2*i, xx, yy );
|
---|
| 435 | a.setPoint( 2*i+1, xx, yy+2 );
|
---|
| 436 | xx++; yy++;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | yy -= 2;
|
---|
| 440 | for ( i=3; i<7; i++ ) {
|
---|
| 441 | a.setPoint( 2*i, xx, yy );
|
---|
| 442 | a.setPoint( 2*i+1, xx, yy+2 );
|
---|
| 443 | xx++; yy--;
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | p->drawLineSegments( a );
|
---|
| 447 | }
|
---|
| 448 | break;
|
---|
| 449 |
|
---|
| 450 | case PE_ExclusiveIndicator:
|
---|
| 451 | {
|
---|
| 452 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
|
---|
| 453 | static const QCOORD pts1[] = { // dark lines
|
---|
| 454 | 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
|
---|
| 455 | static const QCOORD pts2[] = { // black lines
|
---|
| 456 | 2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
|
---|
| 457 | static const QCOORD pts3[] = { // background lines
|
---|
| 458 | 2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
|
---|
| 459 | static const QCOORD pts4[] = { // white lines
|
---|
| 460 | 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
|
---|
| 461 | 11,4, 10,3, 10,2 };
|
---|
| 462 | static const QCOORD pts5[] = { // inner fill
|
---|
| 463 | 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
|
---|
| 464 |
|
---|
| 465 | // make sure the indicator is square
|
---|
| 466 | QRect ir = r;
|
---|
| 467 |
|
---|
| 468 | if (r.width() < r.height()) {
|
---|
| 469 | ir.setTop(r.top() + (r.height() - r.width()) / 2);
|
---|
| 470 | ir.setHeight(r.width());
|
---|
| 471 | } else if (r.height() < r.width()) {
|
---|
| 472 | ir.setLeft(r.left() + (r.width() - r.height()) / 2);
|
---|
| 473 | ir.setWidth(r.height());
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | p->eraseRect(ir);
|
---|
| 477 | bool down = flags & Style_Down;
|
---|
| 478 | bool enabled = flags & Style_Enabled;
|
---|
| 479 | bool on = flags & Style_On;
|
---|
| 480 | QPointArray a;
|
---|
| 481 | a.setPoints( QCOORDARRLEN(pts1), pts1 );
|
---|
| 482 | a.translate( ir.x(), ir.y() );
|
---|
| 483 | p->setPen( cg.dark() );
|
---|
| 484 | p->drawPolyline( a );
|
---|
| 485 | a.setPoints( QCOORDARRLEN(pts2), pts2 );
|
---|
| 486 | a.translate( ir.x(), ir.y() );
|
---|
| 487 | p->setPen( cg.shadow() );
|
---|
| 488 | p->drawPolyline( a );
|
---|
| 489 | a.setPoints( QCOORDARRLEN(pts3), pts3 );
|
---|
| 490 | a.translate( ir.x(), ir.y() );
|
---|
| 491 | p->setPen( cg.midlight() );
|
---|
| 492 | p->drawPolyline( a );
|
---|
| 493 | a.setPoints( QCOORDARRLEN(pts4), pts4 );
|
---|
| 494 | a.translate( ir.x(), ir.y() );
|
---|
| 495 | p->setPen( cg.light() );
|
---|
| 496 | p->drawPolyline( a );
|
---|
| 497 | a.setPoints( QCOORDARRLEN(pts5), pts5 );
|
---|
| 498 | a.translate( ir.x(), ir.y() );
|
---|
| 499 | QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
|
---|
| 500 | p->setPen( fillColor );
|
---|
| 501 | p->setBrush( fillColor ) ;
|
---|
| 502 | p->drawPolygon( a );
|
---|
| 503 | if ( on ) {
|
---|
| 504 | p->setPen( NoPen );
|
---|
| 505 | p->setBrush( cg.text() );
|
---|
| 506 | p->drawRect( ir.x() + 5, ir.y() + 4, 2, 4 );
|
---|
| 507 | p->drawRect( ir.x() + 4, ir.y() + 5, 4, 2 );
|
---|
| 508 | }
|
---|
| 509 | break;
|
---|
| 510 | }
|
---|
| 511 |
|
---|
| 512 | case PE_Panel:
|
---|
| 513 | case PE_PanelPopup:
|
---|
| 514 | {
|
---|
| 515 | int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
|
---|
| 516 | : opt.lineWidth();
|
---|
| 517 |
|
---|
| 518 | if (lw == 2) {
|
---|
| 519 | QColorGroup popupCG = cg;
|
---|
| 520 | if ( pe == PE_PanelPopup ) {
|
---|
| 521 | popupCG.setColor( QColorGroup::Light, cg.background() );
|
---|
| 522 | popupCG.setColor( QColorGroup::Midlight, cg.light() );
|
---|
| 523 | }
|
---|
| 524 | qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
|
---|
| 525 | } else {
|
---|
| 526 | QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
|
---|
| 527 | }
|
---|
| 528 | break;
|
---|
| 529 | }
|
---|
| 530 |
|
---|
| 531 | case PE_Splitter:
|
---|
| 532 | {
|
---|
| 533 | QPen oldPen = p->pen();
|
---|
| 534 | p->setPen( cg.light() );
|
---|
| 535 | if ( flags & Style_Horizontal ) {
|
---|
| 536 | p->drawLine( r.x() + 1, r.y(), r.x() + 1, r.height() );
|
---|
| 537 | p->setPen( cg.dark() );
|
---|
| 538 | p->drawLine( r.x(), r.y(), r.x(), r.height() );
|
---|
| 539 | p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
|
---|
| 540 | p->setPen( cg.shadow() );
|
---|
| 541 | p->drawLine( r.right(), r.y(), r.right(), r.height() );
|
---|
| 542 | } else {
|
---|
| 543 | p->drawLine( r.x(), r.y() + 1, r.width(), r.y() + 1 );
|
---|
| 544 | p->setPen( cg.dark() );
|
---|
| 545 | p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
|
---|
| 546 | p->setPen( cg.shadow() );
|
---|
| 547 | p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
|
---|
| 548 | }
|
---|
| 549 | p->setPen( oldPen );
|
---|
| 550 | break;
|
---|
| 551 | }
|
---|
| 552 | case PE_DockWindowResizeHandle:
|
---|
| 553 | {
|
---|
| 554 | QPen oldPen = p->pen();
|
---|
| 555 | p->setPen( cg.light() );
|
---|
| 556 | if ( flags & Style_Horizontal ) {
|
---|
| 557 | p->drawLine( r.x(), r.y(), r.width(), r.y() );
|
---|
| 558 | p->setPen( cg.dark() );
|
---|
| 559 | p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
|
---|
| 560 | p->setPen( cg.shadow() );
|
---|
| 561 | p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
|
---|
| 562 | } else {
|
---|
| 563 | p->drawLine( r.x(), r.y(), r.x(), r.height() );
|
---|
| 564 | p->setPen( cg.dark() );
|
---|
| 565 | p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
|
---|
| 566 | p->setPen( cg.shadow() );
|
---|
| 567 | p->drawLine( r.right(), r.y(), r.right(), r.height() );
|
---|
| 568 | }
|
---|
| 569 | p->setPen( oldPen );
|
---|
| 570 | break;
|
---|
| 571 | }
|
---|
| 572 |
|
---|
| 573 | case PE_ScrollBarSubLine:
|
---|
| 574 | if (use2000style) {
|
---|
| 575 | if (flags & Style_Down) {
|
---|
| 576 | p->setPen( cg.dark() );
|
---|
| 577 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
---|
| 578 | p->drawRect( r );
|
---|
| 579 | } else
|
---|
| 580 | drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
|
---|
| 581 | } else
|
---|
| 582 | drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
|
---|
| 583 | ((flags & Style_Down) ? Style_Down : Style_Raised));
|
---|
| 584 |
|
---|
| 585 | drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
|
---|
| 586 | p, r, cg, flags);
|
---|
| 587 | break;
|
---|
| 588 |
|
---|
| 589 | case PE_ScrollBarAddLine:
|
---|
| 590 | if (use2000style) {
|
---|
| 591 | if (flags & Style_Down) {
|
---|
| 592 | p->setPen( cg.dark() );
|
---|
| 593 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
---|
| 594 | p->drawRect( r );
|
---|
| 595 | } else
|
---|
| 596 | drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
|
---|
| 597 | } else
|
---|
| 598 | drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
|
---|
| 599 | ((flags & Style_Down) ? Style_Down : Style_Raised));
|
---|
| 600 |
|
---|
| 601 | drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
|
---|
| 602 | p, r, cg, flags);
|
---|
| 603 | break;
|
---|
| 604 |
|
---|
| 605 | case PE_ScrollBarAddPage:
|
---|
| 606 | case PE_ScrollBarSubPage:
|
---|
| 607 | {
|
---|
| 608 | QBrush br;
|
---|
| 609 | QColor c = p->backgroundColor();
|
---|
| 610 |
|
---|
| 611 | p->setPen(NoPen);
|
---|
| 612 | p->setBackgroundMode(OpaqueMode);
|
---|
| 613 |
|
---|
| 614 | if (flags & Style_Down) {
|
---|
| 615 | br = QBrush(cg.shadow(), Dense4Pattern);
|
---|
| 616 | p->setBackgroundColor( cg.dark() );
|
---|
| 617 | p->setBrush( QBrush(cg.shadow(), Dense4Pattern) );
|
---|
| 618 | } else {
|
---|
| 619 | br = (cg.brush(QColorGroup::Light).pixmap() ?
|
---|
| 620 | cg.brush(QColorGroup::Light) :
|
---|
| 621 | QBrush(cg.light(), Dense4Pattern));
|
---|
| 622 | p->setBrush(br);
|
---|
| 623 | }
|
---|
| 624 |
|
---|
| 625 | p->drawRect(r);
|
---|
| 626 | p->setBackgroundColor(c);
|
---|
| 627 | break;
|
---|
| 628 | }
|
---|
| 629 |
|
---|
| 630 | case PE_ScrollBarSlider:
|
---|
| 631 | if (! (flags & Style_Enabled)) {
|
---|
| 632 | QBrush br = (cg.brush(QColorGroup::Light).pixmap() ?
|
---|
| 633 | cg.brush(QColorGroup::Light) :
|
---|
| 634 | QBrush(cg.light(), Dense4Pattern));
|
---|
| 635 | p->setPen(NoPen);
|
---|
| 636 | p->setBrush(br);
|
---|
| 637 | p->setBackgroundMode(OpaqueMode);
|
---|
| 638 | p->drawRect(r);
|
---|
| 639 | } else
|
---|
| 640 | drawPrimitive(PE_ButtonBevel, p, r, cg, Style_Enabled | Style_Raised);
|
---|
| 641 | break;
|
---|
| 642 |
|
---|
| 643 | case PE_WindowFrame:
|
---|
| 644 | {
|
---|
| 645 | QColorGroup popupCG = cg;
|
---|
| 646 | popupCG.setColor( QColorGroup::Light, cg.background() );
|
---|
| 647 | popupCG.setColor( QColorGroup::Midlight, cg.light() );
|
---|
[54] | 648 |
|
---|
| 649 | int lw = opt.isDefault() ? pixelMetric(PM_MDIFrameWidth)
|
---|
| 650 | : opt.lineWidth();
|
---|
| 651 |
|
---|
| 652 | if (lw == 2) {
|
---|
| 653 | qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
|
---|
| 654 | } else {
|
---|
| 655 | QBrush fill = QBrush( cg.background() );
|
---|
| 656 | qDrawWinPanel( p, r, popupCG, flags & Style_Sunken, &fill );
|
---|
| 657 | }
|
---|
| 658 | break;
|
---|
[2] | 659 | }
|
---|
| 660 |
|
---|
| 661 | default:
|
---|
| 662 | if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) {
|
---|
| 663 | QPointArray a;
|
---|
| 664 |
|
---|
| 665 | switch ( pe ) {
|
---|
| 666 | case PE_ArrowUp:
|
---|
| 667 | a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
|
---|
| 668 | break;
|
---|
| 669 |
|
---|
| 670 | case PE_ArrowDown:
|
---|
| 671 | a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
|
---|
| 672 | break;
|
---|
| 673 |
|
---|
| 674 | case PE_ArrowRight:
|
---|
| 675 | a.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
|
---|
| 676 | break;
|
---|
| 677 |
|
---|
| 678 | case PE_ArrowLeft:
|
---|
| 679 | a.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
|
---|
| 680 | break;
|
---|
| 681 |
|
---|
| 682 | default:
|
---|
| 683 | break;
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 686 | if (a.isNull())
|
---|
| 687 | return;
|
---|
| 688 |
|
---|
| 689 | p->save();
|
---|
| 690 | if ( flags & Style_Down )
|
---|
| 691 | p->translate( pixelMetric( PM_ButtonShiftHorizontal ),
|
---|
| 692 | pixelMetric( PM_ButtonShiftVertical ) );
|
---|
| 693 |
|
---|
| 694 | if ( flags & Style_Enabled ) {
|
---|
| 695 | a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
|
---|
| 696 | p->setPen( cg.buttonText() );
|
---|
| 697 | p->drawLineSegments( a, 0, 3 ); // draw arrow
|
---|
| 698 | p->drawPoint( a[6] );
|
---|
| 699 | } else {
|
---|
| 700 | a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
|
---|
| 701 | p->setPen( cg.light() );
|
---|
| 702 | p->drawLineSegments( a, 0, 3 ); // draw arrow
|
---|
| 703 | p->drawPoint( a[6] );
|
---|
| 704 | a.translate( -1, -1 );
|
---|
| 705 | p->setPen( cg.mid() );
|
---|
| 706 | p->drawLineSegments( a, 0, 3 ); // draw arrow
|
---|
| 707 | p->drawPoint( a[6] );
|
---|
| 708 | }
|
---|
| 709 | p->restore();
|
---|
| 710 | } else
|
---|
| 711 | QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
|
---|
| 712 | }
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 |
|
---|
| 716 | /*!
|
---|
| 717 | \reimp
|
---|
| 718 | */
|
---|
| 719 | void QWindowsStyle::drawControl( ControlElement element,
|
---|
| 720 | QPainter *p,
|
---|
| 721 | const QWidget *widget,
|
---|
| 722 | const QRect &r,
|
---|
| 723 | const QColorGroup &cg,
|
---|
| 724 | SFlags flags,
|
---|
| 725 | const QStyleOption& opt ) const
|
---|
| 726 | {
|
---|
| 727 | switch (element) {
|
---|
| 728 | #ifndef QT_NO_TABBAR
|
---|
| 729 | case CE_TabBarTab:
|
---|
| 730 | {
|
---|
| 731 | if ( !widget || !widget->parentWidget() || !opt.tab() )
|
---|
| 732 | break;
|
---|
| 733 |
|
---|
| 734 | const QTabBar * tb = (const QTabBar *) widget;
|
---|
| 735 | const QTab * t = opt.tab();
|
---|
| 736 | bool selected = flags & Style_Selected;
|
---|
| 737 | bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ?
|
---|
| 738 | TRUE : FALSE;
|
---|
| 739 | QRect r2( r );
|
---|
| 740 | if ( tb->shape() == QTabBar::RoundedAbove ) {
|
---|
| 741 | p->setPen( cg.midlight() );
|
---|
| 742 |
|
---|
| 743 | p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
|
---|
| 744 | p->setPen( cg.light() );
|
---|
| 745 | p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
|
---|
| 746 | if ( r2.left() == 0 )
|
---|
| 747 | p->drawPoint( tb->rect().bottomLeft() );
|
---|
| 748 |
|
---|
| 749 | if ( selected ) {
|
---|
| 750 | p->fillRect( QRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2),
|
---|
| 751 | cg.brush( QColorGroup::Background ));
|
---|
| 752 | p->setPen( cg.background() );
|
---|
| 753 | p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
|
---|
| 754 | p->setPen( cg.light() );
|
---|
| 755 | } else {
|
---|
| 756 | p->setPen( cg.light() );
|
---|
| 757 | r2.setRect( r2.left() + 2, r2.top() + 2,
|
---|
| 758 | r2.width() - 4, r2.height() - 2 );
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | int x1, x2;
|
---|
| 762 | x1 = r2.left();
|
---|
| 763 | x2 = r2.right() - 2;
|
---|
| 764 | p->drawLine( x1, r2.bottom()-1, x1, r2.top() + 2 );
|
---|
| 765 | x1++;
|
---|
| 766 | p->drawPoint( x1, r2.top() + 1 );
|
---|
| 767 | x1++;
|
---|
| 768 | p->drawLine( x1, r2.top(), x2, r2.top() );
|
---|
| 769 | if ( r2.left() > 0 ) {
|
---|
| 770 | p->setPen( cg.midlight() );
|
---|
| 771 | }
|
---|
| 772 | x1 = r2.left();
|
---|
| 773 | p->drawPoint( x1, r2.bottom());
|
---|
| 774 |
|
---|
| 775 | p->setPen( cg.midlight() );
|
---|
| 776 | x1++;
|
---|
| 777 | p->drawLine( x1, r2.bottom(), x1, r2.top() + 2 );
|
---|
| 778 | x1++;
|
---|
| 779 | p->drawLine( x1, r2.top()+1, x2, r2.top()+1 );
|
---|
| 780 |
|
---|
| 781 | p->setPen( cg.dark() );
|
---|
| 782 | x2 = r2.right() - 1;
|
---|
| 783 | p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
|
---|
| 784 | (selected ? 1:-1) );
|
---|
| 785 | p->setPen( cg.shadow() );
|
---|
| 786 | p->drawPoint( x2, r2.top() + 1 );
|
---|
| 787 | p->drawPoint( x2, r2.top() + 1 );
|
---|
| 788 | x2++;
|
---|
| 789 | p->drawLine( x2, r2.top() + 2, x2, r2.bottom() -
|
---|
| 790 | (selected ? (lastTab ? 0:1) :2));
|
---|
| 791 | } else if ( tb->shape() == QTabBar::RoundedBelow ) {
|
---|
| 792 | bool rightAligned = styleHint( SH_TabBar_Alignment, tb ) == AlignRight;
|
---|
| 793 | bool firstTab = tb->indexOf( t->identifier() ) == 0;
|
---|
| 794 | if ( selected ) {
|
---|
| 795 | p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-3, 1),
|
---|
| 796 | cg.brush( QColorGroup::Background ));
|
---|
| 797 | p->setPen( cg.background() );
|
---|
| 798 | p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
|
---|
| 799 | p->setPen( cg.dark() );
|
---|
| 800 | } else {
|
---|
| 801 | p->setPen( cg.shadow() );
|
---|
| 802 | p->drawLine( r2.left() +
|
---|
| 803 | (rightAligned && firstTab ? 0 : 1),
|
---|
| 804 | r2.top() + 1,
|
---|
| 805 | r2.right() - (lastTab ? 0 : 2),
|
---|
| 806 | r2.top() + 1 );
|
---|
| 807 |
|
---|
| 808 | if ( rightAligned && lastTab )
|
---|
| 809 | p->drawPoint( r2.right(), r2.top() );
|
---|
| 810 | p->setPen( cg.dark() );
|
---|
| 811 | p->drawLine( r2.left(), r2.top(), r2.right() - 1,
|
---|
| 812 | r2.top() );
|
---|
| 813 | r2.setRect( r2.left() + 2, r2.top(),
|
---|
| 814 | r2.width() - 4, r2.height() - 2 );
|
---|
| 815 | }
|
---|
| 816 |
|
---|
| 817 | p->drawLine( r2.right() - 1, r2.top() + (selected ? 0: 2),
|
---|
| 818 | r2.right() - 1, r2.bottom() - 2 );
|
---|
| 819 | p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
|
---|
| 820 | p->drawLine( r2.right() - 2, r2.bottom() - 1,
|
---|
| 821 | r2.left() + 1, r2.bottom() - 1 );
|
---|
| 822 |
|
---|
| 823 | p->setPen( cg.midlight() );
|
---|
| 824 | p->drawLine( r2.left() + 1, r2.bottom() - 2,
|
---|
| 825 | r2.left() + 1, r2.top() + (selected ? 0 : 2) );
|
---|
| 826 |
|
---|
| 827 | p->setPen( cg.shadow() );
|
---|
| 828 | p->drawLine( r2.right(),
|
---|
| 829 | r2.top() + (lastTab && rightAligned &&
|
---|
| 830 | selected) ? 0 : 1,
|
---|
| 831 | r2.right(), r2.bottom() - 1 );
|
---|
| 832 | p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
|
---|
| 833 | p->drawLine( r2.right() - 1, r2.bottom(),
|
---|
| 834 | r2.left() + 2, r2.bottom() );
|
---|
| 835 |
|
---|
| 836 | p->setPen( cg.light() );
|
---|
| 837 | p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
|
---|
| 838 | r2.left(), r2.bottom() - 2 );
|
---|
| 839 | } else {
|
---|
| 840 | QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
|
---|
| 841 | }
|
---|
| 842 | break;
|
---|
| 843 | }
|
---|
| 844 | #endif // QT_NO_TABBAR
|
---|
| 845 | case CE_ToolBoxTab:
|
---|
| 846 | {
|
---|
| 847 | qDrawShadePanel( p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
|
---|
| 848 | &cg.brush(QColorGroup::Button));
|
---|
| 849 | break;
|
---|
| 850 | }
|
---|
| 851 |
|
---|
| 852 | #ifndef QT_NO_POPUPMENU
|
---|
| 853 | case CE_PopupMenuItem:
|
---|
| 854 | {
|
---|
| 855 | if (! widget || opt.isDefault())
|
---|
| 856 | break;
|
---|
| 857 |
|
---|
| 858 | const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
|
---|
| 859 | QMenuItem *mi = opt.menuItem();
|
---|
[8] | 860 |
|
---|
| 861 | // QPopupMenu has WResizeNoErase and WRepaintNoErase flags, so we
|
---|
| 862 | // must erase areas not covered by menu items (this is requested by
|
---|
| 863 | // QPopupMenu using 0 as the menu item argument).
|
---|
| 864 | // [Win32 version feels ok without this, because it doesn't actually
|
---|
| 865 | // fully obey WResizeNoErase and WRepaintNoErase: WM_ERASEBKGND always
|
---|
| 866 | // erases the background before WM_PAINT and after every resize].
|
---|
| 867 | #if !defined (Q_WS_PM)
|
---|
[2] | 868 | if ( !mi )
|
---|
| 869 | break;
|
---|
[8] | 870 | #endif
|
---|
| 871 |
|
---|
[2] | 872 | int tab = opt.tabWidth();
|
---|
| 873 | int maxpmw = opt.maxIconWidth();
|
---|
| 874 | bool dis = !(flags&Style_Enabled);
|
---|
| 875 | bool checkable = popupmenu->isCheckable();
|
---|
| 876 | bool act = flags & Style_Active;
|
---|
| 877 | int x, y, w, h;
|
---|
| 878 |
|
---|
| 879 | r.rect(&x, &y, &w, &h);
|
---|
| 880 |
|
---|
| 881 | if ( checkable ) {
|
---|
| 882 | // space for the checkmarks
|
---|
| 883 | if (use2000style)
|
---|
| 884 | maxpmw = QMAX( maxpmw, 20 );
|
---|
| 885 | else
|
---|
| 886 | maxpmw = QMAX( maxpmw, 12 );
|
---|
| 887 | }
|
---|
| 888 |
|
---|
| 889 | int checkcol = maxpmw;
|
---|
| 890 |
|
---|
| 891 | if ( mi && mi->isSeparator() ) { // draw separator
|
---|
| 892 | p->setPen( cg.dark() );
|
---|
| 893 | p->drawLine( x, y, x+w, y );
|
---|
| 894 | p->setPen( cg.light() );
|
---|
| 895 | p->drawLine( x, y+1, x+w, y+1 );
|
---|
| 896 | return;
|
---|
| 897 | }
|
---|
| 898 |
|
---|
| 899 | QBrush fill = (act ?
|
---|
| 900 | cg.brush( QColorGroup::Highlight ) :
|
---|
| 901 | cg.brush( QColorGroup::Button ));
|
---|
| 902 | p->fillRect( x, y, w, h, fill);
|
---|
| 903 |
|
---|
| 904 | if ( !mi )
|
---|
| 905 | return;
|
---|
| 906 |
|
---|
| 907 | int xpos = x;
|
---|
| 908 | QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r );
|
---|
| 909 | int xvis = vrect.x();
|
---|
| 910 | if ( mi->isChecked() ) {
|
---|
| 911 | if ( act && !dis )
|
---|
| 912 | qDrawShadePanel( p, xvis, y, checkcol, h,
|
---|
| 913 | cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
|
---|
| 914 | else {
|
---|
| 915 | QBrush fill( cg.light(), Dense4Pattern );
|
---|
| 916 | // set the brush origin for the hash pattern to the x/y coordinate
|
---|
| 917 | // of the menu item's checkmark... this way, the check marks have
|
---|
| 918 | // a consistent look
|
---|
| 919 | QPoint origin = p->brushOrigin();
|
---|
| 920 | p->setBrushOrigin( xvis, y );
|
---|
| 921 | qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1,
|
---|
| 922 | &fill );
|
---|
| 923 | // restore the previous brush origin
|
---|
| 924 | p->setBrushOrigin( origin );
|
---|
| 925 | }
|
---|
| 926 | } else if (! act)
|
---|
| 927 | p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button ));
|
---|
| 928 |
|
---|
| 929 | if ( mi->iconSet() ) { // draw iconset
|
---|
| 930 | QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
|
---|
| 931 | if (act && !dis )
|
---|
| 932 | mode = QIconSet::Active;
|
---|
| 933 | QPixmap pixmap;
|
---|
| 934 | if ( checkable && mi->isChecked() )
|
---|
| 935 | pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
|
---|
| 936 | else
|
---|
| 937 | pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
|
---|
| 938 | int pixw = pixmap.width();
|
---|
| 939 | int pixh = pixmap.height();
|
---|
| 940 | if ( act && !dis && !mi->isChecked() )
|
---|
| 941 | qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1,
|
---|
| 942 | &cg.brush( QColorGroup::Button ) );
|
---|
| 943 | QRect pmr( 0, 0, pixw, pixh );
|
---|
| 944 | pmr.moveCenter( vrect.center() );
|
---|
| 945 | p->setPen( cg.text() );
|
---|
| 946 | p->drawPixmap( pmr.topLeft(), pixmap );
|
---|
| 947 |
|
---|
| 948 | fill = (act ?
|
---|
| 949 | cg.brush( QColorGroup::Highlight ) :
|
---|
| 950 | cg.brush( QColorGroup::Button ));
|
---|
| 951 | int xp = xpos + checkcol + 1;
|
---|
| 952 | p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill);
|
---|
| 953 | } else if ( checkable ) { // just "checking"...
|
---|
| 954 | if ( mi->isChecked() ) {
|
---|
| 955 | int xp = xpos + windowsItemFrame;
|
---|
| 956 |
|
---|
| 957 | SFlags cflags = Style_Default;
|
---|
| 958 | if (! dis)
|
---|
| 959 | cflags |= Style_Enabled;
|
---|
| 960 | if (act)
|
---|
| 961 | cflags |= Style_On;
|
---|
| 962 |
|
---|
| 963 | drawPrimitive(PE_CheckMark, p,
|
---|
| 964 | visualRect( QRect(xp, y + windowsItemFrame,
|
---|
| 965 | checkcol - 2*windowsItemFrame,
|
---|
| 966 | h - 2*windowsItemFrame), r ), cg, cflags);
|
---|
| 967 | }
|
---|
| 968 | }
|
---|
| 969 |
|
---|
| 970 | p->setPen( act ? cg.highlightedText() : cg.buttonText() );
|
---|
| 971 |
|
---|
| 972 | QColor discol;
|
---|
| 973 | if ( dis ) {
|
---|
| 974 | discol = cg.text();
|
---|
| 975 | p->setPen( discol );
|
---|
| 976 | }
|
---|
| 977 |
|
---|
| 978 | int xm = windowsItemFrame + checkcol + windowsItemHMargin;
|
---|
| 979 | xpos += xm;
|
---|
| 980 |
|
---|
| 981 | vrect = visualRect( QRect( xpos, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin ), r );
|
---|
| 982 | xvis = vrect.x();
|
---|
| 983 | if ( mi->custom() ) {
|
---|
| 984 | p->save();
|
---|
| 985 | if ( dis && !act ) {
|
---|
| 986 | p->setPen( cg.light() );
|
---|
| 987 | mi->custom()->paint( p, cg, act, !dis,
|
---|
| 988 | xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin );
|
---|
| 989 | p->setPen( discol );
|
---|
| 990 | }
|
---|
| 991 | mi->custom()->paint( p, cg, act, !dis,
|
---|
| 992 | xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin );
|
---|
| 993 | p->restore();
|
---|
| 994 | }
|
---|
| 995 | QString s = mi->text();
|
---|
| 996 | if ( !s.isNull() ) { // draw text
|
---|
| 997 | int t = s.find( '\t' );
|
---|
| 998 | int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
|
---|
| 999 | if (!styleHint(SH_UnderlineAccelerator, widget))
|
---|
| 1000 | text_flags |= NoAccel;
|
---|
| 1001 | text_flags |= (QApplication::reverseLayout() ? AlignRight : AlignLeft );
|
---|
| 1002 | if ( t >= 0 ) { // draw tab text
|
---|
| 1003 | int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
|
---|
| 1004 | if ( use2000style )
|
---|
| 1005 | xp -= 20;
|
---|
| 1006 | else
|
---|
| 1007 | xp -= windowsRightBorder;
|
---|
| 1008 | int xoff = visualRect( QRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
|
---|
| 1009 | if ( dis && !act ) {
|
---|
| 1010 | p->setPen( cg.light() );
|
---|
| 1011 | p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
|
---|
| 1012 | p->setPen( discol );
|
---|
| 1013 | }
|
---|
| 1014 | p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
|
---|
| 1015 | s = s.left( t );
|
---|
| 1016 | }
|
---|
| 1017 | if ( dis && !act ) {
|
---|
| 1018 | p->setPen( cg.light() );
|
---|
| 1019 | p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
|
---|
| 1020 | p->setPen( discol );
|
---|
| 1021 | }
|
---|
| 1022 | p->drawText( xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
|
---|
| 1023 | } else if ( mi->pixmap() ) { // draw pixmap
|
---|
| 1024 | QPixmap *pixmap = mi->pixmap();
|
---|
| 1025 | if ( pixmap->depth() == 1 )
|
---|
| 1026 | p->setBackgroundMode( OpaqueMode );
|
---|
| 1027 | p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
|
---|
| 1028 | if ( pixmap->depth() == 1 )
|
---|
| 1029 | p->setBackgroundMode( TransparentMode );
|
---|
| 1030 | }
|
---|
| 1031 | if ( mi->popup() ) { // draw sub menu arrow
|
---|
| 1032 | int dim = (h-2*windowsItemFrame) / 2;
|
---|
| 1033 | PrimitiveElement arrow;
|
---|
| 1034 | arrow = ( QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
|
---|
| 1035 | xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
|
---|
| 1036 | vrect = visualRect( QRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
|
---|
| 1037 | if ( act ) {
|
---|
| 1038 | QColorGroup g2 = cg;
|
---|
| 1039 | g2.setColor( QColorGroup::ButtonText, g2.highlightedText() );
|
---|
| 1040 | drawPrimitive(arrow, p, vrect,
|
---|
| 1041 | g2, dis ? Style_Default : Style_Enabled);
|
---|
| 1042 | } else {
|
---|
| 1043 | drawPrimitive(arrow, p, vrect,
|
---|
| 1044 | cg, dis ? Style_Default : Style_Enabled );
|
---|
| 1045 | }
|
---|
| 1046 | }
|
---|
| 1047 |
|
---|
| 1048 | break;
|
---|
| 1049 | }
|
---|
| 1050 | #endif
|
---|
| 1051 |
|
---|
| 1052 | case CE_MenuBarItem:
|
---|
| 1053 | {
|
---|
| 1054 | bool active = flags & Style_Active;
|
---|
| 1055 | bool hasFocus = flags & Style_HasFocus;
|
---|
| 1056 | bool down = flags & Style_Down;
|
---|
| 1057 | QRect pr = r;
|
---|
| 1058 |
|
---|
| 1059 | p->fillRect( r, cg.brush( QColorGroup::Button ) );
|
---|
| 1060 | if ( active || hasFocus ) {
|
---|
| 1061 | QBrush b = cg.brush( QColorGroup::Button );
|
---|
| 1062 | if ( active && down )
|
---|
| 1063 | p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
|
---|
| 1064 | if ( active && hasFocus )
|
---|
| 1065 | qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(),
|
---|
| 1066 | cg, active && down, 1, 0, &b );
|
---|
| 1067 | if ( active && down ) {
|
---|
| 1068 | pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, widget),
|
---|
| 1069 | pixelMetric(PM_ButtonShiftVertical, widget) );
|
---|
| 1070 | p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
|
---|
| 1071 | }
|
---|
| 1072 | }
|
---|
| 1073 | QCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt);
|
---|
| 1074 | break;
|
---|
| 1075 | }
|
---|
| 1076 |
|
---|
| 1077 | default:
|
---|
| 1078 | QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
|
---|
| 1079 | }
|
---|
| 1080 | }
|
---|
| 1081 |
|
---|
| 1082 |
|
---|
| 1083 | /*!
|
---|
| 1084 | \reimp
|
---|
| 1085 | */
|
---|
| 1086 | int QWindowsStyle::pixelMetric(PixelMetric metric, const QWidget *widget) const
|
---|
| 1087 | {
|
---|
| 1088 | int ret;
|
---|
| 1089 |
|
---|
| 1090 | switch (metric) {
|
---|
| 1091 | case PM_ButtonDefaultIndicator:
|
---|
| 1092 | case PM_ButtonShiftHorizontal:
|
---|
| 1093 | case PM_ButtonShiftVertical:
|
---|
| 1094 | ret = 1;
|
---|
| 1095 | break;
|
---|
| 1096 |
|
---|
| 1097 | case PM_MaximumDragDistance:
|
---|
| 1098 | ret = 60;
|
---|
| 1099 | break;
|
---|
| 1100 |
|
---|
| 1101 | #ifndef QT_NO_SLIDER
|
---|
| 1102 | case PM_SliderLength:
|
---|
| 1103 | ret = 11;
|
---|
| 1104 | break;
|
---|
| 1105 |
|
---|
| 1106 | // Returns the number of pixels to use for the business part of the
|
---|
| 1107 | // slider (i.e., the non-tickmark portion). The remaining space is shared
|
---|
| 1108 | // equally between the tickmark regions.
|
---|
| 1109 | case PM_SliderControlThickness:
|
---|
| 1110 | {
|
---|
| 1111 | const QSlider * sl = (const QSlider *) widget;
|
---|
| 1112 | int space = (sl->orientation() == Horizontal) ? sl->height()
|
---|
| 1113 | : sl->width();
|
---|
| 1114 | int ticks = sl->tickmarks();
|
---|
| 1115 | int n = 0;
|
---|
| 1116 | if ( ticks & QSlider::Above ) n++;
|
---|
| 1117 | if ( ticks & QSlider::Below ) n++;
|
---|
| 1118 | if ( !n ) {
|
---|
| 1119 | ret = space;
|
---|
| 1120 | break;
|
---|
| 1121 | }
|
---|
| 1122 |
|
---|
| 1123 | int thick = 6; // Magic constant to get 5 + 16 + 5
|
---|
| 1124 | if ( ticks != QSlider::Both && ticks != QSlider::NoMarks )
|
---|
| 1125 | thick += pixelMetric( PM_SliderLength, sl ) / 4;
|
---|
| 1126 |
|
---|
| 1127 | space -= thick;
|
---|
| 1128 | //### the two sides may be unequal in size
|
---|
| 1129 | if ( space > 0 )
|
---|
| 1130 | thick += (space * 2) / (n + 2);
|
---|
| 1131 | ret = thick;
|
---|
| 1132 | break;
|
---|
| 1133 | }
|
---|
| 1134 | #endif // QT_NO_SLIDER
|
---|
| 1135 |
|
---|
| 1136 | case PM_MenuBarFrameWidth:
|
---|
| 1137 | ret = 0;
|
---|
| 1138 | break;
|
---|
| 1139 |
|
---|
| 1140 | #if defined(Q_WS_WIN)
|
---|
| 1141 | case PM_TitleBarHeight:
|
---|
| 1142 | if ( widget && ( widget->testWFlags( WStyle_Tool ) || ::qt_cast<QDockWindow*>(widget) ) ) {
|
---|
| 1143 | // MS always use one less than they say
|
---|
| 1144 | #if defined(Q_OS_TEMP)
|
---|
| 1145 | ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
|
---|
| 1146 | #else
|
---|
| 1147 | ret = GetSystemMetrics( SM_CYSMCAPTION ) - 1;
|
---|
| 1148 | #endif
|
---|
| 1149 | } else {
|
---|
| 1150 | ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
|
---|
| 1151 | }
|
---|
| 1152 | break;
|
---|
| 1153 |
|
---|
| 1154 | case PM_ScrollBarExtent:
|
---|
| 1155 | {
|
---|
| 1156 | #ifndef Q_OS_TEMP
|
---|
| 1157 | NONCLIENTMETRICS ncm;
|
---|
| 1158 | ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
---|
| 1159 | if ( SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0 ) )
|
---|
| 1160 | ret = QMAX( ncm.iScrollHeight, ncm.iScrollWidth );
|
---|
| 1161 | else
|
---|
| 1162 | #endif
|
---|
| 1163 | ret = QCommonStyle::pixelMetric( metric, widget );
|
---|
| 1164 | }
|
---|
| 1165 | break;
|
---|
| 1166 | #endif
|
---|
| 1167 |
|
---|
| 1168 | case PM_SplitterWidth:
|
---|
| 1169 | ret = QMAX( 6, QApplication::globalStrut().width() );
|
---|
| 1170 | break;
|
---|
| 1171 |
|
---|
| 1172 | #if defined(Q_WS_WIN)
|
---|
| 1173 | case PM_MDIFrameWidth:
|
---|
| 1174 | ret = GetSystemMetrics(SM_CYFRAME);
|
---|
| 1175 | break;
|
---|
| 1176 | #endif
|
---|
| 1177 |
|
---|
| 1178 | default:
|
---|
| 1179 | ret = QCommonStyle::pixelMetric(metric, widget);
|
---|
| 1180 | break;
|
---|
| 1181 | }
|
---|
| 1182 |
|
---|
| 1183 | return ret;
|
---|
| 1184 | }
|
---|
| 1185 |
|
---|
| 1186 |
|
---|
| 1187 | /*!
|
---|
| 1188 | \reimp
|
---|
| 1189 | */
|
---|
| 1190 | QSize QWindowsStyle::sizeFromContents( ContentsType contents,
|
---|
| 1191 | const QWidget *widget,
|
---|
| 1192 | const QSize &contentsSize,
|
---|
| 1193 | const QStyleOption& opt ) const
|
---|
| 1194 | {
|
---|
| 1195 | QSize sz(contentsSize);
|
---|
| 1196 |
|
---|
| 1197 | switch (contents) {
|
---|
| 1198 | case CT_PushButton:
|
---|
| 1199 | {
|
---|
| 1200 | #ifndef QT_NO_PUSHBUTTON
|
---|
| 1201 | const QPushButton *button = (const QPushButton *) widget;
|
---|
| 1202 | sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
|
---|
| 1203 | int w = sz.width(), h = sz.height();
|
---|
| 1204 |
|
---|
| 1205 | int defwidth = 0;
|
---|
| 1206 | if (button->isDefault() || button->autoDefault())
|
---|
| 1207 | defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, widget );
|
---|
| 1208 |
|
---|
| 1209 | if (w < 80+defwidth && !button->pixmap())
|
---|
| 1210 | w = 80+defwidth;
|
---|
| 1211 | if (h < 23+defwidth)
|
---|
| 1212 | h = 23+defwidth;
|
---|
| 1213 |
|
---|
| 1214 | sz = QSize(w, h);
|
---|
| 1215 | #endif
|
---|
| 1216 | break;
|
---|
| 1217 | }
|
---|
| 1218 |
|
---|
| 1219 | case CT_PopupMenuItem:
|
---|
| 1220 | {
|
---|
| 1221 | #ifndef QT_NO_POPUPMENU
|
---|
| 1222 | if (! widget || opt.isDefault())
|
---|
| 1223 | break;
|
---|
| 1224 |
|
---|
| 1225 | const QPopupMenu *popup = (const QPopupMenu *) widget;
|
---|
| 1226 | bool checkable = popup->isCheckable();
|
---|
| 1227 | QMenuItem *mi = opt.menuItem();
|
---|
| 1228 | int maxpmw = opt.maxIconWidth();
|
---|
| 1229 | int w = sz.width(), h = sz.height();
|
---|
| 1230 |
|
---|
| 1231 | if (mi->custom()) {
|
---|
| 1232 | w = mi->custom()->sizeHint().width();
|
---|
| 1233 | h = mi->custom()->sizeHint().height();
|
---|
| 1234 | if (! mi->custom()->fullSpan())
|
---|
| 1235 | h += 2*windowsItemVMargin + 2*windowsItemFrame;
|
---|
| 1236 | } else if ( mi->widget() ) {
|
---|
| 1237 | } else if (mi->isSeparator()) {
|
---|
| 1238 | w = 10; // arbitrary
|
---|
| 1239 | h = windowsSepHeight;
|
---|
| 1240 | } else {
|
---|
| 1241 | if (mi->pixmap())
|
---|
| 1242 | h = QMAX(h, mi->pixmap()->height() + 2*windowsItemFrame);
|
---|
| 1243 | else if (! mi->text().isNull())
|
---|
| 1244 | h = QMAX(h, popup->fontMetrics().height() + 2*windowsItemVMargin +
|
---|
| 1245 | 2*windowsItemFrame);
|
---|
| 1246 |
|
---|
| 1247 | if (mi->iconSet() != 0)
|
---|
| 1248 | h = QMAX(h, mi->iconSet()->pixmap(QIconSet::Small,
|
---|
| 1249 | QIconSet::Normal).height() +
|
---|
| 1250 | 2*windowsItemFrame);
|
---|
| 1251 | }
|
---|
| 1252 |
|
---|
| 1253 | if (! mi->text().isNull() && mi->text().find('\t') >= 0) {
|
---|
| 1254 | if ( use2000style )
|
---|
| 1255 | w += 20;
|
---|
| 1256 | else
|
---|
| 1257 | w += windowsTabSpacing;
|
---|
| 1258 | } else if (mi->popup()) {
|
---|
| 1259 | w += 2*windowsArrowHMargin;
|
---|
| 1260 | }
|
---|
| 1261 |
|
---|
| 1262 | if (use2000style) {
|
---|
| 1263 | if (checkable && maxpmw < 20)
|
---|
| 1264 | w += 20 - maxpmw;
|
---|
| 1265 | } else {
|
---|
| 1266 | if (checkable && maxpmw < windowsCheckMarkWidth)
|
---|
| 1267 | w += windowsCheckMarkWidth - maxpmw;
|
---|
| 1268 | }
|
---|
| 1269 | if (checkable || maxpmw > 0)
|
---|
| 1270 | w += windowsCheckMarkHMargin;
|
---|
| 1271 | if (use2000style)
|
---|
| 1272 | w += 20;
|
---|
| 1273 | else
|
---|
| 1274 | w += windowsRightBorder;
|
---|
| 1275 |
|
---|
| 1276 | sz = QSize(w, h);
|
---|
| 1277 | #endif
|
---|
| 1278 | break;
|
---|
| 1279 | }
|
---|
| 1280 |
|
---|
| 1281 | default:
|
---|
| 1282 | sz = QCommonStyle::sizeFromContents(contents, widget, sz, opt);
|
---|
| 1283 | break;
|
---|
| 1284 | }
|
---|
| 1285 |
|
---|
| 1286 | return sz;
|
---|
| 1287 | }
|
---|
| 1288 |
|
---|
| 1289 | /*! \reimp
|
---|
| 1290 | */
|
---|
| 1291 | void QWindowsStyle::polishPopupMenu( QPopupMenu* p)
|
---|
| 1292 | {
|
---|
| 1293 | #ifndef QT_NO_POPUPMENU
|
---|
| 1294 | if ( !p->testWState( WState_Polished ) )
|
---|
| 1295 | p->setCheckable( TRUE );
|
---|
| 1296 | #endif
|
---|
| 1297 | }
|
---|
| 1298 |
|
---|
| 1299 | #ifndef QT_NO_IMAGEIO_XPM
|
---|
| 1300 | static const char * const qt_close_xpm[] = {
|
---|
| 1301 | "12 12 2 1",
|
---|
| 1302 | "# c #000000",
|
---|
| 1303 | ". c None",
|
---|
| 1304 | "............",
|
---|
| 1305 | "............",
|
---|
| 1306 | "..##....##..",
|
---|
| 1307 | "...##..##...",
|
---|
| 1308 | "....####....",
|
---|
| 1309 | ".....##.....",
|
---|
| 1310 | "....####....",
|
---|
| 1311 | "...##..##...",
|
---|
| 1312 | "..##....##..",
|
---|
| 1313 | "............",
|
---|
| 1314 | "............",
|
---|
| 1315 | "............"};
|
---|
| 1316 |
|
---|
| 1317 | static const char * const qt_maximize_xpm[]={
|
---|
| 1318 | "12 12 2 1",
|
---|
| 1319 | "# c #000000",
|
---|
| 1320 | ". c None",
|
---|
| 1321 | "............",
|
---|
| 1322 | ".#########..",
|
---|
| 1323 | ".#########..",
|
---|
| 1324 | ".#.......#..",
|
---|
| 1325 | ".#.......#..",
|
---|
| 1326 | ".#.......#..",
|
---|
| 1327 | ".#.......#..",
|
---|
| 1328 | ".#.......#..",
|
---|
| 1329 | ".#.......#..",
|
---|
| 1330 | ".#########..",
|
---|
| 1331 | "............",
|
---|
| 1332 | "............"};
|
---|
| 1333 |
|
---|
| 1334 |
|
---|
| 1335 | static const char * const qt_minimize_xpm[] = {
|
---|
| 1336 | "12 12 2 1",
|
---|
| 1337 | "# c #000000",
|
---|
| 1338 | ". c None",
|
---|
| 1339 | "............",
|
---|
| 1340 | "............",
|
---|
| 1341 | "............",
|
---|
| 1342 | "............",
|
---|
| 1343 | "............",
|
---|
| 1344 | "............",
|
---|
| 1345 | "............",
|
---|
| 1346 | "............",
|
---|
| 1347 | "..######....",
|
---|
| 1348 | "..######....",
|
---|
| 1349 | "............",
|
---|
| 1350 | "............"};
|
---|
| 1351 |
|
---|
| 1352 | static const char * const qt_normalizeup_xpm[] = {
|
---|
| 1353 | "12 12 2 1",
|
---|
| 1354 | "# c #000000",
|
---|
| 1355 | ". c None",
|
---|
| 1356 | "............",
|
---|
| 1357 | "....######..",
|
---|
| 1358 | "....######..",
|
---|
| 1359 | "....#....#..",
|
---|
| 1360 | "..######.#..",
|
---|
| 1361 | "..######.#..",
|
---|
| 1362 | "..#....###..",
|
---|
| 1363 | "..#....#....",
|
---|
| 1364 | "..#....#....",
|
---|
| 1365 | "..######....",
|
---|
| 1366 | "............",
|
---|
| 1367 | "............"};
|
---|
| 1368 |
|
---|
| 1369 |
|
---|
| 1370 | static const char * const qt_shade_xpm[] = {
|
---|
| 1371 | "12 12 2 1",
|
---|
| 1372 | "# c #000000",
|
---|
| 1373 | ". c None",
|
---|
| 1374 | "............",
|
---|
| 1375 | "............",
|
---|
| 1376 | "............",
|
---|
| 1377 | "............",
|
---|
| 1378 | "............",
|
---|
| 1379 | ".....#......",
|
---|
| 1380 | "....###.....",
|
---|
| 1381 | "...#####....",
|
---|
| 1382 | "..#######...",
|
---|
| 1383 | "............",
|
---|
| 1384 | "............",
|
---|
| 1385 | "............"};
|
---|
| 1386 |
|
---|
| 1387 | static const char * const qt_unshade_xpm[] = {
|
---|
| 1388 | "12 12 2 1",
|
---|
| 1389 | "# c #000000",
|
---|
| 1390 | ". c None",
|
---|
| 1391 | "............",
|
---|
| 1392 | "............",
|
---|
| 1393 | "............",
|
---|
| 1394 | "............",
|
---|
| 1395 | "..#######...",
|
---|
| 1396 | "...#####....",
|
---|
| 1397 | "....###.....",
|
---|
| 1398 | ".....#......",
|
---|
| 1399 | "............",
|
---|
| 1400 | "............",
|
---|
| 1401 | "............",
|
---|
| 1402 | "............"};
|
---|
| 1403 |
|
---|
| 1404 | static const char * dock_window_close_xpm[] = {
|
---|
| 1405 | "8 8 2 1",
|
---|
| 1406 | "# c #000000",
|
---|
| 1407 | ". c None",
|
---|
| 1408 | "........",
|
---|
| 1409 | ".##..##.",
|
---|
| 1410 | "..####..",
|
---|
| 1411 | "...##...",
|
---|
| 1412 | "..####..",
|
---|
| 1413 | ".##..##.",
|
---|
| 1414 | "........",
|
---|
| 1415 | "........"};
|
---|
| 1416 |
|
---|
| 1417 | /* XPM */
|
---|
| 1418 | static const char * const information_xpm[]={
|
---|
| 1419 | "32 32 5 1",
|
---|
| 1420 | ". c None",
|
---|
| 1421 | "c c #000000",
|
---|
| 1422 | "* c #999999",
|
---|
| 1423 | "a c #ffffff",
|
---|
| 1424 | "b c #0000ff",
|
---|
| 1425 | "...........********.............",
|
---|
| 1426 | "........***aaaaaaaa***..........",
|
---|
| 1427 | "......**aaaaaaaaaaaaaa**........",
|
---|
| 1428 | ".....*aaaaaaaaaaaaaaaaaa*.......",
|
---|
| 1429 | "....*aaaaaaaabbbbaaaaaaaac......",
|
---|
| 1430 | "...*aaaaaaaabbbbbbaaaaaaaac.....",
|
---|
| 1431 | "..*aaaaaaaaabbbbbbaaaaaaaaac....",
|
---|
| 1432 | ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
|
---|
| 1433 | ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
|
---|
| 1434 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
|
---|
| 1435 | "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
|
---|
| 1436 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
| 1437 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
| 1438 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
| 1439 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
| 1440 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
| 1441 | ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
|
---|
| 1442 | ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
|
---|
| 1443 | "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
|
---|
| 1444 | "...caaaaaaabbbbbbbbbaaaaaac****.",
|
---|
| 1445 | "....caaaaaaaaaaaaaaaaaaaac****..",
|
---|
| 1446 | ".....caaaaaaaaaaaaaaaaaac****...",
|
---|
| 1447 | "......ccaaaaaaaaaaaaaacc****....",
|
---|
| 1448 | ".......*cccaaaaaaaaccc*****.....",
|
---|
| 1449 | "........***cccaaaac*******......",
|
---|
| 1450 | "..........****caaac*****........",
|
---|
| 1451 | ".............*caaac**...........",
|
---|
| 1452 | "...............caac**...........",
|
---|
| 1453 | "................cac**...........",
|
---|
| 1454 | ".................cc**...........",
|
---|
| 1455 | "..................***...........",
|
---|
| 1456 | "...................**..........."};
|
---|
| 1457 | /* XPM */
|
---|
| 1458 | static const char* const warning_xpm[]={
|
---|
| 1459 | "32 32 4 1",
|
---|
| 1460 | ". c None",
|
---|
| 1461 | "a c #ffff00",
|
---|
| 1462 | "* c #000000",
|
---|
| 1463 | "b c #999999",
|
---|
| 1464 | ".............***................",
|
---|
| 1465 | "............*aaa*...............",
|
---|
| 1466 | "...........*aaaaa*b.............",
|
---|
| 1467 | "...........*aaaaa*bb............",
|
---|
| 1468 | "..........*aaaaaaa*bb...........",
|
---|
| 1469 | "..........*aaaaaaa*bb...........",
|
---|
| 1470 | ".........*aaaaaaaaa*bb..........",
|
---|
| 1471 | ".........*aaaaaaaaa*bb..........",
|
---|
| 1472 | "........*aaaaaaaaaaa*bb.........",
|
---|
| 1473 | "........*aaaa***aaaa*bb.........",
|
---|
| 1474 | ".......*aaaa*****aaaa*bb........",
|
---|
| 1475 | ".......*aaaa*****aaaa*bb........",
|
---|
| 1476 | "......*aaaaa*****aaaaa*bb.......",
|
---|
| 1477 | "......*aaaaa*****aaaaa*bb.......",
|
---|
| 1478 | ".....*aaaaaa*****aaaaaa*bb......",
|
---|
| 1479 | ".....*aaaaaa*****aaaaaa*bb......",
|
---|
| 1480 | "....*aaaaaaaa***aaaaaaaa*bb.....",
|
---|
| 1481 | "....*aaaaaaaa***aaaaaaaa*bb.....",
|
---|
| 1482 | "...*aaaaaaaaa***aaaaaaaaa*bb....",
|
---|
| 1483 | "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
|
---|
| 1484 | "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
|
---|
| 1485 | "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
|
---|
| 1486 | ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
|
---|
| 1487 | ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
|
---|
| 1488 | "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
|
---|
| 1489 | "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
|
---|
| 1490 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
|
---|
| 1491 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
|
---|
| 1492 | ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
|
---|
| 1493 | "..*************************bbbbb",
|
---|
| 1494 | "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
|
---|
| 1495 | ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
|
---|
| 1496 | /* XPM */
|
---|
| 1497 | static const char* const critical_xpm[]={
|
---|
| 1498 | "32 32 4 1",
|
---|
| 1499 | ". c None",
|
---|
| 1500 | "a c #999999",
|
---|
| 1501 | "* c #ff0000",
|
---|
| 1502 | "b c #ffffff",
|
---|
| 1503 | "...........********.............",
|
---|
| 1504 | ".........************...........",
|
---|
| 1505 | ".......****************.........",
|
---|
| 1506 | "......******************........",
|
---|
| 1507 | ".....********************a......",
|
---|
| 1508 | "....**********************a.....",
|
---|
| 1509 | "...************************a....",
|
---|
| 1510 | "..*******b**********b*******a...",
|
---|
| 1511 | "..******bbb********bbb******a...",
|
---|
| 1512 | ".******bbbbb******bbbbb******a..",
|
---|
| 1513 | ".*******bbbbb****bbbbb*******a..",
|
---|
| 1514 | "*********bbbbb**bbbbb*********a.",
|
---|
| 1515 | "**********bbbbbbbbbb**********a.",
|
---|
| 1516 | "***********bbbbbbbb***********aa",
|
---|
| 1517 | "************bbbbbb************aa",
|
---|
| 1518 | "************bbbbbb************aa",
|
---|
| 1519 | "***********bbbbbbbb***********aa",
|
---|
| 1520 | "**********bbbbbbbbbb**********aa",
|
---|
| 1521 | "*********bbbbb**bbbbb*********aa",
|
---|
| 1522 | ".*******bbbbb****bbbbb*******aa.",
|
---|
| 1523 | ".******bbbbb******bbbbb******aa.",
|
---|
| 1524 | "..******bbb********bbb******aaa.",
|
---|
| 1525 | "..*******b**********b*******aa..",
|
---|
| 1526 | "...************************aaa..",
|
---|
| 1527 | "....**********************aaa...",
|
---|
| 1528 | "....a********************aaa....",
|
---|
| 1529 | ".....a******************aaa.....",
|
---|
| 1530 | "......a****************aaa......",
|
---|
| 1531 | ".......aa************aaaa.......",
|
---|
| 1532 | ".........aa********aaaaa........",
|
---|
| 1533 | "...........aaaaaaaaaaa..........",
|
---|
| 1534 | ".............aaaaaaa............"};
|
---|
| 1535 | /* XPM */
|
---|
| 1536 | static const char *const question_xpm[] = {
|
---|
| 1537 | "32 32 5 1",
|
---|
| 1538 | ". c None",
|
---|
| 1539 | "c c #000000",
|
---|
| 1540 | "* c #999999",
|
---|
| 1541 | "a c #ffffff",
|
---|
| 1542 | "b c #0000ff",
|
---|
| 1543 | "...........********.............",
|
---|
| 1544 | "........***aaaaaaaa***..........",
|
---|
| 1545 | "......**aaaaaaaaaaaaaa**........",
|
---|
| 1546 | ".....*aaaaaaaaaaaaaaaaaa*.......",
|
---|
| 1547 | "....*aaaaaaaaaaaaaaaaaaaac......",
|
---|
| 1548 | "...*aaaaaaaabbbbbbaaaaaaaac.....",
|
---|
| 1549 | "..*aaaaaaaabaaabbbbaaaaaaaac....",
|
---|
| 1550 | ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
|
---|
| 1551 | ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
|
---|
| 1552 | "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
|
---|
| 1553 | "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
|
---|
| 1554 | "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
|
---|
| 1555 | "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
|
---|
| 1556 | "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
|
---|
| 1557 | "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
|
---|
| 1558 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
|
---|
| 1559 | ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
|
---|
| 1560 | ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
|
---|
| 1561 | "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
|
---|
| 1562 | "...caaaaaaaaaabbaaaaaaaaaac****.",
|
---|
| 1563 | "....caaaaaaaaaaaaaaaaaaaac****..",
|
---|
| 1564 | ".....caaaaaaaaaaaaaaaaaac****...",
|
---|
| 1565 | "......ccaaaaaaaaaaaaaacc****....",
|
---|
| 1566 | ".......*cccaaaaaaaaccc*****.....",
|
---|
| 1567 | "........***cccaaaac*******......",
|
---|
| 1568 | "..........****caaac*****........",
|
---|
| 1569 | ".............*caaac**...........",
|
---|
| 1570 | "...............caac**...........",
|
---|
| 1571 | "................cac**...........",
|
---|
| 1572 | ".................cc**...........",
|
---|
| 1573 | "..................***...........",
|
---|
| 1574 | "...................**...........",
|
---|
| 1575 | };
|
---|
| 1576 | #endif //QT_NO_IMAGEIO_XPM
|
---|
| 1577 |
|
---|
| 1578 | /*!
|
---|
| 1579 | \reimp
|
---|
| 1580 | */
|
---|
| 1581 | QPixmap QWindowsStyle::stylePixmap(StylePixmap stylepixmap,
|
---|
| 1582 | const QWidget *widget,
|
---|
| 1583 | const QStyleOption& opt) const
|
---|
| 1584 | {
|
---|
| 1585 | #ifndef QT_NO_IMAGEIO_XPM
|
---|
| 1586 | switch (stylepixmap) {
|
---|
| 1587 | case SP_TitleBarShadeButton:
|
---|
| 1588 | return QPixmap( (const char **)qt_shade_xpm );
|
---|
| 1589 | case SP_TitleBarUnshadeButton:
|
---|
| 1590 | return QPixmap( (const char **)qt_unshade_xpm );
|
---|
| 1591 | case SP_TitleBarNormalButton:
|
---|
| 1592 | return QPixmap( (const char **)qt_normalizeup_xpm );
|
---|
| 1593 | case SP_TitleBarMinButton:
|
---|
| 1594 | return QPixmap( (const char **)qt_minimize_xpm );
|
---|
| 1595 | case SP_TitleBarMaxButton:
|
---|
| 1596 | return QPixmap( (const char **)qt_maximize_xpm );
|
---|
| 1597 | case SP_TitleBarCloseButton:
|
---|
| 1598 | return QPixmap( (const char **)qt_close_xpm );
|
---|
| 1599 | case SP_DockWindowCloseButton:
|
---|
| 1600 | return QPixmap( (const char **)dock_window_close_xpm );
|
---|
| 1601 | case SP_MessageBoxInformation:
|
---|
| 1602 | return QPixmap( (const char **)information_xpm);
|
---|
| 1603 | case SP_MessageBoxWarning:
|
---|
| 1604 | return QPixmap( (const char **)warning_xpm );
|
---|
| 1605 | case SP_MessageBoxCritical:
|
---|
| 1606 | return QPixmap( (const char **)critical_xpm );
|
---|
| 1607 | case SP_MessageBoxQuestion:
|
---|
| 1608 | return QPixmap( (const char **)question_xpm );
|
---|
| 1609 | default:
|
---|
| 1610 | break;
|
---|
| 1611 | }
|
---|
| 1612 | #endif //QT_NO_IMAGEIO_XPM
|
---|
| 1613 | return QCommonStyle::stylePixmap(stylepixmap, widget, opt);
|
---|
| 1614 | }
|
---|
| 1615 |
|
---|
| 1616 | /*!\reimp
|
---|
| 1617 | */
|
---|
| 1618 | void QWindowsStyle::drawComplexControl( ComplexControl ctrl, QPainter *p,
|
---|
| 1619 | const QWidget *widget,
|
---|
| 1620 | const QRect &r,
|
---|
| 1621 | const QColorGroup &cg,
|
---|
| 1622 | SFlags flags,
|
---|
| 1623 | SCFlags sub,
|
---|
| 1624 | SCFlags subActive,
|
---|
| 1625 | const QStyleOption& opt ) const
|
---|
| 1626 | {
|
---|
| 1627 | switch (ctrl) {
|
---|
| 1628 | #ifndef QT_NO_LISTVIEW
|
---|
| 1629 | case CC_ListView:
|
---|
| 1630 | {
|
---|
| 1631 | if ( sub & SC_ListView ) {
|
---|
| 1632 | QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, subActive, opt );
|
---|
| 1633 | }
|
---|
| 1634 | if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
|
---|
| 1635 | if (opt.isDefault())
|
---|
| 1636 | break;
|
---|
| 1637 |
|
---|
| 1638 | QListViewItem *item = opt.listViewItem(),
|
---|
| 1639 | *child = item->firstChild();
|
---|
| 1640 |
|
---|
| 1641 | int y = r.y();
|
---|
| 1642 | int c;
|
---|
| 1643 | int dotoffset = 0;
|
---|
| 1644 | QPointArray dotlines;
|
---|
| 1645 | if ( subActive == (uint)SC_All && sub == SC_ListViewExpand ) {
|
---|
| 1646 | c = 2;
|
---|
| 1647 | dotlines.resize(2);
|
---|
| 1648 | dotlines[0] = QPoint( r.right(), r.top() );
|
---|
| 1649 | dotlines[1] = QPoint( r.right(), r.bottom() );
|
---|
| 1650 | } else {
|
---|
| 1651 | int linetop = 0, linebot = 0;
|
---|
| 1652 | // each branch needs at most two lines, ie. four end points
|
---|
| 1653 | dotoffset = (item->itemPos() + item->height() - y) %2;
|
---|
| 1654 | dotlines.resize( item->childCount() * 4 );
|
---|
| 1655 | c = 0;
|
---|
| 1656 |
|
---|
| 1657 | // skip the stuff above the exposed rectangle
|
---|
| 1658 | while ( child && y + child->height() <= 0 ) {
|
---|
| 1659 | y += child->totalHeight();
|
---|
| 1660 | child = child->nextSibling();
|
---|
| 1661 | }
|
---|
| 1662 |
|
---|
| 1663 | int bx = r.width() / 2;
|
---|
| 1664 |
|
---|
| 1665 | // paint stuff in the magical area
|
---|
| 1666 | QListView* v = item->listView();
|
---|
| 1667 | while ( child && y < r.height() ) {
|
---|
| 1668 | if (child->isVisible()) {
|
---|
| 1669 | int lh;
|
---|
| 1670 | if ( !item->multiLinesEnabled() )
|
---|
| 1671 | lh = child->height();
|
---|
| 1672 | else
|
---|
| 1673 | lh = p->fontMetrics().height() + 2 * v->itemMargin();
|
---|
| 1674 | lh = QMAX( lh, QApplication::globalStrut().height() );
|
---|
| 1675 | if ( lh % 2 > 0 )
|
---|
| 1676 | lh++;
|
---|
| 1677 | linebot = y + lh/2;
|
---|
| 1678 | if ( (child->isExpandable() || child->childCount()) &&
|
---|
| 1679 | (child->height() > 0) ) {
|
---|
| 1680 | // needs a box
|
---|
| 1681 | p->setPen( cg.mid() );
|
---|
| 1682 | p->drawRect( bx-4, linebot-4, 9, 9 );
|
---|
| 1683 | // plus or minus
|
---|
| 1684 | p->setPen( cg.text() );
|
---|
| 1685 | p->drawLine( bx - 2, linebot, bx + 2, linebot );
|
---|
| 1686 | if ( !child->isOpen() )
|
---|
| 1687 | p->drawLine( bx, linebot - 2, bx, linebot + 2 );
|
---|
| 1688 | // dotlinery
|
---|
| 1689 | p->setPen( cg.mid() );
|
---|
| 1690 | dotlines[c++] = QPoint( bx, linetop );
|
---|
| 1691 | dotlines[c++] = QPoint( bx, linebot - 4 );
|
---|
| 1692 | dotlines[c++] = QPoint( bx + 5, linebot );
|
---|
| 1693 | dotlines[c++] = QPoint( r.width(), linebot );
|
---|
| 1694 | linetop = linebot + 5;
|
---|
| 1695 | } else {
|
---|
| 1696 | // just dotlinery
|
---|
| 1697 | dotlines[c++] = QPoint( bx+1, linebot -1);
|
---|
| 1698 | dotlines[c++] = QPoint( r.width(), linebot -1);
|
---|
| 1699 | }
|
---|
| 1700 | y += child->totalHeight();
|
---|
| 1701 | }
|
---|
| 1702 | child = child->nextSibling();
|
---|
| 1703 | }
|
---|
| 1704 |
|
---|
| 1705 | // Expand line height to edge of rectangle if there's any
|
---|
| 1706 | // visible child below
|
---|
| 1707 | while ( child && child->height() <= 0)
|
---|
| 1708 | child = child->nextSibling();
|
---|
| 1709 | if ( child )
|
---|
| 1710 | linebot = r.height();
|
---|
| 1711 |
|
---|
| 1712 | if ( linetop < linebot ) {
|
---|
| 1713 | dotlines[c++] = QPoint( bx, linetop );
|
---|
| 1714 | dotlines[c++] = QPoint( bx, linebot );
|
---|
| 1715 | }
|
---|
| 1716 | }
|
---|
| 1717 | p->setPen( cg.text() );
|
---|
| 1718 |
|
---|
| 1719 | static QBitmap *verticalLine = 0, *horizontalLine = 0;
|
---|
| 1720 | static QCleanupHandler<QBitmap> qlv_cleanup_bitmap;
|
---|
| 1721 | if ( !verticalLine ) {
|
---|
| 1722 | // make 128*1 and 1*128 bitmaps that can be used for
|
---|
| 1723 | // drawing the right sort of lines.
|
---|
| 1724 | verticalLine = new QBitmap( 1, 129, TRUE );
|
---|
| 1725 | horizontalLine = new QBitmap( 128, 1, TRUE );
|
---|
| 1726 | QPointArray a( 64 );
|
---|
| 1727 | QPainter p;
|
---|
| 1728 | p.begin( verticalLine );
|
---|
| 1729 | int i;
|
---|
| 1730 | for( i=0; i<64; i++ )
|
---|
| 1731 | a.setPoint( i, 0, i*2+1 );
|
---|
| 1732 | p.setPen( color1 );
|
---|
| 1733 | p.drawPoints( a );
|
---|
| 1734 | p.end();
|
---|
| 1735 | QApplication::flushX();
|
---|
| 1736 | verticalLine->setMask( *verticalLine );
|
---|
| 1737 | p.begin( horizontalLine );
|
---|
| 1738 | for( i=0; i<64; i++ )
|
---|
| 1739 | a.setPoint( i, i*2+1, 0 );
|
---|
| 1740 | p.setPen( color1 );
|
---|
| 1741 | p.drawPoints( a );
|
---|
| 1742 | p.end();
|
---|
| 1743 | QApplication::flushX();
|
---|
| 1744 | horizontalLine->setMask( *horizontalLine );
|
---|
| 1745 | qlv_cleanup_bitmap.add( &verticalLine );
|
---|
| 1746 | qlv_cleanup_bitmap.add( &horizontalLine );
|
---|
| 1747 | }
|
---|
| 1748 |
|
---|
| 1749 | int line; // index into dotlines
|
---|
| 1750 | if ( sub & SC_ListViewBranch ) for( line = 0; line < c; line += 2 ) {
|
---|
| 1751 | // assumptions here: lines are horizontal or vertical.
|
---|
| 1752 | // lines always start with the numerically lowest
|
---|
| 1753 | // coordinate.
|
---|
| 1754 |
|
---|
| 1755 | // point ... relevant coordinate of current point
|
---|
| 1756 | // end ..... same coordinate of the end of the current line
|
---|
| 1757 | // other ... the other coordinate of the current point/line
|
---|
| 1758 | if ( dotlines[line].y() == dotlines[line+1].y() ) {
|
---|
| 1759 | int end = dotlines[line+1].x();
|
---|
| 1760 | int point = dotlines[line].x();
|
---|
| 1761 | int other = dotlines[line].y();
|
---|
| 1762 | while( point < end ) {
|
---|
| 1763 | int i = 128;
|
---|
| 1764 | if ( i+point > end )
|
---|
| 1765 | i = end-point;
|
---|
| 1766 | p->drawPixmap( point, other, *horizontalLine,
|
---|
| 1767 | 0, 0, i, 1 );
|
---|
| 1768 | point += i;
|
---|
| 1769 | }
|
---|
| 1770 | } else {
|
---|
| 1771 | int end = dotlines[line+1].y();
|
---|
| 1772 | int point = dotlines[line].y();
|
---|
| 1773 | int other = dotlines[line].x();
|
---|
| 1774 | int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
|
---|
| 1775 | while( point < end ) {
|
---|
| 1776 | int i = 128;
|
---|
| 1777 | if ( i+point > end )
|
---|
| 1778 | i = end-point;
|
---|
| 1779 | p->drawPixmap( other, point, *verticalLine,
|
---|
| 1780 | 0, pixmapoffset, 1, i );
|
---|
| 1781 | point += i;
|
---|
| 1782 | }
|
---|
| 1783 | }
|
---|
| 1784 | }
|
---|
| 1785 | }
|
---|
| 1786 | }
|
---|
| 1787 | break;
|
---|
| 1788 | #endif //QT_NO_LISTVIEW
|
---|
| 1789 |
|
---|
| 1790 | #ifndef QT_NO_COMBOBOX
|
---|
| 1791 | case CC_ComboBox:
|
---|
| 1792 | if ( sub & SC_ComboBoxArrow ) {
|
---|
| 1793 | SFlags flags = Style_Default;
|
---|
| 1794 |
|
---|
| 1795 | qDrawWinPanel( p, r, cg, TRUE, widget->isEnabled() ?
|
---|
| 1796 | &cg.brush( QColorGroup::Base ):
|
---|
| 1797 | &cg.brush( QColorGroup::Background ) );
|
---|
| 1798 |
|
---|
| 1799 | QRect ar =
|
---|
| 1800 | QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
|
---|
| 1801 | SC_ComboBoxArrow ), widget );
|
---|
| 1802 | if ( subActive == SC_ComboBoxArrow ) {
|
---|
| 1803 | p->setPen( cg.dark() );
|
---|
| 1804 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
---|
| 1805 | p->drawRect( ar );
|
---|
| 1806 | } else
|
---|
| 1807 | qDrawWinPanel( p, ar, cg, FALSE,
|
---|
| 1808 | &cg.brush( QColorGroup::Button ) );
|
---|
| 1809 |
|
---|
| 1810 | ar.addCoords( 2, 2, -2, -2 );
|
---|
| 1811 | if ( widget->isEnabled() )
|
---|
| 1812 | flags |= Style_Enabled;
|
---|
| 1813 |
|
---|
| 1814 | if ( subActive == SC_ComboBoxArrow ) {
|
---|
| 1815 | flags |= Style_Sunken;
|
---|
| 1816 | }
|
---|
| 1817 | drawPrimitive( PE_ArrowDown, p, ar, cg, flags );
|
---|
| 1818 | }
|
---|
| 1819 |
|
---|
| 1820 | if ( sub & SC_ComboBoxEditField ) {
|
---|
| 1821 | const QComboBox * cb = (const QComboBox *) widget;
|
---|
| 1822 | QRect re =
|
---|
| 1823 | QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
|
---|
| 1824 | SC_ComboBoxEditField ), widget );
|
---|
| 1825 | if ( cb->hasFocus() && !cb->editable() )
|
---|
| 1826 | p->fillRect( re.x(), re.y(), re.width(), re.height(),
|
---|
| 1827 | cg.brush( QColorGroup::Highlight ) );
|
---|
| 1828 |
|
---|
| 1829 | if ( cb->hasFocus() ) {
|
---|
| 1830 | p->setPen( cg.highlightedText() );
|
---|
| 1831 | p->setBackgroundColor( cg.highlight() );
|
---|
| 1832 |
|
---|
| 1833 | } else {
|
---|
| 1834 | p->setPen( cg.text() );
|
---|
| 1835 | p->setBackgroundColor( cg.background() );
|
---|
| 1836 | }
|
---|
| 1837 |
|
---|
| 1838 | if ( cb->hasFocus() && !cb->editable() ) {
|
---|
| 1839 | QRect re =
|
---|
| 1840 | QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
|
---|
| 1841 | drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight()));
|
---|
| 1842 | }
|
---|
| 1843 | }
|
---|
| 1844 |
|
---|
| 1845 | break;
|
---|
| 1846 | #endif // QT_NO_COMBOBOX
|
---|
| 1847 |
|
---|
| 1848 | #ifndef QT_NO_SLIDER
|
---|
| 1849 | case CC_Slider:
|
---|
| 1850 | {
|
---|
| 1851 | const QSlider *sl = (const QSlider *) widget;
|
---|
| 1852 | int thickness = pixelMetric( PM_SliderControlThickness, widget );
|
---|
| 1853 | int len = pixelMetric( PM_SliderLength, widget );
|
---|
| 1854 | int ticks = sl->tickmarks();
|
---|
| 1855 |
|
---|
| 1856 | QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
|
---|
| 1857 | opt),
|
---|
| 1858 | handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
|
---|
| 1859 | opt);
|
---|
| 1860 |
|
---|
| 1861 | if ((sub & SC_SliderGroove) && groove.isValid()) {
|
---|
| 1862 | int mid = thickness / 2;
|
---|
| 1863 |
|
---|
| 1864 | if ( ticks & QSlider::Above )
|
---|
| 1865 | mid += len / 8;
|
---|
| 1866 | if ( ticks & QSlider::Below )
|
---|
| 1867 | mid -= len / 8;
|
---|
| 1868 |
|
---|
| 1869 | p->setPen( cg.shadow() );
|
---|
| 1870 | if ( sl->orientation() == Horizontal ) {
|
---|
| 1871 | qDrawWinPanel( p, groove.x(), groove.y() + mid - 2,
|
---|
| 1872 | groove.width(), 4, cg, TRUE );
|
---|
| 1873 | p->drawLine( groove.x() + 1, groove.y() + mid - 1,
|
---|
| 1874 | groove.x() + groove.width() - 3, groove.y() + mid - 1 );
|
---|
| 1875 | } else {
|
---|
| 1876 | qDrawWinPanel( p, groove.x() + mid - 2, groove.y(),
|
---|
| 1877 | 4, groove.height(), cg, TRUE );
|
---|
| 1878 | p->drawLine( groove.x() + mid - 1, groove.y() + 1,
|
---|
| 1879 | groove.x() + mid - 1,
|
---|
| 1880 | groove.y() + groove.height() - 3 );
|
---|
| 1881 | }
|
---|
| 1882 | }
|
---|
| 1883 |
|
---|
| 1884 | if (sub & SC_SliderTickmarks)
|
---|
| 1885 | QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags,
|
---|
| 1886 | SC_SliderTickmarks, subActive,
|
---|
| 1887 | opt );
|
---|
| 1888 |
|
---|
| 1889 | if ( sub & SC_SliderHandle ) {
|
---|
| 1890 | // 4444440
|
---|
| 1891 | // 4333310
|
---|
| 1892 | // 4322210
|
---|
| 1893 | // 4322210
|
---|
| 1894 | // 4322210
|
---|
| 1895 | // 4322210
|
---|
| 1896 | // *43210*
|
---|
| 1897 | // **410**
|
---|
| 1898 | // ***0***
|
---|
| 1899 | const QColor c0 = cg.shadow();
|
---|
| 1900 | const QColor c1 = cg.dark();
|
---|
| 1901 | // const QColor c2 = g.button();
|
---|
| 1902 | const QColor c3 = cg.midlight();
|
---|
| 1903 | const QColor c4 = cg.light();
|
---|
| 1904 |
|
---|
| 1905 | int x = handle.x(), y = handle.y(),
|
---|
| 1906 | wi = handle.width(), he = handle.height();
|
---|
| 1907 |
|
---|
| 1908 | int x1 = x;
|
---|
| 1909 | int x2 = x+wi-1;
|
---|
| 1910 | int y1 = y;
|
---|
| 1911 | int y2 = y+he-1;
|
---|
| 1912 |
|
---|
| 1913 | Orientation orient = sl->orientation();
|
---|
| 1914 | bool tickAbove = sl->tickmarks() == QSlider::Above;
|
---|
| 1915 | bool tickBelow = sl->tickmarks() == QSlider::Below;
|
---|
| 1916 |
|
---|
| 1917 | p->fillRect( x, y, wi, he, cg.brush( QColorGroup::Background ) );
|
---|
| 1918 |
|
---|
| 1919 | if ( flags & Style_HasFocus ) {
|
---|
| 1920 | QRect re = subRect( SR_SliderFocusRect, sl );
|
---|
| 1921 | drawPrimitive( PE_FocusRect, p, re, cg );
|
---|
| 1922 | }
|
---|
| 1923 |
|
---|
| 1924 | if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) {
|
---|
| 1925 | qDrawWinButton( p, QRect(x,y,wi,he), cg, FALSE,
|
---|
| 1926 | &cg.brush( QColorGroup::Button ) );
|
---|
| 1927 | return;
|
---|
| 1928 | }
|
---|
| 1929 |
|
---|
| 1930 | QSliderDirection dir;
|
---|
| 1931 |
|
---|
| 1932 | if ( orient == Horizontal )
|
---|
| 1933 | if ( tickAbove )
|
---|
| 1934 | dir = SlUp;
|
---|
| 1935 | else
|
---|
| 1936 | dir = SlDown;
|
---|
| 1937 | else
|
---|
| 1938 | if ( tickAbove )
|
---|
| 1939 | dir = SlLeft;
|
---|
| 1940 | else
|
---|
| 1941 | dir = SlRight;
|
---|
| 1942 |
|
---|
| 1943 | QPointArray a;
|
---|
| 1944 |
|
---|
| 1945 | int d = 0;
|
---|
| 1946 | switch ( dir ) {
|
---|
| 1947 | case SlUp:
|
---|
| 1948 | y1 = y1 + wi/2;
|
---|
| 1949 | d = (wi + 1) / 2 - 1;
|
---|
| 1950 | a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );
|
---|
| 1951 | break;
|
---|
| 1952 | case SlDown:
|
---|
| 1953 | y2 = y2 - wi/2;
|
---|
| 1954 | d = (wi + 1) / 2 - 1;
|
---|
| 1955 | a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );
|
---|
| 1956 | break;
|
---|
| 1957 | case SlLeft:
|
---|
| 1958 | d = (he + 1) / 2 - 1;
|
---|
| 1959 | x1 = x1 + he/2;
|
---|
| 1960 | a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
|
---|
| 1961 | break;
|
---|
| 1962 | case SlRight:
|
---|
| 1963 | d = (he + 1) / 2 - 1;
|
---|
| 1964 | x2 = x2 - he/2;
|
---|
| 1965 | a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );
|
---|
| 1966 | break;
|
---|
| 1967 | }
|
---|
| 1968 |
|
---|
| 1969 | QBrush oldBrush = p->brush();
|
---|
| 1970 | p->setBrush( cg.brush( QColorGroup::Button ) );
|
---|
| 1971 | p->setPen( NoPen );
|
---|
| 1972 | p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
|
---|
| 1973 | p->drawPolygon( a );
|
---|
| 1974 | p->setBrush( oldBrush );
|
---|
| 1975 |
|
---|
| 1976 | if ( dir != SlUp ) {
|
---|
| 1977 | p->setPen( c4 );
|
---|
| 1978 | p->drawLine( x1, y1, x2, y1 );
|
---|
| 1979 | p->setPen( c3 );
|
---|
| 1980 | p->drawLine( x1, y1+1, x2, y1+1 );
|
---|
| 1981 | }
|
---|
| 1982 | if ( dir != SlLeft ) {
|
---|
| 1983 | p->setPen( c3 );
|
---|
| 1984 | p->drawLine( x1+1, y1+1, x1+1, y2 );
|
---|
| 1985 | p->setPen( c4 );
|
---|
| 1986 | p->drawLine( x1, y1, x1, y2 );
|
---|
| 1987 | }
|
---|
| 1988 | if ( dir != SlRight ) {
|
---|
| 1989 | p->setPen( c0 );
|
---|
| 1990 | p->drawLine( x2, y1, x2, y2 );
|
---|
| 1991 | p->setPen( c1 );
|
---|
| 1992 | p->drawLine( x2-1, y1+1, x2-1, y2-1 );
|
---|
| 1993 | }
|
---|
| 1994 | if ( dir != SlDown ) {
|
---|
| 1995 | p->setPen( c0 );
|
---|
| 1996 | p->drawLine( x1, y2, x2, y2 );
|
---|
| 1997 | p->setPen( c1 );
|
---|
| 1998 | p->drawLine( x1+1, y2-1, x2-1, y2-1 );
|
---|
| 1999 | }
|
---|
| 2000 |
|
---|
| 2001 | switch ( dir ) {
|
---|
| 2002 | case SlUp:
|
---|
| 2003 | p->setPen( c4 );
|
---|
| 2004 | p->drawLine( x1, y1, x1+d, y1-d);
|
---|
| 2005 | p->setPen( c0 );
|
---|
| 2006 | d = wi - d - 1;
|
---|
| 2007 | p->drawLine( x2, y1, x2-d, y1-d);
|
---|
| 2008 | d--;
|
---|
| 2009 | p->setPen( c3 );
|
---|
| 2010 | p->drawLine( x1+1, y1, x1+1+d, y1-d );
|
---|
| 2011 | p->setPen( c1 );
|
---|
| 2012 | p->drawLine( x2-1, y1, x2-1-d, y1-d);
|
---|
| 2013 | break;
|
---|
| 2014 | case SlDown:
|
---|
| 2015 | p->setPen( c4 );
|
---|
| 2016 | p->drawLine( x1, y2, x1+d, y2+d);
|
---|
| 2017 | p->setPen( c0 );
|
---|
| 2018 | d = wi - d - 1;
|
---|
| 2019 | p->drawLine( x2, y2, x2-d, y2+d);
|
---|
| 2020 | d--;
|
---|
| 2021 | p->setPen( c3 );
|
---|
| 2022 | p->drawLine( x1+1, y2, x1+1+d, y2+d );
|
---|
| 2023 | p->setPen( c1 );
|
---|
| 2024 | p->drawLine( x2-1, y2, x2-1-d, y2+d);
|
---|
| 2025 | break;
|
---|
| 2026 | case SlLeft:
|
---|
| 2027 | p->setPen( c4 );
|
---|
| 2028 | p->drawLine( x1, y1, x1-d, y1+d);
|
---|
| 2029 | p->setPen( c0 );
|
---|
| 2030 | d = he - d - 1;
|
---|
| 2031 | p->drawLine( x1, y2, x1-d, y2-d);
|
---|
| 2032 | d--;
|
---|
| 2033 | p->setPen( c3 );
|
---|
| 2034 | p->drawLine( x1, y1+1, x1-d, y1+1+d );
|
---|
| 2035 | p->setPen( c1 );
|
---|
| 2036 | p->drawLine( x1, y2-1, x1-d, y2-1-d);
|
---|
| 2037 | break;
|
---|
| 2038 | case SlRight:
|
---|
| 2039 | p->setPen( c4 );
|
---|
| 2040 | p->drawLine( x2, y1, x2+d, y1+d);
|
---|
| 2041 | p->setPen( c0 );
|
---|
| 2042 | d = he - d - 1;
|
---|
| 2043 | p->drawLine( x2, y2, x2+d, y2-d);
|
---|
| 2044 | d--;
|
---|
| 2045 | p->setPen( c3 );
|
---|
| 2046 | p->drawLine( x2, y1+1, x2+d, y1+1+d );
|
---|
| 2047 | p->setPen( c1 );
|
---|
| 2048 | p->drawLine( x2, y2-1, x2+d, y2-1-d);
|
---|
| 2049 | break;
|
---|
| 2050 | }
|
---|
| 2051 | }
|
---|
| 2052 |
|
---|
| 2053 | break;
|
---|
| 2054 | }
|
---|
| 2055 | #endif // QT_NO_SLIDER
|
---|
| 2056 |
|
---|
| 2057 | default:
|
---|
| 2058 | QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub,
|
---|
| 2059 | subActive, opt );
|
---|
| 2060 | break;
|
---|
| 2061 | }
|
---|
| 2062 | }
|
---|
| 2063 |
|
---|
| 2064 |
|
---|
| 2065 | /*! \reimp */
|
---|
| 2066 | int QWindowsStyle::styleHint( StyleHint hint,
|
---|
| 2067 | const QWidget *widget,
|
---|
| 2068 | const QStyleOption &opt,
|
---|
| 2069 | QStyleHintReturn *returnData ) const
|
---|
| 2070 | {
|
---|
| 2071 | int ret;
|
---|
| 2072 |
|
---|
| 2073 | switch (hint) {
|
---|
| 2074 | case SH_EtchDisabledText:
|
---|
| 2075 | case SH_Slider_SnapToValue:
|
---|
| 2076 | case SH_PrintDialog_RightAlignButtons:
|
---|
| 2077 | case SH_MainWindow_SpaceBelowMenuBar:
|
---|
| 2078 | case SH_FontDialog_SelectAssociatedText:
|
---|
| 2079 | case SH_PopupMenu_AllowActiveAndDisabled:
|
---|
| 2080 | case SH_MenuBar_AltKeyNavigation:
|
---|
| 2081 | case SH_MenuBar_MouseTracking:
|
---|
| 2082 | case SH_PopupMenu_MouseTracking:
|
---|
| 2083 | case SH_ComboBox_ListMouseTracking:
|
---|
| 2084 | case SH_ScrollBar_StopMouseOverSlider:
|
---|
| 2085 | ret = 1;
|
---|
| 2086 | break;
|
---|
| 2087 |
|
---|
| 2088 | case SH_ItemView_ChangeHighlightOnFocus:
|
---|
| 2089 | #if defined(Q_WS_WIN)
|
---|
| 2090 | if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT )
|
---|
| 2091 | ret = 1;
|
---|
| 2092 | else
|
---|
| 2093 | #endif
|
---|
| 2094 | ret = 0;
|
---|
| 2095 | break;
|
---|
| 2096 |
|
---|
| 2097 | case SH_ToolBox_SelectedPageTitleBold:
|
---|
| 2098 | ret = 0;
|
---|
| 2099 | break;
|
---|
| 2100 |
|
---|
| 2101 | #if defined(Q_WS_WIN)
|
---|
| 2102 | case SH_UnderlineAccelerator:
|
---|
| 2103 | ret = 1;
|
---|
| 2104 | if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT ) {
|
---|
| 2105 | BOOL cues;
|
---|
| 2106 | SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
|
---|
| 2107 | ret = cues ? 1 : 0;
|
---|
| 2108 | // Do nothing if we always paint underlines
|
---|
| 2109 | if (!ret && widget && d) {
|
---|
| 2110 | QMenuBar *menuBar = ::qt_cast<QMenuBar*>(widget);
|
---|
| 2111 | QPopupMenu *popupMenu = 0;
|
---|
| 2112 | if (!menuBar)
|
---|
| 2113 | popupMenu = ::qt_cast<QPopupMenu*>(widget);
|
---|
| 2114 |
|
---|
| 2115 | // If we paint a menubar draw underlines if it has focus, or if alt is down,
|
---|
| 2116 | // or if a popup menu belonging to the menubar is active and paints underlines
|
---|
| 2117 | if (menuBar) {
|
---|
| 2118 | if (menuBar->hasFocus()) {
|
---|
| 2119 | ret = 1;
|
---|
| 2120 | } else if (d->altDown()) {
|
---|
| 2121 | ret = 1;
|
---|
| 2122 | } else if (qApp->focusWidget() && qApp->focusWidget()->isPopup()) {
|
---|
| 2123 | popupMenu = ::qt_cast<QPopupMenu*>(qApp->focusWidget());
|
---|
| 2124 | QMenuData *pm = popupMenu ? (QMenuData*)popupMenu->qt_cast("QMenuData") : 0;
|
---|
| 2125 | if (pm && ((FriendlyMenuData*)pm)->parentMenu == menuBar) {
|
---|
| 2126 | if (d->hasSeenAlt(menuBar))
|
---|
| 2127 | ret = 1;
|
---|
| 2128 | }
|
---|
| 2129 | }
|
---|
| 2130 | // If we paint a popup menu draw underlines if the respective menubar does
|
---|
| 2131 | } else if (popupMenu) {
|
---|
| 2132 | QMenuData *pm = (QMenuData*)popupMenu->qt_cast("QMenuData");
|
---|
| 2133 | while (pm) {
|
---|
| 2134 | if (((FriendlyMenuData*)pm)->isMenuBar) {
|
---|
| 2135 | menuBar = (QMenuBar*)pm;
|
---|
| 2136 | if (d->hasSeenAlt(menuBar))
|
---|
| 2137 | ret = 1;
|
---|
| 2138 | break;
|
---|
| 2139 | }
|
---|
| 2140 | pm = ((FriendlyMenuData*)pm)->parentMenu;
|
---|
| 2141 | }
|
---|
| 2142 | // Otherwise draw underlines if the toplevel widget has seen an alt-press
|
---|
| 2143 | } else if (d->hasSeenAlt(widget)) {
|
---|
| 2144 | ret = 1;
|
---|
| 2145 | }
|
---|
| 2146 | }
|
---|
| 2147 |
|
---|
| 2148 | }
|
---|
| 2149 | break;
|
---|
| 2150 | #endif
|
---|
| 2151 |
|
---|
| 2152 | default:
|
---|
| 2153 | ret = QCommonStyle::styleHint(hint, widget, opt, returnData);
|
---|
| 2154 | break;
|
---|
| 2155 | }
|
---|
| 2156 |
|
---|
| 2157 | return ret;
|
---|
| 2158 | }
|
---|
| 2159 |
|
---|
| 2160 | /*! \reimp */
|
---|
| 2161 | QRect QWindowsStyle::subRect(SubRect r, const QWidget *widget) const
|
---|
| 2162 | {
|
---|
| 2163 | QRect rect;
|
---|
| 2164 |
|
---|
| 2165 | switch (r) {
|
---|
| 2166 | #ifndef QT_NO_SLIDER
|
---|
| 2167 | case SR_SliderFocusRect:
|
---|
| 2168 | {
|
---|
| 2169 | rect = widget->rect();
|
---|
| 2170 | break;
|
---|
| 2171 | }
|
---|
| 2172 | #endif // QT_NO_SLIDER
|
---|
| 2173 | case SR_ToolBoxTabContents:
|
---|
| 2174 | rect = widget->rect();
|
---|
| 2175 | break;
|
---|
| 2176 | default:
|
---|
| 2177 | rect = QCommonStyle::subRect( r, widget );
|
---|
| 2178 | break;
|
---|
| 2179 | }
|
---|
| 2180 |
|
---|
| 2181 | return rect;
|
---|
| 2182 | }
|
---|
| 2183 |
|
---|
| 2184 | #endif
|
---|