OSDN Git Service

Add a feature to set items saved to or restored from the project file. (#953)
[winmerge-jp/winmerge-jp.git] / Src / Common / PreferencesDlg.cpp
index 0e4a126..c75f116 100644 (file)
@@ -41,6 +41,7 @@ CPreferencesDlg::CPreferencesDlg(COptionsMgr *regOptions, SyntaxColors *colors,
 , m_pSyntaxColors(colors)
 , m_pageGeneral(regOptions)
 , m_pageCompare(regOptions)
+, m_pageMessageBoxes(regOptions)
 , m_pageColorSchemes(regOptions)
 , m_pageMergeColors(regOptions)
 , m_pageTextColors(regOptions, colors)
@@ -50,6 +51,8 @@ CPreferencesDlg::CPreferencesDlg(COptionsMgr *regOptions, SyntaxColors *colors,
 , m_pageArchive(regOptions)
 , m_pageCodepage(regOptions)
 , m_pageEditor(regOptions)
+, m_pageEditorSyntax(regOptions)
+, m_pageProject(regOptions)
 , m_pageSystem(regOptions)
 , m_pageBackups(regOptions)
 , m_pageShell(regOptions)
@@ -73,9 +76,9 @@ void CPreferencesDlg::DoDataExchange(CDataExchange* pDX)
        //}}AFX_DATA_MAP
 }
 
-BEGIN_MESSAGE_MAP(CPreferencesDlg, CDialog)
+BEGIN_MESSAGE_MAP(CPreferencesDlg, CTrDialog)
        //{{AFX_MSG_MAP(CPreferencesDlg)
-       ON_WM_DESTROY()
+       ON_WM_SIZE()
        ON_COMMAND(ID_HELP, OnHelpButton)
        ON_BN_CLICKED(IDC_TREEOPT_HELP, OnHelpButton)
        ON_NOTIFY(TVN_SELCHANGED, IDC_TREEOPT_PAGES, OnSelchangedPages)
@@ -104,7 +107,9 @@ BOOL CPreferencesDlg::OnInitDialog()
        AddPage(&m_pageCompareTable, IDS_OPTIONSPG_COMPARE, IDS_OPTIONSPG_TABLECOMPARE);
        AddPage(&m_pageCompareBinary, IDS_OPTIONSPG_COMPARE, IDS_OPTIONSPG_BINARYCOMPARE);
        AddPage(&m_pageCompareImage, IDS_OPTIONSPG_COMPARE, IDS_OPTIONSPG_IMAGECOMPARE);
-       AddPage(&m_pageEditor, IDS_OPTIONSPG_EDITOR);
+       AddPage(&m_pageMessageBoxes, IDS_OPTIONSPG_MESSAGEBOXES);
+       AddPage(&m_pageEditor, IDS_OPTIONSPG_EDITOR, IDS_OPTIONSPG_GENEDITOR);
+       AddPage(&m_pageEditorSyntax, IDS_OPTIONSPG_EDITOR, IDS_OPTIONSPG_EDITOR_SYNTAX);
        AddPage(&m_pageColorSchemes, IDS_OPTIONSPG_COLORS, IDS_OPTIONSPG_COLOR_SCHEMES);
        AddPage(&m_pageMergeColors, IDS_OPTIONSPG_COLORS, IDS_OPTIONSPG_MERGECOLORS);
        AddPage(&m_pageSyntaxColors, IDS_OPTIONSPG_COLORS, IDS_OPTIONSPG_SYNTAXCOLORS);
@@ -112,6 +117,7 @@ BOOL CPreferencesDlg::OnInitDialog()
        AddPage(&m_pageMarkerColors, IDS_OPTIONSPG_COLORS, IDS_OPTIONSPG_MARKERCOLORS);
        AddPage(&m_pageDirColors, IDS_OPTIONSPG_COLORS, IDS_OPTIONSPG_DIRCOLORS);
        AddPage(&m_pageArchive, IDS_OPTIONSPG_ARCHIVE);
+       AddPage(&m_pageProject, IDS_OPTIONSPG_PROJECT);
        AddPage(&m_pageSystem, IDS_OPTIONSPG_SYSTEM);
        AddPage(&m_pageBackups, IDS_OPTIONSPG_BACKUPS);
        AddPage(&m_pageCodepage, IDS_OPTIONSPG_CODEPAGE);
@@ -125,7 +131,12 @@ BOOL CPreferencesDlg::OnInitDialog()
 
        if (m_pphost.Create(rPPHost, this))
                SetActivePage(AfxGetApp()->GetProfileInt(_T("Settings"), _T("OptStartPage"), 0));
-
+       // setup handler for resizing this dialog       
+       m_constraint.InitializeCurrentSize(this);
+       m_constraint.DisallowHeightGrowth();
+       m_constraint.SubclassWnd(); // install subclassing
+       m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("OptionsDlg"), false); // persist size via registry
        return TRUE;  // return TRUE unless you set the focus to a control
                      // EXCEPTION: OCX Property Pages should return FALSE
 }
