1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2007-2008, 2010, 2013 - 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.
20 #include "DiffColors.h"
23 CDiffColors
& CDiffColors::GetInstance()
25 static CDiffColors instance
;
30 CDiffColors::CDiffColors(void)
32 m_regForegroundColors
[DIFFSTATE_UNKNOWN
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorUnknownF"), DIFFSTATE_UNKNOWN_DEFAULT_FG
);
33 m_regForegroundColors
[DIFFSTATE_NORMAL
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorNormalF"), DIFFSTATE_NORMAL_DEFAULT_FG
);
34 m_regForegroundColors
[DIFFSTATE_REMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorRemovedF"), DIFFSTATE_REMOVED_DEFAULT_FG
);
35 m_regForegroundColors
[DIFFSTATE_REMOVEDWHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorRemovedWhitespaceF"), DIFFSTATE_REMOVEDWHITESPACE_DEFAULT_FG
);
36 m_regForegroundColors
[DIFFSTATE_ADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorAddedF"), DIFFSTATE_ADDED_DEFAULT_FG
);
37 m_regForegroundColors
[DIFFSTATE_ADDEDWHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorAddedWhitespaceF"), DIFFSTATE_ADDEDWHITESPACE_DEFAULT_FG
);
38 m_regForegroundColors
[DIFFSTATE_WHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorWhitespaceF"), DIFFSTATE_WHITESPACE_DEFAULT_FG
);
39 m_regForegroundColors
[DIFFSTATE_WHITESPACE_DIFF
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorWhitespaceDiffF"), DIFFSTATE_WHITESPACE_DIFF_DEFAULT_FG
);
40 m_regForegroundColors
[DIFFSTATE_EMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorEmptyF"), DIFFSTATE_EMPTY_DEFAULT_FG
);
41 m_regForegroundColors
[DIFFSTATE_CONFLICTED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedF"), DIFFSTATE_CONFLICTED_DEFAULT_FG
);
42 m_regForegroundColors
[DIFFSTATE_CONFLICTED_IGNORED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedIgnoredF"), DIFFSTATE_CONFLICTED_IGNORED_DEFAULT_FG
);
43 m_regForegroundColors
[DIFFSTATE_CONFLICTADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedAddedF"), DIFFSTATE_CONFLICTADDED_DEFAULT_FG
);
44 m_regForegroundColors
[DIFFSTATE_CONFLICTEMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedEmptyF"), DIFFSTATE_CONFLICTEMPTY_DEFAULT_FG
);
45 m_regForegroundColors
[DIFFSTATE_CONFLICTRESOLVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ConflictResolvedF"), DIFFSTATE_CONFLICTRESOLVED_DEFAULT_FG
);
46 m_regForegroundColors
[DIFFSTATE_CONFLICTRESOLVEDEMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ConflictResolvedEmptyF"), DIFFSTATE_CONFLICTRESOLVED_DEFAULT_FG
);
47 m_regForegroundColors
[DIFFSTATE_IDENTICALREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorIdenticalRemovedF"), DIFFSTATE_IDENTICALREMOVED_DEFAULT_FG
);
48 m_regForegroundColors
[DIFFSTATE_IDENTICALADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorIdenticalAddedF"), DIFFSTATE_IDENTICALADDED_DEFAULT_FG
);
49 m_regForegroundColors
[DIFFSTATE_THEIRSREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorTheirsRemovedF"), DIFFSTATE_THEIRSREMOVED_DEFAULT_FG
);
50 m_regForegroundColors
[DIFFSTATE_THEIRSADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorTheirsAddedF"), DIFFSTATE_THEIRSADDED_DEFAULT_FG
);
51 m_regForegroundColors
[DIFFSTATE_YOURSREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorYoursRemovedF"), DIFFSTATE_YOURSREMOVED_DEFAULT_FG
);
52 m_regForegroundColors
[DIFFSTATE_YOURSADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorYoursAddedF"), DIFFSTATE_YOURSADDED_DEFAULT_FG
);
53 m_regForegroundColors
[DIFFSTATE_EDITED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorEditedF"), DIFFSTATE_EDITED_DEFAULT_FG
);
55 m_regBackgroundColors
[DIFFSTATE_UNKNOWN
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorUnknownB"), DIFFSTATE_UNKNOWN_DEFAULT_BG
);
56 m_regBackgroundColors
[DIFFSTATE_NORMAL
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorNormalB"), DIFFSTATE_NORMAL_DEFAULT_BG
);
57 m_regBackgroundColors
[DIFFSTATE_REMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorRemovedB"), DIFFSTATE_REMOVED_DEFAULT_BG
);
58 m_regBackgroundColors
[DIFFSTATE_REMOVEDWHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorRemovedWhitespaceB"), DIFFSTATE_REMOVEDWHITESPACE_DEFAULT_BG
);
59 m_regBackgroundColors
[DIFFSTATE_ADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorAddedB"), DIFFSTATE_ADDED_DEFAULT_BG
);
60 m_regBackgroundColors
[DIFFSTATE_ADDEDWHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorAddedWhitespaceB"), DIFFSTATE_ADDEDWHITESPACE_DEFAULT_BG
);
61 m_regBackgroundColors
[DIFFSTATE_WHITESPACE
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorWhitespaceB"), DIFFSTATE_WHITESPACE_DEFAULT_BG
);
62 m_regBackgroundColors
[DIFFSTATE_WHITESPACE_DIFF
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorWhitespaceDiffB"), DIFFSTATE_WHITESPACE_DIFF_DEFAULT_BG
);
63 m_regBackgroundColors
[DIFFSTATE_EMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorEmptyB"), DIFFSTATE_EMPTY_DEFAULT_BG
);
64 m_regBackgroundColors
[DIFFSTATE_CONFLICTED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedB"), DIFFSTATE_CONFLICTED_DEFAULT_BG
);
65 m_regBackgroundColors
[DIFFSTATE_CONFLICTED_IGNORED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedIgnoredB"), DIFFSTATE_CONFLICTED_IGNORED_DEFAULT_BG
);
66 m_regBackgroundColors
[DIFFSTATE_CONFLICTADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedAddedB"), DIFFSTATE_CONFLICTADDED_DEFAULT_BG
);
67 m_regBackgroundColors
[DIFFSTATE_CONFLICTEMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorConflictedEmptyB"), DIFFSTATE_CONFLICTEMPTY_DEFAULT_BG
);
68 m_regBackgroundColors
[DIFFSTATE_CONFLICTRESOLVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ConflictResolvedB"), DIFFSTATE_CONFLICTRESOLVED_DEFAULT_BG
);
69 m_regBackgroundColors
[DIFFSTATE_CONFLICTRESOLVEDEMPTY
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ConflictResolvedEmptyB"), DIFFSTATE_CONFLICTRESOLVED_DEFAULT_BG
);
70 m_regBackgroundColors
[DIFFSTATE_IDENTICALREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorIdenticalRemovedB"), DIFFSTATE_IDENTICALREMOVED_DEFAULT_BG
);
71 m_regBackgroundColors
[DIFFSTATE_IDENTICALADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorIdenticalAddedB"), DIFFSTATE_IDENTICALADDED_DEFAULT_BG
);
72 m_regBackgroundColors
[DIFFSTATE_THEIRSREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorTheirsRemovedB"), DIFFSTATE_THEIRSREMOVED_DEFAULT_BG
);
73 m_regBackgroundColors
[DIFFSTATE_THEIRSADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorTheirsAddedB"), DIFFSTATE_THEIRSADDED_DEFAULT_BG
);
74 m_regBackgroundColors
[DIFFSTATE_YOURSREMOVED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorYoursRemovedB"), DIFFSTATE_YOURSREMOVED_DEFAULT_BG
);
75 m_regBackgroundColors
[DIFFSTATE_YOURSADDED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorYoursAddedB"), DIFFSTATE_YOURSADDED_DEFAULT_BG
);
76 m_regBackgroundColors
[DIFFSTATE_EDITED
] = CRegDWORD(_T("Software\\TortoiseGitMerge\\Colors\\ColorEditedB"), DIFFSTATE_EDITED_DEFAULT_BG
);
79 CDiffColors::~CDiffColors(void)
83 void CDiffColors::GetColors(DiffStates state
, COLORREF
&crBkgnd
, COLORREF
&crText
)
85 if ((state
< DIFFSTATE_END
)&&(state
>= 0))
87 crBkgnd
= (COLORREF
)(DWORD
)m_regBackgroundColors
[(int)state
];
88 crText
= (COLORREF
)(DWORD
)m_regForegroundColors
[(int)state
];
92 crBkgnd
= ::GetSysColor(COLOR_WINDOW
);
93 crText
= ::GetSysColor(COLOR_WINDOWTEXT
);
97 void CDiffColors::SetColors(DiffStates state
, const COLORREF
&crBkgnd
, const COLORREF
&crText
)
99 if ((state
< DIFFSTATE_END
)&&(state
>= 0))
101 m_regBackgroundColors
[(int)state
] = crBkgnd
;
102 m_regForegroundColors
[(int)state
] = crText
;
106 void CDiffColors::LoadRegistry()
108 for (int i
=0; i
<DIFFSTATE_END
; ++i
)
110 m_regForegroundColors
[i
].read();
111 m_regBackgroundColors
[i
].read();