source: branches/vendor/trolltech/qt/current/tools/xmlpatterns/qcoloroutput_p.h @ 2

Last change on this file since 2 was 2, checked in by Dmitry A. Kuminov, 12 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.0 KB
Line 
1/****************************************************************************
2 * ** * ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
3** Contact: Qt Software Information (qt-info@nokia.com)
4 * **
5 * ** This file is part of the Patternist project on Trolltech Labs.  * **
6 * ** $QT_BEGIN_LICENSE:LGPL$
7** Commercial Usage
8** Licensees holding valid Qt Commercial licenses may use this file in
9** accordance with the Qt Commercial License Agreement provided with the
10** Software or, alternatively, in accordance with the terms contained in
11** a written agreement between you and Nokia.
12**
13** GNU Lesser General Public License Usage
14** Alternatively, this file may be used under the terms of the GNU Lesser
15** General Public License version 2.1 as published by the Free Software
16** Foundation and appearing in the file LICENSE.LGPL included in the
17** packaging of this file.  Please review the following information to
18** ensure the GNU Lesser General Public License version 2.1 requirements
19** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
20**
21** In addition, as a special exception, Nokia gives you certain
22** additional rights. These rights are described in the Nokia Qt LGPL
23** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
24** package.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 3.0 as published by the Free Software
29** Foundation and appearing in the file LICENSE.GPL included in the
30** packaging of this file.  Please review the following information to
31** ensure the GNU General Public License version 3.0 requirements will be
32** met: http://www.gnu.org/copyleft/gpl.html.
33**
34** If you are unsure which license is appropriate for your use, please
35** contact the sales department at qt-sales@nokia.com.
36** $QT_END_LICENSE$
37 * **
38 * ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
39 * ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
40 * **
41 * ****************************************************************************/
42
43//
44//  W A R N I N G
45//  -------------
46//
47// This file is not part of the Qt API.  It exists purely as an
48// implementation detail.  This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52
53#ifndef Patternist_ColorOutput_h
54#define Patternist_ColorOutput_h
55
56#include <QtCore/QtGlobal>
57#include <QtCore/QHash>
58
59QT_BEGIN_HEADER
60
61QT_BEGIN_NAMESPACE
62
63namespace QPatternist
64{
65    class ColorOutputPrivate;
66
67    class ColorOutput
68    {
69        enum
70        {
71            ForegroundShift = 10,
72            BackgroundShift = 20,
73            SpecialShift    = 20,
74            ForegroundMask  = ((1 << ForegroundShift) - 1) << ForegroundShift,
75            BackgroundMask  = ((1 << BackgroundShift) - 1) << BackgroundShift
76        };
77
78    public:
79        enum ColorCodeComponent
80        {
81            BlackForeground         = 1 << ForegroundShift,
82            BlueForeground          = 2 << ForegroundShift,
83            GreenForeground         = 3 << ForegroundShift,
84            CyanForeground          = 4 << ForegroundShift,
85            RedForeground           = 5 << ForegroundShift,
86            PurpleForeground        = 6 << ForegroundShift,
87            BrownForeground         = 7 << ForegroundShift,
88            LightGrayForeground     = 8 << ForegroundShift,
89            DarkGrayForeground      = 9 << ForegroundShift,
90            LightBlueForeground     = 10 << ForegroundShift,
91            LightGreenForeground    = 11 << ForegroundShift,
92            LightCyanForeground     = 12 << ForegroundShift,
93            LightRedForeground      = 13 << ForegroundShift,
94            LightPurpleForeground   = 14 << ForegroundShift,
95            YellowForeground        = 15 << ForegroundShift,
96            WhiteForeground         = 16 << ForegroundShift,
97
98            BlackBackground         = 1 << BackgroundShift,
99            BlueBackground          = 2 << BackgroundShift,
100            GreenBackground         = 3 << BackgroundShift,
101            CyanBackground          = 4 << BackgroundShift,
102            RedBackground           = 5 << BackgroundShift,
103            PurpleBackground        = 6 << BackgroundShift,
104            BrownBackground         = 7 << BackgroundShift,
105            DefaultColor            = 1 << SpecialShift
106        };
107
108        typedef QFlags<ColorCodeComponent> ColorCode;
109        typedef QHash<int, ColorCode> ColorMapping;
110
111        ColorOutput();
112        ~ColorOutput();
113
114        void setColorMapping(const ColorMapping &cMapping);
115        ColorMapping colorMapping() const;
116        void insertMapping(int colorID, const ColorCode colorCode);
117
118        void writeUncolored(const QString &message);
119        void write(const QString &message, int color = -1);
120        QString colorify(const QString &message, int color = -1) const;
121
122    private:
123        ColorOutputPrivate *d;
124        Q_DISABLE_COPY(ColorOutput)
125    };
126}
127
128Q_DECLARE_OPERATORS_FOR_FLAGS(QPatternist::ColorOutput::ColorCode)
129
130QT_END_NAMESPACE
131
132QT_END_HEADER
133
134#endif
Note: See TracBrowser for help on using the repository browser.