~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/widgets/styles/qwindowscestyle.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtGui module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#include "qwindowscestyle_p.h"
 
43
 
 
44
#if !defined(QT_NO_STYLE_WINDOWSCE) || defined(QT_PLUGIN)
 
45
 
 
46
#include "qpainterpath.h"
 
47
#include "qapplication.h"
 
48
#include "qdockwidget.h"
 
49
#include "qtoolbar.h"
 
50
#include "qpaintengine.h"
 
51
#include "qpainter.h"
 
52
#include "qstyleoption.h"
 
53
#include "qwindowscestyle_p_p.h"
 
54
#include "qdebug.h"
 
55
#include "qdrawutil.h"
 
56
 
 
57
QT_BEGIN_NAMESPACE
 
58
 
 
59
static const int windowsItemFrame        =  2; // menu item frame width
 
60
static const int windowsItemHMargin      =  3; // menu item hor text margin
 
61
static const int windowsItemVMargin      =  2; // menu item ver text margin
 
62
static const int windowsArrowHMargin     =  6; // arrow horizontal margin
 
63
static const int windowsRightBorder      = 15; // right border on windows
 
64
static const int windowsCheckMarkWidth   = 14; // checkmarks width on windows
 
65
 
 
66
static const int windowsCEitemViewCheckBoxSize   = 14;
 
67
static const int windowsCEFrameGroupBoxOffset    = 9;
 
68
static const int windowsCEIndicatorSize          = 14;
 
69
static const int windowsCEExclusiveIndicatorSize = 14;
 
70
static const int windowsCESliderThickness        = 24;
 
71
static const int windowsCEIconSize               = 16;
 
72
 
 
73
static const QColor windowsCECheckBoxGradientColorBegin = QColor(222, 224, 214);
 
74
static const QColor windowsCECheckBoxGradientColorEnd   =  QColor(255, 255, 255);
 
75
 
 
76
enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
 
77
 
 
78
QWindowsCEStyle::QWindowsCEStyle() : QWindowsStyle() {
 
79
    qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
 
80
    qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
 
81
}
 
82
 
 
83
QWindowsCEStyle::~QWindowsCEStyle()
 
84
{
 
85
}
 
86
 
 
87
void QWindowsCEStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
 
88
                                    QPainter *painter, const QWidget *widget) const {
 
89
 
 
90
    bool doRestore = false;
 
91
    QRect rect = option->rect;
 
92
 
 
93
    switch (element) {
 
94
    case PE_PanelButtonTool: {
 
95
        if (
 
96
#ifndef QT_NO_TOOLBAR
 
97
             (widget && qobject_cast<QToolBar*>(widget->parentWidget())) ||
 
98
#endif
 
99
#ifndef QT_NO_DOCKWIDGET
 
100
             (widget && widget->inherits("QDockWidgetTitleButton")) ||
 
101
#endif
 
102
            (option->state & (State_Sunken | State_On)))
 
103
               QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(0, 0, 0, 0),
 
104
                  option->palette, option->state & (State_Sunken | State_On),
 
105
                  &option->palette.button());
 
106
        if (option->state & (State_On)){
 
107
            QBrush fill = QBrush(option->palette.midlight().color(), Qt::Dense4Pattern);
 
108
            painter->fillRect(option->rect.adjusted(windowsItemFrame , windowsItemFrame ,
 
109
                              -windowsItemFrame , -windowsItemFrame ), fill);
 
110
        }
 
111
        break; }
 
112
    case PE_IndicatorButtonDropDown:
 
113
        QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
 
114
            option->state & (State_Sunken | State_On),
 
115
            &option->palette.brush(QPalette::Button));
 
116
        break;
 
117
#ifndef QT_NO_TABBAR
 
118
        case PE_IndicatorTabTear:
 
119
        if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
 
120
            bool rtl = tab->direction == Qt::RightToLeft;
 
121
            QRect rect = tab->rect;
 
122
            QPainterPath path;
 
123
            rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
 
124
            rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
 
125
            path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
 
126
            int count = 3;
 
127
            for(int jags = 1; jags <= count; ++jags, rtl = !rtl)
 
128
                path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
 
129
 
 
130
            painter->setPen(QPen(tab->palette.light(), qreal(.8)));
 
131
            painter->setBrush(tab->palette.background());
 
132
            painter->setRenderHint(QPainter::Antialiasing);
 
133
            painter->drawPath(path);
 
134
        }
 
135
        break;
 
136
#endif //QT_NO_TABBAR
 
137
#ifndef QT_NO_TOOLBAR
 
138
        case PE_IndicatorToolBarSeparator:
 
139
            //nothing to draw on WindowsCE
 
140
            break;
 
141
        case PE_IndicatorToolBarHandle:
 
142
            painter->save();
 
143
            painter->translate(option->rect.x(), option->rect.y());
 
144
            if (option->state & State_Horizontal) {
 
145
                int x = option->rect.width() / 2 - 4;
 
146
                if (QApplication::layoutDirection() == Qt::RightToLeft)
 
147
                    x -= 2;
 
148
                if (option->rect.height() > 4) {
 
149
                    QWindowsCEStylePrivate::drawWinCEButton(painter,x - 1, 0, 7, option->rect.height(),
 
150
                        option->palette, false,  0);
 
151
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, x, 1, 3, option->rect.height() - 1,
 
152
                        option->palette, false, 0);
 
153
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, x + 3, 1, 3, option->rect.height() - 1,
 
154
                        option->palette, false, 0);
 
155
                    painter->setPen(option->palette.button().color());
 
156
                    painter->drawLine(x + 4, 2, x + 4,option->rect.height() - 2);
 
157
                }
 
158
            } else {
 
159
                if (option->rect.width() > 4) {
 
160
                    int y = option->rect.height() / 2 - 4;
 
161
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y, option->rect.width() - 2, 3,
 
162
                        option->palette, false,  0);
 
163
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y + 3, option->rect.width() - 2, 3,
 
164
                        option->palette, false,  0);
 
165
                }
 
166
            }
 
167
            painter->restore();
 
168
            break;
 
169
 
 
170
#endif // QT_NO_TOOLBAR
 
171
        case PE_FrameButtonTool: {
 
172
#ifndef QT_NO_DOCKWIDGET
 
173
            if (widget && widget->inherits("QDockWidgetTitleButton")) {
 
174
                if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent()))
 
175
                    if (dw->isFloating()){
 
176
                        QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(1, 1, 0, 0),
 
177
                                                                option->palette, option->state & (State_Sunken | State_On),
 
178
                            &option->palette.button());
 
179
                        return;
 
180
                    }
 
181
            }
 
182
#endif // QT_NO_DOCKWIDGET
 
183
        QBrush fill;
 
184
        bool stippled;
 
185
        bool panel = (element == PE_PanelButtonTool);
 
186
        if ((!(option->state & State_Sunken ))
 
187
            && (!(option->state & State_Enabled)
 
188
            || ((option->state & State_Enabled ) && !(option->state & State_MouseOver)))
 
189
            && (option->state & State_On)) {
 
190
                fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
191
                stippled = true;
 
192
        } else {
 
193
            fill = option->palette.brush(QPalette::Button);
 
194
            stippled = false;
 
195
        }
 
196
        if (option->state & (State_Raised | State_Sunken | State_On)) {
 
197
            if (option->state & State_AutoRaise) {
 
198
                if(option->state & (State_Enabled | State_Sunken | State_On)){
 
199
                    if (panel)
 
200
                        QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette,
 
201
                        option->state & (State_Sunken | State_On), &fill);
 
202
                    else
 
203
                        qDrawShadeRect(painter, option->rect, option->palette,
 
204
                        option->state & (State_Sunken | State_On), 1);
 
205
                }
 
206
                if (stippled) {
 
207
                    painter->setPen(option->palette.button().color());
 
208
                    painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
 
209
                }
 
210
            } else {
 
211
                QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
 
212
                    option->state & (State_Sunken | State_On), panel ? &fill : 0);
 
213
            }
 
214
        } else {
 
215
            painter->fillRect(option->rect, fill);
 
216
        }
 
217
        break; }
 
218
 
 
219
    case PE_PanelButtonBevel: {
 
220
        QBrush fill;
 
221
        bool panel = element != PE_FrameButtonBevel;
 
222
        painter->setBrushOrigin(option->rect.topLeft());
 
223
        if (!(option->state & State_Sunken) && (option->state & State_On))
 
224
            fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
225
        else
 
226
            fill = option->palette.brush(QPalette::Button);
 
227
 
 
228
        if (option->state & (State_Raised | State_On | State_Sunken)) {
 
229
            QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
 
230
                                                    option->state & (State_Sunken | State_On),
 
231
                panel ? &fill : 0); ;
 
232
        } else {
 
233
            if (panel)
 
234
                painter->fillRect(option->rect, fill);
 
235
            else
 
236
                painter->drawRect(option->rect);
 
237
        }
 
238
        break; }
 
239
 
 
240
    case PE_FrameGroupBox:
 
241
        if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
 
242
            QRect fr = frame->rect;
 
243
            painter->setPen(frame->palette.shadow().color());
 
244
            painter->drawRect(fr.x(), fr.y(), fr.x() + fr.width() - 1,
 
245
                              fr.y() + fr.height() - windowsCEFrameGroupBoxOffset);
 
246
        }
 
247
        break;
 
248
 
 
249
   case PE_IndicatorCheckBox: {
 
250
        QBrush fill;
 
251
        if (option->state & State_NoChange)
 
252
            fill = QBrush(option->palette.base().color(), Qt::Dense4Pattern);
 
253
        else if (option->state & State_Sunken)
 
254
            fill = option->palette.button();
 
255
        else if (option->state & State_Enabled)
 
256
            fill = option->palette.base();
 
257
        else
 
258
            fill = option->palette.background();
 
259
        painter->save();
 
260
        doRestore = true;
 
261
        painter->fillRect(option->rect,fill);
 
262
        painter->setPen(option->palette.dark().color());
 
263
        painter->drawRect(option->rect);
 
264
        painter->setPen(option->palette.shadow().color());
 
265
        painter->drawLine(option->rect.x() + 1,option->rect.y() + 1,
 
266
                          option->rect.x() + option->rect.width() - 1, option->rect.y() + 1);
 
267
        painter->drawLine(option->rect.x() + 1,option->rect.y() + 1,
 
268
                          option->rect.x() + 1, option->rect.y() + option->rect.height() - 1);
 
269
        //fall through...
 
270
    }
 
271
    case PE_IndicatorViewItemCheck: {
 
272
        if (!doRestore) {
 
273
            painter->save();
 
274
            doRestore = true;
 
275
        }
 
276
        int arrowSize= 2;
 
277
        if (element == PE_IndicatorViewItemCheck) {
 
278
            QLinearGradient linearGradient(QPoint(option->rect.x(),option->rect.y()), QPoint(option->rect.x()+option->rect.width(),
 
279
                                           option->rect.y()+option->rect.height()));
 
280
            linearGradient.setColorAt(0, windowsCECheckBoxGradientColorBegin);
 
281
            linearGradient.setColorAt(1, windowsCECheckBoxGradientColorEnd);
 
282
            painter->setBrush(linearGradient);
 
283
            painter->setPen(Qt::NoPen);
 
284
            if (option->state & State_NoChange)
 
285
                painter->setBrush(option->palette.brush(QPalette::Button));
 
286
            painter->setPen(option->palette.link().color());
 
287
            painter->drawRect(option->rect.x(), option->rect.y(), windowsCEitemViewCheckBoxSize, windowsCEitemViewCheckBoxSize);
 
288
            painter->setPen(option->palette.brightText().color());
 
289
            arrowSize= 3;
 
290
        }
 
291
        if (!(option->state & State_Off)) {
 
292
            QLineF lines[9];
 
293
            int i, xx, yy;
 
294
            xx = option->rect.x() + 4;
 
295
            yy = option->rect.y() + 6;
 
296
            for (i = 0; i < 4; ++i) {
 
297
                lines[i] = QLineF(xx, yy, xx, yy + arrowSize);
 
298
                ++xx;
 
299
                ++yy;
 
300
            }
 
301
            yy -= 2;
 
302
            for (i = 4; i < 9; ++i) {
 
303
                lines[i] = QLineF(xx, yy, xx, yy + arrowSize);
 
304
                ++xx;
 
305
                --yy;
 
306
            }
 
307
            painter->drawLines(lines, 9);
 
308
        }
 
309
        if (doRestore)
 
310
            painter->restore();
 
311
 
 
312
        break; }
 
313
    case PE_IndicatorRadioButton: {
 
314
        QRect ir = option->rect;
 
315
        painter->save();
 
316
        painter->setPen(Qt::NoPen);
 
317
        painter->setBrush(option->palette.light());
 
318
        painter->drawEllipse(option->rect);
 
319
        painter->setPen(option->palette.shadow().color());
 
320
        painter->setBrush(option->palette.shadow().color());
 
321
        painter->drawArc(option->rect, 0, 360 * 16);
 
322
        painter->drawArc(option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2,
 
323
                         option->rect.height() - 2, 40 * 16, 180 * 16);
 
324
        painter->setPen(option->palette.light().color());
 
325
        painter->drawPoint(option->rect.x() + 11, option->rect.y() + 3);
 
326
        painter->drawPoint(option->rect.x() + 3,option->rect.y() + 3);
 
327
        painter->setPen(option->palette.shadow().color());
 
328
        painter->drawPoint(option->rect.x() +3,option->rect.y() + 12);
 
329
        if (option->state & (State_Sunken | State_On)) {
 
330
            painter->setPen(Qt::NoPen);
 
331
            painter->setBrush(option->palette.text());
 
332
            painter->drawEllipse(option->rect.x() +3,option->rect.y()+ 2,9,10);
 
333
        }
 
334
        painter->restore();
 
335
        break; }
 
