~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to themes/qmusewindowsstyle.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
** $Id: qmusewindowsstyle.cpp,v 1.1 2002/04/19 20:07:59 kobras Exp $
3
 
**
4
 
** Implementation of Windows-like style class
5
 
** 2002-04-19   Modified for inclusion into muse source tree.
6
 
**              <kobras@debian.org>
7
 
**
8
 
** Created : 981231
9
 
**
10
 
** Copyright (C) 1998-2000 Trolltech AS.  All rights reserved.
11
 
**
12
 
** This file is part of the widgets module of the Qt GUI Toolkit.
13
 
**
14
 
** This file may be distributed under the terms of the Q Public License
15
 
** as defined by Trolltech AS of Norway and appearing in the file
16
 
** LICENSE.QPL included in the packaging of this file.
17
 
**
18
 
** This file may be distributed and/or modified under the terms of the
19
 
** GNU General Public License version 2 as published by the Free Software
20
 
** Foundation and appearing in the file LICENSE.GPL included in the
21
 
** packaging of this file.
22
 
**
23
 
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
24
 
** licenses may use this file in accordance with the Qt Commercial License
25
 
** Agreement provided with the Software.
26
 
**
27
 
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
 
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
 
**
30
 
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
31
 
**   information about Qt Commercial License Agreements.
32
 
** See http://www.trolltech.com/qpl/ for QPL licensing information.
33
 
** See http://www.trolltech.com/gpl/ for GPL licensing information.
34
 
**
35
 
** Contact info@trolltech.com if any conditions of this licensing are
36
 
** not clear to you.
37
 
**
38
 
**********************************************************************/
39
 
 
40
 
#include "qmusewindowsstyle.h"
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
 
 
63
 
#if defined(Q_WS_WIN)
64
 
#include "qt_windows.h"
65
 
#endif
66
 
 
67
 
#include <limits.h>
68
 
 
69
 
 
70
 
static const int windowsItemFrame               =  2; // menu item frame width
71
 
static const int windowsSepHeight               =  2; // separator item height
72
 
static const int windowsItemHMargin             =  3; // menu item hor text margin
73
 
static const int windowsItemVMargin             =  2; // menu item ver text margin
74
 
static const int windowsArrowHMargin            =  6; // arrow horizontal margin
75
 
static const int windowsTabSpacing              = 12; // space between text and tab
76
 
static const int windowsCheckMarkHMargin        =  2; // horiz. margins of check mark
77
 
static const int windowsRightBorder             = 12; // right border on windows
78
 
static const int windowsCheckMarkWidth          = 12; // checkmarks width on windows
79
 
 
80
 
static bool use2000style = TRUE;
81
 
 
82
 
enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
83
 
 
84
 
/*!
85
 
  \class QMuseWindowsStyle qmusewindowsstyle.h
86
 
  \brief The QMuseWindowsStyle class provides a Microsoft Windows-like look and feel.
87
 
  \ingroup appearance
88
 
 
89
 
  This style is Qt's default GUI style on Windows.
90
 
*/
91
 
 
92
 
/*!
93
 
    Constructs a QMuseWindowsStyle
94
 
*/
95
 
QMuseWindowsStyle::QMuseWindowsStyle() : QCommonStyle()
96
 
{
97
 
#if defined(Q_OS_WIN32)
98
 
    if ( qWinVersion() != Qt::WV_NT &&
99
 
         qWinVersion() != Qt::WV_95 )
100
 
        use2000style = TRUE;
101
 
    else
102
 
        use2000style = FALSE;
103
 
#else
104
 
    use2000style = TRUE;
105
 
#endif
106
 
}
107
 
 
108
 
/*! \reimp */
109
 
QMuseWindowsStyle::~QMuseWindowsStyle()
110
 
{
111
 
}
112
 
 
113
 
/*! \reimp */
114
 
void QMuseWindowsStyle::drawPrimitive( PrimitiveElement pe,
115
 
                                   QPainter *p,
116
 
                                   const QRect &r,
117
 
                                   const QColorGroup &cg,
118
 
                                   SFlags flags,
119
 
                                   const QStyleOption& opt ) const
120
 
{
121
 
    switch (pe) {
122
 
    case PE_ButtonCommand:
123
 
        {
124
 
            QBrush fill;
125
 
 
126
 
            if (! (flags & Style_Down) && (flags & Style_On))
127
 
                fill = QBrush(cg.light(), Dense4Pattern);
128
 
            else
129
 
                fill = cg.brush(QColorGroup::Button);
130
 
 
131
 
            if (flags & Style_ButtonDefault && flags & Style_Down) {
132
 
                p->setPen(cg.dark());
133
 
                p->setBrush(fill);
134
 
                p->drawRect(r);
135
 
            } else if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
136
 
                qDrawWinButton(p, r, cg, flags & (Style_Sunken | Style_Down |
137
 
                                                  Style_On), &fill);
138
 
            else
139
 
                p->fillRect(r, fill);
140
 
            break;
141
 
        }
142
 
 
143
 
    case PE_ButtonBevel:
144
 
    case PE_HeaderSection:
145
 
        {
146
 
            QBrush fill;
147
 
 
148
 
            if (! (flags & Style_Down) && (flags & Style_On))
149
 
                fill = QBrush(cg.light(), Dense4Pattern);
150
 
            else
151
 
                fill = cg.brush(QColorGroup::Button);
152
 
 
153
 
            if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
154
 
                qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On), &fill);
155
 
            else
156
 
                p->fillRect(r, fill);
157
 
            break;
158
 
        }
159
 
 
160
 
    case PE_ButtonDefault:
161
 
        p->setPen(cg.shadow());
162
 
        p->drawRect(r);
163
 
        break;
164
 
 
165
 
    case PE_ButtonTool:
166
 
        {
167
 
            QBrush fill;
168
 
            bool stippled = FALSE;
169
 
 
170
 
            if (! (flags & (Style_Down | Style_MouseOver)) &&
171
 
                (flags & Style_On) &&
172
 
                use2000style) {
173
 
                fill = QBrush(cg.light(), Dense4Pattern);
174
 
                stippled = TRUE;
175
 
            } else
176
 
                fill = cg.brush(QColorGroup::Button);
177
 
 
178
 
            if (flags & (Style_Raised | Style_Down | Style_On)) {
179
 
                if (flags & Style_AutoRaise) {
180
 
                    qDrawShadePanel(p, r, cg, flags & (Style_Down | Style_On),
181
 
                                    1, &fill);
182
 
 
183
 
                    if (stippled) {
184
 
                        p->setPen(cg.button());
185
 
                        p->drawRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2);
186
 
                    }
187
 
                } else
188
 
                    qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On),
189
 
                                   &fill);
190
 
            } else
191
 
                p->fillRect(r, fill);
192
 
 
193
 
            break;
194
 
        }
195
 
 
196
 
    case PE_FocusRect:
197
 
        if (opt.isDefault())
198
 
            p->drawWinFocusRect(r);
199
 
        else
200
 
            p->drawWinFocusRect(r, opt.color());
201
 
        break;
202
 
 
203
 
    case PE_Indicator:
204
 
        {
205
 
#ifndef QT_NO_BUTTON
206
 
            QBrush fill;
207
 
            if (flags & Style_NoChange) {
208
 
                QBrush b = p->brush();
209
 
                QColor c = p->backgroundColor();
210
 
                p->setBackgroundMode( TransparentMode );
211
 
                p->setBackgroundColor( green );
212
 
                fill = QBrush(cg.base(), Dense4Pattern);
213
 
                p->setBackgroundColor( c );
214
 
                p->setBrush( b );
215
 
            } else if (flags & Style_Down)
216
 
                fill = cg.brush( QColorGroup::Button );
217
 
            else if (flags & Style_Enabled)
218
 
                fill = cg.brush( QColorGroup::Base );
219
 
            else
220
 
                fill = cg.brush( QColorGroup::Background );
221
 
 
222
 
            qDrawWinPanel( p, r, cg, TRUE, &fill );
223
 
            if (! (flags & Style_Off)) {
224
 
                QPointArray a( 7*2 );
225
 
                int i, xx, yy;
226
 
                xx = r.x() + 3;
227
 
                yy = r.y() + 5;
228
 
 
229
 
                for ( i=0; i<3; i++ ) {
230
 
                    a.setPoint( 2*i,   xx, yy );
231
 
                    a.setPoint( 2*i+1, xx, yy+2 );
232
 
                    xx++; yy++;
233
 
                }
234
 
 
235
 
                yy -= 2;
236
 
                for ( i=3; i<7; i++ ) {
237
 
                    a.setPoint( 2*i,   xx, yy );
238
 
                    a.setPoint( 2*i+1, xx, yy+2 );
239
 
                    xx++; yy--;
240
 
                }
241
 
 
242
 
                if (flags & Style_NoChange)
243
 
                    p->setPen( cg.dark() );
244
 
                else
245
 
                    p->setPen( cg.text() );
246
 
 
247
 
                p->drawLineSegments( a );
248
 
            }
249
 
#endif
250
 
            break;
251
 
        }
