2 * @file PropCompare.cpp
4 * @brief Implementation of PropCompare propertysheet
8 #include "PropCompare.h"
9 #include "OptionsDef.h"
10 #include "OptionsMgr.h"
11 #include "OptionsPanel.h"
19 * @param [in] optionsMgr Pointer to COptionsMgr.
21 PropCompare::PropCompare(COptionsMgr *optionsMgr)
22 : OptionsPanel(optionsMgr, PropCompare::IDD)
23 , m_bIgnoreCase(false)
24 , m_bIgnoreBlankLines(false)
26 , m_bIgnoreCodepage(true)
28 , m_bMovedBlocks(false)
29 , m_bMatchSimilarLines(false)
30 , m_bFilterCommentsLines(false)
32 , m_bIndentHeuristic(true)
33 , m_bCompleteBlankOutIgnoredChanges(false)
37 void PropCompare::DoDataExchange(CDataExchange* pDX)
39 CPropertyPage::DoDataExchange(pDX);
40 //{{AFX_DATA_MAP(PropCompare)
41 DDX_CBIndex(pDX, IDC_DIFF_ALGORITHM, m_nDiffAlgorithm);
42 DDX_Check(pDX, IDC_INDENT_HEURISTIC, m_bIndentHeuristic);
43 DDX_Check(pDX, IDC_IGNCASE_CHECK, m_bIgnoreCase);
44 DDX_Check(pDX, IDC_IGNBLANKS_CHECK, m_bIgnoreBlankLines);
45 DDX_Check(pDX, IDC_FILTERCOMMENTS_CHECK, m_bFilterCommentsLines);
46 DDX_Check(pDX, IDC_CP_SENSITIVE, m_bIgnoreCodepage);
47 DDX_Check(pDX, IDC_EOL_SENSITIVE, m_bIgnoreEol);
48 DDX_Radio(pDX, IDC_WHITESPACE, m_nIgnoreWhite);
49 DDX_Check(pDX, IDC_MOVED_BLOCKS, m_bMovedBlocks);
50 DDX_Check(pDX, IDC_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
51 DDX_Check(pDX, IDC_COMPLETELY_BLANK_OUT_IGNORED_DIFFERENCES, m_bCompleteBlankOutIgnoredChanges);
57 BEGIN_MESSAGE_MAP(PropCompare, OptionsPanel)
58 //{{AFX_MSG_MAP(PropCompare)
59 ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
60 ON_CBN_SELCHANGE(IDC_DIFF_ALGORITHM, OnCbnSelchangeDiffAlgorithm)
65 * @brief Reads options values from storage to UI.
66 * Property sheet calls this before displaying GUI to load values
69 void PropCompare::ReadOptions()
71 m_nIgnoreWhite = GetOptionsMgr()->GetInt(OPT_CMP_IGNORE_WHITESPACE);
72 m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
73 m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
74 m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
75 m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
76 m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
77 m_bMovedBlocks = GetOptionsMgr()->GetBool(OPT_CMP_MOVED_BLOCKS);
78 m_bMatchSimilarLines = GetOptionsMgr()->GetBool(OPT_CMP_MATCH_SIMILAR_LINES);
79 m_nDiffAlgorithm = GetOptionsMgr()->GetInt(OPT_CMP_DIFF_ALGORITHM);
80 m_bIndentHeuristic = GetOptionsMgr()->GetBool(OPT_CMP_INDENT_HEURISTIC);
81 m_bCompleteBlankOutIgnoredChanges = GetOptionsMgr()->GetBool(OPT_CMP_COMPLETELY_BLANK_OUT_IGNORED_CHANGES);
85 * @brief Writes options values from UI to storage.
86 * Property sheet calls this after dialog is closed with OK button to
87 * store values in member variables.
89 void PropCompare::WriteOptions()
91 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_WHITESPACE, m_nIgnoreWhite);
92 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_BLANKLINES, m_bIgnoreBlankLines);
93 GetOptionsMgr()->SaveOption(OPT_CMP_FILTER_COMMENTLINES, m_bFilterCommentsLines);
94 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CODEPAGE, m_bIgnoreCodepage);
95 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, m_bIgnoreEol);
96 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CASE, m_bIgnoreCase);
97 GetOptionsMgr()->SaveOption(OPT_CMP_MOVED_BLOCKS, m_bMovedBlocks);
98 GetOptionsMgr()->SaveOption(OPT_CMP_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
99 GetOptionsMgr()->SaveOption(OPT_CMP_DIFF_ALGORITHM, m_nDiffAlgorithm);
100 GetOptionsMgr()->SaveOption(OPT_CMP_INDENT_HEURISTIC, m_bIndentHeuristic);
101 GetOptionsMgr()->SaveOption(OPT_CMP_COMPLETELY_BLANK_OUT_IGNORED_CHANGES, m_bCompleteBlankOutIgnoredChanges);
105 * @brief Called before propertysheet is drawn.
107 BOOL PropCompare::OnInitDialog()
109 CComboBox * combo = (CComboBox*) GetDlgItem(IDC_DIFF_ALGORITHM);
111 combo->AddString(_("default").c_str());
112 combo->AddString(_("minimal").c_str());
113 combo->AddString(_("patience").c_str());
114 combo->AddString(_("histogram").c_str());
115 combo->SetCurSel(m_nDiffAlgorithm);
117 OptionsPanel::OnInitDialog();
118 return TRUE; // return TRUE unless you set the focus to a control
122 * @brief Sets options to defaults
124 void PropCompare::OnDefaults()
126 m_nIgnoreWhite = GetOptionsMgr()->GetDefault<unsigned>(OPT_CMP_IGNORE_WHITESPACE);
127 m_bIgnoreEol = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_EOL);
128 m_bIgnoreCodepage = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CODEPAGE);
129 m_bIgnoreBlankLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_BLANKLINES);
130 m_bFilterCommentsLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_FILTER_COMMENTLINES);
131 m_bIgnoreCase = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CASE);
132 m_bMovedBlocks = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MOVED_BLOCKS);
133 m_bMatchSimilarLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MATCH_SIMILAR_LINES);
134 m_nDiffAlgorithm = GetOptionsMgr()->GetDefault<unsigned>(OPT_CMP_DIFF_ALGORITHM);
135 m_bIndentHeuristic = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_INDENT_HEURISTIC);
136 m_bCompleteBlankOutIgnoredChanges = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_COMPLETELY_BLANK_OUT_IGNORED_CHANGES);
140 void PropCompare::OnCbnSelchangeDiffAlgorithm()
145 void PropCompare::UpdateControls()
147 CComboBox * pCombo = (CComboBox*)GetDlgItem(IDC_DIFF_ALGORITHM);
148 EnableDlgItem(IDC_INDENT_HEURISTIC, pCombo->GetCurSel() != 0);