doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogColorPicker.h
Go to the documentation of this file.
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
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 
147 
148  CDC memDC;
149  CPoint m_Centre;
151 
152  int rgbWidth;
154  int hsbWidth;
156 
159  CRect brightRect;
161 
163 
166  CPoint Vertex;
167  CPoint Top;
168  CPoint Left;
169  CPoint Right;
170  CRect rects[3];
171  CPoint m_Cuboid[8];
173  int nIndex;
174  int RedLen;
175  int GreenLen;
176  int BlueLen;
178 
179 
180  CRect rgbRect;
181  CRect hsbRect;
184 
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__ */
afx_msg void OnChangeEditSat()
GLubyte g
Definition: glext.h:4662
CDialogColorPicker(COLORREF c, CWnd *pParent=NULL)
BOOL InCircle(CPoint pt)
bool DoNewColor(int *i1, int *i2, int *i3, float *overBright, void(*Update)(float, float, float, float)=NULL)
void TrackPoint(CPoint pt)
afx_msg void OnChangeEditOverbright()
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
BOOL InOverBright(CPoint pt)
void DrawXorRect(CDC *pDC, CRect &cr)
afx_msg void OnChangeEditVal()
virtual BOOL OnInitDialog()
HSVType toHSV()
#define IDD_DIALOG_COLORS
void DrawFilledColor(CDC *pDC, CRect cr, COLORREF c)
#define BOOL
Definition: mprintf.c:71
void LoadMappedBitmap(CBitmap &bitmap, UINT nIdResource, CSize &size)
GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte * bitmap
Definition: qgl.h:183
afx_msg void OnSysColorChange()
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
const GLubyte * c
Definition: glext.h:4677
afx_msg void OnChangeEditBlue()
#define NULL
Definition: Lib.h:88
void(* UpdateParent)(float r, float g, float b, float a)
afx_msg void OnChangeEditGreen()
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
GLubyte GLubyte b
Definition: glext.h:4662
GLdouble GLdouble GLdouble r
Definition: glext.h:2951
void DrawLines(CDC *pDC)
COLORREF color()
afx_msg void OnTimer(UINT nIDEvent)
RGBType toRGB()
GLint GLint i2
Definition: qgl.h:261
GLsizeiptr size
Definition: glext.h:3112
Definition: CDIB.h:35
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLint i1
Definition: qgl.h:261
afx_msg void OnChangeEditHue()
afx_msg void OnLButtonDown(UINT nFlags, CPoint point)
BOOL InBright(CPoint pt)
void DrawMarkers(CDC *pDC)
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
afx_msg void OnChangeEditRed()