252
 
 
253
 
    case PE_ExclusiveIndicator:
254
 
        {
255
 
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
256
 
            static const QCOORD pts1[] = {              // dark lines
257
 
                1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
258
 
            static const QCOORD pts2[] = {              // black lines
259
 
                2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
260
 
            static const QCOORD pts3[] = {              // background lines
261
 
                2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
262
 
            static const QCOORD pts4[] = {              // white lines
263
 
                2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
264
 
                11,4, 10,3, 10,2 };
265
 
            static const QCOORD pts5[] = {              // inner fill
266
 
                4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
267
 
 
268
 
            // make sure the indicator is square
269
 
            QRect ir = r;
270
 
 
271
 
            if (r.width() < r.height()) {
272
 
                ir.setTop(r.top() + (r.height() - r.width()) / 2);
273
 
                ir.setHeight(r.width());
274
 
            } else if (r.height() < r.width()) {
275
 
                ir.setLeft(r.left() + (r.width() - r.height()) / 2);
276
 
                ir.setWidth(r.height());
277
 
            }
278
 
 
279
 
            p->eraseRect(ir);
280
 
            bool down = flags & Style_Down;
281
 
            bool enabled = flags & Style_Enabled;
282
 
            bool on = flags & Style_On;
283
 
            QPointArray a;
284
 
            a.setPoints( QCOORDARRLEN(pts1), pts1 );
285
 
            a.translate( ir.x(), ir.y() );
286
 
            p->setPen( cg.dark() );
287
 
            p->drawPolyline( a );
288
 
            a.setPoints( QCOORDARRLEN(pts2), pts2 );
289
 
            a.translate( ir.x(), ir.y() );
290
 
            p->setPen( cg.shadow() );
291
 
            p->drawPolyline( a );
292
 
            a.setPoints( QCOORDARRLEN(pts3), pts3 );
293
 
            a.translate( ir.x(), ir.y() );
294
 
            p->setPen( cg.midlight() );
295
 
            p->drawPolyline( a );
296
 
            a.setPoints( QCOORDARRLEN(pts4), pts4 );
297
 
            a.translate( ir.x(), ir.y() );
298
 
            p->setPen( cg.light() );
299
 
            p->drawPolyline( a );
300
 
            a.setPoints( QCOORDARRLEN(pts5), pts5 );
301
 
            a.translate( ir.x(), ir.y() );
302
 
            QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
303
 
            p->setPen( fillColor );
304
 
            p->setBrush( fillColor  ) ;
305
 
            p->drawPolygon( a );
306
 
            if ( on ) {
307
 
                p->setPen( NoPen );
308
 
                p->setBrush( cg.text() );
309
 
                p->drawRect( ir.x() + 5, ir.y() + 4, 2, 4 );
310
 
                p->drawRect( ir.x() + 4, ir.y() + 5, 4, 2 );
311
 
            }
312
 
            break;
313
 
        }
314
 
 
315
 
    case PE_Panel:
316
 
    case PE_PanelPopup:
317
 
        {
318
 
            int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
319
 
                        : opt.lineWidth();
320
 
 
321
 
            if (lw == 2)
322
 
                qDrawWinPanel(p, r, cg, flags & Style_Sunken);
323
 
            else
324
 
                QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
325
 
            break;
326
 
        }
327
 
 
328
 
    case PE_Splitter:
329
 
    case PE_DockWindowResizeHandle:
330
 
        qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), cg );
331
 
        break;
332
 
 
333
 
    case PE_ScrollBarSubLine:
334
 
        if (use2000style) {
335
 
            if (flags & Style_Down) {
336
 
                p->setPen( cg.dark() );
337
 
                p->setBrush( cg.brush( QColorGroup::Button ) );
338
 
                p->drawRect( r );
339
 
            } else
340
 
                drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
341
 
        } else
342
 
            drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
343
 
                          ((flags & Style_Down) ? Style_Down : Style_Raised));
344
 
 
345
 
        drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
346
 
                      p, r, cg, flags);
347
 
        break;
348
 
 
349
 
    case PE_ScrollBarAddLine:
350
 
        if (use2000style) {
351
 
            if (flags & Style_Down) {
352
 
                p->setPen( cg.dark() );
353
 
                p->setBrush( cg.brush( QColorGroup::Button ) );
354
 
                p->drawRect( r );
355
 
            } else
356
 
                drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
357
 
        } else
358
 
            drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
359
 
                          ((flags & Style_Down) ? Style_Down : Style_Raised));
360
 
 
361
 
        drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
362
 
                      p, r, cg, flags);
363
 
        break;
364
 
 
365
 
    case PE_ScrollBarAddPage:
366
 
    case PE_ScrollBarSubPage:
367
 
        {
368
 
            QBrush br;
369
 
            QColor c = p->backgroundColor();
370
 
 
371
 
            p->setPen(NoPen);
372
 
            p->setBackgroundMode(OpaqueMode);
373
 
 
374
 
            if (flags & Style_Down) {
375
 
                br = QBrush(cg.shadow(), Dense4Pattern);
376
 
                p->setBackgroundColor( cg.dark() );
377
 
                p->setBrush( QBrush(cg.shadow(), Dense4Pattern) );
378
 
            } else {
379
 
                br = (cg.brush(QColorGroup::Light).pixmap() ?
380
 
                      cg.brush(QColorGroup::Light) :
381
 
                      QBrush(cg.light(), Dense4Pattern));
382
 
                p->setBrush(br);
383
 
            }
384
 
 
385
 
            p->drawRect(r);
386
 
            p->setBackgroundColor(c);
387
 
            break;
388
 
        }
389
 
 
390
 
    case PE_ScrollBarSlider:
391
 
        if (! (flags & Style_Enabled)) {
392
 
            QBrush br = (cg.brush(QColorGroup::Light).pixmap() ?
393
 
                         cg.brush(QColorGroup::Light) :
394
 
                         QBrush(cg.light(), Dense4Pattern));
395
 
            p->setPen(NoPen);
396
 
            p->setBrush(br);
397
 
            p->setBackgroundMode(OpaqueMode);
398
 
            p->drawRect(r);
399
 
        } else
400
 
            drawPrimitive(PE_ButtonBevel, p, r, cg, Style_Enabled | Style_Raised);
401
 
        break;
402
 
 
403
 
    default:
404
 
        if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) {
405
 
            QPointArray a;
406
 
 
407
 
            switch ( pe ) {
408
 
            case PE_ArrowUp:
409
 
                a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
410
 
                break;
411
 
 
412
 
            case PE_ArrowDown:
413
 
                a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
414
 
                break;
415
 
 
416
 
            case PE_ArrowRight:
417
 
                a.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
418
 
                break;
419
 
 
420
 
            case PE_ArrowLeft:
421
 
                a.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
422
 
                break;
423
 
 
424
 
            default:
425
 
                break;
426
 
            }
427
 
 
428
 
            if (a.isNull())
429
 
                return;
430
 
 
431
 
            p->save();
432
 
            if ( flags & Style_Down )
433
 
                p->translate( pixelMetric( PM_ButtonShiftHorizontal ),
434
 
                              pixelMetric( PM_ButtonShiftVertical ) );
435
 
 
436
 
            if ( flags & Style_Enabled ) {
437
 
                a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
438
 
                p->setPen( cg.buttonText() );
439
 
                p->drawLineSegments( a, 0, 3 );         // draw arrow
440
 
                p->drawPoint( a[6] );
441
 
            } else {
442
 
                a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
443
 
                p->setPen( cg.light() );
444
 
                p->drawLineSegments( a, 0, 3 );         // draw arrow
445
 
                p->drawPoint( a[6] );
446
 
                a.translate( -1, -1 );
447
 
                p->setPen( cg.mid() );
448
 
                p->drawLineSegments( a, 0, 3 );         // draw arrow
449
 
                p->drawPoint( a[6] );
450
 
            }
451
 
            p->restore();
452
 
        } else
453
 
            QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
454
 
    }
455
 
}
456
 
 
457
 
 
458
 
/*!
459
 
  \reimp
460
 
*/
461
 
void QMuseWindowsStyle::drawControl( ControlElement element,
462
 
                                 QPainter *p,
463
 
                                 const QWidget *widget,
464
 
                                 const QRect &r,
465
 
                                 const QColorGroup &cg,
466
 
                                 SFlags flags,
467
 
                                 const QStyleOption& opt ) const
468
 
