source: trunk/src/gui/styles/qstylesheetstyle_p.h@ 642

Last change on this file since 642 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 7.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSTYLESHEETSTYLE_P_H
43#define QSTYLESHEETSTYLE_P_H
44
45#include "QtGui/qwindowsstyle.h"
46
47#ifndef QT_NO_STYLE_STYLESHEET
48
49#include "QtGui/qstyleoption.h"
50#include "QtCore/qhash.h"
51#include "QtGui/qevent.h"
52#include "QtCore/qvector.h"
53#include "QtGui/qapplication.h"
54#include "private/qcssparser_p.h"
55#include "QtGui/qbrush.h"
56
57QT_BEGIN_NAMESPACE
58
59//
60// W A R N I N G
61// -------------
62//
63// This file is not part of the Qt API. It exists purely as an
64// implementation detail. This header file may change from version to
65// version without notice, or even be removed.
66//
67// We mean it.
68//
69
70class QRenderRule;
71class QAbstractScrollArea;
72class QStyleSheetStylePrivate;
73class QStyleOptionTitleBar;
74
75class Q_AUTOTEST_EXPORT QStyleSheetStyle : public QWindowsStyle
76{
77 typedef QWindowsStyle ParentStyle;
78
79 Q_OBJECT
80public:
81 QStyleSheetStyle(QStyle *baseStyle);
82 ~QStyleSheetStyle();
83
84 void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
85 const QWidget *w = 0) const;
86 void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
87 const QWidget *w = 0) const;
88 void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
89 void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
90 bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const;
91 void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
92 const QWidget *w = 0) const;
93 QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
94 const QStyleOption *option) const;
95 SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
96 const QPoint &pt, const QWidget *w = 0) const;
97 QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const;
98 QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
99 const QString &text) const;
100 int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
101 void polish(QWidget *widget);
102 void polish(QApplication *app);
103 void polish(QPalette &pal);
104 QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
105 const QSize &contentsSize, const QWidget *widget = 0) const;
106 QPalette standardPalette() const;
107 QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0,
108 const QWidget *w = 0 ) const;
109 int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
110 Qt::Orientation orientation, const QStyleOption *option = 0,
111 const QWidget *widget = 0) const;
112 int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
113 QStyleHintReturn *shret = 0) const;
114 QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
115 QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
116 const QWidget *w = 0) const;
117
118 // These functions are called from QApplication/QWidget. Be careful.
119 QStyle *baseStyle() const;
120 void repolish(QWidget *widget);
121 void repolish(QApplication *app);
122
123 void unpolish(QWidget *widget);
124 void unpolish(QApplication *app);
125
126 QStyle *base;
127 void ref() { ++refcount; }
128 void deref() { Q_ASSERT(refcount > 0); if (!--refcount) delete this; }
129
130 void updateStyleSheetFont(QWidget* w) const;
131 void saveWidgetFont(QWidget* w, const QFont& font) const;
132 void clearWidgetFont(QWidget* w) const;
133
134 bool styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal);
135
136protected Q_SLOTS:
137 QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
138 const QWidget *widget = 0) const;
139 int layoutSpacingImplementation(QSizePolicy::ControlType control1,
140 QSizePolicy::ControlType control2,
141 Qt::Orientation orientation,
142 const QStyleOption *option = 0,
143 const QWidget *widget = 0) const;
144
145protected:
146 bool event(QEvent *e);
147
148private Q_SLOTS:
149 void widgetDestroyed(QObject *);
150
151private:
152 int refcount;
153
154 friend class QRenderRule;
155 int nativeFrameWidth(const QWidget *);
156 QRenderRule renderRule(const QWidget *, int, quint64 = 0) const;
157 QRenderRule renderRule(const QWidget *, const QStyleOption *, int = 0) const;
158 QSize defaultSize(const QWidget *, QSize, const QRect&, int) const;
159 QRect positionRect(const QWidget *, const QRenderRule&, const QRenderRule&, int,
160 const QRect&, Qt::LayoutDirection) const;
161 QRect positionRect(const QWidget *w, const QRenderRule &rule2, int pe,
162 const QRect &originRect, Qt::LayoutDirection dir) const;
163
164 mutable QCss::Parser parser;
165
166 void setPalette(QWidget *);
167 void unsetPalette(QWidget *);
168 void setProperties(QWidget *);
169 void setGeometry(QWidget *);
170 QVector<QCss::StyleRule> styleRules(const QWidget *w) const;
171 bool hasStyleRule(const QWidget *w, int part) const;
172
173 QHash<QStyle::SubControl, QRect> titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const;
174
175 QCss::StyleSheet getDefaultStyleSheet() const;
176
177 static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment);
178 static bool isNaturalChild(const QWidget *w);
179 bool initWidget(const QWidget *w) const;
180public:
181 static int numinstances;
182
183private:
184 Q_DISABLE_COPY(QStyleSheetStyle)
185 Q_DECLARE_PRIVATE(QStyleSheetStyle)
186};
187
188
189QT_END_NAMESPACE
190#endif // QT_NO_STYLE_STYLESHEET
191#endif // QSTYLESHEETSTYLE_P_H
Note: See TracBrowser for help on using the repository browser.