2 * @file PropDirColors.cpp
4 * @brief Implementation of PropDirColors propertysheet
8 #include "PropDirColors.h"
9 #include "OptionsCustomColors.h"
10 #include "OptionsDef.h"
11 #include "OptionsMgr.h"
12 #include "OptionsPanel.h"
19 * @brief Default constructor.
21 PropDirColors::PropDirColors(COptionsMgr *optionsMgr)
22 : OptionsPanel(optionsMgr, PropDirColors::IDD)
27 void PropDirColors::DoDataExchange(CDataExchange* pDX)
29 CDialog::DoDataExchange(pDX);
30 //{{AFX_DATA_MAP(PropDirColors)
31 DDX_Control(pDX, IDC_DIR_ITEM_DIFF_COLOR, m_cDirItemDiff);
32 DDX_Control(pDX, IDC_DIR_ITEM_DIFF_TEXT_COLOR, m_cDirItemDiffText);
33 DDX_Control(pDX, IDC_DIR_ITEM_NOTEXISTALL_COLOR, m_cDirItemNotExistAll);
34 DDX_Control(pDX, IDC_DIR_ITEM_NOTEXISTALL_TEXT_COLOR, m_cDirItemNotExistAllText);
35 DDX_Control(pDX, IDC_DIR_ITEM_FILTERED_COLOR, m_cDirItemFiltered);
36 DDX_Control(pDX, IDC_DIR_ITEM_FILTERED_TEXT_COLOR, m_cDirItemFilteredText);
41 BEGIN_MESSAGE_MAP(PropDirColors, CDialog)
42 //{{AFX_MSG_MAP(PropDirColors)
43 ON_BN_CLICKED(IDC_DIR_ITEM_DIFF_COLOR, OnDirItemDiffColor)
44 ON_BN_CLICKED(IDC_DIR_ITEM_DIFF_TEXT_COLOR, OnDirItemDiffTextColor)
45 ON_BN_CLICKED(IDC_DIR_ITEM_NOTEXISTALL_COLOR, OnDirItemNotExistAllColor)
46 ON_BN_CLICKED(IDC_DIR_ITEM_NOTEXISTALL_TEXT_COLOR, OnDirItemNotExistAllTextColor)
47 ON_BN_CLICKED(IDC_DIR_ITEM_FILTERED_COLOR, OnDirItemFilteredColor)
48 ON_BN_CLICKED(IDC_DIR_ITEM_FILTERED_TEXT_COLOR, OnDirItemFilteredTextColor)
49 ON_BN_CLICKED(IDC_COLORDEFAULTS_BTN, OnDefaults)
54 * @brief Reads options values from storage to UI.
55 * (Property sheet calls this before displaying all property pages)
57 void PropDirColors::ReadOptions()
59 SerializeColors(READ_OPTIONS);
63 * @brief Writes options values from UI to storage.
64 * (Property sheet calls this after displaying all property pages)
66 void PropDirColors::WriteOptions()
68 SerializeColors(WRITE_OPTIONS);
72 * @brief Let user browse common color dialog, and select a color
74 void PropDirColors::BrowseColor(CColorButton & colorButton)
76 CColorDialog dialog(colorButton.GetColor());
77 Options::CustomColors::Load(GetOptionsMgr(), m_cCustColors.data());
78 dialog.m_cc.lpCustColors = m_cCustColors.data();
80 if (dialog.DoModal() == IDOK)
81 colorButton.SetColor(dialog.GetColor());
82 Options::CustomColors::Save(GetOptionsMgr(), m_cCustColors.data());
86 * @brief User wants to change xxx color
88 void PropDirColors::OnDirItemDiffColor()
90 BrowseColor(m_cDirItemDiff);
94 * @brief User wants to change xxx color
96 void PropDirColors::OnDirItemDiffTextColor()
98 BrowseColor(m_cDirItemDiffText);
102 * @brief User wants to change xxx color
104 void PropDirColors::OnDirItemNotExistAllColor()
106 BrowseColor(m_cDirItemNotExistAll);
110 * @brief User wants to change xxx color
112 void PropDirColors::OnDirItemNotExistAllTextColor()
114 BrowseColor(m_cDirItemNotExistAllText);
118 * @brief User wants to change xxx color
120 void PropDirColors::OnDirItemFilteredColor()
122 BrowseColor(m_cDirItemFiltered);
126 * @brief User wants to change xxx color
128 void PropDirColors::OnDirItemFilteredTextColor()
130 BrowseColor(m_cDirItemFilteredText);
133 void PropDirColors::SerializeColors(OPERATION op)
135 SerializeColor(op, m_cDirItemDiff, OPT_DIRCLR_ITEM_DIFF);
136 SerializeColor(op, m_cDirItemDiffText, OPT_DIRCLR_ITEM_DIFF_TEXT);
138 SerializeColor(op, m_cDirItemNotExistAll, OPT_DIRCLR_ITEM_NOT_EXIST_ALL);
139 SerializeColor(op, m_cDirItemNotExistAllText, OPT_DIRCLR_ITEM_NOT_EXIST_ALL_TEXT);
141 SerializeColor(op, m_cDirItemFiltered, OPT_DIRCLR_ITEM_FILTERED);
142 SerializeColor(op, m_cDirItemFilteredText, OPT_DIRCLR_ITEM_FILTERED_TEXT);
145 void PropDirColors::SerializeColor(OPERATION op, CColorButton & btn, const String& optionName)
150 btn.SetColor(GetOptionsMgr()->GetDefault<unsigned>(optionName));
154 GetOptionsMgr()->SaveOption(optionName, (unsigned)btn.GetColor());
158 // Set colors for buttons, do NOT invalidate
159 btn.SetColor(GetOptionsMgr()->GetInt(optionName), false);
165 * @brief Resets colors to defaults
167 void PropDirColors::OnDefaults()
169 SerializeColors(SET_DEFAULTS);