{
469
 
    switch (element) {
470
 
#ifndef QT_NO_TABBAR
471
 
    case CE_TabBarTab:
472
 
        {
473
 
            if ( !widget || !widget->parentWidget() || !opt.tab() )
474
 
                break;
475
 
 
476
 
            const QTabBar * tb = (const QTabBar *) widget;
477
 
            const QTab * t = opt.tab();
478
 
            bool selected = flags & Style_Selected;
479
 
            bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ?
480
 
                           TRUE : FALSE;
481
 
            QRect r2( r );
482
 
            if ( tb->shape()  == QTabBar::RoundedAbove ) {
483
 
                p->setPen( cg.midlight() );
484
 
 
485
 
                p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
486
 
                p->setPen( cg.light() );
487
 
                p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
488
 
                if ( r2.left() == 0 )
489
 
                    p->drawPoint( tb->rect().bottomLeft() );
490
 
 
491
 
                if ( selected ) {
492
 
                    p->fillRect( QRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2),
493
 
                                 cg.brush( QColorGroup::Background ));
494
 
                    p->setPen( cg.background() );
495
 
                    p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
496
 
                    p->setPen( cg.light() );
497
 
                } else {
498
 
                    p->setPen( cg.light() );
499
 
                    r2.setRect( r2.left() + 2, r2.top() + 2,
500
 
                               r2.width() - 4, r2.height() - 2 );
501
 
                }
502
 
 
503
 
                int x1, x2;
504
 
                x1 = r2.left();
505
 
                x2 = r2.right() - 2;
506
 
                p->drawLine( x1, r2.bottom()-1, x1, r2.top() + 2 );
507
 
                x1++;
508
 
                p->drawPoint( x1, r2.top() + 1 );
509
 
                x1++;
510
 
                p->drawLine( x1, r2.top(), x2, r2.top() );
511
 
                if ( r2.left() > 0 ) {
512
 
                    p->setPen( cg.midlight() );
513
 
                }
514
 
                x1 = r2.left();
515
 
                p->drawPoint( x1, r2.bottom());
516
 
 
517
 
                p->setPen( cg.midlight() );
518
 
                x1++;
519
 
                p->drawLine( x1, r2.bottom(), x1, r2.top() + 2 );
520
 
                x1++;
521
 
                p->drawLine( x1, r2.top()+1, x2, r2.top()+1 );
522
 
 
523
 
                p->setPen( cg.dark() );
524
 
                x2 = r2.right() - 1;
525
 
                p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
526
 
                             (selected ? 1:-1) );
527
 
                p->setPen( cg.shadow() );
528
 
                p->drawPoint( x2, r2.top() + 1 );
529
 
                p->drawPoint( x2, r2.top() + 1 );
530
 
                x2++;
531
 
                p->drawLine( x2, r2.top() + 2, x2, r2.bottom() -
532
 
                             (selected ? (lastTab ? 0:1) :2));
533
 
            } else if ( tb->shape() == QTabBar::RoundedBelow ) {
534
 
                bool rightAligned = styleHint( SH_TabBar_Alignment, tb ) == AlignRight;
535
 
                bool firstTab = tb->indexOf( t->identifier() ) == 0;
536
 
                if ( selected ) {
537
 
                    p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-3, 1),
538
 
                                 tb->palette().active().brush( QColorGroup::Background ));
539
 
                    p->setPen( cg.background() );
540
 
                    p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
541
 
                    p->setPen( cg.dark() );
542
 
                } else {
543
 
                    p->setPen( cg.shadow() );
544
 
                    p->drawLine( r2.left() +
545
 
                                 (rightAligned && firstTab ? 0 : 1),
546
 
                                 r2.top() + 1,
547
 
                                 r2.right() - (lastTab ? 0 : 2),
548
 
                                 r2.top() + 1 );
549
 
                
550
 
                    if ( rightAligned && lastTab )
551
 
                        p->drawPoint( r2.right(), r2.top() );
552
 
                    p->setPen( cg.dark() );
553
 
                    p->drawLine( r2.left(), r2.top(), r2.right() - 1,
554
 
                                 r2.top() );
555
 
                    r2.setRect( r2.left() + 2, r2.top(),
556
 
                                r2.width() - 4, r2.height() - 2 );
557
 
                }
558
 
 
559
 
                p->drawLine( r2.right() - 1, r2.top() + (selected ? 0: 2),
560
 
                             r2.right() - 1, r2.bottom() - 2 );
561
 
                p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
562
 
                p->drawLine( r2.right() - 2, r2.bottom() - 1,
563
 
                             r2.left() + 1, r2.bottom() - 1 );
564
 
 
565
 
                p->setPen( cg.midlight() );
566
 
                p->drawLine( r2.left() + 1, r2.bottom() - 2,
567
 
                             r2.left() + 1, r2.top() + (selected ? 0 : 2) );
568
 
 
569
 
                p->setPen( cg.shadow() );
570
 
                p->drawLine( r2.right(),
571
 
                             r2.top() + (lastTab && rightAligned &&
572
 
                                         selected) ? 0 : 1,
573
 
                             r2.right(), r2.bottom() - 1 );
574
 
                p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
575
 
                p->drawLine( r2.right() - 1, r2.bottom(),
576
 
                             r2.left() + 2, r2.bottom() );
577
 
 
578
 
                p->setPen( cg.light() );
579
 
                p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
580
 
                             r2.left(), r2.bottom() - 2 );
581
 
            } else {
582
 
                QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
583
 
            }
584
 
            break;
585
 
        }
586
 
#endif // QT_NO_TABBAR
587
 
 
588
 
#ifndef QT_NO_POPUPMENU
589
 
    case CE_PopupMenuItem:
590
 
        {
591
 
            if (! widget || opt.isDefault())
592
 
                break;
593
 
 
594
 
            const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
595
 
            QMenuItem *mi = opt.menuItem();
596
 
            if ( !mi )
597
 
                break;
598
 
 
599
 
            int tab = opt.tabWidth();
600
 
            int maxpmw = opt.maxIconWidth();
601
 
            bool dis = ! mi->isEnabled();
602
 
            bool checkable = popupmenu->isCheckable();
603
 
            bool act = flags & Style_Active;
604
 
            int x, y, w, h;
605
 
 
606
 
            r.rect(&x, &y, &w, &h);
607
 
 
608
 
            if ( checkable ) {
609
 
                // space for the checkmarks
610
 
                if (use2000style)
611
 
                    maxpmw = QMAX( maxpmw, 20 );
612
 
                else
613
 
                    maxpmw = QMAX( maxpmw, 12 );
614
 
            }
615
 
 
616
 
            int checkcol = maxpmw;
617
 
 
618
 
            if ( mi && mi->isSeparator() ) {                    // draw separator
619
 
                p->setPen( cg.dark() );
620
 
                p->drawLine( x, y, x+w, y );
621
 
                p->setPen( cg.light() );
622
 
                p->drawLine( x, y+1, x+w, y+1 );
623
 
                return;
624
 
            }
625
 
 
626
 
            QBrush fill = (act ?
627
 
                           cg.brush( QColorGroup::Highlight ) :
628
 
                           cg.brush( QColorGroup::Button ));
629
 
            p->fillRect( x, y, w, h, fill);
630
 
 
631
 
            if ( !mi )
632
 
                return;
633
 
 
634
 
            int xpos = x;
635
 
            QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r );
636
 
            int xvis = vrect.x();
637
 
            if ( mi->isChecked() ) {
638
 
                if ( act && !dis )
639
 
                    qDrawShadePanel( p, xvis, y, checkcol, h,
640
 
                                     cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
641
 
                else {
642
 
                    QBrush fill( cg.light(), Dense4Pattern );
643
 
                    // set the brush origin for the hash pattern to the x/y coordinate
644
 
                    // of the menu item's checkmark... this way, the check marks have
645
 
                    // a consistent look
646
 
                    QPoint origin = p->brushOrigin();
647
 
                    p->setBrushOrigin( xvis, y );
648
 
                    qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1,
649
 
                                     &fill );
650
 
                    // restore the previous brush origin
651
 
                    p->setBrushOrigin( origin );
652
 
                }
653
 
            } else if (! act)
654
 
                p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button ));
655
 
 
656
 
            if ( mi->iconSet() ) {              // draw iconset
657
 
                QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
658
 
                if (act && !dis )
659
 
                    mode = QIconSet::Active;
660
 
                QPixmap pixmap;
661
 
                if ( checkable && mi->isChecked() )
662
 
                    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
663
 
                else
664
 
                    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
665
 
                int pixw = pixmap.width();
666
 
                int pixh = pixmap.height();
667
 
                if ( act && !dis && !mi->isChecked() )
668
 
                    qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1,
669
 
                                     &cg.brush( QColorGroup::Button ) );
670
 
                QRect pmr( 0, 0, pixw, pixh );
671
 
                pmr.moveCenter( vrect.center() );
672
 
                p->setPen( cg.text() );
673
 
                p->drawPixmap( pmr.topLeft(), pixmap );
674
 
 
675
 
                fill = (act ?
676
 
                        cg.brush( QColorGroup::Highlight ) :
677
 
                        cg.brush( QColorGroup::Button ));
678
 
                int xp = xpos + checkcol + 1;
679
 
                p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill);
680
 
            } else  if ( checkable ) {  // just "checking"...
681
 
                if ( mi->isChecked() ) {
682
 
                    int xp = xpos + windowsItemFrame;
683
 
 
684
 
                    SFlags cflags = Style_Default;
685
 
                    if (! dis)
686
 
                        cflags |= Style_Enabled;
687
 
                    if (act)
688
 
                        cflags |= Style_On;
689
 
 
690
 
                    drawPrimitive(PE_CheckMark, p,
691
 
                                  visualRect( QRect(xp, y + windowsItemFrame,
692
 
                                        checkcol - 2*windowsItemFrame,
693
 
                                        h - 2*windowsItemFrame), r ), cg, cflags);
694
 
                }
695
 
            }
