1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 CColors::COLOR_DATA
CColors::m_ColorArray
[]=
24 {Cmd
,_T("Software\\TortoiseGit\\Colors\\Cmd"),RGB(100, 100, 100)},
25 {Conflict
,_T("Software\\TortoiseGit\\Colors\\Conflict"), RGB(255, 0, 0)},
26 {Modified
,_T("Software\\TortoiseGit\\Colors\\Modified"), RGB(0, 50, 160)},
27 {Merged
,_T("Software\\TortoiseGit\\Colors\\Merged"), RGB(0, 100, 0)},
28 {Deleted
,_T("Software\\TortoiseGit\\Colors\\Deleted"), RGB(100, 0, 0)},
29 {Added
,_T("Software\\TortoiseGit\\Colors\\Added"), RGB(100, 0, 100)},
30 {LastCommit
,_T("Software\\TortoiseGit\\Colors\\LastCommit"), RGB(100, 100, 100)},
31 {DeletedNode
,_T("Software\\TortoiseGit\\Colors\\DeletedNode"), RGB(255, 0, 0)},
32 {AddedNode
,_T("Software\\TortoiseGit\\Colors\\AddedNode"), RGB(0, 255, 0)},
33 {ReplacedNode
,_T("Software\\TortoiseGit\\Colors\\ReplacedNode"), RGB(0, 255, 0)},
34 {RenamedNode
,_T("Software\\TortoiseGit\\Colors\\RenamedNode"), RGB(0, 0, 255)},
35 {LastCommitNode
,_T("Software\\TortoiseGit\\Colors\\LastCommitNode"), RGB(200, 200, 200)},
36 {PropertyChanged
,_T("Software\\TortoiseGit\\Colors\\PropertyChanged"), RGB(0, 50, 160)},
37 {CurrentBranch
,_T("Software\\TortoiseGit\\Colors\\CurrentBranch"), RGB(200, 0, 0)},
38 {LocalBranch
,_T("Software\\TortoiseGit\\Colors\\LocalBranch"), RGB(0, 195, 0)},
39 {RemoteBranch
,_T("Software\\TortoiseGit\\Colors\\RemoteBranch"), RGB(255, 221, 170)},
40 {Tag
,_T("Software\\TortoiseGit\\Colors\\Tag"), RGB(255, 255, 0)},
41 {Stash
,_T("Software\\TortoiseGit\\Colors\\Stash"), RGB(128, 128, 128)},
42 {BranchLine1
,_T("Software\\TortoiseGit\\Colors\\BranchLine1"), RGB(0,0,0)},
43 {BranchLine2
,_T("Software\\TortoiseGit\\Colors\\BranchLine2"), RGB(0xFF,0,0)},
44 {BranchLine3
,_T("Software\\TortoiseGit\\Colors\\BranchLine3"), RGB(0,0xFF,0)},
45 {BranchLine4
,_T("Software\\TortoiseGit\\Colors\\BranchLine4"), RGB(0,0,0xFF)},
46 {BranchLine5
,_T("Software\\TortoiseGit\\Colors\\BranchLine5"), RGB(128,128,128)},
47 {BranchLine6
,_T("Software\\TortoiseGit\\Colors\\BranchLine6"), RGB(128,128,0)},
48 {BranchLine7
,_T("Software\\TortoiseGit\\Colors\\BranchLine7"), RGB(0,128,128)},
49 {BranchLine8
,_T("Software\\TortoiseGit\\Colors\\BranchLine8"), RGB(128,0,128)},
50 {BisectGood
,_T("Software\\TortoiseGit\\Colors\\BisectGood"), RGB(0,100,200)},
51 {BisectBad
, _T("Software\\TortoiseGit\\Colors\\BisectBad"), RGB(255,0,0)},
52 {COLOR_END
,_T("Software\\TortoiseGit\\Colors\\END"),RGB(0,0,0)},
56 CColors::CColors(void)
60 CColors::~CColors(void)
64 COLORREF
CColors::GetColor(Colors col
, bool bDefault
/*=true*/)
69 if(m_ColorArray
[i
].Color
== COLOR_END
)
72 if(m_ColorArray
[i
].Color
== col
)
75 return m_ColorArray
[i
].Default
;
78 CRegDWORD
reg(m_ColorArray
[i
].RegKey
,m_ColorArray
[i
].Default
);
79 return (COLORREF
)(DWORD
) reg
;
87 void CColors::SetColor(Colors col
, COLORREF cr
)
92 if(m_ColorArray
[i
].Color
== COLOR_END
)
95 if(m_ColorArray
[i
].Color
== col
)
97 CRegDWORD
reg(m_ColorArray
[i
].RegKey
,m_ColorArray
[i
].Default
);
106 COLORREF
CColors::MixColors(COLORREF baseColor
, COLORREF newColor
, unsigned char mixFactor
)
111 colRed
= ((float)( baseColor
&0x000000FF) -(float)( newColor
&0x000000FF) )*mixFactor
/0xFF;//red
112 colGreen
= ((float)((baseColor
&0x0000FF00)>>8) -(float)((newColor
&0x0000FF00)>>8 ))*mixFactor
/0xFF;//green
113 colBlue
= ((float)((baseColor
&0x00FF0000)>>16)-(float)((newColor
&0x00FF0000)>>16))*mixFactor
/0xFF;//blue
115 colRed
= ( baseColor
&0x000000FF) -colRed
;
116 colGreen
= ((baseColor
&0x0000FF00)>>8) -colGreen
;
117 colBlue
= ((baseColor
&0x00FF0000)>>16) -colBlue
;
118 baseColor
=(int)colRed
|((int)colGreen
<<8)|((int)colBlue
<<16);
122 COLORREF
CColors::Lighten(COLORREF baseColor
, unsigned char amount
)
124 return MixColors(baseColor
, RGB(255,255,255), amount
);
127 COLORREF
CColors::Darken(COLORREF baseColor
, unsigned char amount
)
129 return MixColors(baseColor
, RGB(0,0,0), amount
);