336
   case PE_PanelMenuBar:
 
337
       painter->save();
 
338
       painter->setPen(option->palette.shadow().color());
 
339
       painter->drawRect(option->rect);
 
340
       painter->restore();
 
341
       break;
 
342
   case PE_PanelButtonCommand:
 
343
       if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
 
344
           QBrush fill;
 
345
           State flags = option->state;
 
346
           QPalette pal = option->palette;
 
347
           QRect r = option->rect;
 
348
           if (! (flags & State_Sunken) && (flags & State_On))
 
349
               fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
 
350
           else
 
351
               fill = pal.brush(QPalette::Button);
 
352
           if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
 
353
               painter->setPen(pal.dark().color());
 
354
               painter->setBrush(fill);
 
355
               painter->drawRect(r.adjusted(0, 0, -1, -1));
 
356
           } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
 
357
               QWindowsCEStylePrivate::drawWinCEButton(painter, r, pal, flags & (State_Sunken | State_On),
 
358
                   &fill);
 
359
           } else {
 
360
               painter->fillRect(r, fill);
 
361
           }
 
362
 
 
363
       }
 
364
       break;
 
365
   case PE_FrameDefaultButton: {
 
366
       painter->setPen(option->palette.shadow().color());
 
367
       QRect rect = option->rect;
 
368
       rect.adjust(0, 0, -1, -1);
 
369
       painter->drawRect(rect);
 
370
       break; }
 
371
   case PE_IndicatorSpinPlus:
 
372
   case PE_IndicatorSpinMinus: {
 
373
       QRect r = option->rect;
 
374
       int fw = pixelMetric(PM_DefaultFrameWidth, option, widget)+2;
 
375
       QRect br = r.adjusted(fw, fw, -fw, -fw);
 
376
       int offset = (option->state & State_Sunken) ? 1 : 0;
 
377
       int step = (br.width() + 4) / 5;
 
378
       painter->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
 
379
           br.width(), step,
 
380
           option->palette.buttonText());
 
381
       if (element == PE_IndicatorSpinPlus)
 
382
           painter->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset+4,
 
383
           step, br.height()-7,
 
384
           option->palette.buttonText());
 
385
       break; }
 
386
    case PE_IndicatorSpinUp:
 
387
    case PE_IndicatorSpinDown: {
 
388
        painter->save();
 
389
            QPoint points[7];
 
390
            switch (element) {
 
391
                case PE_IndicatorSpinUp:
 
392
                    points[0] = QPoint(-2, -4);
 
393
                    points[1] = QPoint(-2, 2);
 
394
                    points[2] = QPoint(-1, -3);
 
395
                    points[3] = QPoint(-1, 1);
 
396
                    points[4] = QPoint(0, -2);
 
397
                    points[5] = QPoint(0, 0);
 
398
                    points[6] = QPoint(1, -1);
 
399
                break;
 
400
                case PE_IndicatorSpinDown:
 
401
                    points[0] = QPoint(0, -4);
 
402
                    points[1] = QPoint(0, 2);
 
403
                    points[2] = QPoint(-1, -3);
 
404
                    points[3] = QPoint(-1, 1);
 
405
                    points[4] = QPoint(-2, -2);
 
406
                    points[5] = QPoint(-2, 0);
 
407
                    points[6] = QPoint(-3, -1);
 
408
                break;
 
409
                default:
 
410
                break;
 
411
            }
 
412
            if (option->state & State_Sunken)
 
413
                painter->translate(pixelMetric(PM_ButtonShiftHorizontal),
 
414
                pixelMetric(PM_ButtonShiftVertical));
 
415
            if (option->state & State_Enabled) {
 
416
                painter->translate(option->rect.x() + option->rect.width() / 2,
 
417
                                   option->rect.y() + option->rect.height() / 2);
 
418
                painter->setPen(option->palette.buttonText().color());
 
419
                painter->drawLine(points[0], points[1]);
 
420
                painter->drawLine(points[2], points[3]);
 
421
                painter->drawLine(points[4], points[5]);
 
422
                painter->drawPoint(points[6]);
 
423
            } else {
 
424
                painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
 
425
                                   option->rect.y() + option->rect.height() / 2 + 1);
 
426
                painter->setPen(option->palette.light().color());
 
427
                painter->drawLine(points[0], points[1]);
 
428
                painter->drawLine(points[2], points[3]);
 
429
                painter->drawLine(points[4], points[5]);
 
430
                painter->drawPoint(points[6]);
 
431
                painter->translate(-1, -1);
 
432
                painter->setPen(option->palette.mid().color());
 
433
                painter->drawLine(points[0], points[1]);
 
434
                painter->drawLine(points[2], points[3]);
 
435
                painter->drawLine(points[4], points[5]);
 
436
                painter->drawPoint(points[6]);
 
437
            }
 
438
 
 
439
        painter->restore();
 
440
        break; }
 
441
    case PE_IndicatorArrowUp:
 
442
    case PE_IndicatorArrowDown:
 
443
    case PE_IndicatorArrowRight:
 
444
    case PE_IndicatorArrowLeft: {
 
445
            painter->save();
 
446
            QPoint points[9];
 
447
            switch (element) {
 
448
                case PE_IndicatorArrowUp:
 
449
 
 
450
                    points[0] = QPoint(-4, 2);
 
451
                    points[1] = QPoint(4, 2);
 
452
                    points[2] = QPoint(-3, 1);
 
453
                    points[3] = QPoint(3, 1);
 
454
                    points[4] = QPoint(-2, 0);
 
455
                    points[5] = QPoint(2, 0);
 
456
                    points[6] = QPoint(-1, -1);
 
457
                    points[7] = QPoint(1, -1);
 
458
                    points[8] = QPoint(0, -2);
 
459
                break;
 
460
                case PE_IndicatorArrowDown:
 
461
 
 
462
                    points[0] = QPoint(-4, -2);
 
463
                    points[1] = QPoint(4, -2);
 
464
                    points[2] = QPoint(-3, -1);
 
465
                    points[3] = QPoint(3, -1);
 
466
                    points[4] = QPoint(-2, 0);
 
467
                    points[5] = QPoint(2, 0);
 
468
                    points[6] = QPoint(-1, 1);
 
469
                    points[7] = QPoint(1, 1);
 
470
                    points[8] = QPoint(0, 2);
 
471
                break;
 
472
                case PE_IndicatorArrowRight:
 
473
                    points[0] = QPoint(-3, -4);
 
474
                    points[1] = QPoint(-3, 4);
 
475
                    points[2] = QPoint(-2, -3);
 
476
                    points[3] = QPoint(-2, 3);
 
477
                    points[4] = QPoint(-1, -2);
 
478
                    points[5] = QPoint(-1, 2);
 
479
                    points[6] = QPoint(0, -1);
 
480
                    points[7] = QPoint(0, 1);
 
481
                    points[8] = QPoint(1, 0);
 
482
                break;
 
483
                case PE_IndicatorArrowLeft:
 
484
                    points[0] = QPoint(1, -4);
 
485
                    points[1] = QPoint(1, 4);
 
486
                    points[2] = QPoint(0, -3);
 
487
                    points[3] = QPoint(0, 3);
 
488
                    points[4] = QPoint(-1, -2);
 
489
                    points[5] = QPoint(-1, 2);
 
490
                    points[6] = QPoint(-2, -1);
 
491
                    points[7] = QPoint(-2, 1);
 
492
                    points[8] = QPoint(-3, 0);
 
493
                break;
 
494
                default:
 
495
                break;
 
496
            }
 
497
            if (option->state & State_Sunken)
 
498
                painter->translate(pixelMetric(PM_ButtonShiftHorizontal),
 
499
                pixelMetric(PM_ButtonShiftVertical));
 
500
            if (option->state & State_Enabled) {
 
501
                painter->translate(option->rect.x() + option->rect.width() / 2,
 
502
                    option->rect.y() + option->rect.height() / 2);
 
503
                painter->setPen(option->palette.buttonText().color());
 
504
                painter->drawLine(points[0], points[1]);
 
505
                painter->drawLine(points[2], points[3]);
 
506
                painter->drawLine(points[4], points[5]);
 
507
                painter->drawLine(points[6], points[7]);
 
508
                painter->drawPoint(points[8]);
 
509
            } else {
 
510
                painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
 
511
                    option->rect.y() + option->rect.height() / 2 + 1);
 
512
                painter->setPen(option->palette.light().color());
 
513
                painter->drawLine(points[0], points[1]);
 
514
                painter->drawLine(points[2], points[3]);
 
515
                painter->drawLine(points[4], points[5]);
 
516
                painter->drawLine(points[6], points[7]);
 
517
                painter->drawPoint(points[8]);
 
518
                painter->translate(-1, -1);
 
519
                painter->setPen(option->palette.mid().color());
 
520
                painter->drawLine(points[0], points[1]);
 
521
                painter->drawLine(points[2], points[3]);
 
522
                painter->drawLine(points[4], points[5]);
 
523
                painter->drawLine(points[6], points[7]);
 
524
                painter->drawPoint(points[8]);
 
525
            }
 
526
        painter->restore();
 
527
        break; }
 
528
 
 
529
    case PE_FrameWindow: {
 
530
        QPalette popupPal = option->palette;
 
531
        popupPal.setColor(QPalette::Light, option->palette.background().color());
 
532
        popupPal.setColor(QPalette::Midlight, option->palette.light().color());
 
533
        QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, popupPal, option->state & State_Sunken);
 
534
        break; }
 
535
 
 
536
    case PE_Frame:
 
537
    case PE_FrameMenu:
 
538
        if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
 
539
            QPalette popupPal = frame->palette;
 
540
            QRect r = frame->rect;
 
541
            qDrawPlainRect(painter, r, frame->palette.shadow().color(),1);
 
542
        }
 
543
        break;
 
544
    case PE_FrameStatusBar:
 
545
        QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, 0);
 
546
        break;
 
547
 
 
548
    case PE_FrameTabWidget: {
 
549
        QRect rect = option->rect;
 
550
        QPalette pal = option->palette;
 
551
        QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, false, 0);
 
552
        break; }
 
553
    default:
 
554
        QWindowsStyle::drawPrimitive(element, option, painter, widget);
 
555
        break;
 
556
    }
 
557
}
 
558
 
 
559
void QWindowsCEStyle::drawControl(ControlElement element, const QStyleOption *option,
 
560
                                  QPainter *painter, const QWidget *widget) const {
 
561
   switch (element) {
 
562
   #ifndef QT_NO_MENU
 
563
   case CE_MenuTearoff: {
 
564
        if(option->state & State_Selected) {
 
565
            if(pixelMetric(PM_MenuPanelWidth, option, widget) > 1)
 
566
                qDrawShadePanel(painter, option->rect.x(), option->rect.y(), option->rect.width(),
 
567
                                option->rect.height(), option->palette, false, 2,
 
568
                                &option->palette.brush(QPalette::Button));
 
569
            else
 
570
                qDrawShadePanel(painter, option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2,
 
571
                                option->rect.height() - 2, option->palette, true, 1, &option->palette.brush(QPalette::Button));
 
572
        } else {
 
573
            painter->fillRect(option->rect, option->palette.brush(QPalette::Button));
 
574
        }
 
575
        painter->setPen(QPen(option->palette.dark().color(), 1, Qt::DashLine));
 
576
        painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2-1, option->rect.x()+option->rect.width()-4,
 
577
                    option->rect.y()+option->rect.height()/2-1);
 
578
        painter->setPen(QPen(option->palette.light().color(), 1, Qt::DashLine));
 
579
        painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2, option->rect.x()+option->rect.width()-4,
 
580
                    option->rect.y()+option->rect.height()/2);
 
581
        break; }
 
582
 
 
583
 
 
584
   case CE_MenuBarItem:
 
585
        if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
 
586
            bool active = mbi->state & State_Selected;
 
587
            bool hasFocus = mbi->state & State_HasFocus;
 
588
            bool down = mbi->state & State_Sunken;
 
589
            QStyleOptionMenuItem newMbi = *mbi;
 
590
            if (active || hasFocus) {
 
591
                QBrush b = mbi->palette.brush(QPalette::Highlight);
 
592
                if (active && down) {
 
593
                    painter->fillRect(mbi->rect.adjusted(0, 1, 0, -1), b);
 
594
                }
 
595
            }
 
596
            uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip
 
597
                            | Qt::TextSingleLine;
 
598
            if (!styleHint(SH_UnderlineShortcut, mbi, widget))
 
599
                alignment |= Qt::TextHideMnemonic;
 
600
 
 
601
            painter->save();
 
602
            QFont f = painter->font();
 
603
            f.setBold(true);
 
604
            painter->setFont(f);
 
605
            QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize),
 
606
                                          (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
 
607
            if (!pix.isNull())
 
608
                drawItemPixmap(painter,mbi->rect, alignment, pix);
 
609
            else
 
610
                if (active && down)
 
611
                  drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
 
612
                             mbi->text, QPalette::Light);
 
613
                else
 
614
                  drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
 
615
                             mbi->text, QPalette::ButtonText);
 
616
            painter->restore();
 
617
        }
 
618
        break;
 
619
 
 
620
   case CE_MenuBarEmptyArea:
 
621
        painter->save();
 
622
        painter->setPen(option->palette.shadow().color());
 
