Ask what file to save as, defaults to last view
[TortoiseGit.git] / src / TortoiseMerge / FindDlg.cpp
blob94e8e5930c1e6165813e16171dea1bafb0117e2f
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006, 2011-2013 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "TortoiseMerge.h"
21 #include "FindDlg.h"
24 // CFindDlg dialog
26 IMPLEMENT_DYNAMIC(CFindDlg, CDialog)
28 CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/)
29 : CDialog(CFindDlg::IDD, pParent)
30 , m_pParent(pParent)
31 , m_bTerminating(false)
32 , m_bFindNext(false)
33 , m_bMatchCase(FALSE)
34 , m_bLimitToDiffs(FALSE)
35 , m_bWholeWord(FALSE)
36 , m_FindMsg(0)
37 , m_regMatchCase(L"Software\\TortoiseGitMerge\\FindMatchCase", FALSE)
38 , m_regLimitToDiffs(L"Software\\TortoiseGitMerge\\FindLimitToDiffs", FALSE)
39 , m_regWholeWord(L"Software\\TortoiseGitMerge\\FindWholeWord", FALSE)
43 CFindDlg::~CFindDlg()
47 void CFindDlg::DoDataExchange(CDataExchange* pDX)
49 CDialog::DoDataExchange(pDX);
50 DDX_Check(pDX, IDC_MATCHCASE, m_bMatchCase);
51 DDX_Check(pDX, IDC_LIMITTODIFFS, m_bLimitToDiffs);
52 DDX_Check(pDX, IDC_WHOLEWORD, m_bWholeWord);
53 DDX_Control(pDX, IDC_FINDCOMBO, m_FindCombo);
57 BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
58 ON_CBN_EDITCHANGE(IDC_FINDCOMBO, &CFindDlg::OnCbnEditchangeFindcombo)
59 END_MESSAGE_MAP()
62 // CFindDlg message handlers
64 void CFindDlg::OnCancel()
66 m_bTerminating = true;
67 if (m_pParent)
68 m_pParent->SendMessage(m_FindMsg);
69 else if (GetParent())
70 GetParent()->SendMessage(m_FindMsg);
71 DestroyWindow();
74 void CFindDlg::PostNcDestroy()
76 delete this;
79 void CFindDlg::OnOK()
81 UpdateData();
82 m_FindCombo.SaveHistory();
83 m_regMatchCase = m_bMatchCase;
84 m_regLimitToDiffs = m_bLimitToDiffs;
85 m_regWholeWord = m_bWholeWord;
87 if (m_FindCombo.GetString().IsEmpty())
88 return;
89 m_bFindNext = true;
90 if (m_pParent)
91 m_pParent->SendMessage(m_FindMsg);
92 else if (GetParent())
93 GetParent()->SendMessage(m_FindMsg);
94 m_bFindNext = false;
97 BOOL CFindDlg::OnInitDialog()
99 CDialog::OnInitDialog();
100 m_FindMsg = RegisterWindowMessage(FINDMSGSTRING);
102 m_bMatchCase = (BOOL)(DWORD)m_regMatchCase;
103 m_bLimitToDiffs = (BOOL)(DWORD)m_regLimitToDiffs;
104 m_bWholeWord = (BOOL)(DWORD)m_regWholeWord;
105 UpdateData(FALSE);
107 m_FindCombo.DisableTrimming();
108 m_FindCombo.LoadHistory(_T("Software\\TortoiseGitMerge\\History\\Find"), _T("Search"));
109 m_FindCombo.SetCurSel(0);
111 m_FindCombo.SetFocus();
113 return FALSE;
116 void CFindDlg::OnCbnEditchangeFindcombo()
118 UpdateData();
119 GetDlgItem(IDOK)->EnableWindow(!m_FindCombo.GetString().IsEmpty());