1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt3Support 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 The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef Q3STYLESHEET_H
43 #define Q3STYLESHEET_H
44 
45 #include <QtCore/qstring.h>
46 #include <QtCore/qlist.h>
47 #include <QtCore/qhash.h>
48 #include <QtCore/qobject.h>
49 #include <QtGui/qcolor.h>
50 #include <QtGui/qfont.h>
51 
52 QT_BEGIN_HEADER
53 
54 QT_BEGIN_NAMESPACE
55 
56 QT_MODULE(Qt3SupportLight)
57 
58 #ifndef QT_NO_RICHTEXT
59 
60 class Q3StyleSheet;
61 class Q3TextDocument;
62 template<class Key, class T> class QMap;
63 class Q3StyleSheetItemData;
64 
65 class Q_COMPAT_EXPORT Q3StyleSheetItem
66 {
67 public:
68     Q3StyleSheetItem(Q3StyleSheet* parent, const QString& name);
69     Q3StyleSheetItem(const Q3StyleSheetItem &);
70     ~Q3StyleSheetItem();
71 
72     Q3StyleSheetItem& operator=(const Q3StyleSheetItem& other);
73 
74     QString name() const;
75 
76     Q3StyleSheet* styleSheet();
77     const Q3StyleSheet* styleSheet() const;
78 
79     enum AdditionalStyleValues { Undefined = -1 };
80 
81     enum DisplayMode {
82         DisplayBlock,
83         DisplayInline,
84         DisplayListItem,
85         DisplayNone,
86 	DisplayModeUndefined = -1
87     };
88 
89     DisplayMode displayMode() const;
90     void setDisplayMode(DisplayMode m);
91 
92     int alignment() const;
93     void setAlignment(int f);
94 
95     enum VerticalAlignment {
96         VAlignBaseline,
97         VAlignSub,
98         VAlignSuper
99     };
100 
101     VerticalAlignment verticalAlignment() const;
102     void setVerticalAlignment(VerticalAlignment valign);
103 
104     int fontWeight() const;
105     void setFontWeight(int w);
106 
107     int logicalFontSize() const;
108     void setLogicalFontSize(int s);
109 
110     int logicalFontSizeStep() const;
111     void setLogicalFontSizeStep(int s);
112 
113     int fontSize() const;
114     void setFontSize(int s);
115 
116     QString fontFamily() const;
117     void setFontFamily(const QString&);
118 
119     int numberOfColumns() const;
120     void setNumberOfColumns(int ncols);
121 
122     QColor color() const;
123     void setColor(const QColor &);
124 
125     bool fontItalic() const;
126     void setFontItalic(bool);
127     bool definesFontItalic() const;
128 
129     bool fontUnderline() const;
130     void setFontUnderline(bool);
131     bool definesFontUnderline() const;
132 
133     bool fontStrikeOut() const;
134     void setFontStrikeOut(bool);
135     bool definesFontStrikeOut() const;
136 
137     bool isAnchor() const;
138     void setAnchor(bool anc);
139 
140     enum WhiteSpaceMode {
141         WhiteSpaceNormal,
142         WhiteSpacePre,
143         WhiteSpaceNoWrap,
144         WhiteSpaceModeUndefined = -1
145     };
146     WhiteSpaceMode whiteSpaceMode() const;
147     void setWhiteSpaceMode(WhiteSpaceMode m);
148 
149     enum Margin {
150         MarginLeft,
151         MarginRight,
152         MarginTop,
153         MarginBottom,
154         MarginFirstLine,
155         MarginAll,
156         MarginVertical,
157         MarginHorizontal,
158 	MarginUndefined = -1
159     };
160 
161     int margin(Margin m) const;
162     void setMargin(Margin, int);
163 
164     enum ListStyle {
165         ListDisc,
166         ListCircle,
167         ListSquare,
168         ListDecimal,
169         ListLowerAlpha,
170         ListUpperAlpha,
171 	ListStyleUndefined = -1
172     };
173 
174     ListStyle listStyle() const;
175     void setListStyle(ListStyle);
176 
177     QString contexts() const;
178     void setContexts(const QString&);
179     bool allowedInContext(const Q3StyleSheetItem*) const;
180 
181     bool selfNesting() const;
182     void setSelfNesting(bool);
183 
184     void setLineSpacing(int ls);
185     int lineSpacing() const;
186 
187 private:
188     void init();
189     Q3StyleSheetItemData* d;
190 };
191 
192 #ifndef QT_NO_TEXTCUSTOMITEM
193 class Q3TextCustomItem;
194 #endif
195 
196 class Q_COMPAT_EXPORT Q3StyleSheet : public QObject
197 {
198     Q_OBJECT
199 public:
200     Q3StyleSheet(QObject *parent=0, const char *name=0);
201     virtual ~Q3StyleSheet();
202 
203     static Q3StyleSheet* defaultSheet();
204     static void setDefaultSheet(Q3StyleSheet*);
205 
206 
207     Q3StyleSheetItem* item(const QString& name);
208     const Q3StyleSheetItem* item(const QString& name) const;
209 
210     void insert(Q3StyleSheetItem* item);
211 
212     static QString escape(const QString&);
213     static QString convertFromPlainText(const QString&,
214                                         Q3StyleSheetItem::WhiteSpaceMode mode = Q3StyleSheetItem::WhiteSpacePre);
215     static bool mightBeRichText(const QString&);
216 
217     virtual void scaleFont(QFont& font, int logicalSize) const;
218 
219     virtual void error(const QString&) const;
220 
221 private:
222     Q_DISABLE_COPY(Q3StyleSheet)
223 
224     void init();
225     QHash<QString, Q3StyleSheetItem *> styles;
226     Q3StyleSheetItem* nullstyle;
227 };
228 
229 #endif // QT_NO_RICHTEXT
230 
231 QT_END_NAMESPACE
232 
233 QT_END_HEADER
234 
235 #endif // Q3STYLESHEET_H
236