623
        if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) {
 
624
            painter->eraseRect(option->rect);
 
625
            QRect r = option->rect;
 
626
            painter->drawLine(r.x() + 1, r.y() + 1, r.x()+ 1, r.y()+ r.height() - 2);
 
627
            painter->drawLine(r.x() - 2 + r.width(), r.y()  + 1, r.x() - 2 + r.width(), r.y() + r.height() - 2);
 
628
            painter->drawLine(r.x() + 1, r.y() +1, r.x() - 1 + r.width(), r.y() + 1);
 
629
            painter->drawLine(r.x() + 1, r.y() + r.height()-2 , r.x() - 2 + r.width(), r.y() + r.height() - 2);
 
630
        }
 
631
        painter->restore();
 
632
        break;
 
633
 
 
634
    case CE_MenuItem:
 
635
          if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
 
636
            int x, y, w, h;
 
637
            menuitem->rect.getRect(&x, &y, &w, &h);
 
638
            int tab = menuitem->tabWidth;
 
639
            bool dis = !(menuitem->state & State_Enabled);
 
640
            bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
 
641
                            ? menuitem->checked : false;
 
642
            bool act = menuitem->state & State_Selected;
 
643
 
 
644
            // windows always has a check column, regardless whether we have an icon or not
 
645
            int checkcol = qMax(menuitem->maxIconWidth, windowsCheckMarkWidth);
 
646
            QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
 
647
            painter->fillRect(menuitem->rect.adjusted(1, 1, 0, 0), fill);
 
648
 
 
649
            if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
 
650
                int yoff = y-1 + h / 2;
 
651
                painter->setPen(menuitem->palette.shadow().color());
 
652
                painter->drawLine(x + 4, yoff + 1, x + w - 8, yoff + 1);
 
653
                return;
 
654
            }
 
655
 
 
656
            QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(),
 
657
                                          menuitem->rect.y(), checkcol, menuitem->rect.height()));
 
658
            if (checked) {
 
659
                if (act && !dis) {
 
660
                    qDrawPlainRect(painter, vCheckRect,
 
661
                        menuitem->palette.button().color(), 1,
 
662
                                    &menuitem->palette.brush(QPalette::Button));
 
663
                } else {
 
664
                    QBrush fill(menuitem->palette.button().color(), Qt::Dense4Pattern);
 
665
                    qDrawPlainRect(painter, vCheckRect,menuitem->palette.button().color(), 1, &fill);
 
666
                }
 
667
            } else if (!act) {
 
668
                painter->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
 
669
            }
 
670
            // On Windows Style, if we have a checkable item and an icon we
 
671
            // draw the icon recessed to indicate an item is checked. If we
 
672
            // have no icon, we draw a checkmark instead.
 
673
            if (!menuitem->icon.isNull()) {
 
674
                QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
 
675
                if (act && !dis)
 
676
                    mode = QIcon::Active;
 
677
                QPixmap pixmap;
 
678
                if (checked)
 
679
                    pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
 
680
                else
 
681
                    pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
 
682
                int pixw = pixmap.width();
 
683
                int pixh = pixmap.height();
 
684
                if (act && !dis && !checked)
 
685
                    qDrawPlainRect(painter, vCheckRect,  menuitem->palette.button().color(), 1,
 
686
                                    &menuitem->palette.brush(QPalette::Button));
 
687
                QRect pmr(0, 0, pixw, pixh);
 
688
                pmr.moveCenter(vCheckRect.center());
 
689
                painter->setPen(menuitem->palette.text().color());
 
690
                painter->drawPixmap(pmr.topLeft(), pixmap);
 
691
            } else if (checked) {
 
692
                QStyleOptionMenuItem newMi = *menuitem;
 
693
                newMi.state = State_None;
 
694
                if (!dis)
 
695
                    newMi.state |= State_Enabled;
 
696
                if (act)
 
697
                    newMi.state |= State_On;
 
698
                newMi.rect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x()
 
699
                           + windowsItemFrame, menuitem->rect.y() + windowsItemFrame,
 
700
                             checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame));
 
701
                drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, painter, widget);
 
702
            }
 
703
            painter->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
 
704
 
 
705
            QColor discol;
 
706
            if (dis) {
 
707
                discol = menuitem->palette.text().color();
 
708
                painter->setPen(discol);
 
709
            }
 
710
            int xm = windowsItemFrame + checkcol + windowsItemHMargin;
 
711
            int xpos = menuitem->rect.x() + xm;
 
712
            QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
 
713
            QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect);
 
714
            QString s = menuitem->text;
 
715
            if (!s.isEmpty()) {                     // draw text
 
716
                painter->save();
 
717
                int t = s.indexOf(QLatin1Char('\t'));
 
718
                int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
 
719
                if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
 
720
                    text_flags |= Qt::TextHideMnemonic;
 
721
                text_flags |= Qt::AlignLeft;
 
722
                if (t >= 0) {
 
723
                    QRect vShortcutRect = visualRect(option->direction, menuitem->rect,
 
724
                        QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
 
725
                    if (dis && !act)
 
726
                        painter->setPen(discol);
 
727
                    painter->drawText(vShortcutRect, text_flags, s.mid(t + 1));
 
728
                    s = s.left(t);
 
729
                }
 
730
                QFont font = menuitem->font;
 
731
                if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
 
732
                    font.setBold(true);
 
733
                painter->setFont(font);
 
734
                if (dis && !act)
 
735
                    painter->setPen(discol);
 
736
                painter->drawText(vTextRect, text_flags, s.left(t));
 
737
                painter->restore();
 
738
            }
 
739
            if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
 
740
                int dim = (h - 2 * windowsItemFrame) / 2;
 
741
                PrimitiveElement arrow;
 
742
                arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorSpinDown : PE_IndicatorSpinUp;
 
743
                xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
 
744
                QRect  vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
 
745
                QStyleOptionMenuItem newMI = *menuitem;
 
746
                newMI.rect = vSubMenuRect;
 
747
                newMI.state = dis ? State_None : State_Enabled;
 
748
                if (act)
 
749
                    newMI.palette.setColor(QPalette::ButtonText,
 
750
                                           newMI.palette.highlightedText().color());
 
751
                drawPrimitive(arrow, &newMI, painter, widget);
 
752
            }
 
753
        }
 
754
        break;
 
755
#endif // QT_NO_MENU
 
756
    case CE_MenuVMargin:
 
757
        painter->fillRect(option->rect, Qt::white);
 
758
        break;
 
759
    case CE_MenuEmptyArea:
 
760
        QWindowsStyle::drawControl(element,option, painter, widget);
 
761
        break;
 
762
 
 
763
#ifndef QT_NO_TABBAR
 
764
        case CE_TabBarTab:
 
765
            if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
 
766
                drawControl(CE_TabBarTabShape, tab, painter, widget);
 
767
                drawControl(CE_TabBarTabLabel, tab, painter, widget);
 
768
            }
 
769
            break;
 
770
    case CE_TabBarTabShape:
 
771
        if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
 
772
            bool rtlHorTabs = (tab->direction == Qt::RightToLeft
 
773
                               && (tab->shape == QTabBar::RoundedNorth
 
774
                                   || tab->shape == QTabBar::RoundedSouth));
 
775
            bool selected = tab->state & State_Selected;
 
776
            bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
 
777
                            || (rtlHorTabs
 
778
                                && tab->position == QStyleOptionTab::Beginning));
 
779
            bool firstTab = ((!rtlHorTabs
 
780
                               && tab->position == QStyleOptionTab::Beginning)
 
781
                             || (rtlHorTabs
 
782
                                 && tab->position == QStyleOptionTab::End));
 
783
            bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
 
784
            bool previousSelected =
 
785
                ((!rtlHorTabs
 
786
                  && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
 
787
                || (rtlHorTabs
 
788
                    && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
 
789
            bool nextSelected =
 
790
                ((!rtlHorTabs
 
791
                  && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
 
792
                 || (rtlHorTabs
 
793
                     && tab->selectedPosition
 
794
                            == QStyleOptionTab::PreviousIsSelected));
 
795
            int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);
 
796
            bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
 
797
                                || (rtlHorTabs
 
798
                                    && tabBarAlignment == Qt::AlignRight);
 
799
 
 
800
            bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
 
801
                                 || (rtlHorTabs
 
802
                                         && tabBarAlignment == Qt::AlignLeft);
 
803
            QColor light = tab->palette.light().color();
 
804
            QColor midlight = tab->palette.midlight().color();
 
805
            QColor dark = tab->palette.dark().color();
 
806
            QColor shadow = tab->palette.shadow().color();
 
807
            QColor background = tab->palette.background().color();
 
808
            int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget);
 
809
            if (selected)
 
810
                borderThinkness /= 2;
 
811
            QRect r2(option->rect);
 
812
            int x1 = r2.left();
 
813
            int x2 = r2.right();
 
814
            int y1 = r2.top();
 
815
            int y2 = r2.bottom();
 
816
            switch (tab->shape) {
 
817
            default:
 
818
                QCommonStyle::drawControl(element, tab, painter, widget);
 
819
                break;
 
820
            case QTabBar::RoundedNorth: {
 
821
                if (!selected) {
 
822
                    y1 += 2;
 
823
                    x1 += firstTab ? borderThinkness : 0;
 
824
                    x2 -= lastTab ? borderThinkness : 0;
 
825
                }
 
826
 
 
827
                painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
 
828
 
 
829
                // Delete border
 
830
                if (selected) {
 
831
                    painter->setPen(background);
 
832
                    painter->drawLine(x1, y2 - 1, x2, y2 - 1);
 
833
                    painter->drawLine(x1, y2 + 1, x2, y2 + 1);
 
834
                    painter->drawLine(x1, y2, x2, y2);
 
835
                }
 
836
                // Left
 
837
                if (firstTab || selected || onlyOne || !previousSelected) {
 
838
                    painter->setPen(dark);
 
839
                    painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
 
840
                    painter->drawPoint(x1 + 1, y1 + 1);
 
841
                        painter->setPen(midlight);
 
842
                        painter->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 -
 
843
                                         ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
 
844
 
 
845
                }
 
846
                // Top
 
847
                {
 
848
                    int beg = x1 + (previousSelected ? 0 : 2);
 
849
                    int end = x2 - (nextSelected ? 0 : 2);
 
850
                    painter->setPen(dark);
 
851
                    painter->drawLine(beg, y1, end, y1);
 
852
 
 
853
                    painter->setPen(midlight);
 
854
                    painter->drawLine(beg, y1 + 1, end, y1 + 1);
 
855
 
 
856
                }
 
857
                // Right
 
858
                if (lastTab || selected || onlyOne || !nextSelected) {
 
859
                    painter->setPen(shadow);
 
860
                    painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
 
861
                    painter->drawPoint(x2 - 1, y1 + 1);
 
862
                    painter->setPen(dark);
 
863
                    painter->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
 
864
                }
 
865
                break; }
 
866
            case QTabBar::RoundedSouth: {
 
867
                if (!selected) {
 
868
                    y2 -= 2;
 
869
                    x1 += firstTab ? borderThinkness : 0;
 
870
                    x2 -= lastTab ? borderThinkness : 0;
 
871
                }
 
872
 
 
873
                painter->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
 
874
 
 
875
                // Delete border
 
876
                if (selected) {
 
877
                    painter->setPen(background);
 
878
                    painter->drawLine(x1, y1 + 1, x2 - 1, y1 + 1);
 
879
                    painter->drawLine(x1, y1 - 1, x2 - 1, y1 - 1);
 
880
                    painter->drawLine(x1, y1, x2 - 1, y1);
 
881
                }
 
882
                // Left
 
883
                if (firstTab || selected || onlyOne || !previousSelected) {
 
884
                    painter->setPen(dark);
 
885
                    painter->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
 
886
                    painter->drawPoint(x1 + 1, y2 - 1);
 
887
                    painter->setPen(midlight);
 
888
                    painter->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
 
889
                }
 
890
                // Bottom
 
891
                {
 
892
                    int beg = x1 + (previousSelected ? 0 : 2);
 
893
                    int end = x2 - (nextSelected ? 0 : 2);
 
894
                    painter->setPen(shadow);
 
895
                    painter->drawLine(beg, y2, end, y2);
 
896
                    painter->setPen(dark);
 
897
                    painter->drawLine(beg, y2 - 1, end, y2 - 1);
 
898
                }
 
899
                // Right
 
900
                if (lastTab || selected || onlyOne || !nextSelected) {
 
901
                    painter->setPen(shadow);
 
902
                    painter->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected &&
 
903
                                      rightAligned ? 0 : borderThinkness));
 
904
                    painter->drawPoint(x2 - 1, y2 - 1);
 
905
                    painter->setPen(dark);
 
906
                    painter->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected &&
 
907
                                      rightAligned ? 0 : borderThinkness));
 
908
                }
 
909
                break; }
 
910
            case QTabBar::RoundedWest: {
 
911
                if (!selected) {
 
912
                    x1 += 2;
 
913
                    y1 += firstTab ? borderThinkness : 0;
 
914
                    y2 -= lastTab ? borderThinkness : 0;
 
915
                }
 
916
 
 
917
                painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
 
918
 
 
919
                // Delete border
 
920
                if (selected) {
 
921
                    painter->setPen(background);
 
922
                    painter->drawLine(x2 - 1, y1, x2 - 1, y2);
 
923
                    painter->drawLine(x2, y1, x2, y2);
 
924
                }
 
925
                // Top
 
926
                if (firstTab || selected || onlyOne || !previousSelected) {
 
927
                    painter->setPen(dark);
 
928
                    painter->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected &&
 
929
                                      leftAligned ? 0 : borderThinkness), y1);
 
