1 | /****************************************************************************
|
---|
2 | ** $Id: qstylesheet.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of the QStyleSheet class
|
---|
5 | **
|
---|
6 | ** Created : 990101
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QSTYLESHEET_H
|
---|
39 | #define QSTYLESHEET_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qstring.h"
|
---|
43 | #include "qvaluelist.h"
|
---|
44 | #include "qptrvector.h"
|
---|
45 | #include "qdict.h"
|
---|
46 | #include "qobject.h"
|
---|
47 | #endif // QT_H
|
---|
48 |
|
---|
49 | #ifndef QT_NO_RICHTEXT
|
---|
50 |
|
---|
51 | class QStyleSheet;
|
---|
52 | class QTextDocument;
|
---|
53 | template<class Key, class T> class QMap;
|
---|
54 | class QStyleSheetItemData;
|
---|
55 |
|
---|
56 | class Q_EXPORT QStyleSheetItem : public Qt
|
---|
57 | {
|
---|
58 | public:
|
---|
59 | QStyleSheetItem( QStyleSheet* parent, const QString& name );
|
---|
60 | QStyleSheetItem( const QStyleSheetItem & );
|
---|
61 | ~QStyleSheetItem();
|
---|
62 |
|
---|
63 | QStyleSheetItem& operator=( const QStyleSheetItem& other );
|
---|
64 |
|
---|
65 | QString name() const;
|
---|
66 |
|
---|
67 | QStyleSheet* styleSheet();
|
---|
68 | const QStyleSheet* styleSheet() const;
|
---|
69 |
|
---|
70 | enum AdditionalStyleValues { Undefined = - 1};
|
---|
71 |
|
---|
72 | enum DisplayMode {
|
---|
73 | DisplayBlock,
|
---|
74 | DisplayInline,
|
---|
75 | DisplayListItem,
|
---|
76 | DisplayNone
|
---|
77 | #ifndef Q_QDOC
|
---|
78 | , DisplayModeUndefined = -1
|
---|
79 | #endif
|
---|
80 | };
|
---|
81 |
|
---|
82 | DisplayMode displayMode() const;
|
---|
83 | void setDisplayMode(DisplayMode m);
|
---|
84 |
|
---|
85 | int alignment() const;
|
---|
86 | void setAlignment( int f);
|
---|
87 |
|
---|
88 | enum VerticalAlignment {
|
---|
89 | VAlignBaseline,
|
---|
90 | VAlignSub,
|
---|
91 | VAlignSuper
|
---|
92 | };
|
---|
93 |
|
---|
94 | VerticalAlignment verticalAlignment() const;
|
---|
95 | void setVerticalAlignment( VerticalAlignment valign );
|
---|
96 |
|
---|
97 | int fontWeight() const;
|
---|
98 | void setFontWeight(int w);
|
---|
99 |
|
---|
100 | int logicalFontSize() const;
|
---|
101 | void setLogicalFontSize(int s);
|
---|
102 |
|
---|
103 | int logicalFontSizeStep() const;
|
---|
104 | void setLogicalFontSizeStep( int s );
|
---|
105 |
|
---|
106 | int fontSize() const;
|
---|
107 | void setFontSize(int s);
|
---|
108 |
|
---|
109 | QString fontFamily() const;
|
---|
110 | void setFontFamily( const QString& );
|
---|
111 |
|
---|
112 | int numberOfColumns() const;
|
---|
113 | void setNumberOfColumns(int ncols);
|
---|
114 |
|
---|
115 | QColor color() const;
|
---|
116 | void setColor( const QColor &);
|
---|
117 |
|
---|
118 | bool fontItalic() const;
|
---|
119 | void setFontItalic( bool );
|
---|
120 | bool definesFontItalic() const;
|
---|
121 |
|
---|
122 | bool fontUnderline() const;
|
---|
123 | void setFontUnderline( bool );
|
---|
124 | bool definesFontUnderline() const;
|
---|
125 |
|
---|
126 | bool fontStrikeOut() const;
|
---|
127 | void setFontStrikeOut( bool );
|
---|
128 | bool definesFontStrikeOut() const;
|
---|
129 |
|
---|
130 | bool isAnchor() const;
|
---|
131 | void setAnchor(bool anc);
|
---|
132 |
|
---|
133 | enum WhiteSpaceMode {
|
---|
134 | WhiteSpaceNormal,
|
---|
135 | WhiteSpacePre,
|
---|
136 | WhiteSpaceNoWrap
|
---|
137 | #ifndef Q_QDOC
|
---|
138 | , WhiteSpaceModeUndefined = -1
|
---|
139 | #endif
|
---|
140 | };
|
---|
141 | WhiteSpaceMode whiteSpaceMode() const;
|
---|
142 | void setWhiteSpaceMode(WhiteSpaceMode m);
|
---|
143 |
|
---|
144 | enum Margin {
|
---|
145 | MarginLeft,
|
---|
146 | MarginRight,
|
---|
147 | MarginTop,
|
---|
148 | MarginBottom,
|
---|
149 | MarginFirstLine,
|
---|
150 | MarginAll,
|
---|
151 | MarginVertical,
|
---|
152 | MarginHorizontal
|
---|
153 | #ifndef Q_QDOC
|
---|
154 | , MarginUndefined = -1
|
---|
155 | #endif
|
---|
156 | };
|
---|
157 |
|
---|
158 | int margin( Margin m) const;
|
---|
159 | void setMargin( Margin, int);
|
---|
160 |
|
---|
161 | enum ListStyle {
|
---|
162 | ListDisc,
|
---|
163 | ListCircle,
|
---|
164 | ListSquare,
|
---|
165 | ListDecimal,
|
---|
166 | ListLowerAlpha,
|
---|
167 | ListUpperAlpha
|
---|
168 | #ifndef Q_QDOC
|
---|
169 | , ListStyleUndefined = -1
|
---|
170 | #endif
|
---|
171 | };
|
---|
172 |
|
---|
173 | ListStyle listStyle() const;
|
---|
174 | void setListStyle( ListStyle );
|
---|
175 |
|
---|
176 | QString contexts() const;
|
---|
177 | void setContexts( const QString& );
|
---|
178 | bool allowedInContext( const QStyleSheetItem* ) const;
|
---|
179 |
|
---|
180 | bool selfNesting() const;
|
---|
181 | void setSelfNesting( bool );
|
---|
182 |
|
---|
183 | void setLineSpacing( int ls );
|
---|
184 | int lineSpacing() const;
|
---|
185 |
|
---|
186 | private:
|
---|
187 | void init();
|
---|
188 | QStyleSheetItemData* d;
|
---|
189 | };
|
---|
190 |
|
---|
191 |
|
---|
192 | #if defined(Q_TEMPLATEDLL)
|
---|
193 | // MOC_SKIP_BEGIN
|
---|
194 | Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QStyleSheetItem>;
|
---|
195 | Q_TEMPLATE_EXTERN template class Q_EXPORT QValueList< QPtrVector<QStyleSheetItem> >;
|
---|
196 | Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrVector<QStyleSheetItem>;
|
---|
197 | Q_TEMPLATE_EXTERN template class Q_EXPORT QValueList<QStyleSheetItem::ListStyle>;
|
---|
198 | // MOC_SKIP_END
|
---|
199 | #endif
|
---|
200 |
|
---|
201 | #ifndef QT_NO_TEXTCUSTOMITEM
|
---|
202 | class QTextCustomItem;
|
---|
203 | #endif
|
---|
204 |
|
---|
205 | class Q_EXPORT QStyleSheet : public QObject
|
---|
206 | {
|
---|
207 | Q_OBJECT
|
---|
208 | public:
|
---|
209 | QStyleSheet( QObject *parent=0, const char *name=0 );
|
---|
210 | virtual ~QStyleSheet();
|
---|
211 |
|
---|
212 | static QStyleSheet* defaultSheet();
|
---|
213 | static void setDefaultSheet( QStyleSheet* );
|
---|
214 |
|
---|
215 |
|
---|
216 | QStyleSheetItem* item( const QString& name);
|
---|
217 | const QStyleSheetItem* item( const QString& name) const;
|
---|
218 |
|
---|
219 | void insert( QStyleSheetItem* item);
|
---|
220 |
|
---|
221 | #ifndef QT_NO_TEXTCUSTOMITEM
|
---|
222 | virtual QTextCustomItem* tag( const QString& name,
|
---|
223 | const QMap<QString, QString> &attr,
|
---|
224 | const QString& context,
|
---|
225 | const QMimeSourceFactory& factory,
|
---|
226 | bool emptyTag, QTextDocument *doc ) const;
|
---|
227 | #endif
|
---|
228 | static QString escape( const QString& );
|
---|
229 | static QString convertFromPlainText( const QString&,
|
---|
230 | QStyleSheetItem::WhiteSpaceMode mode = QStyleSheetItem::WhiteSpacePre );
|
---|
231 | static bool mightBeRichText( const QString& );
|
---|
232 |
|
---|
233 | virtual void scaleFont( QFont& font, int logicalSize ) const;
|
---|
234 |
|
---|
235 | virtual void error( const QString& ) const;
|
---|
236 |
|
---|
237 | private:
|
---|
238 | void init();
|
---|
239 | QDict<QStyleSheetItem> styles;
|
---|
240 | QStyleSheetItem* nullstyle;
|
---|
241 | private: // Disabled copy constructor and operator=
|
---|
242 | #if defined(Q_DISABLE_COPY)
|
---|
243 | QStyleSheet( const QStyleSheet & );
|
---|
244 | QStyleSheet &operator=( const QStyleSheet & );
|
---|
245 | #endif
|
---|
246 | };
|
---|
247 |
|
---|
248 | #endif // QT_NO_RICHTEXT
|
---|
249 |
|
---|
250 | #endif // QSTYLESHEET_H
|
---|