1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
4 // Copyright (C) 2009-2013, 2016-2017 - 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.
23 CColors::COLOR_DATA
CColors::m_ColorArray
[]=
25 { Cmd
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Cmd", RGB(100, 100, 100)) },
26 { Conflict
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Conflict", RGB(255, 0, 0)) },
27 { Modified
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Modified", RGB(0, 50, 160)) },
28 { Merged
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Merged", RGB(0, 100, 0)) },
29 { Deleted
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Deleted", RGB(100, 0, 0)) },
30 { Added
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Added", RGB(100, 0, 100)) },
31 { LastCommit
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\LastCommit", RGB(100, 100, 100)) },
32 { NoteNode
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\NoteNode", RGB(160, 160, 0)) },
33 { Renamed
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Renamed", RGB(0, 0, 255)) },
34 { LastCommitNode
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\LastCommitNode", RGB(200, 200, 200)) },
35 { PropertyChanged
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\PropertyChanged", RGB(0, 50, 160)) },
36 { CurrentBranch
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\CurrentBranch", RGB(200, 0, 0)) },
37 { LocalBranch
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\LocalBranch", RGB(0, 195, 0)) },
38 { RemoteBranch
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\RemoteBranch", RGB(255, 221, 170)) },
39 { Tag
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Tag", RGB(255, 255, 0)) },
40 { Stash
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\Stash", RGB(128, 128, 128)) },
41 { BranchLine1
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine1", RGB(0, 0, 0)) },
42 { BranchLine2
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine2", RGB(0xFF, 0, 0)) },
43 { BranchLine3
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine3", RGB(0, 0xFF, 0)) },
44 { BranchLine4
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine4", RGB(0, 0, 0xFF)) },
45 { BranchLine5
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine5", RGB(128, 128, 128)) },
46 { BranchLine6
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine6", RGB(128, 128, 0)) },
47 { BranchLine7
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine7", RGB(0, 128, 128)) },
48 { BranchLine8
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BranchLine8", RGB(128, 0, 128)) },
49 { BisectGood
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BisectGood", RGB(0, 100, 200)) },
50 { BisectBad
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BisectBad", RGB(255, 0, 0)) },
51 { BisectSkip
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\BisectBad", RGB(192, 192, 192)) },
52 { OtherRef
, CRegDWORD(L
"Software\\TortoiseGit\\Colors\\OtherRef", RGB(224, 224, 224)) },
55 CColors::CColors(void)
59 CColors::~CColors(void)
63 COLORREF
CColors::GetColor(Colors col
, bool bDefault
/*=true*/)
68 return m_ColorArray
[col
].RegKey
.defaultValue();
70 return (COLORREF
)(DWORD
)m_ColorArray
[col
].RegKey
;
73 void CColors::SetColor(Colors col
, COLORREF cr
)
80 m_ColorArray
[col
].RegKey
= cr
;
84 COLORREF
CColors::MixColors(COLORREF baseColor
, COLORREF newColor
, unsigned char mixFactor
)
89 colRed
= (short)((float)( baseColor
&0x000000FF) -(float)( newColor
&0x000000FF) )*mixFactor
/0xFF;//red
90 colGreen
= (short)((float)((baseColor
&0x0000FF00)>>8) -(float)((newColor
&0x0000FF00)>>8 ))*mixFactor
/0xFF;//green
91 colBlue
= (short)((float)((baseColor
&0x00FF0000)>>16)-(float)((newColor
&0x00FF0000)>>16))*mixFactor
/0xFF;//blue
93 colRed
= ( baseColor
&0x000000FF) -colRed
;
94 colGreen
= ((baseColor
&0x0000FF00)>>8) -colGreen
;
95 colBlue
= ((baseColor
&0x00FF0000)>>16) -colBlue
;
96 baseColor
=(int)colRed
|((int)colGreen
<<8)|((int)colBlue
<<16);
100 COLORREF
CColors::Lighten(COLORREF baseColor
, unsigned char amount
)
102 return MixColors(baseColor
, RGB(255,255,255), amount
);
105 COLORREF
CColors::Darken(COLORREF baseColor
, unsigned char amount
)
107 return MixColors(baseColor
, RGB(0,0,0), amount
);