1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997-2000 Thingamahoochie Software
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.
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.
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.
20 /////////////////////////////////////////////////////////////////////////////
24 * @brief Implementation file for PropGeneral propertyheet
29 #include "PropGeneral.h"
31 #include "OptionsDef.h"
32 #include "OptionsMgr.h"
33 #include "OptionsPanel.h"
34 #include "LanguageSelect.h"
39 static char THIS_FILE[] = __FILE__;
43 * @brief Constructor initialising members.
45 PropGeneral::PropGeneral(COptionsMgr *optionsMgr)
46 : OptionsPanel(optionsMgr, PropGeneral::IDD)
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)
59 PropGeneral::~PropGeneral()
63 BOOL PropGeneral::OnInitDialog()
65 theApp.TranslateDialog(m_hWnd);
66 CPropertyPage::OnInitDialog();
68 CComboBox *pWnd = (CComboBox*)GetDlgItem(IDC_AUTO_COMPLETE_SOURCE);
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());
75 pWnd->SetCurSel(m_nAutoCompleteSource);
77 m_ctlLangList.SetDroppedWidth(600);
79 for (auto&& i : theApp.m_pLangDlg->GetAvailableLanguages())
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);
87 return TRUE; // return TRUE unless you set the focus to a control
90 void PropGeneral::DoDataExchange(CDataExchange* pDX)
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);
108 BEGIN_MESSAGE_MAP(PropGeneral, CPropertyPage)
109 //{{AFX_MSG_MAP(PropGeneral)
110 ON_BN_CLICKED(IDC_RESET_ALL_MESSAGE_BOXES, OnResetAllMessageBoxes)
115 * @brief Reads options values from storage to UI.
117 void PropGeneral::ReadOptions()
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);
131 * @brief Writes options values from UI to storage.
133 void PropGeneral::WriteOptions()
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();
147 WORD lang = (WORD)m_ctlLangList.GetItemData(index);
148 GetOptionsMgr()->SaveOption(OPT_SELECTED_LANGUAGE, (int)lang);
153 * @brief Called when user wants to see all messageboxes again.
155 void PropGeneral::OnResetAllMessageBoxes()
157 CMessageBoxDialog::ResetMessageBoxes();
158 LangMessageBox(IDS_MESSAGE_BOX_ARE_RESET, MB_ICONINFORMATION);