Drop unused msysgit dialog of installer
[TortoiseGit.git] / src / TortoiseProc / Colors.cpp
blob04a4ea77d68d7922054b4e6b23c687ad6002ec38
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
4 // Copyright (C) 2009-2013 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "Colors.h"
23 CColors::COLOR_DATA CColors::m_ColorArray[]=
25 {Cmd,_T("Software\\TortoiseGit\\Colors\\Cmd"),RGB(100, 100, 100)},
26 {Conflict,_T("Software\\TortoiseGit\\Colors\\Conflict"), RGB(255, 0, 0)},
27 {Modified,_T("Software\\TortoiseGit\\Colors\\Modified"), RGB(0, 50, 160)},
28 {Merged,_T("Software\\TortoiseGit\\Colors\\Merged"), RGB(0, 100, 0)},
29 {Deleted,_T("Software\\TortoiseGit\\Colors\\Deleted"), RGB(100, 0, 0)},
30 {Added,_T("Software\\TortoiseGit\\Colors\\Added"), RGB(100, 0, 100)},
31 {LastCommit,_T("Software\\TortoiseGit\\Colors\\LastCommit"), RGB(100, 100, 100)},
32 {NoteNode,_T("Software\\TortoiseGit\\Colors\\NoteNode"), RGB(160, 160, 0)},
33 {Renamed,_T("Software\\TortoiseGit\\Colors\\Renamed"), RGB(0, 0, 255)},
34 {LastCommitNode,_T("Software\\TortoiseGit\\Colors\\LastCommitNode"), RGB(200, 200, 200)},
35 {PropertyChanged,_T("Software\\TortoiseGit\\Colors\\PropertyChanged"), RGB(0, 50, 160)},
36 {CurrentBranch,_T("Software\\TortoiseGit\\Colors\\CurrentBranch"), RGB(200, 0, 0)},
37 {LocalBranch,_T("Software\\TortoiseGit\\Colors\\LocalBranch"), RGB(0, 195, 0)},
38 {RemoteBranch,_T("Software\\TortoiseGit\\Colors\\RemoteBranch"), RGB(255, 221, 170)},
39 {Tag,_T("Software\\TortoiseGit\\Colors\\Tag"), RGB(255, 255, 0)},
40 {Stash,_T("Software\\TortoiseGit\\Colors\\Stash"), RGB(128, 128, 128)},
41 {BranchLine1,_T("Software\\TortoiseGit\\Colors\\BranchLine1"), RGB(0,0,0)},
42 {BranchLine2,_T("Software\\TortoiseGit\\Colors\\BranchLine2"), RGB(0xFF,0,0)},
43 {BranchLine3,_T("Software\\TortoiseGit\\Colors\\BranchLine3"), RGB(0,0xFF,0)},
44 {BranchLine4,_T("Software\\TortoiseGit\\Colors\\BranchLine4"), RGB(0,0,0xFF)},
45 {BranchLine5,_T("Software\\TortoiseGit\\Colors\\BranchLine5"), RGB(128,128,128)},
46 {BranchLine6,_T("Software\\TortoiseGit\\Colors\\BranchLine6"), RGB(128,128,0)},
47 {BranchLine7,_T("Software\\TortoiseGit\\Colors\\BranchLine7"), RGB(0,128,128)},
48 {BranchLine8,_T("Software\\TortoiseGit\\Colors\\BranchLine8"), RGB(128,0,128)},
49 {BisectGood,_T("Software\\TortoiseGit\\Colors\\BisectGood"), RGB(0,100,200)},
50 {BisectBad, _T("Software\\TortoiseGit\\Colors\\BisectBad"), RGB(255,0,0)},
51 {COLOR_END,_T("Software\\TortoiseGit\\Colors\\END"),RGB(0,0,0)},
55 CColors::CColors(void)
59 CColors::~CColors(void)
63 COLORREF CColors::GetColor(Colors col, bool bDefault /*=true*/)
65 int i=0;
66 while(1)
68 if(m_ColorArray[i].Color == COLOR_END)
69 return RGB(0,0,0);
71 if(m_ColorArray[i].Color == col)
73 if(bDefault)
74 return m_ColorArray[i].Default;
75 else
77 CRegDWORD reg(m_ColorArray[i].RegKey,m_ColorArray[i].Default);
78 return (COLORREF)(DWORD) reg;
82 ++i;
86 void CColors::SetColor(Colors col, COLORREF cr)
88 int i=0;
89 while(1)
91 if(m_ColorArray[i].Color == COLOR_END)
92 break;
94 if(m_ColorArray[i].Color == col)
96 CRegDWORD reg(m_ColorArray[i].RegKey,m_ColorArray[i].Default);
97 reg=cr;
100 ++i;
105 COLORREF CColors::MixColors(COLORREF baseColor, COLORREF newColor, unsigned char mixFactor)
107 short colRed;
108 short colGreen;
109 short colBlue;
110 colRed = (short)((float)( baseColor&0x000000FF) -(float)( newColor&0x000000FF) )*mixFactor/0xFF;//red
111 colGreen = (short)((float)((baseColor&0x0000FF00)>>8) -(float)((newColor&0x0000FF00)>>8 ))*mixFactor/0xFF;//green
112 colBlue = (short)((float)((baseColor&0x00FF0000)>>16)-(float)((newColor&0x00FF0000)>>16))*mixFactor/0xFF;//blue
114 colRed = ( baseColor&0x000000FF) -colRed;
115 colGreen = ((baseColor&0x0000FF00)>>8) -colGreen;
116 colBlue = ((baseColor&0x00FF0000)>>16) -colBlue;
117 baseColor=(int)colRed|((int)colGreen<<8)|((int)colBlue<<16);
118 return baseColor;
121 COLORREF CColors::Lighten(COLORREF baseColor, unsigned char amount)
123 return MixColors(baseColor, RGB(255,255,255), amount);
126 COLORREF CColors::Darken(COLORREF baseColor, unsigned char amount)
128 return MixColors(baseColor, RGB(0,0,0), amount);