1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** 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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 #include "texteditor_global.h"
39 #include <QtCore/QMap>
40 #include <QtCore/QString>
41 #include <QtGui/QColor>
43 namespace TextEditor {
45 /*! Format for a particular piece of text (text/comment, etc). */
46 class TEXTEDITOR_EXPORT Format
51 QColor foreground() const { return m_foreground; }
52 void setForeground(const QColor &foreground);
54 QColor background() const { return m_background; }
55 void setBackground(const QColor &background);
57 bool bold() const { return m_bold; }
58 void setBold(bool bold);
60 bool italic() const { return m_italic; }
61 void setItalic(bool italic);
63 bool equals(const Format &f) const;
65 QString toString() const;
66 bool fromString(const QString &str);
75 inline bool operator==(const Format &f1, const Format &f2) { return f1.equals(f2); }
76 inline bool operator!=(const Format &f1, const Format &f2) { return !f1.equals(f2); }
79 /*! A color scheme combines a set of formats for different highlighting
80 categories. It also provides saving and loading of the scheme to a file.
87 void setDisplayName(const QString &name)
88 { m_displayName = name; }
90 QString displayName() const
91 { return m_displayName; }
93 inline bool isEmpty() const
94 { return m_formats.isEmpty(); }
96 bool contains(const QString &category) const;
98 Format &formatFor(const QString &category);
99 Format formatFor(const QString &category) const;
101 void setFormatFor(const QString &category, const Format &format);
105 bool save(const QString &fileName) const;
106 bool load(const QString &fileName);
108 inline bool equals(const ColorScheme &cs) const
110 return m_formats == cs.m_formats
111 && m_displayName == cs.m_displayName;
114 static QString readNameOfScheme(const QString &fileName);
117 QMap<QString, Format> m_formats;
118 QString m_displayName;
121 inline bool operator==(const ColorScheme &cs1, const ColorScheme &cs2) { return cs1.equals(cs2); }
122 inline bool operator!=(const ColorScheme &cs1, const ColorScheme &cs2) { return !cs1.equals(cs2); }
124 } // namespace TextEditor
126 #endif // COLORSCHEME_H