930
                    painter->drawPoint(x1 + 1, y1 + 1);
 
931
                    painter->setPen(midlight);
 
932
                    painter->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected &&
 
933
                                      leftAligned ? 0 : borderThinkness), y1 + 1);
 
934
                }
 
935
                // Left
 
936
                {
 
937
                    int beg = y1 + (previousSelected ? 0 : 2);
 
938
                    int end = y2 - (nextSelected ? 0 : 2);
 
939
                    painter->setPen(dark);
 
940
                    painter->drawLine(x1, beg, x1, end);
 
941
                    painter->setPen(midlight);
 
942
                    painter->drawLine(x1 + 1, beg, x1 + 1, end);
 
943
                }
 
944
                // Bottom
 
945
                if (lastTab || selected || onlyOne || !nextSelected) {
 
946
                    painter->setPen(shadow);
 
947
                    painter->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected &&
 
948
                                      rightAligned ? 0 : borderThinkness), y2);
 
949
                    painter->drawPoint(x1 + 2, y2 - 1);
 
950
                    painter->setPen(dark);
 
951
                    painter->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected &&
 
952
                                      rightAligned ? 0 : borderThinkness), y2 - 1);
 
953
                    painter->drawPoint(x1 + 1, y2 - 1);
 
954
                    painter->drawPoint(x1 + 2, y2);
 
955
                }
 
956
                break; }
 
957
            case QTabBar::RoundedEast: {
 
958
                if (!selected) {
 
959
                    x2 -= 2;
 
960
                    y1 += firstTab ? borderThinkness : 0;
 
961
                    y2 -= lastTab ? borderThinkness : 0;
 
962
                }
 
963
 
 
964
                painter->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
 
965
 
 
966
                // Delete border
 
967
                if (selected) {
 
968
                    painter->setPen(background);
 
969
                    painter->drawLine(x1 + 1, y1, x1 + 1, y2 - 1);
 
970
                    painter->drawLine(x1, y1, x1, y2 - 1);
 
971
                }
 
972
                // Top
 
973
                if (firstTab || selected || onlyOne || !previousSelected) {
 
974
                    painter->setPen(dark);
 
975
                    painter->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected &&
 
976
                                      leftAligned ? 0 : borderThinkness), y1);
 
977
                    painter->drawPoint(x2 - 1, y1 + 1);
 
978
                    painter->setPen(midlight);
 
979
                    painter->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) &&
 
980
                                      selected && leftAligned ? 0 : borderThinkness), y1 + 1);
 
981
                    painter->drawPoint(x2 - 1, y1);
 
982
 
 
983
                }
 
984
                // Right
 
985
                {
 
986
                    int beg = y1 + (previousSelected ? 0 : 2);
 
987
                    int end = y2 - (nextSelected ? 0 : 2);
 
988
                    painter->setPen(shadow);
 
989
                    painter->drawLine(x2, beg, x2, end);
 
990
                    painter->setPen(dark);
 
991
                    painter->drawLine(x2 - 1, beg, x2 - 1, end);
 
992
                }
 
993
                // Bottom
 
994
                if (lastTab || selected || onlyOne || !nextSelected) {
 
995
                    painter->setPen(shadow);
 
996
                    painter->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) &&
 
997
                                      selected && rightAligned ? 0 : borderThinkness), y2);
 
998
                    painter->drawPoint(x2 - 1, y2 - 1);
 
999
                    painter->setPen(dark);
 
1000
                    painter->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) &&
 
1001
                                      selected && rightAligned ? 0 : borderThinkness), y2 - 1);
 
1002
                }
 
1003
                break; }
 
1004
            }
 
1005
        }
 
1006
        break;
 
1007
#endif // QT_NO_TABBAR
 
1008
 
 
1009
    case CE_ToolBar: {
 
1010
        QRect rect = option->rect;
 
1011
        painter->setPen(QPen(option->palette.dark().color()));
 
1012
        painter->drawLine(rect.topRight().x()-1,
 
1013
            rect.topRight().y(),
 
1014
            rect.bottomRight().x()-1,
 
1015
            rect.bottomRight().y());
 
1016
        painter->drawLine(rect.bottomLeft().x(),
 
1017
            rect.bottomLeft().y(),
 
1018
            rect.bottomRight().x(),
 
1019
            rect.bottomRight().y());
 
1020
        painter->setPen(QPen(option->palette.light().color()));
 
1021
        painter->drawLine(rect.topRight().x(),
 
1022
            rect.topRight().y(),
 
1023
            rect.bottomRight().x(),
 
1024
            rect.bottomRight().y());
 
1025
        painter->drawLine(rect.topLeft().x(),
 
1026
            rect.topLeft().y(),
 
1027
            rect.topRight().x(),
 
1028
            rect.topRight().y());
 
1029
 
 
1030
        break; }
 
1031
#ifndef QT_NO_SCROLLBAR
 
1032
    case CE_ScrollBarSubLine:
 
1033
    case CE_ScrollBarAddLine: {
 
1034
        if (option->state & State_Sunken) {
 
1035
            QStyleOption buttonOpt = *option;
 
1036
 
 
1037
            drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
 
1038
        } else {
 
1039
            QStyleOption buttonOpt = *option;
 
1040
            if (!(buttonOpt.state & State_Sunken))
 
1041
                buttonOpt.state |= State_Raised;
 
1042
            drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
 
1043
        }
 
1044
        PrimitiveElement arrow;
 
1045
        if (option->state & State_Horizontal) {
 
1046
            if (element == CE_ScrollBarAddLine)
 
1047
                arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
 
1048
            else
 
1049
                arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
 
1050
        } else {
 
1051
            if (element == CE_ScrollBarAddLine)
 
1052
                arrow = PE_IndicatorArrowDown;
 
1053
            else
 
1054
                arrow = PE_IndicatorArrowUp;
 
1055
        }
 
1056
        drawPrimitive(arrow, option, painter, widget);
 
1057
        break; }
 
1058
    case CE_ScrollBarAddPage:
 
1059
    case CE_ScrollBarSubPage: {
 
1060
            QBrush br;
 
1061
            QBrush bg = painter->background();
 
1062
            Qt::BGMode bg_mode = painter->backgroundMode();
 
1063
            painter->setPen(Qt::NoPen);
 
1064
            painter->setBackgroundMode(Qt::OpaqueMode);
 
1065
 
 
1066
            if (option->state & State_Sunken) {
 
1067
                br = QBrush(option->palette.shadow().color(), Qt::Dense4Pattern);
 
1068
                painter->setBackground(option->palette.dark().color());
 
1069
                painter->setBrush(br);
 
1070
            } else {
 
1071
                QPixmap pm = option->palette.brush(QPalette::Light).texture();
 
1072
                if (option->state & State_Enabled)
 
1073
                    br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.button().color(), Qt::Dense4Pattern);
 
1074
                else
 
1075
                    br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
1076
                painter->setBackground(option->palette.base().color());
 
1077
                painter->setBrush(br);
 
1078
            }
 
1079
            painter->drawRect(option->rect);
 
1080
            painter->setBackground(bg);
 
1081
            painter->setBackgroundMode(bg_mode);
 
1082
            break; }
 
1083
    case CE_ScrollBarSlider:
 
1084
        if (!(option->state & State_Enabled)) {
 
1085
            QStyleOptionButton buttonOpt;
 
1086
            buttonOpt.QStyleOption::operator=(*option);
 
1087
            buttonOpt.state = State_Enabled | State_Raised;
 
1088
            drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
 
1089
            QPixmap pm = option->palette.brush(QPalette::Light).texture();
 
1090
            QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
1091
            painter->setPen(Qt::NoPen);
 
1092
            painter->setBrush(br);
 
1093
            painter->setBackgroundMode(Qt::OpaqueMode);
 
1094
            painter->drawRect(option->rect.adjusted(2, 2, -2, -2));
 
1095
        } else {
 
1096
            QStyleOptionButton buttonOpt;
 
1097
            buttonOpt.QStyleOption::operator=(*option);
 
1098
            buttonOpt.state = State_Enabled | State_Raised;
 
1099
            drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
 
1100
        }
 
1101
        break;
 
1102
#endif // QT_NO_SCROLLBAR
 
1103
    case CE_HeaderSection: {
 
1104
        QBrush fill;
 
1105
        if (option->state & State_On)
 
1106
            fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
1107
        else
 
1108
            fill = option->palette.brush(QPalette::Button);
 
1109
 
 
1110
        if (option->state & (State_Raised | State_Sunken)) {
 
1111
            QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
 
1112
                                                    option->state & State_Sunken, &fill);
 
1113
        } else {
 
1114
            painter->fillRect(option->rect, fill);
 
1115
        }
 
1116
        break; }
 
1117
 
 
1118
    case CE_DockWidgetTitle:
 
1119
        QWindowsStyle::drawControl(element,option, painter, widget);
 
1120
        break;
 
1121
 
 
1122
        case CE_PushButtonLabel:
 
1123
        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
 
1124
            painter->save();
 
1125
            QFont f = painter->font();
 
1126
            f.setBold(true);
 
1127
            painter->setFont(f);
 
1128
            QRect ir = btn->rect;
 
1129
            uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
 
1130
            if (!styleHint(SH_UnderlineShortcut, btn, widget))
 
1131
                tf |= Qt::TextHideMnemonic;
 
1132
 
 
1133
            if (btn->state & (State_On | State_Sunken))
 
1134
                ir.translate(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
 
1135
                             pixelMetric(PM_ButtonShiftVertical, option, widget));
 
1136
            if (!btn->icon.isNull()) {
 
1137
                QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal
 
1138
                                                              : QIcon::Disabled;
 
1139
                if (mode == QIcon::Normal && btn->state & State_HasFocus)
 
1140
                    mode = QIcon::Active;
 
1141
                QIcon::State state = QIcon::Off;
 
1142
                if (btn->state & State_On)
 
1143
                    state = QIcon::On;
 
1144
                QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state);
 
1145
                int pixw = pixmap.width();
 
1146
                int pixh = pixmap.height();
 
1147
                //Center the icon if there is no text
 
1148
 
 
1149
                QPoint point;
 
1150
                if (btn->text.isEmpty()) {
 
1151
                    point = QPoint(ir.x() + ir.width() / 2 - pixw / 2,
 
1152
                                   ir.y() + ir.height() / 2 - pixh / 2);
 
1153
                } else {
 
1154
                    point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2);
 
1155
                }
 
1156
                if (btn->direction == Qt::RightToLeft)
 
1157
                    point.rx() += pixw;
 
1158
 
 
1159
                if ((btn->state & (State_On | State_Sunken)) && btn->direction == Qt::RightToLeft)
 
1160
                    point.rx() -= pixelMetric(PM_ButtonShiftHorizontal, option, widget) * 2;
 
1161
 
 
1162
                painter->drawPixmap(visualPos(btn->direction, btn->rect, point), pixmap);
 
1163
 
 
1164
                if (btn->direction == Qt::RightToLeft)
 
1165
                    ir.translate(-4, 0);
 
1166
                else
 
1167
                    ir.translate(pixw + 4, 0);
 
1168
                ir.setWidth(ir.width() - (pixw + 4));
 
1169
                // left-align text if there is
 
1170
                if (!btn->text.isEmpty())
 
1171
                    tf |= Qt::AlignLeft;
 
1172
            } else {
 
1173
                tf |= Qt::AlignHCenter;
 
1174
            }
 
1175
            drawItemText(painter, ir, tf, btn->palette, (btn->state & State_Enabled),
 
1176
                         btn->text, QPalette::ButtonText);
 
1177
            painter->restore();
 
1178
        }
 
1179
        break;
 
1180
        default:
 
1181
            QWindowsStyle::drawControl(element, option, painter, widget);
 
1182
            break;
 
1183
    }
 
1184
}
 
1185
 
 
1186
void QWindowsCEStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
 
1187
                                         QPainter *painter, const QWidget *widget) const {
 
1188
    switch (control) {
 
1189
        #ifndef QT_NO_SLIDER
 
1190
    case CC_Slider:
 
1191
        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
 
1192
            int thickness  = pixelMetric(PM_SliderControlThickness, slider, widget);
 
1193
            int len        = pixelMetric(PM_SliderLength, slider, widget);
 
1194
            int ticks = slider->tickPosition;
 
1195
            QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
 
1196
            QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
 
1197
 
 
1198
            if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
 
1199
                int mid = thickness / 2;
 
1200
                if (ticks & QSlider::TicksAbove)
 
1201
                    mid += len / 8;
 
1202
                if (ticks & QSlider::TicksBelow)
 
1203
                    mid -= len / 8;
 
1204
 
 
1205
                painter->setPen(slider->palette.shadow().color());
 
1206
                if (slider->orientation == Qt::Horizontal) {
 
1207
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x(), groove.y() + mid - 2,
 
1208
                                   groove.width(), 4, option->palette, true);
 
1209
                    painter->drawLine(groove.x() + 1, groove.y() + mid - 1,
 
1210
                                groove.x() + groove.width() - 3, groove.y() + mid - 1);
 
1211
                } else {
 
1212
                    QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x() + mid - 2, groove.y(),
 
1213
                                  4, groove.height(), option->palette, true);
 
1214
                    painter->drawLine(groove.x() + mid - 1, groove.y() + 1,
 
1215
                                groove.x() + mid - 1, groove.y() + groove.height() - 3);
 
1216
                }
 
1217
            }
 
