File: windowsmodernstyle.h

package info (click to toggle)
fraqtive 0.4.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 988 kB
  • ctags: 1,249
  • sloc: cpp: 8,387; sh: 103; makefile: 45
file content (118 lines) | stat: -rw-r--r-- 3,629 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**************************************************************************
* This file is part of the Fraqtive program
* Copyright (C) 2004-2008 Michał Męciński
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This code is partially based on the QtDotNet Style, a Qt Solutions
* component, licensed under the GNU General Public License.
* Copyright (C) 2003-2007 Trolltech ASA.
**************************************************************************/

#ifndef WINDOWSMODERNSTYLE_H
#define WINDOWSMODERNSTYLE_H

#include <QtGlobal>

#if !defined( Q_WS_WIN ) || ( QT_VERSION < 0x040300 ) || defined( QT_NO_STYLE_WINDOWSVISTA )
#define NO_STYLE_WINDOWSMODERN
#endif

#if !defined( NO_STYLE_WINDOWSMODERN )

#include <QWindowsVistaStyle>

class WindowsModernStyle : public QWindowsVistaStyle
{
    Q_OBJECT
public:
    WindowsModernStyle();
    ~WindowsModernStyle();

public: // overrides
    void polish( QApplication* application );
    void unpolish( QApplication* application );

    void polish( QPalette& palette );

    void polish( QWidget* widget );
    void unpolish( QWidget* widget );

    int pixelMetric( PixelMetric metric, const QStyleOption* option, const QWidget* widget ) const;

    QSize sizeFromContents( ContentsType type, const QStyleOption* option,
        const QSize& contentsSize, const QWidget* widget ) const;

    QRect subElementRect( SubElement element, const QStyleOption* option, const QWidget* widget ) const;
    QRect subControlRect( ComplexControl control, const QStyleOptionComplex* option,
        SubControl subControl, const QWidget* widget ) const;

    void drawPrimitive( PrimitiveElement element, const QStyleOption* option,
        QPainter* painter, const QWidget* widget ) const;
    void drawControl( ControlElement element, const QStyleOption* option,
        QPainter* painter, const QWidget* widget ) const;
    void drawComplexControl( ComplexControl control, const QStyleOptionComplex* option,
        QPainter* painter, const QWidget* widget ) const;

protected slots:
    int layoutSpacingImplementation( QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
        Qt::Orientation orientation, const QStyleOption* option, const QWidget* widget ) const;

private:
    enum Mode
    {
        Blue,
        Silver,
        Olive,
        Classic
    };

private:
    Mode m_mode;

    // main window, toolbox
    QColor m_colorBackgroundBegin;
    QColor m_colorBackgroundEnd;

    // menu
    QColor m_colorMenuBorder;
    QColor m_colorMenuBackground;
    QColor m_colorMenuTitleBegin;
    QColor m_colorMenuTitleEnd;

    // toolbar, tab, toolbox
    QColor m_colorBarBegin;
    QColor m_colorBarMiddle;
    QColor m_colorBarEnd;

    // toolbar handle
    QColor m_colorHandle;
    QColor m_colorHandleLight;

    // menu, toolbar
    QColor m_colorSeparator;
    QColor m_colorSeparatorLight;

    // menu, toolbar, tab, toolbox
    QColor m_colorItemBorder;
    QColor m_colorItemBackgroundBegin;
    QColor m_colorItemBackgroundMiddle;
    QColor m_colorItemBackgroundEnd;
    QColor m_colorItemCheckedBegin;
    QColor m_colorItemCheckedMiddle;
    QColor m_colorItemCheckedEnd;
    QColor m_colorItemSunkenBegin;
    QColor m_colorItemSunkenMiddle;
    QColor m_colorItemSunkenEnd;

    // toolbar shadow, tab, toolbox tab
    QColor m_colorBorder;
    QColor m_colorBorderLight;
};

#endif // !defined( NO_STYLE_WINDOWSMODERN )

#endif