1 /****************************************************************************
2 * Simple XML-based UI builder for Qt4
3 * Copyright (C) 2007-2012 Michał Męciński
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *   1. Redistributions of source code must retain the above copyright notice,
8 *      this list of conditions and the following disclaimer.
9 *   2. Redistributions in binary form must reproduce the above copyright
10 *      notice, this list of conditions and the following disclaimer in the
11 *      documentation and/or other materials provided with the distribution.
12 *   3. Neither the name of the copyright holder nor the names of the
13 *      contributors may be used to endorse or promote products derived from
14 *      this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 ****************************************************************************/
28 
29 #ifndef XMLUI_WINDOWSSTYLE_H
30 #define XMLUI_WINDOWSSTYLE_H
31 
32 #include <QtGlobal>
33 
34 #if !defined( Q_OS_WIN ) || ( QT_VERSION < 0x040600 ) || defined( QT_NO_STYLE_WINDOWSVISTA )
35 #define XMLUI_NO_STYLE_WINDOWS
36 #endif
37 
38 #if !defined( XMLUI_NO_STYLE_WINDOWS )
39 
40 #include <QProxyStyle>
41 
42 namespace XmlUi
43 {
44 
45 /**
46 * Modern Qt style for Windows.
47 *
48 * The style imitates the look of MS Office.
49 */
50 class WindowsStyle : public QProxyStyle
51 {
52     Q_OBJECT
53 public:
54     /**
55     * Constructor.
56     */
57     WindowsStyle();
58 
59     /**
60     * Destructor.
61     */
62     ~WindowsStyle();
63 
64 public: // overrides
65     void polish( QPalette& palette );
66 
67     void polish( QWidget* widget );
68     void unpolish( QWidget* widget );
69 
70     int pixelMetric( PixelMetric metric, const QStyleOption* option, const QWidget* widget ) const;
71 
72     QSize sizeFromContents( ContentsType type, const QStyleOption* option,
73         const QSize& contentsSize, const QWidget* widget ) const;
74 
75     void drawPrimitive( PrimitiveElement element, const QStyleOption* option,
76         QPainter* painter, const QWidget* widget ) const;
77     void drawControl( ControlElement element, const QStyleOption* option,
78         QPainter* painter, const QWidget* widget ) const;
79     void drawComplexControl( ComplexControl control, const QStyleOptionComplex* option,
80         QPainter* painter, const QWidget* widget ) const;
81 
82 private:
83     QColor m_colorBackgroundBegin;
84     QColor m_colorBackgroundEnd;
85     QColor m_colorMenuBorder;
86     QColor m_colorMenuBackground;
87     QColor m_colorBarBegin;
88     QColor m_colorBarEnd;
89     QColor m_colorSeparator;
90     QColor m_colorItemBorder;
91     QColor m_colorItemBackgroundBegin;
92     QColor m_colorItemBackgroundMiddle;
93     QColor m_colorItemBackgroundEnd;
94     QColor m_colorItemCheckedBegin;
95     QColor m_colorItemCheckedMiddle;
96     QColor m_colorItemCheckedEnd;
97     QColor m_colorItemSunkenBegin;
98     QColor m_colorItemSunkenMiddle;
99     QColor m_colorItemSunkenEnd;
100     QColor m_colorToolStripLabel;
101 };
102 
103 }
104 
105 #endif // !defined( XMLUI_NO_STYLE_WINDOWS )
106 
107 #endif
108