Subversion Repositories Scribus

Rev

Rev 4535 | Rev 4645 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
2886 fschmid 7
/***************************************************************************
8
                          sccolor.h  -  description
9
                             -------------------
10
    begin                : Sun Sep 9 2001
11
    copyright            : (C) 2001 by Franz Schmid
12
    email                : Franz.Schmid@altmuehlnet.de
13
 ***************************************************************************/
14
 
15
/***************************************************************************
16
 *                                                                         *
17
 *   This program is free software; you can redistribute it and/or modify  *
18
 *   it under the terms of the GNU General Public License as published by  *
19
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 *   (at your option) any later version.                                   *
21
 *                                                                         *
22
 ***************************************************************************/
23
 
24
#ifndef SCCOLOR_H
25
#define SCCOLOR_H
26
 
3251 craig 27
#include "qstring.h"
28
#include <qcolor.h>
29
#include "qmap.h"
30
 
2969 craig 31
#include "scribusapi.h"
2886 fschmid 32
 
33
 
34
/**
35
  *@author Franz Schmid
36
  * This Class adds support for CMYK-Colors to QT.
37
  * its API is based on the API of QColor
38
  */
39
 
40
/** Scribus color models */
41
enum colorModel
42
{
43
        colorModelRGB,
44
        colorModelCMYK
45
};
46
 
2969 craig 47
class SCRIBUS_API ScColor
2886 fschmid 48
{
49
public:
50
        ScColor();
51
/** Constructs a ScColor with 4 Components
52
 * in the range from 0 - 255 */
53
        ScColor(int c, int m, int y, int k);
54
/** Constructs a RGBColor with 3 Components
55
 * in the range from 0 - 255 */
56
        ScColor(int r, int g, int b);
57
        ~ScColor() {};
4608 cbradney 58
 
59
        bool operator==(const ScColor& rhs) const;
60
 
2886 fschmid 61
/** flag to enable and disable use of color management (default: true) */
62
        static bool UseProf;
63
 
64
/** Same as the Constructor but for an existing Color */
65
        void setColor(int c, int m, int y, int k);
66
 
67
/** Computes a ScColor from an RGB-Color
68
 * Applies Gray-Component-Removal to the resulting ScColor
69
 * or if color management is enabled, an approriate transform */
70
        void setColorRGB(int r, int g, int b);
71
 
72
/** set the color model */
73
        void setColorModel (colorModel cm);
74
 
75
/** get the color model */
76
        colorModel getColorModel ();
77
 
78
/** Computes a ScColor for a QColor */
79
        void fromQColor(QColor color);
80
 
81
/** Returns the transformed/proofed RGB color  */
82
        QColor getRGBColor();
83
        void getRawRGBColor(int *r, int *g, int *b);
3046 fschmid 84
        QColor getRawRGBColor();
2886 fschmid 85
 
86
/** Returns the 4 Values that form an ScColor */
87
        void getCMYK(int *c, int *m, int *y, int *k);
88
 
89
/** Returns the 3 Values that form an RGBColor */
90
        void getRGB(int *r, int *g, int *b);
91
 
92
/** get CMYK values of a specified shade */
93
        void getShadeColorCMYK(int *c, int *m, int *y, int *k, int level);
94
 
95
/** get RGB values of a specified shade */
96
        void getShadeColorRGB(int *r, int *g, int *b, int level);
97
 
98
/** Return a proofed QColor with the specified shade */
99
        QColor getShadeColorProof(int level);
100
 
101
/** Applys Gray-Component-Removal to an ScColor */
102
        void applyGCR();
103
 
104
/** Returns the ScColor as an Hex-String in the Form #CCYYMMKK for
105
 * a CMYK color or ##RRGGBB for a RGB color*/
106
        QString name();
4535 fschmid 107
/** Returns the ScColor as an Hex-String in the Form #RRGGBB */
108
        QString nameRGB();
109
/** Returns the ScColor as an Hex-String in the Form #CCYYMMKK */
110
        QString nameCMYK();
2886 fschmid 111
 
112
/** Sets the Values of a color from an Hex-String in the Form #CCMMYYKK
113
 * or #RRGGBB */
114
        void setNamedColor(QString nam);
115
        void RecalcRGB();
3041 fschmid 116
        bool isOutOfGamut();
3046 fschmid 117
        void checkGamut();
3051 fschmid 118
        bool isSpotColor();
119
        void setSpotColor(bool s);
3060 fschmid 120
        bool isRegistrationColor();
121
        void setRegistrationColor(bool s);
2886 fschmid 122
 
123
private:
124
/** Cyan-Component of Color */
125
        int C;
126
 
127
/** Magenta-Component of Color */
128
        int M;
129
 
130
/** Yellow-Component of Color */
131
        int Y;
132
 
133
/** Black-Component of Color */
134
        int K;
135
 
136
/** Red-Component of Color */
137
        int R;
138
 
139
/** Green-Component of Color */
140
        int G;
141
 
142
/** Blue-Component of Color */
143
        int B;
144
 
145
/** RGB-Equivalent including color transforms */
146
        QColor RGB;
147
 
148
/** Flag, true if the Color is a Spotcolor */
149
        bool Spot;
150
 
3060 fschmid 151
/** Flag, true if the Color is a Registration color */
152
        bool Regist;
153
 
2886 fschmid 154
/** Color model of the current color */
155
        colorModel Model;
3041 fschmid 156
 
157
/** Flag, true if out of Gamut */
158
        bool outOfGamutFlag;
2886 fschmid 159
};
160
 
3251 craig 161
/** Definition der Farbenlisten */
162
typedef QMap<QString,ScColor> ColorList;
163
 
2886 fschmid 164
#endif