Laxkit  0.0.7.1
colorsliders.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) 2013 by Tom Lechner
22 //
23 #ifndef _LAX_COLORSLIDERS_H
24 #define _LAX_COLORSLIDERS_H
25 
26 
27 #include <lax/anxapp.h>
28 #include <lax/colorbase.h>
29 #include <lax/buttondowninfo.h>
30 #include <lax/rectangles.h>
31 #include <lax/lists.h>
32 
33 
34 namespace Laxkit {
35 
36 
37 //------------------------------------------- ColorSliders ----------------------------------
38 
39 enum ColorSliderBlockType {
40  COLORBLOCK_RGB,
41  COLORBLOCK_CMYK,
42  COLORBLOCK_HSV,
43  COLORBLOCK_Alpha,
44  COLORBLOCK_Gray,
45  COLORBLOCK_Hue,
46  COLORBLOCK_CieLAB, //unimplemented
47  COLORBLOCK_XYZ, //unimplemented
48  COLORBLACK_MAX
49 };
50 
51 enum ColorSliderType {
52  COLORSLIDER_Red,
53  COLORSLIDER_Green,
54  COLORSLIDER_Blue,
55  COLORSLIDER_Cyan,
56  COLORSLIDER_Magenta,
57  COLORSLIDER_Yellow,
58  COLORSLIDER_Black,
59  COLORSLIDER_Hue,
60  COLORSLIDER_Saturation,
61  COLORSLIDER_Value,
62  COLORSLIDER_Transparency,
63  COLORSLIDER_MAX
64 };
65 
66 enum ColorSlidersStyle {
67  COLORSLIDERS_Vertical = (1<<16),
68  COLORSLIDERS_HideOldNew = (1<<17),
69  COLORSLIDERS_VerticalOldNew = (1<<18),
70  COLORSLIDERS_HideHex = (1<<19),
71  COLORSLIDERS_MAX
72 };
73 
75 {
76  public:
77  int id;
78  int type; //usually one of ColorSliderType
79  int hidden;
80  double pos;
81  ColorBarInfo(int nid,int ntype,double npos=0);
82 };
83 
84 class ColorSliders : public anXWindow, public ColorBase
85 {
86  protected:
87  ButtonDownInfo buttondown;
88  IntRectangle bwcolor, hue;
89  IntRectangle sliders, hex, oldnew;
90  ScreenColor curcolor,original_color;
91 
93  int current, currenthalf;
94  int mouseshape;
95 
96  virtual int send();
97 
98  public:
99  int gap;
100  double step;
101 
102  ColorSliders(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
103  int nx,int ny,int nw,int nh,int brder,
104  anXWindow *prev,unsigned long owner,const char *mes,
105  int ctype, int nmax, int nstep,
106  int c0,int c1,int c2,int c3=-1,int c4=-1);
107  virtual ~ColorSliders();
108  virtual const char *whattype() { return "ColorSliders"; }
109  virtual int init();
110  virtual void updateSliderRect();
111  virtual int Resize(int nw,int nh);
112  virtual int MoveResize(int nx,int ny,int nw,int nh);
113 
114  virtual void Refresh();
115  virtual void DrawVertical(ScreenColor &color1,ScreenColor &color2, int x,int y,int w,int h,double pos,const char *text);
116  virtual void DrawHorizontal(ScreenColor &color1,ScreenColor &color2, int x,int y,int w,int h,double pos,const char *text);
117  virtual void DrawPos(int x,int y,int w,int h, double pos);
118  virtual void DrawOldNew(int x,int y,int w,int h, int horiz);
119 
120  virtual int GetPos(int x,int y, double *pos, int *half);
121  virtual int LBDown(int x,int y,unsigned int state,int count, const LaxMouse *d);
122  virtual int LBUp(int x,int y,unsigned int state, const LaxMouse *d);
123  virtual int MBDown(int x,int y,unsigned int state,int count, const LaxMouse *d);
124  virtual int MBUp(int x,int y,unsigned int state, const LaxMouse *d);
125  virtual int RBDown(int x,int y,unsigned int state,int count, const LaxMouse *d);
126  virtual int RBUp(int x,int y,unsigned int state, const LaxMouse *d);
127  virtual int MouseMove(int mx,int my, unsigned int state, const LaxMouse *d);
128  virtual int WheelUp(int x,int y,unsigned int state,int count,const LaxMouse *d);
129  virtual int WheelDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
130  virtual int CharInput(unsigned int ch,const char *buffer,int len,unsigned int state, const LaxKeyboard *d);
131  virtual int Event(const EventData *e,const char *mes);
132 
133  virtual void Updated();
134  virtual void SetBar(int whichbar, double pos);
135  virtual double GetPosForBar(int whichbar);
136  virtual int FindBar(int type);
137  virtual int EditHex();
138 };
139 
140 
141 
142 
143 } // namespace Laxkit
144 
145 #endif
146 
147 

Mon Feb 17 2014 11:52:56, Laxkit