Laxkit  0.0.7.1
colors.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2009-2010,2012 by Tom Lechner
22 //
23 #ifndef _LAX_COLORS_H
24 #define _LAX_COLORS_H
25 
26 
27 #include <lax/refptrstack.h>
28 #include <lax/anobject.h>
29 #include <lax/dump.h>
30 #include <lax/screencolor.h>
31 #include <lax/events.h>
32 
33 //#include <lcms.h>
34 
35 
36 namespace Laxkit {
37 
38 #define LAX_COLOR_RGB 1
39 #define LAX_COLOR_CMYK 2
40 #define LAX_COLOR_GRAY 3
41 
42 enum SimpleColorId {
43  COLOR_Foreground,
44  COLOR_Background,
45  COLOR_Stroke,
46  COLOR_Fill,
47  COLOR_Controls,
48  COLOR_MAX
49 };
50 
51 //------------------------------- SimpleColorEventData ------------------------------
53 {
54  public:
55  int numchannels;
56  int *channels;
57  int max;
58  int colortype; //LAX_COLOR_RGB, LAX_COLOR_CMYK, or LAX_COLOR_GRAY
59  int id;
61  SimpleColorEventData(int nmax, int gray,int a, int nid);
62  SimpleColorEventData(int nmax, int r, int g, int b, int a, int nid);
63  SimpleColorEventData(int nmax, int c, int m, int y, int k, int a, int nid);
64  virtual ~SimpleColorEventData();
65 };
66 
67 
68 
69 //------------------------------- ColorPrimary -------------------------------
71 {
72  public:
73  char *name;
74  double maxvalue;
75  double minvalue;
76  ScreenColor screencolor;
77 
78  LaxFiles::Attribute atts; //*** this could be a ColorAttribute class, to allow ridiculously adaptable color systems
79  // like being able to define a sparkle or metal speck fill pattern
80  // for each i'th attribute
81  ColorPrimary();
82  virtual ~ColorPrimary();
83 };
84 
85 //------------------------------- ColorSystem -------------------------------
86 
87 #define COLOR_ADDITIVE (1<<0)
88 #define COLOR_SUBTRACTIVE (1<<1)
89 #define COLOR_SPOT (1<<2)
90 #define COLOR_ALPHAOK (1<<3)
91 #define COLOR_SPECIAL_INK (1<<4)
92 
93 class Color;
94 
96 {
97  public:
98  char *name;
99  unsigned int systemid;
100  unsigned long style;
101 
102  //cmsHPROFILE iccprofile;
103  PtrStack<ColorPrimary> primaries;
104 
105  ColorSystem();
106  virtual ~ColorSystem();
107 
108  virtual Color *newColor(int n,...);
109  virtual int AlphaChannel() = 0;
110 
111  //return an image tile representing the color, speckled inks, for instance
112  //virtual LaxImage *PaintPattern(Color *color);
113 };
114 
115 
116 
117 //------------------------------- Color -------------------------------
119 {
120  public:
121  int id;
122  char *name; //optional color instance name
123  double alpha; //additional to any alpha defined in ColorSystem itself
124 
125  ColorSystem *system;
126  int colorsystemid; //usually same as system->systemid;
127  int n; // num values, put here so you don't have to always look them up in system definition
128  double *values; // the values for each primary
129 
130  Color();
131  virtual ~Color();
132  Color(const Color &l);
133  Color &operator=(Color &l);
134  virtual int ColorSystedId() { return system ? system->systemid : colorsystemid; }
135  virtual double ChannelValue(int channel);
136  virtual int ChannelValueInt(int channel, int *error_ret=NULL);
137  virtual double Alpha();
138 };
139 
140 
141 
142 //------------------------------ ColorSet ----------------------------------
144 {
145  public:
146  unsigned int setstyle;
147  char *name;
148  RefPtrStack<Color> colors;
149  ColorSet();
150  virtual ~ColorSet();
151 };
152 
154 //
155 // todo!
156 
157 
158 } //namespace Laxkit
159 
160 
161 #endif
162 
163 

Mon Feb 17 2014 11:52:56, Laxkit