OSDN Git Service

Bump revision to 2.14.0+-jp-79
[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
28 #include "stdafx.h"
29 #include "PropGeneral.h"
30 #include "Merge.h"
31 #include "OptionsDef.h"
32 #include "OptionsMgr.h"
33 #include "OptionsPanel.h"
34 #include "LanguageSelect.h"
35
36 #ifdef _DEBUG
37 #define new DEBUG_NEW
38 #undef THIS_FILE
39 static char THIS_FILE[] = __FILE__;
40 #endif
41
42 /** 
43  * @brief Constructor initialising members.
44  */
45 PropGeneral::PropGeneral(COptionsMgr *optionsMgr) 
46 : OptionsPanel(optionsMgr, PropGeneral::IDD)
47 , m_bScroll(FALSE)
48 , m_bSingleInstance(FALSE)
49 , m_bVerifyPaths(FALSE)
50 , m_bCloseWindowWithEsc(TRUE)
51 , m_bAskMultiWindowClose(FALSE)
52 , m_nAutoCompleteSource(0)
53 , m_bPreserveFiletime(FALSE)
54 , m_bShowSelectFolderOnStartup(FALSE)
55 , m_bCloseWithOK(TRUE)
56 {
57 }
58
59 PropGeneral::~PropGeneral()
60 {
61 }
62
63 BOOL PropGeneral::OnInitDialog()
64 {
65         theApp.TranslateDialog(m_hWnd);
66         CPropertyPage::OnInitDialog();
67
68         CComboBox *pWnd = (CComboBox*)GetDlgItem(IDC_AUTO_COMPLETE_SOURCE);
69         ASSERT(NULL != pWnd);
70
71         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_DISABLED).c_str());
72         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_FILE_SYS).c_str());
73         pWnd->AddString(theApp.LoadString(IDS_AUTOCOMPLETE_MRU).c_str());
74
75         pWnd->SetCurSel(m_nAutoCompleteSource);
76
77         m_ctlLangList.SetDroppedWidth(600);
78
79         for (auto&& i : theApp.m_pLangDlg->GetAvailableLanguages())
80         {
81                 m_ctlLangList.AddString(i.second.c_str());
82                 m_ctlLangList.SetItemData(m_ctlLangList.GetCount() - 1, i.first);
83                 if (i.first == theApp.m_pLangDlg->GetLangId())
84                         m_ctlLangList.SetCurSel(m_ctlLangList.GetCount() - 1);
85         }
86
87         return TRUE;  // return TRUE  unless you set the focus to a control
88 }
89
90 void PropGeneral::DoDataExchange(CDataExchange* pDX)
91 {
92         CPropertyPage::DoDataExchange(pDX);
93         //{{AFX_DATA_MAP(PropGeneral)
94         DDX_Check(pDX, IDC_SCROLL_CHECK, m_bScroll);
95         DDX_Check(pDX, IDC_SINGLE_INSTANCE, m_bSingleInstance);
96         DDX_Check(pDX, IDC_VERIFY_OPEN_PATHS, m_bVerifyPaths);
97         DDX_Check(pDX, IDC_ESC_CLOSES_WINDOW, m_bCloseWindowWithEsc);
98         DDX_Check(pDX, IDC_ASK_MULTIWINDOW_CLOSE, m_bAskMultiWindowClose);
99         DDX_CBIndex(pDX, IDC_AUTO_COMPLETE_SOURCE, m_nAutoCompleteSource);
100         DDX_Check(pDX, IDC_PRESERVE_FILETIME, m_bPreserveFiletime);
101         DDX_Check(pDX, IDC_STARTUP_FOLDER_SELECT, m_bShowSelectFolderOnStartup);
102         DDX_Check(pDX, IDC_CLOSE_WITH_OK, m_bCloseWithOK);
103         DDX_Control(pDX, IDC_LANGUAGE_LIST, m_ctlLangList);
104         //}}AFX_DATA_MAP
105 }
106
107
108 BEGIN_MESSAGE_MAP(PropGeneral, CPropertyPage)
109         //{{AFX_MSG_MAP(PropGeneral)
110         ON_BN_CLICKED(IDC_RESET_ALL_MESSAGE_BOXES, OnResetAllMessageBoxes)
111         //}}AFX_MSG_MAP
112 END_MESSAGE_MAP()
113
114 /** 
115  * @brief Reads options values from storage to UI.
116  */
117 void PropGeneral::ReadOptions()
118 {
119         m_bScroll = GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST);
120         m_bSingleInstance = GetOptionsMgr()->GetBool(OPT_SINGLE_INSTANCE);
121         m_bVerifyPaths = GetOptionsMgr()->GetBool(OPT_VERIFY_OPEN_PATHS);
122         m_bCloseWindowWithEsc = GetOptionsMgr()->GetBool(OPT_CLOSE_WITH_ESC);
123         m_bAskMultiWindowClose = GetOptionsMgr()->GetBool(OPT_ASK_MULTIWINDOW_CLOSE);
124         m_nAutoCompleteSource = GetOptionsMgr()->GetInt(OPT_AUTO_COMPLETE_SOURCE);
125         m_bPreserveFiletime = GetOptionsMgr()->GetBool(OPT_PRESERVE_FILETIMES);
126         m_bShowSelectFolderOnStartup = GetOptionsMgr()->GetBool(OPT_SHOW_SELECT_FILES_AT_STARTUP);
127         m_bCloseWithOK = GetOptionsMgr()->GetBool(OPT_CLOSE_WITH_OK);
128 }
129
130 /** 
131  * @brief Writes options values from UI to storage.
132  */
133 void PropGeneral::WriteOptions()
134 {
135         GetOptionsMgr()->SaveOption(OPT_SCROLL_TO_FIRST, m_bScroll == 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_AUTO_COMPLETE_SOURCE, m_nAutoCompleteSource);
141         GetOptionsMgr()->SaveOption(OPT_PRESERVE_FILETIMES, m_bPreserveFiletime);
142         GetOptionsMgr()->SaveOption(OPT_SHOW_SELECT_FILES_AT_STARTUP, m_bShowSelectFolderOnStartup);
143         GetOptionsMgr()->SaveOption(OPT_CLOSE_WITH_OK, m_bCloseWithOK);
144         int index = m_ctlLangList.GetCurSel();
145         if (index >= 0)
146         {
147                 WORD lang = (WORD)m_ctlLangList.GetItemData(index);
148                 GetOptionsMgr()->SaveOption(OPT_SELECTED_LANGUAGE, (int)lang);
149         }
150 }
151
152 /** 
153  * @brief Called when user wants to see all messageboxes again.
154  */
155 void PropGeneral::OnResetAllMessageBoxes()
156 {
157         CMessageBoxDialog::ResetMessageBoxes();
158         LangMessageBox(IDS_MESSAGE_BOX_ARE_RESET, MB_ICONINFORMATION);
159 }