696
 
 
697
 
            p->setPen( act ? cg.highlightedText() : cg.buttonText() );
698
 
 
699
 
            QColor discol;
700
 
            if ( dis ) {
701
 
                discol = cg.text();
702
 
                p->setPen( discol );
703
 
            }
704
 
 
705
 
            int xm = windowsItemFrame + checkcol + windowsItemHMargin;
706
 
            xpos += xm;
707
 
 
708
 
            vrect = visualRect( QRect( xpos, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin ), r );
709
 
            xvis = vrect.x();
710
 
            if ( mi->custom() ) {
711
 
                p->save();
712
 
                if ( dis && !act ) {
713
 
                    p->setPen( cg.light() );
714
 
                    mi->custom()->paint( p, cg, act, !dis,
715
 
                                         xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin );
716
 
                    p->setPen( discol );
717
 
                }
718
 
                mi->custom()->paint( p, cg, act, !dis,
719
 
                                     xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin );
720
 
                p->restore();
721
 
            }
722
 
            QString s = mi->text();
723
 
            if ( !s.isNull() ) {                        // draw text
724
 
                int t = s.find( '\t' );
725
 
                int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
726
 
                text_flags |= (QApplication::reverseLayout() ? AlignRight : AlignLeft );
727
 
                if ( t >= 0 ) {                         // draw tab text
728
 
                    int xp;
729
 
                    xp = x + w - tab - ((use2000style) ? 20 : windowsRightBorder) -
730
 
                         windowsItemHMargin - windowsItemFrame + 1;
731
 
                    int xoff = visualRect( QRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
732
 
                    if ( dis && !act ) {
733
 
                        p->setPen( cg.light() );
734
 
                        p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
735
 
                        p->setPen( discol );
736
 
                    }
737
 
                    p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
738
 
                    s = s.left( t );
739
 
                }
740
 
                if ( dis && !act ) {
741
 
                    p->setPen( cg.light() );
742
 
                    p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
743
 
                    p->setPen( discol );
744
 
                }
745
 
                p->drawText( xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
746
 
            } else if ( mi->pixmap() ) {                        // draw pixmap
747
 
                QPixmap *pixmap = mi->pixmap();
748
 
                if ( pixmap->depth() == 1 )
749
 
                    p->setBackgroundMode( OpaqueMode );
750
 
                p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
751
 
                if ( pixmap->depth() == 1 )
752
 
                    p->setBackgroundMode( TransparentMode );
753
 
            }
754
 
            if ( mi->popup() ) {                        // draw sub menu arrow
755
 
                int dim = (h-2*windowsItemFrame) / 2;
756
 
                PrimitiveElement arrow;
757
 
                arrow = ( QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
758
 
                xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
759
 
                vrect = visualRect( QRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
760
 
                if ( act ) {
761
 
                    if ( !dis )
762
 
                        discol = white;
763
 
                    QColorGroup g2( discol, cg.highlight(),
764
 
                                    white, white,
765
 
                                    dis ? discol : white,
766
 
                                    discol, white );
767
 
 
768
 
                    drawPrimitive(arrow, p, vrect,
769
 
                                  g2, Style_Enabled);
770
 
                } else {
771
 
                    drawPrimitive(arrow, p, vrect,
772
 
                                  cg, mi->isEnabled() ? Style_Enabled : Style_Default);
773
 
                }
774
 
            }
775
 
 
776
 
            break;
777
 
        }
778
 
#endif
779
 
 
780
 
    case CE_MenuBarItem:
781
 
        {
782
 
            bool active = flags & Style_Active;
783
 
            bool hasFocus = flags & Style_HasFocus;
784
 
            bool down = flags & Style_Down;
785
 
            QRect pr = r;
786
 
 
787
 
            p->fillRect( r, cg.brush( QColorGroup::Button ) );
788
 
            if ( active || hasFocus ) {
789
 
                QBrush b = cg.brush( QColorGroup::Button );
790
 
                if ( active && down )
791
 
                    p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
792
 
                if ( active && hasFocus )
793
 
                    qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(),
794
 
                                    cg, active && down, 1, 0, &b );
795
 
                if ( active && down ) {
796
 
                    pr.setRect( r.x() + 2 + pixelMetric(PM_ButtonShiftHorizontal,
797
 
                                                        widget),
798
 
                                r.y() + 2 + pixelMetric(PM_ButtonShiftVertical,
799
 
                                                        widget),
800
 
                                r.width()-4, r.height()-4 );
801
 
                    p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
802
 
                }
803
 
            }
804
 
            QCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt);
805
 
            break;
806
 
        }
807
 
 
808
 
    default:
809
 
        QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
810
 
    }
811
 
}
812
 
 
813
 
 
814
 
/*!
815
 
  \reimp
816
 
*/
817
 
int QMuseWindowsStyle::pixelMetric(PixelMetric metric, const QWidget *widget) const
818
 
{
819
 
    int ret;
820
 
 
821
 
    switch (metric) {
822
 
    case PM_ButtonDefaultIndicator:
823
 
    case PM_ButtonShiftHorizontal:
824
 
    case PM_ButtonShiftVertical:
825
 
        ret = 1;
826
 
        break;
827
 
 
828
 
    case PM_MaximumDragDistance:
829
 
        ret = 20;
830
 
        break;
831
 
 
832
 
#ifndef QT_NO_SLIDER
833
 
    case PM_SliderLength:
834
 
        ret = 11;
835
 
        break;
836
 
 
837
 
        // Returns the number of pixels to use for the business part of the
838
 
        // slider (i.e., the non-tickmark portion). The remaining space is shared
839
 
        // equally between the tickmark regions.
840
 
    case PM_SliderControlThickness:
841
 
        {
842
 
            const QSlider * sl = (const QSlider *) widget;
843
 
            int space = (sl->orientation() == Horizontal) ? sl->height()
844
 
                        : sl->width();
845
 
            int ticks = sl->tickmarks();
846
 
            int n = 0;
847
 
            if ( ticks & QSlider::Above ) n++;
848
 
            if ( ticks & QSlider::Below ) n++;
849
 
            if ( !n ) {
850
 
                ret = space;
851
 
                break;
852
 
            }
853
 
 
854
 
            int thick = 6;      // Magic constant to get 5 + 16 + 5
855
 
            if ( ticks != QSlider::Both && ticks != QSlider::NoMarks )
856
 
                thick += pixelMetric( PM_SliderLength, sl ) / 4;
857
 
 
858
 
            space -= thick;
859
 
            //### the two sides may be unequal in size
860
 
            if ( space > 0 )
861
 
                thick += (space * 2) / (n + 2);
862
 
            ret = thick;
863
 
            break;
864
 
        }
865
 
#endif // QT_NO_SLIDER
866
 
 
867
 
    case PM_MenuBarFrameWidth:
868
 
        ret = 0;
869
 
        break;
870
 
 
871
 
#if defined(Q_WS_WIN)
872
 
    case PM_TitleBarHeight:
873
 
        if ( widget && ( widget->testWFlags( WStyle_Tool ) || widget->inherits( "QDockWindow" ) ) ) {
874
 
            ret = GetSystemMetrics( SM_CYSMCAPTION );
875
 
        } else {
876
 
            ret = GetSystemMetrics( SM_CYCAPTION );
877
 
        }
878
 
        break;
879
 
#endif
880
 
 
881
 
    case PM_SplitterWidth:
882
 
        ret = QMAX( 6, QApplication::globalStrut().width() );
883
 
        break;
884
 
 
885
 
    default:
886
 
        ret = QCommonStyle::pixelMetric(metric, widget);
887
 
        break;
888
 
    }
889
 
 
890
 
    return ret;
891
 
}
892
 
 
893
 
 
894
 
/*!
895
 
  \reimp
896
 
*/
897
 
QSize QMuseWindowsStyle::sizeFromContents( ContentsType contents,
898
 
                                       const QWidget *widget,
899
 
                                       const QSize &contentsSize,
900
 
                                       const QStyleOption& opt ) const
901
 
