29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/Radiant_resource.h"
35 #ifdef ID_DEBUG_MEMORY
81 #define SECTION _T("Custom Colors")
86 entry.Format(
"tool_color%d",
i);
89 c_LastCustColors[
i] = c_CustColors[
i] = cvar->
GetInteger();
91 c_LastCustColors[
i] = c_CustColors[
i] = RGB( 255, 255, 255 );
99 if ( c_LastCustColors[
i] != c_CustColors[
i] ) {
101 entry.Format(
"tool_color%d", i );
102 if ( c_CustColors[i] == RGB( 255, 255, 255 ) ) {
107 c_LastCustColors[
i] = c_CustColors[
i];
113 CWnd* pParentWnd) : CColorDialog(clrInit,dwFlags,pParentWnd)
124 int code = CColorDialog::DoModal();
131 CColorDialog::DoDataExchange(pDX);
144 return dlg.GetColor();
159 #define IN_OVERBRIGHT 3
161 int Distance(CPoint pt1,CPoint pt2);
164 double Slope( CPoint pt1,CPoint pt2 ) {
208 return CPoint((
int)x,(
int)y);
228 double x,
y,m,
a,
c,C,
A;
240 m = (double)(pt2.y - pt1.y)/(pt2.x - pt1.x);
243 c = (double)pt1.y - m * (
double)pt1.x;
258 pt = CPoint((
int)x,(
int)y);
263 pt = CPoint((
int)x,(
int)y);
271 pt = CPoint((
int)x,(
int)y);
276 pt = CPoint((
int)x,(
int)y);
296 a = (double)x + (
double)
y ;
305 y = -1 * (pt.y - center.y);
324 x = sat * cos(angle);
325 y = sat * sin(angle);
329 pt = CPoint((
int)x,(
int)y);
341 rgb.
r = rgb.
g = rgb.
b =
v;
347 delta = (max *
s)/255.0;
351 if(
h > 300 ||
h <= 60)
357 hue = (hue - 360.0)/60.0;
358 rgb.
b = (
int)((hue * delta - min) * -1);
364 rgb.
g = (
int)(hue * delta + min);
367 else if(
h > 60 &&
h < 180)
373 hue = (hue/60.0 - 2.0 ) * delta;
374 rgb.
r = (
int)(min - hue);
379 hue = (hue/60 - 2.0) * delta;
380 rgb.
b = (
int)(min + hue);
389 hue = (hue/60.0 - 4.0 ) * delta;
390 rgb.
g = (
int)(min - hue);
395 hue = (hue/60 - 4.0) * delta;
396 rgb.
r = (
int)(min + hue);
407 double min,
max,delta,temp;
409 min = __min(
r,__min(
g,
b));
410 max = __max(
r,__max(
g,
b));
421 hsv.
s = (
int)(temp*255);
425 temp = (double)(
g-
b)/delta;
430 temp = 2.0 + ((double)(
b-
r)/delta);
434 temp = 4.0 + ((double)(
r-
g)/delta);
463 Left = CPoint(23,147);
464 Right = CPoint(181,147);
497 ON_WM_SYSCOLORCHANGE()
515 if(hsbRect.PtInRect(point)) {
517 if(InCircle(point)) {
519 }
else if (InBright(point)) {
521 }
else if (InOverBright(point)) {
532 else if (rgbRect.PtInRect(point)) {
534 if(rects[
RED].PtInRect(point)) {
538 }
else if (rects[
GREEN].PtInRect(point)) {
542 }
else if (rects[
BLUE].PtInRect(point)) {
549 CDialog::OnLButtonDown(nFlags, point);
554 if(GetCapture() ==
this)
559 CDialog::OnLButtonUp(nFlags, point);
655 CDialog::OnMouseMove(nFlags, point);
668 CDialog::OnInitDialog();
684 memDC.CreateCompatibleDC(&dc);
736 SetTimer(0, 50,
NULL);
751 oldPen = (CPen *)pDC->SelectStockObject(WHITE_PEN);
752 oldBrush = (CBrush *)pDC->SelectStockObject(NULL_BRUSH);
754 oldMode = pDC->SetROP2(R2_XORPEN);
758 pen.CreatePen(PS_SOLID,2,RGB(255,255,255));
759 pDC->SelectObject(&pen);
762 pDC->SelectObject(oldPen);
763 pDC->SelectObject(oldBrush);
764 pDC->SetROP2(oldMode);
850 BYTE palette[768],*
p;
858 h.
v = (
int)((
double)
i * d);
886 CBitmap *pOldBitmap ;
891 memDC.SelectObject(pOldBitmap);
899 CBitmap *pOldBitmap ;
903 memDC.SelectObject(pOldBitmap);
915 COLORREF col = RGB(255,255,255);
918 for(
int i = 0;
i < 3;
i++ ) {
927 oldPen = (CPen *)pDC->SelectStockObject(WHITE_PEN);
928 oldMode = pDC->SetROP2(R2_XORPEN);
957 pDC->SelectObject(oldPen);
958 pDC->SetROP2(oldMode);
969 pen.CreatePen(PS_SOLID,1,RGB(255,255,255));
970 oldPen = (CPen *)pDC->SelectObject(&pen);
971 oldBrush = (CBrush *)pDC->SelectStockObject(NULL_BRUSH);
972 oldMode =pDC->SetROP2(R2_XORPEN);
974 pDC->SetROP2(oldMode);
975 pDC->SelectObject(oldPen);
976 pDC->SelectObject(oldBrush);
989 for( i = 0; i < 3; i++ ) {
1022 double rLen,gLen,bLen;
1089 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_RED))->SetRange(0,255);
1090 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_GREEN))->SetRange(0,255);
1091 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_BLUE))->SetRange(0,255);
1093 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_HUE))->SetRange(0,360);
1094 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_SAT))->SetRange(0,255);
1095 ((CSpinButtonCtrl *)GetDlgItem(
IDC_SPIN_VAL))->SetRange(0,255);
1232 pDC->FillSolidRect(&cr,c);
1233 pDC->Draw3dRect(&cr,RGB(0,0,0),RGB(0,0,0));
1234 cr.InflateRect(-1,-1);
1235 pDC->Draw3dRect(&cr,RGB(192,192,192),RGB(128,128,128));
1240 CBitmap *pOldBitmap;
1242 if(bitmap.GetSafeHandle()) bitmap.DeleteObject();
1244 if(bitmap.LoadBitmap(nIdResource))
1250 ::GetObject(bitmap.m_hObject,
sizeof(bmInfo),&bmInfo);
1251 width = bmInfo.bmWidth;
1252 height = bmInfo.bmHeight;
1254 COLORREF colorWindow = ::GetSysColor(COLOR_3DFACE);
1255 COLORREF sourceColor = RGB(192,192,192);
1257 pOldBitmap = (CBitmap *)
memDC.SelectObject(&bitmap);
1261 for(i=0; i <
height; i++)
1263 for(j=0; j <
width; j++)
1265 if(
memDC.GetPixel(j,i) == sourceColor)
1267 memDC.SetPixel(j,i,colorWindow);
1272 memDC.SelectObject(&pOldBitmap);
1273 size = CSize(width,height);
1299 bool DoNewColor(
int*
i1,
int*
i2,
int* i3,
float *overBright,
void (*Update)(
float,
float,
float,
float ) ) {
1300 COLORREF cr = (*i1) + ((*i2) <<8) + ((*i3) <<16);
1304 dlg.UpdateParent = Update;
1306 if ( dlg.DoModal() == IDOK ) {
1307 *i1 = (dlg.GetColor() & 255);
1308 *i2 = ((dlg.GetColor() >> 8) & 255);
1309 *i3 = ((dlg.GetColor() >> 16) & 255);
1310 *overBright = dlg.GetOverBright();
afx_msg void OnChangeEditSat()
CDialogColorPicker(COLORREF c, CWnd *pParent=NULL)
void SetPalette(unsigned char *palette)
#define IDC_SPIN_OVERBRIGHT
idCVarSystem * cvarSystem
void TrackPoint(CPoint pt)
double AngleFromPoint(CPoint pt, CPoint center)
afx_msg void OnChangeEditOverbright()
double Slope(CPoint pt1, CPoint pt2)
CPoint PointOnLine(CPoint pt1, CPoint pt2, int len, int maxlen)
CONST PIXELFORMATDESCRIPTOR UINT
BOOL InOverBright(CPoint pt)
void DrawXorRect(CDC *pDC, CRect &cr)
#define IDC_STATIC_RGB_RECT
afx_msg void OnChangeEditVal()
virtual BOOL OnInitDialog()
CPoint PtFromAngle(double angle, double sat, CPoint center)
static float Sqrt(float x)
void DrawFilledColor(CDC *pDC, CRect cr, COLORREF c)
virtual void SetCVarString(const char *name, const char *value, int flags=0)=0
afx_msg void OnBtnColor()
unsigned char * GetLinePtr(int line)
virtual void DoDataExchange(CDataExchange *pDX)
void LoadMappedBitmap(CBitmap &bitmap, UINT nIdResource, CSize &size)
GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte * bitmap
CPoint Intersection(LineDesc l1, LineDesc l2)
virtual idCVar * Find(const char *name)=0
afx_msg void OnSysColorChange()
static void SaveCustColors()
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
static COLORREF c_LastCustColors[NCUSTCOLORS]
int Distance(CPoint pt1, CPoint pt2)
CMyColorDialog(COLORREF clrInit=0, DWORD dwFlags=0, CWnd *pParentWnd=NULL)
#define IDC_STATIC_HSB_RECT
afx_msg void OnChangeEditBlue()
bool DoNewColor(int *i1, int *i2, int *i3, float *overBright, void(*Update)(float, float, float, float))
int GetInteger(void) const
void(* UpdateParent)(float r, float g, float b, float a)
void BitBlt(HDC hDest, int nXDest, int nYDest, int nWidth, int nHeight, int xSrc, int ySrc)
afx_msg void OnChangeEditGreen()
DECLARE_DYNCREATE(CMyColorDialog)
GLubyte GLubyte GLubyte a
#define IDC_EDIT_OVERBRIGHT
double FindC(LineDesc &l)
GLenum GLsizei GLsizei height
#define IDC_STATIC_NEWCOLOR
GLdouble GLdouble GLdouble r
afx_msg void OnTimer(UINT nIDEvent)
IMPLEMENT_DYNCREATE(CCamWnd, CWnd)
COLORREF DoOldColor(COLORREF cr)
BOOL Create(int width, int height, int bits=24)
afx_msg void OnChangeEditHue()
static void InitCustColors()
char * va(const char *fmt,...)
static bool c_NeedToInitCustColors
void DrawMarkers(CDC *pDC)
static COLORREF c_CustColors[NCUSTCOLORS]
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
afx_msg void OnChangeEditRed()