*
* @brief Implementation of PropTextColors propertysheet
*/
-// ID line follows -- this is updated by SVN
-// $Id$
#include "stdafx.h"
#include "PropTextColors.h"
-#include "Merge.h"
#include "SyntaxColors.h"
#include "OptionsCustomColors.h"
#include "OptionsDef.h"
#include "OptionsMgr.h"
#include "OptionsPanel.h"
-#include "DDXHelper.h"
#ifdef _DEBUG
#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
#endif
/** @brief Section name for settings in registry. */
: OptionsPanel(optionsMgr, PropTextColors::IDD)
, m_bCustomColors(false)
, m_pTempColors(pColors)
+, m_cCustColors()
{
- memset(m_cCustColors, 0, sizeof(m_cCustColors));
}
void PropTextColors::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PropTextColors)
- DDX_Control(pDX, IDC_DEFAULT_STANDARD_COLORS, m_btnDefaultStandardColors);
DDX_Check(pDX, IDC_DEFAULT_STANDARD_COLORS, m_bCustomColors);
DDX_Control(pDX, IDC_WHITESPACE_BKGD_COLOR, m_btnWhitespaceBackground);
DDX_Control(pDX, IDC_REGULAR_BKGD_COLOR, m_btnRegularBackground);
DDX_Control(pDX, IDC_REGULAR_TEXT_COLOR, m_btnRegularText);
DDX_Control(pDX, IDC_SELECTION_BKGD_COLOR, m_btnSelectionBackground);
DDX_Control(pDX, IDC_SELECTION_TEXT_COLOR, m_btnSelectionText);
+ DDX_Control(pDX, IDC_MARGIN_BKGD_COLOR, m_btnMarginBackground);
//}}AFX_DATA_MAP
+ EnableColorButtons(m_bCustomColors);
}
-BEGIN_MESSAGE_MAP(PropTextColors, CDialog)
+BEGIN_MESSAGE_MAP(PropTextColors, OptionsPanel)
//{{AFX_MSG_MAP(PropTextColors)
ON_BN_CLICKED(IDC_DEFAULT_STANDARD_COLORS, OnDefaultsStandardColors)
ON_BN_CLICKED(IDC_WHITESPACE_BKGD_COLOR, OnWhitespaceBackgroundColor)
ON_BN_CLICKED(IDC_REGULAR_TEXT_COLOR, OnRegularTextColor)
ON_BN_CLICKED(IDC_SELECTION_BKGD_COLOR, OnSelectionBackgroundColor)
ON_BN_CLICKED(IDC_SELECTION_TEXT_COLOR, OnSelectionTextColor)
+ ON_BN_CLICKED(IDC_MARGIN_BKGD_COLOR, OnMarginBackgroundColor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/**
- * @brief Enable/Disable controls when dialog is shown.
- */
-BOOL PropTextColors::OnInitDialog()
-{
- theApp.TranslateDialog(m_hWnd);
- CPropertyPage::OnInitDialog();
-
- if (m_bCustomColors)
- EnableColorButtons(TRUE);
- else
- EnableColorButtons(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
-}
-
-/**
* @brief Reads options values from storage to UI.
* (Property sheet calls this before displaying all property pages)
*/
*/
void PropTextColors::WriteOptions()
{
- GetOptionsMgr()->SaveOption(OPT_CLR_DEFAULT_TEXT_COLORING, m_bCustomColors == false);
+ GetOptionsMgr()->SaveOption(OPT_CLR_DEFAULT_TEXT_COLORING, !m_bCustomColors);
// User can only change colors via BrowseColorAndSave,
// which writes to m_pTempColors
// so user's latest choices are in m_pTempColors
void PropTextColors::BrowseColorAndSave(CColorButton & colorButton, int colorIndex)
{
// Ignore user if colors are slaved to system
- if (m_btnDefaultStandardColors.GetCheck() == BST_UNCHECKED)
+ if (IsDlgButtonChecked(IDC_DEFAULT_STANDARD_COLORS) == BST_UNCHECKED)
return;
COLORREF currentColor = m_pTempColors->GetColor(colorIndex);
CColorDialog dialog(currentColor);
- Options::CustomColors::Load(m_cCustColors);
- dialog.m_cc.lpCustColors = m_cCustColors;
+ Options::CustomColors::Load(GetOptionsMgr(), m_cCustColors.data());
+ dialog.m_cc.lpCustColors = m_cCustColors.data();
if (dialog.DoModal() == IDOK)
{
colorButton.SetColor(currentColor);
m_pTempColors->SetColor(colorIndex, currentColor);
}
- Options::CustomColors::Save(m_cCustColors);
+ Options::CustomColors::Save(GetOptionsMgr(), m_cCustColors.data());
}
/**
BrowseColorAndSave(m_btnSelectionText, COLORINDEX_SELTEXT);
}
+/**
+ * @brief User wants to change margin background color
+ */
+void PropTextColors::OnMarginBackgroundColor()
+{
+ BrowseColorAndSave(m_btnMarginBackground, COLORINDEX_SELMARGIN);
+}
+
/**
* @brief Load all colors, Save all colors, or set all colors to default
* @param [in] op Operation to do, one of
SerializeColorToFromScreen(op, m_btnSelectionBackground, COLORINDEX_SELBKGND);
SerializeColorToFromScreen(op, m_btnSelectionText, COLORINDEX_SELTEXT);
+
+ SerializeColorToFromScreen(op, m_btnMarginBackground, COLORINDEX_SELMARGIN);
}
/**
*/
void PropTextColors::SerializeColorToFromScreen(OPERATION op, CColorButton & btn, int colorIndex)
{
-
switch (op)
{
case SET_DEFAULTS:
- {
- COLORREF color = m_pTempColors->GetColor(colorIndex);
- btn.SetColor(color);
- return;
- }
-
case LOAD_COLORS:
- {
- COLORREF color = m_pTempColors->GetColor(colorIndex);
- // Set colors for buttons, do NOT invalidate
- btn.SetColor(color, FALSE);
- return;
- }
+ btn.SetColor(m_pTempColors->GetColor(colorIndex));
+ break;
}
}
// Reset all text colors to default every time user checks defaults button
SerializeColorsToFromScreen(SET_DEFAULTS);
- CButton * btn = (CButton *)GetDlgItem(IDC_DEFAULT_STANDARD_COLORS);
- if (btn->GetCheck() == BST_UNCHECKED)
- {
- EnableColorButtons(FALSE);
- }
- else
- {
- EnableColorButtons(TRUE);
- }
+ UpdateData();
}
/**
* @brief Enable / disable color controls on dialog.
- * @param [in] bEnable If TRUE color controls are enabled.
+ * @param [in] bEnable If `true` color controls are enabled.
*/
-void PropTextColors::EnableColorButtons(BOOL bEnable)
+void PropTextColors::EnableColorButtons(bool bEnable)
{
- CStatic * stc = (CStatic *) GetDlgItem(IDC_CUSTOM_COLORS_GROUP);
- stc->EnableWindow(bEnable);
- stc = (CStatic *) GetDlgItem(IDC_WHITESPACE_COLOR_LABEL);
- stc->EnableWindow(bEnable);
- stc = (CStatic *) GetDlgItem(IDC_TEXT_COLOR_LABEL);
- stc->EnableWindow(bEnable);
- stc = (CStatic *) GetDlgItem(IDC_SELECTION_COLOR_LABEL);
- stc->EnableWindow(bEnable);
- stc = (CStatic *) GetDlgItem(IDC_BACKGROUND_COLUMN_LABEL);
- stc->EnableWindow(bEnable);
- stc = (CStatic *) GetDlgItem(IDC_TEXT_COLUMN_LABEL);
- stc->EnableWindow(bEnable);
+ EnableDlgItem(IDC_WHITESPACE_COLOR_LABEL, bEnable);
+ EnableDlgItem(IDC_TEXT_COLOR_LABEL, bEnable);
+ EnableDlgItem(IDC_SELECTION_COLOR_LABEL, bEnable);
+ EnableDlgItem(IDC_MARGIN_COLOR_LABEL, bEnable);
+ EnableDlgItem(IDC_BACKGROUND_COLUMN_LABEL, bEnable);
+ EnableDlgItem(IDC_TEXT_COLUMN_LABEL, bEnable);
}