1218
            if (slider->subControls & SC_SliderTickmarks) {
 
1219
                QStyleOptionSlider tmpSlider = *slider;
 
1220
                tmpSlider.subControls = SC_SliderTickmarks;
 
1221
                QCommonStyle::drawComplexControl(control, &tmpSlider, painter, widget);
 
1222
            }
 
1223
 
 
1224
            if (slider->subControls & SC_SliderHandle) {
 
1225
                // 4444440
 
1226
                // 4333310
 
1227
                // 4322210
 
1228
                // 4322210
 
1229
                // 4322210
 
1230
                // 4322210
 
1231
                // *43210*
 
1232
                // **440**
 
1233
                // ***0***
 
1234
                const QColor c0 = slider->palette.shadow().color();
 
1235
                const QColor c1 = slider->palette.dark().color();
 
1236
                // const QColor c2 = g.button();
 
1237
                const QColor c3 = slider->palette.midlight().color();
 
1238
                const QColor c4 = slider->palette.dark().color();
 
1239
                QBrush handleBrush;
 
1240
 
 
1241
                if (slider->state & State_Enabled) {
 
1242
                    handleBrush = slider->palette.color(QPalette::Button);
 
1243
                } else {
 
1244
                    handleBrush = QBrush(slider->palette.color(QPalette::Button),
 
1245
                                         Qt::Dense4Pattern);
 
1246
                }
 
1247
 
 
1248
                int x = handle.x(), y = handle.y(),
 
1249
                   wi = handle.width(), he = handle.height();
 
1250
 
 
1251
                int x1 = x;
 
1252
                int x2 = x + wi - 1;
 
1253
                int y1 = y;
 
1254
                int y2 = y + he - 1;
 
1255
 
 
1256
                Qt::Orientation orient = slider->orientation;
 
1257
                bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
 
1258
                bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
 
1259
 
 
1260
                if (slider->state & State_HasFocus) {
 
1261
                    QStyleOptionFocusRect fropt;
 
1262
                    fropt.QStyleOption::operator=(*slider);
 
1263
                    fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
 
1264
                    drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
 
1265
                }
 
1266
                if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
 
1267
                    Qt::BGMode oldMode = painter->backgroundMode();
 
1268
                    painter->setBackgroundMode(Qt::OpaqueMode);
 
1269
                    QWindowsCEStylePrivate::drawWinCEButton(painter, QRect(x, y, wi, he), slider->palette, false,
 
1270
                                                            &handleBrush);
 
1271
                    painter->setBackgroundMode(oldMode);
 
1272
                    QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
1273
                    if (slider->state & State_Sunken)
 
1274
                      painter->fillRect(QRectF(x1 + 2, y1 + 2, x2 - x1 - 3, y2 - y1 - 3),fill);
 
1275
                    return;
 
1276
                }
 
1277
                QSliderDirection dir;
 
1278
                if (orient == Qt::Horizontal)
 
1279
                    if (tickAbove)
 
1280
                        dir = SlUp;
 
1281
                    else
 
1282
                        dir = SlDown;
 
1283
                else
 
1284
                    if (tickAbove)
 
1285
                        dir = SlLeft;
 
1286
                    else
 
1287
                        dir = SlRight;
 
1288
                QPolygon a;
 
1289
                int d = 0;
 
1290
                switch (dir) {
 
1291
                case SlUp:
 
1292
                    x2++;
 
1293
                    y1 = y1 + wi / 2;
 
1294
                    d =  (wi + 1) / 2 - 1;
 
1295
                    a.setPoints(5, x1, y1, x1, y2, x2, y2, x2, y1, x1 + d, y1 - d);
 
1296
                    break;
 
1297
                case SlDown:
 
1298
                    x2++;
 
1299
                    y2 = y2 - wi / 2;
 
1300
                    d =  (wi + 1) / 2 - 1;
 
1301
                    a.setPoints(5, x1, y1, x1, y2, x1 + d, y2+d, x2, y2, x2, y1);
 
1302
                    break;
 
1303
                case SlLeft:
 
1304
                    d =  (he + 1) / 2 - 1;
 
1305
                    x1 = x1 + he / 2;
 
1306
                    a.setPoints(5, x1, y1, x1 - d, y1 + d, x1, y2, x2, y2, x2, y1);
 
1307
                    y1--;
 
1308
                    break;
 
1309
                case SlRight:
 
1310
                    d =  (he + 1) / 2 - 1;
 
1311
                    x2 = x2 - he / 2;
 
1312
                    a.setPoints(5, x1, y1, x1, y2, x2, y2, x2 + d, y1 + d, x2, y1);
 
1313
                    y1--;
 
1314
                    break;
 
1315
                }
 
1316
                QBrush oldBrush = painter->brush();
 
1317
                painter->setPen(Qt::NoPen);
 
1318
                painter->setBrush(handleBrush);
 
1319
                Qt::BGMode oldMode = painter->backgroundMode();
 
1320
                painter->setBackgroundMode(Qt::OpaqueMode);
 
1321
                painter->drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
 
1322
                painter->drawPolygon(a);
 
1323
                QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
 
1324
                if (slider->state & State_Sunken)
 
1325
                  painter->fillRect(QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1),fill);
 
1326
                painter->setBrush(oldBrush);
 
1327
                painter->setBackgroundMode(oldMode);
 
1328
 
 
1329
                if (dir != SlUp) {
 
1330
                    painter->setPen(c4);
 
1331
                    painter->drawLine(x1, y1, x2, y1);
 
1332
                    painter->setPen(c3);
 
1333
                    painter->drawLine(x1, y1 + 1, x2, y1 + 1);
 
1334
                }
 
1335
                if (dir != SlLeft) {
 
1336
                    painter->setPen(c3);
 
1337
                    painter->drawLine(x1 + 1, y1 + 1, x1 + 1, y2);
 
1338
                    painter->setPen(c4);
 
1339
                    painter->drawLine(x1, y1, x1, y2);
 
1340
                }
 
1341
                if (dir != SlRight) {
 
1342
                    painter->setPen(c0);
 
1343
                    painter->drawLine(x2, y1, x2, y2);
 
1344
                    painter->setPen(c1);
 
1345
                    painter->drawLine(x2 - 1, y1 + 1, x2 - 1, y2 - 1);
 
1346
                }
 
1347
                if (dir != SlDown) {
 
1348
                    painter->setPen(c0);
 
1349
                    painter->drawLine(x1, y2, x2, y2);
 
1350
                    painter->setPen(c1);
 
1351
                    painter->drawLine(x1+1, y2 - 1, x2 - 1, y2 - 1);
 
1352
                }
 
1353
 
 
1354
               switch (dir) {
 
1355
                case SlUp:
 
1356
                    if (slider->state & State_Sunken)
 
1357
                      painter->fillRect(QRectF(x1 + 3, y1 - d + 2, x2 - x1 - 4,y1), fill);
 
1358
                    painter->setPen(c4);
 
1359
                    painter->drawLine(x1, y1, x1 + d, y1 - d);
 
1360
                    painter->setPen(c0);
 
1361
                    d = wi - d - 1;
 
1362
                    painter->drawLine(x2, y1, x2 - d, y1 - d);
 
1363
                    d--;
 
1364
                    painter->setPen(c3);
 
1365
                    painter->drawLine(x1 + 1, y1, x1 + 1 + d-1, y1 - d + 1);
 
1366
                    painter->setPen(c1);
 
1367
                    painter->drawLine(x2 - 1, y1, x2-1 - d, y1 - d);
 
1368
                    break;
 
1369
                case SlDown:
 
1370
                    if (slider->state & State_Sunken)
 
1371
                      painter->fillRect(QRectF(x1 + 3, y2 - d, x2 - x1 - 4,y2 - 8), fill);
 
1372
                    painter->setPen(c4);
 
1373
                    painter->drawLine(x1, y2, x1 + d, y2 + d);
 
1374
                    painter->setPen(c0);
 
1375
                    d = wi - d - 1;
 
1376
                    painter->drawLine(x2, y2, x2 - d, y2 + d);
 
1377
                    d--;
 
1378
                    painter->setPen(c3);
 
1379
                    painter->drawLine(x1 + 1, y2, x1 + 1 + d - 1, y2 + d - 1);
 
1380
                    painter->setPen(c1);
 
1381
                    painter->drawLine(x2 - 1, y2, x2 - 1 - d, y2 + d);
 
1382
                    break;
 
1383
                case SlLeft:
 
1384
                    if (slider->state & State_Sunken)
 
1385
                      painter->fillRect(QRectF(x1 - d + 2, y1 + 2, x1,y2 - y1 - 3), fill);
 
1386
                    painter->setPen(c4);
 
1387
                    painter->drawLine(x1, y1, x1 - d, y1 + d);
 
1388
                    painter->setPen(c0);
 
1389
                    d = he - d - 1;
 
1390
                    painter->drawLine(x1, y2, x1 - d, y2 - d);
 
1391
                    d--;
 
1392
                    painter->setPen(c3);
 
1393
                    painter->drawLine(x1, y1 + 1, x1 - d + 1, y1 + 1 + d - 1);
 
1394
                    painter->setPen(c1);
 
1395
                    painter->drawLine(x1, y2 - 1, x1 - d, y2 - 1 - d);
 
1396
                    break;
 
1397
                case SlRight:
 
1398
                    if (slider->state & State_Sunken)
 
1399
                      painter->fillRect(QRectF(x2 - d - 4, y1 + 2, x2 - 4, y2 - y1 - 3), fill);
 
1400
                    painter->setPen(c4);
 
1401
                    painter->drawLine(x2, y1, x2 + d, y1 + d);
 
1402
                    painter->setPen(c0);
 
1403
                    d = he - d - 1;
 
1404
                    painter->drawLine(x2, y2, x2 + d, y2 - d);
 
1405
                    d--;
 
1406
                    painter->setPen(c3);
 
1407
                    painter->drawLine(x2, y1 + 1, x2 + d - 1, y1 + 1 + d - 1);
 
1408
                    painter->setPen(c1);
 
1409
                    painter->drawLine(x2, y2 - 1, x2 + d, y2 - 1 - d);
 
1410
                    break;
 
1411
                }
 
1412
            }
 
1413
        }
 
1414
        break;
 
1415
#endif // QT_NO_SLIDER
 
1416
    case CC_ToolButton:
 
1417
        if (const QStyleOptionToolButton *toolbutton
 
1418
                = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
 
1419
            QRect button, menuarea;
 
1420
 
 
1421
#ifndef QT_NO_TOOLBAR
 
1422
            bool flat = !(widget ? qobject_cast<QToolBar*>(widget->parentWidget()) : 0);
 
1423
#else
 
1424
            bool flat = true;
 
1425
#endif
 
1426
 
 
1427
            button = subControlRect(control, toolbutton, SC_ToolButton, widget);
 
1428
            menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
 
1429
 
 
1430
            if (flat && (toolbutton->subControls & SC_ToolButtonMenu)) {
 
1431
                menuarea.setLeft(menuarea.left() - 4);
 
1432
                button.setRight(button.right() - 4);
 
1433
            }
 
1434
 
 
1435
            State bflags = toolbutton->state;
 
1436
 
 
1437
            if (bflags & State_AutoRaise)
 
1438
                if (!(bflags & State_MouseOver)) {
 
1439
                    bflags &= ~State_Raised;
 
1440
                }
 
1441
            State mflags = bflags;
 
1442
 
 
1443
            if (toolbutton->activeSubControls & SC_ToolButton)
 
1444
                bflags |= State_Sunken;
 
1445
            if (toolbutton->activeSubControls & SC_ToolButtonMenu)
 
1446
                mflags |= State_Sunken;
 
1447
 
 
1448
            QStyleOption tool(0);
 
1449
            tool.palette = toolbutton->palette;
 
1450
            if (toolbutton->subControls & SC_ToolButton) {
 
1451
                    tool.rect = button;
 
1452
                    tool.state = bflags;
 
1453
                    drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
1454
                }
 
1455
 
 
1456
            if (toolbutton->subControls & SC_ToolButtonMenu) {
 
1457
                tool.rect = menuarea;
 
1458
                tool.state = mflags;
 
1459
                tool.state = bflags;
 
1460
                drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
 
1461
 
 
1462
                if (!flat) {
 
1463
 
 
1464
                    //connect buttons
 
1465
                    painter->save();
 
1466
                    painter->setPen(tool.palette.button().color());
 
1467
                    painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() - 2, tool.rect.y() + tool.rect.height());
 
1468
                    painter->drawLine(tool.rect.x() - 1, tool.rect.y(), tool.rect.x() - 1, tool.rect.y() + tool.rect.height());
 
1469
                    painter->drawLine(tool.rect.x(), tool.rect.y(), tool.rect.x(), tool.rect.y() + tool.rect.height());
 
1470
                    painter->drawLine(tool.rect.x() + 1, tool.rect.y(), tool.rect.x() + 1, tool.rect.y() + tool.rect.height());
 
1471
 
 
1472
                    if (tool.state & State_Sunken)
 
1473
                    {
 
1474
                        painter->setPen(tool.palette.midlight().color());
 
1475
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 2,
 
1476
                            tool.rect.x() + 1, tool.rect.y() + tool.rect.height() -2 );
 
1477
                        painter->setPen(tool.palette.shadow().color());
 
1478
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1);
 
1479
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() + 1, tool.rect.y());
 
1480
                        painter->setPen(tool.palette.light().color());
 
1481
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1,
 
1482
                            tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1);
 
1483
                    }
 
1484
                    else
 
1485
                    {
 
1486
                        painter->setPen(tool.palette.dark().color());
 
1487
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y(),tool.rect.x() + 1, tool.rect.y());
 
