Subversion Repositories Scribus

Rev

Rev 7857 | 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
 
5880 jghali 27
#include <qstring.h>
3251 craig 28
#include <qcolor.h>
5880 jghali 29
#include <qmap.h>
30
#include <qguardedptr.h>
3251 craig 31
 
5880 jghali 32
class ScribusDoc;
2969 craig 33
#include "scribusapi.h"
2886 fschmid 34
 
35
 
36
/**
37
  *@author Franz Schmid
4645 subik 38
  * \brief This Class adds support for CMYK-Colors to QT.
2886 fschmid 39
  * its API is based on the API of QColor
40
  */
41
 
42
/** Scribus color models */
43
enum colorModel
44
{
45
        colorModelRGB,
46
        colorModelCMYK
47
};
48
 
2969 craig 49
class SCRIBUS_API ScColor
2886 fschmid 50
{
51
public:
7478 jghali 52
 
53
        friend class ScColorEngine;
54
 
55
        /** \brief Constructs a ScColor with 4 Components set to 0 */
56
        ScColor(void);
57
        /** \brief Constructs a ScColor with 4 Components in the range from 0 - 255 */
58
        ScColor(int c, int m, int y, int k);
59
        /** \brief Constructs a RGBColor with 3 Components in the range from 0 - 255 */
60
        ScColor(int r, int g, int b);
4608 cbradney 61
 
7478 jghali 62
        bool operator==(const ScColor& other) const;
2886 fschmid 63
 
7478 jghali 64
        /** \brief Set color from an existing document */
65
        void setColor(ScribusDoc* doc, const QString& name);
5880 jghali 66
 
4645 subik 67
        /** \brief Same as the Constructor but for an existing Color */
2886 fschmid 68
        void setColor(int c, int m, int y, int k);
69
 
4645 subik 70
        /** \brief Computes a ScColor from an RGB-Color
71
        * Applies Gray-Component-Removal to the resulting ScColor
72
        * or if color management is enabled, an approriate transform */
2886 fschmid 73
        void setColorRGB(int r, int g, int b);
74
 
4645 subik 75
        /** \brief get the color model */
7478 jghali 76
        colorModel getColorModel () const;
2886 fschmid 77
 
4645 subik 78
        /** \brief Computes a ScColor for a QColor */
2886 fschmid 79
        void fromQColor(QColor color);
80
 
7478 jghali 81
        /** \brief Returns the RGB color  
82
        * Must not be called if color is the None Color. */
5880 jghali 83
        void getRawRGBColor(int *r, int *g, int *b) const;
84
        QColor getRawRGBColor() const;
2886 fschmid 85
 
7478 jghali 86
        /** \brief Returns the 4 Values that form an ScColor.
87
        * Returns meaningful results only if color is a cmyk color.
88
        * Must not be called if color is the None Color. */
5880 jghali 89
        void getCMYK(int *c, int *m, int *y, int *k) const;
2886 fschmid 90
 
7478 jghali 91
        /** \brief Returns the 3 Values that form an RGBColor
92
        * Returns meaningful results only if color is a rgb color.
93
        * Must not be called if color is the None Color. */
5880 jghali 94
        void getRGB(int *r, int *g, int *b) const;
2886 fschmid 95
 
7478 jghali 96
        /** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK for a CMYK color or ##RRGGBB for a RGB color.
97
        * For the None color return the "None" string. */
2886 fschmid 98
        QString name();
7478 jghali 99
        /** \brief Returns the ScColor as an Hex-String in the Form #RRGGBB
7857 jghali 100
        * If doc member is not specified, return meaningful result only for RGB colors. */
101
        QString nameRGB(const ScribusDoc* doc = NULL);
7478 jghali 102
        /** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK
7857 jghali 103
        * If doc member is not specified, return meaningful result only for CMYK colors. */
104
        QString nameCMYK(const ScribusDoc* doc = NULL);
2886 fschmid 105
 
7478 jghali 106
        /** \brief Sets the Values of a color from an Hex-String in the Form #CCMMYYKK or #RRGGBB */
2886 fschmid 107
        void setNamedColor(QString nam);
7478 jghali 108
 
109
        /** \brief If the color is a spot color */
110
        bool isSpotColor() const;
111
        /** \brief Set a color to be a spot color or not. No effect if color is the None color. */
3051 fschmid 112
        void setSpotColor(bool s);
7478 jghali 113
        /** \brief If the color is a registration color */
114
        bool isRegistrationColor() const;
115
        /** \brief Set a color to be a registration color or not. No effect if color is the None color. */
3060 fschmid 116
        void setRegistrationColor(bool s);
2886 fschmid 117
 
118
private:
5880 jghali 119
 
7478 jghali 120
        /** \brief Cyan or Red Component of Color (depends of color model)*/
121
        int CR;
122
        /** \brief Magenta or Green Component of Color (depends of color model)*/
123
        int MG;
124
        /** \brief Yellow or Blue Component of Color (depends of color model)*/
125
        int YB;
4645 subik 126
        /** \brief Black-Component of Color */
2886 fschmid 127
        int K;
128
 
4645 subik 129
        /** \brief Flag, true if the Color is a Spotcolor */
2886 fschmid 130
        bool Spot;
4645 subik 131
        /** \brief Flag, true if the Color is a Registration color */
3060 fschmid 132
        bool Regist;
4645 subik 133
        /** \brief Color model of the current color */
2886 fschmid 134
        colorModel Model;
135
};
136
 
5880 jghali 137
class SCRIBUS_API ColorList : public QMap<QString,ScColor>
138
{
139
protected:
140
        QGuardedPtr<ScribusDoc> m_doc;
141
        bool m_retainDoc;
9293 jghali 142
 
143
        /** \brief Ensure availability of black color. */
144
        void ensureBlack(void);
145
 
146
        /** \brief Ensure availability of white color. */
147
        void ensureWhite(void);
148
 
5880 jghali 149
public:
150
        ColorList(ScribusDoc* doc = NULL, bool retainDoc = false);
3251 craig 151
 
5880 jghali 152
        ColorList& operator= (const ColorList& list);
153
 
7478 jghali 154
        /** \brief Get the document the list is related */
155
        ScribusDoc* document(void) { return m_doc; }
5880 jghali 156
 
7478 jghali 157
        /** \brief Assign the doc to which the list belong to.*/
5880 jghali 158
        void setDocument(ScribusDoc* doc);
159
 
7478 jghali 160
        /** \brief Add colors from the specified list. Colors are added using shadow copy.*/
5880 jghali 161
        void addColors(const ColorList& colorList, bool overwrite = TRUE);
162
 
7478 jghali 163
        /** \brief Copy colors from the specified list.*/
5880 jghali 164
        void copyColors(const ColorList& colorList, bool overwrite = TRUE);
9293 jghali 165
 
166
        /** \brief Ensure availability of black and white colors. */
167
        void ensureBlackAndWhite(void);
5880 jghali 168
};
169
 
2886 fschmid 170
#endif