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_bIgnoreNumbers(false)
25 , m_bIgnoreBlankLines(false)
27 , m_bIgnoreCodepage(true)
29 , m_bMovedBlocks(false)
30 , m_bMatchSimilarLines(false)
31 , m_bFilterCommentsLines(false)
33 , m_bIndentHeuristic(true)
34 , m_bCompleteBlankOutIgnoredChanges(false)
38 void PropCompare::DoDataExchange(CDataExchange* pDX)
40 CPropertyPage::DoDataExchange(pDX);
41 //{{AFX_DATA_MAP(PropCompare)
42 DDX_CBIndex(pDX, IDC_DIFF_ALGORITHM, m_nDiffAlgorithm);
43 DDX_Check(pDX, IDC_INDENT_HEURISTIC, m_bIndentHeuristic);
44 DDX_Check(pDX, IDC_IGNCASE_CHECK, m_bIgnoreCase);
45 DDX_Check(pDX, IDC_IGNBLANKS_CHECK, m_bIgnoreBlankLines);
46 DDX_Check(pDX, IDC_FILTERCOMMENTS_CHECK, m_bFilterCommentsLines);
47 DDX_Check(pDX, IDC_CP_SENSITIVE, m_bIgnoreCodepage);
48 DDX_Check(pDX, IDC_EOL_SENSITIVE, m_bIgnoreEol);
49 DDX_Check(pDX, IDC_IGNORE_NUMBERS, m_bIgnoreNumbers);
50 DDX_Radio(pDX, IDC_WHITESPACE, m_nIgnoreWhite);
51 DDX_Check(pDX, IDC_MOVED_BLOCKS, m_bMovedBlocks);
52 DDX_Check(pDX, IDC_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
53 DDX_Check(pDX, IDC_COMPLETELY_BLANK_OUT_IGNORED_DIFFERENCES, m_bCompleteBlankOutIgnoredChanges);
59 BEGIN_MESSAGE_MAP(PropCompare, OptionsPanel)
60 //{{AFX_MSG_MAP(PropCompare)
61 ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
62 ON_CBN_SELCHANGE(IDC_DIFF_ALGORITHM, OnCbnSelchangeDiffAlgorithm)
67 * @brief Reads options values from storage to UI.
68 * Property sheet calls this before displaying GUI to load values
71 void PropCompare::ReadOptions()
73 m_nIgnoreWhite = GetOptionsMgr()->GetInt(OPT_CMP_IGNORE_WHITESPACE);
74 m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
75 m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
76 m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
77 m_bIgnoreNumbers = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS);
78 m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
79 m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
80 m_bMovedBlocks = GetOptionsMgr()->GetBool(OPT_CMP_MOVED_BLOCKS);
81 m_bMatchSimilarLines = GetOptionsMgr()->GetBool(OPT_CMP_MATCH_SIMILAR_LINES);
82 m_nDiffAlgorithm = GetOptionsMgr()->GetInt(OPT_CMP_DIFF_ALGORITHM);
83 m_bIndentHeuristic = GetOptionsMgr()->GetBool(OPT_CMP_INDENT_HEURISTIC);
84 m_bCompleteBlankOutIgnoredChanges = GetOptionsMgr()->GetBool(OPT_CMP_COMPLETELY_BLANK_OUT_IGNORED_CHANGES);
88 * @brief Writes options values from UI to storage.
89 * Property sheet calls this after dialog is closed with OK button to
90 * store values in member variables.
92 void PropCompare::WriteOptions()
94 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_WHITESPACE, m_nIgnoreWhite);
95 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_BLANKLINES, m_bIgnoreBlankLines);
96 GetOptionsMgr()->SaveOption(OPT_CMP_FILTER_COMMENTLINES, m_bFilterCommentsLines);
97 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CODEPAGE, m_bIgnoreCodepage);
98 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, m_bIgnoreEol);
99 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CASE, m_bIgnoreCase);
100 GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, m_bIgnoreNumbers);
101 GetOptionsMgr()->SaveOption(OPT_CMP_MOVED_BLOCKS, m_bMovedBlocks);
102 GetOptionsMgr()->SaveOption(OPT_CMP_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
103 GetOptionsMgr()->SaveOption(OPT_CMP_DIFF_ALGORITHM, m_nDiffAlgorithm);
104 GetOptionsMgr()->SaveOption(OPT_CMP_INDENT_HEURISTIC, m_bIndentHeuristic);
105 GetOptionsMgr()->SaveOption(OPT_CMP_COMPLETELY_BLANK_OUT_IGNORED_CHANGES, m_bCompleteBlankOutIgnoredChanges);
109 * @brief Called before propertysheet is drawn.
111 BOOL PropCompare::OnInitDialog()
113 SetDlgItemComboBoxList(IDC_DIFF_ALGORITHM,
114 { _("default"), _("minimal"), _("patience"), _("histogram"), _("none") });
116 OptionsPanel::OnInitDialog();
117 return TRUE; // return TRUE unless you set the focus to a control
121 * @brief Sets options to defaults
123 void PropCompare::OnDefaults()
125 m_nIgnoreWhite = GetOptionsMgr()->GetDefault<unsigned>(OPT_CMP_IGNORE_WHITESPACE);
126 m_bIgnoreEol = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_EOL);
127 m_bIgnoreCodepage = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CODEPAGE);
128 m_bIgnoreBlankLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_BLANKLINES);
129 m_bFilterCommentsLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_FILTER_COMMENTLINES);
130 m_bIgnoreCase = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CASE);
131 m_bIgnoreNumbers = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_NUMBERS);
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 int cursel = pCombo->GetCurSel();
149 EnableDlgItem(IDC_INDENT_HEURISTIC, cursel != 0/*default*/ && cursel != 4/*none*/);