1488
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y()+tool.rect.height() - 2,tool.rect.x() + 1,
 
1489
                            tool.rect.y() + tool.rect.height() - 2);
 
1490
                        painter->setPen(tool.palette.midlight().color());
 
1491
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1);
 
1492
                        painter->setPen(tool.palette.shadow().color());
 
1493
                        painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1,
 
1494
                            tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1);
 
1495
                    }
 
1496
                    painter->restore();
 
1497
                }
 
1498
 
 
1499
 
 
1500
                if (!flat) {
 
1501
                    tool.rect.adjust(-3,0,-3,0);
 
1502
                    painter->save();
 
1503
                    painter->setPen(tool.palette.button().color());
 
1504
                    if (tool.state & State_Sunken)
 
1505
                        painter->drawLine(tool.rect.x() + 2, tool.rect.y() + 10,
 
1506
                        tool.rect.x() + tool.rect.width(), tool.rect.y() + 10);
 
1507
                    else
 
1508
                        painter->drawLine(tool.rect.x() + 1, tool.rect.y() + 9, tool.rect.x() +
 
1509
                        tool.rect.width() - 1, tool.rect.y() + 9);
 
1510
                    painter->restore();
 
1511
                } else {
 
1512
                    tool.rect.adjust(-1,0,-1,0);
 
1513
                }
 
1514
 
 
1515
                drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
 
1516
            }
 
1517
 
 
1518
            if (toolbutton->state & State_HasFocus) {
 
1519
                QStyleOptionFocusRect fr;
 
1520
                fr.QStyleOption::operator=(*toolbutton);
 
1521
                fr.rect.adjust(3, 3, -3, -3);
 
1522
                if (toolbutton->features & QStyleOptionToolButton::Menu)
 
1523
                    fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
 
1524
                                                         toolbutton, widget), 0);
 
1525
                drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
 
1526
            }
 
1527
            QStyleOptionToolButton label = *toolbutton;
 
1528
            int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
 
1529
            label.rect = button.adjusted(fw, fw, -fw, -fw);
 
1530
            drawControl(CE_ToolButtonLabel, &label, painter, widget);
 
1531
        }
 
1532
        break;
 
1533
 
 
1534
#ifndef QT_NO_GROUPBOX
 
1535
    case CC_GroupBox:
 
1536
        if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
 
1537
            // Draw frame
 
1538
            painter->save();
 
1539
            QFont f = painter->font();
 
1540
            f.setBold(true);
 
1541
            painter->setFont(f);
 
1542
            QStyleOptionGroupBox groupBoxFont = *groupBox;
 
1543
            groupBoxFont.fontMetrics = QFontMetrics(f);
 
1544
            QRect textRect = subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
 
1545
            QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget);
 
1546
            if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
 
1547
                QStyleOptionFrameV2 frame;
 
1548
                frame.QStyleOption::operator=(*groupBox);
 
1549
                frame.features = groupBox->features;
 
1550
                frame.lineWidth = groupBox->lineWidth;
 
1551
                frame.midLineWidth = groupBox->midLineWidth;
 
1552
                frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
 
1553
                painter->save();
 
1554
 
 
1555
                QRegion region(groupBox->rect);
 
1556
                if (!groupBox->text.isEmpty()) {
 
1557
                    bool ltr = groupBox->direction == Qt::LeftToRight;
 
1558
                    QRect finalRect = checkBoxRect.united(textRect);
 
1559
                    if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
 
1560
                        finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
 
1561
                    region -= finalRect;
 
1562
                }
 
1563
                painter->setClipRegion(region);
 
1564
                drawPrimitive(PE_FrameGroupBox, &frame, painter, widget);
 
1565
                painter->restore();
 
1566
            }
 
1567
 
 
1568
            // Draw title
 
1569
            if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
 
1570
                QColor textColor = groupBox->textColor;
 
1571
                if (textColor.isValid())
 
1572
                    painter->setPen(textColor);
 
1573
                int alignment = int(groupBox->textAlignment);
 
1574
                if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
 
1575
                    alignment |= Qt::TextHideMnemonic;
 
1576
 
 
1577
                drawItemText(painter, textRect,  Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
 
1578
                             groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
 
1579
                             textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
 
1580
 
 
1581
                if (groupBox->state & State_HasFocus) {
 
1582
                    QStyleOptionFocusRect fropt;
 
1583
                    fropt.QStyleOption::operator=(*groupBox);
 
1584
                    fropt.rect = textRect;
 
1585
                    drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
 
1586
                }
 
1587
            }
 
1588
            // Draw checkbox
 
1589
            if (groupBox->subControls & SC_GroupBoxCheckBox) {
 
1590
                QStyleOptionButton box;
 
1591
                box.QStyleOption::operator=(*groupBox);
 
1592
                box.rect = checkBoxRect;
 
1593
                drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
 
1594
            }
 
1595
            painter->restore();
 
1596
        }
 
1597
        break;
 
1598
#endif //QT_NO_GROUPBOX
 
1599
#ifndef QT_NO_COMBOBOX
 
1600
    case CC_ComboBox:
 
1601
        if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
 
1602
            QBrush editBrush = cmb->palette.brush(QPalette::Base);
 
1603
            if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame)
 
1604
                QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, &editBrush);
 
1605
            else
 
1606
                painter->fillRect(option->rect, editBrush);
 
1607
 
 
1608
            if (cmb->subControls & SC_ComboBoxArrow) {
 
1609
                State flags = State_None;
 
1610
 
 
1611
                QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
 
1612
                if (cmb->activeSubControls == SC_ComboBoxArrow) {
 
1613
                    painter->setPen(cmb->palette.dark().color());
 
1614
                    painter->setBrush(cmb->palette.brush(QPalette::Button));
 
1615
                    painter->drawRect(ar.adjusted(0, 0, -1, -1));
 
1616
                    QWindowsCEStylePrivate::drawWinCEButton(painter, ar.adjusted(0, 0, -1, -1), option->palette, true,
 
1617
                    &cmb->palette.brush(QPalette::Button));
 
1618
                } else {
 
1619
                    // Make qDrawWinButton use the right colors for drawing the shade of the button
 
1620
 
 
1621
                    QWindowsCEStylePrivate::drawWinCEButton(painter, ar, option->palette, false,
 
1622
                                   &cmb->palette.brush(QPalette::Button));
 
1623
                }
 
1624
 
 
1625
                ar.adjust(2, 2, -2, -2);
 
1626
                if (option->state & State_Enabled)
 
1627
                    flags |= State_Enabled;
 
1628
 
 
1629
                if (cmb->activeSubControls == SC_ComboBoxArrow)
 
1630
                    flags |= State_Sunken;
 
1631
                QStyleOption arrowOpt(0);
 
1632
                arrowOpt.rect = ar;
 
1633
                arrowOpt.palette = cmb->palette;
 
1634
                arrowOpt.state = flags;
 
1635
                drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
 
1636
            }
 
1637
            if (cmb->subControls & SC_ComboBoxEditField) {
 
1638
                QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
 
1639
                if (cmb->state & State_HasFocus && !cmb->editable)
 
1640
                    painter->fillRect(re.x(), re.y(), re.width(), re.height(),
 
1641
                 cmb->palette.brush(QPalette::Highlight));
 
1642
                 if (cmb->state & State_HasFocus) {
 
1643
                    painter->setPen(cmb->palette.highlightedText().color());
 
1644
                    painter->setBackground(cmb->palette.highlight());
 
1645
                 } else {
 
1646
                    painter->setPen(cmb->palette.text().color());
 
1647
                    painter->setBackground(cmb->palette.background());
 
1648
                 }
 
1649
                 if (cmb->state & State_HasFocus && !cmb->editable) {
 
1650
                    QStyleOptionFocusRect focus;
 
1651
                    focus.QStyleOption::operator=(*cmb);
 
1652
                    focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
 
1653
                    focus.state |= State_FocusAtBorder;
 
1654
                    focus.backgroundColor = cmb->palette.highlight().color();
 
1655
                    drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
 
1656
               }
 
1657
            }
 
1658
        }
 
1659
        break;
 
1660
#endif // QT_NO_COMBOBOX
 
1661
#ifndef QT_NO_SPINBOX
 
1662
    case CC_SpinBox:
 
1663
        if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
 
1664
            QStyleOptionSpinBox copy = *sb;
 
1665
            PrimitiveElement pe;
 
1666
 
 
1667
            if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
 
1668
                QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
 
1669
                QWindowsCEStylePrivate::drawWinCEPanel(painter, r, option->palette, true);
 
1670
            }
 
1671
            QPalette shadePal(option->palette);
 
1672
            shadePal.setColor(QPalette::Button, option->palette.light().color());
 
1673
            shadePal.setColor(QPalette::Light, option->palette.button().color());
 
1674
 
 
1675
            bool reverse = QApplication::layoutDirection() == Qt::RightToLeft;
 
1676
 
 
1677
            if (sb->subControls & SC_SpinBoxUp) {
 
1678
                copy.subControls = SC_SpinBoxUp;
 
1679
                QPalette pal2 = sb->palette;
 
1680
                if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
 
1681
                    pal2.setCurrentColorGroup(QPalette::Disabled);
 
1682
                    copy.state &= ~State_Enabled;
 
1683
                }
 
1684
                copy.palette = pal2;
 
1685
                if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
 
1686
                    copy.state |= State_On;
 
1687
                    copy.state |= State_Sunken;
 
1688
                } else {
 
1689
                    copy.state |= State_Raised;
 
1690
                    copy.state &= ~State_Sunken;
 
1691
                }
 
1692
                if (reverse)
 
1693
                    pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
 
1694
                    : PE_IndicatorSpinDown);
 
1695
                else
 
1696
                    pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
 
1697
                    : PE_IndicatorSpinUp);
 
1698
                copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
 
1699
                QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, option->palette, copy.state & (State_Sunken | State_On),
 
1700
                                &copy.palette.brush(QPalette::Button));
 
1701
                copy.rect.adjust(3, 0, -4, 0);
 
1702
                drawPrimitive(pe, &copy, painter, widget);
 
1703
            }
 
1704
            if (sb->subControls & SC_SpinBoxDown) {
 
1705
                copy.subControls = SC_SpinBoxDown;
 
1706
                copy.state = sb->state;
 
1707
                QPalette pal2 = sb->palette;
 
1708
                if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
 
1709
                    pal2.setCurrentColorGroup(QPalette::Disabled);
 
1710
                    copy.state &= ~State_Enabled;
 
1711
                }
 
1712
                copy.palette = pal2;
 
1713
 
 
1714
                if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
 
1715
                    copy.state |= State_On;
 
1716
                    copy.state |= State_Sunken;
 
1717
                } else {
 
1718
                    copy.state |= State_Raised;
 
1719
                    copy.state &= ~State_Sunken;
 
1720
                }
 
1721
                if (reverse)
 
1722
                    pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
 
1723
                    : PE_IndicatorSpinUp);
 
1724
                else
 
1725
                    pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
 
1726
                    : PE_IndicatorSpinDown);
 
1727
                copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
 
1728
                QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
 
1729
                                &copy.palette.brush(QPalette::Button));
 
1730
 
 
1731
                copy.rect.adjust(3, 0, -4, 0);
 
1732
                if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown) {
 
1733
                    copy.rect = copy.rect.adjusted(1, 1, -1, -1);
 
1734
                    drawPrimitive(pe, &copy, painter, widget);
 
1735
                }
 
1736
                else {
 
1737
                    drawPrimitive(pe, &copy, painter, widget);
 
1738
                }
 
1739
                if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
 
1740
                    QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget);
 
1741
                    painter->save();
 
1742
                    painter->setPen(option->palette.light().color());
 
1743
                    painter->drawLine(r.x() + 1 + r.width(), r.y() - 2, r.x() + 1 + r.width(), r.y() + r.height() + 1);
 
1744
                    painter->setPen(option->palette.midlight().color());
 
1745
                    painter->drawLine(r.x() + r.width(), r.y() - 1, r.x() + r.width(), r.y() + r.height());
 
1746
                    painter->restore();
 
1747
                }
 
1748
            }
 
1749
        }
 
1750
        break;
 
1751
#endif // QT_NO_SPINBOX
 
1752
 
 
1753
    default:
 
1754
        QWindowsStyle::drawComplexControl(control, option, painter, widget);
 
1755
        break;
 
1756
    }
 
1757
}
 
1758
 
 
1759
void QWindowsCEStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
 
1760
                          bool enabled, const QString& text, QPalette::ColorRole textRole) const {
 
1761
    if (text.isEmpty())
 
1762
        return;
 
1763
    QPen savedPen;
 
1764
    if (textRole != QPalette::NoRole) {
 
1765
        savedPen = painter->pen();
 
1766
        painter->setPen(pal.color(textRole));
 
1767
    }
 
1768
    if (!enabled) {
 
1769
            QPen pen = painter->pen();
 
1770
            painter->setPen(pal.light().color());
 
1771
            //painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
 
1772
            painter->setPen(pen);
 
1773
        }
 
1774
    painter->drawText(rect, alignment, text);
 
1775
    if (textRole != QPalette::NoRole)
 
1776
        painter->setPen(savedPen);
 
1777
}
 
1778
 
 
1779
 
 
1780
QSize QWindowsCEStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
 