{
902
 
    QSize sz(contentsSize);
903
 
 
904
 
    switch (contents) {
905
 
    case CT_PushButton:
906
 
        {
907
 
#ifndef QT_NO_PUSHBUTTON
908
 
            const QPushButton *button = (const QPushButton *) widget;
909
 
            sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
910
 
            int w = sz.width(), h = sz.height();
911
 
 
912
 
            int defwidth = 0;
913
 
            if (button->isDefault() || button->autoDefault())
914
 
                defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, widget );
915
 
 
916
 
            if (w < 80+defwidth && !button->pixmap())
917
 
                w = 80+defwidth;
918
 
            if (h < 23+defwidth)
919
 
                h = 23+defwidth;
920
 
 
921
 
            sz = QSize(w, h);
922
 
#endif
923
 
            break;
924
 
        }
925
 
 
926
 
    case CT_PopupMenuItem:
927
 
        {
928
 
#ifndef QT_NO_POPUPMENU
929
 
            if (! widget || opt.isDefault())
930
 
                break;
931
 
 
932
 
            const QPopupMenu *popup = (const QPopupMenu *) widget;
933
 
            bool checkable = popup->isCheckable();
934
 
            QMenuItem *mi = opt.menuItem();
935
 
            int maxpmw = opt.maxIconWidth();
936
 
            int w = sz.width(), h = sz.height();
937
 
 
938
 
            if (mi->custom()) {
939
 
                w = mi->custom()->sizeHint().width();
940
 
                h = mi->custom()->sizeHint().height();
941
 
                if (! mi->custom()->fullSpan())
942
 
                    h += 2*windowsItemVMargin + 2*windowsItemFrame;
943
 
            } else if ( mi->widget() ) {
944
 
            } else if (mi->isSeparator()) {
945
 
                w = 10; // arbitrary
946
 
                h = windowsSepHeight;
947
 
            } else {
948
 
                if (mi->pixmap())
949
 
                    h = QMAX(h, mi->pixmap()->height() + 2*windowsItemFrame);
950
 
                else if (! mi->text().isNull())
951
 
                    h = QMAX(h, popup->fontMetrics().height() + 2*windowsItemVMargin +
952
 
                             2*windowsItemFrame);
953
 
 
954
 
                if (mi->iconSet() != 0)
955
 
                    h = QMAX(h, mi->iconSet()->pixmap(QIconSet::Small,
956
 
                                                      QIconSet::Normal).height() +
957
 
                             2*windowsItemFrame);
958
 
            }
959
 
 
960
 
            if (! mi->text().isNull() && mi->text().find('\t') >= 0)
961
 
                w += windowsTabSpacing;
962
 
            else if (mi->popup())
963
 
                w += 2*windowsArrowHMargin;
964
 
 
965
 
            if (use2000style) {
966
 
                if (checkable && maxpmw < 20)
967
 
                    w += 20 - maxpmw;
968
 
            } else {
969
 
                if (checkable && maxpmw < windowsCheckMarkWidth)
970
 
                    w += windowsCheckMarkWidth - maxpmw;
971
 
            }
972
 
            if (maxpmw)
973
 
                w += maxpmw + 6;
974
 
            if (checkable || maxpmw > 0)
975
 
                w += windowsCheckMarkHMargin;
976
 
            if (use2000style)
977
 
                w += 20;
978
 
            else
979
 
                w += windowsRightBorder;
980
 
 
981
 
            sz = QSize(w, h);
982
 
#endif
983
 
            break;
984
 
        }
985
 
 
986
 
    default:
987
 
        sz = QCommonStyle::sizeFromContents(contents, widget, sz, opt);
988
 
        break;
989
 
    }
990
 
 
991
 
    return sz;
992
 
}
993
 
 
994
 
/*! \reimp
995
 
*/
996
 
void QMuseWindowsStyle::polishPopupMenu( QPopupMenu* p)
997
 
{
998
 
#ifndef QT_NO_POPUPMENU
999
 
    if ( !p->testWState( WState_Polished ) )
1000
 
        p->setCheckable( TRUE );
1001
 
#endif
1002
 
}
1003
 
 
1004
 
#ifndef QT_NO_IMAGEIO_XPM
1005
 
static const char * const qt_close_xpm[] = {
1006
 
"12 12 2 1",
1007
 
"# c #000000",
1008
 
". c None",
1009
 
"............",
1010
 
"............",
1011
 
"..##....##..",
1012
 
"...##..##...",
1013
 
"....####....",
1014
 
".....##.....",
1015
 
"....####....",
1016
 
"...##..##...",
1017
 
"..##....##..",
1018
 
"............",
1019
 
"............",
1020
 
"............"};
1021
 
 
1022
 
static const char * const qt_maximize_xpm[]={
1023
 
"12 12 2 1",
1024
 
"# c #000000",
1025
 
". c None",
1026
 
"............",
1027
 
"............",
1028
 
".##########.",
1029
 
".##########.",
1030
 
".#........#.",
1031
 
".#........#.",
1032
 
".#........#.",
1033
 
".#........#.",
1034
 
".#........#.",
1035
 
".#........#.",
1036
 
".##########.",
1037
 
"............"};
1038
 
 
1039
 
 
1040
 
static const char * const qt_minimize_xpm[] = {
1041
 
"12 12 2 1",
1042
 
"# c #000000",
1043
 
". c None",
1044
 
"............",
1045
 
"............",
1046
 
"............",
1047
 
"............",
1048
 
"............",
1049
 
"............",
1050
 
"............",
1051
 
"...######...",
1052
 
"...######...",
1053
 
"............",
1054
 
"............",
1055
 
"............"};
1056
 
 
1057
 
#if 0 // ### not used???
1058
 
static const char * const qt_normalize_xpm[] = {
1059
 
"12 12 2 1",
1060
 
"# c #000000",
1061
 
". c None",
1062
 
"............",
1063
 
"...#######..",
1064
 
"...#######..",
1065
 
"...#.....#..",
1066
 
".#######.#..",
1067
 
".#######.#..",
1068
 
".#.....#.#..",
1069
 
".#.....###..",
1070
 
".#.....#....",
1071
 
".#.....#....",
1072
 
".#######....",
1073
 
"............"};
1074
 
#endif
1075
 
 
1076
 
static const char * const qt_normalizeup_xpm[] = {
1077
 
"12 12 2 1",
1078
 
"# c #000000",
1079
 
". c None",
1080
 
"............",
1081
 
"...#######..",
1082
 
"...#######..",
1083
 
"...#.....#..",
1084
 
".#######.#..",
1085
 
".#######.#..",
1086
 
".#.....#.#..",
1087
 
".#.....###..",
1088
 
".#.....#....",
1089
 
".#.....#....",
1090
 
".#######....",
1091
 
"............"};
1092
 
 
1093
 
 
1094
 
static const char * const qt_shade_xpm[] = {
1095
 
"12 12 2 1",
1096
 
"# c #000000",
1097
 
". c None",
1098
 
"............",
1099
 
"............",
1100
 
"............",
1101
 
"............",
1102
 
"............",
1103
 
".....#......",
1104
 
"....###.....",
1105
 
"...#####....",
1106
 
"..#######...",
1107
 
"............",
1108
 
"............",
1109
 
"............"};
1110
 
 
1111
 
static const char * const qt_unshade_xpm[] = {
1112
 
"12 12 2 1",
1113
 
"# c #000000",
1114
 
". c None",
1115
 
"............",
1116
 
"............",
1117
 
"............",
1118
 
"............",
1119
 
"..#######...",
1120
 
"...#####....",
1121
 
"....###.....",
1122
 
".....#......",
1123
 
"............",
1124
 
"............",
1125
 
"............",
1126
 
"............"};
1127
 
 
1128
 
static const char * dock_window_close_xpm[] = {
1129
 
"8 8 2 1",
1130
 
"# c #000000",
1131
 
". c None",
1132
 
"##....##",
1133
 
".##..##.",
1134
 
"..####..",
1135
 
"...##...",
1136
 
"..####..",
1137
 
".##..##.",
1138
 
"##....##",
1139
 
"........"};
1140
 
 
1141
 
// Message box icons, from page 210 of the Windows style guide.
1142
 
 
1143
 
// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape
1144
 
// palette.  The "question mark" icon, which Microsoft recommends not
1145
 
// using but a lot of people still use, is left out.
1146
 
 
1147
 
/* XPM */
1148
 
static const char * const information_xpm[]={
1149
 
"32 32 5 1",
1150
 
". c None",
1151
 
"c c #000000",
1152
 
"* c #999999",
1153
 
"a c #ffffff",
1154
 
"b c #0000ff",
1155
 
"...........********.............",
1156
 
"........***aaaaaaaa***..........",
1157
 
"......**aaaaaaaaaaaaaa**........",
1158
 
".....*aaaaaaaaaaaaaaaaaa*.......",
1159
 
"....*aaaaaaaabbbbaaaaaaaac......",
1160
 
"...*aaaaaaaabbbbbbaaaaaaaac.....",
1161
 
"..*aaaaaaaaabbbbbbaaaaaaaaac....",
1162
 
".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
1163
 
".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
1164
 
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
1165
 
"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
1166
 
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1167
 
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1168
 
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1169
 
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1170
 
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1171
 
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1172
 
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1173
 
"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
1174
 
"...caaaaaaabbbbbbbbbaaaaaac****.",
1175
 
"....caaaaaaaaaaaaaaaaaaaac****..",
1176
 
".....caaaaaaaaaaaaaaaaaac****...",
1177
 
"......ccaaaaaaaaaaaaaacc****....",
1178
 
".......*cccaaaaaaaaccc*****.....",
1179
 
"........***cccaaaac*******......",
1180
 
"..........****caaac*****........",
1181
 
".............*caaac**...........",
1182
 
"...............caac**...........",
1183
 
"................cac**...........",
1184
 
".................cc**...........",
1185
 
"..................***...........",
1186
 
"...................**..........."};
1187
 
/* XPM */
1188
 
