Subversion Repositories Scribus

Rev

Rev 4608 | Rev 5369 | 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
4645 subik 36
  * \brief This Class adds support for CMYK-Colors to QT.
2886 fschmid 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();
4645 subik 51
/** \brief Constructs a ScColor with 4 Components
2886 fschmid 52
 * in the range from 0 - 255 */
53
        ScColor(int c, int m, int y, int k);
4645 subik 54
/** \brief Constructs a RGBColor with 3 Components
2886 fschmid 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
 
4645 subik 61
        /** \brief flag to enable and disable use of color management (default: true) */
2886 fschmid 62
        static bool UseProf;
63
 
4645 subik 64
        /** \brief Same as the Constructor but for an existing Color */
2886 fschmid 65
        void setColor(int c, int m, int y, int k);
66
 
4645 subik 67
        /** \brief 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 */
2886 fschmid 70
        void setColorRGB(int r, int g, int b);
71
 
4645 subik 72
        /** \brief set the color model */
2886 fschmid 73
        void setColorModel (colorModel cm);
74
 
4645 subik 75
        /** \brief get the color model */
2886 fschmid 76
        colorModel getColorModel ();
77
 
4645 subik 78
        /** \brief Computes a ScColor for a QColor */
2886 fschmid 79
        void fromQColor(QColor color);
80
 
4645 subik 81
        /** \brief Returns the transformed/proofed RGB color  */
2886 fschmid 82
        QColor getRGBColor();
83
        void getRawRGBColor(int *r, int *g, int *b);
3046 fschmid 84
        QColor getRawRGBColor();
2886 fschmid 85
 
4645 subik 86
        /** \brief Returns the 4 Values that form an ScColor */
2886 fschmid 87
        void getCMYK(int *c, int *m, int *y, int *k);
88
 
4645 subik 89
        /** \brief Returns the 3 Values that form an RGBColor */
2886 fschmid 90
        void getRGB(int *r, int *g, int *b);
91
 
4645 subik 92
        /** \brief get CMYK values of a specified shade */
2886 fschmid 93
        void getShadeColorCMYK(int *c, int *m, int *y, int *k, int level);
94
 
4645 subik 95
        /** \brief get RGB values of a specified shade */
2886 fschmid 96
        void getShadeColorRGB(int *r, int *g, int *b, int level);
97
 
4645 subik 98
        /** \brief Return a proofed QColor with the specified shade */
2886 fschmid 99
        QColor getShadeColorProof(int level);
100
 
4645 subik 101
        /** \brief Applys Gray-Component-Removal to an ScColor */
2886 fschmid 102
        void applyGCR();
103
 
4645 subik 104
/** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK for
2886 fschmid 105
 * a CMYK color or ##RRGGBB for a RGB color*/
106
        QString name();
4645 subik 107
        /** \brief Returns the ScColor as an Hex-String in the Form #RRGGBB */
4535 fschmid 108
        QString nameRGB();
4645 subik 109
        /** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK */
4535 fschmid 110
        QString nameCMYK();
2886 fschmid 111
 
4645 subik 112
/** \brief Sets the Values of a color from an Hex-String in the Form #CCMMYYKK
2886 fschmid 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:
4645 subik 124
        /** \brief Cyan-Component of Color */
2886 fschmid 125
        int C;
126
 
4645 subik 127
        /** \brief Magenta-Component of Color */
2886 fschmid 128
        int M;
129
 
4645 subik 130
        /** \brief Yellow-Component of Color */
2886 fschmid 131
        int Y;
132
 
4645 subik 133
        /** \brief Black-Component of Color */
2886 fschmid 134
        int K;
135
 
4645 subik 136
        /** \brief Red-Component of Color */
2886 fschmid 137
        int R;
138
 
4645 subik 139
        /** \brief Green-Component of Color */
2886 fschmid 140
        int G;
141
 
4645 subik 142
        /** \brief Blue-Component of Color */
2886 fschmid 143
        int B;
144
 
4645 subik 145
        /** \brief RGB-Equivalent including color transforms */
2886 fschmid 146
        QColor RGB;
147
 
4645 subik 148
        /** \brief Flag, true if the Color is a Spotcolor */
2886 fschmid 149
        bool Spot;
150
 
4645 subik 151
        /** \brief Flag, true if the Color is a Registration color */
3060 fschmid 152
        bool Regist;
153
 
4645 subik 154
        /** \brief Color model of the current color */
2886 fschmid 155
        colorModel Model;
3041 fschmid 156
 
4645 subik 157
        /** \brief Flag, true if out of Gamut */
3041 fschmid 158
        bool outOfGamutFlag;
2886 fschmid 159
};
160
 
4645 subik 161
/** \brief Definition of the Color list */
3251 craig 162
typedef QMap<QString,ScColor> ColorList;
163
 
2886 fschmid 164
#endif