Laxkit  0.0.7.1
palette.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) 2004-2007,2010 by Tom Lechner
22 //
23 #ifndef _LAX_PALETTE_H
24 #define _LAX_PALETTE_H
25 
26 #include <lax/dump.h>
27 #include <lax/anxapp.h>
28 #include <lax/anobject.h>
29 #include <lax/rectangles.h>
30 #include <lax/lists.h>
31 #include <lax/buttondowninfo.h>
32 
33 namespace Laxkit {
34 
35 #define LAX_GIMP_PALETTE 1
36 
37 //-------------------------------- Palette/PaletteEntry -----------------------------
39 {
40  public:
41  int *channels;
42  int numcolors;
43  int color_space;
44  int maxcolor;
45  char *name;
46  PaletteEntry(const char *nname,int n,int *v,int space,int max=255);
47  ~PaletteEntry();
48 };
49 
50 class Palette : public LaxFiles::DumpUtility, public anObject
51 {
52  public:
53  int defaultmaxcolor;
54  int default_colorspace;
55  char *filename;
56  char *name;
57  char is_read_in;
58  int columns;
60  Palette();
61  virtual ~Palette();
62 
63  virtual void dump_out(FILE *f,int indent,int what,anObject *savecontext);
64  virtual void dump_in (FILE *f,int indent,int what,anObject *loadcontext,LaxFiles::Attribute **att);
65  virtual LaxFiles::Attribute *dump_out_atts(LaxFiles::Attribute *att,int what,anObject *savecontext);
66  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,anObject *loadcontext);
67 
68  virtual int AddRGB(const char *name, int r, int g, int b, int max);
69  virtual int AddRGBA(const char *name, int r, int g, int b, int a, int max);
70  virtual int AddCMYK(const char *name, int c, int m, int y, int k, int max);
71  virtual int AddCMYKA(const char *name, int c, int m, int y, int k, int a, int max);
72  virtual int AddGray(const char *name, int g,int max);
73  virtual int AddGrayA(const char *name, int g,int a,int max);
74 };
75 
76 Palette *rainbowPalette(int w,int h,int max,int include_gray_strip);
77 
78 //-------------------------------- PaletteWindow -----------------------------
79 
80 #define PALW_DBCLK_TO_LOAD (1<<16)
81 
82 class PaletteWindow : public anXWindow
83 {
84  protected:
85  int xn,yn;
86  double dx,dy;
87  ButtonDownInfo buttondown;
88  public:
89  Palette *palette;
90  int curcolor,ccolor;
91  IntRectangle inrect;
92  PaletteWindow(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
93  int xx,int yy,int ww,int hh,int brder,
94  anXWindow *prev,unsigned long nowner,const char *nsend);
95  virtual ~PaletteWindow();
96  virtual const char *whattype() { return "PaletteWindow"; }
97  virtual int Event(const EventData *e,const char *mes);
98  virtual int send();
99  virtual int LBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
100  virtual int LBUp(int x,int y,unsigned int state,const LaxMouse *d);
101  virtual int RBUp(int x,int y,unsigned int state,const LaxMouse *d);
102  virtual int MouseMove(int x,int y,unsigned int state,const LaxMouse *d);
103  virtual void Refresh();
104  virtual void findInrect();
105  virtual int findColorIndex(int x,int y);
106  virtual int MoveResize(int nx,int ny,int nw,int nh);
107  virtual int Resize(int nw,int nh);
108 
109  virtual const char *PaletteDir();
110  virtual int LoadPalette(const char *file);
111 };
112 
113 } //namespace Laxkit;
114 
115 #endif
116 

Mon Feb 17 2014 11:52:57, Laxkit