static const char* const warning_xpm[]={
1189
 
"32 32 4 1",
1190
 
". c None",
1191
 
"a c #ffff00",
1192
 
"* c #000000",
1193
 
"b c #999999",
1194
 
".............***................",
1195
 
"............*aaa*...............",
1196
 
"...........*aaaaa*b.............",
1197
 
"...........*aaaaa*bb............",
1198
 
"..........*aaaaaaa*bb...........",
1199
 
"..........*aaaaaaa*bb...........",
1200
 
".........*aaaaaaaaa*bb..........",
1201
 
".........*aaaaaaaaa*bb..........",
1202
 
"........*aaaaaaaaaaa*bb.........",
1203
 
"........*aaaa***aaaa*bb.........",
1204
 
".......*aaaa*****aaaa*bb........",
1205
 
".......*aaaa*****aaaa*bb........",
1206
 
"......*aaaaa*****aaaaa*bb.......",
1207
 
"......*aaaaa*****aaaaa*bb.......",
1208
 
".....*aaaaaa*****aaaaaa*bb......",
1209
 
".....*aaaaaa*****aaaaaa*bb......",
1210
 
"....*aaaaaaaa***aaaaaaaa*bb.....",
1211
 
"....*aaaaaaaa***aaaaaaaa*bb.....",
1212
 
"...*aaaaaaaaa***aaaaaaaaa*bb....",
1213
 
"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
1214
 
"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
1215
 
"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
1216
 
".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
1217
 
".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
1218
 
"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
1219
 
"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
1220
 
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1221
 
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1222
 
".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
1223
 
"..*************************bbbbb",
1224
 
"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
1225
 
".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
1226
 
/* XPM */
1227
 
static const char* const critical_xpm[]={
1228
 
"32 32 4 1",
1229
 
". c None",
1230
 
"a c #999999",
1231
 
"* c #ff0000",
1232
 
"b c #ffffff",
1233
 
"...........********.............",
1234
 
".........************...........",
1235
 
".......****************.........",
1236
 
"......******************........",
1237
 
".....********************a......",
1238
 
"....**********************a.....",
1239
 
"...************************a....",
1240
 
"..*******b**********b*******a...",
1241
 
"..******bbb********bbb******a...",
1242
 
".******bbbbb******bbbbb******a..",
1243
 
".*******bbbbb****bbbbb*******a..",
1244
 
"*********bbbbb**bbbbb*********a.",
1245
 
"**********bbbbbbbbbb**********a.",
1246
 
"***********bbbbbbbb***********aa",
1247
 
"************bbbbbb************aa",
1248
 
"************bbbbbb************aa",
1249
 
"***********bbbbbbbb***********aa",
1250
 
"**********bbbbbbbbbb**********aa",
1251
 
"*********bbbbb**bbbbb*********aa",
1252
 
".*******bbbbb****bbbbb*******aa.",
1253
 
".******bbbbb******bbbbb******aa.",
1254
 
"..******bbb********bbb******aaa.",
1255
 
"..*******b**********b*******aa..",
1256
 
"...************************aaa..",
1257
 
"....**********************aaa...",
1258
 
"....a********************aaa....",
1259
 
".....a******************aaa.....",
1260
 
"......a****************aaa......",
1261
 
".......aa************aaaa.......",
1262
 
".........aa********aaaaa........",
1263
 
"...........aaaaaaaaaaa..........",
1264
 
".............aaaaaaa............"};
1265
 
 
1266
 
#endif //QT_NO_IMAGEIO_XPM
1267
 
 
1268
 
/*!
1269
 
 \reimp
1270
 
 */
1271
 
QPixmap QMuseWindowsStyle::stylePixmap(StylePixmap stylepixmap,
1272
 
                                   const QWidget *widget,
1273
 
                                   const QStyleOption& opt) const
1274
 
{
1275
 
#ifndef QT_NO_IMAGEIO_XPM
1276
 
    switch (stylepixmap) {
1277
 
    case SP_TitleBarShadeButton:
1278
 
        return QPixmap((const char **)qt_shade_xpm);
1279
 
    case SP_TitleBarUnshadeButton:
1280
 
        return QPixmap((const char **)qt_unshade_xpm);
1281
 
    case SP_TitleBarNormalButton:
1282
 
        return QPixmap((const char **)qt_normalizeup_xpm);
1283
 
    case SP_TitleBarMinButton:
1284
 
        return QPixmap((const char **)qt_minimize_xpm);
1285
 
    case SP_TitleBarMaxButton:
1286
 
        return QPixmap((const char **)qt_maximize_xpm);
1287
 
    case SP_TitleBarCloseButton:
1288
 
        return QPixmap((const char **)qt_close_xpm);
1289
 
    case SP_DockWindowCloseButton:
1290
 
        return QPixmap((const char **)dock_window_close_xpm );
1291
 
    case SP_MessageBoxInformation:
1292
 
        return QPixmap((const char **)information_xpm);
1293
 
    case SP_MessageBoxWarning:
1294
 
        return QPixmap((const char **)warning_xpm);
1295
 
    case SP_MessageBoxCritical:
1296
 
        return QPixmap((const char **)critical_xpm);
1297
 
    default:
1298
 
        break;
1299
 
    }
1300
 
#endif //QT_NO_IMAGEIO_XPM
1301
 
    return QCommonStyle::stylePixmap(stylepixmap, widget, opt);
1302
 
}
1303
 
 
1304
 
/*!\reimp
1305
 
*/
1306
 
void QMuseWindowsStyle::drawComplexControl( ComplexControl ctrl, QPainter *p,
1307
 
                                        const QWidget *widget,
1308
 
                                        const QRect &r,
1309
 
                                        const QColorGroup &cg,
1310
 
                                        SFlags flags,
1311
 
                                        SCFlags sub,
1312
 
                                        SCFlags subActive,
1313
 
                                        const QStyleOption& opt ) const
1314
 
{
1315
 
    switch (ctrl) {
1316
 
#ifndef QT_NO_LISTVIEW
1317
 
    case CC_ListView:
1318
 
        {
1319
 
            if ( sub & SC_ListView ) {
1320
 
                QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, subActive, opt );
1321
 
            }
1322
 
            if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
1323
 
                if (opt.isDefault())
1324
 
                    break;
1325
 
 
1326
 
                QListViewItem *item = opt.listViewItem(),
1327
 
                             *child = item->firstChild();
1328
 
 
1329
 
                int y = r.y();
1330
 
                int c;
1331
 
                int dotoffset;
1332
 
                QPointArray dotlines;
1333
 
                if ( subActive == SC_All && sub == SC_ListViewExpand ) {
1334
 
                    c = 2;
1335
 
                    dotlines.resize(2);
1336
 
                    dotlines[0] = QPoint( r.right(), r.top() );
1337
 
                    dotlines[1] = QPoint( r.right(), r.bottom() );
1338
 
                } else {
1339
 
                    int linetop = 0, linebot = 0;
1340
 
                    // each branch needs at most two lines, ie. four end points
1341
 
                    dotoffset = (item->itemPos() + item->height() - y) %2;
1342
 
                    dotlines.resize( item->childCount() * 4 );
1343
 
                    c = 0;
1344
 
 
1345
 
                    // skip the stuff above the exposed rectangle
1346
 
                    while ( child && y + child->height() <= 0 ) {
1347
 
                        y += child->totalHeight();
1348
 
                        child = child->nextSibling();
1349
 
                    }
1350
 
 
1351
 
                    int bx = r.width() / 2;
1352
 
 
1353
 
                    // paint stuff in the magical area
1354
 
                    QListView* v = item->listView();
1355
 
                    int lh;
1356
 
                    if ( !item->multiLinesEnabled() )
1357
 
                        lh = child ? child->height() : 0;
1358
 
                    else
1359
 
                        lh = p->fontMetrics().height() + 2 * v->itemMargin();
1360
 
                    lh = QMAX( lh, QApplication::globalStrut().height() );
1361
 
                    if ( lh % 2 > 0 )
1362
 
                        lh++;
1363
 
                    while ( child && y < r.height() ) {
1364
 
                        linebot = y + lh/2;
1365
 
                        if ( (child->isExpandable() || child->childCount()) &&
1366
 
                             (child->height() > 0) ) {
1367
 
                            // needs a box
1368
 
                            p->setPen( cg.mid() );
1369
 
                            p->drawRect( bx-4, linebot-4, 9, 9 );
1370
 
                            // plus or minus
1371
 
                            p->setPen( cg.text() );
1372
 
                            p->drawLine( bx - 2, linebot, bx + 2, linebot );
1373
 
                            if ( !child->isOpen() )
1374
 
                                p->drawLine( bx, linebot - 2, bx, linebot + 2 );
1375
 
                            // dotlinery
1376
 
                            p->setPen( cg.mid() );
1377
 
                            dotlines[c++] = QPoint( bx, linetop );
1378
 
                            dotlines[c++] = QPoint( bx, linebot - 4 );
1379
 
                            dotlines[c++] = QPoint( bx + 5, linebot );
1380
 
                            dotlines[c++] = QPoint( r.width(), linebot );
1381
 
                            linetop = linebot + 5;
1382
 
                        } else {
1383
 
                            // just dotlinery
1384
 
                            dotlines[c++] = QPoint( bx+1, linebot );
1385
 
                            dotlines[c++] = QPoint( r.width(), linebot );
1386
 
                        }
1387
 
 
1388
 
                        y += child->totalHeight();
1389
 
                        child = child->nextSibling();
1390
 
                    }
1391
 
 
1392
 
                    if ( child ) // there's a child, so move linebot to edge of rectangle
1393
 
                        linebot = r.height();
1394
 
 
1395
 
                    if ( linetop < linebot ) {
1396
 
                        dotlines[c++] = QPoint( bx, linetop );
1397
 
                        dotlines[c++] = QPoint( bx, linebot );
1398
 
                    }
1399
 
                }
1400
 
                p->setPen( cg.text() );
1401
 
 
1402
 
                static QBitmap *verticalLine = 0, *horizontalLine = 0;
1403
 
                static QCleanupHandler<QBitmap> qlv_cleanup_bitmap;
1404
 
                if ( !verticalLine ) {
1405
 
                    // make 128*1 and 1*128 bitmaps that can be used for
1406
 
                    // drawing the right sort of lines.
1407
 
                    verticalLine = new QBitmap( 1, 129, TRUE );
1408
 
                    horizontalLine = new QBitmap( 128, 1, TRUE );
1409
 
                    QPointArray a( 64 );
1410
 
                    QPainter p;
1411
 
                    p.begin( verticalLine );
1412
 
                    int i;
1413
 
                    for( i=0; i<64; i++ )
1414
 
                        a.setPoint( i, 0, i*2+1 );
1415
 
                    p.setPen( color1 );
1416
 
                    p.drawPoints( a );
1417
 
                    p.end();
1418
 
                    QApplication::flushX();
1419
 
                    verticalLine->setMask( *verticalLine );
1420
 
                    p.begin( horizontalLine );
1421
 
                    for( i=0; i<64; i++ )
1422
 
                        a.setPoint( i, i*2+1, 0 );
1423
 
                    p.setPen( color1 );
1424
 
                    p.drawPoints( a );
1425
 
                    p.end();
1426
 
                    QApplication::flushX();
1427
 
                    horizontalLine->setMask( *horizontalLine );
1428
 
                    qlv_cleanup_bitmap.add( &verticalLine );
1429
 
                    qlv_cleanup_bitmap.add( &horizontalLine );
1430
 
                }
1431
 
 
1432
 
                int line; // index into dotlines
1433
 
                for( line = 0; line < c; line += 2 ) {
1434
 
                    // assumptions here: lines are horizontal or vertical.
1435
 
                    // lines always start with the numerically lowest
1436
 
                    // coordinate.
1437
 
 
1438
 
                    // point ... relevant coordinate of current point
1439
 
                    // end ..... same coordinate of the end of the current line
1440
 
                    // other ... the other coordinate of the current point/line
1441
 
                    if ( dotlines[line].y() == dotlines[line+1].y() ) {
1442
 
                        int end = dotlines[line+1].x();
1443
 
                        int point = dotlines[line].x();
1444
 
                        int other = dotlines[line].y();
1445
 
                        while( point < end ) {
1446
 
                            int i = 128;
1447
 
                            if ( i+point > end )
1448
 
                                i = end-point;
1449
 
                            p->drawPixmap( point, other, *horizontalLine,
1450
 
                                           0, 0, i, 1 );
1451
 
                            point += i;
1452
 
                        }
1453
 
                    } else {
1454
 
                        int end = dotlines[line+1].y();
1455
 
                        int point = dotlines[line].y();
1456
 
                        int other = dotlines[line].x();
1457
 
                        int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
1458
 
                        while( point < end ) {
1459
 
                            int i = 128;
1460
 
                            if ( i+point > end )
1461
 
                                i = end-point;
1462
 
                            p->drawPixmap( other, point, *verticalLine,
1463
 
                                           0, pixmapoffset, 1, i );
1464
 
                            point += i;
1465
 
                        }
1466
 
                    }
1467
 
                }
1468
 
            }
1469
 
        }
1470
 
        break;
1471
 
#endif //QT_NO_LISTVIEW
1472
 
 
1473
 
#ifndef QT_NO_COMBOBOX
1474
 
    case CC_ComboBox:
1475
 
        if ( sub & SC_ComboBoxArrow ) {
1476
 
            SFlags flags = Style_Default;
1477
 
 
1478
 
            qDrawWinPanel( p, r, cg, TRUE, widget->isEnabled() ?
1479
 
                           &cg.brush( QColorGroup::Base ):
1480
 
                           &cg.brush( QColorGroup::Background ) );
1481
 
 
1482
 
            QRect ar =
1483
 
                QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
1484
 
                                                            SC_ComboBoxArrow ), widget );
