]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/comafx/DialogColorPicker.h
hello world
[icculus/iodoom3.git] / neo / tools / comafx / DialogColorPicker.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #ifndef __DIALOGCOLORPICKER__
30 #define __DIALOGCOLORPICKER__
31
32 // Original ColorPicker/DIB source by Rajiv Ramachandran <rrajivram@hotmail.com>
33 // included with permission from the author
34
35 #include "CDib.h"
36
37 #define RADIUS          100
38 #define PI                      3.14159265358
39
40 #define RECT_WIDTH      5
41
42 #define TOSCALE(x)      (((x)*RADIUS)/255.0)
43 #define SCALETOMAX(x) (((x)*255.0)/RADIUS)
44
45
46 #define RED     0
47 #define GREEN 1
48 #define BLUE 2
49
50 #define BAD_SLOPE       1000000.0
51
52
53 struct HSVType;
54
55 struct RGBType {
56         COLORREF                color() { return RGB( r, g, b ); }
57         HSVType                 toHSV();
58         int                             r, g, b;
59 };
60
61 struct HSVType {
62         RGBType                 toRGB();
63         int                             h, s, v;
64 };
65
66 struct LineDesc {
67         double                  x, y;
68         double                  slope;
69         double                  c;
70 };
71
72
73 class CDialogColorPicker : public CDialog
74 {
75 // Construction
76 public:
77                                         CDialogColorPicker(COLORREF c,CWnd* pParent = NULL);   // standard constructor
78                                         ~CDialogColorPicker();
79
80         COLORREF                GetColor() { return color.color();};
81         float                   GetOverBright() { return overBright; };
82
83
84         // Dialog Data
85         //{{AFX_DATA(CDialogColorPicker)
86         enum { IDD = IDD_DIALOG_COLORS };
87         float                   m_overBright;
88         //}}AFX_DATA
89
90         void                    (*UpdateParent)( float r, float g, float b, float a );
91
92         // Overrides
93         // ClassWizard generated virtual function overrides
94         //{{AFX_VIRTUAL(CDialogColorPicker)
95         //}}AFX_VIRTUAL
96
97 // Implementation
98 protected:
99
100         // Generated message map functions
101         //{{AFX_MSG(CDialogColorPicker)
102         afx_msg void    OnLButtonDown(UINT nFlags, CPoint point);
103         afx_msg void    OnLButtonUp(UINT nFlags, CPoint point);
104         afx_msg void    OnMouseMove(UINT nFlags, CPoint point);
105         afx_msg void    OnSysColorChange();
106         afx_msg void    OnPaint();
107         virtual BOOL    OnInitDialog();
108         afx_msg void    OnChangeEditBlue();
109         afx_msg void    OnChangeEditGreen();
110         afx_msg void    OnChangeEditHue();
111         afx_msg void    OnChangeEditRed();
112         afx_msg void    OnChangeEditSat();
113         afx_msg void    OnChangeEditVal();
114         afx_msg void    OnChangeEditOverbright();
115         afx_msg void    OnTimer(UINT nIDEvent);
116         afx_msg void    OnBtnColor();
117         //}}AFX_MSG
118         DECLARE_MESSAGE_MAP()
119
120         void                    DrawFilledColor(CDC *pDC,CRect cr,COLORREF c);
121         void                    DrawLines(CDC *pDC);
122         void                    DrawXorRect(CDC *pDC,CRect& cr);
123         void                    CalcSlopes();
124         void                    CalcCuboid();
125
126         void                    CreateBrightDIB();
127         void                    SetDIBPalette();
128         void                    DrawMarkers(CDC *pDC);
129         void                    TrackPoint(CPoint pt);
130         void                    CalcRects();
131                 
132         BOOL                    InCircle(CPoint pt);
133         BOOL                    InBright(CPoint pt);
134         BOOL                    InOverBright(CPoint pt);
135
136
137         void                    SetSpinVals();
138         void                    SetEditVals();
139         void                    DrawAll();
140
141         void                    DrawRGB(CDC *pDC);
142         void                    DrawHSB(CDC *pDC);
143
144         void                    LoadMappedBitmap(CBitmap& bitmap,UINT nIdResource,CSize& size);
145
146         CBitmap                 m_RgbBitmap,m_HsbBitmap;
147
148         CDC                             memDC;
149         CPoint                  m_Centre;
150         CDIB                    m_BrightDIB;
151
152         int                             rgbWidth;
153         int                             rgbHeight;
154         int                             hsbWidth;
155         int                             hsbHeight;
156
157         int                             m_nMouseIn;
158         CRect                   m_CurrentRect,brightMark;
159         CRect                   brightRect;
160         CRect                   overBrightRect;
161
162         HSVType                 hsvColor;       
163
164         RGBType                 color;
165         RGBType                 m_OldColor;
166         CPoint                  Vertex;
167         CPoint                  Top;
168         CPoint                  Left;
169         CPoint                  Right;
170         CRect                   rects[3];
171         CPoint                  m_Cuboid[8];
172         BOOL                    m_bInMouse;
173         int                             nIndex;
174         int                             RedLen;
175         int                             GreenLen;
176         int                             BlueLen;
177         LineDesc                lines[3];
178
179
180         CRect                   rgbRect;
181         CRect                   hsbRect;
182         CRect                   OldColorRect;
183         CRect                   NewColorRect;
184
185         BOOL                    m_bInitOver;
186         BOOL                    m_bInDrawAll;
187
188         float                   overBright;
189 };
190
191 bool DoNewColor( int* i1, int* i2, int* i3, float *overBright, void (*Update)( float, float, float, float ) = NULL );
192
193 #endif /* !__DIALOGCOLORPICKER__ */