1781
                                        const QSize &size, const QWidget *widget) const {
 
1782
    QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
 
1783
    switch (type) {
 
1784
    case CT_PushButton:
 
1785
       if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
 
1786
            newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
 
1787
            int w = newSize.width(),
 
1788
                h = newSize.height();
 
1789
            int defwidth = 0;
 
1790
            if (btn->features & QStyleOptionButton::AutoDefaultButton)
 
1791
                defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
 
1792
            if (w < 75 + defwidth && btn->icon.isNull())
 
1793
                w = 75 + defwidth;
 
1794
            if (h < 23 + defwidth)
 
1795
                h = 23 + defwidth;
 
1796
            newSize = QSize(w+14, h);
 
1797
        }
 
1798
        break;
 
1799
 
 
1800
    case CT_RadioButton:
 
1801
    case CT_CheckBox:
 
1802
        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
 
1803
            bool isRadio = (type == CT_RadioButton);
 
1804
            QRect irect = visualRect(btn->direction, btn->rect,
 
1805
                                     subElementRect(isRadio ? SE_RadioButtonIndicator
 
1806
                                                            : SE_CheckBoxIndicator, btn, widget));
 
1807
            int h = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
 
1808
                                        : PM_IndicatorHeight, btn, widget);
 
1809
            int margins = (!btn->icon.isNull() && btn->text.isEmpty()) ? 0 : 10;
 
1810
            newSize += QSize(irect.right() + margins, 4);
 
1811
            newSize.setHeight(qMax(newSize.height(), h));
 
1812
        }
 
1813
        break;
 
1814
    case CT_ComboBox:
 
1815
        if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
 
1816
            int fw = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, option, widget) * 2 : 0;
 
1817
            newSize = QSize(newSize.width() + fw -1, qMax(24, newSize.height() + fw-1));
 
1818
        }
 
1819
        break;
 
1820
#ifndef QT_NO_SPINBOX
 
1821
    case CT_SpinBox:
 
1822
        if (const QStyleOptionSpinBox *spnb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
 
1823
            int fw = spnb->frame ? pixelMetric(PM_SpinBoxFrameWidth, option, widget) * 2 : 0;
 
1824
            newSize = QSize(newSize.width() + fw - 5, newSize.height() + fw - 6);
 
1825
        }
 
1826
        break;
 
1827
#endif
 
1828
    case CT_LineEdit:
 
1829
        newSize += QSize(0,1);
 
1830
        break;
 
1831
    case CT_MenuBarItem:
 
1832
        newSize += QSize(5, 1);
 
1833
        break;
 
1834
    case CT_MenuItem:
 
1835
        newSize += QSize(0, -2);
 
1836
        break;
 
1837
    case CT_MenuBar:
 
1838
        newSize += QSize(0, -1);
 
1839
        break;
 
1840
    case CT_ToolButton:
 
1841
        if (const QStyleOptionToolButton *b = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
 
1842
          if (b->toolButtonStyle != Qt::ToolButtonIconOnly)
 
1843
            newSize = QSize(newSize.width() + 1, newSize.height() - 1);
 
1844
          else
 
1845
            newSize = QSize(newSize.width() + 1, newSize.height());
 
1846
        }
 
1847
        break;
 
1848
 
 
1849
    default:
 
1850
        break;
 
1851
    }
 
1852
    return newSize;
 
1853
}
 
1854
 
 
1855
QRect QWindowsCEStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const {
 
1856
    QRect rect = QWindowsStyle::subElementRect(element, option, widget);
 
1857
    switch (element) {
 
1858
#ifndef QT_NO_COMBOBOX
 
1859
    case SE_ComboBoxFocusRect:
 
1860
        if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
 
1861
            int margin = cb->frame ? 3 : 0;
 
1862
            rect.setRect(margin, margin, option->rect.width() - 2*margin - 20, option->rect.height() - 2*margin);
 
1863
            rect = visualRect(option->direction, option->rect, rect);
 
1864
        }
 
1865
        break;
 
1866
#endif // QT_NO_COMBOBOX
 
1867
    default:
 
1868
        break;
 
1869
    }
 
1870
    return rect;
 
1871
}
 
1872
 
 
1873
QRect QWindowsCEStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
 
1874
                                      SubControl subControl, const QWidget *widget) const {
 
1875
    QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
 
1876
    switch (control) {
 
1877
#ifndef QT_NO_SLIDER
 
1878
        case CC_Slider:
 
1879
        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
 
1880
            int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget);
 
1881
            int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
 
1882
 
 
1883
            switch (subControl) {
 
1884
            case SC_SliderHandle: {
 
1885
                int sliderPos = 0;
 
1886
                int len = pixelMetric(PM_SliderLength, slider, widget);
 
1887
                bool horizontal = slider->orientation == Qt::Horizontal;
 
1888
                sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
 
1889
                                                    slider->sliderPosition,
 
1890
                                                    (horizontal ? slider->rect.width()
 
1891
                                                                : slider->rect.height()) - len,
 
1892
                                                    slider->upsideDown);
 
1893
                if (horizontal)
 
1894
                    rect.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
 
1895
                else
 
1896
                    rect.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
 
1897
                break; }
 
1898
            default:
 
1899
                break;
 
1900
            }
 
1901
            rect = visualRect(slider->direction, slider->rect, rect);
 
1902
        }
 
1903
        break;
 
1904
#endif //QT_NO_SLIDER
 
1905
#ifndef QT_NO_COMBOBOX
 
1906
    case CC_ComboBox:
 
1907
        if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
 
1908
        int x = cb->rect.x(),
 
1909
            y = cb->rect.y(),
 
1910
            wi = cb->rect.width(),
 
1911
            he = cb->rect.height();
 
1912
        int xpos = x;
 
1913
        int margin = cb->frame ? 3 : 0;
 
1914
        int bmarg = cb->frame ? 2 : 0;
 
1915
        xpos += wi - (he - 2*bmarg) - bmarg;
 
1916
        switch (subControl) {
 
1917
          case SC_ComboBoxArrow:
 
1918
            rect.setRect(xpos, y + bmarg, he - 2*bmarg, he - 2*bmarg);
 
1919
            break;
 
1920
           case SC_ComboBoxEditField:
 
1921
                rect.setRect(x + margin, y + margin, wi - 2 * margin - (he - 2*bmarg), he - 2 * margin);
 
1922
                break;
 
1923
            case SC_ComboBoxListBoxPopup:
 
1924
                rect = cb->rect;
 
1925
                break;
 
1926
            case SC_ComboBoxFrame:
 
1927
                rect = cb->rect;
 
1928
                break;
 
1929
        default:
 
1930
        break;
 
1931
        }
 
1932
        rect = visualRect(cb->direction, cb->rect, rect);
 
1933
    }
 
1934
#endif //QT_NO_COMBOBOX
 
1935
#ifndef QT_NO_SPINBOX
 
1936
    case CC_SpinBox:
 
1937
        if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
 
1938
            QSize bs;
 
1939
            int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
 
1940
            bs.setWidth(qMax(18, (spinbox->rect.height() / 2 - fw + 1)));
 
1941
            // 1.6 -approximate golden mean
 
1942
            bs.setHeight(qMax(18, qMin((bs.height() * 8 / 5), (spinbox->rect.width() / 4))));
 
1943
            bs = bs.expandedTo(QApplication::globalStrut());
 
1944
            int y = fw;
 
1945
            int x, lx, rx;
 
1946
            x = spinbox->rect.width() - y - bs.width() * 2;
 
1947
            lx = fw;
 
1948
            rx = x - fw;
 
1949
          switch (subControl) {
 
1950
          case SC_SpinBoxUp:
 
1951
                rect = QRect(x + bs.width(), y, bs.width(), bs.height());
 
1952
                break;
 
1953
          case SC_SpinBoxDown:
 
1954
                rect = QRect(x, y , bs.width(), bs.height());
 
1955
                break;
 
1956
          case SC_SpinBoxEditField:
 
1957
                if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
 
1958
                    rect = QRect(lx, fw, spinbox->rect.width() - 2*fw - 2, spinbox->rect.height() - 2*fw);
 
1959
                } else {
 
1960
                    rect = QRect(lx, fw, rx-2, spinbox->rect.height() - 2*fw);
 
1961
                }
 
1962
                break;
 
1963
          case SC_SpinBoxFrame:
 
1964
                rect = spinbox->rect;
 
1965
          default:
 
1966
                break;
 
1967
          }
 
1968
          rect = visualRect(spinbox->direction, spinbox->rect, rect);
 
1969
        }
 
1970
        break;
 
1971
#endif // Qt_NO_SPINBOX
 
1972
#ifndef QT_NO_GROUPBOX
 
1973
    case CC_GroupBox: {
 
1974
        if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
 
1975
            switch (subControl) {
 
1976
            case SC_GroupBoxFrame:
 
1977
                // FALL THROUGH
 
1978
            case SC_GroupBoxContents: {
 
1979
                int topMargin = 0;
 
1980
                int topHeight = 0;
 
1981
                int bottomMargin = 0;
 
1982
                int noLabelMargin = 0;
 
1983
                QRect frameRect = groupBox->rect;
 
1984
                int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
 
1985
                if (groupBox->text.size()) {
 
1986
                    topHeight = groupBox->fontMetrics.height();
 
1987
                    if (verticalAlignment & Qt::AlignVCenter)
 
1988
                        topMargin = topHeight / 2;
 
1989
                    else if (verticalAlignment & Qt::AlignTop)
 
1990
                        topMargin = -topHeight/2;
 
1991
                }
 
1992
                else {
 
1993
                  topHeight = groupBox->fontMetrics.height();
 
1994
                  noLabelMargin = topHeight / 2;
 
1995
                  if (verticalAlignment & Qt::AlignVCenter) {
 
1996
                        topMargin = topHeight / 4 - 4;
 
1997
                        bottomMargin = topHeight / 4 - 4;
 
1998
                  }
 
1999
                  else if (verticalAlignment & Qt::AlignTop) {
 
2000
                        topMargin = topHeight/2 - 4;
 
2001
                        bottomMargin = topHeight/2 - 4;
 
2002
                  }
 
2003
                }
 
2004
 
 
2005
                if (subControl == SC_GroupBoxFrame) {
 
2006
                    frameRect.setTop(topMargin);
 
2007
                    frameRect.setBottom(frameRect.height() + bottomMargin);
 
2008
                    rect = frameRect;
 
2009
                    break;
 
2010
                }
 
2011
 
 
2012
                int frameWidth = 0;
 
2013
                if ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)
 
2014
                    frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
 
2015
                rect = frameRect.adjusted(frameWidth, frameWidth + topHeight, -frameWidth, -frameWidth - noLabelMargin);
 
2016
                break;
 
2017
            }
 
2018
            case SC_GroupBoxCheckBox:
 
2019
                // FALL THROUGH
 
2020
            case SC_GroupBoxLabel: {
 
2021
                QFontMetrics fontMetrics = groupBox->fontMetrics;
 
2022
                int h = fontMetrics.height();
 
2023
                int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
 
2024
                int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8;
 
2025
                rect = groupBox->rect.adjusted(marg, 0, -marg, 0);
 
2026
                rect.setHeight(h);
 
2027
 
 
2028
                int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget);
 
2029
                int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, option, widget) - 1;
 
2030
                bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
 
2031
                int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
 
2032
 
 
2033
                // Adjusted rect for label + indicatorWidth + indicatorSpace
 
2034
                QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
 
2035
                                              QSize(tw + checkBoxSize, h), rect);
 
2036
 
 
2037
                // Adjust totalRect if checkbox is set
 
2038
                if (hasCheckBox) {
 
2039
                    bool ltr = groupBox->direction == Qt::LeftToRight;
 
2040
                    int left = 0;
 
2041
                    // Adjust for check box
 
2042
                    if (subControl == SC_GroupBoxCheckBox) {
 
2043
                        int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget);
 
2044
                        left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
 
2045
                        int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
 
2046
                        totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
 
2047
                    // Adjust for label
 
2048
                    } else {
 
2049
                        left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
 
2050
                        totalRect.setRect(left, totalRect.top(),
 
2051
                                          totalRect.width() - checkBoxSize, totalRect.height());
 
2052
                    }
 
2053
                }
 
2054
                rect = totalRect;
 
2055
                break;
 
2056
            }
 
2057
            default:
 
2058
                break;
 
2059
            }
 
2060
        }
 
2061
        break;
 
2062
    }
 
2063
#endif // QT_NO_GROUPBOX
 
2064
    default:
 
2065
        break;
 
2066
    }
 
2067
    return rect;
 
2068
}
 
2069
 
 
2070
QStyle::SubControl QWindowsCEStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
 
2071
                                                          const QPoint &pos, const QWidget *widget) const {
 
2072
    /*switch (control) {
 
2073
    default:
 
2074
        break;
 
2075
    }*/
 
2076
    return QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
 
2077
}
 
2078
 
 
2079
 
 
2080
QPalette QWindowsCEStyle::standardPalette() const {
 
2081
    QPalette palette (Qt::black,QColor(198, 195, 198), QColor(222, 223, 222 ),
 
2082
                      QColor(132, 130, 132), QColor(198, 195, 198) ,  Qt::black,  Qt::white, Qt::white, QColor(198, 195, 198));
 
2083
    palette.setColor(QPalette::Window, QColor(198, 195, 198));
 
2084
    palette.setColor(QPalette::Base, Qt::white);
 
2085
    palette.setColor(QPalette::Button, QColor(198, 195, 198));
 
2086
    palette.setColor(QPalette::Highlight, QColor(0, 0, 132));
 
2087
    palette.setColor(QPalette::Light, Qt::white);
 
2088
    palette.setColor(QPalette::Midlight, QColor(222, 223, 222 ));
 
2089
    palette.setColor(QPalette::Dark, QColor(132, 130, 132));
 
2090
    palette.setColor(QPalette::Mid, QColor(132, 130, 132));
 
2091
    palette.setColor(QPalette::Shadow, QColor(0, 0, 0));
 
2092
    palette.setColor(QPalette::BrightText, QColor(33, 162, 33)); //color for ItemView checked indicator (arrow)
 
2093
    palette.setColor(QPalette::Link, QColor(24,81,132)); // color for the box around the ItemView indicator
 
2094
 
 
2095
    return palette;
 
2096
}
 