1485
 
            if ( subActive == SC_ComboBoxArrow ) {
1486
 
                p->setPen( cg.dark() );
1487
 
                p->setBrush( cg.brush( QColorGroup::Button ) );
1488
 
                p->drawRect( ar );
1489
 
            } else
1490
 
                qDrawWinPanel( p, ar, cg, FALSE,
1491
 
                               &cg.brush( QColorGroup::Button ) );
1492
 
 
1493
 
            ar.addCoords( 2, 2, -2, -2 );
1494
 
            if ( widget->isEnabled() )
1495
 
                flags |= Style_Enabled;
1496
 
 
1497
 
            if ( subActive & Style_Sunken ) {
1498
 
                flags |= Style_Sunken;
1499
 
            }
1500
 
            drawPrimitive( PE_ArrowDown, p, ar, cg, flags );
1501
 
        }
1502
 
 
1503
 
        if ( sub & SC_ComboBoxEditField ) {
1504
 
            const QComboBox * cb = (const QComboBox *) widget;
1505
 
            QRect re =
1506
 
                QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
1507
 
                                                            SC_ComboBoxEditField ), widget );
1508
 
            if ( cb->hasFocus() && !cb->editable() )
1509
 
                p->fillRect( re.x(), re.y(), re.width(), re.height(),
1510
 
                             cg.brush( QColorGroup::Highlight ) );
1511
 
 
1512
 
            if ( cb->hasFocus() ) {
1513
 
                p->setPen( cg.highlightedText() );
1514
 
                p->setBackgroundColor( cg.highlight() );
1515
 
 
1516
 
            } else {
1517
 
                p->setPen( cg.text() );
1518
 
                p->setBackgroundColor( cg.background() );
1519
 
            }
1520
 
 
1521
 
            if ( cb->hasFocus() && !cb->editable() ) {
1522
 
                QRect re =
1523
 
                    QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
1524
 
                drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight()));
1525
 
            }
1526
 
        }
1527
 
 
1528
 
        break;
1529
 
#endif  // QT_NO_COMBOBOX
1530
 
 
1531
 
#ifndef QT_NO_SLIDER
1532
 
    case CC_Slider:
1533
 
        {
1534
 
            const QSlider *sl = (const QSlider *) widget;
1535
 
            int thickness  = pixelMetric( PM_SliderControlThickness, widget );
1536
 
            int len        = pixelMetric( PM_SliderLength, widget );
1537
 
            int ticks = sl->tickmarks();
1538
 
 
1539
 
            QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
1540
 
                                                  opt),
1541
 
                  handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
1542
 
                                                  opt);
1543
 
 
1544
 
            if ((sub & SC_SliderGroove) && groove.isValid()) {
1545
 
                int mid = thickness / 2;
1546
 
 
1547
 
                if ( ticks & QSlider::Above )
1548
 
                    mid += len / 8;
1549
 
                if ( ticks & QSlider::Below )
1550
 
                    mid -= len / 8;
1551
 
 
1552
 
                p->setPen( cg.shadow() );
1553
 
                if ( sl->orientation() == Horizontal ) {
1554
 
                    qDrawWinPanel( p, groove.x(), groove.y() + mid - 2,
1555
 
                                   groove.width(), 4, cg, TRUE );
1556
 
                    p->drawLine( groove.x() + 1, groove.y() + mid - 1,
1557
 
                                 groove.x() + groove.width() - 3, groove.y() + mid - 1 );
1558
 
                } else {
1559
 
                    qDrawWinPanel( p, groove.x() + mid - 2, groove.y(),
1560
 
                                   4, groove.height(), cg, TRUE );
1561
 
                    p->drawLine( groove.x() + mid - 1, groove.y() + 1,
1562
 
                                 groove.x() + mid - 1,
1563
 
                                 groove.y() + groove.height() - 3 );
1564
 
                }
1565
 
            }
1566
 
 
1567
 
            if (sub & SC_SliderTickmarks)
1568
 
                QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags,
1569
 
                                                 SC_SliderTickmarks, subActive,
1570
 
                                                 opt );
