OSDN Git Service

* Use standard order of header files
[winmerge-jp/winmerge-jp.git] / Src / PropGeneral.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 //    WinMerge:  an interactive diff/merge utility
3 //    Copyright (C) 1997-2000  Thingamahoochie Software
4 //    Author: Dean Grimm
5 //
6 //    This program is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    This program is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License
17 //    along with this program; if not, write to the Free Software
18 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20 /////////////////////////////////////////////////////////////////////////////
21 /** 
22  * @file  PropGeneral.h
23  *
24  * @brief Implementation file for PropGeneral propertyheet
25  *
26  */
27 // ID line follows -- this is updated by SVN
28 // $Id$
29
30 #include "stdafx.h"
31 #include "PropGeneral.h"
32 #include "Merge.h"
33 #include "OptionsDef.h"
34 #include "OptionsMgr.h"
35 #include "OptionsPanel.h"
36
37 #ifdef _DEBUG
38 #define new DEBUG_NEW
39 #undef THIS_FILE
40 static char THIS_FILE[] = __FILE__;
41 #endif
42
43 /** 
44  * @brief Constructor initialising members.
45  */
46 PropGeneral::PropGeneral(COptionsMgr *optionsMgr) 
47 : OptionsPanel(optionsMgr, PropGeneral::IDD)
48 , m_bScroll(FALSE)
49 , m_bDisableSplash(FALSE)
50 , m_bSingleInstance(FALSE)
51 , m_bVerifyPaths(FALSE)
52 , m_bCloseWindowWithEsc(TRUE)
53 , m_bAskMultiWindowClose(FALSE)
54 , m_bMultipleFileCmp(FALSE)
55 , m_bMultipleDirCmp(FALSE)
56 , m_nAutoCompleteSource(0)
57 , m_bPreserveFiletime(FALSE)
58 , m_bShowSelectFolderOnStartup(FALSE)
59 , m_bCloseWithOK(TRUE)
60 {
61 }
62
63 PropGeneral::~PropGeneral()
64 {
65 }
66
67 BOOL PropGeneral::OnInitDialog()
68 {
69         theApp.TranslateDialog(m_hWnd);
70         CPropertyPage::OnInitDialog();
71
72         CComboBox *pWnd = (CComboBox*)GetDlgItem(IDC_AUTO_COMPLETE_SOURCE);
73         ASSERT(NULL != pWnd);
74
75         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_DISABLED).c_str());
76         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_FILE_SYS).c_str());
77         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_MRU).c_str());
78
79         pWnd->SetCurSel(m_nAutoCompleteSource);
80
81         return TRUE;  // return TRUE  unless you set the focus to a control
82 }
83
84 void PropGeneral::DoDataExchange(CDataExchange* pDX)
85 {
86         CPropertyPage::DoDataExchange(pDX);
87         //{{AFX_DATA_MAP(PropGeneral)
88         DDX_Check(pDX, IDC_SCROLL_CHECK, m_bScroll);
89         DDX_Check(pDX, IDC_DISABLE_SPLASH, m_bDisableSplash);
90         DDX_Check(pDX, IDC_SINGLE_INSTANCE, m_bSingleInstance);
91         DDX_Check(pDX, IDC_VERIFY_OPEN_PATHS, m_bVerifyPaths);
92         DDX_Check(pDX, IDC_ESC_CLOSES_WINDOW, m_bCloseWindowWithEsc);
93         DDX_Check(pDX, IDC_ASK_MULTIWINDOW_CLOSE, m_bAskMultiWindowClose);
94         DDX_Check(pDX, IDC_MULTIDOC_FILECMP, m_bMultipleFileCmp);
95         DDX_Check(pDX, IDC_MULTIDOC_DIRCMP, m_bMultipleDirCmp);
96         DDX_CBIndex(pDX, IDC_AUTO_COMPLETE_SOURCE, m_nAutoCompleteSource);
97         DDX_Check(pDX, IDC_PRESERVE_FILETIME, m_bPreserveFiletime);
98         DDX_Check(pDX, IDC_STARTUP_FOLDER_SELECT, m_bShowSelectFolderOnStartup);
99         DDX_Check(pDX, IDC_CLOSE_WITH_OK, m_bCloseWithOK);
100         //}}AFX_DATA_MAP
101 }
102
103
104 BEGIN_MESSAGE_MAP(PropGeneral, CPropertyPage)
105         //{{AFX_MSG_MAP(PropGeneral)
106         ON_BN_CLICKED(IDC_RESET_ALL_MESSAGE_BOXES, OnResetAllMessageBoxes)
107         //}}AFX_MSG_MAP
108 END_MESSAGE_MAP()
109
110 /** 
111  * @brief Reads options values from storage to UI.
112  */
113 void PropGeneral::ReadOptions()
114 {
115         m_bScroll = GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST);
116         m_bDisableSplash = GetOptionsMgr()->GetBool(OPT_DISABLE_SPLASH);
117         m_bSingleInstance = GetOptionsMgr()->GetBool(OPT_SINGLE_INSTANCE);
118         m_bVerifyPaths = GetOptionsMgr()->GetBool(OPT_VERIFY_OPEN_PATHS);
119         m_bCloseWindowWithEsc = GetOptionsMgr()->GetBool(OPT_CLOSE_WITH_ESC);
120         m_bAskMultiWindowClose = GetOptionsMgr()->GetBool(OPT_ASK_MULTIWINDOW_CLOSE);
121         m_bMultipleFileCmp = GetOptionsMgr()->GetBool(OPT_MULTIDOC_MERGEDOCS);
122         m_bMultipleDirCmp = GetOptionsMgr()->GetBool(OPT_MULTIDOC_DIRDOCS);
123         m_nAutoCompleteSource = GetOptionsMgr()->GetInt(OPT_AUTO_COMPLETE_SOURCE);
124         m_bPreserveFiletime = GetOptionsMgr()->GetBool(OPT_PRESERVE_FILETIMES);
125         m_bShowSelectFolderOnStartup = GetOptionsMgr()->GetBool(OPT_SHOW_SELECT_FILES_AT_STARTUP);
126         m_bCloseWithOK = GetOptionsMgr()->GetBool(OPT_CLOSE_WITH_OK);
127 }
128
129 /** 
130  * @brief Writes options values from UI to storage.
131  */
132 void PropGeneral::WriteOptions()
133 {
134         GetOptionsMgr()->SaveOption(OPT_SCROLL_TO_FIRST, m_bScroll == TRUE);
135         GetOptionsMgr()->SaveOption(OPT_DISABLE_SPLASH, m_bDisableSplash == TRUE);
136         GetOptionsMgr()->SaveOption(OPT_SINGLE_INSTANCE, m_bSingleInstance == TRUE);
137         GetOptionsMgr()->SaveOption(OPT_VERIFY_OPEN_PATHS, m_bVerifyPaths == TRUE);
138         GetOptionsMgr()->SaveOption(OPT_CLOSE_WITH_ESC, m_bCloseWindowWithEsc == TRUE);
139         GetOptionsMgr()->SaveOption(OPT_ASK_MULTIWINDOW_CLOSE, m_bAskMultiWindowClose == TRUE);
140         GetOptionsMgr()->SaveOption(OPT_MULTIDOC_MERGEDOCS, m_bMultipleFileCmp == TRUE);
141         GetOptionsMgr()->SaveOption(OPT_MULTIDOC_DIRDOCS, m_bMultipleDirCmp == TRUE);
142         GetOptionsMgr()->SaveOption(OPT_AUTO_COMPLETE_SOURCE, m_nAutoCompleteSource);
143         GetOptionsMgr()->SaveOption(OPT_PRESERVE_FILETIMES, m_bPreserveFiletime);
144         GetOptionsMgr()->SaveOption(OPT_SHOW_SELECT_FILES_AT_STARTUP, m_bShowSelectFolderOnStartup);
145         GetOptionsMgr()->SaveOption(OPT_CLOSE_WITH_OK, m_bCloseWithOK);
146 }
147
148 /** 
149  * @brief Called when user wants to see all messageboxes again.
150  */
151 void PropGeneral::OnResetAllMessageBoxes()
152 {
153         CMessageBoxDialog::ResetMessageBoxes();
154         LangMessageBox(IDS_MESSAGE_BOX_ARE_RESET, MB_ICONINFORMATION);
155 }