2097
 
 
2098
void QWindowsCEStyle::polish(QApplication *app) {
 
2099
    QWindowsStyle::polish(app);
 
2100
}
 
2101
 
 
2102
void QWindowsCEStyle::polish(QWidget *widget) {
 
2103
    QWindowsStyle::polish(widget);
 
2104
}
 
2105
 
 
2106
void QWindowsCEStyle::polish(QPalette &palette) {
 
2107
    QWindowsStyle::polish(palette);
 
2108
}
 
2109
 
 
2110
int QWindowsCEStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const {
 
2111
    int ret;
 
2112
 
 
2113
    switch (pm) {
 
2114
    case PM_DefaultFrameWidth:
 
2115
        ret = 1;
 
2116
        break;
 
2117
 
 
2118
    case PM_MenuBarHMargin:
 
2119
        ret = 2;
 
2120
        break;
 
2121
    case PM_MenuBarVMargin:
 
2122
        ret = 2;
 
2123
        break;
 
2124
    /*case PM_MenuBarItemSpacing:
 
2125
        ret = 2;
 
2126
        break;*/
 
2127
 
 
2128
    case PM_MenuButtonIndicator:
 
2129
        ret = 10;
 
2130
        break;
 
2131
 
 
2132
    case PM_SpinBoxFrameWidth:
 
2133
        ret = 2;
 
2134
        break;
 
2135
    case PM_ButtonDefaultIndicator:
 
2136
    case PM_ButtonShiftHorizontal:
 
2137
    case PM_ButtonShiftVertical:
 
2138
        ret = 1;
 
2139
        break;
 
2140
#ifndef QT_NO_TABBAR
 
2141
    case PM_TabBarTabShiftHorizontal:
 
2142
        ret = 0;
 
2143
        break;
 
2144
    case PM_TabBarTabShiftVertical:
 
2145
        ret = 6;
 
2146
        break;
 
2147
#endif
 
2148
    case PM_MaximumDragDistance:
 
2149
        ret = 60;
 
2150
        break;
 
2151
 
 
2152
      case PM_IndicatorWidth:
 
2153
        ret = windowsCEIndicatorSize;
 
2154
        break;
 
2155
 
 
2156
    case PM_IndicatorHeight:
 
2157
        ret = windowsCEIndicatorSize;
 
2158
        break;
 
2159
 
 
2160
    case PM_ExclusiveIndicatorWidth:
 
2161
        ret = windowsCEExclusiveIndicatorSize;
 
2162
        break;
 
2163
 
 
2164
    case PM_ExclusiveIndicatorHeight:
 
2165
        ret = windowsCEExclusiveIndicatorSize;;
 
2166
        break;
 
2167
 
 
2168
#ifndef QT_NO_SLIDER
 
2169
    case PM_SliderLength:
 
2170
        ret = 12;
 
2171
        break;
 
2172
    case PM_SliderThickness:
 
2173
        ret = windowsCESliderThickness;
 
2174
        break;
 
2175
 
 
2176
     case PM_TabBarScrollButtonWidth:
 
2177
        ret = 18;
 
2178
        break;
 
2179
 
 
2180
        // Returns the number of pixels to use for the business part of the
 
2181
        // slider (i.e., the non-tickmark portion). The remaining space is shared
 
2182
        // equally between the tickmark regions.
 
2183
    case PM_SliderControlThickness:
 
2184
        if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
 
2185
            int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
 
2186
            int ticks = sl->tickPosition;
 
2187
            int n = 0;
 
2188
            if (ticks & QSlider::TicksAbove)
 
2189
                ++n;
 
2190
            if (ticks & QSlider::TicksBelow)
 
2191
                ++n;
 
2192
            if (!n) {
 
2193
                ret = space;
 
2194
                break;
 
2195
            }
 
2196
            int thick = 12;
 
2197
            if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
 
2198
                thick += pixelMetric(PM_SliderLength, sl, widget) / 4;
 
2199
 
 
2200
            space -= thick;
 
2201
            if (space > 0)
 
2202
                thick += (space * 2) / (n + 2);
 
2203
            ret = thick;
 
2204
        } else {
 
2205
            ret = 0;
 
2206
        }
 
2207
        break;
 
2208
#endif // QT_NO_SLIDER
 
2209
 
 
2210
#ifndef QT_NO_MENU
 
2211
 
 
2212
    case PM_SmallIconSize:
 
2213
        ret = windowsCEIconSize;
 
2214
        break;
 
2215
    case PM_ButtonMargin:
 
2216
        ret = 6;
 
2217
        break;
 
2218
 
 
2219
    case PM_LargeIconSize:
 
2220
        ret = 32;
 
2221
        break;
 
2222
 
 
2223
    case PM_IconViewIconSize:
 
2224
        ret = pixelMetric(PM_LargeIconSize, opt, widget);
 
2225
        break;
 
2226
 
 
2227
    case PM_ToolBarIconSize:
 
2228
        ret = windowsCEIconSize;
 
2229
        break;
 
2230
    case PM_DockWidgetTitleMargin:
 
2231
        ret = 2;
 
2232
        break;
 
2233
#if defined(Q_WS_WIN)
 
2234
//    case PM_DockWidgetFrameWidth:
 
2235
//        ret = GetSystemMetrics(SM_CXFRAME);
 
2236
//        break;
 
2237
#else
 
2238
    case PM_DockWidgetFrameWidth:
 
2239
        ret = 4;
 
2240
        break;
 
2241
#endif // Q_WS_WIN
 
2242
    break;
 
2243
 
 
2244
#endif // QT_NO_MENU
 
2245
 
 
2246
   case PM_TitleBarHeight:
 
2247
          ret = 30;
 
2248
        break;
 
2249
    case PM_ScrollBarExtent:
 
2250
        ret = 19;
 
2251
        break;
 
2252
    case PM_SplitterWidth:
 
2253
        ret = qMax(4, QApplication::globalStrut().width());
 
2254
        break;
 
2255
 
 
2256
#if defined(Q_WS_WIN)
 
2257
    case PM_MDIFrameWidth:
 
2258
        ret = 3;
 
2259
        break;
 
2260
#endif
 
2261
    case PM_ToolBarItemMargin:
 
2262
        ret = 1;
 
2263
        break;
 
2264
    case PM_ToolBarItemSpacing:
 
2265
        ret = 0;
 
2266
        break;
 
2267
    case PM_ToolBarHandleExtent:
 
2268
        ret = 10;
 
2269
        break;
 
2270
    case PM_ButtonIconSize:
 
2271
        ret = 22;
 
2272
        break;
 
2273
    default:
 
2274
        ret = QWindowsStyle::pixelMetric(pm, opt, widget);
 
2275
        break;
 
2276
    }
 
2277
    return ret;
 
2278
}
 
2279
 
 
2280
QPixmap QWindowsCEStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
 
2281
                                      const QWidget *widget) const {
 
2282
#ifndef QT_NO_IMAGEFORMAT_XPM
 
2283
    /*switch (standardPixmap) {
 
2284
 
 
2285
    default:
 
2286
        break;
 
2287
    }*/
 
2288
#endif //QT_NO_IMAGEFORMAT_XPM
 
2289
    return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
 
2290
}
 
2291
 
 
2292
int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
 
2293
                             QStyleHintReturn *returnData) const {
 
2294
    int ret;
 
2295
    switch (hint) {
 
2296
    case SH_TabBar_ElideMode:
 
2297
        ret = Qt::ElideMiddle;
 
2298
        break;
 
2299
    case SH_EtchDisabledText:
 
2300
        ret = false;
 
2301
        break;
 
2302
    case SH_RequestSoftwareInputPanel:
 
2303
        ret = RSIP_OnMouseClick;
 
2304
        break;
 
2305
    default:
 
2306
        ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
 
2307
        break;
 
2308
    }
 
2309
    return ret;
 
2310
}
 
2311
 
 
2312
void QWindowsCEStylePrivate::drawWinShades(QPainter *p,
 
2313
                           int x, int y, int w, int h,
 
2314
                           const QColor &c1, const QColor &c2,
 
2315
                           const QColor &c3, const QColor &c4,
 
2316
                           const QBrush *fill) {
 
2317
    if (w < 2 || h < 2)                        // can't do anything with that
 
2318
        return;
 
2319
    QPen oldPen = p->pen();
 
2320
    QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
 
2321
    p->setPen(c1);
 
2322
    p->drawPolyline(a, 3);
 
2323
    QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
 
2324
    p->setPen(c2);
 
2325
    p->drawPolyline(b, 3);
 
2326
    if (w > 4 && h > 4) {
 
2327
        QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
 
2328
        p->setPen(c3);
 
2329
        p->drawPolyline(c, 3);
 
2330
        QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
 
2331
        p->setPen(c4);
 
2332
        p->drawPolyline(d, 3);
 
2333
        if (fill)
 
2334
            p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
 
2335
    }
 
2336
    p->setPen(oldPen);
 
2337
}
 
2338
 
 
2339
void QWindowsCEStylePrivate::drawWinCEShades(QPainter *p,
 
2340
                           int x, int y, int w, int h,
 
2341
                           const QColor &c1, const QColor &c2,
 
2342
                           const QColor &c3, const QColor &c4,
 
2343
                           const QBrush *fill) {
 
2344
    if (w < 2 || h < 2)                        // can't do anything with that
 
2345
        return;
 
2346
    QPen oldPen = p->pen();
 
2347
    QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
 
2348
    p->setPen(c2);
 
2349
    p->drawPolyline(b, 3);
 
2350
    if (w > 4 && h > 4) {
 
2351
        QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
 
2352
        p->setPen(c3);
 
2353
        p->drawPolyline(c, 3);
 
2354
        QPoint d[5] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y), QPoint(x, y), QPoint(x, y+h-2) };
 
2355
        p->setPen(c4);
 
2356
        p->drawPolyline(d, 5);
 
2357
        if (fill)
 
2358
            p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
 
2359
    }
 
2360
    QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
 
2361
    p->setPen(c1);
 
2362
    p->drawPolyline(a, 3);
 
2363
    p->setPen(oldPen);
 
2364
}
 
2365
 
 
2366
void QWindowsCEStylePrivate::drawWinCEShadesSunken(QPainter *p,
 
2367
                           int x, int y, int w, int h,
 
2368
                           const QColor &c1, const QColor &c2,
 
2369
                           const QColor &c3, const QColor &c4,
 
2370
                           const QBrush *fill) {
 
2371
    if (w < 2 || h < 2)                        // can't do anything with that
 
2372
        return;
 
2373
    QPen oldPen = p->pen();
 
2374
 
 
2375
    QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
 
2376
    p->setPen(c2);
 
2377
    p->drawPolyline(b, 3);
 
2378
    if (w > 4 && h > 4) {
 
2379
        QPoint d[3] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y) };
 
2380
        p->setPen(c4);
 
2381
        p->drawPolyline(d, 3);
 
2382
        QPoint c[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
 
2383
        p->setPen(c3);
 
2384
        p->drawPolyline(c, 3);
 
2385
        if (fill)
 
2386
            p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
 
2387
    }
 
2388
    QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
 
2389
    p->setPen(c1);
 
2390
    p->drawPolyline(a, 3);
 
2391
    p->setPen(oldPen);
 
2392
}
 
2393
 
 
2394
 
 
2395
void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, int x, int y, int w, int h,
 
2396
                     const QPalette &pal, bool sunken,
 
2397
                     const QBrush *fill) {
 
2398
    if (sunken)
 
2399
        drawWinCEShadesSunken(p, x, y, w, h,
 
2400
                       pal.shadow().color(), pal.light().color(), pal.shadow().color(),
 
2401
                       pal.midlight().color(), fill);
 
2402
    else
 
2403
        drawWinCEShades(p, x, y, w, h,
 
2404
                       pal.midlight().color(), pal.shadow().color(), pal.button().color(),
 
2405
                       pal.dark().color(), fill);
 
2406
}
 
2407
 
 
2408
void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, int x, int y, int w, int h,
 
2409
                    const QPalette &pal, bool        sunken,
 
2410
                    const QBrush *fill) {
 
2411
    if (sunken)
 
2412
        drawWinShades(p, x, y, w, h,
 
2413
                        pal.dark().color(), pal.light().color(), pal.shadow().color(),
 
2414
                       pal.midlight().color(), fill);
 
2415
    else
 
2416
        drawWinShades(p, x, y, w, h,
 
2417
                       pal.light().color(), pal.shadow().color(), pal.button().color(),
 
2418
                       pal.midlight().color(), fill);
 
2419
}
 
2420
 
 
2421
void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, const QRect &r,
 
2422
                     const QPalette &pal, bool sunken, const QBrush *fill) {
 
2423
    drawWinCEButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
 
2424
}
 
2425
 
 
2426
void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, const QRect &r,
 
2427
                    const QPalette &pal, bool sunken, const QBrush *fill) {
 
2428
    drawWinCEPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
 
2429
}
 
2430
 
 
2431
QT_END_NAMESPACE
 
2432
 
 
2433
#endif // QT_NO_STYLE_WINDOWSCE