@@ -136,15 +147,23 @@ void CPreferencesDlg::OnOK()
        m_pphost.OnOK();
 
        SaveOptions();
-}
 
-void CPreferencesDlg::OnDestroy() 
-{
-       CDialog::OnDestroy();
-       
        AfxGetApp()->WriteProfileInt(_T("Settings"), _T("OptStartPage"), m_pphost.GetActiveIndex());
 }
 
+void CPreferencesDlg::OnSize(UINT nType, int cx, int cy)
+{
+       CWnd::OnSize(nType, cx, cy);
+
+       if (CWnd *pPPHostWnd = GetDlgItem(IDC_TREEOPT_HOSTFRAME))
+       {
+               CRect rPPHost;
+               pPPHostWnd->GetWindowRect(rPPHost);
+               ScreenToClient(rPPHost);
+               m_pphost.MoveWindow(&rPPHost);
+       }
+}
+       
 void CPreferencesDlg::OnHelpButton() 
 {
        theApp.ShowHelp(OptionsHelpLocation);
@@ -275,9 +294,12 @@ void CPreferencesDlg::ReadOptions(bool bUpdate)
        m_pageCompareTable.ReadOptions();
        m_pageCompareBinary.ReadOptions();
        m_pageCompareImage.ReadOptions();
+       m_pageMessageBoxes.ReadOptions();
        m_pageEditor.ReadOptions();
+       m_pageEditorSyntax.ReadOptions();
        m_pageCodepage.ReadOptions();
        m_pageArchive.ReadOptions();
+       m_pageProject.ReadOptions();
        m_pageBackups.ReadOptions();
        m_pageShell.ReadOptions();
 
@@ -296,9 +318,12 @@ void CPreferencesDlg::ReadOptions(bool bUpdate)
                SafeUpdatePage(&m_pageCompareTable, false);
                SafeUpdatePage(&m_pageCompareBinary, false);
                SafeUpdatePage(&m_pageCompareImage, false);
+               SafeUpdatePage(&m_pageMessageBoxes, false);
                SafeUpdatePage(&m_pageEditor, false);
+               SafeUpdatePage(&m_pageEditorSyntax, false);
                SafeUpdatePage(&m_pageCodepage, false);
                SafeUpdatePage(&m_pageArchive, false);
+               SafeUpdatePage(&m_pageProject, false);
                SafeUpdatePage(&m_pageBackups, false);
                SafeUpdatePage(&m_pageShell, false);
        }
@@ -316,7 +341,9 @@ void CPreferencesDlg::SaveOptions()
        m_pageCompareTable.WriteOptions();
        m_pageCompareBinary.WriteOptions();
        m_pageCompareImage.WriteOptions();
+       m_pageMessageBoxes.WriteOptions();
        m_pageEditor.WriteOptions();
+       m_pageEditorSyntax.WriteOptions();
        m_pageColorSchemes.WriteOptions();
        m_pageMergeColors.WriteOptions();
        m_pageTextColors.WriteOptions();
@@ -325,6 +352,7 @@ void CPreferencesDlg::SaveOptions()
        m_pageDirColors.WriteOptions();
        m_pageCodepage.WriteOptions();
        m_pageArchive.WriteOptions();
+       m_pageProject.WriteOptions();
        m_pageBackups.WriteOptions();
        m_pageShell.WriteOptions();
 }