1571
 
 
1572
 
            if ( sub & SC_SliderHandle ) {
1573
 
                // 4444440
1574
 
                // 4333310
1575
 
                // 4322210
1576
 
                // 4322210
1577
 
                // 4322210
1578
 
                // 4322210
1579
 
                // *43210*
1580
 
                // **410**
1581
 
                // ***0***
1582
 
                const QColor c0 = cg.shadow();
1583
 
                const QColor c1 = cg.dark();
1584
 
                // const QColor c2 = g.button();
1585
 
                const QColor c3 = cg.midlight();
1586
 
                const QColor c4 = cg.light();
1587
 
 
1588
 
                int x = handle.x(), y = handle.y(),
1589
 
                   wi = handle.width(), he = handle.height();
1590
 
 
1591
 
                int x1 = x;
1592
 
                int x2 = x+wi-1;
1593
 
                int y1 = y;
1594
 
                int y2 = y+he-1;
1595
 
 
1596
 
                Orientation orient = sl->orientation();
1597
 
                bool tickAbove = sl->tickmarks() == QSlider::Above;
1598
 
                bool tickBelow = sl->tickmarks() == QSlider::Below;
1599
 
 
1600
 
                p->fillRect( x, y, wi, he, cg.brush( QColorGroup::Background ) );
1601
 
 
1602
 
                if ( sl->hasFocus() ) {
1603
 
                    QRect re = subRect( SR_SliderFocusRect, sl );
1604
 
                    drawPrimitive( PE_FocusRect, p, re, cg );
1605
 
                }
1606
 
 
1607
 
                if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) {
1608
 
                    qDrawWinButton( p, QRect(x,y,wi,he), cg, FALSE,
1609
 
                                    &cg.brush( QColorGroup::Button ) );
1610
 
                    return;
1611
 
                }
1612
 
 
1613
 
                QSliderDirection dir;
1614
 
 
1615
 
                if ( orient == Horizontal )
1616
 
                    if ( tickAbove )
1617
 
                        dir = SlUp;
1618
 
                    else
1619
 
                        dir = SlDown;
1620
 
                else
1621
 
                    if ( tickAbove )
1622
 
                        dir = SlLeft;
1623
 
                    else
1624
 
                        dir = SlRight;
1625
 
 
1626
 
                QPointArray a;
1627
 
 
1628
 
                int d = 0;
1629
 
                switch ( dir ) {
1630
 
                case SlUp:
1631
 
                    y1 = y1 + wi/2;
1632
 
                    d =  (wi + 1) / 2 - 1;
1633
 
                    a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );
1634
 
                    break;
1635
 
                case SlDown:
1636
 
                    y2 = y2 - wi/2;
1637
 
                    d =  (wi + 1) / 2 - 1;
1638
 
                    a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );
1639
 
                    break;
1640
 
                case SlLeft:
1641
 
                    d =  (he + 1) / 2 - 1;
1642
 
                    x1 = x1 + he/2;
1643
 
                    a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
1644
 
                    break;
1645
 
                case SlRight:
1646
 
                    d =  (he + 1) / 2 - 1;
1647
 
                    x2 = x2 - he/2;
1648
 
                    a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );
1649
 
                    break;
1650
 
                }
1651
 
 
1652
 
                QBrush oldBrush = p->brush();
1653
 
                p->setBrush( cg.brush( QColorGroup::Button ) );
1654
 
                p->setPen( NoPen );
1655
 
                p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
1656
 
                p->drawPolygon( a );
1657
 
                p->setBrush( oldBrush );
1658
 
 
1659
 
                if ( dir != SlUp ) {
1660
 
                    p->setPen( c4 );
1661
 
                    p->drawLine( x1, y1, x2, y1 );
1662
 
                    p->setPen( c3 );
1663
 
                    p->drawLine( x1, y1+1, x2, y1+1 );
1664
 
                }
1665
 
                if ( dir != SlLeft ) {
1666
 
                    p->setPen( c3 );
1667
 
                    p->drawLine( x1+1, y1+1, x1+1, y2 );
1668
 
                    p->setPen( c4 );
1669
 
                    p->drawLine( x1, y1, x1, y2 );
1670
 
                }
1671
 
                if ( dir != SlRight ) {
1672
 
                    p->setPen( c0 );
1673
 
                    p->drawLine( x2, y1, x2, y2 );
1674
 
                    p->setPen( c1 );
1675
 
                    p->drawLine( x2-1, y1+1, x2-1, y2-1 );
1676
 
                }
1677
 
                if ( dir != SlDown ) {
1678
 
                    p->setPen( c0 );
1679
 
                    p->drawLine( x1, y2, x2, y2 );
1680
 
                    p->setPen( c1 );
1681
 
                    p->drawLine( x1+1, y2-1, x2-1, y2-1 );
1682
 
                }
1683
 
 
1684
 
                switch ( dir ) {
1685
 
                case SlUp:
1686
 
                    p->setPen( c4 );
1687
 
                    p->drawLine( x1, y1, x1+d, y1-d);
1688
 
                    p->setPen( c0 );
1689
 
                    d = wi - d - 1;
1690
 
                    p->drawLine( x2, y1, x2-d, y1-d);
1691
 
                    d--;
1692
 
                    p->setPen( c3 );
1693
 
                    p->drawLine( x1+1, y1, x1+1+d, y1-d );
1694
 
                    p->setPen( c1 );
1695
 
                    p->drawLine( x2-1, y1, x2-1-d, y1-d);
1696
 
                    break;
1697
 
                case SlDown:
1698
 
                    p->setPen( c4 );
1699
 
                    p->drawLine( x1, y2, x1+d, y2+d);
1700
 
                    p->setPen( c0 );
1701
 
                    d = wi - d - 1;
1702
 
                    p->drawLine( x2, y2, x2-d, y2+d);
1703
 
                    d--;
1704
 
                    p->setPen( c3 );
1705
 
                    p->drawLine( x1+1, y2, x1+1+d, y2+d );
1706
 
                    p->setPen( c1 );
1707
 
                    p->drawLine( x2-1, y2, x2-1-d, y2+d);
1708
 
                    break;
1709
 
                case SlLeft:
1710
 
                    p->setPen( c4 );
1711
 
                    p->drawLine( x1, y1, x1-d, y1+d);
1712
 
                    p->setPen( c0 );
1713
 
                    d = he - d - 1;
1714
 
                    p->drawLine( x1, y2, x1-d, y2-d);
1715
 
                    d--;
1716
 
                    p->setPen( c3 );
1717
 
                    p->drawLine( x1, y1+1, x1-d, y1+1+d );
1718
 
                    p->setPen( c1 );
1719
 
                    p->drawLine( x1, y2-1, x1-d, y2-1-d);
1720
 
                    break;
1721
 
                case SlRight:
1722
 
                    p->setPen( c4 );
1723
 
                    p->drawLine( x2, y1, x2+d, y1+d);
1724
 
                    p->setPen( c0 );
1725
 
                    d = he - d - 1;
1726
 
                    p->drawLine( x2, y2, x2+d, y2-d);
1727
 
                    d--;
1728
 
                    p->setPen( c3 );
1729
 
                    p->drawLine(  x2, y1+1, x2+d, y1+1+d );
1730
 
                    p->setPen( c1 );
1731
 
                    p->drawLine( x2, y2-1, x2+d, y2-1-d);
1732
 
                    break;
1733
 
                }
1734
 
            }
1735
 
 
1736
 
            break;
1737
 
        }
1738
 
#endif // QT_NO_SLIDER
1739
 
 
1740
 
    default:
1741
 
        QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub,
1742
 
                                          subActive, opt );
1743
 
        break;
1744
 
    }
1745
 
}
1746
 
 
1747
 
 
1748
 
/*! \reimp */
1749
 
int QMuseWindowsStyle::styleHint( StyleHint hint,
1750
 
                              const QWidget *widget,
1751
 
                              const QStyleOption &opt,
1752
 
                              QStyleHintReturn *returnData ) const
1753
 
{
1754
 
    int ret;
1755
 
 
1756
 
    switch (hint) {
1757
 
    case SH_EtchDisabledText:
1758
 
    case SH_Slider_SnapToValue:
1759
 
    case SH_PrintDialog_RightAlignButtons:
1760
 
    case SH_MainWindow_SpaceBelowMenuBar:
1761
 
    case SH_FontDialog_SelectAssociatedText:
1762
 
    case SH_PopupMenu_AllowActiveAndDisabled:
1763
 
    case SH_MenuBar_AltKeyNavigation:
1764
 
    case SH_MenuBar_MouseTracking:
1765
 
    case SH_PopupMenu_MouseTracking:
1766
 
    case SH_ComboBox_ListMouseTracking:
1767
 
        ret = 1;
1768
 
        break;
1769
 
 
1770
 
    case SH_ItemView_ChangeHighlightOnFocus:
1771
 
#if defined(Q_WS_WIN)
1772
 
        if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT )
1773
 
            ret = 1;
1774
 
        else
1775
 
#endif
1776
 
            ret = 0;
1777
 
        break;
1778
 
 
1779
 
    default:
1780
 
        ret = QCommonStyle::styleHint(hint, widget, opt, returnData);
1781
 
        break;
1782
 
    }
1783
 
 
1784
 
    return ret;
1785
 
}
1786